提交 68bd11f5 编写于 作者: M Michael Niedermayer

working around undefined behavior of get-vlc if the vlc s invalid

more debug output by default for errors (so we can see immedeatly whats wrong on bugreports)
guess long_vectors mode

Originally committed as revision 874 to svn://svn.ffmpeg.org/ffmpeg/trunk
上级 ee3b2be6
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
//#define DEBUG //#define DEBUG
#define DC_VLC_BITS 9 #define DC_VLC_BITS 14 //FIXME find a better solution
static const UINT16 rv_lum_code[256] = static const UINT16 rv_lum_code[256] =
{ {
...@@ -210,6 +210,7 @@ int rv_decode_dc(MpegEncContext *s, int n) ...@@ -210,6 +210,7 @@ int rv_decode_dc(MpegEncContext *s, int n)
get_bits(&s->gb, 9); get_bits(&s->gb, 9);
code = 1; code = 1;
} else { } else {
fprintf(stderr, "chroma dc error\n");
return 0xffff; return 0xffff;
} }
} else { } else {
...@@ -261,6 +262,7 @@ static int get_num(GetBitContext *gb) ...@@ -261,6 +262,7 @@ static int get_num(GetBitContext *gb)
static int rv10_decode_picture_header(MpegEncContext *s) static int rv10_decode_picture_header(MpegEncContext *s)
{ {
int mb_count, pb_frame, marker, h, full_frame; int mb_count, pb_frame, marker, h, full_frame;
int pic_num, unk;
/* skip packet header */ /* skip packet header */
h = get_bits(&s->gb, 8); h = get_bits(&s->gb, 8);
...@@ -269,15 +271,17 @@ static int rv10_decode_picture_header(MpegEncContext *s) ...@@ -269,15 +271,17 @@ static int rv10_decode_picture_header(MpegEncContext *s)
full_frame = 1; full_frame = 1;
len = get_num(&s->gb); len = get_num(&s->gb);
pos = get_num(&s->gb); pos = get_num(&s->gb);
//printf("pos:%d\n",len);
} else { } else {
int seq, frame_size, pos; int seq, frame_size, pos;
full_frame = 0; full_frame = 0;
seq = get_bits(&s->gb, 8); seq = get_bits(&s->gb, 8);
frame_size = get_num(&s->gb); frame_size = get_num(&s->gb);
pos = get_num(&s->gb); pos = get_num(&s->gb);
//printf("seq:%d, size:%d, pos:%d\n",seq,frame_size,pos);
} }
/* picture number */ /* picture number */
get_bits(&s->gb, 8); pic_num= get_bits(&s->gb, 8);
marker = get_bits(&s->gb, 1); marker = get_bits(&s->gb, 1);
...@@ -285,15 +289,18 @@ static int rv10_decode_picture_header(MpegEncContext *s) ...@@ -285,15 +289,18 @@ static int rv10_decode_picture_header(MpegEncContext *s)
s->pict_type = P_TYPE; s->pict_type = P_TYPE;
else else
s->pict_type = I_TYPE; s->pict_type = I_TYPE;
//printf("h:%d ver:%d\n",h,s->rv10_version);
if(!marker) printf("marker missing\n");
pb_frame = get_bits(&s->gb, 1); pb_frame = get_bits(&s->gb, 1);
#ifdef DEBUG #ifdef DEBUG
printf("pict_type=%d pb_frame=%d\n", s->pict_type, pb_frame); printf("pict_type=%d pb_frame=%d\n", s->pict_type, pb_frame);
#endif #endif
if (pb_frame) if (pb_frame){
fprintf(stderr, "pb frame not supported\n");
return -1; return -1;
}
s->qscale = get_bits(&s->gb, 5); s->qscale = get_bits(&s->gb, 5);
if(s->qscale==0){ if(s->qscale==0){
...@@ -326,8 +333,9 @@ static int rv10_decode_picture_header(MpegEncContext *s) ...@@ -326,8 +333,9 @@ static int rv10_decode_picture_header(MpegEncContext *s)
s->mb_y = 0; s->mb_y = 0;
mb_count = s->mb_width * s->mb_height; mb_count = s->mb_width * s->mb_height;
} }
//printf("%d\n", get_bits(&s->gb, 3)); unk= get_bits(&s->gb, 3); /* ignored */
get_bits(&s->gb, 3); /* ignored */ //printf("%d\n", unk);
s->h263_long_vectors = s->mb_num<100; //FIXME check if this is ok (100 i just guessed)
s->f_code = 1; s->f_code = 1;
s->unrestricted_mv = 1; s->unrestricted_mv = 1;
#if 0 #if 0
...@@ -405,25 +413,19 @@ static int rv10_decode_frame(AVCodecContext *avctx, ...@@ -405,25 +413,19 @@ static int rv10_decode_frame(AVCodecContext *avctx,
mb_count = rv10_decode_picture_header(s); mb_count = rv10_decode_picture_header(s);
if (mb_count < 0) { if (mb_count < 0) {
#ifdef DEBUG fprintf(stderr, "HEADER ERROR\n");
printf("HEADER ERROR\n");
#endif
return -1; return -1;
} }
if (s->mb_x >= s->mb_width || if (s->mb_x >= s->mb_width ||
s->mb_y >= s->mb_height) { s->mb_y >= s->mb_height) {
#ifdef DEBUG fprintf(stderr, "POS ERROR %d %d\n", s->mb_x, s->mb_y);
printf("POS ERROR %d %d\n", s->mb_x, s->mb_y);
#endif
return -1; return -1;
} }
mb_pos = s->mb_y * s->mb_width + s->mb_x; mb_pos = s->mb_y * s->mb_width + s->mb_x;
left = s->mb_width * s->mb_height - mb_pos; left = s->mb_width * s->mb_height - mb_pos;
if (mb_count > left) { if (mb_count > left) {
#ifdef DEBUG fprintf(stderr, "COUNT ERROR\n");
printf("COUNT ERROR\n");
#endif
return -1; return -1;
} }
...@@ -470,9 +472,7 @@ static int rv10_decode_frame(AVCodecContext *avctx, ...@@ -470,9 +472,7 @@ static int rv10_decode_frame(AVCodecContext *avctx,
s->mv_dir = MV_DIR_FORWARD; s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16; s->mv_type = MV_TYPE_16X16;
if (h263_decode_mb(s, block) < 0) { if (h263_decode_mb(s, block) < 0) {
#ifdef DEBUG fprintf(stderr, "ERROR at MB %d %d\n", s->mb_x, s->mb_y);
printf("ERROR\n");
#endif
return -1; return -1;
} }
MPV_decode_mb(s, block); MPV_decode_mb(s, block);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册