aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2013-03-05 16:34:16 +0100
committerLuca Barbato <lu_zero@gentoo.org>2013-03-12 20:05:39 +0100
commit5df064df62373c6854ac5b9bd372c74ebdc6fe0f (patch)
tree0ad5905029ec131de0290438c6d048a980b942b0
parentff5a06f7f0d6e64de7c5fd02043e0482b9eae493 (diff)
downloadffmpeg-5df064df62373c6854ac5b9bd372c74ebdc6fe0f.tar.gz
shorten: report meaningful errors
(cherry picked from commit 4c364eb2b856fc33cf7b42f7c7b979e69fde5f3a) (cherry picked from commit 0daf1428e82926dc5a8c72a0ff4c93aaa8a84ed9) Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
-rw-r--r--libavcodec/shorten.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
index 04a4912088..c2dffd533a 100644
--- a/libavcodec/shorten.c
+++ b/libavcodec/shorten.c
@@ -129,13 +129,13 @@ static int allocate_buffers(ShortenContext *s)
for (chan = 0; chan < s->channels; chan++) {
if (FFMAX(1, s->nmean) >= UINT_MAX / sizeof(int32_t)) {
av_log(s->avctx, AV_LOG_ERROR, "nmean too large\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
if (s->blocksize + s->nwrap >= UINT_MAX / sizeof(int32_t) ||
s->blocksize + s->nwrap <= (unsigned)s->nwrap) {
av_log(s->avctx, AV_LOG_ERROR,
"s->blocksize + s->nwrap too large\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
tmp_ptr =
@@ -208,14 +208,14 @@ static int decode_wave_header(AVCodecContext *avctx, const uint8_t *header,
if (bytestream_get_le32(&header) != MKTAG('R', 'I', 'F', 'F')) {
av_log(avctx, AV_LOG_ERROR, "missing RIFF tag\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
header += 4; /* chunk size */
if (bytestream_get_le32(&header) != MKTAG('W', 'A', 'V', 'E')) {
av_log(avctx, AV_LOG_ERROR, "missing WAVE tag\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
while (bytestream_get_le32(&header) != MKTAG('f', 'm', 't', ' ')) {
@@ -226,7 +226,7 @@ static int decode_wave_header(AVCodecContext *avctx, const uint8_t *header,
if (len < 16) {
av_log(avctx, AV_LOG_ERROR, "fmt chunk was too short\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
wave_format = bytestream_get_le16(&header);
@@ -236,7 +236,7 @@ static int decode_wave_header(AVCodecContext *avctx, const uint8_t *header,
break;
default:
av_log(avctx, AV_LOG_ERROR, "unsupported wave format\n");
- return -1;
+ return AVERROR(ENOSYS);
}
header += 2; // skip channels (already got from shorten header)
@@ -247,7 +247,7 @@ static int decode_wave_header(AVCodecContext *avctx, const uint8_t *header,
if (avctx->bits_per_coded_sample != 16) {
av_log(avctx, AV_LOG_ERROR, "unsupported number of bits per sample\n");
- return -1;
+ return AVERROR(ENOSYS);
}
len -= 16;
@@ -329,7 +329,7 @@ static int read_header(ShortenContext *s)
/* shorten signature */
if (get_bits_long(&s->gb, 32) != AV_RB32("ajkg")) {
av_log(s->avctx, AV_LOG_ERROR, "missing shorten magic 'ajkg'\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
s->lpcqoffset = 0;
@@ -342,7 +342,7 @@ static int read_header(ShortenContext *s)
if (s->channels > MAX_CHANNELS) {
av_log(s->avctx, AV_LOG_ERROR, "too many channels: %d\n", s->channels);
s->channels = 0;
- return -1;
+ return AVERROR_INVALIDDATA;
}
s->avctx->channels = s->channels;
@@ -380,7 +380,7 @@ static int read_header(ShortenContext *s)
if (get_ur_golomb_shorten(&s->gb, FNSIZE) != FN_VERBATIM) {
av_log(s->avctx, AV_LOG_ERROR,
"missing verbatim section at beginning of stream\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
s->header_size = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE);
@@ -388,14 +388,14 @@ static int read_header(ShortenContext *s)
s->header_size < CANONICAL_HEADER_SIZE) {
av_log(s->avctx, AV_LOG_ERROR, "header is wrong size: %d\n",
s->header_size);
- return -1;
+ return AVERROR_INVALIDDATA;
}
for (i = 0; i < s->header_size; i++)
s->header[i] = (char)get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE);
- if (decode_wave_header(s->avctx, s->header, s->header_size) < 0)
- return -1;
+ if ((ret = decode_wave_header(s->avctx, s->header, s->header_size)) < 0)
+ return ret;
s->cur_chan = 0;
s->bitshift = 0;
@@ -609,7 +609,7 @@ finish_frame:
av_log(s->avctx, AV_LOG_ERROR, "overread: %d\n", i - buf_size);
s->bitstream_size = 0;
s->bitstream_index = 0;
- return -1;
+ return AVERROR_INVALIDDATA;
}
if (s->bitstream_size) {
s->bitstream_index += i;