video: driver: Add support for slice encode delivery

Add support to enable slice encode delivery for
HEVC and AVC codec. Basically in this mode, each
encoded slice is given as a separate FBD to the client.

Change-Id: Ia30fde9abaf2b38fb486113807fbb7f19110225c
Signed-off-by: Chandrakant I Viraktamath <quic_civirakt@quicinc.com>
This commit is contained in:
Chandrakant I Viraktamath
2021-08-17 11:38:28 +05:30
父節點 a079cc43f3
當前提交 308499361d
共有 11 個文件被更改,包括 299 次插入7 次删除

查看文件

@@ -1201,6 +1201,64 @@ _yuv_bufcount_min, is_opb, num_vpp_pipes) \
size = HFI_ALIGN(bitstream_size, HFI_ALIGNMENT_4096); \
} while (0)
#define HFI_IRIS3_ENC_TILE_SIZE_INFO(tile_size, tile_count, last_tile_size, \
frame_width_coded, codec_standard) \
do \
{ \
HFI_U32 without_tile_enc_width; \
HFI_U32 min_tile_size = 352, fixed_tile_width = 960; \
without_tile_enc_width = min_tile_size + fixed_tile_width; \
if ((codec_standard == HFI_CODEC_ENCODE_HEVC) && \
(frame_width_coded > without_tile_enc_width)) \
{ \
tile_size = fixed_tile_width; \
tile_count = (frame_width_coded + tile_size - 1) / tile_size; \
last_tile_size = (frame_width_coded - (tile_size * (tile_count - 1))); \
if (last_tile_size < min_tile_size) \
{ \
tile_count -= 1; \
last_tile_size = (tile_size + min_tile_size); \
} \
} \
else \
{ \
tile_size = frame_width_coded; \
tile_count = 1; \
last_tile_size = 0; \
} \
} while (0)
#define HFI_IRIS3_ENC_MB_BASED_MULTI_SLICE_COUNT(total_slice_count, frame_width, frame_height, \
codec_standard, multi_slice_max_mb_count) \
do \
{ \
HFI_U32 tile_size, tile_count, last_tile_size, \
slice_count_per_tile, slice_count_in_last_tile; \
HFI_U32 mbs_in_one_tile, mbs_in_last_tile; \
HFI_U32 frame_width_coded, frame_height_coded, lcu_size; \
lcu_size = (codec_standard == HFI_CODEC_ENCODE_HEVC) ? 32 : 16; \
frame_width_coded = HFI_ALIGN(frame_width, lcu_size); \
frame_height_coded = HFI_ALIGN(frame_height, lcu_size); \
HFI_IRIS3_ENC_TILE_SIZE_INFO(tile_size, tile_count, last_tile_size, \
frame_width_coded, codec_standard); \
mbs_in_one_tile = (tile_size * frame_height_coded) / (lcu_size * lcu_size); \
slice_count_per_tile = \
(mbs_in_one_tile + multi_slice_max_mb_count - 1) / (multi_slice_max_mb_count); \
if (last_tile_size) \
{ \
mbs_in_last_tile = \
(last_tile_size * frame_height_coded) / (lcu_size * lcu_size); \
slice_count_in_last_tile = \
(mbs_in_last_tile + multi_slice_max_mb_count - 1) / (multi_slice_max_mb_count); \
total_slice_count = \
(slice_count_per_tile * (tile_count - 1)) + slice_count_in_last_tile; \
} \
else \
{ \
total_slice_count = (slice_count_per_tile * tile_count); \
} \
} while (0)
#define SIZE_ROI_METADATA_ENC(size_roi, frame_width, frame_height, lcu_size)\
do \
{ \

查看文件

@@ -670,6 +670,48 @@ static int msm_buffer_dpb_count(struct msm_vidc_inst *inst)
return msm_vidc_get_recon_buf_count(inst);
}
static int msm_buffer_delivery_mode_based_min_count_iris3(struct msm_vidc_inst *inst,
uint32_t count)
{
struct v4l2_format *f;
u32 width, height, total_num_slices = 1;
u32 hfi_codec = 0;
u32 max_mbs_per_slice = 0;
u32 slice_mode = 0;
u32 delivery_mode = 0;
if (!inst || !inst->capabilities) {
d_vpr_e("%s: invalid params\n", __func__);
return count;
}
slice_mode = inst->capabilities->cap[SLICE_MODE].value;
delivery_mode = inst->capabilities->cap[DELIVERY_MODE].value;
if (slice_mode != V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_MAX_MB ||
(inst->codec == MSM_VIDC_H264 &&
delivery_mode != V4L2_MPEG_VIDC_H264_ENCODE_DELIVERY_MODE_SLICE_BASED) ||
(inst->codec == MSM_VIDC_HEVC &&
delivery_mode != V4L2_MPEG_VIDC_HEVC_ENCODE_DELIVERY_MODE_SLICE_BASED))
return count;
f = &inst->fmts[OUTPUT_PORT];
width = f->fmt.pix_mp.width;
height = f->fmt.pix_mp.height;
max_mbs_per_slice = inst->capabilities->cap[SLICE_MAX_MB].value;
if (inst->codec == MSM_VIDC_H264)
hfi_codec = HFI_CODEC_ENCODE_AVC;
else if (inst->codec == MSM_VIDC_HEVC)
hfi_codec = HFI_CODEC_ENCODE_HEVC;
HFI_IRIS3_ENC_MB_BASED_MULTI_SLICE_COUNT(total_num_slices, width, height,
hfi_codec, max_mbs_per_slice);
return (total_num_slices * count);
}
int msm_buffer_min_count_iris3(struct msm_vidc_inst *inst,
enum msm_vidc_buffer_type buffer_type)
{
@@ -688,6 +730,7 @@ int msm_buffer_min_count_iris3(struct msm_vidc_inst *inst,
case MSM_VIDC_BUF_OUTPUT:
case MSM_VIDC_BUF_OUTPUT_META:
count = msm_vidc_output_min_count(inst);
count = msm_buffer_delivery_mode_based_min_count_iris3(inst, count);
break;
case MSM_VIDC_BUF_BIN:
case MSM_VIDC_BUF_COMV: