summaryrefslogtreecommitdiff
path: root/libavcodec/huffyuvdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-01-26 19:53:14 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-01-26 19:59:57 +0100
commite6c0da70fc82d7af4e730c901e8e0ccd87b37060 (patch)
tree5072a5fa192572c573796e3a1b60c6cfddcfef31 /libavcodec/huffyuvdec.c
parent37baa2af43a052803fad7dc57a6b5b3449645670 (diff)
avcodec/huffyuvdec: optimize >8bps VLC reading
97479 -> 54891 decicycles Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/huffyuvdec.c')
-rw-r--r--libavcodec/huffyuvdec.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c
index 699a3eb744..16cf275247 100644
--- a/libavcodec/huffyuvdec.c
+++ b/libavcodec/huffyuvdec.c
@@ -125,14 +125,18 @@ static int generate_joint_tables(HYuvContext *s)
int limit = VLC_BITS - len0;
if(limit <= 0 || !len0)
continue;
+ if((sign_extend(y, 8) & (s->vlc_n-1)) != y)
+ continue;
for (u = 0; u < s->vlc_n; u++) {
int len1 = s->len[p][u];
if (len1 > limit || !len1)
continue;
+ if((sign_extend(u, 8) & (s->vlc_n-1)) != u)
+ continue;
av_assert0(i < (1 << VLC_BITS));
len[i] = len0 + len1;
bits[i] = (s->bits[p0][y] << len1) + s->bits[p][u];
- symbols[i] = (y << 8) + u; //FIXME
+ symbols[i] = (y << 8) + (u & 0xFF);
if(symbols[i] != 0xffff) // reserved to mean "invalid"
i++;
}
@@ -581,8 +585,14 @@ static void decode_422_bitstream(HYuvContext *s, int count)
}\
}
#define READ_2PIX_PLANE14(dst0, dst1, plane){\
- dst0 = get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3);\
- dst1 = get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3);\
+ int16_t code = get_vlc2(&s->gb, s->vlc[4+plane].table, VLC_BITS, 1);\
+ if(code != (int16_t)0xffff){\
+ dst0 = code>>8;\
+ dst1 = sign_extend(code, 8);\
+ }else{\
+ dst0 = get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3);\
+ dst1 = get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3);\
+ }\
}
#define READ_2PIX_PLANE16(dst0, dst1, plane){\