media_module: vp9/h265: add save buf mode [2/2]

PD#173436 PD#SWPL-349

Problem:
not enought codec mm for cts decoder test which
running in both none-nativewindow and nativewindow mode

Solution:
reduce omx output buffer and decoder buffer for gsi

Verify:
QA verified

Change-Id: I7cf120722c42db2ed75cc09e25a3fbb34cdf9598
Signed-off-by: Yao.Liu <yao.liu@amlogic.com>
This commit is contained in:
Yao.Liu
2018-10-13 08:14:05 -04:00
committed by Dongjin Kim
parent be3f6f1bd9
commit 72b294a41b
2 changed files with 51 additions and 17 deletions

View File

@@ -1538,6 +1538,7 @@ struct hevc_state_s {
int double_write_mode;
int dynamic_buf_num_margin;
int start_action;
int save_buffer_mode;
#endif
u32 i_only;
struct list_head log_list;
@@ -2453,6 +2454,11 @@ static int get_work_pic_num(struct hevc_state_s *hevc)
} else
used_buf_num = max_buf_num;
if (hevc->save_buffer_mode)
hevc_print(hevc, 0,
"save buf _mode : dynamic_buf_num_margin %d ----> %d \n",
dynamic_buf_num_margin, hevc->dynamic_buf_num_margin);
if (used_buf_num > MAX_BUF_NUM)
used_buf_num = MAX_BUF_NUM;
return used_buf_num;
@@ -10579,6 +10585,12 @@ static int ammvdec_h265_probe(struct platform_device *pdev)
else
hevc->double_write_mode = double_write_mode;
if (get_config_int(pdata->config, "save_buffer_mode",
&config_val) == 0)
hevc->save_buffer_mode = config_val;
else
hevc->save_buffer_mode = 0;
/*use ptr config for max_pic_w, etc*/
if (get_config_int(pdata->config, "hevc_buf_width",
&config_val) == 0) {
@@ -10596,8 +10608,10 @@ static int ammvdec_h265_probe(struct platform_device *pdev)
hevc->vh265_amstream_dec_info.rate = 30;
hevc->double_write_mode = double_write_mode;
}
hevc->dynamic_buf_num_margin = dynamic_buf_num_margin;
if (hevc->save_buffer_mode && dynamic_buf_num_margin > 2)
hevc->dynamic_buf_num_margin = dynamic_buf_num_margin -2;
else
hevc->dynamic_buf_num_margin = dynamic_buf_num_margin;
if (mmu_enable_force == 0) {
if (get_cpu_major_id() < AM_MESON_CPU_MAJOR_ID_GXL

View File

@@ -590,7 +590,10 @@ enum REFERENCE_MODE {
#define REF_FRAMES_LOG2 3
#define REF_FRAMES (1 << REF_FRAMES_LOG2)
#define REF_FRAMES_4K (6)
#define REF_FRAMES_2K (6)
#define REF_FRAMES_4K (4)
/*4 scratch frames for the new frames to support a maximum of 4 cores decoding
*in parallel, 3 for scaled references on the encoder.
@@ -975,6 +978,7 @@ struct VP9Decoder_s {
unsigned last_lcu_idx;
int decode_timeout_count;
unsigned timeout_num;
int save_buffer_mode;
int double_write_mode;
#endif
@@ -1114,6 +1118,7 @@ struct VP9Decoder_s {
struct firmware_s *fw;
int max_pic_w;
int max_pic_h;
u32 dec_buf_margin;
#ifdef SUPPORT_FB_DECODING
int dec_s1_result;
int s1_test_cmd;
@@ -1666,12 +1671,14 @@ static int init_mv_buf_list(struct VP9Decoder_s *pbi)
int lcu_total = pic_width_lcu * pic_height_lcu;
int size = ((lcu_total * MV_MEM_UNIT) + 0xffff) &
(~0xffff);
if (mv_buf_margin > 0)
count = REF_FRAMES + mv_buf_margin;
if (pbi->init_pic_w > 2048 && pbi->init_pic_h > 1088)
count = REF_FRAMES_4K + mv_buf_margin;
if (pbi->init_pic_w >= 3840 && pbi->init_pic_h >= 2160)
count = REF_FRAMES_4K;
else if (pbi->init_pic_w > 2048 && pbi->init_pic_h > 1088)
count = REF_FRAMES_2K;
else
count = REF_FRAMES;
count += pbi->dec_buf_margin;
if (debug) {
pr_info("%s w:%d, h:%d, count: %d\n",
__func__, pbi->init_pic_w, pbi->init_pic_h, count);
@@ -2757,12 +2764,13 @@ static u32 max_decoding_time;
static u32 error_handle_policy;
/*static u32 parser_sei_enable = 1;*/
#define MAX_BUF_NUM_NORMAL 12
#define MAX_BUF_NUM_LESS 10
static u32 max_buf_num = MAX_BUF_NUM_NORMAL;
#define BUF_NUM_NORMAL 4
#define BUF_NUM_LESS 3
static u32 dec_buf_margin = BUF_NUM_NORMAL;
static u32 run_ready_min_buf_num = 2;
static DEFINE_MUTEX(vvp9_mutex);
#ifndef MULTI_INSTANCE_SUPPORT
static struct device *cma_dev;
@@ -6020,8 +6028,13 @@ static int vp9_local_init(struct VP9Decoder_s *pbi)
}
#endif
if (pbi->init_pic_w >= 3840 && pbi->init_pic_h >= 2160)
pbi->used_buf_num = REF_FRAMES_4K + pbi->dec_buf_margin;
else if (pbi->init_pic_w > 2048 && pbi->init_pic_h > 1088)
pbi->used_buf_num = REF_FRAMES_2K + pbi->dec_buf_margin;
else
pbi->used_buf_num = REF_FRAMES + pbi->dec_buf_margin;
pbi->used_buf_num = max_buf_num;
if (pbi->used_buf_num > MAX_BUF_NUM)
pbi->used_buf_num = MAX_BUF_NUM;
if (pbi->used_buf_num > FRAME_BUFFERS)
@@ -9096,6 +9109,13 @@ static int ammvdec_vp9_probe(struct platform_device *pdev)
else
pbi->double_write_mode = double_write_mode;
if (get_config_int(pdata->config, "save_buffer_mode",
&config_val) == 0)
pbi->save_buffer_mode = config_val;
else
pbi->save_buffer_mode = 0;
pbi->dec_buf_margin = dec_buf_margin;
/*use ptr config for max_pic_w, etc*/
if (get_config_int(pdata->config, "vp9_max_pic_w",
&config_val) == 0) {
@@ -9288,7 +9308,6 @@ static struct mconfig vp9_configs[] = {
MC_PU32("buf_alloc_size", &buf_alloc_size),
MC_PU32("buffer_mode", &buffer_mode),
MC_PU32("buffer_mode_dbg", &buffer_mode_dbg),
MC_PU32("max_buf_num", &max_buf_num),
MC_PU32("dynamic_buf_num_margin", &dynamic_buf_num_margin),
MC_PU32("mem_map_mode", &mem_map_mode),
MC_PU32("double_write_mode", &double_write_mode),
@@ -9357,7 +9376,7 @@ static int __init amvdec_vp9_driver_init_module(void)
}
if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_G12A)
max_buf_num = MAX_BUF_NUM_LESS;
dec_buf_margin = BUF_NUM_LESS;
vcodec_profile_register(&amvdec_vp9_profile);
INIT_REG_NODE_CONFIGS("media.decoder", &vp9_node,
@@ -9443,15 +9462,16 @@ MODULE_PARM_DESC(buffer_mode, "\n buffer_mode\n");
module_param(buffer_mode_dbg, uint, 0664);
MODULE_PARM_DESC(buffer_mode_dbg, "\n buffer_mode_dbg\n");
/*USE_BUF_BLOCK*/
module_param(max_buf_num, uint, 0664);
MODULE_PARM_DESC(max_buf_num, "\n max_buf_num\n");
module_param(dynamic_buf_num_margin, uint, 0664);
MODULE_PARM_DESC(dynamic_buf_num_margin, "\n dynamic_buf_num_margin\n");
module_param(mv_buf_margin, uint, 0664);
MODULE_PARM_DESC(mv_buf_margin, "\n mv_buf_margin\n");
module_param(dec_buf_margin, uint, 0664);
MODULE_PARM_DESC(dec_buf_margin, "\n dec_buf_margin\n");
module_param(run_ready_min_buf_num, uint, 0664);
MODULE_PARM_DESC(run_ready_min_buf_num, "\n run_ready_min_buf_num\n");