diff mbox series

[FFmpeg-devel,07/30] avcodec/truemotion1data: Avoid indirection for delta-table init

Message ID 20201230233157.1055287-7-andreas.rheinhardt@gmail.com
State New
Headers show
Series [FFmpeg-devel,01/30] avcodec/opustab: Make array static
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Dec. 30, 2020, 11:31 p.m. UTC
Up until arrays of pointers to other arrays have been used, yet these
other arrays all have the same number of elements and the same
underlying type, so one can use an array of arrays. This also avoids
relocations.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
On 64bit systems it would also make sense to transform the fat tables.

 libavcodec/truemotion1data.h | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/truemotion1data.h b/libavcodec/truemotion1data.h
index 3e581434e4..f432d87d08 100644
--- a/libavcodec/truemotion1data.h
+++ b/libavcodec/truemotion1data.h
@@ -29,25 +29,28 @@ 
 #include <stdlib.h>
 
 /* Y delta tables, skinny and fat */
-static const int16_t ydt1[8] = { 0, -2, 2, -6, 6, -12, 12, -12 };
-static const int16_t ydt2[8] = { 0, -2, 4, -6, 8, -12, 12, -12 };
-static const int16_t ydt3[8] = { 4, -6, 20, -20, 46, -46, 94, -94 };
+static const int16_t ydts[][8] = {
+    { 0, -2,  2,  -6,  6, -12, 12, -12 },
+    { 0, -2,  4,  -6,  8, -12, 12, -12 },
+    { 4, -6, 20, -20, 46, -46, 94, -94 },
+    { 0, -4,  4, -16, 16, -36, 36, -80 },
+};
 static const int16_t fat_ydt3[8] = { 0, -15, 50, -50, 115, -115, 235, -235 };
-static const int16_t ydt4[8] = { 0, -4, 4, -16, 16, -36, 36, -80 };
 /* NOTE: This table breaks the [+,-] pattern that the rest of the
  * tables maintain. Is this intentional? */
 static const int16_t fat_ydt4[8] = { 0, 40, 80, -76, 160, -154, 236, -236 };
 
 /* C delta tables, skinny and fat */
-static const int16_t cdt1[8] = { 0, -1, 1, -2, 3, -4, 5, -4 };
-static const int16_t cdt2[8] = { 0, -4, 3, -16, 20, -32, 36, -32 };
+static const int16_t cdts[][8] = {
+    { 0, -1,  1,  -2,  3,  -4,  5,  -4 },
+    { 0, -1,  1,  -2,  3,  -4,  5,  -4 }, // Same as above
+    { 0, -4,  3, -16, 20, -32, 36, -32 },
+    { 0, -2,  2,  -8,  8, -18, 18, -40 },
+};
 static const int16_t fat_cdt2[8] = { 0, -20, 15, -80, 100, -160, 180, -160 };
-static const int16_t cdt3[8] = { 0, -2, 2, -8, 8, -18, 18, -40 };
 
-/* all the delta tables to choose from, at all 4 delta levels */
-static const int16_t * const ydts[] = { ydt1, ydt2, ydt3, ydt4, NULL };
+/* Fat delta tables to choose from, at all 4 delta levels */
 static const int16_t * const fat_ydts[] = { fat_ydt3, fat_ydt3, fat_ydt3, fat_ydt4, NULL };
-static const int16_t * const cdts[] = { cdt1, cdt1, cdt2, cdt3, NULL };
 static const int16_t * const fat_cdts[] = { fat_cdt2, fat_cdt2, fat_cdt2, fat_ydt4, NULL };
 
 static const uint8_t pc_tbl2[] = {