1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

rv10: return meaningful error codes.

Also improve some error messages.
This commit is contained in:
Anton Khirnov 2013-04-09 20:11:09 +02:00
parent 69f6f03cd1
commit bac8d38c0a

View File

@ -257,14 +257,14 @@ static int rv10_decode_picture_header(MpegEncContext *s)
av_dlog(s->avctx, "pict_type=%d pb_frame=%d\n", s->pict_type, pb_frame); av_dlog(s->avctx, "pict_type=%d pb_frame=%d\n", s->pict_type, pb_frame);
if (pb_frame) { if (pb_frame) {
av_log(s->avctx, AV_LOG_ERROR, "pb frame not supported\n"); avpriv_request_sample(s->avctx, "pb frame");
return -1; return AVERROR_PATCHWELCOME;
} }
s->qscale = get_bits(&s->gb, 5); s->qscale = get_bits(&s->gb, 5);
if (s->qscale == 0) { if (s->qscale == 0) {
av_log(s->avctx, AV_LOG_ERROR, "error, qscale:0\n"); av_log(s->avctx, AV_LOG_ERROR, "Invalid qscale value: 0\n");
return -1; return AVERROR_INVALIDDATA;
} }
if (s->pict_type == AV_PICTURE_TYPE_I) { if (s->pict_type == AV_PICTURE_TYPE_I) {
@ -300,7 +300,7 @@ static int rv10_decode_picture_header(MpegEncContext *s)
static int rv20_decode_picture_header(RVDecContext *rv) static int rv20_decode_picture_header(RVDecContext *rv)
{ {
MpegEncContext *s = &rv->m; MpegEncContext *s = &rv->m;
int seq, mb_pos, i; int seq, mb_pos, i, ret;
int rpr_bits; int rpr_bits;
i = get_bits(&s->gb, 2); i = get_bits(&s->gb, 2);
@ -311,23 +311,23 @@ static int rv20_decode_picture_header(RVDecContext *rv)
case 3: s->pict_type = AV_PICTURE_TYPE_B; break; case 3: s->pict_type = AV_PICTURE_TYPE_B; break;
default: default:
av_log(s->avctx, AV_LOG_ERROR, "unknown frame type\n"); av_log(s->avctx, AV_LOG_ERROR, "unknown frame type\n");
return -1; return AVERROR_INVALIDDATA;
} }
if (s->last_picture_ptr == NULL && s->pict_type == AV_PICTURE_TYPE_B) { if (s->last_picture_ptr == NULL && s->pict_type == AV_PICTURE_TYPE_B) {
av_log(s->avctx, AV_LOG_ERROR, "early B pix\n"); av_log(s->avctx, AV_LOG_ERROR, "early B-frame\n");
return -1; return AVERROR_INVALIDDATA;
} }
if (get_bits1(&s->gb)) { if (get_bits1(&s->gb)) {
av_log(s->avctx, AV_LOG_ERROR, "reserved bit set\n"); av_log(s->avctx, AV_LOG_ERROR, "reserved bit set\n");
return -1; return AVERROR_INVALIDDATA;
} }
s->qscale = get_bits(&s->gb, 5); s->qscale = get_bits(&s->gb, 5);
if (s->qscale == 0) { if (s->qscale == 0) {
av_log(s->avctx, AV_LOG_ERROR, "error, qscale:0\n"); av_log(s->avctx, AV_LOG_ERROR, "Invalid qscale value: 0\n");
return -1; return AVERROR_INVALIDDATA;
} }
if (RV_GET_MINOR_VER(rv->sub_id) >= 2) if (RV_GET_MINOR_VER(rv->sub_id) >= 2)
@ -356,13 +356,13 @@ static int rv20_decode_picture_header(RVDecContext *rv)
av_log(s->avctx, AV_LOG_DEBUG, av_log(s->avctx, AV_LOG_DEBUG,
"attempting to change resolution to %dx%d\n", new_w, new_h); "attempting to change resolution to %dx%d\n", new_w, new_h);
if (av_image_check_size(new_w, new_h, 0, s->avctx) < 0) if (av_image_check_size(new_w, new_h, 0, s->avctx) < 0)
return -1; return AVERROR_INVALIDDATA;
ff_MPV_common_end(s); ff_MPV_common_end(s);
avcodec_set_dimensions(s->avctx, new_w, new_h); avcodec_set_dimensions(s->avctx, new_w, new_h);
s->width = new_w; s->width = new_w;
s->height = new_h; s->height = new_h;
if (ff_MPV_common_init(s) < 0) if ((ret = ff_MPV_common_init(s)) < 0)
return -1; return ret;
} }
if (s->avctx->debug & FF_DEBUG_PICT_INFO) { if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
@ -423,11 +423,11 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
RVDecContext *rv = avctx->priv_data; RVDecContext *rv = avctx->priv_data;
MpegEncContext *s = &rv->m; MpegEncContext *s = &rv->m;
static int done = 0; static int done = 0;
int major_ver, minor_ver, micro_ver; int major_ver, minor_ver, micro_ver, ret;
if (avctx->extradata_size < 8) { if (avctx->extradata_size < 8) {
av_log(avctx, AV_LOG_ERROR, "Extradata is too small.\n"); av_log(avctx, AV_LOG_ERROR, "Extradata is too small.\n");
return -1; return AVERROR_INVALIDDATA;
} }
ff_MPV_decode_defaults(s); ff_MPV_decode_defaults(s);
@ -472,8 +472,8 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
avctx->pix_fmt = AV_PIX_FMT_YUV420P; avctx->pix_fmt = AV_PIX_FMT_YUV420P;
if (ff_MPV_common_init(s) < 0) if ((ret = ff_MPV_common_init(s)) < 0)
return -1; return ret;
ff_h263_decode_init_vlc(); ff_h263_decode_init_vlc();
@ -504,7 +504,7 @@ static int rv10_decode_packet(AVCodecContext *avctx,
{ {
RVDecContext *rv = avctx->priv_data; RVDecContext *rv = avctx->priv_data;
MpegEncContext *s = &rv->m; MpegEncContext *s = &rv->m;
int mb_count, mb_pos, left, start_mb_x, active_bits_size; int mb_count, mb_pos, left, start_mb_x, active_bits_size, ret;
active_bits_size = buf_size * 8; active_bits_size = buf_size * 8;
init_get_bits(&s->gb, buf, FFMAX(buf_size, buf_size2) * 8); init_get_bits(&s->gb, buf, FFMAX(buf_size, buf_size2) * 8);
@ -514,19 +514,19 @@ static int rv10_decode_packet(AVCodecContext *avctx,
mb_count = rv20_decode_picture_header(rv); mb_count = rv20_decode_picture_header(rv);
if (mb_count < 0) { if (mb_count < 0) {
av_log(s->avctx, AV_LOG_ERROR, "HEADER ERROR\n"); av_log(s->avctx, AV_LOG_ERROR, "HEADER ERROR\n");
return -1; return AVERROR_INVALIDDATA;
} }
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) {
av_log(s->avctx, AV_LOG_ERROR, "POS ERROR %d %d\n", s->mb_x, s->mb_y); av_log(s->avctx, AV_LOG_ERROR, "POS ERROR %d %d\n", s->mb_x, s->mb_y);
return -1; return AVERROR_INVALIDDATA;
} }
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) {
av_log(s->avctx, AV_LOG_ERROR, "COUNT ERROR\n"); av_log(s->avctx, AV_LOG_ERROR, "COUNT ERROR\n");
return -1; return AVERROR_INVALIDDATA;
} }
if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr == NULL) { if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr == NULL) {
@ -535,13 +535,13 @@ static int rv10_decode_packet(AVCodecContext *avctx,
ff_MPV_frame_end(s); ff_MPV_frame_end(s);
s->mb_x = s->mb_y = s->resync_mb_x = s->resync_mb_y = 0; s->mb_x = s->mb_y = s->resync_mb_x = s->resync_mb_y = 0;
} }
if (ff_MPV_frame_start(s, avctx) < 0) if ((ret = ff_MPV_frame_start(s, avctx)) < 0)
return -1; return ret;
ff_mpeg_er_frame_start(s); ff_mpeg_er_frame_start(s);
} else { } else {
if (s->current_picture_ptr->f.pict_type != s->pict_type) { if (s->current_picture_ptr->f.pict_type != s->pict_type) {
av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n"); av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n");
return -1; return AVERROR_INVALIDDATA;
} }
} }
@ -610,7 +610,7 @@ static int rv10_decode_packet(AVCodecContext *avctx,
if (ret == SLICE_ERROR || active_bits_size < get_bits_count(&s->gb)) { if (ret == SLICE_ERROR || active_bits_size < get_bits_count(&s->gb)) {
av_log(s->avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x, s->mb_y); av_log(s->avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x, s->mb_y);
return -1; return AVERROR_INVALIDDATA;
} }
if (s->pict_type != AV_PICTURE_TYPE_B) if (s->pict_type != AV_PICTURE_TYPE_B)
ff_h263_update_motion_val(s); ff_h263_update_motion_val(s);