radeonsi/vcn: change max_poc to fixed value for hevc encoder.
authorRuijing Dong <ruijing.dong@amd.com>
Wed, 13 Sep 2023 19:03:17 +0000 (15:03 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 14 Sep 2023 14:43:15 +0000 (14:43 +0000)
problem: max_poc means the number of bits used in poc lsb
         in slice header, and it should not be related to GOP
 size. When large GOP size used, it could generate
 corrupted video, as the POC could not be correctly
 decoded.

solution: use fixed value of max_poc (16) for now.

Cc: mesa-stable
Reviewed-by: Boyuan Zhang <Boyuan.Zhang@amd.com>
Signed-off-by: Ruijing Dong <ruijing.dong@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25214>

src/gallium/drivers/radeonsi/radeon_vcn_enc.c

index 17cfcdc..4c06adf 100644 (file)
@@ -459,7 +459,6 @@ static void radeon_vcn_enc_hevc_get_param(struct radeon_encoder *enc,
    enc->enc_pic.picture_type = pic->picture_type;
    enc->enc_pic.frame_num = pic->frame_num;
    radeon_vcn_enc_quality_modes(enc, &pic->quality_modes);
-   enc->enc_pic.pic_order_cnt = pic->pic_order_cnt;
    enc->enc_pic.pic_order_cnt_type = pic->pic_order_cnt_type;
    enc->enc_pic.ref_idx_l0 = pic->ref_idx_l0_list[0];
    enc->enc_pic.ref_idx_l1 = pic->ref_idx_l1_list[0];
@@ -469,12 +468,11 @@ static void radeon_vcn_enc_hevc_get_param(struct radeon_encoder *enc,
    enc->enc_pic.general_tier_flag = pic->seq.general_tier_flag;
    enc->enc_pic.general_profile_idc = pic->seq.general_profile_idc;
    enc->enc_pic.general_level_idc = pic->seq.general_level_idc;
-   enc->enc_pic.max_poc = MAX2(16, util_next_power_of_two(pic->seq.intra_period));
-   enc->enc_pic.log2_max_poc = 0;
+   /* use fixed value for max_poc until new feature added */
+   enc->enc_pic.max_poc = 16;
+   enc->enc_pic.log2_max_poc = 4;
    enc->enc_pic.num_temporal_layers = 1;
-   for (int i = enc->enc_pic.max_poc; i != 0; enc->enc_pic.log2_max_poc++)
-      i = (i >> 1);
-
+   enc->enc_pic.pic_order_cnt = pic->pic_order_cnt % enc->enc_pic.max_poc;
    enc->enc_pic.chroma_format_idc = pic->seq.chroma_format_idc;
    enc->enc_pic.pic_width_in_luma_samples = pic->seq.pic_width_in_luma_samples;
    enc->enc_pic.pic_height_in_luma_samples = pic->seq.pic_height_in_luma_samples;