int i;
if (size < 2 * 64 * 4) {
av_log(avctx, AV_LOG_ERROR, "insufficient rtjpeg quant data\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
for (i = 0; i < 64; i++, buf += 4)
c->lq[i] = AV_RL32(buf);
int quality)
{
NuvContext *c = avctx->priv_data;
+ int ret;
+
width = FFALIGN(width, 2);
height = FFALIGN(height, 2);
if (quality >= 0)
if (width != c->width || height != c->height) {
// also reserve space for a possible additional header
int buf_size = 24 + height * width * 3 / 2 + AV_LZO_OUTPUT_PADDING;
- if (av_image_check_size(height, width, 0, avctx) < 0 ||
- buf_size > INT_MAX/8)
+ if (buf_size > INT_MAX/8)
return -1;
+ if ((ret = av_image_check_size(height, width, 0, avctx)) < 0)
+ return ret;
avctx->width = c->width = width;
avctx->height = c->height = height;
av_fast_malloc(&c->decomp_buf, &c->decomp_size,
if (buf_size < 12) {
av_log(avctx, AV_LOG_ERROR, "coded frame too small\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
// codec data (rtjpeg quant tables)
if (buf_size < 12 || buf[0] != 'V') {
av_log(avctx, AV_LOG_ERROR, "not a nuv video frame\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
comptype = buf[1];
switch (comptype) {
}
if (c->codec_frameheader) {
int w, h, q;
- int res;
if (buf_size < RTJPEG_HEADER_SIZE) {
av_log(avctx, AV_LOG_ERROR, "Too small NUV video frame\n");
return AVERROR_INVALIDDATA;
w = AV_RL16(&buf[6]);
h = AV_RL16(&buf[8]);
q = buf[10];
- res = codec_reinit(avctx, w, h, q);
- if (res < 0)
- return res;
- if (res) {
+ if ((result = codec_reinit(avctx, w, h, q)) < 0)
+ return result;
+ if (result) {
buf = avpkt->data;
buf_size = avpkt->size;
size_change = 1;
goto retry;
}
- buf = &buf[RTJPEG_HEADER_SIZE];
+ buf = &buf[RTJPEG_HEADER_SIZE];
buf_size -= RTJPEG_HEADER_SIZE;
}
result = avctx->reget_buffer(avctx, &c->pic);
if (result < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return -1;
+ return result;
}
c->pic.pict_type = keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
break;
default:
av_log(avctx, AV_LOG_ERROR, "unknown compression\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
*picture = c->pic;
static av_cold int decode_init(AVCodecContext *avctx)
{
NuvContext *c = avctx->priv_data;
+ int ret;
+
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
c->pic.data[0] = NULL;
c->decomp_buf = NULL;
ff_dsputil_init(&c->dsp, avctx);
- if (codec_reinit(avctx, avctx->width, avctx->height, -1) < 0)
- return 1;
+ if ((ret = codec_reinit(avctx, avctx->width, avctx->height, -1)) < 0)
+ return ret;
return 0;
}