mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avcodec/speedhqenc: Hardcode table to save space
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.rheinhardt@gmail.com>
This commit is contained in:
parent
b05631f7b9
commit
03008c2811
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user