Merge "video: driver: Use max bitrate depending upon session"
This commit is contained in:

committed by
Gerrit - the friendly Code Review server

commit
395e8686ec
@@ -510,6 +510,7 @@ int msm_vidc_state_change_start(struct msm_vidc_inst *inst);
|
||||
int msm_vidc_state_change_input_psc(struct msm_vidc_inst *inst);
|
||||
int msm_vidc_state_change_last_flag(struct msm_vidc_inst *inst);
|
||||
int msm_vidc_get_mbs_per_frame(struct msm_vidc_inst *inst);
|
||||
u32 msm_vidc_get_max_bitrate(struct msm_vidc_inst* inst);
|
||||
int msm_vidc_get_fps(struct msm_vidc_inst *inst);
|
||||
int msm_vidc_num_buffers(struct msm_vidc_inst *inst,
|
||||
enum msm_vidc_buffer_type type, enum msm_vidc_buffer_attributes attr);
|
||||
|
@@ -491,6 +491,10 @@ enum msm_vidc_inst_capability_type {
|
||||
INPUT_META_VIA_REQUEST,
|
||||
ENC_IP_CR,
|
||||
COMPLEXITY,
|
||||
CABAC_MAX_BITRATE,
|
||||
CAVLC_MAX_BITRATE,
|
||||
ALLINTRA_MAX_BITRATE,
|
||||
LOWLATENCY_MAX_BITRATE,
|
||||
/* place all root(no parent) enums before this line */
|
||||
|
||||
PROFILE,
|
||||
|
@@ -2079,9 +2079,10 @@ int msm_vidc_adjust_bitrate(void *instance, struct v4l2_ctrl *ctrl)
|
||||
int i, rc = 0;
|
||||
struct msm_vidc_inst *inst = (struct msm_vidc_inst *) instance;
|
||||
struct msm_vidc_inst_capability *capability;
|
||||
s32 adjusted_value, max_bitrate, enh_layer_count;
|
||||
s32 adjusted_value, enh_layer_count;
|
||||
u32 cumulative_bitrate = 0, cap_id = 0, cap_value = 0;
|
||||
u32 layer_br_caps[6] = {L0_BR, L1_BR, L2_BR, L3_BR, L4_BR, L5_BR};
|
||||
u32 max_bitrate = 0;
|
||||
|
||||
if (!inst || !inst->capabilities) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
@@ -2110,7 +2111,10 @@ int msm_vidc_adjust_bitrate(void *instance, struct v4l2_ctrl *ctrl)
|
||||
ENH_LAYER_COUNT, &enh_layer_count, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
max_bitrate = inst->capabilities->cap[BIT_RATE].max;
|
||||
/* get max bit rate for current session config*/
|
||||
max_bitrate = msm_vidc_get_max_bitrate(inst);
|
||||
if (inst->capabilities->cap[BIT_RATE].value > max_bitrate)
|
||||
msm_vidc_update_cap_value(inst, BIT_RATE, max_bitrate, __func__);
|
||||
|
||||
/*
|
||||
* ENH_LAYER_COUNT cap max is positive only if
|
||||
@@ -2584,6 +2588,7 @@ int msm_vidc_adjust_bitrate_boost(void *instance, struct v4l2_ctrl *ctrl)
|
||||
s32 adjusted_value;
|
||||
struct msm_vidc_inst *inst = (struct msm_vidc_inst *) instance;
|
||||
s32 min_quality = -1, rc_type = -1;
|
||||
u32 max_bitrate = 0, bitrate = 0;
|
||||
|
||||
if (!inst || !inst->capabilities) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
@@ -2617,6 +2622,17 @@ int msm_vidc_adjust_bitrate_boost(void *instance, struct v4l2_ctrl *ctrl)
|
||||
goto adjust;
|
||||
}
|
||||
|
||||
max_bitrate = msm_vidc_get_max_bitrate(inst);
|
||||
bitrate = inst->capabilities->cap[BIT_RATE].value;
|
||||
if (adjusted_value) {
|
||||
if ((bitrate + bitrate / (100 / adjusted_value)) > max_bitrate) {
|
||||
i_vpr_h(inst,
|
||||
"%s: bitrate %d is beyond max bitrate %d, remove bitrate boost\n",
|
||||
__func__, max_bitrate, bitrate);
|
||||
adjusted_value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
adjust:
|
||||
msm_vidc_update_cap_value(inst, BITRATE_BOOST,
|
||||
adjusted_value, __func__);
|
||||
|
@@ -189,6 +189,10 @@ static const struct msm_vidc_cap_name cap_name_arr[] = {
|
||||
{INPUT_META_VIA_REQUEST, "INPUT_META_VIA_REQUEST" },
|
||||
{ENC_IP_CR, "ENC_IP_CR" },
|
||||
{COMPLEXITY, "COMPLEXITY" },
|
||||
{CABAC_MAX_BITRATE, "CABAC_MAX_BITRATE" },
|
||||
{CAVLC_MAX_BITRATE, "CAVLC_MAX_BITRATE" },
|
||||
{ALLINTRA_MAX_BITRATE, "ALLINTRA_MAX_BITRATE" },
|
||||
{LOWLATENCY_MAX_BITRATE, "LOWLATENCY_MAX_BITRATE" },
|
||||
{PROFILE, "PROFILE" },
|
||||
{ENH_LAYER_COUNT, "ENH_LAYER_COUNT" },
|
||||
{BIT_RATE, "BIT_RATE" },
|
||||
@@ -6137,6 +6141,43 @@ static int msm_vidc_check_inst_mbpf(struct msm_vidc_inst *inst)
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 msm_vidc_get_max_bitrate(struct msm_vidc_inst* inst)
|
||||
{
|
||||
struct msm_vidc_inst_capability *capability;
|
||||
u32 max_bitrate = 0x7fffffff;
|
||||
|
||||
if (!inst || !inst->capabilities) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
capability = inst->capabilities;
|
||||
|
||||
if (inst->capabilities->cap[LOWLATENCY_MODE].value)
|
||||
max_bitrate = min(max_bitrate,
|
||||
(u32)inst->capabilities->cap[LOWLATENCY_MAX_BITRATE].max);
|
||||
|
||||
if (inst->capabilities->cap[ALL_INTRA].value)
|
||||
max_bitrate = min(max_bitrate,
|
||||
(u32)inst->capabilities->cap[ALLINTRA_MAX_BITRATE].max);
|
||||
|
||||
if (inst->codec == MSM_VIDC_HEVC) {
|
||||
max_bitrate = min(max_bitrate,
|
||||
(u32)inst->capabilities->cap[CABAC_MAX_BITRATE].max);
|
||||
} else if (inst->codec == MSM_VIDC_H264) {
|
||||
if (inst->capabilities->cap[ENTROPY_MODE].value ==
|
||||
V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC)
|
||||
max_bitrate = min(max_bitrate,
|
||||
(u32)inst->capabilities->cap[CAVLC_MAX_BITRATE].max);
|
||||
else
|
||||
max_bitrate = min(max_bitrate,
|
||||
(u32)inst->capabilities->cap[CABAC_MAX_BITRATE].max);
|
||||
}
|
||||
if (max_bitrate == 0x7fffffff || !max_bitrate)
|
||||
max_bitrate = min(max_bitrate, (u32)inst->capabilities->cap[BIT_RATE].max);
|
||||
|
||||
return max_bitrate;
|
||||
}
|
||||
|
||||
static bool msm_vidc_allow_image_encode_session(struct msm_vidc_inst *inst)
|
||||
{
|
||||
struct msm_vidc_inst_capability *capability;
|
||||
|
Reference in New Issue
Block a user