mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-07 10:00:55 +08:00
[h264d] add yuv422 format support.
git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@993 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -251,6 +251,7 @@ static void generate_info_set(MppBufSlotsImpl *impl, MppFrame frame, RK_U32 forc
|
|||||||
|
|
||||||
mpp_frame_set_width(impl->info_set, width);
|
mpp_frame_set_width(impl->info_set, width);
|
||||||
mpp_frame_set_height(impl->info_set, height);
|
mpp_frame_set_height(impl->info_set, height);
|
||||||
|
mpp_frame_set_fmt(impl->info_set, mpp_frame_get_fmt(frame));
|
||||||
mpp_frame_set_hor_stride(impl->info_set, hal_hor_stride);
|
mpp_frame_set_hor_stride(impl->info_set, hal_hor_stride);
|
||||||
mpp_frame_set_ver_stride(impl->info_set, hal_ver_stride);
|
mpp_frame_set_ver_stride(impl->info_set, hal_ver_stride);
|
||||||
mpp_frame_set_buf_size(impl->info_set, size);
|
mpp_frame_set_buf_size(impl->info_set, size);
|
||||||
@@ -806,7 +807,7 @@ MPP_RET mpp_buf_slot_set_prop(MppBufSlots slots, RK_S32 index, SlotPropType type
|
|||||||
* 1. buffer size change
|
* 1. buffer size change
|
||||||
* this case need to reset buffer group and commit buffer with new size
|
* this case need to reset buffer group and commit buffer with new size
|
||||||
* 2. display info change
|
* 2. display info change
|
||||||
* if only width/height is change and buffer do not need to be reset
|
* if only width/height/fmt is change and buffer do not need to be reset
|
||||||
* only display info change is need
|
* only display info change is need
|
||||||
*/
|
*/
|
||||||
generate_info_set(impl, frame, 0);
|
generate_info_set(impl, frame, 0);
|
||||||
@@ -815,10 +816,10 @@ MPP_RET mpp_buf_slot_set_prop(MppBufSlots slots, RK_S32 index, SlotPropType type
|
|||||||
#ifdef RKPLATFORM
|
#ifdef RKPLATFORM
|
||||||
MppFrameImpl *old = (MppFrameImpl *)impl->info;
|
MppFrameImpl *old = (MppFrameImpl *)impl->info;
|
||||||
mpp_log("info change found\n");
|
mpp_log("info change found\n");
|
||||||
mpp_log("old width %4d height %4d stride hor %4d ver %4d\n",
|
mpp_log("old width %4d height %4d stride hor %4d ver %4d fmt %4d\n",
|
||||||
old->width, old->height, old->hor_stride, old->ver_stride);
|
old->width, old->height, old->hor_stride, old->ver_stride, old->fmt);
|
||||||
mpp_log("new width %4d height %4d stride hor %4d ver %4d\n",
|
mpp_log("new width %4d height %4d stride hor %4d ver %4d fmt %4d\n",
|
||||||
dst->width, dst->height, dst->hor_stride, dst->ver_stride);
|
dst->width, dst->height, dst->hor_stride, dst->ver_stride, dst->fmt);
|
||||||
#endif
|
#endif
|
||||||
// info change found here
|
// info change found here
|
||||||
}
|
}
|
||||||
|
@@ -118,6 +118,7 @@ MPP_RET mpp_frame_info_cmp(MppFrame frame0, MppFrame frame1)
|
|||||||
(f0->height == f1->height) &&
|
(f0->height == f1->height) &&
|
||||||
(f0->hor_stride == f1->hor_stride) &&
|
(f0->hor_stride == f1->hor_stride) &&
|
||||||
(f0->ver_stride == f1->ver_stride) &&
|
(f0->ver_stride == f1->ver_stride) &&
|
||||||
|
(f0->fmt == f1->fmt) &&
|
||||||
(f0->buf_size == f1->buf_size) &&
|
(f0->buf_size == f1->buf_size) &&
|
||||||
(f0->color_range == f1->color_range) &&
|
(f0->color_range == f1->color_range) &&
|
||||||
(f0->color_primaries == f1->color_primaries) &&
|
(f0->color_primaries == f1->color_primaries) &&
|
||||||
|
@@ -377,6 +377,11 @@ __FAILED:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static RK_U32 rkv_len_align_422(RK_U32 val)
|
||||||
|
{
|
||||||
|
return ((5 * MPP_ALIGN(val, 16)) / 2);
|
||||||
|
}
|
||||||
|
|
||||||
static MPP_RET dpb_mark_malloc(H264dVideoCtx_t *p_Vid, H264_StorePic_t *dec_pic)
|
static MPP_RET dpb_mark_malloc(H264dVideoCtx_t *p_Vid, H264_StorePic_t *dec_pic)
|
||||||
{
|
{
|
||||||
RK_U8 idx = 0;
|
RK_U8 idx = 0;
|
||||||
@@ -411,8 +416,10 @@ static MPP_RET dpb_mark_malloc(H264dVideoCtx_t *p_Vid, H264_StorePic_t *dec_pic
|
|||||||
mpp_frame_set_fmt(mframe, MPP_FMT_YUV420SP_10BIT);
|
mpp_frame_set_fmt(mframe, MPP_FMT_YUV420SP_10BIT);
|
||||||
} else if ((YUV422 == p_Vid->yuv_format) && (8 == p_Vid->bit_depth_luma)) {
|
} else if ((YUV422 == p_Vid->yuv_format) && (8 == p_Vid->bit_depth_luma)) {
|
||||||
mpp_frame_set_fmt(mframe, MPP_FMT_YUV422SP);
|
mpp_frame_set_fmt(mframe, MPP_FMT_YUV422SP);
|
||||||
|
mpp_slots_set_prop(p_Dec->frame_slots, SLOTS_LEN_ALIGN, rkv_len_align_422);
|
||||||
} else if ((YUV422 == p_Vid->yuv_format) && (10 == p_Vid->bit_depth_luma)) {
|
} else if ((YUV422 == p_Vid->yuv_format) && (10 == p_Vid->bit_depth_luma)) {
|
||||||
mpp_frame_set_fmt(mframe, MPP_FMT_YUV422SP_10BIT);
|
mpp_frame_set_fmt(mframe, MPP_FMT_YUV422SP_10BIT);
|
||||||
|
mpp_slots_set_prop(p_Dec->frame_slots, SLOTS_LEN_ALIGN, rkv_len_align_422);
|
||||||
}
|
}
|
||||||
hor_stride = ((p_Vid->width * p_Vid->bit_depth_luma + 127) & (~127)) / 8;
|
hor_stride = ((p_Vid->width * p_Vid->bit_depth_luma + 127) & (~127)) / 8;
|
||||||
ver_stride = p_Vid->height;
|
ver_stride = p_Vid->height;
|
||||||
|
@@ -593,7 +593,6 @@ MPP_RET parse_prepare(H264dInputCtx_t *p_Inp, H264dCurCtx_t *p_Cur)
|
|||||||
p_strm->nalu_len -= START_PREFIX_3BYTE;
|
p_strm->nalu_len -= START_PREFIX_3BYTE;
|
||||||
while (p_strm->nalu_buf[p_strm->nalu_len - 1] == 0x00) {
|
while (p_strm->nalu_buf[p_strm->nalu_len - 1] == 0x00) {
|
||||||
p_strm->nalu_len--;
|
p_strm->nalu_len--;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
p_Dec->nalu_ret = EndOfNalu;
|
p_Dec->nalu_ret = EndOfNalu;
|
||||||
FUN_CHECK(ret = store_cur_nalu(p_Cur, &p_Dec->p_Cur->strm, p_Dec->dxva_ctx));
|
FUN_CHECK(ret = store_cur_nalu(p_Cur, &p_Dec->p_Cur->strm, p_Dec->dxva_ctx));
|
||||||
|
@@ -179,16 +179,12 @@ static MPP_RET parser_sps(BitReadCtx_t *p_bitctx, H264_SPS_t *cur_sps, H264_DecC
|
|||||||
|| cur_sps->profile_idc == 86 || cur_sps->profile_idc == 118
|
|| cur_sps->profile_idc == 86 || cur_sps->profile_idc == 118
|
||||||
|| cur_sps->profile_idc == 128 || cur_sps->profile_idc == 138) {
|
|| cur_sps->profile_idc == 128 || cur_sps->profile_idc == 138) {
|
||||||
READ_UE(p_bitctx, &cur_sps->chroma_format_idc, "chroma_format_idc");
|
READ_UE(p_bitctx, &cur_sps->chroma_format_idc, "chroma_format_idc");
|
||||||
ASSERT(cur_sps->chroma_format_idc < 4);
|
mpp_log_f("chroma_format_idc=%d \n", cur_sps->chroma_format_idc);
|
||||||
//if (cur_sps->chroma_format_idc >= 3) {
|
if (cur_sps->chroma_format_idc > 2) {
|
||||||
// H264D_ERR("ERROR: Not support chroma_format_idc=%d.", cur_sps->chroma_format_idc);
|
H264D_ERR("ERROR: Not support chroma_format_idc=%d.", cur_sps->chroma_format_idc);
|
||||||
// p_Dec->err_ctx.err_flag |= VPU_FRAME_ERR_UNSUPPORT;
|
p_Dec->errctx.un_spt_flag = VPU_FRAME_ERR_UNSUPPORT;
|
||||||
// goto __FAILED;
|
goto __FAILED;
|
||||||
//}
|
}
|
||||||
//if (cur_sps->chroma_format_idc == 3) {
|
|
||||||
// READ_ONEBIT(p_bitctx, &cur_sps->separate_colour_plane_flag, "separate_colour_plane_flag");
|
|
||||||
// LogError(p_bitctx->ctx, "Not support YUV444 format current.");
|
|
||||||
//}
|
|
||||||
READ_UE(p_bitctx, &cur_sps->bit_depth_luma_minus8, "bit_depth_luma_minus8");
|
READ_UE(p_bitctx, &cur_sps->bit_depth_luma_minus8, "bit_depth_luma_minus8");
|
||||||
ASSERT(cur_sps->bit_depth_luma_minus8 < 7);
|
ASSERT(cur_sps->bit_depth_luma_minus8 < 7);
|
||||||
READ_UE(p_bitctx, &cur_sps->bit_depth_chroma_minus8, "bit_depth_chroma_minus8");
|
READ_UE(p_bitctx, &cur_sps->bit_depth_chroma_minus8, "bit_depth_chroma_minus8");
|
||||||
|
@@ -718,6 +718,7 @@ void *mpp_dec_hal_thread(void *data)
|
|||||||
mpp_frame_set_info_change(info_frame, 1);
|
mpp_frame_set_info_change(info_frame, 1);
|
||||||
mpp_frame_set_errinfo(info_frame, 0);
|
mpp_frame_set_errinfo(info_frame, 0);
|
||||||
mpp_put_frame(mpp, info_frame);
|
mpp_put_frame(mpp, info_frame);
|
||||||
|
|
||||||
hal_task_hnd_set_status(task, TASK_IDLE);
|
hal_task_hnd_set_status(task, TASK_IDLE);
|
||||||
task = NULL;
|
task = NULL;
|
||||||
mpp->mThreadCodec->signal();
|
mpp->mThreadCodec->signal();
|
||||||
@@ -969,6 +970,8 @@ MPP_RET mpp_dec_control(MppDec *dec, MpiCmd cmd, void *param)
|
|||||||
mpp_err_f("found NULL input dec %p\n", dec);
|
mpp_err_f("found NULL input dec %p\n", dec);
|
||||||
return MPP_ERR_NULL_PTR;
|
return MPP_ERR_NULL_PTR;
|
||||||
}
|
}
|
||||||
|
parser_control(dec->parser, cmd, param);
|
||||||
|
mpp_hal_control(dec->hal, cmd, param);
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case MPP_CODEC_SET_FRAME_INFO : {
|
case MPP_CODEC_SET_FRAME_INFO : {
|
||||||
@@ -979,6 +982,7 @@ MPP_RET mpp_dec_control(MppDec *dec, MpiCmd cmd, void *param)
|
|||||||
mpp_frame_set_height(frame, p->ImgHeight);
|
mpp_frame_set_height(frame, p->ImgHeight);
|
||||||
mpp_frame_set_hor_stride(frame, p->ImgHorStride);
|
mpp_frame_set_hor_stride(frame, p->ImgHorStride);
|
||||||
mpp_frame_set_ver_stride(frame, p->ImgVerStride);
|
mpp_frame_set_ver_stride(frame, p->ImgVerStride);
|
||||||
|
mpp_frame_set_fmt(frame, (MppFrameFormat)p->CodecType);
|
||||||
mpp_log_f("setting default w %4d h %4d\n", p->ImgWidth, p->ImgHeight);
|
mpp_log_f("setting default w %4d h %4d\n", p->ImgWidth, p->ImgHeight);
|
||||||
mpp_slots_set_prop(dec->frame_slots, SLOTS_FRAME_INFO, frame);
|
mpp_slots_set_prop(dec->frame_slots, SLOTS_FRAME_INFO, frame);
|
||||||
mpp_frame_deinit(&frame);
|
mpp_frame_deinit(&frame);
|
||||||
@@ -991,8 +995,7 @@ MPP_RET mpp_dec_control(MppDec *dec, MpiCmd cmd, void *param)
|
|||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
parser_control(dec->parser, cmd, param);
|
|
||||||
mpp_hal_control(dec->hal, cmd, param);
|
|
||||||
|
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
@@ -396,9 +396,9 @@ void rkv_generate_regs(void *hal, HalTaskInfo *task, FifoCtx_t *pkt)
|
|||||||
if (pp->chroma_format_idc == 0) { //!< Y400
|
if (pp->chroma_format_idc == 0) { //!< Y400
|
||||||
yuv_virstride = y_virstride;
|
yuv_virstride = y_virstride;
|
||||||
} else if (pp->chroma_format_idc == 1) { //!< Y420
|
} else if (pp->chroma_format_idc == 1) { //!< Y420
|
||||||
yuv_virstride += y_virstride + y_virstride / 2;
|
yuv_virstride = y_virstride + y_virstride / 2;
|
||||||
} else if (pp->chroma_format_idc == 2) { //!< Y422
|
} else if (pp->chroma_format_idc == 2) { //!< Y422
|
||||||
yuv_virstride += 2 * y_virstride;
|
yuv_virstride = 2 * y_virstride;
|
||||||
}
|
}
|
||||||
p_regs->swreg3_picpar.sw_y_hor_virstride = hor_virstride / 16;
|
p_regs->swreg3_picpar.sw_y_hor_virstride = hor_virstride / 16;
|
||||||
p_regs->swreg3_picpar.sw_uv_hor_virstride = hor_virstride / 16;
|
p_regs->swreg3_picpar.sw_uv_hor_virstride = hor_virstride / 16;
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "vpu_api.h"
|
||||||
#include "rk_type.h"
|
#include "rk_type.h"
|
||||||
#include "mpp_err.h"
|
#include "mpp_err.h"
|
||||||
#include "mpp_mem.h"
|
#include "mpp_mem.h"
|
||||||
@@ -208,6 +209,12 @@ static RK_U32 rkv_len_align(RK_U32 val)
|
|||||||
return (2 * MPP_ALIGN(val, 16));
|
return (2 * MPP_ALIGN(val, 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static RK_U32 rkv_len_align_422(RK_U32 val)
|
||||||
|
{
|
||||||
|
return ((5 * MPP_ALIGN(val, 16)) / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void rkv_h264d_hal_dump(H264dHalCtx_t *p_hal, RK_U32 dump_type)
|
static void rkv_h264d_hal_dump(H264dHalCtx_t *p_hal, RK_U32 dump_type)
|
||||||
{
|
{
|
||||||
if (rkv_h264d_hal_debug & H264D_DBG_ERR_DUMP) {
|
if (rkv_h264d_hal_debug & H264D_DBG_ERR_DUMP) {
|
||||||
@@ -532,10 +539,20 @@ MPP_RET rkv_h264d_control(void *hal, RK_S32 cmd_type, void *param)
|
|||||||
|
|
||||||
INP_CHECK(ret, NULL == p_hal);
|
INP_CHECK(ret, NULL == p_hal);
|
||||||
FunctionIn(p_hal->logctx.parr[RUN_HAL]);
|
FunctionIn(p_hal->logctx.parr[RUN_HAL]);
|
||||||
|
switch ((MpiCmd)cmd_type)
|
||||||
|
{
|
||||||
|
case MPP_CODEC_SET_FRAME_INFO: {
|
||||||
|
VPU_GENERIC *p = (VPU_GENERIC *)param;
|
||||||
|
if (p->CodecType == MPP_FMT_YUV422SP){
|
||||||
|
mpp_slots_set_prop(p_hal->frame_slots, SLOTS_LEN_ALIGN, rkv_len_align_422);
|
||||||
|
mpp_log_f("control format YUV422SP \n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
FunctionOut(p_hal->logctx.parr[RUN_HAL]);
|
FunctionOut(p_hal->logctx.parr[RUN_HAL]);
|
||||||
(void)hal;
|
(void)hal;
|
||||||
|
@@ -85,6 +85,7 @@ RK_S32 VpuApi::init(VpuCodecContext *ctx, RK_U8 *extraData, RK_U32 extra_size)
|
|||||||
mpp_err("found invalid context input");
|
mpp_err("found invalid context input");
|
||||||
return MPP_ERR_NULL_PTR;
|
return MPP_ERR_NULL_PTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = mpp_init(mpp_ctx, type, (MppCodingType)ctx->videoCoding);
|
ret = mpp_init(mpp_ctx, type, (MppCodingType)ctx->videoCoding);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
mpp_err_f(" init error. \n");
|
mpp_err_f(" init error. \n");
|
||||||
@@ -203,11 +204,13 @@ RK_S32 VpuApi:: decode_getoutframe(DecoderOut_t *aDecOut)
|
|||||||
}
|
}
|
||||||
case MPP_FMT_YUV422SP: {
|
case MPP_FMT_YUV422SP: {
|
||||||
vframe->ColorType = VPU_OUTPUT_FORMAT_YUV422;
|
vframe->ColorType = VPU_OUTPUT_FORMAT_YUV422;
|
||||||
|
vframe->OutputWidth = 0x10;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MPP_FMT_YUV422SP_10BIT: {
|
case MPP_FMT_YUV422SP_10BIT: {
|
||||||
vframe->ColorType = VPU_OUTPUT_FORMAT_YUV422;
|
vframe->ColorType = VPU_OUTPUT_FORMAT_YUV422;
|
||||||
vframe->ColorType |= VPU_OUTPUT_FORMAT_BIT_10;
|
vframe->ColorType |= VPU_OUTPUT_FORMAT_BIT_10;
|
||||||
|
vframe->OutputWidth = 0x23;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -246,7 +249,7 @@ RK_S32 VpuApi:: decode_getoutframe(DecoderOut_t *aDecOut)
|
|||||||
pdes[2 * j + 1] = psrc[2 * j * step + 1];
|
pdes[2 * j + 1] = psrc[2 * j * step + 1];
|
||||||
}
|
}
|
||||||
pdes += img_w;
|
pdes += img_w;
|
||||||
psrc += step * vframe->FrameWidth;
|
psrc += step * vframe->FrameWidth * ((mpp_frame_get_fmt(mframe) > MPP_FMT_YUV420SP_10BIT) ? 2 : 1);
|
||||||
}
|
}
|
||||||
fwrite(fp_buf, 1, img_w * img_h * 3 / 2, fp);
|
fwrite(fp_buf, 1, img_w * img_h * 3 / 2, fp);
|
||||||
if (vpu_api_debug & VPU_API_DBG_DUMP_LOG) {
|
if (vpu_api_debug & VPU_API_DBG_DUMP_LOG) {
|
||||||
@@ -359,17 +362,23 @@ RK_S32 VpuApi::control(VpuCodecContext *ctx, VPU_API_CMD cmd, void *param)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case VPU_API_SET_DEFAULT_WIDTH_HEIGH: {
|
case VPU_API_SET_DEFAULT_WIDTH_HEIGH: {
|
||||||
|
RK_U32 ImgWidth = 0;
|
||||||
VPU_GENERIC *p = (VPU_GENERIC *)param;
|
VPU_GENERIC *p = (VPU_GENERIC *)param;
|
||||||
RK_U32 ImgWidth = p->ImgWidth;
|
|
||||||
mpicmd = MPP_CODEC_SET_FRAME_INFO;
|
mpicmd = MPP_CODEC_SET_FRAME_INFO;
|
||||||
/**hightest of p->ImgWidth bit show current dec bitdepth
|
/**hightest of p->ImgWidth bit show current dec bitdepth
|
||||||
* 0 - 8bit
|
* 0 - 8bit
|
||||||
* 1 - 10bit
|
* 1 - 10bit
|
||||||
**/
|
**/
|
||||||
if (((p->ImgWidth & 0x80000000) >> 31)) {
|
if (p->ImgWidth & 0x80000000) {
|
||||||
p->ImgWidth = (p->ImgWidth & 0x7FFFFFFF);
|
|
||||||
ImgWidth = (p->ImgWidth * 10) >> 3;
|
ImgWidth = ((p->ImgWidth & 0xFFFF) * 10) >> 3;
|
||||||
|
p->CodecType = (p->ImgWidth & 0x40000000) ? MPP_FMT_YUV422SP_10BIT : MPP_FMT_YUV420SP_10BIT;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
ImgWidth = (p->ImgWidth & 0xFFFF);
|
||||||
|
p->CodecType = (p->ImgWidth & 0x40000000) ? MPP_FMT_YUV422SP : MPP_FMT_YUV420SP;
|
||||||
|
}
|
||||||
|
p->ImgWidth = (p->ImgWidth & 0xFFFF);
|
||||||
if (ctx->videoCoding == OMX_RK_VIDEO_CodingHEVC) {
|
if (ctx->videoCoding == OMX_RK_VIDEO_CodingHEVC) {
|
||||||
p->ImgHorStride = hevc_ver_align_256_odd(ImgWidth);
|
p->ImgHorStride = hevc_ver_align_256_odd(ImgWidth);
|
||||||
p->ImgVerStride = hevc_ver_align_8(p->ImgHeight);
|
p->ImgVerStride = hevc_ver_align_8(p->ImgHeight);
|
||||||
@@ -377,6 +386,7 @@ RK_S32 VpuApi::control(VpuCodecContext *ctx, VPU_API_CMD cmd, void *param)
|
|||||||
p->ImgHorStride = default_align_16(ImgWidth);
|
p->ImgHorStride = default_align_16(ImgWidth);
|
||||||
p->ImgVerStride = default_align_16(p->ImgHeight);
|
p->ImgVerStride = default_align_16(p->ImgHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case VPU_API_SET_INFO_CHANGE: {
|
case VPU_API_SET_INFO_CHANGE: {
|
||||||
|
Reference in New Issue
Block a user