aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-09-25 22:54:54 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-09-25 22:55:03 +0200
commit3308b443f9342cd597a9d7440d2315f0a65b1566 (patch)
tree8fcd08caf65c6256e60d1b1ed15ca317304f4ad2
parent91ad27e8f5fb931eb2e6d810d4090e570ff5c3a7 (diff)
parente2dcb8208e8f6cffef58a85127765047f5ef8868 (diff)
downloadffmpeg-3308b443f9342cd597a9d7440d2315f0a65b1566.tar.gz
Merge commit 'e2dcb8208e8f6cffef58a85127765047f5ef8868' into release/0.10
* commit 'e2dcb8208e8f6cffef58a85127765047f5ef8868': indeo5: return proper error codes indeo4: Validate scantable dimension Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/indeo4.c6
-rw-r--r--libavcodec/indeo5.c54
2 files changed, 36 insertions, 24 deletions
diff --git a/libavcodec/indeo4.c b/libavcodec/indeo4.c
index 0c1d50ff2e..b15e250cfe 100644
--- a/libavcodec/indeo4.c
+++ b/libavcodec/indeo4.c
@@ -354,6 +354,12 @@ static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
av_log(avctx, AV_LOG_ERROR, "Custom scan pattern encountered!\n");
return AVERROR_INVALIDDATA;
}
+ if (scan_indx > 4 && scan_indx < 10) {
+ if (band->blk_size != 4)
+ return AVERROR_INVALIDDATA;
+ } else if (band->blk_size != 8)
+ return AVERROR_INVALIDDATA;
+
band->scan = scan_index_to_tab[scan_indx];
band->quant_mat = get_bits(&ctx->gb, 5);
diff --git a/libavcodec/indeo5.c b/libavcodec/indeo5.c
index 1d5824faf7..9404b57c06 100644
--- a/libavcodec/indeo5.c
+++ b/libavcodec/indeo5.c
@@ -74,7 +74,7 @@ static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
tile_size = (ctx->gop_flags & 0x40) ? 64 << get_bits(&ctx->gb, 2) : 0;
if (tile_size > 256) {
av_log(avctx, AV_LOG_ERROR, "Invalid tile size: %d\n", tile_size);
- return -1;
+ return AVERROR_INVALIDDATA;
}
/* decode number of wavelet bands */
@@ -85,7 +85,7 @@ static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
if (is_scalable && (pic_conf.luma_bands != 4 || pic_conf.chroma_bands != 1)) {
av_log(avctx, AV_LOG_ERROR, "Scalability: unsupported subdivision! Luma bands: %d, chroma bands: %d\n",
pic_conf.luma_bands, pic_conf.chroma_bands);
- return -1;
+ return AVERROR_INVALIDDATA;
}
pic_size_indx = get_bits(&ctx->gb, 4);
@@ -98,8 +98,8 @@ static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
}
if (ctx->gop_flags & 2) {
- av_log(avctx, AV_LOG_ERROR, "YV12 picture format not supported!\n");
- return -1;
+ av_log_missing_feature(avctx, "YV12 picture format", 0);
+ return AVERROR_PATCHWELCOME;
}
pic_conf.chroma_height = (pic_conf.pic_height + 3) >> 2;
@@ -115,9 +115,9 @@ static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
/* check if picture layout was changed and reallocate buffers */
if (ivi_pic_config_cmp(&pic_conf, &ctx->pic_conf)) {
result = ff_ivi_init_planes(ctx->planes, &pic_conf);
- if (result) {
+ if (result < 0) {
av_log(avctx, AV_LOG_ERROR, "Couldn't reallocate color planes!\n");
- return -1;
+ return result;
}
ctx->pic_conf = pic_conf;
ctx->is_scalable = is_scalable;
@@ -141,8 +141,8 @@ static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
}
if (get_bits1(&ctx->gb)) {
- av_log(avctx, AV_LOG_ERROR, "Extended transform info encountered!\n");
- return -1;
+ av_log_missing_feature(avctx, "Extended transform info", 0);
+ return AVERROR_PATCHWELCOME;
}
/* select transform function and scan pattern according to plane and band number */
@@ -206,7 +206,7 @@ static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
if (get_bits(&ctx->gb, 2)) {
av_log(avctx, AV_LOG_ERROR, "End marker missing!\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
}
}
@@ -235,17 +235,17 @@ static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
if (blk_size_changed) {
result = ff_ivi_init_tiles(ctx->planes, pic_conf.tile_width,
pic_conf.tile_height);
- if (result) {
+ if (result < 0) {
av_log(avctx, AV_LOG_ERROR,
"Couldn't reallocate internal structures!\n");
- return -1;
+ return result;
}
}
if (ctx->gop_flags & 8) {
if (get_bits(&ctx->gb, 3)) {
av_log(avctx, AV_LOG_ERROR, "Alignment bits are not zero!\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
if (get_bits1(&ctx->gb))
@@ -294,25 +294,27 @@ static inline void skip_hdr_extension(GetBitContext *gb)
*/
static int decode_pic_hdr(IVI45DecContext *ctx, AVCodecContext *avctx)
{
+ int ret;
+
if (get_bits(&ctx->gb, 5) != 0x1F) {
av_log(avctx, AV_LOG_ERROR, "Invalid picture start code!\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
ctx->prev_frame_type = ctx->frame_type;
ctx->frame_type = get_bits(&ctx->gb, 3);
if (ctx->frame_type >= 5) {
av_log(avctx, AV_LOG_ERROR, "Invalid frame type: %d \n", ctx->frame_type);
- return -1;
+ return AVERROR_INVALIDDATA;
}
ctx->frame_num = get_bits(&ctx->gb, 8);
if (ctx->frame_type == FRAMETYPE_INTRA) {
ctx->gop_invalid = 1;
- if (decode_gop_header(ctx, avctx)) {
+ if ((ret = decode_gop_header(ctx, avctx)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid GOP header, skipping frames.\n");
- return AVERROR_INVALIDDATA;
+ return ret;
}
ctx->gop_invalid = 0;
}
@@ -329,8 +331,10 @@ static int decode_pic_hdr(IVI45DecContext *ctx, AVCodecContext *avctx)
skip_hdr_extension(&ctx->gb); /* XXX: untested */
/* decode macroblock huffman codebook */
- if (ff_ivi_dec_huff_desc(&ctx->gb, ctx->frame_flags & 0x40, IVI_MB_HUFF, &ctx->mb_vlc, avctx))
- return -1;
+ ret = ff_ivi_dec_huff_desc(&ctx->gb, ctx->frame_flags & 0x40,
+ IVI_MB_HUFF, &ctx->mb_vlc, avctx);
+ if (ret < 0)
+ return ret;
skip_bits(&ctx->gb, 3); /* FIXME: unknown meaning! */
}
@@ -352,7 +356,7 @@ static int decode_pic_hdr(IVI45DecContext *ctx, AVCodecContext *avctx)
static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
AVCodecContext *avctx)
{
- int i;
+ int i, ret;
uint8_t band_flags;
band_flags = get_bits(&ctx->gb, 8);
@@ -376,7 +380,7 @@ static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
if (band->num_corr > 61) {
av_log(avctx, AV_LOG_ERROR, "Too many corrections: %d\n",
band->num_corr);
- return -1;
+ return AVERROR_INVALIDDATA;
}
/* read correction pairs */
@@ -388,8 +392,10 @@ static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
band->rvmap_sel = (band_flags & 0x40) ? get_bits(&ctx->gb, 3) : 8;
/* decode block huffman codebook */
- if (ff_ivi_dec_huff_desc(&ctx->gb, band_flags & 0x80, IVI_BLK_HUFF, &band->blk_vlc, avctx))
- return -1;
+ ret = ff_ivi_dec_huff_desc(&ctx->gb, band_flags & 0x80, IVI_BLK_HUFF,
+ &band->blk_vlc, avctx);
+ if (ret < 0)
+ return ret;
band->checksum_present = get_bits1(&ctx->gb);
if (band->checksum_present)
@@ -456,7 +462,7 @@ static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band,
if (get_bits1(&ctx->gb)) {
if (ctx->frame_type == FRAMETYPE_INTRA) {
av_log(avctx, AV_LOG_ERROR, "Empty macroblock in an INTRA picture!\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
mb->type = 1; /* empty macroblocks are always INTER */
mb->cbp = 0; /* all blocks are empty */
@@ -622,7 +628,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
result = ff_ivi_init_planes(ctx->planes, &ctx->pic_conf);
if (result) {
av_log(avctx, AV_LOG_ERROR, "Couldn't allocate color planes!\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
ctx->buf_switch = 0;