[FFmpeg-cvslog] sgidec: return meaningful error codes
Paul B Mahol
git at videolan.org
Sat Jul 27 14:05:34 CEST 2013
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Jul 26 21:26:56 2013 +0000| [997e2b59e354a16995656ba16edc293122fd4775] | committer: Paul B Mahol
sgidec: return meaningful error codes
Signed-off-by: Paul B Mahol <onemda at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=997e2b59e354a16995656ba16edc293122fd4775
---
libavcodec/sgidec.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c
index c6e7508..a32620b 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)
More information about the ffmpeg-cvslog
mailing list