summaryrefslogtreecommitdiff
path: root/libavcodec/motionpixels.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-10-29 10:56:32 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-11-24 11:35:03 +0100
commitcc18bcdd5204feff6724486f72fafcad15640362 (patch)
tree87d6201dffa5a1469c8a4155119e3c396466c449 /libavcodec/motionpixels.c
parentd3fba7480302ada9d75575ff6892fdbb9318f1ea (diff)
downloadffmpeg-cc18bcdd5204feff6724486f72fafcad15640362.tar.gz
avcodec/motionpixels: Use symbols table
If allows us to directly store the deltas in the VLC table and therefore avoids a level of indirection. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/motionpixels.c')
-rw-r--r--libavcodec/motionpixels.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c
index a65250efe5..927f9fdc14 100644
--- a/libavcodec/motionpixels.c
+++ b/libavcodec/motionpixels.c
@@ -192,10 +192,8 @@ static void mp_set_rgb_from_yuv(MotionPixelsContext *mp, int x, int y, const Yuv
static av_always_inline int mp_get_vlc(MotionPixelsContext *mp, GetBitContext *gb)
{
- int i;
-
- i = (mp->codes_count == 1) ? 0 : get_vlc2(gb, mp->vlc.table, mp->max_codes_bits, 1);
- return mp->codes[i].delta;
+ return mp->vlc.table ? get_vlc2(gb, mp->vlc.table, mp->max_codes_bits, 1)
+ : mp->codes[0].delta;
}
static void mp_decode_line(MotionPixelsContext *mp, GetBitContext *gb, int y)
@@ -322,9 +320,14 @@ static int mp_decode_frame(AVCodecContext *avctx,
if (sz == 0)
goto end;
- if (mp->codes_count > 1)
- if (init_vlc(&mp->vlc, mp->max_codes_bits, mp->codes_count, &mp->codes[0].size, sizeof(HuffCode), 1, &mp->codes[0].code, sizeof(HuffCode), 4, 0))
- goto end;
+ if (mp->codes_count > 1) {
+ ret = ff_init_vlc_sparse(&mp->vlc, mp->max_codes_bits, mp->codes_count,
+ &mp->codes[0].size, sizeof(HuffCode), 1,
+ &mp->codes[0].code, sizeof(HuffCode), 4,
+ &mp->codes[0].delta, sizeof(HuffCode), 1, 0);
+ if (ret < 0)
+ goto end;
+ }
mp_decode_frame_helper(mp, &gb);
ff_free_vlc(&mp->vlc);