1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-13 21:28:01 +02:00

avcodec/speedhqenc: Avoid unnecessary indirection

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2022-10-22 00:39:13 +02:00
parent 19ede649a0
commit 18412c76e6
3 changed files with 13 additions and 6 deletions

View File

@ -24,7 +24,7 @@
#include "speedhq.h"
/* AC codes: Very similar but not identical to MPEG-2. */
static const uint16_t speedhq_vlc[123][2] = {
const uint16_t ff_speedhq_vlc_table[SPEEDHQ_RL_NB_ELEMS + 2][2] = {
{0x0001, 2}, {0x0003, 3}, {0x000E, 4}, {0x0007, 5},
{0x0017, 5}, {0x0028, 6}, {0x0008, 6}, {0x006F, 7},
{0x001F, 7}, {0x00C4, 8}, {0x0044, 8}, {0x005F, 8},
@ -101,7 +101,7 @@ static const uint8_t speedhq_run[121] = {
RLTable ff_rl_speedhq = {
121,
121,
speedhq_vlc,
ff_speedhq_vlc_table,
speedhq_run,
speedhq_level,
};

View File

@ -21,9 +21,16 @@
#ifndef AVCODEC_SPEEDHQ_H
#define AVCODEC_SPEEDHQ_H
#include <stdint.h>
#include "rl.h"
#include "libavutil/attributes_internal.h"
#define SPEEDHQ_RL_NB_ELEMS 121
FF_VISIBILITY_PUSH_HIDDEN
extern const uint16_t ff_speedhq_vlc_table[SPEEDHQ_RL_NB_ELEMS + 2][2];
extern RLTable attribute_visibility_hidden ff_rl_speedhq;
FF_VISIBILITY_POP_HIDDEN
#endif /* AVCODEC_SPEEDHQ_H */

View File

@ -222,11 +222,11 @@ static void encode_block(MpegEncContext *s, int16_t *block, int n)
if (alevel <= ff_rl_speedhq.max_level[0][run]) {
code = ff_rl_speedhq.index_run[0][run] + alevel - 1;
/* store the VLC & sign at once */
put_bits_le(&s->pb, ff_rl_speedhq.table_vlc[code][1] + 1,
ff_rl_speedhq.table_vlc[code][0] + (sign << ff_rl_speedhq.table_vlc[code][1]));
put_bits_le(&s->pb, ff_speedhq_vlc_table[code][1] + 1,
ff_speedhq_vlc_table[code][0] | (sign << ff_speedhq_vlc_table[code][1]));
} else {
/* escape seems to be pretty rare <5% so I do not optimize it;
* the values correspond to ff_rl_speedhq.table_vlc[121] */
* the values correspond to ff_speedhq_vlc_table[121] */
put_bits_le(&s->pb, 6, 32);
/* escape: only clip in this case */
put_bits_le(&s->pb, 6, run);
@ -235,7 +235,7 @@ static void encode_block(MpegEncContext *s, int16_t *block, int n)
last_non_zero = i;
}
}
/* end of block; the values correspond to ff_rl_speedhq.table_vlc[122] */
/* end of block; the values correspond to ff_speedhq_vlc_table[122] */
put_bits_le(&s->pb, 4, 6);
}