[jpegd]: Support RGB 16-bit format output

Change-Id: I0f3152bd068498fccc95569bb2950ab78ade2bf6
Signed-off-by: Johnson Ding <johnson.ding@rock-chips.com>
This commit is contained in:
Johnson Ding
2021-07-19 18:06:05 +08:00
parent be76be4634
commit e81e72eca6
5 changed files with 296 additions and 121 deletions

View File

@@ -31,6 +31,209 @@
#include "jpegd_api.h" #include "jpegd_api.h"
#include "hal_jpegd_common.h" #include "hal_jpegd_common.h"
static PpRgbCfg pp_rgb_cfgs[PP_RGB_CFG_LENTH] = {
//ffmpeg: rgb565be, bin(rrrr,rggg, gggb,bbbb) mem MSB-->LSB(gggb,bbbb, rrrr,rggg)
{
.fmt = MPP_FMT_RGB565, .pp_out_fmt = PP_OUT_FORMAT_RGB565,
.out_endian = 1, .swap_16 = 0, .swap_32 = 1, .rgb_in_32 = 1,
.r_padd = 0, .g_padd = 5, .b_padd = 11,
.r_dither = 2, .g_dither = 3, .b_dither = 2,
.r_mask = 0xf800f800, .g_mask = 0x07e007e0, .b_mask = 0x001f001f
},
//ffmpeg: bgr565be, bin(bbbb,bggg, gggr,rrrr) mem MSB-->LSB(gggr,rrrr, bbbb,bggg)
{
.fmt = MPP_FMT_BGR565, .pp_out_fmt = PP_OUT_FORMAT_RGB565,
.out_endian = 1, .swap_16 = 0, .swap_32 = 1, .rgb_in_32 = 1,
.r_padd = 11, .g_padd = 5, .b_padd = 0,
.r_dither = 2, .g_dither = 3, .b_dither = 2,
.r_mask = 0x001f001f, .g_mask = 0x07e007e0, .b_mask = 0xf800f800
},
//ffmpeg: rgb555be, bin(0rrr,rrgg, gggb,bbbb) mem MSB-->LSB(gggb,bbbb, 0rrr,rrgg)
{
.fmt = MPP_FMT_RGB555, .pp_out_fmt = PP_OUT_FORMAT_RGB565,
.out_endian = 1, .swap_16 = 0, .swap_32 = 1, .rgb_in_32 = 1,
.r_padd = 1, .g_padd = 6, .b_padd = 11,
.r_dither = 2, .g_dither = 2, .b_dither = 2,
.r_mask = 0x7c007c00, .g_mask = 0x03e003e0, .b_mask = 0x001f001f
},
//ffmpeg: bgr555be, bin(0bbb,bbgg, gggr,rrrr) mem MSB-->LSB(gggr,rrrr, 0bbb,bbgg)
{
.fmt = MPP_FMT_BGR555, .pp_out_fmt = PP_OUT_FORMAT_RGB565,
.out_endian = 1, .swap_16 = 0, .swap_32 = 1, .rgb_in_32 = 1,
.r_padd = 11, .g_padd = 6, .b_padd = 1,
.r_dither = 2, .g_dither = 2, .b_dither = 2,
.r_mask = 0x001f001f, .g_mask = 0x03e003e0, .b_mask = 0x7c007c00
},
//ffmpeg: rgb444be, bin(0000,rrrr, gggg,bbbb) mem MSB-->LSB(gggg,bbbb, 0000,rrrr)
{
.fmt = MPP_FMT_RGB444, .pp_out_fmt = PP_OUT_FORMAT_RGB565,
.out_endian = 0, .swap_16 = 1, .swap_32 = 1, .rgb_in_32 = 1,
.r_padd = 12, .g_padd = 0, .b_padd = 4,
.r_dither = 1, .g_dither = 1, .b_dither = 1,
.r_mask = 0x000f000f, .g_mask = 0xf000f000, .b_mask = 0x0f000f00
},
//ffmpeg: bgr444be, bin(0000,bbbb, gggg,rrrr) mem MSB-->LSB(gggg,rrrr, 0000,bbbb)
{
.fmt = MPP_FMT_BGR444, .pp_out_fmt = PP_OUT_FORMAT_RGB565,
.out_endian = 0, .swap_16 = 1, .swap_32 = 1, .rgb_in_32 = 1,
.r_padd = 4, .g_padd = 0, .b_padd = 12, .r_mask = 0x0f000f00,
.r_dither = 1, .g_dither = 1, .b_dither = 1,
.g_mask = 0xf000f000, .b_mask = 0x000f000f
},
//ffmpeg: argb, bin(aaaa,aaaa, rrrr,rrrr, gggg,gggg, bbbb,bbbb)
{
.fmt = MPP_FMT_ARGB8888, .pp_out_fmt = PP_OUT_FORMAT_ARGB,
.out_endian = 0, .swap_16 = 0, .swap_32 = 1, .rgb_in_32 = 0,
.r_padd = 16, .g_padd = 8, .b_padd = 0,
.r_dither = 0, .g_dither = 0, .b_dither = 0,
.r_mask = 0x0000ff00 | 0xff,
.g_mask = 0x00ff0000 | 0xff,
.b_mask = 0xff000000 | 0xff
},
//ffmepg: rgba, bin(aaaa,aaaa, bbbb,bbbb, gggg,gggg, rrrr,rrrr)
{
.fmt = MPP_FMT_ABGR8888, .pp_out_fmt = PP_OUT_FORMAT_ARGB,
.out_endian = 0, .swap_16 = 0, .swap_32 = 1, .rgb_in_32 = 0,
.r_padd = 0, .g_padd = 8, .b_padd = 16,
.r_dither = 0, .g_dither = 0, .b_dither = 0,
.r_mask = 0xff000000 | 0xff,
.g_mask = 0x00ff0000 | 0xff,
.b_mask = 0x0000ff00 | 0xff
},
//ffmpeg: bgra, bin(bbbb,bbbb, gggg,gggg, rrrr,rrrr, aaaa,aaaa)
{
.fmt = MPP_FMT_BGRA8888, .pp_out_fmt = PP_OUT_FORMAT_ARGB,
.out_endian = 0, .swap_16 = 0, .swap_32 = 1, .rgb_in_32 = 0,
.r_padd = 8, .g_padd = 16, .b_padd = 24,
.r_dither = 0, .g_dither = 0, .b_dither = 0,
.r_mask = 0x00ff0000 | (0xff << 24),
.g_mask = 0x0000ff00 | (0xff << 24),
.b_mask = 0x000000ff | (0xff << 24)
},
//ffmpeg: rgba, bin(rrrr,rrrr, gggg,gggg, bbbb,bbbb, aaaa,aaaa)
{
.fmt = MPP_FMT_RGBA8888, .pp_out_fmt = PP_OUT_FORMAT_ARGB,
.out_endian = 0, .swap_16 = 0, .swap_32 = 1, .rgb_in_32 = 0,
.r_padd = 24, .g_padd = 16, .b_padd = 8,
.r_dither = 0, .g_dither = 0, .b_dither = 0,
.r_mask = 0x000000ff | (0xff << 24),
.g_mask = 0x0000ff00 | (0xff << 24),
.b_mask = 0x00ff0000 | (0xff << 24)
},
};
static PpRgbCfg pp_rgb_le_cfgs[PP_RGB_CFG_LENTH] = {
//ffmpeg: rgb565le, bin(gggb,bbbb, rrrr,rggg) mem MSB-->LSB(rrrr,rggg, gggb,bbbb)
{
.fmt = MPP_FMT_RGB565 | MPP_FRAME_FMT_LE_MASK, .pp_out_fmt = PP_OUT_FORMAT_RGB565,
.out_endian = 0, .swap_16 = 1, .swap_32 = 1, .rgb_in_32 = 1,
.r_padd = 0, .g_padd = 5, .b_padd = 11,
.r_dither = 2, .g_dither = 3, .b_dither = 2,
.r_mask = 0xf800f800, .g_mask = 0x07e007e0, .b_mask = 0x001f001f
},
//ffmpeg: bgr565le, bin(gggr,rrrr, bbbb,bggg) mem MSB-->LSB(bbbb,bggg, gggr,rrrr)
{
.fmt = MPP_FMT_BGR565 | MPP_FRAME_FMT_LE_MASK, .pp_out_fmt = PP_OUT_FORMAT_RGB565,
.out_endian = 0, .swap_16 = 1, .swap_32 = 1, .rgb_in_32 = 1,
.r_padd = 11, .g_padd = 5, .b_padd = 0,
.r_dither = 2, .g_dither = 3, .b_dither = 2,
.r_mask = 0x001f001f, .g_mask = 0x07e007e0, .b_mask = 0xf800f800
},
//ffmpeg: rgb555le, bin(gggb,bbbb, 0rrr,rrgg) mem MSB-->LSB(0rrr,rrgg, gggb,bbbb)
{
.fmt = MPP_FMT_RGB555 | MPP_FRAME_FMT_LE_MASK, .pp_out_fmt = PP_OUT_FORMAT_RGB565,
.out_endian = 0, .swap_16 = 1, .swap_32 = 1, .rgb_in_32 = 1,
.r_padd = 1, .g_padd = 6, .b_padd = 11,
.r_dither = 2, .g_dither = 2, .b_dither = 2,
.r_mask = 0x7c007c00, .g_mask = 0x03e003e0, .b_mask = 0x001f001f
},
//ffmpeg: bgr555le, bin(gggr,rrrr, 0bbb,bbgg) mem MSB-->LSB(0bbb,bbgg, gggr,rrrr)
{
.fmt = MPP_FMT_BGR555 | MPP_FRAME_FMT_LE_MASK, .pp_out_fmt = PP_OUT_FORMAT_RGB565,
.out_endian = 0, .swap_16 = 1, .swap_32 = 1, .rgb_in_32 = 1,
.r_padd = 11, .g_padd = 6, .b_padd = 1,
.r_dither = 2, .g_dither = 2, .b_dither = 2,
.r_mask = 0x001f001f, .g_mask = 0x03e003e0, .b_mask = 0x7c007c00
},
//ffmpeg: rgb444le, bin(gggg,bbbb, 0000,rrrr) mem MSB-->LSB(0000,rrrr, gggg,bbbb)
{
.fmt = MPP_FMT_RGB444 | MPP_FRAME_FMT_LE_MASK, .pp_out_fmt = PP_OUT_FORMAT_RGB565,
.out_endian = 1, .swap_16 = 0, .swap_32 = 1, .rgb_in_32 = 1,
.r_padd = 12, .g_padd = 0, .b_padd = 4,
.r_dither = 1, .g_dither = 1, .b_dither = 1,
.r_mask = 0x000f000f, .g_mask = 0xf000f000, .b_mask = 0x0f000f00
},
//ffmpeg: bgr444le, bin(gggg,rrrr, 0000,bbbb) mem MSB-->LSB(0000,bbbb, gggg,rrrr)
{
.fmt = MPP_FMT_BGR444 | MPP_FRAME_FMT_LE_MASK, .pp_out_fmt = PP_OUT_FORMAT_RGB565,
.out_endian = 1, .swap_16 = 0, .swap_32 = 1, .rgb_in_32 = 1,
.r_padd = 4, .g_padd = 0, .b_padd = 12, .r_mask = 0x0f000f00,
.r_dither = 1, .g_dither = 1, .b_dither = 1,
.g_mask = 0xf000f000, .b_mask = 0x000f000f
},
//in memory: [31:0] A:R:G:B 8:8:8:8 little endian
{
.fmt = MPP_FMT_ARGB8888 | MPP_FRAME_FMT_LE_MASK, .pp_out_fmt = PP_OUT_FORMAT_ARGB,
.out_endian = 0, .swap_16 = 0, .swap_32 = 1, .rgb_in_32 = 0,
.r_padd = 8, .g_padd = 16, .b_padd = 24,
.r_dither = 0, .g_dither = 0, .b_dither = 0,
.r_mask = 0x00ff0000 | (0xff << 24),
.g_mask = 0x0000ff00 | (0xff << 24),
.b_mask = 0x000000ff | (0xff << 24)
},
//in memory: [31:0] A:B:G:R 8:8:8:8 little endian
{
.fmt = MPP_FMT_ABGR8888 | MPP_FRAME_FMT_LE_MASK, .pp_out_fmt = PP_OUT_FORMAT_ARGB,
.out_endian = 0, .swap_16 = 0, .swap_32 = 1, .rgb_in_32 = 0,
.r_padd = 24, .g_padd = 16, .b_padd = 8,
.r_dither = 0, .g_dither = 0, .b_dither = 0,
.r_mask = 0x000000ff | (0xff << 24),
.g_mask = 0x0000ff00 | (0xff << 24),
.b_mask = 0x00ff0000 | (0xff << 24)
},
//in memory: [31:0] B:G:R:A 8:8:8:8 little endian
{
.fmt = MPP_FMT_BGRA8888 | MPP_FRAME_FMT_LE_MASK, .pp_out_fmt = PP_OUT_FORMAT_ARGB,
.out_endian = 0, .swap_16 = 0, .swap_32 = 1, .rgb_in_32 = 0,
.r_padd = 16, .g_padd = 8, .b_padd = 0,
.r_dither = 0, .g_dither = 0, .b_dither = 0,
.r_mask = 0x0000ff00 | 0xff,
.g_mask = 0x00ff0000 | 0xff,
.b_mask = 0xff000000 | 0xff
},
//in memory: [31:0] R:G:B:A 8:8:8:8 little endian
{
.fmt = MPP_FMT_RGBA8888 | MPP_FRAME_FMT_LE_MASK, .pp_out_fmt = PP_OUT_FORMAT_ARGB,
.out_endian = 0, .swap_16 = 0, .swap_32 = 1, .rgb_in_32 = 0,
.r_padd = 0, .g_padd = 8, .b_padd = 16,
.r_dither = 0, .g_dither = 0, .b_dither = 0,
.r_mask = 0xff000000 | 0xff,
.g_mask = 0x00ff0000 | 0xff,
.b_mask = 0x0000ff00 | 0xff
},
};
PpRgbCfg* get_pp_rgb_Cfg(MppFrameFormat fmt)
{
PpRgbCfg* cfg = NULL;
PpRgbCfg* cfg_array = NULL;
RK_U8 i = 0;
if (MPP_FRAME_FMT_IS_LE(fmt))
cfg_array = pp_rgb_le_cfgs;
else
cfg_array = pp_rgb_cfgs;
for (i = 0; i < PP_RGB_CFG_LENTH; i++) {
if (cfg_array[i].fmt == fmt) {
cfg = &cfg_array[i];
break;
}
}
return cfg;
}
RK_U32 jpegd_vdpu_tail_0xFF_patch(MppBuffer stream, RK_U32 length) RK_U32 jpegd_vdpu_tail_0xFF_patch(MppBuffer stream, RK_U32 length)
{ {
RK_U8 *p = mpp_buffer_get_ptr(stream); RK_U8 *p = mpp_buffer_get_ptr(stream);
@@ -240,6 +443,8 @@ MPP_RET jpegd_setup_output_fmt(JpegdHalCtx *ctx, JpegdSyntax *s, RK_S32 output)
MPP_RET ret = MPP_OK; MPP_RET ret = MPP_OK;
if (ctx->set_output_fmt_flag && (ctx->output_fmt != s->output_fmt)) { if (ctx->set_output_fmt_flag && (ctx->output_fmt != s->output_fmt)) {
MppFrameFormat fmt = MPP_FMT_BUTT;
/* Using pp to convert all format to yuv420sp */ /* Using pp to convert all format to yuv420sp */
switch (s->output_fmt) { switch (s->output_fmt) {
case MPP_FMT_YUV400: case MPP_FMT_YUV400:
@@ -268,7 +473,13 @@ MPP_RET jpegd_setup_output_fmt(JpegdHalCtx *ctx, JpegdSyntax *s, RK_S32 output)
pp_info->pp_enable = 1; pp_info->pp_enable = 1;
pp_info->pp_in_fmt = pp_in_fmt; pp_info->pp_in_fmt = pp_in_fmt;
switch (ctx->output_fmt) { fmt = ctx->output_fmt;
if (MPP_FRAME_FMT_IS_LE(fmt)) {
fmt &= MPP_FRAME_FMT_MASK;
}
switch (fmt) {
case MPP_FMT_RGB565 : case MPP_FMT_RGB565 :
case MPP_FMT_BGR565 : case MPP_FMT_BGR565 :
case MPP_FMT_RGB555 : case MPP_FMT_RGB555 :

View File

@@ -50,6 +50,26 @@ static const RK_U8 zzOrder[64] = {
58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63
}; };
#define PP_RGB_CFG_LENTH (10)
typedef struct PpRgbCfg_t {
MppFrameFormat fmt;
RK_U8 pp_out_fmt;
RK_U8 out_endian;
RK_U8 swap_16;
RK_U8 swap_32;
RK_U8 rgb_in_32;
RK_U8 r_padd;
RK_U8 g_padd;
RK_U8 b_padd;
RK_U8 r_dither;
RK_U8 g_dither;
RK_U8 b_dither;
RK_U32 r_mask;
RK_U32 g_mask;
RK_U32 b_mask;
} PpRgbCfg;
PpRgbCfg* get_pp_rgb_Cfg(MppFrameFormat fmt);
RK_U32 jpegd_vdpu_tail_0xFF_patch(MppBuffer stream, RK_U32 length); RK_U32 jpegd_vdpu_tail_0xFF_patch(MppBuffer stream, RK_U32 length);
void jpegd_write_qp_ac_dc_table(JpegdHalCtx *ctx, void jpegd_write_qp_ac_dc_table(JpegdHalCtx *ctx,

View File

@@ -470,8 +470,6 @@ static MPP_RET jpegd_setup_pp(JpegdHalCtx *ctx, JpegdSyntax *syntax)
post->reg69.sw_color_coeffa2 = tmp; post->reg69.sw_color_coeffa2 = tmp;
} }
post->reg61_dev_conf.sw_pp_out_endian = 0;
/* saturation */ /* saturation */
satur = 64 + SATURATION; satur = 64 + SATURATION;
@@ -504,72 +502,36 @@ static MPP_RET jpegd_setup_pp(JpegdHalCtx *ctx, JpegdSyntax *syntax)
post->reg71_color_coeff_1.sw_color_coeffe = (unsigned int) tmp; post->reg71_color_coeff_1.sw_color_coeffe = (unsigned int) tmp;
} }
switch (out_color) { if (out_color <= PP_OUT_FORMAT_ARGB) {
case PP_OUT_FORMAT_RGB565: PpRgbCfg *cfg = get_pp_rgb_Cfg(ctx->output_fmt);
post->reg82_r_mask = 0xF800F800; post->reg82_r_mask = cfg->r_mask;
post->reg83_g_mask = 0x07E007E0; post->reg83_g_mask = cfg->g_mask;
post->reg84_b_mask = 0x001F001F; post->reg84_b_mask = cfg->b_mask;
post->reg79_scaling_0.sw_rgb_r_padd = 0; post->reg79_scaling_0.sw_rgb_r_padd = cfg->r_padd;
post->reg79_scaling_0.sw_rgb_g_padd = 5; post->reg79_scaling_0.sw_rgb_g_padd = cfg->g_padd;
post->reg80_scaling_1.sw_rgb_b_padd = 11; post->reg80_scaling_1.sw_rgb_b_padd = cfg->b_padd;
if (dither) { if (dither) {
jpegd_dbg_hal("we do dither."); jpegd_dbg_hal("we do dither.");
post->reg91_pip_2.sw_dither_select_r = 2; post->reg91_pip_2.sw_dither_select_r = cfg->r_dither;
post->reg91_pip_2.sw_dither_select_g = 3; post->reg91_pip_2.sw_dither_select_r = cfg->g_dither;
post->reg91_pip_2.sw_dither_select_b = 2; post->reg91_pip_2.sw_dither_select_r = cfg->b_dither;
} else { } else {
jpegd_dbg_hal("we do not dither."); jpegd_dbg_hal("we do not dither.");
} }
post->reg79_scaling_0.sw_rgb_pix_in32 = 1;
post->reg85_ctrl.sw_pp_out_swap16_e = 1; post->reg79_scaling_0.sw_rgb_pix_in32 = cfg->rgb_in_32;
post->reg85_ctrl.sw_pp_out_swap16_e = cfg->swap_16;
post->reg61_dev_conf.sw_pp_out_swap32_e = cfg->swap_32;
post->reg61_dev_conf.sw_pp_out_endian = cfg->out_endian;
post->reg85_ctrl.sw_pp_out_format = 0; post->reg85_ctrl.sw_pp_out_format = 0;
break;
case PP_OUT_FORMAT_ARGB:
if (ctx->output_fmt == MPP_FMT_ARGB8888) {
post->reg82_r_mask = 0x0000FF00 | (0xff);
post->reg83_g_mask = 0x00FF0000 | (0xff);
post->reg84_b_mask = 0xFF000000 | (0xff);
post->reg79_scaling_0.sw_rgb_r_padd = 16; } else if (out_color == PP_OUT_FORMAT_YUV422INTERLAVE) {
post->reg79_scaling_0.sw_rgb_g_padd = 8;
post->reg80_scaling_1.sw_rgb_b_padd = 0;
} else if (ctx->output_fmt == MPP_FMT_ABGR8888) {
post->reg82_r_mask = 0xFF000000 | (0xff);
post->reg83_g_mask = 0x00FF0000 | (0xff);
post->reg84_b_mask = 0x0000FF00 | (0xff);
post->reg79_scaling_0.sw_rgb_r_padd = 0;
post->reg79_scaling_0.sw_rgb_g_padd = 8;
post->reg80_scaling_1.sw_rgb_b_padd = 16;
} else if (ctx->output_fmt == MPP_FMT_BGRA8888) {
post->reg82_r_mask = 0x00FF0000 | (0xff << 24);
post->reg83_g_mask = 0x0000FF00 | (0xff << 24);
post->reg84_b_mask = 0x000000FF | (0xff << 24);
post->reg79_scaling_0.sw_rgb_r_padd = 8;
post->reg79_scaling_0.sw_rgb_g_padd = 16;
post->reg80_scaling_1.sw_rgb_b_padd = 24;
} else if (ctx->output_fmt == MPP_FMT_RGBA8888) {
post->reg82_r_mask = 0x000000FF | (0xff << 24);
post->reg83_g_mask = 0x0000FF00 | (0xff << 24);
post->reg84_b_mask = 0x00FF0000 | (0xff << 24);
post->reg79_scaling_0.sw_rgb_r_padd = 24;
post->reg79_scaling_0.sw_rgb_g_padd = 16;
post->reg80_scaling_1.sw_rgb_b_padd = 8;
}
post->reg79_scaling_0.sw_rgb_pix_in32 = 0;
post->reg85_ctrl.sw_pp_out_format = 0;
break;
case PP_OUT_FORMAT_YUV422INTERLAVE:
post->reg85_ctrl.sw_pp_out_format = 3; post->reg85_ctrl.sw_pp_out_format = 3;
break; } else if (out_color == PP_OUT_FORMAT_YUV420INTERLAVE) {
case PP_OUT_FORMAT_YUV420INTERLAVE: {
post->reg85_ctrl.sw_pp_out_format = 5; post->reg85_ctrl.sw_pp_out_format = 5;
} } else {
break;
default:
mpp_err_f("unsuppotred format:%d", out_color); mpp_err_f("unsuppotred format:%d", out_color);
return -1; return -1;
} }

View File

@@ -521,74 +521,38 @@ static MPP_RET jpegd_setup_pp(JpegdHalCtx *ctx, JpegdSyntax *syntax)
reg->reg2.sw_color_coeffe = (unsigned int) tmp; reg->reg2.sw_color_coeffe = (unsigned int) tmp;
} }
switch (out_color) { if (out_color <= PP_OUT_FORMAT_ARGB) {
case PP_OUT_FORMAT_RGB565: PpRgbCfg *cfg = get_pp_rgb_Cfg(ctx->output_fmt);
reg->reg9_r_mask = 0xF800F800; reg->reg9_r_mask = cfg->r_mask;
reg->reg10_g_mask = 0x07E007E0; reg->reg10_g_mask = cfg->g_mask;
reg->reg11_b_mask = 0x001F001F; reg->reg11_b_mask = cfg->b_mask;
reg->reg16.sw_rgb_r_padd = 0; reg->reg16.sw_rgb_r_padd = cfg->r_padd;
reg->reg16.sw_rgb_g_padd = 5; reg->reg16.sw_rgb_g_padd = cfg->g_padd;
reg->reg16.sw_rgb_b_padd = 11; reg->reg16.sw_rgb_b_padd = cfg->b_padd;
if (dither) { if (dither) {
jpegd_dbg_hal("we do dither.\n"); jpegd_dbg_hal("we do dither.");
reg->reg36.sw_dither_select_r = 2; reg->reg36.sw_dither_select_r = cfg->r_dither;
reg->reg36.sw_dither_select_g = 3; reg->reg36.sw_dither_select_g = cfg->g_dither;
reg->reg36.sw_dither_select_b = 2; reg->reg36.sw_dither_select_b = cfg->b_dither;
} else { } else {
jpegd_dbg_hal("we do not dither.\n"); jpegd_dbg_hal("we do not dither.");
}
reg->reg37.sw_rgb_pix_in32 = 1;
reg->reg37.sw_pp_out_swap16_e = 1;
reg->reg38.sw_pp_out_format = 0;
break;
case PP_OUT_FORMAT_ARGB:
if (ctx->output_fmt == MPP_FMT_ARGB8888) {
reg->reg9_r_mask = 0x0000FF00 | (0xff);
reg->reg10_g_mask = 0x00FF0000 | (0xff);
reg->reg11_b_mask = 0xFF000000 | (0xff);
reg->reg16.sw_rgb_r_padd = 16;
reg->reg16.sw_rgb_g_padd = 8;
reg->reg16.sw_rgb_b_padd = 0;
} else if (ctx->output_fmt == MPP_FMT_ABGR8888) {
reg->reg9_r_mask = 0xFF000000 | (0xff);
reg->reg10_g_mask = 0x00FF0000 | (0xff);
reg->reg11_b_mask = 0x0000FF00 | (0xff);
reg->reg16.sw_rgb_r_padd = 0;
reg->reg16.sw_rgb_g_padd = 8;
reg->reg16.sw_rgb_b_padd = 16;
} else if (ctx->output_fmt == MPP_FMT_BGRA8888) {
reg->reg9_r_mask = 0x00FF0000 | (0xff << 24);
reg->reg10_g_mask = 0x0000FF00 | (0xff << 24);
reg->reg11_b_mask = 0x000000FF | (0xff << 24);
reg->reg16.sw_rgb_r_padd = 8;
reg->reg16.sw_rgb_g_padd = 16;
reg->reg16.sw_rgb_b_padd = 24;
} else if (ctx->output_fmt == MPP_FMT_RGBA8888) {
reg->reg9_r_mask = 0x000000FF | (0xff << 24);
reg->reg10_g_mask = 0x0000FF00 | (0xff << 24);
reg->reg11_b_mask = 0x00FF0000 | (0xff << 24);
reg->reg16.sw_rgb_r_padd = 24;
reg->reg16.sw_rgb_g_padd = 16;
reg->reg16.sw_rgb_b_padd = 8;
} }
reg->reg37.sw_rgb_pix_in32 = 0; reg->reg37.sw_rgb_pix_in32 = cfg->rgb_in_32;
reg->reg37.sw_pp_out_swap16_e = cfg->swap_16;
reg->reg37.sw_pp_out_swap32_e = cfg->swap_32;
reg->reg37.sw_pp_out_endian = cfg->out_endian;
reg->reg38.sw_pp_out_format = 0; reg->reg38.sw_pp_out_format = 0;
break;
case PP_OUT_FORMAT_YUV422INTERLAVE: } else if (out_color == PP_OUT_FORMAT_YUV422INTERLAVE) {
reg->reg38.sw_pp_out_format = 3; reg->reg38.sw_pp_out_format = 3;
break; } else if (out_color == PP_OUT_FORMAT_YUV420INTERLAVE) {
case PP_OUT_FORMAT_YUV420INTERLAVE: {
reg->reg38.sw_pp_out_format = 5; reg->reg38.sw_pp_out_format = 5;
} } else {
break;
default:
mpp_err_f("unsuppotred format:%d", out_color); mpp_err_f("unsuppotred format:%d", out_color);
return MPP_NOK; return -1;
} }
reg->reg38.sw_rotation_mode = 0; reg->reg38.sw_rotation_mode = 0;

View File

@@ -58,6 +58,9 @@ void dump_mpp_frame_to_file(MppFrame frame, FILE *fp)
base = (RK_U8 *)mpp_buffer_get_ptr(buffer); base = (RK_U8 *)mpp_buffer_get_ptr(buffer);
if (MPP_FRAME_FMT_IS_RGB(fmt) && MPP_FRAME_FMT_IS_LE(fmt)) {
fmt &= MPP_FRAME_FMT_MASK;
}
switch (fmt) { switch (fmt) {
case MPP_FMT_YUV422SP : { case MPP_FMT_YUV422SP : {
/* YUV422SP -> YUV422P for better display */ /* YUV422SP -> YUV422P for better display */
@@ -152,11 +155,26 @@ void dump_mpp_frame_to_file(MppFrame frame, FILE *fp)
RK_U8 *base_y = base; RK_U8 *base_y = base;
RK_U8 *tmp = mpp_malloc(RK_U8, width * height * 4); RK_U8 *tmp = mpp_malloc(RK_U8, width * height * 4);
for (i = 0; i < height; i++, base_y += h_stride * 4) for (i = 0; i < height; i++, base_y += h_stride)
fwrite(base_y, 1, width * 4, fp); fwrite(base_y, 1, width * 4, fp);
mpp_free(tmp); mpp_free(tmp);
} break; } break;
case MPP_FMT_RGB565:
case MPP_FMT_BGR565:
case MPP_FMT_RGB555:
case MPP_FMT_BGR555:
case MPP_FMT_RGB444:
case MPP_FMT_BGR444: {
RK_U32 i;
RK_U8 *base_y = base;
RK_U8 *tmp = mpp_malloc(RK_U8, width * height * 2);
for (i = 0; i < height; i++, base_y += h_stride)
fwrite(base_y, 1, width * 2, fp);
mpp_free(tmp);
} break;
default : { default : {
mpp_err("not supported format %d\n", fmt); mpp_err("not supported format %d\n", fmt);
} break; } break;