From c59fec783d6540dd96540b079d753ee4a6ad2e58 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 8 Jan 2016 17:08:39 +0100 Subject: nvenc: generate dts properly When there is a non-zero decoding delay due to reordering, the first dts should be lower than the first pts (since the first packet fed to the decoder does not produce any output). Use the same scheme used in mpegvideo_enc (which comes from x264 originally) -- wait for first two timestamps and extrapolate linearly to the past to produce the first dts value. --- libavcodec/nvenc.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libavcodec/nvenc.h') diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h index 8819b3ca32..32d3345414 100644 --- a/libavcodec/nvenc.h +++ b/libavcodec/nvenc.h @@ -112,7 +112,10 @@ typedef struct NVENCContext { AVFifoBuffer *timestamps; AVFifoBuffer *pending, *ready; - int64_t last_dts; + /* timestamps of the first two frames, for computing the first dts + * when b-frames are present */ + int64_t initial_pts[2]; + int first_packet_output; void *nvenc_ctx; -- cgit v1.2.3