mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
sgidec: return meaningful error codes
Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
parent
5efa5103b0
commit
997e2b59e3
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user