PR #20976 opened by Zhao Zhili (quink)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20976
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20976.patch


>From f846397a9265ecec4101fd2bfa234ca6936840b9 Mon Sep 17 00:00:00 2001
From: Zhao Zhili <[email protected]>
Date: Tue, 28 Oct 2025 20:25:12 +0800
Subject: [PATCH 1/2] avcodec/hevc: reset long_term_rps.nb_refs for IDR

For mv-hevc, the second layer of IDR frame can be a P slice.
long_term_rps wasn't been reset before the patch, which leading to
ff_hevc_frame_nb_refs return incorrect result.

This fix decoding failure for samples from Pico VR.

(cherry picked from commit 141f5c9071e10c08d0ca35fb8b663ee17ad5f709)
---
 libavcodec/hevc/hevcdec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 8a845f54f3..6615f42ba2 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -916,6 +916,7 @@ static int hls_slice_header(SliceHeader *sh, const 
HEVCContext *s, GetBitContext
             sh->short_term_ref_pic_set_size     = 0;
             sh->short_term_rps                  = NULL;
             sh->long_term_ref_pic_set_size      = 0;
+            sh->long_term_rps.nb_refs           = 0;
             sh->slice_temporal_mvp_enabled_flag = 0;
         }
 
-- 
2.49.1


>From ea809c02ab66d19b70f5678b62349de2cc322272 Mon Sep 17 00:00:00 2001
From: Zhao Zhili <[email protected]>
Date: Tue, 28 Oct 2025 22:30:21 +0800
Subject: [PATCH 2/2] tests/fate/hevc: add a mv-hevc sample using long term ref

(cherry picked from commit 071db4b81cca7fe041dc41a109e84f8643c43fb5)
---
 tests/fate/hevc.mak        |  5 +++
 tests/ref/fate/hevc-mv-ltr | 68 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 73 insertions(+)
 create mode 100644 tests/ref/fate/hevc-mv-ltr

diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak
index 7b22e36a3d..9f0d1667a2 100644
--- a/tests/fate/hevc.mak
+++ b/tests/fate/hevc.mak
@@ -291,6 +291,11 @@ FATE_HEVC-$(call FRAMECRC, HEVC, HEVC, SCALE_FILTER 
CONCAT_PROTOCOL) += fate-hev
 fate-hevc-mv-position: CMD = framecrc -i $(TARGET_SAMPLES)/hevc/multiview.mov 
-map 0:v:vpos:left -map 0:v:vpos:right
 FATE_HEVC-$(call FRAMECRC, MOV, HEVC) += fate-hevc-mv-position
 
+# The sample is from PICO VR. It use long term ref.
+# Check long term ref being reset in IDR frame.
+fate-hevc-mv-ltr: CMD = framecrc -i $(TARGET_SAMPLES)/hevc/pico-mv-hevc.mp4 
-map 0:vidx:1
+FATE_HEVC-$(call FRAMECRC, MOV, HEVC) += fate-hevc-mv-ltr
+
 fate-hevc-alpha: CMD = framecrc -i $(TARGET_SAMPLES)/hevc/alpha.mp4
 FATE_HEVC-$(call FRAMECRC, MOV, HEVC) += fate-hevc-alpha
 
diff --git a/tests/ref/fate/hevc-mv-ltr b/tests/ref/fate/hevc-mv-ltr
new file mode 100644
index 0000000000..e342fbb6ca
--- /dev/null
+++ b/tests/ref/fate/hevc-mv-ltr
@@ -0,0 +1,68 @@
+#tb 0: 1/60
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 2048x1536
+#sar 0: 0/1
+0,          0,          0,        1,  4718592, 0xa201f61d
+0,          1,          1,        1,  4718592, 0x63438b04
+0,          2,          2,        1,  4718592, 0xb2ef2022
+0,          3,          3,        1,  4718592, 0x9bcd7e4e
+0,          4,          4,        1,  4718592, 0x7d84b453
+0,          5,          5,        1,  4718592, 0xe1825fd9
+0,          6,          6,        1,  4718592, 0x4d3fa47e
+0,          7,          7,        1,  4718592, 0x3717852e
+0,          8,          8,        1,  4718592, 0x3b894106
+0,          9,          9,        1,  4718592, 0x94b23d4d
+0,         10,         10,        1,  4718592, 0x813ef53f
+0,         11,         11,        1,  4718592, 0xa4fd9eb2
+0,         12,         12,        1,  4718592, 0x719308ab
+0,         13,         13,        1,  4718592, 0xcc53abdb
+0,         14,         14,        1,  4718592, 0x69a1fbad
+0,         15,         15,        1,  4718592, 0xb1dee2e6
+0,         16,         16,        1,  4718592, 0x8892b11a
+0,         17,         17,        1,  4718592, 0xeea14ec7
+0,         18,         18,        1,  4718592, 0x1c8351a2
+0,         19,         19,        1,  4718592, 0x616a56d6
+0,         20,         20,        1,  4718592, 0x166e9329
+0,         21,         21,        1,  4718592, 0xe62a5ada
+0,         22,         22,        1,  4718592, 0x7ad680b9
+0,         23,         23,        1,  4718592, 0xa6c5d534
+0,         24,         24,        1,  4718592, 0xfbfbfd9a
+0,         25,         25,        1,  4718592, 0x30c3a53f
+0,         26,         26,        1,  4718592, 0x7229cad1
+0,         27,         27,        1,  4718592, 0x2703bd48
+0,         28,         28,        1,  4718592, 0xc46880e9
+0,         29,         29,        1,  4718592, 0x9480ac78
+0,         30,         30,        1,  4718592, 0xc9410aa9
+0,         31,         31,        1,  4718592, 0x7094d03d
+0,         32,         32,        1,  4718592, 0x63b02bce
+0,         33,         33,        1,  4718592, 0x5b7bf9c5
+0,         34,         34,        1,  4718592, 0x99af0869
+0,         35,         35,        1,  4718592, 0x54b382b6
+0,         36,         36,        1,  4718592, 0xc2511916
+0,         37,         37,        1,  4718592, 0x9833e473
+0,         38,         38,        1,  4718592, 0x91062ed4
+0,         39,         39,        1,  4718592, 0x47669bea
+0,         40,         40,        1,  4718592, 0x0bde1655
+0,         41,         41,        1,  4718592, 0x0c638749
+0,         42,         42,        1,  4718592, 0x4d5c380a
+0,         43,         43,        1,  4718592, 0x1780c529
+0,         44,         44,        1,  4718592, 0xe16a41da
+0,         45,         45,        1,  4718592, 0xfc265995
+0,         46,         46,        1,  4718592, 0x4fa62cc5
+0,         47,         47,        1,  4718592, 0x3c1263dc
+0,         48,         48,        1,  4718592, 0x43e21353
+0,         49,         49,        1,  4718592, 0x81a20ca5
+0,         50,         50,        1,  4718592, 0x74a6065b
+0,         51,         51,        1,  4718592, 0x5305f734
+0,         52,         52,        1,  4718592, 0xe287f597
+0,         53,         53,        1,  4718592, 0xc7c5dd6b
+0,         54,         54,        1,  4718592, 0x5b173885
+0,         55,         55,        1,  4718592, 0xb146d1f2
+0,         56,         56,        1,  4718592, 0x9c462f75
+0,         57,         57,        1,  4718592, 0x5214a211
+0,         58,         58,        1,  4718592, 0x473dd1c2
+0,         59,         59,        1,  4718592, 0x85efaa75
+0,         60,         60,        1,  4718592, 0x0885206c
+0,         61,         61,        1,  4718592, 0xe591f7c0
+0,         62,         62,        1,  4718592, 0xecd67225
-- 
2.49.1

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

Reply via email to