diff mbox series

[FFmpeg-devel,v2,2/3] decklink: Fix setting of last_pts to only be set for video

Message ID 20230303210815.23692-2-dheitmueller@ltnglobal.com
State New
Headers show
Series [FFmpeg-devel,v2,1/3] decklink: Don't take for granted that first frame to decklink output will be PTS 0 | expand


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

Devin Heitmueller March 3, 2023, 9:08 p.m. UTC
The ff_decklink_write_packet() was always caching the last pts
received, to be used when calling StopScheduledPlayback().  However
because audio and video are on different timebases and the call to
StopScheduledPlayback() expects the video timebase, we'll end up
sending a weird value to the stop routine if the last packet
received contained audio.

Move the setting of last_pts to just be for the video stream.

Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
 libavdevice/decklink_enc.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series


diff --git a/libavdevice/decklink_enc.cpp b/libavdevice/decklink_enc.cpp
index 5a435ddc78..573b9e687c 100644
--- a/libavdevice/decklink_enc.cpp
+++ b/libavdevice/decklink_enc.cpp
@@ -441,6 +441,8 @@  static int decklink_write_video_packet(AVFormatContext *avctx, AVPacket *pkt)
     uint32_t buffered;
     HRESULT hr;
+    ctx->last_pts = FFMAX(ctx->last_pts, pkt->pts);
     if (st->codecpar->codec_id == AV_CODEC_ID_WRAPPED_AVFRAME) {
         if (tmp->format != AV_PIX_FMT_UYVY422 ||
             tmp->width  != ctx->bmd_width ||
@@ -629,8 +631,6 @@  int ff_decklink_write_packet(AVFormatContext *avctx, AVPacket *pkt)
     struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
     AVStream *st = avctx->streams[pkt->stream_index];
-    ctx->last_pts = FFMAX(ctx->last_pts, pkt->pts);
     if      (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
         return decklink_write_video_packet(avctx, pkt);
     else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)