[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
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;
return length;
}
@@ -1534,6 +1546,12 @@ static RK_S32 parser_nal_units(HEVCContext *s)
fail:
return ret;
}
RK_U16 U16_AT(const RK_U8 *ptr)
{
return ptr[0] << 8 | ptr[1];
}
static RK_S32 hevc_parser_extradata(HEVCContext *s)
{
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
* is finalized. When finalized, configurationVersion will be 1 and we
* 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->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 {
s->is_nalff = 0;
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);
return MPP_OK;
}
if (h265dctx->need_split) {
if (h265dctx->need_split && !s->is_nalff) {
RK_S32 consume = 0;
RK_U8 *split_out_buf = NULL;
RK_S32 split_size = 0;
@@ -1604,6 +1662,10 @@ MPP_RET h265d_prepare(void *ctx, MppPacket pkt, HalDecTask *task)
} else {
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);

View File

@@ -221,7 +221,7 @@ typedef enum SlotPropType_e {
SLOT_EOS,
SLOT_FRAME,
SLOT_BUFFER,
SLOT_FRAME_PTR,
SLOT_FRAME_PTR,
SLOT_PROP_BUTT,
} SlotPropType;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -69,7 +69,7 @@ static RK_S32 inc_used_memory_handle_ref(vpu_display_mem_pool *p, void * hdl)
mpp_buffer_inc_ref(buffer);
}
(void)p;
(void)p;
return MPP_OK;
}
@@ -80,7 +80,7 @@ static RK_S32 put_used_memory_handle(vpu_display_mem_pool *p, void *hdl)
if (buf != NULL) {
mpp_buffer_put(buf);
}
(void)p;
(void)p;
return MPP_OK;
}
@@ -106,7 +106,7 @@ vpu_display_mem_pool* open_vpu_memory_pool()
{
vpu_display_mem_pool_impl *p_mempool = mpp_calloc(vpu_display_mem_pool_impl, 1);
mpp_err("open_vpu_memory_pool in\n");
mpp_err("open_vpu_memory_pool in\n");
if (NULL == p_mempool) {
return NULL;
}
@@ -129,8 +129,8 @@ void close_vpu_memory_pool(vpu_display_mem_pool *p)
{
vpu_display_mem_pool_impl *p_mempool = (vpu_display_mem_pool_impl *)p;
mpp_err("close_vpu_memory_pool in xxxxxxxxxxxxxxx");
mpp_buffer_group_put(p_mempool->group);
mpp_err("close_vpu_memory_pool in xxxxxxxxxxxxxxx");
mpp_buffer_group_put(p_mempool->group);
mpp_free(p_mempool);
return;
}
@@ -156,7 +156,7 @@ int create_vpu_memory_pool_allocator(vpu_display_mem_pool **ipool, int num, int
p_mempool->buff_size = size;
*ipool = (vpu_display_mem_pool*)p_mempool;
(void)num;
(void)num;
return 0;
}

View File

@@ -43,17 +43,17 @@ struct MppFrameImpl_t {
* 7 - deinterlaced paired field
*/
RK_U32 mode;
/*
/*
* current decoded frame whether to display
*
* 0 - display
* 1 - display
*/
RK_U32 display;
/*
RK_U32 display;
/*
* send decoded frame belong which view
*/
RK_U32 viewid;
RK_U32 viewid;
/*
* pts - display time stamp