瀏覽代碼

Merge "video: driver: fix encoder output buffer size requirement"

qctecmdr 2 年之前
父節點
當前提交
e77d578972

+ 7 - 4
driver/variant/iris3/inc/hfi_buffer_iris3.h

@@ -1177,23 +1177,26 @@ _yuv_bufcount_min, is_opb, num_vpp_pipes)           \
 			rc_type, is_ten_bit) \
 	do \
 	{ \
-		HFI_U32 aligned_width, aligned_height, bitstream_size; \
+		HFI_U32 aligned_width, aligned_height, bitstream_size, yuv_size; \
 		aligned_width = HFI_ALIGN(frame_width, 32); \
 		aligned_height = HFI_ALIGN(frame_height, 32); \
 		bitstream_size = aligned_width * aligned_height * 3; \
+		yuv_size = (aligned_width * aligned_height * 3) >> 1; \
 		if (aligned_width * aligned_height > (4096 * 2176)) \
 		{ \
+		    /* bitstream_size = 0.25 * yuv_size; */ \
 			bitstream_size = (bitstream_size >> 3); \
 		} \
-		else if (bitstream_size > (1280 * 720)) \
+		else if (aligned_width * aligned_height > (1280 * 720)) \
 		{ \
+		    /* bitstream_size = 0.5 * yuv_size; */ \
 			bitstream_size = (bitstream_size >> 2); \
 		} \
 		else \
 		{ \
-			bitstream_size = (bitstream_size << 1);\
+		    /* bitstream_size = 2 * yuv_size; */ \
 		} \
-		if ((rc_type == HFI_RC_CQ) || (rc_type == HFI_RC_OFF))  \
+		if (((rc_type == HFI_RC_CQ) || (rc_type == HFI_RC_OFF)) && (bitstream_size < yuv_size))  \
 		{ \
 			bitstream_size = (bitstream_size << 1);\
 		} \

+ 2 - 1
driver/vidc/inc/msm_vidc_internal.h

@@ -73,7 +73,8 @@ enum msm_vidc_metadata_bits {
 #define MAX_VP9D_INST_COUNT     6
 /* TODO: move below macros to waipio.c */
 #define MAX_ENH_LAYER_HB        3
-#define MAX_HEVC_ENH_LAYER_SLIDING_WINDOW     5
+#define MAX_HEVC_VBR_ENH_LAYER_SLIDING_WINDOW         5
+#define MAX_HEVC_NON_VBR_ENH_LAYER_SLIDING_WINDOW     3
 #define MAX_AVC_ENH_LAYER_SLIDING_WINDOW      3
 #define MAX_AVC_ENH_LAYER_HYBRID_HP           5
 #define INVALID_DEFAULT_MARK_OR_USE_LTR      -1

+ 9 - 4
driver/vidc/src/msm_vidc_control.c

@@ -1826,7 +1826,7 @@ static int msm_vidc_adjust_static_layer_count_and_type(struct msm_vidc_inst *ins
 			inst->hfi_layer_type = HFI_HIER_P_HYBRID_LTR;
 	}
 
-	/* sanitize layer count based on layer type and codec */
+	/* sanitize layer count based on layer type and codec, and rc type */
 	if (inst->hfi_layer_type == HFI_HIER_B) {
 		if (layer_count > MAX_ENH_LAYER_HB)
 			layer_count = MAX_ENH_LAYER_HB;
@@ -1837,9 +1837,14 @@ static int msm_vidc_adjust_static_layer_count_and_type(struct msm_vidc_inst *ins
 		if (inst->codec == MSM_VIDC_H264) {
 			if (layer_count > MAX_AVC_ENH_LAYER_SLIDING_WINDOW)
 				layer_count = MAX_AVC_ENH_LAYER_SLIDING_WINDOW;
-		} else {
-			if (layer_count > MAX_HEVC_ENH_LAYER_SLIDING_WINDOW)
-				layer_count = MAX_HEVC_ENH_LAYER_SLIDING_WINDOW;
+		} else if (inst->codec == MSM_VIDC_HEVC) {
+			if (inst->hfi_rc_type == HFI_RC_VBR_CFR) {
+				if (layer_count > MAX_HEVC_VBR_ENH_LAYER_SLIDING_WINDOW)
+					layer_count = MAX_HEVC_VBR_ENH_LAYER_SLIDING_WINDOW;
+			} else {
+				if (layer_count > MAX_HEVC_NON_VBR_ENH_LAYER_SLIDING_WINDOW)
+					layer_count = MAX_HEVC_NON_VBR_ENH_LAYER_SLIDING_WINDOW;
+			}
 		}
 	}