summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-07-12 14:37:15 +0200
committerAnton Khirnov <anton@khirnov.net>2022-11-28 10:34:10 +0100
commit321fdaf810facef37b185c6b7fd7221c4c8e2f04 (patch)
treea33d827d689e29ef58dbdec15ebef927c652c114
parent88a1a3d5fa5bfc9c3f3b7e926c4de2aee6ee4b2c (diff)
lavc/pngenc: handle frame durations and AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
-rw-r--r--libavcodec/pngenc.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index d1448bd0cd..a54cfcdd69 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -977,6 +977,19 @@ static int encode_apng(AVCodecContext *avctx, AVPacket *pkt,
memcpy(pkt->data, s->last_frame_packet, s->last_frame_packet_size);
pkt->pts = pkt->dts = s->last_frame->pts;
+ pkt->duration = s->last_frame->duration;
+
+ if (s->last_frame->opaque_ref &&
+ avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
+ pkt->opaque = s->last_frame->opaque;
+ if (s->last_frame->opaque_ref) {
+ pkt->opaque_ref = av_buffer_ref(s->last_frame->opaque_ref);
+ if (!pkt->opaque_ref)
+ return AVERROR(ENOMEM);
+ }
+ }
+
+ avctx->reordered_opaque = s->last_frame->reordered_opaque;
}
if (pict) {
@@ -1219,7 +1232,8 @@ const FFCodec ff_apng_encoder = {
CODEC_LONG_NAME("APNG (Animated Portable Network Graphics) image"),
.p.type = AVMEDIA_TYPE_VIDEO,
.p.id = AV_CODEC_ID_APNG,
- .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
+ .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
+ AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
.priv_data_size = sizeof(PNGEncContext),
.init = png_enc_init,
.close = png_enc_close,