The SpeedHQ encoder currently reverses the entries of two small tables and stores them in other tables. These other tables have a size of 48 bytes, yet the code for their initialization takes 135 bytes (GCC 9.3, x64, O3 albeit in an av_cold function). So remove the runtime initialization and hardcode the tables.
Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@gmail.com> --- libavcodec/speedhqenc.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c index dbc638cb82..abad87632f 100644 --- a/libavcodec/speedhqenc.c +++ b/libavcodec/speedhqenc.c @@ -38,8 +38,13 @@ extern RLTable ff_rl_speedhq; static uint8_t speedhq_static_rl_table_store[2][2*MAX_RUN + MAX_LEVEL + 3]; -static uint16_t mpeg12_vlc_dc_lum_code_reversed[12]; -static uint16_t mpeg12_vlc_dc_chroma_code_reversed[12]; +/* Exactly the same as MPEG-2, except little-endian. */ +static const uint16_t mpeg12_vlc_dc_lum_code_reversed[12] = { + 0x1, 0x0, 0x2, 0x5, 0x3, 0x7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, 0x1FF +}; +static const uint16_t mpeg12_vlc_dc_chroma_code_reversed[12] = { + 0x0, 0x2, 0x1, 0x3, 0x7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, 0x1FF, 0x3FF +}; /* simple include everything table for dc, first byte is bits * number next 3 are code */ @@ -48,30 +53,8 @@ static uint32_t speedhq_chr_dc_uni[512]; static uint8_t uni_speedhq_ac_vlc_len[64 * 64 * 2]; -static uint32_t reverse(uint32_t num, int bits) -{ - return bitswap_32(num) >> (32 - bits); -} - -static void reverse_code(const uint16_t *code, const uint8_t *bits, - uint16_t *reversed_code, int num_entries) -{ - for (int i = 0; i < num_entries; i++) - reversed_code[i] = reverse(code[i], bits[i]); -} - static av_cold void speedhq_init_static_data(void) { - /* Exactly the same as MPEG-2, except little-endian. */ - reverse_code(ff_mpeg12_vlc_dc_lum_code, - ff_mpeg12_vlc_dc_lum_bits, - mpeg12_vlc_dc_lum_code_reversed, - 12); - reverse_code(ff_mpeg12_vlc_dc_chroma_code, - ff_mpeg12_vlc_dc_chroma_bits, - mpeg12_vlc_dc_chroma_code_reversed, - 12); - ff_rl_init(&ff_rl_speedhq, speedhq_static_rl_table_store); /* build unified dc encoding tables */ -- 2.25.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".