This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 3da2a21710a466eb64bce5675a939736394aceb1 Author: Andreas Rheinhardt <[email protected]> AuthorDate: Wed Dec 10 21:38:29 2025 +0100 Commit: Andreas Rheinhardt <[email protected]> CommitDate: Sat Dec 13 05:57:47 2025 +0100 avcodec/hq_hqadata: Avoid relocations for HQProfiles Reviewed-by: Marton Balint <[email protected]> Reviewed-by: Lynne <[email protected]> Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavcodec/hq_hqa.c | 2 +- libavcodec/hq_hqadata.h | 167 +++++++++++++++++++++--------------------------- 2 files changed, 75 insertions(+), 94 deletions(-) diff --git a/libavcodec/hq_hqa.c b/libavcodec/hq_hqa.c index 664d10c1fc..94945a4040 100644 --- a/libavcodec/hq_hqa.c +++ b/libavcodec/hq_hqa.c @@ -168,7 +168,7 @@ static int hq_decode_frame(HQContext *ctx, AVFrame *pic, GetByteContext *gbc, slice_off[i] = bytestream2_get_be24u(gbc) - 4; next_off = 0; - const uint8_t *perm = profile->perm_tab; + const uint8_t *perm = hq_perms + profile->tab_offset; for (slice = 0; slice < profile->num_slices; slice++) { start_off = next_off; next_off = profile->tab_h * (slice + 1) / profile->num_slices; diff --git a/libavcodec/hq_hqadata.h b/libavcodec/hq_hqadata.h index 9c2c792c7f..75f9ab92c6 100644 --- a/libavcodec/hq_hqadata.h +++ b/libavcodec/hq_hqadata.h @@ -21,19 +21,13 @@ #ifndef AVCODEC_HQ_HQADATA_H #define AVCODEC_HQ_HQADATA_H +#include <assert.h> #include <stdint.h> #define NUM_HQ_AC_ENTRIES 747 // includes one invalid entry #define NUM_HQ_PROFILES 22 #define NUM_HQ_QUANTS 16 -typedef struct HQProfile { - const uint8_t *perm_tab; - int width, height; - int num_slices; - int tab_w, tab_h; -} HQProfile; - enum { QMAT00, QMAT01, @@ -1368,8 +1362,59 @@ static const uint8_t hq_ac_lens[NUM_HQ_AC_ENTRIES] = { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, }; +typedef struct HQProfile { + unsigned tab_offset; + int width, height; + int num_slices; + int tab_w, tab_h; +} HQProfile; + +/* List of profiles, order is important */ +#define HQPROFILES(M, DEF) \ + /* case 0 (default) = case 11*/\ + DEF(11,160, 120, 8, 10, 8) \ + M(1, 720, 480, 8, 25, 54) \ + M(2, 720, 486, 8, 15, 93) \ + M(3, 720, 576, 8, 20, 81) \ + M(4, 960, 720, 12, 25, 108) \ + M(5, 1280, 720, 16, 25, 144) \ + M(6, 1280, 1080, 16, 20, 272) \ + M(7, 1440, 1080, 16, 24, 255) \ + M(8, 1920, 1080, 20, 24, 340) \ + M(9, 640, 480, 8, 25, 48) \ + M(10, 320, 240, 8, 25, 12) \ + M(11, 160, 120, 8, 10, 8) \ + M(12, 800, 600, 8, 25, 76) \ + M(13, 352, 480, 8, 20, 33) \ + M(14, 352, 240, 8, 22, 15) \ + M(15, 352, 288, 8, 18, 22) \ + M(16, 176, 144, 8, 9, 11) \ + M(17, 1280, 1024, 16, 20, 256) \ + M(18, 1280, 960, 16, 25, 192) \ + M(19, 1024, 768, 16, 24, 128) \ + M(20, 704, 480, 8, 20, 66) \ + M(21, 704, 576, 8, 24, 66) \ + +#define OFFSET(PROFILE, W, H, NUM_SLICES, TAB_W, TAB_H) \ + PROFILE_ ## PROFILE ## _OFFSET, \ + PROFILE_ ## PROFILE ## _LAST = PROFILE_ ## PROFILE ## _OFFSET + TAB_W * TAB_H * 2 - 1, +#define NOTHING(PROFILE, W, H, NUM_SLICES, TAB_W, TAB_H) +enum { + HQPROFILES(OFFSET, NOTHING) + NUM_HQ_PERMS +}; + +#define HQPROFILE(PROFILE, W, H, NUM_SLICES, TAB_W, TAB_H) \ + { .tab_offset = PROFILE_ ## PROFILE ## _OFFSET, .width = W, .height = H, \ + .num_slices = NUM_SLICES, .tab_w = TAB_W, .tab_h = TAB_H }, + +static const HQProfile hq_profile[NUM_HQ_PROFILES] = { + HQPROFILES(HQPROFILE, HQPROFILE) +}; + /* tables section - one per supported profile */ -static const uint8_t hq_tab_01[] = { +static const uint8_t hq_perms[] = { + [PROFILE_1_OFFSET] = /* Profile 1 - 2700 elements */ 0, 0, 12, 3, 20, 0, 28, 3, 40, 0, 0, 10, 15, 6, 20, 10, 35, 6, 40, 10, 7, 13, 15, 16, 23, 13, 35, 16, 39, 13, 7, 23, 10, 19, 23, 23, 27, 20, 39, 23, 2, 26, 10, 29, 22, @@ -1550,9 +1595,7 @@ static const uint8_t hq_tab_01[] = { 0, 29, 3, 39, 0, 0, 9, 14, 6, 19, 10, 34, 6, 39, 10, 8, 13, 14, 16, 24, 13, 34, 16, 40, 13, 8, 23, 11, 19, 24, 23, 27, 19, 40, 23, 1, 26, 11, 29, 21, 26, 27, 29, 41, 26, -}; - -static const uint8_t hq_tab_02[] = { + [PROFILE_2_OFFSET] = /* Profile 2 - 2790 elements */ 0, 0, 12, 5, 20, 0, 28, 5, 40, 0, 3, 16, 17, 11, 23, 16, 33, 11, 43, 16, 1, 21, 14, 27, 18, 22, 30, 27, 38, 22, 1, 0, 11, 5, 21, 0, 27, 5, 41, 0, 4, 16, 16, 11, 24, @@ -1739,9 +1782,7 @@ static const uint8_t hq_tab_02[] = { 16, 35, 11, 41, 16, 3, 21, 16, 27, 19, 21, 32, 27, 36, 22, 2, 10, 13, 5, 19, 0, 29, 5, 39, 0, 2, 16, 17, 10, 22, 16, 34, 11, 42, 16, 2, 21, 15, 27, 18, 21, 31, 27, 37, 22, -}; - -static const uint8_t hq_tab_03[] = { + [PROFILE_3_OFFSET] = /* Profile 3 - 3240 elements */ 0, 0, 14, 4, 20, 0, 34, 4, 40, 0, 8, 14, 15, 9, 24, 14, 35, 9, 40, 14, 7, 19, 11, 23, 23, 19, 27, 23, 39, 19, 1, 33, 10, 28, 21, 33, 27, 29, 41, 33, 1, 0, 15, 4, 21, @@ -1958,9 +1999,7 @@ static const uint8_t hq_tab_03[] = { 33, 28, 28, 39, 33, 8, 8, 13, 4, 19, 0, 33, 4, 39, 0, 8, 13, 14, 9, 25, 14, 34, 9, 41, 14, 8, 19, 12, 23, 24, 19, 28, 23, 40, 19, 0, 33, 11, 28, 20, 33, 27, 28, 40, 33, -}; - -static const uint8_t hq_tab_04[] = { + [PROFILE_4_OFFSET] = /* Profile 4 - 5400 elements */ 0, 0, 19, 4, 26, 0, 45, 4, 52, 0, 11, 13, 18, 9, 34, 14, 44, 9, 56, 14, 10, 18, 18, 23, 35, 19, 40, 23, 57, 19, 2, 32, 19, 28, 24, 32, 41, 28, 49, 33, 3, 37, 15, 42, 25, @@ -2321,9 +2360,7 @@ static const uint8_t hq_tab_04[] = { 0, 44, 4, 51, 0, 10, 13, 17, 9, 35, 14, 43, 9, 57, 14, 9, 18, 19, 23, 35, 18, 41, 23, 58, 19, 3, 32, 20, 28, 25, 32, 42, 28, 48, 33, 4, 37, 14, 42, 26, 37, 40, 42, 48, 37, -}; - -static const uint8_t hq_tab_05[] = { + [PROFILE_5_OFFSET] = /* Profile 5 - 7200 elements */ 0, 0, 25, 4, 34, 0, 59, 4, 68, 0, 13, 13, 22, 9, 47, 13, 56, 9, 78, 14, 10, 18, 28, 23, 44, 18, 58, 23, 78, 18, 8, 32, 31, 28, 38, 32, 61, 28, 68, 32, 11, 37, 18, 41, 41, @@ -2804,9 +2841,7 @@ static const uint8_t hq_tab_05[] = { 0, 58, 4, 67, 0, 12, 13, 21, 9, 46, 13, 55, 9, 79, 14, 9, 18, 29, 23, 43, 18, 59, 23, 77, 18, 9, 32, 31, 27, 39, 32, 62, 28, 69, 32, 12, 37, 19, 41, 42, 37, 49, 41, 72, 37, -}; - -static const uint8_t hq_tab_06[] = { + [PROFILE_6_OFFSET] = /* Profile 6 - 10880 elements */ 0, 0, 25, 8, 34, 0, 59, 8, 68, 0, 13, 25, 22, 17, 47, 25, 56, 17, 78, 26, 10, 34, 28, 43, 44, 34, 58, 43, 78, 34, 8, 60, 31, 52, 38, 60, 61, 52, 68, 60, 1, 0, 26, 8, 35, @@ -3533,9 +3568,7 @@ static const uint8_t hq_tab_06[] = { 0, 58, 8, 67, 0, 12, 25, 21, 17, 46, 25, 55, 17, 79, 26, 9, 34, 29, 43, 43, 34, 59, 43, 77, 34, 9, 60, 31, 51, 39, 60, 62, 52, 69, 60, -}; - -static const uint8_t hq_tab_07[] = { + [PROFILE_7_OFFSET] = /* Profile 7 - 12240 elements */ 0, 0, 23, 8, 32, 0, 55, 8, 64, 0, 87, 8, 13, 25, 22, 17, 44, 26, 54, 17, 72, 26, 86, 17, 12, 34, 24, 43, 44, 34, 52, 43, 73, 35, 80, 43, 4, 60, 25, 52, 32, 60, 53, 52, 60, @@ -4352,9 +4385,7 @@ static const uint8_t hq_tab_07[] = { 8, 31, 0, 54, 8, 63, 0, 86, 8, 12, 25, 21, 17, 44, 25, 53, 17, 73, 26, 85, 17, 11, 34, 25, 43, 43, 34, 53, 43, 74, 35, 81, 43, 5, 60, 26, 52, 33, 60, 54, 52, 61, 60, 82, 52, -}; - -static const uint8_t hq_tab_08[] = { + [PROFILE_8_OFFSET] = /* Profile 8 - 16320 elements */ 0, 0, 31, 8, 42, 0, 73, 8, 84, 0, 115, 8, 16, 25, 27, 17, 58, 25, 69, 17, 99, 26, 111, 17, 12, 34, 36, 43, 54, 34, 74, 43, 96, 34, 112, 43, 11, 60, 39, 51, 49, 60, 78, 52, 87, @@ -5443,9 +5474,7 @@ static const uint8_t hq_tab_08[] = { 8, 41, 0, 72, 8, 83, 0, 114, 8, 15, 25, 26, 17, 57, 25, 68, 17, 99, 25, 110, 17, 11, 34, 37, 43, 53, 34, 75, 43, 95, 34, 113, 43, 12, 60, 38, 51, 50, 60, 79, 52, 88, 60, 117, 52, -}; - -static const uint8_t hq_tab_09[] = { + [PROFILE_9_OFFSET] = /* Profile 9 - 2400 elements */ 0, 0, 10, 3, 18, 0, 24, 3, 36, 0, 1, 10, 14, 6, 19, 10, 31, 7, 37, 10, 5, 13, 15, 16, 19, 13, 30, 17, 33, 13, 4, 23, 8, 20, 18, 23, 26, 20, 32, 23, 4, 26, 9, 24, 22, @@ -5606,9 +5635,7 @@ static const uint8_t hq_tab_09[] = { 0, 25, 3, 35, 0, 0, 10, 13, 6, 18, 10, 31, 6, 36, 10, 6, 13, 14, 16, 20, 13, 31, 17, 34, 13, 5, 23, 8, 19, 19, 23, 25, 20, 33, 23, 3, 26, 8, 24, 21, 26, 26, 24, 39, 26, -}; - -static const uint8_t hq_tab_10[] = { + [PROFILE_10_OFFSET] = /* Profile 10 - 600 elements */ 0, 0, 4, 1, 10, 0, 13, 2, 19, 1, 0, 5, 6, 4, 10, 3, 15, 5, 16, 3, 2, 8, 6, 7, 8, 6, 12, 7, 18, 6, 2, 11, 4, 10, 8, 11, 14, 10, 18, 9, 0, 14, 7, 12, 10, @@ -5649,9 +5676,7 @@ static const uint8_t hq_tab_10[] = { 0, 12, 2, 19, 0, 1, 5, 5, 4, 11, 3, 15, 4, 17, 3, 1, 8, 7, 7, 11, 8, 13, 7, 17, 6, 3, 11, 4, 9, 9, 11, 13, 10, 19, 9, 0, 13, 6, 12, 9, 14, 15, 13, 19, 14, -}; - -static const uint8_t hq_tab_11[] = { + [PROFILE_11_OFFSET] = /* Profile 11 - 160 elements */ 0, 0, 3, 3, 5, 1, 6, 0, 8, 2, 1, 5, 3, 7, 4, 6, 6, 4, 9, 7, 1, 0, 2, 3, 4, 1, 7, 0, 9, 2, 0, 5, 2, 7, 5, 6, 7, 4, 8, 7, 1, 1, 2, 0, 4, @@ -5663,9 +5688,7 @@ static const uint8_t hq_tab_11[] = { 1, 3, 2, 2, 4, 0, 7, 3, 9, 1, 0, 4, 2, 6, 5, 5, 7, 7, 8, 6, 0, 3, 3, 2, 5, 0, 6, 3, 8, 1, 1, 4, 3, 6, 4, 5, 6, 7, 9, 6, -}; - -static const uint8_t hq_tab_12[] = { + [PROFILE_12_OFFSET] = /* Profile 12 - 3800 elements */ 0, 0, 13, 3, 22, 0, 31, 3, 44, 0, 3, 11, 12, 8, 21, 11, 34, 8, 40, 12, 2, 16, 11, 19, 24, 16, 30, 20, 46, 16, 1, 27, 14, 24, 20, 28, 36, 24, 42, 28, 4, 32, 10, 36, 26, @@ -5920,9 +5943,7 @@ static const uint8_t hq_tab_12[] = { 11, 33, 8, 40, 11, 1, 16, 12, 19, 23, 16, 30, 19, 45, 16, 2, 27, 13, 24, 20, 27, 35, 24, 41, 28, 3, 32, 10, 35, 25, 32, 31, 36, 47, 32, -}; - -static const uint8_t hq_tab_13[] = { + [PROFILE_13_OFFSET] = /* Profile 13 - 1320 elements */ 0, 0, 15, 1, 7, 4, 18, 3, 4, 6, 11, 7, 10, 11, 14, 9, 8, 12, 14, 14, 6, 17, 11, 16, 9, 19, 18, 20, 2, 23, 15, 22, 5, 25, 11, 24, 9, 27, 19, 28, 1, 0, 14, 1, 8, @@ -6011,9 +6032,7 @@ static const uint8_t hq_tab_13[] = { 26, 0, 29, 17, 28, 10, 2, 16, 1, 6, 4, 19, 3, 3, 6, 12, 7, 10, 10, 15, 9, 7, 12, 13, 14, 7, 17, 11, 15, 10, 19, 17, 20, 3, 23, 14, 22, 6, 25, 21, 26, 10, 27, 18, 28, -}; - -static const uint8_t hq_tab_14[] = { + [PROFILE_14_OFFSET] = /* Profile 14 - 660 elements */ 0, 0, 17, 0, 0, 2, 14, 1, 9, 3, 14, 3, 9, 5, 19, 4, 2, 6, 19, 6, 9, 6, 12, 7, 7, 9, 16, 8, 0, 9, 15, 9, 10, 11, 15, 11, 10, 13, 18, 12, 1, 14, 18, 14, 1, @@ -6058,9 +6077,7 @@ static const uint8_t hq_tab_14[] = { 14, 7, 1, 16, 0, 0, 1, 15, 1, 10, 3, 15, 3, 10, 5, 18, 4, 1, 6, 18, 6, 1, 8, 13, 7, 8, 9, 15, 8, 1, 9, 20, 10, 10, 10, 16, 11, 10, 12, 17, 12, 0, 14, 17, 14, -}; - -static const uint8_t hq_tab_15[] = { + [PROFILE_15_OFFSET] = /* Profile 15 - 792 elements */ 0, 0, 15, 1, 3, 3, 14, 2, 4, 4, 11, 5, 0, 6, 18, 6, 8, 8, 14, 8, 4, 10, 21, 11, 9, 13, 18, 12, 8, 14, 17, 15, 5, 17, 21, 17, 1, 0, 14, 1, 2, 3, 15, 2, 5, @@ -6114,9 +6131,7 @@ static const uint8_t hq_tab_15[] = { 19, 15, 7, 17, 20, 16, 0, 1, 16, 1, 4, 3, 13, 2, 3, 4, 12, 5, 0, 7, 17, 6, 7, 8, 13, 8, 3, 10, 21, 10, 10, 13, 17, 12, 7, 14, 18, 15, 6, 17, 21, 16, -}; - -static const uint8_t hq_tab_16[] = { + [PROFILE_16_OFFSET] = /* Profile 16 - 198 elements */ 0, 0, 4, 1, 2, 2, 2, 3, 4, 4, 0, 5, 6, 6, 9, 7, 8, 8, 1, 0, 3, 1, 3, 2, 1, 3, 5, 4, 10, 5, 7, 6, 8, 7, 9, 8, 2, 0, 2, 1, 4, 2, 0, 3, 6, @@ -6131,9 +6146,7 @@ static const uint8_t hq_tab_16[] = { 1, 0, 2, 4, 3, 2, 4, 2, 5, 4, 6, 0, 7, 6, 8, 10, 0, 5, 1, 1, 2, 3, 3, 3, 4, 1, 5, 5, 6, 10, 7, 7, 8, -}; - -static const uint8_t hq_tab_17[] = { + [PROFILE_17_OFFSET] = /* Profile 17 - 10240 elements */ 0, 0, 25, 8, 34, 0, 59, 8, 68, 0, 13, 24, 22, 16, 47, 24, 56, 16, 78, 25, 10, 32, 28, 41, 44, 32, 58, 41, 78, 32, 8, 57, 31, 49, 38, 57, 61, 49, 68, 57, 1, 0, 26, 8, 35, @@ -6817,9 +6830,7 @@ static const uint8_t hq_tab_17[] = { 0, 15, 24, 8, 33, 0, 58, 8, 67, 0, 12, 24, 21, 16, 46, 24, 55, 16, 79, 25, 9, 32, 29, 41, 43, 32, 59, 41, 77, 32, 9, 57, 31, 48, 39, 57, 62, 49, 69, 57, -}; - -static const uint8_t hq_tab_18[] = { + [PROFILE_18_OFFSET] = /* Profile 18 - 9600 elements */ 0, 0, 25, 6, 34, 0, 59, 6, 68, 0, 13, 18, 22, 12, 47, 18, 56, 12, 78, 19, 10, 24, 28, 31, 44, 24, 58, 31, 78, 24, 8, 43, 31, 37, 38, 43, 61, 37, 68, 43, 11, 49, 18, 55, 41, @@ -7460,9 +7471,7 @@ static const uint8_t hq_tab_18[] = { 0, 58, 6, 67, 0, 12, 18, 21, 12, 46, 18, 55, 12, 79, 19, 9, 24, 29, 31, 43, 24, 59, 31, 77, 24, 9, 43, 31, 36, 39, 43, 62, 37, 69, 43, 12, 49, 19, 55, 42, 49, 49, 55, 72, 49, -}; - -static const uint8_t hq_tab_19[] = { + [PROFILE_19_OFFSET] = /* Profile 19 - 6144 elements */ 0, 0, 25, 4, 34, 0, 59, 4, 12, 12, 21, 8, 46, 12, 55, 8, 8, 16, 30, 21, 42, 16, 60, 21, 11, 29, 29, 24, 41, 29, 63, 24, 15, 33, 22, 37, 45, 33, 52, 37, 3, 45, 26, 41, 33, @@ -7873,9 +7882,7 @@ static const uint8_t hq_tab_19[] = { 12, 20, 8, 45, 12, 54, 8, 7, 16, 31, 21, 41, 16, 61, 21, 12, 29, 28, 24, 42, 29, 62, 24, 15, 32, 23, 37, 46, 33, 53, 37, 4, 45, 27, 41, 34, 45, 57, 41, -}; - -static const uint8_t hq_tab_20[] = { + [PROFILE_20_OFFSET] = /* Profile 20 - 2640 elements */ 0, 0, 15, 3, 24, 0, 35, 3, 1, 9, 16, 6, 22, 10, 40, 6, 8, 12, 14, 16, 32, 12, 38, 16, 6, 22, 19, 19, 30, 22, 39, 19, 5, 25, 21, 29, 25, 25, 41, 29, 1, 0, 14, 3, 25, @@ -8052,9 +8059,7 @@ static const uint8_t hq_tab_20[] = { 28, 27, 25, 43, 29, 0, 5, 16, 3, 23, 0, 36, 3, 2, 9, 15, 6, 22, 9, 39, 6, 7, 12, 13, 16, 31, 12, 37, 16, 5, 22, 20, 19, 29, 22, 40, 19, 6, 25, 21, 28, 26, 25, 42, 29, -}; - -static const uint8_t hq_tab_21[] = { + [PROFILE_21_OFFSET] = /* Profile 21 - 3168 elements */ 0, 0, 15, 3, 24, 0, 35, 3, 1, 9, 16, 6, 22, 10, 40, 6, 8, 12, 14, 16, 32, 12, 38, 16, 6, 22, 19, 19, 30, 22, 39, 19, 5, 25, 21, 29, 25, 25, 41, 29, 7, 35, 11, 31, 27, @@ -8269,30 +8274,6 @@ static const uint8_t hq_tab_21[] = { 35, 33, 32, }; -/* List of profiles, order is important */ -static const HQProfile hq_profile[NUM_HQ_PROFILES] = { - { hq_tab_11, 160, 120, 8, 10, 8 }, // case 0 (default) = case 11 - { hq_tab_01, 720, 480, 8, 25, 54 }, - { hq_tab_02, 720, 486, 8, 15, 93 }, - { hq_tab_03, 720, 576, 8, 20, 81 }, - { hq_tab_04, 960, 720, 12, 25, 108 }, - { hq_tab_05, 1280, 720, 16, 25, 144 }, - { hq_tab_06, 1280, 1080, 16, 20, 272 }, - { hq_tab_07, 1440, 1080, 16, 24, 255 }, - { hq_tab_08, 1920, 1080, 20, 24, 340 }, - { hq_tab_09, 640, 480, 8, 25, 48 }, - { hq_tab_10, 320, 240, 8, 25, 12 }, - { hq_tab_11, 160, 120, 8, 10, 8 }, - { hq_tab_12, 800, 600, 8, 25, 76 }, - { hq_tab_13, 352, 480, 8, 20, 33 }, - { hq_tab_14, 352, 240, 8, 22, 15 }, - { hq_tab_15, 352, 288, 8, 18, 22 }, - { hq_tab_16, 176, 144, 8, 9, 11 }, - { hq_tab_17, 1280, 1024, 16, 20, 256 }, - { hq_tab_18, 1280, 960, 16, 25, 192 }, - { hq_tab_19, 1024, 768, 16, 24, 128 }, - { hq_tab_20, 704, 480, 8, 20, 66 }, - { hq_tab_21, 704, 576, 8, 24, 66 }, -}; +static_assert(sizeof(hq_perms) == NUM_HQ_PERMS, "Inconsistent offsets"); #endif /* AVCODEC_HQ_HQADATA_H */ _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
