Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-01-07 03:38:25 +0400
committerMichael Niedermayer <michaelni@gmx.at>2013-01-07 03:41:06 +0400
commit07f22d0b49332d9616ce5ff94679da5a01c19b0d (patch)
tree00e7f5f81436ddf1e54339661383e8fc6105cfca /libavcodec
parent7b018e5c8d182b0272477322377b8daafa1c970f (diff)
parent57d11e5e28bfe0bc445ad78fc033aafa73068bb4 (diff)
Merge commit '57d11e5e28bfe0bc445ad78fc033aafa73068bb4'
* commit '57d11e5e28bfe0bc445ad78fc033aafa73068bb4': fraps: return meaningful error codes. kgv1dec: return meaningful error codes. kmvc: return meaningful error codes. wnv1: return meaningful error codes. dpx: return meaningful error codes. truemotion1: return meaningful error codes pnm: return meaningful error codes. Conflicts: libavcodec/dpx.c libavcodec/fraps.c libavcodec/kmvc.c libavcodec/pnm.c libavcodec/pnmdec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/dpx.c18
-rw-r--r--libavcodec/fraps.c28
-rw-r--r--libavcodec/kgv1dec.c6
-rw-r--r--libavcodec/kmvc.c5
-rw-r--r--libavcodec/pnm.c18
-rw-r--r--libavcodec/pnmdec.c6
-rw-r--r--libavcodec/truemotion1.c24
7 files changed, 54 insertions, 51 deletions
diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c
index a9a8c16d6c..92c0e4b8d1 100644
--- a/libavcodec/dpx.c
+++ b/libavcodec/dpx.c
@@ -71,7 +71,7 @@ static int decode_frame(AVCodecContext *avctx,
unsigned int offset;
int magic_num, endian;
- int x, y, i;
+ int x, y, i, ret;
int w, h, bits_per_color, descriptor, elements, packing, total_size;
unsigned int rgbBuffer = 0;
@@ -93,7 +93,7 @@ static int decode_frame(AVCodecContext *avctx,
endian = 1;
} else {
av_log(avctx, AV_LOG_ERROR, "DPX marker not found\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
offset = read32(&buf, endian);
@@ -105,8 +105,8 @@ static int decode_frame(AVCodecContext *avctx,
buf = avpkt->data + 0x304;
w = read32(&buf, endian);
h = read32(&buf, endian);
- if (av_image_check_size(w, h, 0, avctx))
- return AVERROR(EINVAL);
+ if ((ret = av_image_check_size(w, h, 0, avctx)) < 0)
+ return ret;
if (w != avctx->width || h != avctx->height)
avcodec_set_dimensions(avctx, w, h);
@@ -141,7 +141,7 @@ static int decode_frame(AVCodecContext *avctx,
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unsupported descriptor %d\n", descriptor);
- return -1;
+ return AVERROR_INVALIDDATA;
}
switch (bits_per_color) {
@@ -183,14 +183,14 @@ static int decode_frame(AVCodecContext *avctx,
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unsupported color depth : %d\n", bits_per_color);
- return -1;
+ return AVERROR_INVALIDDATA;
}
if (s->picture.data[0])
avctx->release_buffer(avctx, &s->picture);
- if (ff_get_buffer(avctx, p) < 0) {
+ if ((ret = ff_get_buffer(avctx, p)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return -1;
+ return ret;
}
// Move pointer to offset from start of file
@@ -201,7 +201,7 @@ static int decode_frame(AVCodecContext *avctx,
if (total_size > avpkt->size) {
av_log(avctx, AV_LOG_ERROR, "Overread buffer. Invalid header?\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
switch (bits_per_color) {
case 10:
diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c
index 6500c853e2..6cdb0d99a3 100644
--- a/libavcodec/fraps.c
+++ b/libavcodec/fraps.c
@@ -88,7 +88,7 @@ static int fraps2_decode_plane(FrapsContext *s, uint8_t *dst, int stride, int w,
int h, const uint8_t *src, int size, int Uoff,
const int step)
{
- int i, j;
+ int i, j, ret;
GetBitContext gb;
VLC vlc;
Node nodes[512];
@@ -96,9 +96,9 @@ static int fraps2_decode_plane(FrapsContext *s, uint8_t *dst, int stride, int w,
for(i = 0; i < 256; i++)
nodes[i].count = bytestream_get_le32(&src);
size -= 1024;
- if (ff_huff_build_tree(s->avctx, &vlc, 256, nodes, huff_cmp,
- FF_HUFFMAN_FLAG_ZERO_COUNT) < 0)
- return -1;
+ if ((ret = ff_huff_build_tree(s->avctx, &vlc, 256, nodes, huff_cmp,
+ FF_HUFFMAN_FLAG_ZERO_COUNT)) < 0)
+ return ret;
/* we have built Huffman table and are ready to decode plane */
/* convert bits so they may be used by standard bitreader */
@@ -139,11 +139,10 @@ static int decode_frame(AVCodecContext *avctx,
const uint32_t *buf32;
uint32_t *luma1,*luma2,*cb,*cr;
uint32_t offs[4];
- int i, j, is_chroma;
+ int i, j, ret, is_chroma;
const int planes = 3;
uint8_t *out;
enum AVPixelFormat pix_fmt;
- int ret;
header = AV_RL32(buf);
version = header & 0xff;
@@ -249,6 +248,7 @@ static int decode_frame(AVCodecContext *avctx,
memcpy(&f->data[0][ (avctx->height-y)*f->linesize[0] ],
&buf[y*avctx->width*3],
3*avctx->width);
+
break;
case 2:
@@ -259,10 +259,13 @@ static int decode_frame(AVCodecContext *avctx,
*/
for(i = 0; i < planes; i++){
is_chroma = !!i;
- if(fraps2_decode_plane(s, f->data[i], f->linesize[i], avctx->width >> is_chroma,
- avctx->height >> is_chroma, buf + offs[i], offs[i + 1] - offs[i], is_chroma, 1) < 0) {
+ if ((ret = fraps2_decode_plane(s, f->data[i], f->linesize[i],
+ avctx->width >> is_chroma,
+ avctx->height >> is_chroma,
+ buf + offs[i], offs[i + 1] - offs[i],
+ is_chroma, 1)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error decoding plane %i\n", i);
- return AVERROR_INVALIDDATA;
+ return ret;
}
}
break;
@@ -270,10 +273,11 @@ static int decode_frame(AVCodecContext *avctx,
case 5:
/* Virtually the same as version 4, but is for RGB24 */
for(i = 0; i < planes; i++){
- if(fraps2_decode_plane(s, f->data[0] + i + (f->linesize[0] * (avctx->height - 1)), -f->linesize[0],
- avctx->width, avctx->height, buf + offs[i], offs[i + 1] - offs[i], 0, 3) < 0) {
+ if ((ret = fraps2_decode_plane(s, f->data[0] + i + (f->linesize[0] * (avctx->height - 1)),
+ -f->linesize[0], avctx->width, avctx->height,
+ buf + offs[i], offs[i + 1] - offs[i], 0, 3)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error decoding plane %i\n", i);
- return AVERROR_INVALIDDATA;
+ return ret;
}
}
out = f->data[0];
diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c
index 0199636822..008843c673 100644
--- a/libavcodec/kgv1dec.c
+++ b/libavcodec/kgv1dec.c
@@ -55,14 +55,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
int w, h, i, res;
if (avpkt->size < 2)
- return -1;
+ return AVERROR_INVALIDDATA;
w = (buf[0] + 1) * 8;
h = (buf[1] + 1) * 8;
buf += 2;
- if (av_image_check_size(w, h, 0, avctx))
- return -1;
+ if ((res = av_image_check_size(w, h, 0, avctx)) < 0)
+ return res;
if (w != avctx->width || h != avctx->height) {
if (c->prev.data[0])
diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c
index edfafa0401..ffef77138b 100644
--- a/libavcodec/kmvc.c
+++ b/libavcodec/kmvc.c
@@ -264,11 +264,10 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame,
{
KmvcContext *const ctx = avctx->priv_data;
uint8_t *out, *src;
- int i;
+ int i, ret;
int header;
int blocksize;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
- int ret;
bytestream2_init(&ctx->g, avpkt->data, avpkt->size);
if (ctx->pic.data[0])
@@ -383,7 +382,7 @@ static av_cold int decode_init(AVCodecContext * avctx)
if (avctx->width > 320 || avctx->height > 200) {
av_log(avctx, AV_LOG_ERROR, "KMVC supports frames <= 320x200\n");
- return AVERROR_INVALIDDATA;
+ return AVERROR(EINVAL);
}
c->frm0 = av_mallocz(320 * 200);
diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
index 13ecbb057f..8972143eab 100644
--- a/libavcodec/pnm.c
+++ b/libavcodec/pnm.c
@@ -65,7 +65,7 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
pnm_get(s, buf1, sizeof(buf1));
s->type= buf1[1]-'0';
if(buf1[0] != 'P')
- return -1;
+ return AVERROR_INVALIDDATA;
if (s->type==1 || s->type==4) {
avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
@@ -103,12 +103,12 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
} else if (!strcmp(buf1, "ENDHDR")) {
break;
} else {
- return -1;
+ return AVERROR_INVALIDDATA;
}
}
/* check that all tags are present */
if (w <= 0 || h <= 0 || maxval <= 0 || depth <= 0 || tuple_type[0] == '\0' || av_image_check_size(w, h, 0, avctx) || s->bytestream >= s->bytestream_end)
- return -1;
+ return AVERROR_INVALIDDATA;
avctx->width = w;
avctx->height = h;
@@ -137,18 +137,18 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
avctx->pix_fmt = AV_PIX_FMT_RGBA64BE;
}
} else {
- return -1;
+ return AVERROR_INVALIDDATA;
}
return 0;
} else {
- return -1;
+ return AVERROR_INVALIDDATA;
}
pnm_get(s, buf1, sizeof(buf1));
w = atoi(buf1);
pnm_get(s, buf1, sizeof(buf1));
h = atoi(buf1);
if(w <= 0 || h <= 0 || av_image_check_size(w, h, 0, avctx) || s->bytestream >= s->bytestream_end)
- return -1;
+ return AVERROR_INVALIDDATA;
avctx->width = w;
avctx->height = h;
@@ -168,7 +168,7 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
} else {
av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format\n");
avctx->pix_fmt = AV_PIX_FMT_NONE;
- return -1;
+ return AVERROR_INVALIDDATA;
}
}
}else
@@ -176,10 +176,10 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
/* more check if YUV420 */
if (avctx->pix_fmt == AV_PIX_FMT_YUV420P) {
if ((avctx->width & 1) != 0)
- return -1;
+ return AVERROR_INVALIDDATA;
h = (avctx->height * 2);
if ((h % 3) != 0)
- return -1;
+ return AVERROR_INVALIDDATA;
h /= 3;
avctx->height = h;
}
diff --git a/libavcodec/pnmdec.c b/libavcodec/pnmdec.c
index fd17fe3499..1c22f74052 100644
--- a/libavcodec/pnmdec.c
+++ b/libavcodec/pnmdec.c
@@ -41,8 +41,8 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data,
s->bytestream = (uint8_t *)buf;
s->bytestream_end = (uint8_t *)buf + buf_size;
- if (ff_pnm_decode_header(avctx, s) < 0)
- return AVERROR_INVALIDDATA;
+ if ((ret = ff_pnm_decode_header(avctx, s)) < 0)
+ return ret;
if (p->data[0])
avctx->release_buffer(avctx, p);
@@ -57,7 +57,7 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data,
switch (avctx->pix_fmt) {
default:
- return AVERROR_INVALIDDATA;
+ return AVERROR(EINVAL);
case AV_PIX_FMT_RGBA64BE:
n = avctx->width * 8;
components=4;
diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c
index e2c1d2804a..eba48ac630 100644
--- a/libavcodec/truemotion1.c
+++ b/libavcodec/truemotion1.c
@@ -308,7 +308,7 @@ static void gen_vector_table24(TrueMotion1Context *s, const uint8_t *sel_vector_
* there was an error while decoding the header */
static int truemotion1_decode_header(TrueMotion1Context *s)
{
- int i;
+ int i, ret;
int width_shift = 0;
int new_pix_fmt;
struct frame_header header;
@@ -319,7 +319,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s)
if (s->buf[0] < 0x10 || header.header_size >= s->size)
{
av_log(s->avctx, AV_LOG_ERROR, "invalid header size (%d)\n", s->buf[0]);
- return -1;
+ return AVERROR_INVALIDDATA;
}
/* unscramble the header bytes with a XOR operation */
@@ -343,7 +343,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s)
if (header.header_type > 3)
{
av_log(s->avctx, AV_LOG_ERROR, "invalid header type (%d)\n", header.header_type);
- return -1;
+ return AVERROR_INVALIDDATA;
} else if ((header.header_type == 2) || (header.header_type == 3)) {
s->flags = header.flags;
if (!(s->flags & FLAG_INTERFRAME))
@@ -371,7 +371,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s)
if (header.compression >= 17) {
av_log(s->avctx, AV_LOG_ERROR, "invalid compression type (%d)\n", header.compression);
- return -1;
+ return AVERROR_INVALIDDATA;
}
if ((header.deltaset != s->last_deltaset) ||
@@ -385,7 +385,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s)
sel_vector_table = tables[header.vectable - 1];
else {
av_log(s->avctx, AV_LOG_ERROR, "invalid vector table id (%d)\n", header.vectable);
- return -1;
+ return AVERROR_INVALIDDATA;
}
}
@@ -396,8 +396,8 @@ static int truemotion1_decode_header(TrueMotion1Context *s)
new_pix_fmt = AV_PIX_FMT_RGB555; // RGB565 is supported as well
s->w >>= width_shift;
- if (av_image_check_size(s->w, s->h, 0, s->avctx) < 0)
- return -1;
+ if ((ret = av_image_check_size(s->w, s->h, 0, s->avctx)) < 0)
+ return ret;
if (s->w != s->avctx->width || s->h != s->avctx->height ||
new_pix_fmt != s->avctx->pix_fmt) {
@@ -860,21 +860,21 @@ static int truemotion1_decode_frame(AVCodecContext *avctx,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
+ int ret, buf_size = avpkt->size;
TrueMotion1Context *s = avctx->priv_data;
s->buf = buf;
s->size = buf_size;
- if (truemotion1_decode_header(s) == -1)
- return -1;
+ if ((ret = truemotion1_decode_header(s)) < 0)
+ return ret;
s->frame.reference = 3;
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID |
FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
- if (avctx->reget_buffer(avctx, &s->frame) < 0) {
+ if ((ret = avctx->reget_buffer(avctx, &s->frame)) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return -1;
+ return ret;
}
if (compression_types[s->compression].algorithm == ALGO_RGB24H) {