PR #25426 opened by Kacper Michajłow (kasper93)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25426
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25426.patch


From ff3859c2b3b3dd3dea0ce6bc21456f7594f22f27 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]>
Date: Sat, 24 Oct 2026 07:34:30 +0200
Subject: [PATCH 1/3] avcodec/jpeg2000dec: set AVFrame.pkt_dts
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Copy the dts of the decoded packet to the frame. decode.c does this only
for decoders with the decode callback, so it got lost when 6287ad1f9b
moved the decoder to the receive_frame API, and frames decoded from
packets that carry only a dts have had no timestamp since.

Fixes: 6287ad1f9b
Signed-off-by: Kacper Michajłow <[email protected]>
---
 libavcodec/jpeg2000dec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 9282f7610ef..7acb11710b8 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2948,6 +2948,7 @@ static int jpeg2000_receive_frame(AVCodecContext *avctx, 
AVFrame *frame)
             return ret;
 
         ret = jpeg2000_decode_frame(avctx, frame, avpkt);
+        frame->pkt_dts = avpkt->dts;
         av_packet_unref(avpkt);
         if (ret < 0)
             return ret;
-- 
2.54.0


From db2c92385ce7a59bf1120c66871d35e16d0a7408 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]>
Date: Sat, 24 Oct 2026 07:34:31 +0200
Subject: [PATCH 2/3] avcodec/apv_decode: set AVFrame.pkt_dts
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Copy the dts of the decoded packet to the frame. decode.c does this only
for decoders with the decode callback, so it got lost when 084b67f6e3
moved the decoder to the receive_frame API, and frames decoded from
packets that carry only a dts have had no timestamp since.

Fixes: 084b67f6e3
Signed-off-by: Kacper Michajłow <[email protected]>
---
 libavcodec/apv_decode.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/apv_decode.c b/libavcodec/apv_decode.c
index cde65936028..a6ca9ba8fb2 100644
--- a/libavcodec/apv_decode.c
+++ b/libavcodec/apv_decode.c
@@ -513,6 +513,7 @@ static int apv_receive_frame_internal(AVCodecContext 
*avctx, AVFrame *frame)
         switch (pbu->type) {
         case APV_PBU_PRIMARY_FRAME:
             err = apv_decode(avctx, frame, pbu->content);
+            frame->pkt_dts = apv->pkt->dts;
             i++;
             goto end;
         case APV_PBU_METADATA:
-- 
2.54.0


From 554c3314f5cbdc444f0da5f489fd83d68d60bf35 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]>
Date: Sat, 24 Oct 2026 07:36:45 +0200
Subject: [PATCH 3/3] tests/fate: add tests for jpeg2000 and apv frame
 timestamps
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Kacper Michajłow <[email protected]>
---
 tests/fate/apv.mak                    | 7 ++++++-
 tests/fate/jpeg2000.mak               | 6 +++++-
 tests/ref/fate/apv-timestamps         | 3 +++
 tests/ref/fate/jpeg2000dec-timestamps | 2 ++
 4 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 tests/ref/fate/apv-timestamps
 create mode 100644 tests/ref/fate/jpeg2000dec-timestamps

diff --git a/tests/fate/apv.mak b/tests/fate/apv.mak
index ede66454e5b..23cde0ccc95 100644
--- a/tests/fate/apv.mak
+++ b/tests/fate/apv.mak
@@ -2,8 +2,13 @@ FATE_APV = fate-apv-422-10 fate-apv-400-10
 
 FATE_SAMPLES_FFMPEG-$(call FRAMECRC, APV, APV, SCALE_FILTER) += $(FATE_APV)
 
-fate-apv:      $(FATE_APV)
+FATE_APV_FFPROBE-$(call DEMDEC, APV, APV) += fate-apv-timestamps
+FATE_SAMPLES_FFPROBE += $(FATE_APV_FFPROBE-yes)
+
+fate-apv:      $(FATE_APV) $(FATE_APV_FFPROBE-yes)
 
 fate-apv-422-10:       CMD = framecrc -i 
$(TARGET_SAMPLES)/apv/profile_422-10.apv -pix_fmt yuv422p10le -vf scale
 
 fate-apv-400-10:       CMD = framecrc -i 
$(TARGET_SAMPLES)/apv/profile_400-10.apv -pix_fmt gray10le -vf scale
+
+fate-apv-timestamps:   CMD = probeframes -of compact -show_entries 
frame=pts,pkt_dts $(TARGET_SAMPLES)/apv/profile_422-10.apv
diff --git a/tests/fate/jpeg2000.mak b/tests/fate/jpeg2000.mak
index a99b0c4e0cd..682fb4c3701 100644
--- a/tests/fate/jpeg2000.mak
+++ b/tests/fate/jpeg2000.mak
@@ -63,7 +63,11 @@ fate-jpeg2000dec-p0_16: CMD = framecrc -flags +bitexact -i 
$(TARGET_SAMPLES)/jpe
 FATE_JPEG2000DEC += fate-jpeg2000dec-ds0_ht_01_b11
 fate-jpeg2000dec-ds0_ht_01_b11: CMD = framecrc -flags +bitexact -i 
$(TARGET_SAMPLES)/jpeg2000/itu-iso/htj2k_bsets_profile0/ds0_ht_01_b11.j2k
 
+FATE_JPEG2000DEC_FFPROBE-$(call DEMDEC, MXF, JPEG2000) += 
fate-jpeg2000dec-timestamps
+fate-jpeg2000dec-timestamps: CMD = probeframes -of compact -show_entries 
frame=pts,pkt_dts $(TARGET_SAMPLES)/jpeg2000/chiens_dcinema2K.mxf
+
 FATE_JPEG2000DEC += $(FATE_JPEG2000DEC-yes)
 
 FATE_SAMPLES_FFMPEG-$(call FRAMECRC, IMAGE_J2K_PIPE, JPEG2000) += 
$(FATE_JPEG2000DEC)
-fate-jpeg2000dec: $(FATE_JPEG2000DEC)
+FATE_SAMPLES_FFPROBE += $(FATE_JPEG2000DEC_FFPROBE-yes)
+fate-jpeg2000dec: $(FATE_JPEG2000DEC) $(FATE_JPEG2000DEC_FFPROBE-yes)
diff --git a/tests/ref/fate/apv-timestamps b/tests/ref/fate/apv-timestamps
new file mode 100644
index 00000000000..01d8d94159d
--- /dev/null
+++ b/tests/ref/fate/apv-timestamps
@@ -0,0 +1,3 @@
+frame|pts=0|pkt_dts=0
+frame|pts=1|pkt_dts=1
+frame|pts=2|pkt_dts=2
diff --git a/tests/ref/fate/jpeg2000dec-timestamps 
b/tests/ref/fate/jpeg2000dec-timestamps
new file mode 100644
index 00000000000..00acddde9d8
--- /dev/null
+++ b/tests/ref/fate/jpeg2000dec-timestamps
@@ -0,0 +1,2 @@
+frame|pts=0|pkt_dts=0
+frame|pts=1|pkt_dts=1
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to