mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
sunrast: Return AVERROR values instead of -1.
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
This commit is contained in:
parent
4fbccfab23
commit
41afdd913a
@ -72,13 +72,14 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
unsigned int w, h, depth, type, maptype, maplength, stride, x, y, len, alen;
|
unsigned int w, h, depth, type, maptype, maplength, stride, x, y, len, alen;
|
||||||
uint8_t *ptr;
|
uint8_t *ptr;
|
||||||
const uint8_t *bufstart = buf;
|
const uint8_t *bufstart = buf;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (avpkt->size < 32)
|
if (avpkt->size < 32)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
if (AV_RB32(buf) != RAS_MAGIC) {
|
if (AV_RB32(buf) != RAS_MAGIC) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "this is not sunras encoded data\n");
|
av_log(avctx, AV_LOG_ERROR, "this is not sunras encoded data\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
w = AV_RB32(buf + 4);
|
w = AV_RB32(buf + 4);
|
||||||
@ -95,15 +96,15 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
}
|
}
|
||||||
if (type > RT_FORMAT_IFF) {
|
if (type > RT_FORMAT_IFF) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "invalid (compression) type\n");
|
av_log(avctx, AV_LOG_ERROR, "invalid (compression) type\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
if (av_image_check_size(w, h, 0, avctx)) {
|
if (av_image_check_size(w, h, 0, avctx)) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "invalid image size\n");
|
av_log(avctx, AV_LOG_ERROR, "invalid image size\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
if (maptype & ~1) {
|
if (maptype & ~1) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "invalid colormap type\n");
|
av_log(avctx, AV_LOG_ERROR, "invalid colormap type\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -119,7 +120,7 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
av_log(avctx, AV_LOG_ERROR, "invalid depth\n");
|
av_log(avctx, AV_LOG_ERROR, "invalid depth\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->data[0])
|
if (p->data[0])
|
||||||
@ -127,9 +128,9 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
|
|
||||||
if (w != avctx->width || h != avctx->height)
|
if (w != avctx->width || h != avctx->height)
|
||||||
avcodec_set_dimensions(avctx, w, h);
|
avcodec_set_dimensions(avctx, w, h);
|
||||||
if (avctx->get_buffer(avctx, p) < 0) {
|
if ((ret = avctx->get_buffer(avctx, p)) < 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||||
return -1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
p->pict_type = AV_PICTURE_TYPE_I;
|
p->pict_type = AV_PICTURE_TYPE_I;
|
||||||
@ -145,7 +146,7 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
|
|
||||||
if (maplength % 3 || maplength > 768) {
|
if (maplength % 3 || maplength > 768) {
|
||||||
av_log(avctx, AV_LOG_WARNING, "invalid colormap length\n");
|
av_log(avctx, AV_LOG_WARNING, "invalid colormap length\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr = p->data[1];
|
ptr = p->data[1];
|
||||||
|
Loading…
Reference in New Issue
Block a user