ThreadFrame last_picture;
ThreadFrame picture;
+ AVDictionary *frame_metadata;
+
+ uint8_t iccp_name[82];
+ uint8_t *iccp_data;
+ size_t iccp_data_len;
+
+ int stereo_mode;
+
+ int have_chrm;
+ uint32_t white_point[2];
+ uint32_t display_primaries[3][2];
+
enum PNGHeaderState hdr_state;
enum PNGImageState pic_state;
int width, height;
int has_trns;
uint8_t transparent_color_be[6];
+ uint8_t *background_buf;
+ unsigned background_buf_allocated;
uint32_t palette[256];
uint8_t *crow_buf;
uint8_t *last_row;
}
}
-static int png_decode_idat(PNGDecContext *s, int length,
+static int png_decode_idat(PNGDecContext *s, GetByteContext *gb,
uint8_t *dst, ptrdiff_t dst_stride)
{
int ret;
- s->zstream.avail_in = FFMIN(length, bytestream2_get_bytes_left(&s->gb));
- s->zstream.next_in = s->gb.buffer;
- bytestream2_skip(&s->gb, length);
+ s->zstream.avail_in = bytestream2_get_bytes_left(gb);
+ s->zstream.next_in = gb->buffer;
/* decode one line if possible */
while (s->zstream.avail_in > 0) {
return out;
}
-static int decode_text_chunk(PNGDecContext *s, uint32_t length, int compressed,
- AVDictionary **dict)
+static int decode_text_chunk(PNGDecContext *s, GetByteContext *gb, int compressed)
{
int ret, method;
- const uint8_t *data = s->gb.buffer;
- const uint8_t *data_end = data + length;
+ const uint8_t *data = gb->buffer;
+ const uint8_t *data_end = gb->buffer_end;
const uint8_t *keyword = data;
const uint8_t *keyword_end = memchr(keyword, 0, data_end - keyword);
uint8_t *kw_utf8 = NULL, *text, *txt_utf8 = NULL;
return AVERROR(ENOMEM);
}
- av_dict_set(dict, kw_utf8, txt_utf8,
+ av_dict_set(&s->frame_metadata, kw_utf8, txt_utf8,
AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
return 0;
}
static int decode_ihdr_chunk(AVCodecContext *avctx, PNGDecContext *s,
- uint32_t length)
+ GetByteContext *gb)
{
- if (length != 13)
+ if (bytestream2_get_bytes_left(gb) != 13)
return AVERROR_INVALIDDATA;
if (s->pic_state & PNG_IDAT) {
return AVERROR_INVALIDDATA;
}
- s->width = s->cur_w = bytestream2_get_be32(&s->gb);
- s->height = s->cur_h = bytestream2_get_be32(&s->gb);
+ s->width = s->cur_w = bytestream2_get_be32(gb);
+ s->height = s->cur_h = bytestream2_get_be32(gb);
if (av_image_check_size(s->width, s->height, 0, avctx)) {
s->cur_w = s->cur_h = s->width = s->height = 0;
av_log(avctx, AV_LOG_ERROR, "Invalid image size\n");
return AVERROR_INVALIDDATA;
}
- s->bit_depth = bytestream2_get_byte(&s->gb);
+ s->bit_depth = bytestream2_get_byte(gb);
if (s->bit_depth != 1 && s->bit_depth != 2 && s->bit_depth != 4 &&
s->bit_depth != 8 && s->bit_depth != 16) {
av_log(avctx, AV_LOG_ERROR, "Invalid bit depth\n");
goto error;
}
- s->color_type = bytestream2_get_byte(&s->gb);
- s->compression_type = bytestream2_get_byte(&s->gb);
+ s->color_type = bytestream2_get_byte(gb);
+ s->compression_type = bytestream2_get_byte(gb);
if (s->compression_type) {
av_log(avctx, AV_LOG_ERROR, "Invalid compression method %d\n", s->compression_type);
goto error;
}
- s->filter_type = bytestream2_get_byte(&s->gb);
- s->interlace_type = bytestream2_get_byte(&s->gb);
- bytestream2_skip(&s->gb, 4); /* crc */
+ s->filter_type = bytestream2_get_byte(gb);
+ s->interlace_type = bytestream2_get_byte(gb);
s->hdr_state |= PNG_IHDR;
if (avctx->debug & FF_DEBUG_PICT_INFO)
av_log(avctx, AV_LOG_DEBUG, "width=%d height=%d depth=%d color_type=%d "
return AVERROR_INVALIDDATA;
}
-static int decode_phys_chunk(AVCodecContext *avctx, PNGDecContext *s)
+static int decode_phys_chunk(AVCodecContext *avctx, PNGDecContext *s,
+ GetByteContext *gb)
{
if (s->pic_state & PNG_IDAT) {
av_log(avctx, AV_LOG_ERROR, "pHYs after IDAT\n");
return AVERROR_INVALIDDATA;
}
- avctx->sample_aspect_ratio.num = bytestream2_get_be32(&s->gb);
- avctx->sample_aspect_ratio.den = bytestream2_get_be32(&s->gb);
+ avctx->sample_aspect_ratio.num = bytestream2_get_be32(gb);
+ avctx->sample_aspect_ratio.den = bytestream2_get_be32(gb);
if (avctx->sample_aspect_ratio.num < 0 || avctx->sample_aspect_ratio.den < 0)
avctx->sample_aspect_ratio = (AVRational){ 0, 1 };
- bytestream2_skip(&s->gb, 1); /* unit specifier */
- bytestream2_skip(&s->gb, 4); /* crc */
+ bytestream2_skip(gb, 1); /* unit specifier */
return 0;
}
static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s,
- uint32_t length, AVFrame *p)
+ GetByteContext *gb, AVFrame *p)
{
int ret;
size_t byte_depth = s->bit_depth > 8 ? 2 : 1;
if (s->has_trns && s->color_type != PNG_COLOR_TYPE_PALETTE)
s->bpp -= byte_depth;
- ret = png_decode_idat(s, length, p->data[0], p->linesize[0]);
+ ret = png_decode_idat(s, gb, p->data[0], p->linesize[0]);
if (s->has_trns && s->color_type != PNG_COLOR_TYPE_PALETTE)
s->bpp += byte_depth;
if (ret < 0)
return ret;
- bytestream2_skip(&s->gb, 4); /* crc */
-
return 0;
}
static int decode_plte_chunk(AVCodecContext *avctx, PNGDecContext *s,
- uint32_t length)
+ GetByteContext *gb)
{
+ int length = bytestream2_get_bytes_left(gb);
int n, i, r, g, b;
if ((length % 3) != 0 || length > 256 * 3)
/* read the palette */
n = length / 3;
for (i = 0; i < n; i++) {
- r = bytestream2_get_byte(&s->gb);
- g = bytestream2_get_byte(&s->gb);
- b = bytestream2_get_byte(&s->gb);
+ r = bytestream2_get_byte(gb);
+ g = bytestream2_get_byte(gb);
+ b = bytestream2_get_byte(gb);
s->palette[i] = (0xFFU << 24) | (r << 16) | (g << 8) | b;
}
for (; i < 256; i++)
s->palette[i] = (0xFFU << 24);
s->hdr_state |= PNG_PLTE;
- bytestream2_skip(&s->gb, 4); /* crc */
return 0;
}
static int decode_trns_chunk(AVCodecContext *avctx, PNGDecContext *s,
- uint32_t length)
+ GetByteContext *gb)
{
+ int length = bytestream2_get_bytes_left(gb);
int v, i;
if (!(s->hdr_state & PNG_IHDR)) {
return AVERROR_INVALIDDATA;
for (i = 0; i < length; i++) {
- unsigned v = bytestream2_get_byte(&s->gb);
+ unsigned v = bytestream2_get_byte(gb);
s->palette[i] = (s->palette[i] & 0x00ffffff) | (v << 24);
}
} else if (s->color_type == PNG_COLOR_TYPE_GRAY || s->color_type == PNG_COLOR_TYPE_RGB) {
for (i = 0; i < length / 2; i++) {
/* only use the least significant bits */
- v = av_mod_uintp2(bytestream2_get_be16(&s->gb), s->bit_depth);
+ v = av_mod_uintp2(bytestream2_get_be16(gb), s->bit_depth);
if (s->bit_depth > 8)
AV_WB16(&s->transparent_color_be[2 * i], v);
return AVERROR_INVALIDDATA;
}
- bytestream2_skip(&s->gb, 4); /* crc */
s->has_trns = 1;
return 0;
}
-static int decode_iccp_chunk(PNGDecContext *s, int length, AVFrame *f)
+static int decode_iccp_chunk(PNGDecContext *s, GetByteContext *gb, AVFrame *f)
{
int ret, cnt = 0;
- uint8_t *data, profile_name[82];
AVBPrint bp;
- AVFrameSideData *sd;
- while ((profile_name[cnt++] = bytestream2_get_byte(&s->gb)) && cnt < 81);
+ while ((s->iccp_name[cnt++] = bytestream2_get_byte(gb)) && cnt < 81);
if (cnt > 80) {
av_log(s->avctx, AV_LOG_ERROR, "iCCP with invalid name!\n");
- return AVERROR_INVALIDDATA;
+ ret = AVERROR_INVALIDDATA;
+ goto fail;
}
- length = FFMAX(length - cnt, 0);
-
- if (bytestream2_get_byte(&s->gb) != 0) {
+ if (bytestream2_get_byte(gb) != 0) {
av_log(s->avctx, AV_LOG_ERROR, "iCCP with invalid compression!\n");
- return AVERROR_INVALIDDATA;
+ ret = AVERROR_INVALIDDATA;
+ goto fail;
}
- length = FFMAX(length - 1, 0);
-
- if ((ret = decode_zbuf(&bp, s->gb.buffer, s->gb.buffer + length)) < 0)
+ if ((ret = decode_zbuf(&bp, gb->buffer, gb->buffer_end)) < 0)
return ret;
- ret = av_bprint_finalize(&bp, (char **)&data);
+ av_freep(&s->iccp_data);
+ ret = av_bprint_finalize(&bp, (char **)&s->iccp_data);
if (ret < 0)
return ret;
-
- sd = av_frame_new_side_data(f, AV_FRAME_DATA_ICC_PROFILE, bp.len);
- if (!sd) {
- av_free(data);
- return AVERROR(ENOMEM);
- }
-
- av_dict_set(&sd->metadata, "name", profile_name, 0);
- memcpy(sd->data, data, bp.len);
- av_free(data);
-
- /* ICC compressed data and CRC */
- bytestream2_skip(&s->gb, length + 4);
+ s->iccp_data_len = bp.len;
return 0;
+fail:
+ s->iccp_name[0] = 0;
+ return ret;
}
static void handle_small_bpp(PNGDecContext *s, AVFrame *p)
}
static int decode_fctl_chunk(AVCodecContext *avctx, PNGDecContext *s,
- uint32_t length)
+ GetByteContext *gb)
{
uint32_t sequence_number;
int cur_w, cur_h, x_offset, y_offset, dispose_op, blend_op;
- if (length != 26)
+ if (bytestream2_get_bytes_left(gb) != 26)
return AVERROR_INVALIDDATA;
if (!(s->hdr_state & PNG_IHDR)) {
s->last_y_offset = s->y_offset;
s->last_dispose_op = s->dispose_op;
- sequence_number = bytestream2_get_be32(&s->gb);
- cur_w = bytestream2_get_be32(&s->gb);
- cur_h = bytestream2_get_be32(&s->gb);
- x_offset = bytestream2_get_be32(&s->gb);
- y_offset = bytestream2_get_be32(&s->gb);
- bytestream2_skip(&s->gb, 4); /* delay_num (2), delay_den (2) */
- dispose_op = bytestream2_get_byte(&s->gb);
- blend_op = bytestream2_get_byte(&s->gb);
- bytestream2_skip(&s->gb, 4); /* crc */
+ sequence_number = bytestream2_get_be32(gb);
+ cur_w = bytestream2_get_be32(gb);
+ cur_h = bytestream2_get_be32(gb);
+ x_offset = bytestream2_get_be32(gb);
+ y_offset = bytestream2_get_be32(gb);
+ bytestream2_skip(gb, 4); /* delay_num (2), delay_den (2) */
+ dispose_op = bytestream2_get_byte(gb);
+ blend_op = bytestream2_get_byte(gb);
if (sequence_number == 0 &&
(cur_w != s->width ||
ff_thread_await_progress(&s->last_picture, INT_MAX, 0);
// need to reset a rectangle to background:
- // create a new writable copy
if (s->last_dispose_op == APNG_DISPOSE_OP_BACKGROUND) {
- int ret = av_frame_make_writable(s->last_picture.f);
- if (ret < 0)
- return ret;
+ av_fast_malloc(&s->background_buf, &s->background_buf_allocated,
+ src_stride * p->height);
+ if (!s->background_buf)
+ return AVERROR(ENOMEM);
- src = s->last_picture.f->data[0];
- src_stride = s->last_picture.f->linesize[0];
+ memcpy(s->background_buf, src, src_stride * p->height);
for (y = s->last_y_offset; y < s->last_y_offset + s->last_h; y++) {
- memset(s->last_picture.f->data[0] + src_stride * y +
+ memset(s->background_buf + src_stride * y +
s->bpp * s->last_x_offset, 0, s->bpp * s->last_w);
}
+
+ src = s->background_buf;
}
// copy unchanged rectangles from the last frame
AVFrame *p, const AVPacket *avpkt)
{
const AVCRC *crc_tab = av_crc_get_table(AV_CRC_32_IEEE_LE);
- AVDictionary **metadatap = NULL;
uint32_t tag, length;
int decode_next_dat = 0;
int i, ret;
for (;;) {
+ GetByteContext gb_chunk;
+
length = bytestream2_get_bytes_left(&s->gb);
if (length <= 0) {
}
length = bytestream2_get_be32(&s->gb);
- if (length > 0x7fffffff || length > bytestream2_get_bytes_left(&s->gb)) {
+ if (length > 0x7fffffff || length + 8 > bytestream2_get_bytes_left(&s->gb)) {
av_log(avctx, AV_LOG_ERROR, "chunk too big\n");
ret = AVERROR_INVALIDDATA;
goto fail;
goto fail;
}
av_log(avctx, AV_LOG_ERROR, ", skipping\n");
- bytestream2_skip(&s->gb, 4); /* tag */
- goto skip_tag;
+ bytestream2_skip(&s->gb, length + 8); /* tag */
}
}
tag = bytestream2_get_le32(&s->gb);
av_log(avctx, AV_LOG_DEBUG, "png: tag=%s length=%u\n",
av_fourcc2str(tag), length);
+ bytestream2_init(&gb_chunk, s->gb.buffer, length);
+ bytestream2_skip(&s->gb, length + 4);
+
if (avctx->codec_id == AV_CODEC_ID_PNG &&
avctx->skip_frame == AVDISCARD_ALL) {
switch(tag) {
case MKTAG('t', 'R', 'N', 'S'):
break;
default:
- goto skip_tag;
+ continue;
}
}
- metadatap = &p->metadata;
switch (tag) {
case MKTAG('I', 'H', 'D', 'R'):
- if ((ret = decode_ihdr_chunk(avctx, s, length)) < 0)
+ if ((ret = decode_ihdr_chunk(avctx, s, &gb_chunk)) < 0)
goto fail;
break;
case MKTAG('p', 'H', 'Y', 's'):
- if ((ret = decode_phys_chunk(avctx, s)) < 0)
+ if ((ret = decode_phys_chunk(avctx, s, &gb_chunk)) < 0)
goto fail;
break;
case MKTAG('f', 'c', 'T', 'L'):
if (!CONFIG_APNG_DECODER || avctx->codec_id != AV_CODEC_ID_APNG)
- goto skip_tag;
- if ((ret = decode_fctl_chunk(avctx, s, length)) < 0)
+ continue;
+ if ((ret = decode_fctl_chunk(avctx, s, &gb_chunk)) < 0)
goto fail;
decode_next_dat = 1;
break;
case MKTAG('f', 'd', 'A', 'T'):
if (!CONFIG_APNG_DECODER || avctx->codec_id != AV_CODEC_ID_APNG)
- goto skip_tag;
- if (!decode_next_dat || length < 4) {
+ continue;
+ if (!decode_next_dat || bytestream2_get_bytes_left(&gb_chunk) < 4) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
- bytestream2_get_be32(&s->gb);
- length -= 4;
+ bytestream2_get_be32(&gb_chunk);
/* fallthrough */
case MKTAG('I', 'D', 'A', 'T'):
if (CONFIG_APNG_DECODER && avctx->codec_id == AV_CODEC_ID_APNG && !decode_next_dat)
- goto skip_tag;
- if ((ret = decode_idat_chunk(avctx, s, length, p)) < 0)
+ continue;
+ if ((ret = decode_idat_chunk(avctx, s, &gb_chunk, p)) < 0)
goto fail;
break;
case MKTAG('P', 'L', 'T', 'E'):
- if (decode_plte_chunk(avctx, s, length) < 0)
- goto skip_tag;
+ decode_plte_chunk(avctx, s, &gb_chunk);
break;
case MKTAG('t', 'R', 'N', 'S'):
- if (decode_trns_chunk(avctx, s, length) < 0)
- goto skip_tag;
+ decode_trns_chunk(avctx, s, &gb_chunk);
break;
case MKTAG('t', 'E', 'X', 't'):
- if (decode_text_chunk(s, length, 0, metadatap) < 0)
+ if (decode_text_chunk(s, &gb_chunk, 0) < 0)
av_log(avctx, AV_LOG_WARNING, "Broken tEXt chunk\n");
- bytestream2_skip(&s->gb, length + 4);
break;
case MKTAG('z', 'T', 'X', 't'):
- if (decode_text_chunk(s, length, 1, metadatap) < 0)
+ if (decode_text_chunk(s, &gb_chunk, 1) < 0)
av_log(avctx, AV_LOG_WARNING, "Broken zTXt chunk\n");
- bytestream2_skip(&s->gb, length + 4);
break;
case MKTAG('s', 'T', 'E', 'R'): {
- int mode = bytestream2_get_byte(&s->gb);
- AVStereo3D *stereo3d = av_stereo3d_create_side_data(p);
- if (!stereo3d) {
- ret = AVERROR(ENOMEM);
- goto fail;
- }
+ int mode = bytestream2_get_byte(&gb_chunk);
if (mode == 0 || mode == 1) {
- stereo3d->type = AV_STEREO3D_SIDEBYSIDE;
- stereo3d->flags = mode ? 0 : AV_STEREO3D_FLAG_INVERT;
+ s->stereo_mode = mode;
} else {
av_log(avctx, AV_LOG_WARNING,
"Unknown value in sTER chunk (%d)\n", mode);
}
- bytestream2_skip(&s->gb, 4); /* crc */
break;
}
case MKTAG('i', 'C', 'C', 'P'): {
- if ((ret = decode_iccp_chunk(s, length, p)) < 0)
+ if ((ret = decode_iccp_chunk(s, &gb_chunk, p)) < 0)
goto fail;
break;
}
case MKTAG('c', 'H', 'R', 'M'): {
- AVMasteringDisplayMetadata *mdm = av_mastering_display_metadata_create_side_data(p);
- if (!mdm) {
- ret = AVERROR(ENOMEM);
- goto fail;
- }
+ s->have_chrm = 1;
- mdm->white_point[0] = av_make_q(bytestream2_get_be32(&s->gb), 100000);
- mdm->white_point[1] = av_make_q(bytestream2_get_be32(&s->gb), 100000);
+ s->white_point[0] = bytestream2_get_be32(&gb_chunk);
+ s->white_point[1] = bytestream2_get_be32(&gb_chunk);
/* RGB Primaries */
for (i = 0; i < 3; i++) {
- mdm->display_primaries[i][0] = av_make_q(bytestream2_get_be32(&s->gb), 100000);
- mdm->display_primaries[i][1] = av_make_q(bytestream2_get_be32(&s->gb), 100000);
+ s->display_primaries[i][0] = bytestream2_get_be32(&gb_chunk);
+ s->display_primaries[i][1] = bytestream2_get_be32(&gb_chunk);
}
- mdm->has_primaries = 1;
- bytestream2_skip(&s->gb, 4); /* crc */
break;
}
case MKTAG('g', 'A', 'M', 'A'): {
AVBPrint bp;
char *gamma_str;
- int num = bytestream2_get_be32(&s->gb);
+ int num = bytestream2_get_be32(&gb_chunk);
av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
av_bprintf(&bp, "%i/%i", num, 100000);
if (ret < 0)
return ret;
- av_dict_set(&p->metadata, "gamma", gamma_str, AV_DICT_DONT_STRDUP_VAL);
+ av_dict_set(&s->frame_metadata, "gamma", gamma_str, AV_DICT_DONT_STRDUP_VAL);
- bytestream2_skip(&s->gb, 4); /* crc */
break;
}
case MKTAG('I', 'E', 'N', 'D'):
ret = AVERROR_INVALIDDATA;
goto fail;
}
- bytestream2_skip(&s->gb, 4); /* crc */
goto exit_loop;
- default:
- /* skip tag */
-skip_tag:
- bytestream2_skip(&s->gb, length + 4);
- break;
}
}
exit_loop:
return ret;
}
+static void clear_frame_metadata(PNGDecContext *s)
+{
+ av_freep(&s->iccp_data);
+ s->iccp_data_len = 0;
+ s->iccp_name[0] = 0;
+
+ s->stereo_mode = -1;
+
+ s->have_chrm = 0;
+
+ av_dict_free(&s->frame_metadata);
+}
+
+static int output_frame(PNGDecContext *s, AVFrame *f,
+ const AVFrame *src)
+{
+ int ret;
+
+ ret = av_frame_ref(f, src);
+ if (ret < 0)
+ return ret;
+
+ if (s->iccp_data) {
+ AVFrameSideData *sd = av_frame_new_side_data(f, AV_FRAME_DATA_ICC_PROFILE, s->iccp_data_len);
+ if (!sd) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+ memcpy(sd->data, s->iccp_data, s->iccp_data_len);
+
+ av_dict_set(&sd->metadata, "name", s->iccp_name, 0);
+ }
+
+ if (s->stereo_mode >= 0) {
+ AVStereo3D *stereo3d = av_stereo3d_create_side_data(f);
+ if (!stereo3d) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+
+ stereo3d->type = AV_STEREO3D_SIDEBYSIDE;
+ stereo3d->flags = s->stereo_mode ? 0 : AV_STEREO3D_FLAG_INVERT;
+ }
+
+ if (s->have_chrm) {
+ AVMasteringDisplayMetadata *mdm = av_mastering_display_metadata_create_side_data(f);
+ if (!mdm) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+
+ mdm->white_point[0] = av_make_q(s->white_point[0], 100000);
+ mdm->white_point[1] = av_make_q(s->white_point[1], 100000);
+
+ /* RGB Primaries */
+ for (int i = 0; i < 3; i++) {
+ mdm->display_primaries[i][0] = av_make_q(s->display_primaries[i][0], 100000);
+ mdm->display_primaries[i][1] = av_make_q(s->display_primaries[i][1], 100000);
+ }
+
+ mdm->has_primaries = 1;
+ }
+
+ FFSWAP(AVDictionary*, f->metadata, s->frame_metadata);
+
+ return 0;
+fail:
+ av_frame_unref(f);
+ return ret;
+}
+
#if CONFIG_PNG_DECODER
static int decode_frame_png(AVCodecContext *avctx,
void *data, int *got_frame,
PNGDecContext *const s = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
+ AVFrame *dst_frame = data;
AVFrame *p = s->picture.f;
int64_t sig;
int ret;
+ clear_frame_metadata(s);
+
bytestream2_init(&s->gb, buf, buf_size);
/* check signature */
goto the_end;
}
- if ((ret = av_frame_ref(data, s->picture.f)) < 0)
+ ret = output_frame(s, dst_frame, s->picture.f);
+ if (ret < 0)
goto the_end;
if (!(avctx->active_thread_type & FF_THREAD_FRAME)) {
AVPacket *avpkt)
{
PNGDecContext *const s = avctx->priv_data;
+ AVFrame *dst_frame = data;
int ret;
AVFrame *p = s->picture.f;
+ clear_frame_metadata(s);
+
if (!(s->hdr_state & PNG_IHDR)) {
if (!avctx->extradata_size)
return AVERROR_INVALIDDATA;
ret = AVERROR_INVALIDDATA;
goto end;
}
- if ((ret = av_frame_ref(data, s->picture.f)) < 0)
+
+ ret = output_frame(s, dst_frame, s->picture.f);
+ if (ret < 0)
goto end;
if (!(avctx->active_thread_type & FF_THREAD_FRAME)) {
s->last_row_size = 0;
av_freep(&s->tmp_row);
s->tmp_row_size = 0;
+ av_freep(&s->background_buf);
+
+ av_freep(&s->iccp_data);
+ av_dict_free(&s->frame_metadata);
return 0;
}
#if CONFIG_APNG_DECODER
-AVCodec ff_apng_decoder = {
+const AVCodec ff_apng_decoder = {
.name = "apng",
.long_name = NULL_IF_CONFIG_SMALL("APNG (Animated Portable Network Graphics) image"),
.type = AVMEDIA_TYPE_VIDEO,
#endif
#if CONFIG_PNG_DECODER
-AVCodec ff_png_decoder = {
+const AVCodec ff_png_decoder = {
.name = "png",
.long_name = NULL_IF_CONFIG_SMALL("PNG (Portable Network Graphics) image"),
.type = AVMEDIA_TYPE_VIDEO,