From d2459e4fac1c8909ec02d8e67bb6d0e733514a4d Mon Sep 17 00:00:00 2001 From: Johnson Ding Date: Wed, 12 Jun 2019 10:33:00 +0800 Subject: [PATCH] [jpegd]: Add YUV400 support Change-Id: I110f0f2a16977f985d32204704ca4c2effcd8b90 Signed-off-by: Johnson Ding --- inc/mpp_frame.h | 2 +- mpp/codec/dec/jpeg/jpegd_parser.c | 5 ++++- mpp/hal/vpu/jpegd/hal_jpegd_common.c | 2 +- utils/utils.c | 10 ++++++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/inc/mpp_frame.h b/inc/mpp_frame.h index 6c1b7f1d..b3bfff1e 100644 --- a/inc/mpp_frame.h +++ b/inc/mpp_frame.h @@ -165,7 +165,7 @@ typedef enum { MPP_FMT_YUV422SP_VU, /* YYYY... VUVUVU... (NV42) */ MPP_FMT_YUV422_YUYV, /* YUYVYUYV... (YUY2) */ MPP_FMT_YUV422_UYVY, /* UYVYUYVY... (UYVY) */ - MPP_FMT_YUV400SP, /* YYYY... */ + MPP_FMT_YUV400, /* YYYY... */ MPP_FMT_YUV440SP, /* YYYY... UVUV... */ MPP_FMT_YUV411SP, /* YYYY... UV... */ MPP_FMT_YUV444SP, /* YYYY... UVUVUVUV... */ diff --git a/mpp/codec/dec/jpeg/jpegd_parser.c b/mpp/codec/dec/jpeg/jpegd_parser.c index abe09975..9d99d8d0 100644 --- a/mpp/codec/dec/jpeg/jpegd_parser.c +++ b/mpp/codec/dec/jpeg/jpegd_parser.c @@ -144,7 +144,7 @@ static MPP_RET jpeg_judge_yuv_mode(JpegdCtx *ctx) } else if (s->nb_components == 1) { if ((s->h_count[0] == 1) || (s->v_count[0] == 1)) { s->yuv_mode = JPEGDEC_YUV400; - s->output_fmt = MPP_FMT_YUV400SP; + s->output_fmt = MPP_FMT_YUV400; /* check if fill needed */ if ((s->width & 0xf) && ((s->width & 0xf) <= 8)) { @@ -1145,6 +1145,9 @@ static MPP_RET jpegd_allocate_frame(JpegdCtx *ctx) case JPEGDEC_YUV444: { fmt = MPP_FMT_YUV444SP; } break; + case JPEGDEC_YUV400: { + fmt = MPP_FMT_YUV400; + } break; default : { fmt = MPP_FMT_YUV420SP; } break; diff --git a/mpp/hal/vpu/jpegd/hal_jpegd_common.c b/mpp/hal/vpu/jpegd/hal_jpegd_common.c index 9b683867..faea4b5a 100644 --- a/mpp/hal/vpu/jpegd/hal_jpegd_common.c +++ b/mpp/hal/vpu/jpegd/hal_jpegd_common.c @@ -247,7 +247,7 @@ void jpegd_setup_output_fmt(JpegdHalCtx *ctx, JpegdSyntax *s, RK_S32 output) if (ctx->set_output_fmt_flag && (ctx->output_fmt != s->output_fmt)) { /* Using pp to convert all format to yuv420sp */ switch (s->output_fmt) { - case MPP_FMT_YUV400SP: + case MPP_FMT_YUV400: pp_in_fmt = PP_IN_FORMAT_YUV400; break; case MPP_FMT_YUV420SP: diff --git a/utils/utils.c b/utils/utils.c index 67c1c0f5..a4c33054 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -132,6 +132,16 @@ void dump_mpp_frame_to_file(MppFrame frame, FILE *fp) fwrite(tmp, 1, width * height * 2, fp); mpp_free(tmp); } break; + case MPP_FMT_YUV400: { + RK_U32 i; + RK_U8 *base_y = base; + RK_U8 *tmp = mpp_malloc(RK_U8, h_stride * height); + + for (i = 0; i < height; i++, base_y += h_stride) + fwrite(base_y, 1, width, fp); + + mpp_free(tmp); + } break; default : { mpp_err("not supported format %d\n", fmt); } break;