aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-04-09 20:11:09 +0200
committerAnton Khirnov <anton@khirnov.net>2013-04-17 11:01:17 +0200
commitbac8d38c0a716c8bdfdecf0ae545015c68f5df36 (patch)
treef4a2cb216cfb04d379c402230b89a5630d62a22e
parent69f6f03cd16a09e4e848b4e82bae4993bc361cd0 (diff)
downloadffmpeg-bac8d38c0a716c8bdfdecf0ae545015c68f5df36.tar.gz
rv10: return meaningful error codes.
Also improve some error messages.
-rw-r--r--libavcodec/rv10.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index 5effa0eb1d..789847da82 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -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);
if (pb_frame) {
- av_log(s->avctx, AV_LOG_ERROR, "pb frame not supported\n");
- return -1;
+ avpriv_request_sample(s->avctx, "pb frame");
+ return AVERROR_PATCHWELCOME;
}
s->qscale = get_bits(&s->gb, 5);
if (s->qscale == 0) {
- av_log(s->avctx, AV_LOG_ERROR, "error, qscale:0\n");
- return -1;
+ av_log(s->avctx, AV_LOG_ERROR, "Invalid qscale value: 0\n");
+ return AVERROR_INVALIDDATA;
}
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)
{
MpegEncContext *s = &rv->m;
- int seq, mb_pos, i;
+ int seq, mb_pos, i, ret;
int rpr_bits;
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;
default:
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) {
- av_log(s->avctx, AV_LOG_ERROR, "early B pix\n");
- return -1;
+ av_log(s->avctx, AV_LOG_ERROR, "early B-frame\n");
+ return AVERROR_INVALIDDATA;
}
if (get_bits1(&s->gb)) {
av_log(s->avctx, AV_LOG_ERROR, "reserved bit set\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
s->qscale = get_bits(&s->gb, 5);
if (s->qscale == 0) {
- av_log(s->avctx, AV_LOG_ERROR, "error, qscale:0\n");
- return -1;
+ av_log(s->avctx, AV_LOG_ERROR, "Invalid qscale value: 0\n");
+ return AVERROR_INVALIDDATA;
}
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,
"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)
- return -1;
+ return AVERROR_INVALIDDATA;
ff_MPV_common_end(s);
avcodec_set_dimensions(s->avctx, new_w, new_h);
s->width = new_w;
s->height = new_h;
- if (ff_MPV_common_init(s) < 0)
- return -1;
+ if ((ret = ff_MPV_common_init(s)) < 0)
+ return ret;
}
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;
MpegEncContext *s = &rv->m;
static int done = 0;
- int major_ver, minor_ver, micro_ver;
+ int major_ver, minor_ver, micro_ver, ret;
if (avctx->extradata_size < 8) {
av_log(avctx, AV_LOG_ERROR, "Extradata is too small.\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
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;
- if (ff_MPV_common_init(s) < 0)
- return -1;
+ if ((ret = ff_MPV_common_init(s)) < 0)
+ return ret;
ff_h263_decode_init_vlc();
@@ -504,7 +504,7 @@ static int rv10_decode_packet(AVCodecContext *avctx,
{
RVDecContext *rv = avctx->priv_data;
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;
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);
if (mb_count < 0) {
av_log(s->avctx, AV_LOG_ERROR, "HEADER ERROR\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
if (s->mb_x >= s->mb_width ||
s->mb_y >= s->mb_height) {
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;
left = s->mb_width * s->mb_height - mb_pos;
if (mb_count > left) {
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) {
@@ -535,13 +535,13 @@ static int rv10_decode_packet(AVCodecContext *avctx,
ff_MPV_frame_end(s);
s->mb_x = s->mb_y = s->resync_mb_x = s->resync_mb_y = 0;
}
- if (ff_MPV_frame_start(s, avctx) < 0)
- return -1;
+ if ((ret = ff_MPV_frame_start(s, avctx)) < 0)
+ return ret;
ff_mpeg_er_frame_start(s);
} else {
if (s->current_picture_ptr->f.pict_type != s->pict_type) {
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)) {
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)
ff_h263_update_motion_val(s);