From 71434945f20c6d340b4c942de7746e6ea46ec74b Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 26 Mar 2005 17:01:49 +0000 Subject: more checks, fixes assertion failure Originally committed as revision 4081 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/mpeg12.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index b2cce663b9..1af8c3b4a1 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -1080,6 +1080,15 @@ static int mpeg_decode_mb(MpegEncContext *s, s->mb_skiped = 1; s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16; } else { + int mb_type; + + if(s->mb_x) + mb_type= s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1]; + else + mb_type= s->current_picture.mb_type[ s->mb_width + (s->mb_y-1)*s->mb_stride - 1]; // FIXME not sure if this is allowed in mpeg at all, + if(IS_INTRA(mb_type)) + return -1; + /* if B type, reuse previous vectors and directions */ s->mv[0][0][0] = s->last_mv[0][0][0]; s->mv[0][0][1] = s->last_mv[0][0][1]; @@ -1087,7 +1096,7 @@ static int mpeg_decode_mb(MpegEncContext *s, s->mv[1][0][1] = s->last_mv[1][0][1]; s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= - s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1] | MB_TYPE_SKIP; + mb_type | MB_TYPE_SKIP; // assert(s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1]&(MB_TYPE_16x16|MB_TYPE_16x8)); if((s->mv[0][0][0]|s->mv[0][0][1]|s->mv[1][0][0]|s->mv[1][0][1])==0) @@ -2104,6 +2113,8 @@ static int mpeg1_decode_picture(AVCodecContext *avctx, ref = get_bits(&s->gb, 10); /* temporal ref */ s->pict_type = get_bits(&s->gb, 3); + if(s->pict_type == 0 || s->pict_type > 3) + return -1; vbv_delay= get_bits(&s->gb, 16); if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) { @@ -2125,8 +2136,8 @@ static int mpeg1_decode_picture(AVCodecContext *avctx, s->current_picture.pict_type= s->pict_type; s->current_picture.key_frame= s->pict_type == I_TYPE; -// if(avctx->debug & FF_DEBUG_PICT_INFO) -// av_log(avctx, AV_LOG_DEBUG, "vbv_delay %d, ref %d\n", vbv_delay, ref); + if(avctx->debug & FF_DEBUG_PICT_INFO) + av_log(avctx, AV_LOG_DEBUG, "vbv_delay %d, ref %d type:%d\n", vbv_delay, ref, s->pict_type); s->y_dc_scale = 8; s->c_dc_scale = 8; -- cgit v1.2.3