[h265d]:supprot key hevcc process

[mpp_dec]: remove display flag 

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@460 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
ChenSiyong
2015-11-16 21:11:43 +00:00
parent 5edd26e52a
commit 5f9f4b4805
9 changed files with 148 additions and 86 deletions

View File

@@ -1313,7 +1313,19 @@ RK_S32 mpp_hevc_extract_rbsp(HEVCContext *s, const RK_U8 *src, int length,
} }
if (i >= length - 1) { // no escaped 0 if (i >= length - 1) { // no escaped 0
nal->data = src; if (length + MPP_INPUT_BUFFER_PADDING_SIZE > nal->rbsp_buffer_size) {
RK_S32 min_size = length + MPP_INPUT_BUFFER_PADDING_SIZE;
mpp_free(nal->rbsp_buffer);
nal->rbsp_buffer = NULL;
min_size = MPP_MAX(17 * min_size / 16 + 32, min_size);
nal->rbsp_buffer = mpp_malloc(RK_U8, min_size);
if (nal->rbsp_buffer == NULL) {
min_size = 0;
}
nal->rbsp_buffer_size = min_size;
}
memcpy(nal->rbsp_buffer, src, length);
nal->data = nal->rbsp_buffer;
nal->size = length; nal->size = length;
return length; return length;
} }
@@ -1534,6 +1546,12 @@ static RK_S32 parser_nal_units(HEVCContext *s)
fail: fail:
return ret; return ret;
} }
RK_U16 U16_AT(const RK_U8 *ptr)
{
return ptr[0] << 8 | ptr[1];
}
static RK_S32 hevc_parser_extradata(HEVCContext *s) static RK_S32 hevc_parser_extradata(HEVCContext *s)
{ {
H265dContext_t *h265dctx = s->h265dctx; H265dContext_t *h265dctx = s->h265dctx;
@@ -1545,8 +1563,48 @@ static RK_S32 hevc_parser_extradata(HEVCContext *s)
* Temporarily, we support configurationVersion==0 until 14496-15 3rd * Temporarily, we support configurationVersion==0 until 14496-15 3rd
* is finalized. When finalized, configurationVersion will be 1 and we * is finalized. When finalized, configurationVersion will be 1 and we
* can recognize hvcC by checking if h265dctx->extradata[0]==1 or not. */ * can recognize hvcC by checking if h265dctx->extradata[0]==1 or not. */
mpp_err("extradata is encoded as hvcC format"); const RK_U8 *ptr = (const uint8_t *)h265dctx->extradata;
RK_U32 size = h265dctx->extradata_size;
RK_U32 numofArrays = 0, numofNals = 0;
RK_U32 j = 0, i = 0;
if (size < 7) {
return MPP_NOK;
}
mpp_log("extradata is encoded as hvcC format");
s->is_nalff = 1; s->is_nalff = 1;
s->nal_length_size = 1 + (ptr[14 + 7] & 3);
ptr += 22;
size -= 22;
numofArrays = (char)ptr[0];
ptr += 1;
size -= 1;
for (i = 0; i < numofArrays; i++) {
ptr += 1;
size -= 1;
// Num of nals
numofNals = U16_AT(ptr);
ptr += 2;
size -= 2;
for (j = 0; j < numofNals; j++) {
RK_U32 length = 0;
if (size < 2) {
return MPP_NOK;
}
length = U16_AT(ptr);
ptr += 2;
size -= 2;
if (size < length) {
return MPP_NOK;
}
parser_nal_unit(s, ptr, length);
ptr += length;
size -= length;
}
}
} else { } else {
s->is_nalff = 0; s->is_nalff = 0;
ret = split_nal_units(s, h265dctx->extradata, h265dctx->extradata_size); ret = split_nal_units(s, h265dctx->extradata, h265dctx->extradata_size);
@@ -1585,7 +1643,7 @@ MPP_RET h265d_prepare(void *ctx, MppPacket pkt, HalDecTask *task)
mpp_packet_set_pos(pkt, pos); mpp_packet_set_pos(pkt, pos);
return MPP_OK; return MPP_OK;
} }
if (h265dctx->need_split) { if (h265dctx->need_split && !s->is_nalff) {
RK_S32 consume = 0; RK_S32 consume = 0;
RK_U8 *split_out_buf = NULL; RK_U8 *split_out_buf = NULL;
RK_S32 split_size = 0; RK_S32 split_size = 0;
@@ -1604,6 +1662,10 @@ MPP_RET h265d_prepare(void *ctx, MppPacket pkt, HalDecTask *task)
} else { } else {
return MPP_FAIL_SPLIT_FRAME; return MPP_FAIL_SPLIT_FRAME;
} }
} else {
pos = buf + length;
s->pts = pts;
mpp_packet_set_pos(pkt, pos);
} }
ret = (MPP_RET)split_nal_units(s, buf, length); ret = (MPP_RET)split_nal_units(s, buf, length);

View File

@@ -605,10 +605,10 @@ void *mpp_dec_hal_thread(void *data)
RK_S32 index; RK_S32 index;
while (MPP_OK == mpp_buf_slot_dequeue(frame_slots, &index, QUEUE_DISPLAY)) { while (MPP_OK == mpp_buf_slot_dequeue(frame_slots, &index, QUEUE_DISPLAY)) {
MppFrame frame; MppFrame frame;
RK_U32 display; //RK_U32 display;
mpp_buf_slot_get_prop(frame_slots, index, SLOT_FRAME, &frame); mpp_buf_slot_get_prop(frame_slots, index, SLOT_FRAME, &frame);
display = mpp_frame_get_display(frame); // display = mpp_frame_get_display(frame);
if (!dec->reset_flag && display) { if (!dec->reset_flag) {
mpp_put_frame(mpp, frame); mpp_put_frame(mpp, frame);
} else { } else {
mpp_frame_deinit(&frame); mpp_frame_deinit(&frame);

View File

@@ -32,7 +32,8 @@
#ifdef ANDROID #ifdef ANDROID
namespace android { namespace android
{
status_t ppOpInit(PP_OP_HANDLE *hnd, PP_OPERATION *init) status_t ppOpInit(PP_OP_HANDLE *hnd, PP_OPERATION *init)
{ {
@@ -93,22 +94,22 @@ status_t ppOpRelease(PP_OP_HANDLE hnd)
int main() int main()
{ {
FILE *fpr, *fpw; FILE *fpr, *fpw;
int wid_alig16 = ((SRC_WIDTH+15)&(~0xf)); int wid_alig16 = ((SRC_WIDTH + 15) & (~0xf));
int hei_alig16 = ((SRC_HEIGHT+15)&(~0xf)); int hei_alig16 = ((SRC_HEIGHT + 15) & (~0xf));
int src_vir_width = 1920;//2048; int src_vir_width = 1920;//2048;
int src_vir_height = 1088;//1088; int src_vir_height = 1088;//1088;
int dst_vir_width = 800;//800; int dst_vir_width = 800;//800;
int dst_vir_height = 1280;//1280; int dst_vir_height = 1280;//1280;
int framecnt = 0; int framecnt = 0;
char *tmpbuf = (char *)malloc(src_vir_width*src_vir_height/2); char *tmpbuf = (char *)malloc(src_vir_width * src_vir_height / 2);
RK_S32 ret = 0, i, j; RK_S32 ret = 0, i, j;
ALOGI("ppOp test start\n"); ALOGI("ppOp test start\n");
VPUMemLinear_t src, dst; VPUMemLinear_t src, dst;
android::PP_OP_HANDLE hnd; android::PP_OP_HANDLE hnd;
int vpuFd = VPUClientInit(VPU_PP); int vpuFd = VPUClientInit(VPU_PP);
ret |= VPUMallocLinear(&src, src_vir_width*src_vir_height*2);//SRC_SIZE); ret |= VPUMallocLinear(&src, src_vir_width * src_vir_height * 2); //SRC_SIZE);
ret |= VPUMallocLinear(&dst, dst_vir_width*dst_vir_height*2);//DST_SIZE); ret |= VPUMallocLinear(&dst, dst_vir_width * dst_vir_height * 2); //DST_SIZE);
if (ret) { if (ret) {
ALOGE("failed to malloc vpu_mem"); ALOGE("failed to malloc vpu_mem");
goto end; goto end;
@@ -119,51 +120,46 @@ int main()
} }
{ {
#if 0 #if 0
int i, j; int i, j;
char *tmp = (char *)src.vir_addr; char *tmp = (char *)src.vir_addr;
for(i=0; i<SRC_HEIGHT; i++) for (i = 0; i < SRC_HEIGHT; i++) {
{ memset(tmp, (i & 0xff), SRC_WIDTH);
memset(tmp, (i&0xff), SRC_WIDTH);
tmp += SRC_WIDTH; tmp += SRC_WIDTH;
} }
#endif #endif
#if 1 #if 1
char *tmp = (char *)src.vir_addr; char *tmp = (char *)src.vir_addr;
fpr = fopen("/sdcard/testin.yuv", "rb"); fpr = fopen("/sdcard/testin.yuv", "rb");
for(i=0; i<SRC_HEIGHT; i++) for (i = 0; i < SRC_HEIGHT; i++) {
{ if (fpr)fread(tmp, 1, SRC_WIDTH, fpr);
if(fpr)fread(tmp, 1, SRC_WIDTH, fpr);
tmp += src_vir_width; tmp += src_vir_width;
} }
tmp = (char *)src.vir_addr; tmp = (char *)src.vir_addr;
if(fpr)fread(&tmp[src_vir_width*src_vir_height], 1, SRC_WIDTH*SRC_HEIGHT/2, fpr); if (fpr)fread(&tmp[src_vir_width * src_vir_height], 1, SRC_WIDTH * SRC_HEIGHT / 2, fpr);
if(fpr)fclose(fpr); if (fpr)fclose(fpr);
for(i=0; i<SRC_HEIGHT/2; i++) //planar to semi planar for (i = 0; i < SRC_HEIGHT / 2; i++) { //planar to semi planar
{ for (j = 0; j < SRC_WIDTH / 2; j++) { //planar to semi planar
for(j=0; j<SRC_WIDTH/2; j++) //planar to semi planar tmpbuf[i * src_vir_width + j * 2 + 0] = tmp[src_vir_width * src_vir_height + i * SRC_WIDTH / 2 + j];
{ tmpbuf[i * src_vir_width + j * 2 + 1] = tmp[src_vir_width * src_vir_height + SRC_WIDTH * SRC_HEIGHT / 4 + i * SRC_WIDTH / 2 + j];
tmpbuf[i*src_vir_width+j*2+0] = tmp[src_vir_width*src_vir_height + i*SRC_WIDTH/2 + j];
tmpbuf[i*src_vir_width+j*2+1] = tmp[src_vir_width*src_vir_height + SRC_WIDTH*SRC_HEIGHT/4 + i*SRC_WIDTH/2 + j];
} }
} }
memcpy(&tmp[src_vir_width*src_vir_height], tmpbuf, src_vir_width*src_vir_height/2); memcpy(&tmp[src_vir_width * src_vir_height], tmpbuf, src_vir_width * src_vir_height / 2);
//memset(&tmp[SRC_WIDTH*SRC_HEIGHT], 0x80, SRC_WIDTH*SRC_HEIGHT/2); //memset(&tmp[SRC_WIDTH*SRC_HEIGHT], 0x80, SRC_WIDTH*SRC_HEIGHT/2);
#endif #endif
VPUMemClean(&src); VPUMemClean(&src);
} }
while(1) while (1) {
{
printf("framecnt=%d\n", framecnt); printf("framecnt=%d\n", framecnt);
if(framecnt++ >= 1) if (framecnt++ >= 1)
break; break;
wid_alig16 = ((SRC_WIDTH+15)&(~0xf)); wid_alig16 = ((SRC_WIDTH + 15) & (~0xf));
hei_alig16 = ((SRC_HEIGHT+15)&(~0xf)); hei_alig16 = ((SRC_HEIGHT + 15) & (~0xf));
android::PP_OPERATION opt; android::PP_OPERATION opt;
memset(&opt, 0, sizeof(opt)); memset(&opt, 0, sizeof(opt));
@@ -175,13 +171,13 @@ int main()
opt.srcVStride = src_vir_height; opt.srcVStride = src_vir_height;
opt.srcX = 0; opt.srcX = 0;
opt.srcY = 0; opt.srcY = 0;
if(wid_alig16 != SRC_WIDTH) if (wid_alig16 != SRC_WIDTH)
opt.srcCrop8R = 1; opt.srcCrop8R = 1;
if(hei_alig16 != SRC_HEIGHT) if (hei_alig16 != SRC_HEIGHT)
opt.srcCrop8D= 1; opt.srcCrop8D = 1;
wid_alig16 = ((DST_WIDTH+15)&(~0xf)); wid_alig16 = ((DST_WIDTH + 15) & (~0xf));
hei_alig16 = ((DST_HEIGHT+15)&(~0xf)); hei_alig16 = ((DST_HEIGHT + 15) & (~0xf));
opt.dstAddr = dst.phy_addr; opt.dstAddr = dst.phy_addr;
opt.dstFormat = PP_OUT_FORMAT_YUV420INTERLAVE; opt.dstFormat = PP_OUT_FORMAT_YUV420INTERLAVE;
@@ -218,7 +214,7 @@ int main()
VPUMemInvalidate(&dst); VPUMemInvalidate(&dst);
{ {
#if 0 #if 0
int i, j, ret = 0; int i, j, ret = 0;
char *tmp = (char *)dst.vir_addr; char *tmp = (char *)dst.vir_addr;
/*for(i=0; i<3; i++) /*for(i=0; i<3; i++)
@@ -229,37 +225,35 @@ int main()
{ {
printf("las out_pos=%d, 0x%x\n", (DST_HEIGHT-1-i)*DST_WIDTH, tmp[(DST_HEIGHT-1-i)*DST_WIDTH]); printf("las out_pos=%d, 0x%x\n", (DST_HEIGHT-1-i)*DST_WIDTH, tmp[(DST_HEIGHT-1-i)*DST_WIDTH]);
}*/ }*/
for(i=0; i<DST_HEIGHT; i++) for (i = 0; i < DST_HEIGHT; i++) {
{ for (j = 0; j < DST_WIDTH; j++) {
for(j=0; j<DST_WIDTH; j++) if ( tmp[i * DST_WIDTH + j] != (i & 0xff))
{
if( tmp[i*DST_WIDTH + j] != (i&0xff))
ret = 1; ret = 1;
} }
} }
if( ret) if ( ret)
printf("framecount=%d pp operation is failed!\n", (framecnt-1)); printf("framecount=%d pp operation is failed!\n", (framecnt - 1));
else else
printf("framecount=%d pp operation is suceess!\n", (framecnt-1)); printf("framecount=%d pp operation is suceess!\n", (framecnt - 1));
memset(dst.vir_addr, 0xff, DST_SIZE); memset(dst.vir_addr, 0xff, DST_SIZE);
VPUMemClean(&dst); VPUMemClean(&dst);
#endif #endif
#if 1 #if 1
char *tmp = (char *)dst.vir_addr; char *tmp = (char *)dst.vir_addr;
//memset(&tmp[DST_WIDTH*DST_HEIGHT], 0x80, DST_WIDTH*DST_HEIGHT/2); //memset(&tmp[DST_WIDTH*DST_HEIGHT], 0x80, DST_WIDTH*DST_HEIGHT/2);
//VPUMemClean(&dst); //VPUMemClean(&dst);
fpw = fopen("/data/testout.yuv", "wb+"); fpw = fopen("/data/testout.yuv", "wb+");
if(fpw)fwrite((char *)(dst.vir_addr), 1, dst_vir_width*dst_vir_height*3/2, fpw); if (fpw)fwrite((char *)(dst.vir_addr), 1, dst_vir_width * dst_vir_height * 3 / 2, fpw);
if(fpw)fclose(fpw); if (fpw)fclose(fpw);
#endif #endif
} }
} }
end: end:
if(tmpbuf)free(tmpbuf); if (tmpbuf)free(tmpbuf);
if (src.phy_addr) VPUFreeLinear(&src); if (src.phy_addr) VPUFreeLinear(&src);
if (dst.phy_addr) VPUFreeLinear(&dst); if (dst.phy_addr) VPUFreeLinear(&dst);
if (vpuFd > 0) VPUClientRelease(vpuFd); if (vpuFd > 0) VPUClientRelease(vpuFd);

View File

@@ -32,7 +32,8 @@
typedef int32_t status_t; typedef int32_t status_t;
namespace android { namespace android
{
#define PP_IN_FORMAT_YUV422INTERLAVE 0 #define PP_IN_FORMAT_YUV422INTERLAVE 0
#define PP_IN_FORMAT_YUV420SEMI 1 #define PP_IN_FORMAT_YUV420SEMI 1

View File

@@ -200,7 +200,7 @@ RK_S32 open_orign_vpu(VpuCodecContext **ctx)
if (rkapi_hdl == NULL) { if (rkapi_hdl == NULL) {
mpp_log("dlopen librk_vpuapi library fail\n"); mpp_log("dlopen librk_vpuapi library fail\n");
rkapi_hdl = dlopen("/system/lib/librk_on2.so", RTLD_LAZY); rkapi_hdl = dlopen("/system/lib/librk_on2.so", RTLD_LAZY);
if(rkapi_hdl == NULL){ if (rkapi_hdl == NULL) {
return -1; return -1;
} }
} }
@@ -224,7 +224,7 @@ RK_S32 close_orign_vpu(VpuCodecContext **ctx)
if (rkapi_hdl == NULL) { if (rkapi_hdl == NULL) {
mpp_log("dlopen librk_vpuapi library fail\n"); mpp_log("dlopen librk_vpuapi library fail\n");
rkapi_hdl = dlopen("/system/lib/librk_on2.so", RTLD_LAZY); rkapi_hdl = dlopen("/system/lib/librk_on2.so", RTLD_LAZY);
if(rkapi_hdl == NULL){ if (rkapi_hdl == NULL) {
return -1; return -1;
} }
} }
@@ -260,7 +260,7 @@ RK_S32 vpu_open_context(VpuCodecContext **ctx)
if (s != NULL) { if (s != NULL) {
mpp_log("s->videoCoding = %d", s->videoCoding); mpp_log("s->videoCoding = %d", s->videoCoding);
if (s->videoCoding == OMX_RK_VIDEO_CodingHEVC if (s->videoCoding == OMX_RK_VIDEO_CodingHEVC
||(s->videoCoding == OMX_RK_VIDEO_CodingAVC && || (s->videoCoding == OMX_RK_VIDEO_CodingAVC &&
s->codecType == CODEC_DECODER)) { s->codecType == CODEC_DECODER)) {
free(s); free(s);
s = NULL; s = NULL;

View File

@@ -79,7 +79,9 @@ RK_S32 VpuApi::flush(VpuCodecContext *ctx)
{ {
(void)ctx; (void)ctx;
mpp_log_f("in\n"); mpp_log_f("in\n");
if (mpi && mpi->flush) {
mpi->flush(mpp_ctx); mpi->flush(mpp_ctx);
}
mpp_log_f("ok\n"); mpp_log_f("ok\n");
return 0; return 0;
} }
@@ -208,6 +210,9 @@ RK_S32 VpuApi::control(VpuCodecContext *ctx, VPU_API_CMD cmd, void *param)
{ {
mpp_log_f("in\n"); mpp_log_f("in\n");
MpiCmd mpicmd; MpiCmd mpicmd;
if (mpi == NULL) {
return 0;
}
(void)ctx; (void)ctx;
switch (cmd) { switch (cmd) {
case VPU_API_SET_VPUMEM_CONTEXT: { case VPU_API_SET_VPUMEM_CONTEXT: {