The branch, master has been updated
via 84fcbce16c75f64343e6ef03609390cfb50bfa94 (commit)
via 2d241202fffd32df1b5992197e622f298d3d029d (commit)
via 6c83bcadbbdbec8e2b8cf156de3e8bcc4e6c880a (commit)
via 5f15734d92eb85413f4bc1d33801c322247448c9 (commit)
via 91b2fe71ccc4f69e1a9caca514cdd3dd8198f83e (commit)
from 671e54d7151b133c9a7b8f5195628ba7c8e7a448 (commit)
- Log -----------------------------------------------------------------
commit 84fcbce16c75f64343e6ef03609390cfb50bfa94
Author: Zhao Zhili <[email protected]>
AuthorDate: Mon Oct 13 22:12:48 2025 +0800
Commit: Zhao Zhili <[email protected]>
CommitDate: Wed Nov 5 15:13:54 2025 +0000
fate/hevc: add tests for the dts2pts bsf
diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak
index 7b22e36a3d..739735802e 100644
--- a/tests/fate/hevc.mak
+++ b/tests/fate/hevc.mak
@@ -235,6 +235,18 @@ fate-hevc-bsf-mp4toannexb: CMD = md5 -i
$(TARGET_PATH)/tests/data/hevc-mp4.mov -
fate-hevc-bsf-mp4toannexb: CMP = oneline
fate-hevc-bsf-mp4toannexb: REF = 73019329ed7f81c24f9af67c34c640c0
+# Start with IDR, POC < 0 after the second IDR
+FATE_HEVC-$(call FRAMECRC, MOV HEVC,, HEVC_PARSER MOV_MUXER DTS2PTS_BSF) +=
fate-hevc-bsf-dts2pts-idr
+fate-hevc-bsf-dts2pts-idr: CMD = transcode "hevc"
$(TARGET_SAMPLES)/hevc-conformance/SLIST_B_Sony_8.bit mov "-c:v copy -bsf:v
dts2pts" "-c:v copy"
+
+# IDR + CRA, POC = 0
+FATE_HEVC-$(call FRAMECRC, MOV HEVC,, HEVC_PARSER MOV_MUXER DTS2PTS_BSF) +=
fate-hevc-bsf-dts2pts-idr-cra
+fate-hevc-bsf-dts2pts-idr-cra: CMD = transcode "hevc"
$(TARGET_SAMPLES)/hevc-conformance/SLIST_A_Sony_4.bit mov "-c:v copy -bsf:v
dts2pts" "-c:v copy"
+
+# First frame is CRA, POC != 0
+FATE_HEVC-$(call FRAMECRC, MOV HEVC,, HEVC_PARSER MOV_MUXER DTS2PTS_BSF) +=
fate-hevc-bsf-dts2pts-cra
+fate-hevc-bsf-dts2pts-cra: CMD = transcode "hevc"
$(TARGET_SAMPLES)/hevc-conformance/RAP_A_docomo_4.bit mov "-c:v copy -bsf:v
dts2pts -frames:v 80" "-c:v copy"
+
fate-hevc-skiploopfilter: CMD = framemd5 -skip_loop_filter nokey -i
$(TARGET_SAMPLES)/hevc-conformance/SAO_D_Samsung_5.bit -sws_flags bitexact
FATE_HEVC-$(call FRAMEMD5, HEVC, HEVC, HEVC_PARSER) += fate-hevc-skiploopfilter
diff --git a/tests/ref/fate/hevc-bsf-dts2pts-cra
b/tests/ref/fate/hevc-bsf-dts2pts-cra
new file mode 100644
index 0000000000..4e9e2c5114
--- /dev/null
+++ b/tests/ref/fate/hevc-bsf-dts2pts-cra
@@ -0,0 +1,88 @@
+c3c00fdc637a19fa3d23d37d9974d28d *tests/data/fate/hevc-bsf-dts2pts-cra.mov
+103067 tests/data/fate/hevc-bsf-dts2pts-cra.mov
+#extradata 0: 118, 0x25f51994
+#tb 0: 1/1200000
+#media_type 0: video
+#codec_id 0: hevc
+#dimensions 0: 416x240
+#sar 0: 0/1
+0, -144000, 336000, 48000, 7990, 0xc6026e64
+0, -96000, 144000, 48000, 1765, 0xc816635b, F=0x0
+0, -48000, 48000, 48000, 894, 0x428fbdff, F=0x0
+0, 0, 0, 48000, 297, 0x9dd28986, F=0x0
+0, 48000, 96000, 48000, 246, 0x3b5878bd, F=0x0
+0, 96000, 240000, 48000, 972, 0xf1dbe630, F=0x0
+0, 144000, 192000, 48000, 238, 0xbdda7a15, F=0x0
+0, 192000, 288000, 48000, 326, 0x85fa9eb7, F=0x0
+0, 240000, 720000, 48000, 5269, 0x02a83809, F=0x0
+0, 288000, 528000, 48000, 1857, 0xe9f8a77e, F=0x0
+0, 336000, 432000, 48000, 1054, 0x10b70755, F=0x0
+0, 384000, 384000, 48000, 360, 0xe04cbda9, F=0x0
+0, 432000, 480000, 48000, 361, 0x4e05aff5, F=0x0
+0, 480000, 624000, 48000, 1015, 0x3da8ec98, F=0x0
+0, 528000, 576000, 48000, 349, 0x27daadf4, F=0x0
+0, 576000, 672000, 48000, 319, 0x672c9699, F=0x0
+0, 624000, 1104000, 48000, 4491, 0x32eca7c6, F=0x0
+0, 672000, 912000, 48000, 1858, 0x3039994f, F=0x0
+0, 720000, 816000, 48000, 1016, 0xe6010553, F=0x0
+0, 768000, 768000, 48000, 356, 0x5344a6ca, F=0x0
+0, 816000, 864000, 48000, 323, 0xf76d9d30, F=0x0
+0, 864000, 1008000, 48000, 1019, 0x4c8c06d2, F=0x0
+0, 912000, 960000, 48000, 301, 0x0f1d8f43, F=0x0
+0, 960000, 1056000, 48000, 307, 0x341897cb, F=0x0
+0, 1008000, 1488000, 48000, 4275, 0x77a96a7d, F=0x0
+0, 1056000, 1296000, 48000, 1644, 0xc86d3753, F=0x0
+0, 1104000, 1200000, 48000, 853, 0xb3a1a7f4, F=0x0
+0, 1152000, 1152000, 48000, 309, 0x5e4a9840, F=0x0
+0, 1200000, 1248000, 48000, 242, 0x30db7905, F=0x0
+0, 1248000, 1392000, 48000, 960, 0x6b42e74d, F=0x0
+0, 1296000, 1344000, 48000, 279, 0x3ed281a7, F=0x0
+0, 1344000, 1440000, 48000, 261, 0xb6698462, F=0x0
+0, 1392000, 1872000, 48000, 6940, 0x7ab8531d
+0, 1440000, 1680000, 48000, 1904, 0x7eb9c679, F=0x0
+0, 1488000, 1584000, 48000, 993, 0x11d9e429, F=0x0
+0, 1536000, 1536000, 48000, 253, 0x08417a25, F=0x0
+0, 1584000, 1632000, 48000, 329, 0x136ca4a1, F=0x0
+0, 1632000, 1776000, 48000, 949, 0xdfaed80a, F=0x0
+0, 1680000, 1728000, 48000, 283, 0x81f686c2, F=0x0
+0, 1728000, 1824000, 48000, 274, 0x81138813, F=0x0
+0, 1776000, 2256000, 48000, 4940, 0x92098d44, F=0x0
+0, 1824000, 2064000, 48000, 1583, 0x25a61e94, F=0x0
+0, 1872000, 1968000, 48000, 909, 0x41fdb7da, F=0x0
+0, 1920000, 1920000, 48000, 251, 0xe68f7697, F=0x0
+0, 1968000, 2016000, 48000, 205, 0xfe4461bd, F=0x0
+0, 2016000, 2160000, 48000, 892, 0x0d2ab3bc, F=0x0
+0, 2064000, 2112000, 48000, 238, 0x45827561, F=0x0
+0, 2112000, 2208000, 48000, 281, 0x2a3a8e61, F=0x0
+0, 2160000, 2256010, 48000, 4629, 0xf2e0fb0f, F=0x0
+0, 2208000, 2256005, 48000, 1453, 0x6ae5dc98, F=0x0
+0, 2256000, 2256002, 1, 869, 0x3982ae69, F=0x0
+0, 2256001, 2256001, 1, 282, 0xd9e28960, F=0x0
+0, 2256002, 2256004, 2, 259, 0x253a809d, F=0x0
+0, 2256004, 2256007, 1, 835, 0x83499f30, F=0x0
+0, 2256005, 2256006, 1, 255, 0xa77b7690, F=0x0
+0, 2256006, 2256008, 1, 242, 0x83977ccf, F=0x0
+0, 2256007, 2256019, 1, 5082, 0xba55ee51, F=0x0
+0, 2256008, 2256014, 2, 1393, 0xc998b442, F=0x0
+0, 2256010, 2256012, 1, 742, 0x91ab75d2, F=0x0
+0, 2256011, 2256011, 1, 229, 0xfa326d98, F=0x0
+0, 2256012, 2256013, 1, 275, 0x49c38226, F=0x0
+0, 2256013, 2256017, 1, 869, 0xdd05acc4, F=0x0
+0, 2256014, 2256016, 2, 293, 0xcc9e904f, F=0x0
+0, 2256016, 2256018, 1, 334, 0x212aa4b1, F=0x0
+0, 2256017, 2256029, 1, 8539, 0xcccc9eb1
+0, 2256018, 2256024, 1, 1593, 0x5a351a68, F=0x0
+0, 2256019, 2256022, 1, 1042, 0xb77d00cc, F=0x0
+0, 2256020, 2256020, 2, 302, 0xbcdb9750, F=0x0
+0, 2256022, 2256023, 1, 336, 0xc7b0a55d, F=0x0
+0, 2256023, 2256026, 1, 875, 0x7e31b046, F=0x0
+0, 2256024, 2256025, 1, 401, 0xb473bca8, F=0x0
+0, 2256025, 2256028, 1, 246, 0x43357263, F=0x0
+0, 2256026, 2256038, 2, 3254, 0x8be44a2d, F=0x0
+0, 2256028, 2256034, 1, 1151, 0x29d52d14, F=0x0
+0, 2256029, 2256031, 1, 733, 0x33606982, F=0x0
+0, 2256030, 2256030, 1, 234, 0xb70a79ff, F=0x0
+0, 2256031, 2256032, 1, 228, 0x86916848, F=0x0
+0, 2256032, 2256036, 2, 689, 0xcca34b40, F=0x0
+0, 2256034, 2256035, 1, 223, 0xa96f6e31, F=0x0
+0, 2256035, 2256037, 1, 241, 0x7ac17531, F=0x0
diff --git a/tests/ref/fate/hevc-bsf-dts2pts-idr
b/tests/ref/fate/hevc-bsf-dts2pts-idr
new file mode 100644
index 0000000000..9568a5932c
--- /dev/null
+++ b/tests/ref/fate/hevc-bsf-dts2pts-idr
@@ -0,0 +1,73 @@
+368d177821450241820bf3507d74b35a *tests/data/fate/hevc-bsf-dts2pts-idr.mov
+346603 tests/data/fate/hevc-bsf-dts2pts-idr.mov
+#extradata 0: 699, 0x9c810c10
+#tb 0: 1/1200000
+#media_type 0: video
+#codec_id 0: hevc
+#dimensions 0: 832x480
+#sar 0: 0/1
+0, -144000, 0, 48000, 31869, 0x95a3c8bb
+0, -96000, 384000, 48000, 21935, 0x9bb336b5, F=0x0
+0, -48000, 192000, 48000, 5864, 0xb2f50830, F=0x0
+0, 0, 96000, 48000, 3760, 0x1cb23d8a, F=0x0
+0, 48000, 48000, 48000, 1510, 0x3b84b90d, F=0x0
+0, 96000, 144000, 48000, 1400, 0xdf676c38, F=0x0
+0, 144000, 288000, 48000, 3342, 0xfb263c8a, F=0x0
+0, 192000, 240000, 48000, 1333, 0x927c6d5c, F=0x0
+0, 240000, 336000, 48000, 1435, 0x3e5696c3, F=0x0
+0, 288000, 768000, 48000, 18971, 0x43f7cd73, F=0x0
+0, 336000, 576000, 48000, 5704, 0xd9dcd87b, F=0x0
+0, 384000, 480000, 48000, 3325, 0xdf6c7700, F=0x0
+0, 432000, 432000, 48000, 1432, 0xa0208c4d, F=0x0
+0, 480000, 528000, 48000, 1393, 0x125275ad, F=0x0
+0, 528000, 672000, 48000, 3303, 0x6aad4730, F=0x0
+0, 576000, 624000, 48000, 1112, 0xc790210c, F=0x0
+0, 624000, 720000, 48000, 951, 0xbeb4cfc7, F=0x0
+0, 672000, 1152000, 48000, 20743, 0xa8c8ec0c, F=0x0
+0, 720000, 960000, 48000, 5697, 0xe522cd06, F=0x0
+0, 768000, 864000, 48000, 3280, 0x72ab514c, F=0x0
+0, 816000, 816000, 48000, 1295, 0xa50d45e3, F=0x0
+0, 864000, 912000, 48000, 1328, 0x277b47c1, F=0x0
+0, 912000, 1056000, 48000, 3263, 0x9ba82e47, F=0x0
+0, 960000, 1008000, 48000, 1354, 0xdbaa775f, F=0x0
+0, 1008000, 1104000, 48000, 1416, 0x7f24810d, F=0x0
+0, 1056000, 1536000, 48000, 30901, 0x41e117ca
+0, 1104000, 1344000, 48000, 8038, 0x572b8898, F=0x0
+0, 1152000, 1248000, 48000, 4534, 0xa41bf004, F=0x0
+0, 1200000, 1200000, 48000, 1562, 0x16c5fd13, F=0x0
+0, 1248000, 1296000, 48000, 990, 0xd6a6e71e, F=0x0
+0, 1296000, 1440000, 48000, 3607, 0x5a6debfc, F=0x0
+0, 1344000, 1392000, 48000, 1257, 0xff495eb3, F=0x0
+0, 1392000, 1488000, 48000, 1190, 0xa3aa4de2, F=0x0
+0, 1440000, 1920000, 48000, 18418, 0xdbacc32f, F=0x0
+0, 1488000, 1728000, 48000, 4566, 0xdbb2dcfd, F=0x0
+0, 1536000, 1632000, 48000, 2578, 0x4fff0eb8, F=0x0
+0, 1584000, 1584000, 48000, 1121, 0x8688214f, F=0x0
+0, 1632000, 1680000, 48000, 864, 0x72a19f39, F=0x0
+0, 1680000, 1824000, 48000, 2208, 0x8e2146e8, F=0x0
+0, 1728000, 1776000, 48000, 900, 0x669fb97b, F=0x0
+0, 1776000, 1872000, 48000, 817, 0x3eb689e1, F=0x0
+0, 1824000, 2256001, 48000, 17919, 0x4e83b301, F=0x0
+0, 1872000, 2112000, 48000, 4911, 0x2fc88e1f, F=0x0
+0, 1920000, 2016000, 48000, 2717, 0xcc1f551e, F=0x0
+0, 1968000, 1968000, 48000, 908, 0x43e1b421, F=0x0
+0, 2016000, 2064000, 48000, 1028, 0xf475f21d, F=0x0
+0, 2064000, 2208000, 48000, 2857, 0xdeee9614, F=0x0
+0, 2112000, 2160000, 48000, 1039, 0x9cf8f494, F=0x0
+0, 2160000, 2256000, 48000, 975, 0x0f4ec85b, F=0x0
+0, 2208000, 2256011, 48000, 18345, 0xf9dabd3b, F=0x0
+0, 2256000, 2256006, 1, 5280, 0xc5c33809, F=0x0
+0, 2256001, 2256004, 1, 2755, 0xda955c75, F=0x0
+0, 2256002, 2256002, 2, 1027, 0xf652eff3, F=0x0
+0, 2256004, 2256005, 1, 901, 0xe23cb716, F=0x0
+0, 2256005, 2256008, 1, 3010, 0x783de5cb, F=0x0
+0, 2256006, 2256007, 1, 1005, 0x91fcf92f, F=0x0
+0, 2256007, 2256010, 1, 1131, 0xd88b2920, F=0x0
+0, 2256008, 2256008, 2, 29018, 0xc9b25608
+0, 2256010, 2256016, 1, 7436, 0x18344e77, F=0x0
+0, 2256011, 2256013, 1, 4050, 0x54fcbee0, F=0x0
+0, 2256012, 2256012, 1, 1412, 0xe249bd86, F=0x0
+0, 2256013, 2256014, 1, 977, 0xa749dc21, F=0x0
+0, 2256014, 2256014, 2, 2953, 0xba90c008, F=0x0
+0, 2256016, 2256017, 1, 1004, 0xddebea9a, F=0x0
+0, 2256017, 2256017, 1, 1109, 0x7e081570, F=0x0
diff --git a/tests/ref/fate/hevc-bsf-dts2pts-idr-cra
b/tests/ref/fate/hevc-bsf-dts2pts-idr-cra
new file mode 100644
index 0000000000..02e9765a26
--- /dev/null
+++ b/tests/ref/fate/hevc-bsf-dts2pts-idr-cra
@@ -0,0 +1,73 @@
+07a216d6537502705348fea392d5d73d *tests/data/fate/hevc-bsf-dts2pts-idr-cra.mov
+375266 tests/data/fate/hevc-bsf-dts2pts-idr-cra.mov
+#extradata 0: 648, 0x30a7fa5c
+#tb 0: 1/1200000
+#media_type 0: video
+#codec_id 0: hevc
+#dimensions 0: 832x480
+#sar 0: 0/1
+0, -144000, 0, 48000, 31816, 0xa06cb717
+0, -96000, 384000, 48000, 21934, 0x9f0434a1, F=0x0
+0, -48000, 192000, 48000, 6005, 0x2fd372f5, F=0x0
+0, 0, 96000, 48000, 3981, 0xc27b5eb8, F=0x0
+0, 48000, 48000, 48000, 1771, 0xf9f407cc, F=0x0
+0, 96000, 144000, 48000, 1598, 0x47c9afdc, F=0x0
+0, 144000, 288000, 48000, 3561, 0x989b9e59, F=0x0
+0, 192000, 240000, 48000, 1621, 0x3fc1c5f3, F=0x0
+0, 240000, 336000, 48000, 1543, 0x5d2a9a11, F=0x0
+0, 288000, 768000, 48000, 20108, 0xed0fb618, F=0x0
+0, 336000, 576000, 48000, 5880, 0x31bb1d8c, F=0x0
+0, 384000, 480000, 48000, 3978, 0xfded6791, F=0x0
+0, 432000, 432000, 48000, 1644, 0xa159d804, F=0x0
+0, 480000, 528000, 48000, 1656, 0x8bafe135, F=0x0
+0, 528000, 672000, 48000, 3576, 0x6d6395cc, F=0x0
+0, 576000, 624000, 48000, 1644, 0x25afd308, F=0x0
+0, 624000, 720000, 48000, 1520, 0x5e81969d, F=0x0
+0, 672000, 1152000, 48000, 20230, 0x70abe220, F=0x0
+0, 720000, 960000, 48000, 5905, 0xce0b2163, F=0x0
+0, 768000, 864000, 48000, 3414, 0x264c3886, F=0x0
+0, 816000, 816000, 48000, 1522, 0x1f66970a, F=0x0
+0, 864000, 912000, 48000, 1548, 0x9df8a077, F=0x0
+0, 912000, 1056000, 48000, 3481, 0x136f4cda, F=0x0
+0, 960000, 1008000, 48000, 1570, 0x96b5b46f, F=0x0
+0, 1008000, 1104000, 48000, 1552, 0x5f90a241, F=0x0
+0, 1056000, 1536000, 48000, 34165, 0xd51c2237
+0, 1104000, 1344000, 48000, 6053, 0x43cc75d1, F=0x0
+0, 1152000, 1248000, 48000, 3616, 0x705b946d, F=0x0
+0, 1200000, 1200000, 48000, 1651, 0x99d2dd20, F=0x0
+0, 1248000, 1296000, 48000, 1585, 0x138cae59, F=0x0
+0, 1296000, 1440000, 48000, 4152, 0x4853ad40, F=0x0
+0, 1344000, 1392000, 48000, 1790, 0xdf251cf7, F=0x0
+0, 1392000, 1488000, 48000, 1731, 0x1be6ede1, F=0x0
+0, 1440000, 1920000, 48000, 20669, 0x94f6cf6e, F=0x0
+0, 1488000, 1728000, 48000, 5001, 0xb4092855, F=0x0
+0, 1536000, 1632000, 48000, 3120, 0x4de4c3e7, F=0x0
+0, 1584000, 1584000, 48000, 1674, 0x7f5edac2, F=0x0
+0, 1632000, 1680000, 48000, 1436, 0xebb36623, F=0x0
+0, 1680000, 1824000, 48000, 2674, 0x296fd411, F=0x0
+0, 1728000, 1776000, 48000, 1420, 0x304d6168, F=0x0
+0, 1776000, 1872000, 48000, 1364, 0x48734084, F=0x0
+0, 1824000, 2256001, 48000, 19349, 0xda0944f0, F=0x0
+0, 1872000, 2112000, 48000, 5550, 0x9c346b7b, F=0x0
+0, 1920000, 2016000, 48000, 3180, 0x5368f72b, F=0x0
+0, 1968000, 1968000, 48000, 1475, 0x369b7aae, F=0x0
+0, 2016000, 2064000, 48000, 1556, 0xc548affb, F=0x0
+0, 2064000, 2208000, 48000, 3365, 0x81d511a6, F=0x0
+0, 2112000, 2160000, 48000, 1575, 0xba81b0a5, F=0x0
+0, 2160000, 2256000, 48000, 1538, 0xf1199439, F=0x0
+0, 2208000, 2256011, 48000, 20138, 0x101fb220, F=0x0
+0, 2256000, 2256006, 1, 5806, 0xcc500158, F=0x0
+0, 2256001, 2256004, 1, 3267, 0xf8f0d6cd, F=0x0
+0, 2256002, 2256002, 2, 1557, 0x894faf3e, F=0x0
+0, 2256004, 2256005, 1, 1482, 0x6b1884b7, F=0x0
+0, 2256005, 2256008, 1, 3513, 0x81227a59, F=0x0
+0, 2256006, 2256007, 1, 1576, 0x855eabd8, F=0x0
+0, 2256007, 2256010, 1, 1668, 0x030ade2e, F=0x0
+0, 2256008, 2256008, 2, 32088, 0xfadbf5f6
+0, 2256010, 2256016, 1, 5921, 0x21fb4976, F=0x0
+0, 2256011, 2256013, 1, 3436, 0x92085cd6, F=0x0
+0, 2256012, 2256012, 1, 1613, 0x1e0cb7c6, F=0x0
+0, 2256013, 2256014, 1, 1483, 0x88d18a4e, F=0x0
+0, 2256014, 2256018, 2, 3540, 0xc57c8e7b, F=0x0
+0, 2256016, 2256017, 1, 1561, 0x9740a363, F=0x0
+0, 2256017, 2256019, 1, 1651, 0x18e3d52d, F=0x0
commit 2d241202fffd32df1b5992197e622f298d3d029d
Author: Zhao Zhili <[email protected]>
AuthorDate: Mon Oct 13 20:52:46 2025 +0800
Commit: Zhao Zhili <[email protected]>
CommitDate: Wed Nov 5 15:13:54 2025 +0000
avcodec/bsf/dts2pts: add hevc support
diff --git a/configure b/configure
index 1d421460f9..af125bc115 100755
--- a/configure
+++ b/configure
@@ -3585,7 +3585,7 @@ av1_frame_merge_bsf_select="cbs_av1"
av1_frame_split_bsf_select="cbs_av1"
av1_metadata_bsf_select="cbs_av1"
dovi_rpu_bsf_select="cbs_h265 cbs_av1 dovi_rpudec dovi_rpuenc"
-dts2pts_bsf_select="cbs_h264 h264parse"
+dts2pts_bsf_select="cbs_h264 h264parse cbs_h265 hevc_parser"
eac3_core_bsf_select="ac3_parser"
eia608_to_smpte436m_bsf_select="smpte_436m"
evc_frame_merge_bsf_select="evcparse"
diff --git a/libavcodec/bsf/dts2pts.c b/libavcodec/bsf/dts2pts.c
index 6474061974..122661a5df 100644
--- a/libavcodec/bsf/dts2pts.c
+++ b/libavcodec/bsf/dts2pts.c
@@ -23,6 +23,8 @@
* Derive PTS by reordering DTS from supported streams
*/
+#include <stdbool.h>
+
#include "libavutil/avassert.h"
#include "libavutil/fifo.h"
#include "libavutil/mem.h"
@@ -32,8 +34,10 @@
#include "bsf_internal.h"
#include "cbs.h"
#include "cbs_h264.h"
+#include "cbs_h265.h"
#include "h264_parse.h"
#include "h264_ps.h"
+#include "hevc/ps.h"
#include "libavutil/refstruct.h"
typedef struct DTS2PTSNode {
@@ -59,6 +63,12 @@ typedef struct DTS2PTSH264Context {
int picture_structure;
} DTS2PTSH264Context;
+typedef struct DTS2PTSHEVCContext {
+ int gop;
+ int poc_tid0;
+ int highest_poc;
+} DTS2PTSHEVCContext;
+
typedef struct DTS2PTSContext {
struct AVTreeNode *root;
AVFifo *fifo;
@@ -75,6 +85,7 @@ typedef struct DTS2PTSContext {
union {
DTS2PTSH264Context h264;
+ DTS2PTSHEVCContext hevc;
} u;
int nb_frame;
@@ -363,6 +374,176 @@ static void h264_flush(AVBSFContext *ctx)
h264->last_poc = h264->highest_poc = INT_MIN;
}
+static int hevc_init(AVBSFContext *ctx)
+{
+ DTS2PTSContext *s = ctx->priv_data;
+ DTS2PTSHEVCContext *hevc = &s->u.hevc;
+
+ hevc->gop = -1;
+ hevc->poc_tid0 = 0;
+ hevc->highest_poc = INT_MIN;
+ s->nb_frame = -ctx->par_in->video_delay;
+
+ return 0;
+}
+
+static void hevc_flush(AVBSFContext *ctx)
+{
+ hevc_init(ctx);
+}
+
+static int hevc_init_nb_frame(AVBSFContext *ctx, int poc)
+{
+ DTS2PTSContext *s = ctx->priv_data;
+ const CodedBitstreamH265Context *cbs_hevc = s->cbc->priv_data;
+ const H265RawVPS *vps = cbs_hevc->active_vps;
+
+ if (!vps)
+ return AVERROR_INVALIDDATA;
+
+ int latency = vps->vps_max_num_reorder_pics[0];
+ if (vps->vps_max_latency_increase_plus1[0])
+ latency += vps->vps_max_latency_increase_plus1[0] - 1;
+
+ s->nb_frame = poc - latency;
+ av_log(ctx, AV_LOG_DEBUG, "Latency %d, poc %d, nb_frame %d\n",
+ latency, poc, s->nb_frame);
+
+ return 0;
+}
+
+static int same_gop(void *opaque, void *elem)
+{
+ DTS2PTSNode *node = elem;
+ int gop = ((int *)opaque)[1];
+ return FFDIFFSIGN(gop, node->gop);
+}
+
+static int hevc_queue_frame(AVBSFContext *ctx, AVPacket *pkt, int poc, bool
*queued)
+{
+ DTS2PTSContext *s = ctx->priv_data;
+ DTS2PTSHEVCContext *hevc = &s->u.hevc;
+ int ret;
+
+ if (hevc->gop == -1) {
+ ret = hevc_init_nb_frame(ctx, poc);
+ if (ret < 0)
+ return ret;
+ hevc->gop = s->gop;
+ }
+
+ hevc->highest_poc = FFMAX(hevc->highest_poc, poc);
+ if (s->nb_frame > hevc->highest_poc) {
+ s->nb_frame = 0;
+ s->gop = (s->gop + 1) % s->fifo_size;
+ hevc->highest_poc = poc;
+ }
+
+ if (poc < s->nb_frame && hevc->gop == s->gop) {
+ int tmp[] = {s->nb_frame - poc, s->gop};
+
+ s->nb_frame -= tmp[0];
+ av_tree_enumerate(s->root, tmp, same_gop, dec_poc);
+ }
+
+ ret = alloc_and_insert_node(ctx, pkt->dts, pkt->duration, s->nb_frame, 1,
s->gop);
+ if (ret < 0)
+ return ret;
+
+ av_log(ctx, AV_LOG_DEBUG, "Queueing frame with POC %d, GOP %d, nb_frame
%d, dts %"PRId64"\n",
+ poc, s->gop, s->nb_frame, pkt->dts);
+ s->nb_frame++;
+
+ DTS2PTSFrame frame = {
+ .pkt = pkt,
+ .poc = poc,
+ .poc_diff = 1,
+ .gop = s->gop,
+ };
+ ret = av_fifo_write(s->fifo, &frame, 1);
+ if (ret < 0)
+ return ret;
+
+ *queued = true;
+
+ return 0;
+}
+
+static int hevc_filter(AVBSFContext *ctx)
+{
+ DTS2PTSContext *s = ctx->priv_data;
+ DTS2PTSHEVCContext *hevc = &s->u.hevc;
+ CodedBitstreamFragment *au = &s->au;
+ AVPacket *in;
+ bool queued = 0;
+ int ret = ff_bsf_get_packet(ctx, &in);
+ if (ret < 0)
+ return ret;
+
+ ret = ff_cbs_read_packet(s->cbc, au, in);
+ if (ret < 0) {
+ av_log(ctx, AV_LOG_WARNING, "Failed to parse access unit.\n");
+ goto fail;
+ }
+
+ for (int i = 0; i < au->nb_units; i++) {
+ CodedBitstreamUnit *unit = &au->units[i];
+ CodedBitstreamUnitType type = unit->type;
+
+ bool is_slice = type <= HEVC_NAL_RASL_R || (type >= HEVC_NAL_BLA_W_LP
&&
+ type <= HEVC_NAL_CRA_NUT);
+ if (!is_slice)
+ continue;
+
+ const H265RawSliceHeader *slice = unit->content;
+ if (!slice->first_slice_segment_in_pic_flag)
+ continue;
+
+ const CodedBitstreamH265Context *cbs_hevc = s->cbc->priv_data;
+ const H265RawSPS *sps = cbs_hevc->active_sps;
+ if (!sps) {
+ av_log(ctx, AV_LOG_ERROR, "No active SPS for a slice\n");
+ ret = AVERROR_INVALIDDATA;
+ goto fail;
+ }
+
+ int poc;
+ if (type == HEVC_NAL_IDR_W_RADL || type == HEVC_NAL_IDR_N_LP) {
+ poc = 0;
+ hevc->gop = (hevc->gop + 1) % s->fifo_size;
+ } else {
+ unsigned log2_max_poc_lsb = sps->log2_max_pic_order_cnt_lsb_minus4
+ 4;
+ int poc_lsb = slice->slice_pic_order_cnt_lsb;
+
+ poc = ff_hevc_compute_poc2(log2_max_poc_lsb, hevc->poc_tid0,
poc_lsb, type);
+ }
+
+ if (slice->nal_unit_header.nuh_temporal_id_plus1 == 1 &&
+ type != HEVC_NAL_TRAIL_N && type != HEVC_NAL_TSA_N &&
+ type != HEVC_NAL_STSA_N && type != HEVC_NAL_RADL_N &&
+ type != HEVC_NAL_RASL_N && type != HEVC_NAL_RADL_R &&
+ type != HEVC_NAL_RASL_R) {
+ hevc->poc_tid0 = poc;
+ }
+
+ ret = hevc_queue_frame(ctx, in, poc, &queued);
+ if (ret < 0)
+ goto fail;
+ break;
+ }
+
+ if (!queued) {
+ av_log(ctx, AV_LOG_ERROR, "No slices in access unit\n");
+ ret = AVERROR_INVALIDDATA;
+ }
+
+fail:
+ ff_cbs_fragment_reset(au);
+ if (!queued)
+ av_packet_free(&in);
+ return ret;
+}
+
// Core functions
static const struct {
enum AVCodecID id;
@@ -372,6 +553,7 @@ static const struct {
size_t fifo_size;
} func_tab[] = {
{ AV_CODEC_ID_H264, h264_init, h264_filter, h264_flush,
H264_MAX_DPB_FRAMES * 2 * 2 },
+ { AV_CODEC_ID_HEVC, hevc_init, hevc_filter, hevc_flush, HEVC_MAX_DPB_SIZE
* 2 },
};
static int dts2pts_init(AVBSFContext *ctx)
@@ -536,6 +718,7 @@ static void dts2pts_close(AVBSFContext *ctx)
static const enum AVCodecID dts2pts_codec_ids[] = {
AV_CODEC_ID_H264,
+ AV_CODEC_ID_HEVC,
AV_CODEC_ID_NONE,
};
commit 6c83bcadbbdbec8e2b8cf156de3e8bcc4e6c880a
Author: Zhao Zhili <[email protected]>
AuthorDate: Mon Oct 13 20:15:53 2025 +0800
Commit: Zhao Zhili <[email protected]>
CommitDate: Wed Nov 5 15:13:54 2025 +0000
avcodec/hevc: add ff_hevc_compute_poc2 which don't depend on HEVCSPS
directly
So it can be used in other places like bsf.
diff --git a/libavcodec/hevc/ps.c b/libavcodec/hevc/ps.c
index 1b7c275ba4..7b9dbbcff8 100644
--- a/libavcodec/hevc/ps.c
+++ b/libavcodec/hevc/ps.c
@@ -2443,9 +2443,9 @@ void ff_hevc_ps_uninit(HEVCParamSets *ps)
av_refstruct_unref(&ps->pps_list[i]);
}
-int ff_hevc_compute_poc(const HEVCSPS *sps, int pocTid0, int poc_lsb, int
nal_unit_type)
+int ff_hevc_compute_poc2(unsigned log2_max_poc_lsb, int pocTid0, int poc_lsb,
int nal_unit_type)
{
- int max_poc_lsb = 1 << sps->log2_max_poc_lsb;
+ int max_poc_lsb = 1 << log2_max_poc_lsb;
int prev_poc_lsb = pocTid0 % max_poc_lsb;
int prev_poc_msb = pocTid0 - prev_poc_lsb;
int poc_msb;
diff --git a/libavcodec/hevc/ps.h b/libavcodec/hevc/ps.h
index 25475b5593..d620887b8e 100644
--- a/libavcodec/hevc/ps.h
+++ b/libavcodec/hevc/ps.h
@@ -546,6 +546,11 @@ int ff_hevc_encode_nal_vps(HEVCVPS *vps, unsigned int id,
/**
* Compute POC of the current frame and return it.
*/
-int ff_hevc_compute_poc(const HEVCSPS *sps, int pocTid0, int poc_lsb, int
nal_unit_type);
+int ff_hevc_compute_poc2(unsigned log2_max_poc_lsb, int pocTid0, int poc_lsb,
int nal_unit_type);
+
+static inline int ff_hevc_compute_poc(const HEVCSPS *sps, int pocTid0, int
poc_lsb, int nal_unit_type)
+{
+ return ff_hevc_compute_poc2(sps->log2_max_poc_lsb, pocTid0, poc_lsb,
nal_unit_type);
+}
#endif /* AVCODEC_HEVC_PS_H */
commit 5f15734d92eb85413f4bc1d33801c322247448c9
Author: Zhao Zhili <[email protected]>
AuthorDate: Mon Oct 13 20:54:10 2025 +0800
Commit: Zhao Zhili <[email protected]>
CommitDate: Wed Nov 5 15:13:54 2025 +0000
avcodec/bsf/dts2pts: fix return 0 on error path
diff --git a/libavcodec/bsf/dts2pts.c b/libavcodec/bsf/dts2pts.c
index febf3069a5..6474061974 100644
--- a/libavcodec/bsf/dts2pts.c
+++ b/libavcodec/bsf/dts2pts.c
@@ -261,6 +261,7 @@ static int h264_filter(AVBSFContext *ctx)
if (!sps) {
av_log(ctx, AV_LOG_ERROR, "No active SPS for a slice\n");
+ ret = AVERROR_INVALIDDATA;
goto fail;
}
// Initialize the SPS struct with the fields ff_h264_init_poc()
cares about
commit 91b2fe71ccc4f69e1a9caca514cdd3dd8198f83e
Author: Zhao Zhili <[email protected]>
AuthorDate: Mon Oct 13 16:40:36 2025 +0800
Commit: Zhao Zhili <[email protected]>
CommitDate: Wed Nov 5 15:13:54 2025 +0000
avcodec/bsf/dts2pts: remove always true check
diff --git a/libavcodec/bsf/dts2pts.c b/libavcodec/bsf/dts2pts.c
index 9d31d7dc08..febf3069a5 100644
--- a/libavcodec/bsf/dts2pts.c
+++ b/libavcodec/bsf/dts2pts.c
@@ -485,11 +485,10 @@ static int dts2pts_filter(AVBSFContext *ctx, AVPacket
*out)
av_packet_unref(out);
return ret;
}
- if (!ret)
- av_log(ctx, AV_LOG_DEBUG, "Queueing frame for POC %d, GOP %d,
dts %"PRId64", "
- "generated from POC %d, GOP %d, dts
%"PRId64", duration %"PRId64"\n",
- frame.poc, frame.gop, out->pts,
- poc_node->poc, poc_node->gop, poc_node->dts,
poc_node->duration);
+ av_log(ctx, AV_LOG_DEBUG, "Queueing frame for POC %d, GOP %d, dts
%"PRId64", "
+ "generated from POC %d, GOP %d, dts
%"PRId64", duration %"PRId64"\n",
+ frame.poc, frame.gop, out->pts,
+ poc_node->poc, poc_node->gop, poc_node->dts,
poc_node->duration);
} else
av_log(ctx, AV_LOG_WARNING, "No timestamp for POC %d in tree\n",
frame.poc);
} else
-----------------------------------------------------------------------
Summary of changes:
configure | 2 +-
libavcodec/bsf/dts2pts.c | 193 +++++++++++++++++++++++++++++++-
libavcodec/hevc/ps.c | 4 +-
libavcodec/hevc/ps.h | 7 +-
tests/fate/hevc.mak | 12 ++
tests/ref/fate/hevc-bsf-dts2pts-cra | 88 +++++++++++++++
tests/ref/fate/hevc-bsf-dts2pts-idr | 73 ++++++++++++
tests/ref/fate/hevc-bsf-dts2pts-idr-cra | 73 ++++++++++++
8 files changed, 443 insertions(+), 9 deletions(-)
create mode 100644 tests/ref/fate/hevc-bsf-dts2pts-cra
create mode 100644 tests/ref/fate/hevc-bsf-dts2pts-idr
create mode 100644 tests/ref/fate/hevc-bsf-dts2pts-idr-cra
hooks/post-receive
--
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]