[mpp_enc]: implement more encoder control function

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@1119 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
ChenHengming
2016-07-28 06:39:53 +00:00
parent 84b3cd2de7
commit 05e4178f9d
8 changed files with 59 additions and 41 deletions

View File

@@ -134,6 +134,8 @@ typedef struct MppEncConfig_t {
*/
RK_S32 width;
RK_S32 height;
RK_S32 hor_stride;
RK_S32 ver_stride;
RK_S32 format;
/*

View File

@@ -43,6 +43,22 @@
#define VPU_OUTPUT_FORMAT_BIT_14 (0x00030000)
#define VPU_OUTPUT_FORMAT_BIT_16 (0x00040000)
typedef enum {
ENC_INPUT_YUV420_PLANAR = 0, /* YYYY... UUUU... VVVV */
ENC_INPUT_YUV420_SEMIPLANAR = 1, /* YYYY... UVUVUV... */
ENC_INPUT_YUV422_INTERLEAVED_YUYV = 2, /* YUYVYUYV... */
ENC_INPUT_YUV422_INTERLEAVED_UYVY = 3, /* UYVYUYVY... */
ENC_INPUT_RGB565 = 4, /* 16-bit RGB */
ENC_INPUT_BGR565 = 5, /* 16-bit RGB */
ENC_INPUT_RGB555 = 6, /* 15-bit RGB */
ENC_INPUT_BGR555 = 7, /* 15-bit RGB */
ENC_INPUT_RGB444 = 8, /* 12-bit RGB */
ENC_INPUT_BGR444 = 9, /* 12-bit RGB */
ENC_INPUT_RGB888 = 10, /* 24-bit RGB */
ENC_INPUT_BGR888 = 11, /* 24-bit RGB */
ENC_INPUT_RGB101010 = 12, /* 30-bit RGB */
ENC_INPUT_BGR101010 = 13 /* 30-bit RGB */
} EncInputPictureType;
typedef enum VPU_API_CMD {
VPU_API_ENC_SETCFG,
@@ -144,23 +160,6 @@ typedef struct EncoderOut {
} EncoderOut_t;
typedef enum {
VPU_H264ENC_YUV420_PLANAR = 0, /* YYYY... UUUU... VVVV */
VPU_H264ENC_YUV420_SEMIPLANAR = 1, /* YYYY... UVUVUV... */
VPU_H264ENC_YUV422_INTERLEAVED_YUYV = 2, /* YUYVYUYV... */
VPU_H264ENC_YUV422_INTERLEAVED_UYVY = 3, /* UYVYUYVY... */
VPU_H264ENC_RGB565 = 4, /* 16-bit RGB */
VPU_H264ENC_BGR565 = 5, /* 16-bit RGB */
VPU_H264ENC_RGB555 = 6, /* 15-bit RGB */
VPU_H264ENC_BGR555 = 7, /* 15-bit RGB */
VPU_H264ENC_RGB444 = 8, /* 12-bit RGB */
VPU_H264ENC_BGR444 = 9, /* 12-bit RGB */
VPU_H264ENC_RGB888 = 10, /* 24-bit RGB */
VPU_H264ENC_BGR888 = 11, /* 24-bit RGB */
VPU_H264ENC_RGB101010 = 12, /* 30-bit RGB */
VPU_H264ENC_BGR101010 = 13 /* 30-bit RGB */
} H264EncPictureType;
/*
* Enumeration used to define the possible video compression codings.
* NOTE: This essentially refers to file extensions. If the coding is

View File

@@ -39,6 +39,7 @@ struct MppEnc_t {
/*
* configuration parameter to controller and hal
*/
MppEncConfig mpp_cfg;
H264EncConfig enc_cfg;
H264EncRateCtrl enc_rc_cfg;
h264e_control_extra_info_cfg extra_info_cfg;

View File

@@ -413,6 +413,8 @@ MPP_RET mpp_enc_control(MppEnc *enc, MpiCmd cmd, void *param)
switch (cmd) {
case MPP_ENC_SET_CFG : {
//H264ENC_NAL_UNIT_STREAM; // decide whether stream start with start code,e.g."00 00 00 01"
enc->mpp_cfg = *mpp_cfg;
enc_cfg->streamType = H264ENC_BYTE_STREAM;
enc_cfg->frameRateDenom = 1;
if (mpp_cfg->profile)
@@ -489,6 +491,9 @@ MPP_RET mpp_enc_control(MppEnc *enc, MpiCmd cmd, void *param)
mpp_hal_control(enc->hal, MPP_ENC_SET_EXTRA_INFO, (void*)(&(enc->extra_info_cfg)));
} break;
case MPP_ENC_GET_CFG : {
*mpp_cfg = enc->mpp_cfg;
} break;
case MPP_ENC_GET_EXTRA_INFO : {
mpp_hal_control(enc->hal, cmd, param);
} break;

View File

@@ -63,7 +63,7 @@ VpuApiLegacy::VpuApiLegacy() :
pictureMem(NULL),
outbufMem(NULL),
outData(NULL),
use_fd_flag(0),
enc_in_fmt(ENC_INPUT_YUV420_PLANAR),
mEosSet(0)
{
mpp_env_get_u32("vpu_api_debug", &vpu_api_debug, 0);
@@ -96,8 +96,8 @@ VpuApiLegacy::~VpuApiLegacy()
outData = NULL;
}
if (memGroup) {
mpp_err("memGroup deInit");
mpp_buffer_group_put(memGroup);
memGroup = NULL;
}
mpp_destroy(mpp_ctx);
@@ -196,9 +196,6 @@ RK_S32 VpuApiLegacy::init(VpuCodecContext *ctx, RK_U8 *extraData, RK_U32 extra_s
if (pkt) {
ctx->extradata_size = mpp_packet_get_length(pkt);
ctx->extradata = mpp_packet_get_data(pkt);
mpp_log("Mpp generate extra data!");
} else {
mpp_err("No extra data generate!");
}
pkt = NULL;
}
@@ -448,6 +445,7 @@ RK_S32 VpuApiLegacy::encode(VpuCodecContext *ctx, EncInputStream_t *aEncInStrm,
/* try import input buffer and output buffer */
MppBufferInfo inputCommit;
MppBufferInfo outputCommit;
RK_U32 use_fd_flag = 0;
memset(&inputCommit, 0, sizeof(inputCommit));
memset(&outputCommit, 0, sizeof(outputCommit));
@@ -802,6 +800,15 @@ RK_S32 VpuApiLegacy::control(VpuCodecContext *ctx, VPU_API_CMD cmd, void *param)
MpiCmd mpicmd = MPI_CMD_BUTT;
switch (cmd) {
case VPU_API_ENC_SETCFG : {
mpicmd = MPP_ENC_SET_CFG;
} break;
case VPU_API_ENC_GETCFG : {
mpicmd = MPP_ENC_GET_CFG;
} break;
case VPU_API_ENC_SETFORMAT : {
enc_in_fmt = *((EncInputPictureType *)param);
} break;
case VPU_API_SET_VPUMEM_CONTEXT: {
mpicmd = MPP_DEC_SET_EXT_BUF_GROUP;
break;
@@ -858,18 +865,18 @@ RK_S32 VpuApiLegacy::control(VpuCodecContext *ctx, VPU_API_CMD cmd, void *param)
mpicmd = MPP_DEC_GET_VPUMEM_USED_COUNT;
break;
}
case VPU_API_DEC_GET_EOS_STATUS: {
*(RK_S32 *)param = mEosSet;
case VPU_API_DEC_GETFORMAT: {
mpicmd = MPI_CMD_BUTT;
getDecoderFormat(ctx, (DecoderFormat_t *)param);
break;
}
case VPU_API_SET_OUTPUT_BLOCK: {
mpicmd = MPP_SET_OUTPUT_BLOCK;
break;
}
case VPU_API_DEC_GETFORMAT: {
case VPU_API_DEC_GET_EOS_STATUS: {
*(RK_S32 *)param = mEosSet;
mpicmd = MPI_CMD_BUTT;
getDecoderFormat(ctx, (DecoderFormat_t *)param);
break;
}
default: {

View File

@@ -71,11 +71,13 @@ private:
RK_U32 set_eos;
FILE *fp;
RK_U8 *fp_buf;
MppBufferGroup memGroup;
MppBuffer pictureMem;
MppBuffer outbufMem;
RK_U8* outData;
RK_U32 use_fd_flag;
/* encoder parameters */
MppBufferGroup memGroup;
MppBuffer pictureMem;
MppBuffer outbufMem;
RK_U8* outData;
EncInputPictureType enc_in_fmt;
RK_U32 mEosSet;
};

View File

@@ -155,7 +155,7 @@ int mpi_enc_test(MpiEncTestCmd *cmd)
memset(&mpp_cfg, 0, sizeof(mpp_cfg));
mpp_cfg.width = width;
mpp_cfg.height = height;
mpp_cfg.format = VPU_H264ENC_YUV420_PLANAR;
mpp_cfg.format = ENC_INPUT_YUV420_PLANAR;
mpp_cfg.rc_mode = 1;
mpp_cfg.skip_cnt = 0;
mpp_cfg.bps = SZ_4M * 8;

View File

@@ -263,7 +263,7 @@ static RK_S32 vpu_encode_demo(VpuApiDemoCmdContext_t *cmd)
memset(ctx, 0, sizeof(struct VpuCodecContext));
#endif
int Format = VPU_H264ENC_YUV420_PLANAR;//VPU_H264ENC_YUV420_SEMIPLANAR;
int Format = ENC_INPUT_YUV420_PLANAR;
if (cmd == NULL) {
return -1;
@@ -303,9 +303,10 @@ static RK_S32 vpu_encode_demo(VpuApiDemoCmdContext_t *cmd)
#ifdef FOR_TEST_ENCODE
ctx->videoCoding = OMX_RK_VIDEO_CodingAVC;
ctx->codecType = CODEC_ENCODER;
ctx->width = cmd->width;
ctx->width = cmd->width;
ctx->height = cmd->height;
#endif
fseek(pInFile, 0L, SEEK_END);
fileSize = ftell(pInFile);
fseek(pInFile, 0L, SEEK_SET);
@@ -340,13 +341,14 @@ static RK_S32 vpu_encode_demo(VpuApiDemoCmdContext_t *cmd)
memset(ctx->private_data, 0, sizeof(EncParameter_t));
enc_param = (EncParameter_t*)ctx->private_data;
enc_param->width = cmd->width;
enc_param->height = cmd->height;
enc_param->bitRate = 100000;
enc_param->framerate = 25;
enc_param->enableCabac = 0;
enc_param->cabacInitIdc = 0;
enc_param->intraPicRate = 30;
enc_param->width = cmd->width;
enc_param->height = cmd->height;
enc_param->rc_mode = 0;
enc_param->bitRate = 100000;
enc_param->framerate = 25;
enc_param->enableCabac = 1;
enc_param->cabacInitIdc = 0;
enc_param->intraPicRate = 30;
if ((ret = ctx->init(ctx, NULL, 0)) != 0) {
mpp_log("init vpu api context fail, ret: 0x%X\n", ret);