huffyuvdec: Skip len==0 cases

Fixes vlc decoding for hypothetical files that would contain such cases.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 0dfc01c2bb)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 5ff41ffeb4cb9ea6df49757dc859619dc3d3ab4f)

Conflicts:

	libavcodec/huffyuv.c
(cherry picked from commit 9bc70fe1ae50fd2faa0b9429d47cfbda01a92ebc)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-01-29 19:22:33 +01:00
parent a7faa1d070
commit a77cf47d88
1 changed files with 5 additions and 5 deletions

View File

@ -279,11 +279,11 @@ static void generate_joint_tables(HYuvContext *s){
for(i=y=0; y<256; y++){ for(i=y=0; y<256; y++){
int len0 = s->len[0][y]; int len0 = s->len[0][y];
int limit = VLC_BITS - len0; int limit = VLC_BITS - len0;
if(limit <= 0) if(limit <= 0 || !len0)
continue; continue;
for(u=0; u<256; u++){ for(u=0; u<256; u++){
int len1 = s->len[p][u]; int len1 = s->len[p][u];
if(len1 > limit) if (len1 > limit || !len1)
continue; continue;
assert(i < (1 << VLC_BITS)); assert(i < (1 << VLC_BITS));
len[i] = len0 + len1; len[i] = len0 + len1;
@ -307,17 +307,17 @@ static void generate_joint_tables(HYuvContext *s){
for(i=0, g=-16; g<16; g++){ for(i=0, g=-16; g<16; g++){
int len0 = s->len[p0][g&255]; int len0 = s->len[p0][g&255];
int limit0 = VLC_BITS - len0; int limit0 = VLC_BITS - len0;
if(limit0 < 2) if (limit0 < 2 || !len0)
continue; continue;
for(b=-16; b<16; b++){ for(b=-16; b<16; b++){
int len1 = s->len[p1][b&255]; int len1 = s->len[p1][b&255];
int limit1 = limit0 - len1; int limit1 = limit0 - len1;
if(limit1 < 1) if (limit1 < 1 || !len1)
continue; continue;
code = (s->bits[p0][g&255] << len1) + s->bits[p1][b&255]; code = (s->bits[p0][g&255] << len1) + s->bits[p1][b&255];
for(r=-16; r<16; r++){ for(r=-16; r<16; r++){
int len2 = s->len[2][r&255]; int len2 = s->len[2][r&255];
if(len2 > limit1) if (len2 > limit1 || !len2)
continue; continue;
assert(i < (1 << VLC_BITS)); assert(i < (1 << VLC_BITS));
len[i] = len0 + len1 + len2; len[i] = len0 + len1 + len2;