[Mesa-dev] [PATCH v2 2/2] radeon/vcn: fix width alignment for hevc encoding

Zhang, Boyuan Boyuan.Zhang at amd.com
Mon Apr 22 20:57:57 UTC 2019


Both patches are
Reviewed-by: Boyuan Zhang <boyuan.zhang at amd.com>

Thanks,
Boyuan

-----Original Message-----
From: mesa-dev <mesa-dev-bounces at lists.freedesktop.org> On Behalf Of Lei Zhou
Sent: April 18, 2019 12:14 PM
To: mesa-dev at lists.freedesktop.org
Subject: [Mesa-dev] [PATCH v2 2/2] radeon/vcn: fix width alignment for hevc encoding

The width alignment for HEVC encoding should be 64 due to hardware requirement. This will fix conformance_window_flag in SPS.

v2 (Zhang, Boyuan):
 - add marcos to define width alignment for hevc and h264

Signed-off-by: Lei Zhou <zhoulei at kylinos.cn>
---
 src/gallium/drivers/radeon/radeon_vcn_enc.c     | 4 ++--
 src/gallium/drivers/radeon/radeon_vcn_enc.h     | 3 +++
 src/gallium/drivers/radeon/radeon_vcn_enc_1_2.c | 4 ++--
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_vcn_enc.c b/src/gallium/drivers/radeon/radeon_vcn_enc.c
index 7d64a28a405..a882bba502c 100644
--- a/src/gallium/drivers/radeon/radeon_vcn_enc.c
+++ b/src/gallium/drivers/radeon/radeon_vcn_enc.c
@@ -51,7 +51,7 @@ static void radeon_vcn_enc_get_param(struct radeon_encoder *enc, struct pipe_pic
       enc->enc_pic.not_referenced = pic->not_referenced;
       enc->enc_pic.is_idr = (pic->picture_type == PIPE_H264_ENC_PICTURE_TYPE_IDR);
       enc->enc_pic.crop_left = 0;
-      enc->enc_pic.crop_right = (align(enc->base.width, 16) - enc->base.width) / 2;
+      enc->enc_pic.crop_right = (align(enc->base.width, 
+ RENCODE_H264_WIDTH_ALIGN) - enc->base.width) / 2;
       enc->enc_pic.crop_top = 0;
       enc->enc_pic.crop_bottom = (align(enc->base.height, 16) - enc->base.height) / 2;
    } else if (u_reduce_video_profile(picture->profile) == PIPE_VIDEO_FORMAT_HEVC) { @@ -66,7 +66,7 @@ static void radeon_vcn_enc_get_param(struct radeon_encoder *enc, struct pipe_pic
       enc->enc_pic.is_idr = (pic->picture_type == PIPE_H265_ENC_PICTURE_TYPE_IDR) ||
                             (pic->picture_type == PIPE_H265_ENC_PICTURE_TYPE_I);
       enc->enc_pic.crop_left = 0;
-      enc->enc_pic.crop_right = (align(enc->base.width, 16) - enc->base.width) / 2;
+      enc->enc_pic.crop_right = (align(enc->base.width, 
+ RENCODE_HEVC_WIDTH_ALIGN) - enc->base.width) / 2;
       enc->enc_pic.crop_top = 0;
       enc->enc_pic.crop_bottom = (align(enc->base.height, 16) - enc->base.height) / 2;
       enc->enc_pic.general_tier_flag = pic->seq.general_tier_flag; diff --git a/src/gallium/drivers/radeon/radeon_vcn_enc.h b/src/gallium/drivers/radeon/radeon_vcn_enc.h
index 04685c69af1..fadc74cc898 100644
--- a/src/gallium/drivers/radeon/radeon_vcn_enc.h
+++ b/src/gallium/drivers/radeon/radeon_vcn_enc.h
@@ -148,6 +148,9 @@
 #define RENCODE_FEEDBACK_BUFFER_MODE_LINEAR 			0
 #define RENCODE_FEEDBACK_BUFFER_MODE_CIRCULAR			1
 
+#define RENCODE_H264_WIDTH_ALIGN                        16
+#define RENCODE_HEVC_WIDTH_ALIGN                        64
+
 typedef struct rvcn_enc_session_info_s
 {
     uint32_t	interface_version;
diff --git a/src/gallium/drivers/radeon/radeon_vcn_enc_1_2.c b/src/gallium/drivers/radeon/radeon_vcn_enc_1_2.c
index 7f5b1909344..388df42909f 100644
--- a/src/gallium/drivers/radeon/radeon_vcn_enc_1_2.c
+++ b/src/gallium/drivers/radeon/radeon_vcn_enc_1_2.c
@@ -212,7 +212,7 @@ static void radeon_enc_task_info(struct radeon_encoder *enc, bool need_feedback)  static void radeon_enc_session_init(struct radeon_encoder *enc)  {
 	enc->enc_pic.session_init.encode_standard = RENCODE_ENCODE_STANDARD_H264;
-	enc->enc_pic.session_init.aligned_picture_width = align(enc->base.width, 16);
+	enc->enc_pic.session_init.aligned_picture_width = 
+align(enc->base.width, RENCODE_H264_WIDTH_ALIGN);
 	enc->enc_pic.session_init.aligned_picture_height = align(enc->base.height, 16);
 	enc->enc_pic.session_init.padding_width = enc->enc_pic.session_init.aligned_picture_width - enc->base.width;
 	enc->enc_pic.session_init.padding_height = enc->enc_pic.session_init.aligned_picture_height - enc->base.height; @@ -233,7 +233,7 @@ static void radeon_enc_session_init(struct radeon_encoder *enc)  static void radeon_enc_session_init_hevc(struct radeon_encoder *enc)  {
 	enc->enc_pic.session_init.encode_standard = RENCODE_ENCODE_STANDARD_HEVC;
-	enc->enc_pic.session_init.aligned_picture_width = align(enc->base.width, 64);
+	enc->enc_pic.session_init.aligned_picture_width = 
+align(enc->base.width, RENCODE_HEVC_WIDTH_ALIGN);
 	enc->enc_pic.session_init.aligned_picture_height = align(enc->base.height, 16);
 	enc->enc_pic.session_init.padding_width = enc->enc_pic.session_init.aligned_picture_width - enc->base.width;
 	enc->enc_pic.session_init.padding_height = enc->enc_pic.session_init.aligned_picture_height - enc->base.height;
--
2.21.0



_______________________________________________
mesa-dev mailing list
mesa-dev at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list