Commit ce3bcaed authored by Michael Niedermayer's avatar Michael Niedermayer

fixing illegal 3. esc bug (the mpeg4 std only requires encoders to use...

fixing illegal 3. esc bug (the mpeg4 std only requires encoders to use unescaped symbols but not esc1 or esc2 if they are shorter than esc3, andjust beause its logical to use the shortest possible vlc doesnt mean encoders do that)

Originally committed as revision 1304 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent dc172cc1
...@@ -548,12 +548,16 @@ typedef struct AVCodecContext { ...@@ -548,12 +548,16 @@ typedef struct AVCodecContext {
float b_quant_offset; float b_quant_offset;
/** /**
* error resilience {-1,0,1} higher values will detect more errors but may missdetect * error resilience higher values will detect more errors but may missdetect
* some more or less valid parts as errors * some more or less valid parts as errors
* encoding: unused * encoding: unused
* decoding: set by user * decoding: set by user
*/ */
int error_resilience; int error_resilience;
#define FF_ER_CAREFULL 1
#define FF_ER_COMPLIANT 2
#define FF_ER_AGGRESSIVE 3
#define FF_ER_VERY_AGGRESSIVE 4
/** /**
* called at the beginning of each frame to get a buffer for it. * called at the beginning of each frame to get a buffer for it.
......
...@@ -3624,19 +3624,21 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block, ...@@ -3624,19 +3624,21 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
#if 1 #if 1
{ {
const int abs_level= ABS(level); const int abs_level= ABS(level);
if(abs_level<=MAX_LEVEL && run<=MAX_RUN && ((s->workaround_bugs&FF_BUG_AC_VLC)==0)){ if(abs_level<=MAX_LEVEL && run<=MAX_RUN){
const int run1= run - rl->max_run[last][abs_level] - 1; const int run1= run - rl->max_run[last][abs_level] - 1;
if(abs_level <= rl->max_level[last][run]){ if(abs_level <= rl->max_level[last][run]){
fprintf(stderr, "illegal 3. esc, vlc encoding possible\n"); fprintf(stderr, "illegal 3. esc, vlc encoding possible\n");
return -1; return -1;
} }
if(abs_level <= rl->max_level[last][run]*2){ if(s->error_resilience > FF_ER_COMPLIANT){
fprintf(stderr, "illegal 3. esc, esc 1 encoding possible\n"); if(abs_level <= rl->max_level[last][run]*2){
return -1; fprintf(stderr, "illegal 3. esc, esc 1 encoding possible\n");
} return -1;
if(run1 >= 0 && abs_level <= rl->max_level[last][run1]){ }
fprintf(stderr, "illegal 3. esc, esc 2 encoding possible\n"); if(run1 >= 0 && abs_level <= rl->max_level[last][run1]){
return -1; fprintf(stderr, "illegal 3. esc, esc 2 encoding possible\n");
return -1;
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment