diff mbox series

[FFmpeg-devel] hevc_ps: fix cpb_cnt_minus1 initialization and fixed_rate check

Message ID 20230910150100.11249-2-llyyr.public@gmail.com
State New
Headers show
Series [FFmpeg-devel] hevc_ps: fix cpb_cnt_minus1 initialization and fixed_rate check | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

llyyr Sept. 10, 2023, 3 p.m. UTC
Fixes: fc429d785e9e24c5520ce716d4bc3b5547e581eb

cpb_cnt was initialized to 1 before
fc429d785e9e24c5520ce716d4bc3b5547e581eb, so cpb_cnt_minus1 should be
initialized to 0 instead of 1.

Since we split fixed_rate into a general flag and a within_cvs_flag now,
check for both in conditional.
---
 libavcodec/hevc_ps.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Derek Buitenhuis Sept. 10, 2023, 3:16 p.m. UTC | #1
On 9/10/2023 4:00 PM, llyyr wrote:
> Fixes: fc429d785e9e24c5520ce716d4bc3b5547e581eb
> 
> cpb_cnt was initialized to 1 before
> fc429d785e9e24c5520ce716d4bc3b5547e581eb, so cpb_cnt_minus1 should be
> initialized to 0 instead of 1.
> 
> Since we split fixed_rate into a general flag and a within_cvs_flag now,
> check for both in conditional.
> ---
>  libavcodec/hevc_ps.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)

Should be two commits, I think.

Also, cpb_cnt_minus1 is being passed to decode_sublayer_hrd() below, and needs
a +1 there.

- Derek
diff mbox series

Patch

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index bdd623507d..da5ba5a3bf 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -406,12 +406,11 @@  static int decode_hrd(GetBitContext *gb, int common_inf_present,
     for (int i = 0; i < max_sublayers; i++) {
         hdr->flags.fixed_pic_rate_general_flag = get_bits1(gb);
 
-        hdr->cpb_cnt_minus1[i] = 1;
-
         if (!hdr->flags.fixed_pic_rate_general_flag)
             hdr->flags.fixed_pic_rate_within_cvs_flag = get_bits1(gb);
 
-        if (hdr->flags.fixed_pic_rate_within_cvs_flag)
+        if (hdr->flags.fixed_pic_rate_within_cvs_flag ||
+            hdr->flags.fixed_pic_rate_general_flag)
             hdr->elemental_duration_in_tc_minus1[i] = get_ue_golomb_long(gb);
         else
             hdr->flags.low_delay_hrd_flag = get_bits1(gb);