Merge commit '5ba83e90919cdeef38e2b5343b48f3f367292564' into release/1.1

* commit '5ba83e90919cdeef38e2b5343b48f3f367292564':
  wavpack: return meaningful errors

Conflicts:
	libavcodec/wavpack.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer
2013-06-03 00:57:23 +02:00

View File

@@ -781,13 +781,13 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
if (block_no >= wc->fdec_num && wv_alloc_frame_context(wc) < 0) { if (block_no >= wc->fdec_num && wv_alloc_frame_context(wc) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error creating frame decode context\n"); av_log(avctx, AV_LOG_ERROR, "Error creating frame decode context\n");
return -1; return AVERROR_INVALIDDATA;
} }
s = wc->fdec[block_no]; s = wc->fdec[block_no];
if (!s) { if (!s) {
av_log(avctx, AV_LOG_ERROR, "Context for block %d is not present\n", block_no); av_log(avctx, AV_LOG_ERROR, "Context for block %d is not present\n", block_no);
return -1; return AVERROR_INVALIDDATA;
} }
if (wc->ch_offset >= avctx->channels) { if (wc->ch_offset >= avctx->channels) {
@@ -1035,7 +1035,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
case WP_ID_CHANINFO: case WP_ID_CHANINFO:
if (size <= 1) { if (size <= 1) {
av_log(avctx, AV_LOG_ERROR, "Insufficient channel information\n"); av_log(avctx, AV_LOG_ERROR, "Insufficient channel information\n");
return -1; return AVERROR_INVALIDDATA;
} }
chan = *buf++; chan = *buf++;
switch (size - 2) { switch (size - 2) {
@@ -1054,10 +1054,11 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
chmask = avctx->channel_layout; chmask = avctx->channel_layout;
} }
if (chan != avctx->channels) { if (chan != avctx->channels) {
av_log(avctx, AV_LOG_ERROR, "Block reports total %d channels, " av_log(avctx, AV_LOG_ERROR,
"decoder believes it's %d channels\n", chan, "Block reports total %d channels, "
avctx->channels); "decoder believes it's %d channels\n",
return -1; chan, avctx->channels);
return AVERROR_INVALIDDATA;
} }
if (!avctx->channel_layout) if (!avctx->channel_layout)
avctx->channel_layout = chmask; avctx->channel_layout = chmask;
@@ -1072,31 +1073,31 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
if (!got_terms) { if (!got_terms) {
av_log(avctx, AV_LOG_ERROR, "No block with decorrelation terms\n"); av_log(avctx, AV_LOG_ERROR, "No block with decorrelation terms\n");
return -1; return AVERROR_INVALIDDATA;
} }
if (!got_weights) { if (!got_weights) {
av_log(avctx, AV_LOG_ERROR, "No block with decorrelation weights\n"); av_log(avctx, AV_LOG_ERROR, "No block with decorrelation weights\n");
return -1; return AVERROR_INVALIDDATA;
} }
if (!got_samples) { if (!got_samples) {
av_log(avctx, AV_LOG_ERROR, "No block with decorrelation samples\n"); av_log(avctx, AV_LOG_ERROR, "No block with decorrelation samples\n");
return -1; return AVERROR_INVALIDDATA;
} }
if (!got_entropy) { if (!got_entropy) {
av_log(avctx, AV_LOG_ERROR, "No block with entropy info\n"); av_log(avctx, AV_LOG_ERROR, "No block with entropy info\n");
return -1; return AVERROR_INVALIDDATA;
} }
if (s->hybrid && !got_hybrid) { if (s->hybrid && !got_hybrid) {
av_log(avctx, AV_LOG_ERROR, "Hybrid config not found\n"); av_log(avctx, AV_LOG_ERROR, "Hybrid config not found\n");
return -1; return AVERROR_INVALIDDATA;
} }
if (!got_bs) { if (!got_bs) {
av_log(avctx, AV_LOG_ERROR, "Packed samples not found\n"); av_log(avctx, AV_LOG_ERROR, "Packed samples not found\n");
return -1; return AVERROR_INVALIDDATA;
} }
if (!got_float && avctx->sample_fmt == AV_SAMPLE_FMT_FLT) { if (!got_float && avctx->sample_fmt == AV_SAMPLE_FMT_FLT) {
av_log(avctx, AV_LOG_ERROR, "Float information not found\n"); av_log(avctx, AV_LOG_ERROR, "Float information not found\n");
return -1; return AVERROR_INVALIDDATA;
} }
if (s->got_extra_bits && avctx->sample_fmt != AV_SAMPLE_FMT_FLT) { if (s->got_extra_bits && avctx->sample_fmt != AV_SAMPLE_FMT_FLT) {
const int size = get_bits_left(&s->gb_extra_bits); const int size = get_bits_left(&s->gb_extra_bits);
@@ -1116,7 +1117,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_FLT); samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_FLT);
if (samplecount < 0) if (samplecount < 0)
return -1; return samplecount;
samplecount >>= 1; samplecount >>= 1;
} else { } else {
@@ -1130,7 +1131,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_FLT); samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_FLT);
if (samplecount < 0) if (samplecount < 0)
return -1; return samplecount;
if (s->stereo && avctx->sample_fmt == AV_SAMPLE_FMT_S16) { if (s->stereo && avctx->sample_fmt == AV_SAMPLE_FMT_S16) {
int16_t *dst = (int16_t*)samples + 1; int16_t *dst = (int16_t*)samples + 1;
@@ -1207,7 +1208,7 @@ static int wavpack_decode_frame(AVCodecContext *avctx, void *data,
if (s->samples <= 0 || s->samples > WV_MAX_SAMPLES) { if (s->samples <= 0 || s->samples > WV_MAX_SAMPLES) {
av_log(avctx, AV_LOG_ERROR, "Invalid number of samples: %d\n", av_log(avctx, AV_LOG_ERROR, "Invalid number of samples: %d\n",
s->samples); s->samples);
return AVERROR(EINVAL); return AVERROR_INVALIDDATA;
} }
if (frame_flags & 0x80) { if (frame_flags & 0x80) {
@@ -1249,7 +1250,7 @@ static int wavpack_decode_frame(AVCodecContext *avctx, void *data,
s->frame.data[0], got_frame_ptr, s->frame.data[0], got_frame_ptr,
buf, frame_size)) < 0) { buf, frame_size)) < 0) {
wavpack_decode_flush(avctx); wavpack_decode_flush(avctx);
return AVERROR_INVALIDDATA; return samplecount;
} }
s->block++; s->block++;
buf += frame_size; buf_size -= frame_size; buf += frame_size; buf_size -= frame_size;