[misc]: Add compatible for fbc header alignment

Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
Change-Id: I0ae4ec4b8603648a7186d0cccf63aa3ea3fb29b3
This commit is contained in:
Herman Chen
2022-12-23 16:38:54 +08:00
parent f115d415b4
commit 5469f9d08b
14 changed files with 57 additions and 33 deletions

View File

@@ -23,6 +23,7 @@
typedef enum MppCompatId_e {
MPP_COMPAT_INC_FBC_BUF_SIZE,
MPP_COMPAT_ENC_ASYNC_INPUT,
MPP_COMPAT_DEC_FBC_HDR_256_ODD,
MPP_COMPAT_BUTT,
} MppCompatId;

View File

@@ -473,6 +473,8 @@ static MPP_RET dpb_mark_malloc(H264dVideoCtx_t *p_Vid, H264_StorePic_t *dec_pic)
impl->ver_stride += 16;
impl->fbc_hdr_stride = MPP_ALIGN(impl->width, 64);
if (*compat_ext_fbc_hdr_256_odd)
impl->fbc_hdr_stride = MPP_ALIGN(impl->width, 256) | 256;
}
/* After cropped */

View File

@@ -100,6 +100,8 @@ static HEVCFrame *alloc_frame(HEVCContext *s)
mpp_frame_set_fmt(frame->frame, s->h265dctx->pix_fmt);
if (MPP_FRAME_FMT_IS_FBC(s->h265dctx->pix_fmt)) {
RK_U32 fbc_hdr_stride = MPP_ALIGN(s->h265dctx->width, 64);
mpp_slots_set_prop(s->slots, SLOTS_HOR_ALIGN, hor_align_64);
mpp_frame_set_offset_x(frame->frame, 0);
mpp_frame_set_offset_y(frame->frame, 4);
@@ -107,7 +109,10 @@ static HEVCFrame *alloc_frame(HEVCContext *s)
if (*compat_ext_fbc_buf_size)
mpp_frame_set_ver_stride(frame->frame, s->h265dctx->coded_height + 16);
mpp_frame_set_fbc_hdr_stride(frame->frame, MPP_ALIGN(s->h265dctx->width, 64));
if (*compat_ext_fbc_hdr_256_odd)
fbc_hdr_stride = MPP_ALIGN(s->h265dctx->width, 256) | 256;
mpp_frame_set_fbc_hdr_stride(frame->frame, fbc_hdr_stride);
} else {
if ((s->h265dctx->cfg->base.enable_vproc & MPP_VPROC_MODE_DETECTION) &&
s->h265dctx->width <= 1920 && s->h265dctx->height <= 1088)

View File

@@ -24,6 +24,7 @@
#include "mpp_common.h"
#include "mpp_bitread.h"
#include "mpp_packet_impl.h"
#include "mpp_compat_impl.h"
#include "vp9data.h"
#include "vp9d_codec.h"
@@ -402,9 +403,15 @@ static RK_S32 vp9_alloc_frame(Vp9CodecContext *ctx, VP9Frame *frame)
mpp_frame_set_poc(frame->f, s->cur_poc);
if (MPP_FRAME_FMT_IS_FBC(s->cfg->base.out_fmt)) {
RK_U32 fbc_hdr_stride = MPP_ALIGN(ctx->width, 64);
mpp_slots_set_prop(s->slots, SLOTS_HOR_ALIGN, hor_align_64);
mpp_frame_set_fmt(frame->f, ctx->pix_fmt | ((s->cfg->base.out_fmt & (MPP_FRAME_FBC_MASK))));
mpp_frame_set_fbc_hdr_stride(frame->f, MPP_ALIGN(ctx->width, 64));
if (*compat_ext_fbc_hdr_256_odd)
fbc_hdr_stride = MPP_ALIGN(ctx->width, 256) | 256;
mpp_frame_set_fbc_hdr_stride(frame->f, fbc_hdr_stride);
} else
mpp_frame_set_fmt(frame->f, ctx->pix_fmt);

View File

@@ -343,12 +343,12 @@ static MPP_RET fill_registers(Avs2dHalCtx_t *p_hal, Vdpu34xAvs2dRegSet *p_regs,
AVS2D_HAL_TRACE("is_fbc %d y_virstride %d, hor_virstride %d, ver_virstride %d\n", is_fbc, y_virstride, hor_virstride, ver_virstride);
if (is_fbc) {
RK_U32 pixel_width = MPP_ALIGN(mpp_frame_get_width(mframe), 64);
RK_U32 fbd_offset = MPP_ALIGN(pixel_width * (ver_virstride + 16) / 16, SZ_4K);
RK_U32 fbc_hdr_stride = mpp_frame_get_fbc_hdr_stride(mframe);
RK_U32 fbd_offset = MPP_ALIGN(fbc_hdr_stride * (ver_virstride + 16) / 16, SZ_4K);
common->reg012.fbc_e = 1;
common->reg018.y_hor_virstride = pixel_width / 16;
common->reg019.uv_hor_virstride = pixel_width / 16;
common->reg018.y_hor_virstride = fbc_hdr_stride / 16;
common->reg019.uv_hor_virstride = fbc_hdr_stride / 16;
common->reg020_fbc_payload_off.payload_st_offset = fbd_offset >> 4;
} else {
common->reg012.fbc_e = 0;

View File

@@ -346,12 +346,12 @@ static MPP_RET fill_registers(Avs2dHalCtx_t *p_hal, Vdpu382Avs2dRegSet *p_regs,
AVS2D_HAL_TRACE("is_fbc %d y_virstride %d, hor_virstride %d, ver_virstride %d\n", is_fbc, y_virstride, hor_virstride, ver_virstride);
if (is_fbc) {
RK_U32 pixel_width = MPP_ALIGN(mpp_frame_get_width(mframe), 64);
RK_U32 fbd_offset = MPP_ALIGN(pixel_width * (ver_virstride + 16) / 16, SZ_4K);
RK_U32 fbc_hdr_stride = mpp_frame_get_fbc_hdr_stride(mframe);
RK_U32 fbd_offset = MPP_ALIGN(fbc_hdr_stride * (ver_virstride + 16) / 16, SZ_4K);
common->reg012.fbc_e = 1;
common->reg018.y_hor_virstride = pixel_width / 16;
common->reg019.uv_hor_virstride = pixel_width / 16;
common->reg018.y_hor_virstride = fbc_hdr_stride / 16;
common->reg019.uv_hor_virstride = fbc_hdr_stride / 16;
common->reg020_fbc_payload_off.payload_st_offset = fbd_offset >> 4;
} else {
common->reg012.fbc_e = 0;

View File

@@ -552,12 +552,12 @@ static MPP_RET set_registers(H264dHalCtx_t *p_hal, Vdpu34xH264dRegSet *regs, Hal
y_virstride = hor_virstride * ver_virstride;
if (MPP_FRAME_FMT_IS_FBC(mpp_frame_get_fmt(mframe))) {
RK_U32 pixel_width = MPP_ALIGN(mpp_frame_get_width(mframe), 64);
RK_U32 fbd_offset = MPP_ALIGN(pixel_width * (ver_virstride + 16) / 16, SZ_4K);
RK_U32 fbc_hdr_stride = mpp_frame_get_fbc_hdr_stride(mframe);
RK_U32 fbd_offset = MPP_ALIGN(fbc_hdr_stride * (ver_virstride + 16) / 16, SZ_4K);
common->reg012.fbc_e = 1;
common->reg018.y_hor_virstride = pixel_width / 16;
common->reg019.uv_hor_virstride = pixel_width / 16;
common->reg018.y_hor_virstride = fbc_hdr_stride / 16;
common->reg019.uv_hor_virstride = fbc_hdr_stride / 16;
common->reg020_fbc_payload_off.payload_st_offset = fbd_offset >> 4;
} else {
common->reg012.fbc_e = 0;

View File

@@ -554,12 +554,12 @@ static MPP_RET set_registers(H264dHalCtx_t *p_hal, Vdpu382H264dRegSet *regs, Hal
y_virstride = hor_virstride * ver_virstride;
if (MPP_FRAME_FMT_IS_FBC(mpp_frame_get_fmt(mframe))) {
RK_U32 pixel_width = MPP_ALIGN(mpp_frame_get_width(mframe), 64);
RK_U32 fbd_offset = MPP_ALIGN(pixel_width * (ver_virstride + 16) / 16, SZ_4K);
RK_U32 fbc_hdr_stride = mpp_frame_get_fbc_hdr_stride(mframe);
RK_U32 fbd_offset = MPP_ALIGN(fbc_hdr_stride * (ver_virstride + 16) / 16, SZ_4K);
common->reg012.fbc_e = 1;
common->reg018.y_hor_virstride = pixel_width / 16;
common->reg019.uv_hor_virstride = pixel_width / 16;
common->reg018.y_hor_virstride = fbc_hdr_stride / 16;
common->reg019.uv_hor_virstride = fbc_hdr_stride / 16;
common->reg020_fbc_payload_off.payload_st_offset = fbd_offset >> 4;
} else {
common->reg012.fbc_e = 0;

View File

@@ -954,13 +954,12 @@ static MPP_RET hal_h265d_vdpu34x_gen_regs(void *hal, HalTaskInfo *syn)
hw_regs->h265d_param.reg64.h26x_stream_mode = 0;
if (MPP_FRAME_FMT_IS_FBC(mpp_frame_get_fmt(mframe))) {
RK_U32 pixel_width = MPP_ALIGN(mpp_frame_get_width(mframe), 64);
RK_U32 fbd_offset = MPP_ALIGN(pixel_width * (MPP_ALIGN(ver_virstride, 64) + 16) / 16,
SZ_4K);
RK_U32 fbc_hdr_stride = mpp_frame_get_fbc_hdr_stride(mframe);
RK_U32 fbd_offset = MPP_ALIGN(fbc_hdr_stride * (ver_virstride + 64) / 16, SZ_4K);
hw_regs->common.reg012.fbc_e = 1;
hw_regs->common.reg018.y_hor_virstride = pixel_width >> 4;
hw_regs->common.reg019.uv_hor_virstride = pixel_width >> 4;
hw_regs->common.reg018.y_hor_virstride = fbc_hdr_stride >> 4;
hw_regs->common.reg019.uv_hor_virstride = fbc_hdr_stride >> 4;
hw_regs->common.reg020_fbc_payload_off.payload_st_offset = fbd_offset >> 4;
} else {
hw_regs->common.reg012.fbc_e = 0;

View File

@@ -727,13 +727,12 @@ static MPP_RET hal_h265d_vdpu382_gen_regs(void *hal, HalTaskInfo *syn)
hw_regs->h265d_param.reg64.h26x_stream_mode = 0;
if (MPP_FRAME_FMT_IS_FBC(mpp_frame_get_fmt(mframe))) {
RK_U32 pixel_width = MPP_ALIGN(mpp_frame_get_width(mframe), 64);
RK_U32 fbd_offset = MPP_ALIGN(pixel_width * (MPP_ALIGN(ver_virstride, 64) + 16) / 16,
SZ_4K);
RK_U32 fbc_hdr_stride = mpp_frame_get_fbc_hdr_stride(mframe);
RK_U32 fbd_offset = MPP_ALIGN(fbc_hdr_stride * (ver_virstride + 64) / 16, SZ_4K);
hw_regs->common.reg012.fbc_e = 1;
hw_regs->common.reg018.y_hor_virstride = pixel_width >> 4;
hw_regs->common.reg019.uv_hor_virstride = pixel_width >> 4;
hw_regs->common.reg018.y_hor_virstride = fbc_hdr_stride >> 4;
hw_regs->common.reg019.uv_hor_virstride = fbc_hdr_stride >> 4;
hw_regs->common.reg020_fbc_payload_off.payload_st_offset = fbd_offset >> 4;
} else {
hw_regs->common.reg012.fbc_e = 0;

View File

@@ -598,7 +598,8 @@ static MPP_RET hal_vp9d_vdpu34x_gen_regs(void *hal, HalTaskInfo *task)
if (fbc_en) {
RK_U32 w = MPP_ALIGN(mpp_frame_get_width(mframe), 64);
RK_U32 h = MPP_ALIGN(mpp_frame_get_height(mframe), 64);
RK_U32 fbd_offset = MPP_ALIGN(w * (h + 16) / 16, SZ_4K);
RK_U32 fbd_offset = MPP_ALIGN(mpp_frame_get_fbc_hdr_stride(mframe) *
(h + 16) / 16, SZ_4K);
vp9_hw_regs->common.reg012.fbc_e = 1;
vp9_hw_regs->common.reg018.y_hor_virstride = w >> 4;

View File

@@ -596,13 +596,13 @@ static MPP_RET hal_vp9d_vdpu382_gen_regs(void *hal, HalTaskInfo *task)
fbc_en = MPP_FRAME_FMT_IS_FBC(mpp_frame_get_fmt(mframe));
if (fbc_en) {
RK_U32 w = MPP_ALIGN(mpp_frame_get_width(mframe), 64);
RK_U32 fbc_hdr_stride = mpp_frame_get_fbc_hdr_stride(mframe);
RK_U32 h = MPP_ALIGN(mpp_frame_get_height(mframe), 64);
RK_U32 fbd_offset = MPP_ALIGN(w * (h + 16) / 16, SZ_4K);
RK_U32 fbd_offset = MPP_ALIGN(fbc_hdr_stride * (h + 16) / 16, SZ_4K);
vp9_hw_regs->common.reg012.fbc_e = 1;
vp9_hw_regs->common.reg018.y_hor_virstride = w >> 4;
vp9_hw_regs->common.reg019.uv_hor_virstride = w >> 4;
vp9_hw_regs->common.reg018.y_hor_virstride = fbc_hdr_stride >> 4;
vp9_hw_regs->common.reg019.uv_hor_virstride = fbc_hdr_stride >> 4;
vp9_hw_regs->common.reg020_fbc_payload_off.payload_st_offset = fbd_offset >> 4;
} else {
sw_y_hor_virstride = (vp9_hor_align((pic_param->width * bit_depth) >> 3) >> 4);

View File

@@ -21,5 +21,6 @@
extern RK_S32 *compat_ext_fbc_buf_size;
extern RK_S32 *compat_ext_async_input;
extern RK_S32 *compat_ext_fbc_hdr_256_odd;
#endif /*__MPP_COMPAT_IMPL_H__*/

View File

@@ -48,10 +48,19 @@ static MppCompat compats[] = {
"support encoder async input mode",
NULL,
},
{
MPP_COMPAT_DEC_FBC_HDR_256_ODD,
MPP_COMPAT_BOOL,
0,
0,
"set decoder fbc header stride to 256 odd align",
NULL,
},
};
RK_S32 *compat_ext_fbc_buf_size = &compats[MPP_COMPAT_INC_FBC_BUF_SIZE].value_usr;
RK_S32 *compat_ext_async_input = &compats[MPP_COMPAT_ENC_ASYNC_INPUT].value_usr;
RK_S32 *compat_ext_fbc_hdr_256_odd = &compats[MPP_COMPAT_DEC_FBC_HDR_256_ODD].value_usr;
MppCompat *mpp_compat_query(void)
{