diff mbox series

[FFmpeg-devel,26/30] lavc/libtheoraenc: handle frame durations and AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE

Message ID 20221127170351.11477-26-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/30] lavc/libx264: factor out setting up the input frame | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov Nov. 27, 2022, 5:03 p.m. UTC
---
 libavcodec/libtheoraenc.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c
index da16c6372e..9b8404ce31 100644
--- a/libavcodec/libtheoraenc.c
+++ b/libavcodec/libtheoraenc.c
@@ -347,6 +347,19 @@  static int encode_frame(AVCodecContext* avc_context, AVPacket *pkt,
     // HACK: assumes no encoder delay, this is true until libtheora becomes
     // multithreaded (which will be disabled unless explicitly requested)
     pkt->pts = pkt->dts = frame->pts;
+    pkt->duration = frame->duration;
+
+    if (avc_context->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
+        pkt->opaque = frame->opaque;
+        if (frame->opaque_ref) {
+            pkt->opaque_ref = av_buffer_ref(frame->opaque_ref);
+            if (!pkt->opaque_ref)
+                return AVERROR(ENOMEM);
+        }
+    }
+
+    avc_context->reordered_opaque = frame->reordered_opaque;
+
     if (!(o_packet.granulepos & h->keyframe_mask))
         pkt->flags |= AV_PKT_FLAG_KEY;
     *got_packet = 1;
@@ -373,7 +386,9 @@  const FFCodec ff_libtheora_encoder = {
     .p.type         = AVMEDIA_TYPE_VIDEO,
     .p.id           = AV_CODEC_ID_THEORA,
     .p.capabilities = AV_CODEC_CAP_DR1 |
-                      AV_CODEC_CAP_DELAY /* for statsfile summary */,
+                      /* for statsfile summary */
+                      AV_CODEC_CAP_DELAY |
+                      AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
     .caps_internal  = FF_CODEC_CAP_NOT_INIT_THREADSAFE,
     .priv_data_size = sizeof(TheoraContext),
     .init           = encode_init,