aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/sgidec.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2013-07-26 21:26:56 +0000
committerPaul B Mahol <onemda@gmail.com>2013-07-27 12:00:25 +0000
commit997e2b59e354a16995656ba16edc293122fd4775 (patch)
tree0c06f0b5f18428800dfbbf4ae8ea3c62a810d0f5 /libavcodec/sgidec.c
parent5efa5103b0e7b5c63d36c4df224c2bdeff276413 (diff)
downloadandroid_external_ffmpeg-997e2b59e354a16995656ba16edc293122fd4775.tar.gz
android_external_ffmpeg-997e2b59e354a16995656ba16edc293122fd4775.tar.bz2
android_external_ffmpeg-997e2b59e354a16995656ba16edc293122fd4775.zip
sgidec: return meaningful error codes
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavcodec/sgidec.c')
-rw-r--r--libavcodec/sgidec.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c
index c6e7508d50..a32620be78 100644
--- a/libavcodec/sgidec.c
+++ b/libavcodec/sgidec.c
@@ -41,7 +41,7 @@ typedef struct SgiState {
* @param out_buf Points to one line after the output buffer.
* @param out_end end of line in output buffer
* @param pixelstride pixel stride of input buffer
- * @return size of output in bytes, -1 if buffer overflows
+ * @return size of output in bytes, else return error code.
*/
static int expand_rle_row(SgiState *s, uint8_t *out_buf,
uint8_t *out_end, int pixelstride)
@@ -58,7 +58,8 @@ static int expand_rle_row(SgiState *s, uint8_t *out_buf,
}
/* Check for buffer overflow. */
- if(out_buf + pixelstride * (count-1) >= out_end) return -1;
+ if (out_buf + pixelstride * (count - 1) >= out_end)
+ return AVERROR_INVALIDDATA;
if (pixel & 0x80) {
while (count--) {
@@ -81,7 +82,7 @@ static int expand_rle_row(SgiState *s, uint8_t *out_buf,
* Read a run length encoded SGI image.
* @param out_buf output buffer
* @param s the current image state
- * @return 0 if no error, else return error number.
+ * @return 0 if no error, else return error code.
*/
static int read_rle_sgi(uint8_t *out_buf, SgiState *s)
{
@@ -115,7 +116,7 @@ static int read_rle_sgi(uint8_t *out_buf, SgiState *s)
* Read an uncompressed SGI image.
* @param out_buf output buffer
* @param s the current image state
- * @return 0 if read success, otherwise return -1.
+ * @return 0 if read success, else return error code.
*/
static int read_uncompressed_sgi(unsigned char* out_buf, SgiState *s)
{
@@ -181,13 +182,13 @@ static int decode_frame(AVCodecContext *avctx,
if (s->bytes_per_channel != 1 && (s->bytes_per_channel != 2 || rle)) {
av_log(avctx, AV_LOG_ERROR, "wrong channel number\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
/* Check for supported image dimensions. */
if (dimension != 2 && dimension != 3) {
av_log(avctx, AV_LOG_ERROR, "wrong dimension number\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
if (s->depth == SGI_GRAYSCALE) {
@@ -198,11 +199,11 @@ static int decode_frame(AVCodecContext *avctx,
avctx->pix_fmt = s->bytes_per_channel == 2 ? AV_PIX_FMT_RGBA64BE : AV_PIX_FMT_RGBA;
} else {
av_log(avctx, AV_LOG_ERROR, "wrong picture format\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
if (av_image_check_size(s->width, s->height, 0, avctx))
- return -1;
+ return AVERROR_INVALIDDATA;
avcodec_set_dimensions(avctx, s->width, s->height);
if ((ret = ff_get_buffer(avctx, p, 0)) < 0)