[hal_jpegd]: Fix hal jpeg RGB output byte stride

NOTE: RGB format horizontal stride is byte stride. The pixel_stride in
MppFrame is the stride by pixel.

Change-Id: I09e87c5f7fb871ee2b285451ed2f0abfb1351f19
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
Herman Chen
2021-07-16 10:06:20 +08:00
parent 82aeaebe34
commit 0c43069763
2 changed files with 28 additions and 8 deletions

View File

@@ -233,6 +233,7 @@ void jpegd_setup_output_fmt(JpegdHalCtx *ctx, JpegdSyntax *s, RK_S32 output)
{
jpegd_dbg_func("enter\n");
RK_U32 pp_in_fmt = 0;
RK_U32 stride = 0;
PPInfo *pp_info = &(ctx->pp_info);
MppFrame frm = NULL;
@@ -266,15 +267,25 @@ void jpegd_setup_output_fmt(JpegdHalCtx *ctx, JpegdSyntax *s, RK_S32 output)
pp_info->pp_in_fmt = pp_in_fmt;
switch (ctx->output_fmt) {
case MPP_FMT_ARGB8888:
case MPP_FMT_ABGR8888:
case MPP_FMT_RGBA8888:
case MPP_FMT_BGRA8888:
case MPP_FMT_RGB565 :
case MPP_FMT_BGR565 :
case MPP_FMT_RGB555 :
case MPP_FMT_BGR555 :
case MPP_FMT_RGB444 :
case MPP_FMT_BGR444 : {
pp_info->pp_out_fmt = PP_OUT_FORMAT_RGB565;
stride = s->hor_stride * 2;
} break;
case MPP_FMT_ARGB8888 :
case MPP_FMT_ABGR8888 :
case MPP_FMT_RGBA8888 :
case MPP_FMT_BGRA8888 : {
pp_info->pp_out_fmt = PP_OUT_FORMAT_ARGB;
break;
default:
stride = s->hor_stride * 4;
} break;
default : {
pp_info->pp_out_fmt = PP_OUT_FORMAT_YUV420INTERLAVE;
break;
} break;
}
jpegd_dbg_hal("Post Process! pp_in_fmt:%d, pp_out_fmt:%d",
@@ -288,6 +299,10 @@ void jpegd_setup_output_fmt(JpegdHalCtx *ctx, JpegdSyntax *s, RK_S32 output)
mpp_buf_slot_get_prop(ctx->frame_slots, output,
SLOT_FRAME_PTR, &frm);
mpp_frame_set_fmt(frm, ctx->output_fmt);
mpp_frame_set_hor_stride_pixel(frm, s->hor_stride);
/* update RGBX format byte stride and pixel stride */
if (stride)
mpp_frame_set_hor_stride(frm, stride);
jpegd_dbg_func("exit\n");
return;
@@ -305,4 +320,4 @@ MPP_RET jpeg_image_check_size(RK_U32 hor_stride, RK_U32 ver_stride)
}
return ret;
}
}

View File

@@ -301,6 +301,7 @@ static MPP_RET setup_output_fmt(JpegdHalCtx *ctx, JpegdSyntax *syntax, RK_S32 ou
MPP_RET ret = MPP_OK;
JpegdSyntax *s = syntax;
JpegRegSet *regs = (JpegRegSet *)ctx->regs;
RK_U32 stride = syntax->hor_stride;
MppFrame frm = NULL;
mpp_buf_slot_get_prop(ctx->frame_slots, out_idx, SLOT_FRAME_PTR, &frm);
@@ -316,6 +317,8 @@ static MPP_RET setup_output_fmt(JpegdHalCtx *ctx, JpegdSyntax *syntax, RK_S32 ou
regs->reg2_sys.scaledown_mode = SCALEDOWN_DISABLE;
}
mpp_frame_set_hor_stride_pixel(frm, stride);
if (ctx->set_output_fmt_flag && (ctx->output_fmt != s->output_fmt)) { // PP enable
if (MPP_FRAME_FMT_IS_YUV(ctx->output_fmt) && s->output_fmt != MPP_FMT_YUV400) {
if (ctx->output_fmt == MPP_FMT_YUV420SP)
@@ -336,8 +339,10 @@ static MPP_RET setup_output_fmt(JpegdHalCtx *ctx, JpegdSyntax *syntax, RK_S32 ou
} else if (MPP_FRAME_FMT_IS_RGB(ctx->output_fmt)) {
if (ctx->output_fmt == MPP_FMT_RGB888) {
regs->reg2_sys.yuv_out_format = YUV_OUT_FMT_2_RGB888;
mpp_frame_set_hor_stride(frm, stride * 3);
} else if (ctx->output_fmt == MPP_FMT_BGR565) { //bgr565le
regs->reg2_sys.yuv_out_format = YUV_OUT_FMT_2_RGB565;
mpp_frame_set_hor_stride(frm, stride * 2);
} else {
mpp_err_f("unsupported output format %d\n", ctx->output_fmt);
ret = MPP_NOK;