mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-28 19:31:45 +08:00
[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:
@@ -233,6 +233,7 @@ void jpegd_setup_output_fmt(JpegdHalCtx *ctx, JpegdSyntax *s, RK_S32 output)
|
|||||||
{
|
{
|
||||||
jpegd_dbg_func("enter\n");
|
jpegd_dbg_func("enter\n");
|
||||||
RK_U32 pp_in_fmt = 0;
|
RK_U32 pp_in_fmt = 0;
|
||||||
|
RK_U32 stride = 0;
|
||||||
PPInfo *pp_info = &(ctx->pp_info);
|
PPInfo *pp_info = &(ctx->pp_info);
|
||||||
MppFrame frm = NULL;
|
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;
|
pp_info->pp_in_fmt = pp_in_fmt;
|
||||||
|
|
||||||
switch (ctx->output_fmt) {
|
switch (ctx->output_fmt) {
|
||||||
|
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_ARGB8888 :
|
||||||
case MPP_FMT_ABGR8888 :
|
case MPP_FMT_ABGR8888 :
|
||||||
case MPP_FMT_RGBA8888 :
|
case MPP_FMT_RGBA8888 :
|
||||||
case MPP_FMT_BGRA8888:
|
case MPP_FMT_BGRA8888 : {
|
||||||
pp_info->pp_out_fmt = PP_OUT_FORMAT_ARGB;
|
pp_info->pp_out_fmt = PP_OUT_FORMAT_ARGB;
|
||||||
break;
|
stride = s->hor_stride * 4;
|
||||||
default:
|
} break;
|
||||||
|
default : {
|
||||||
pp_info->pp_out_fmt = PP_OUT_FORMAT_YUV420INTERLAVE;
|
pp_info->pp_out_fmt = PP_OUT_FORMAT_YUV420INTERLAVE;
|
||||||
break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
jpegd_dbg_hal("Post Process! pp_in_fmt:%d, pp_out_fmt:%d",
|
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,
|
mpp_buf_slot_get_prop(ctx->frame_slots, output,
|
||||||
SLOT_FRAME_PTR, &frm);
|
SLOT_FRAME_PTR, &frm);
|
||||||
mpp_frame_set_fmt(frm, ctx->output_fmt);
|
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");
|
jpegd_dbg_func("exit\n");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -301,6 +301,7 @@ static MPP_RET setup_output_fmt(JpegdHalCtx *ctx, JpegdSyntax *syntax, RK_S32 ou
|
|||||||
MPP_RET ret = MPP_OK;
|
MPP_RET ret = MPP_OK;
|
||||||
JpegdSyntax *s = syntax;
|
JpegdSyntax *s = syntax;
|
||||||
JpegRegSet *regs = (JpegRegSet *)ctx->regs;
|
JpegRegSet *regs = (JpegRegSet *)ctx->regs;
|
||||||
|
RK_U32 stride = syntax->hor_stride;
|
||||||
MppFrame frm = NULL;
|
MppFrame frm = NULL;
|
||||||
|
|
||||||
mpp_buf_slot_get_prop(ctx->frame_slots, out_idx, SLOT_FRAME_PTR, &frm);
|
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;
|
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 (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 (MPP_FRAME_FMT_IS_YUV(ctx->output_fmt) && s->output_fmt != MPP_FMT_YUV400) {
|
||||||
if (ctx->output_fmt == MPP_FMT_YUV420SP)
|
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)) {
|
} else if (MPP_FRAME_FMT_IS_RGB(ctx->output_fmt)) {
|
||||||
if (ctx->output_fmt == MPP_FMT_RGB888) {
|
if (ctx->output_fmt == MPP_FMT_RGB888) {
|
||||||
regs->reg2_sys.yuv_out_format = YUV_OUT_FMT_2_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
|
} else if (ctx->output_fmt == MPP_FMT_BGR565) { //bgr565le
|
||||||
regs->reg2_sys.yuv_out_format = YUV_OUT_FMT_2_RGB565;
|
regs->reg2_sys.yuv_out_format = YUV_OUT_FMT_2_RGB565;
|
||||||
|
mpp_frame_set_hor_stride(frm, stride * 2);
|
||||||
} else {
|
} else {
|
||||||
mpp_err_f("unsupported output format %d\n", ctx->output_fmt);
|
mpp_err_f("unsupported output format %d\n", ctx->output_fmt);
|
||||||
ret = MPP_NOK;
|
ret = MPP_NOK;
|
||||||
|
|||||||
Reference in New Issue
Block a user