ffmpeg | branch: master | Timo Rothenpieler <t...@rothenpieler.org> | Sat Nov  
5 21:20:06 2022 +0100| [aa3d98227e88f316f56aa73a5c6356e3949e9808] | committer: 
Timo Rothenpieler

avcodec/nvenc: don't queue and offset dts for AV1

dts != pts is actually a spec violation for AV1, given it has no
reordering in the classical sense.

We don't really need the whole timestamp queue in this case and can just
pass through the timestamp as is for both dts and pts.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aa3d98227e88f316f56aa73a5c6356e3949e9808
---

 libavcodec/nvenc.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 0d1d68d70d..2583ec2912 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -2170,9 +2170,13 @@ static int nvenc_set_timestamp(AVCodecContext *avctx,
     NvencContext *ctx = avctx->priv_data;
 
     pkt->pts = params->outputTimeStamp;
-    pkt->dts = timestamp_queue_dequeue(ctx->timestamp_list);
 
-    pkt->dts -= FFMAX(ctx->encode_config.frameIntervalP - 1, 0) * 
FFMAX(avctx->ticks_per_frame, 1);
+    if (avctx->codec_descriptor->props & AV_CODEC_PROP_REORDER) {
+        pkt->dts = timestamp_queue_dequeue(ctx->timestamp_list);
+        pkt->dts -= FFMAX(ctx->encode_config.frameIntervalP - 1, 0) * 
FFMAX(avctx->ticks_per_frame, 1);
+    } else {
+        pkt->dts = pkt->pts;
+    }
 
     return 0;
 }
@@ -2582,7 +2586,9 @@ static int nvenc_send_frame(AVCodecContext *avctx, const 
AVFrame *frame)
 
     if (frame && frame->buf[0]) {
         av_fifo_write(ctx->output_surface_queue, &in_surf, 1);
-        timestamp_queue_enqueue(ctx->timestamp_list, frame->pts);
+
+        if (avctx->codec_descriptor->props & AV_CODEC_PROP_REORDER)
+            timestamp_queue_enqueue(ctx->timestamp_list, frame->pts);
     }
 
     /* all the pending buffers are now ready for output */

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to