mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-10 03:20:04 +08:00
[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:
@@ -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);
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -32,7 +32,8 @@
|
||||
|
||||
#ifdef ANDROID
|
||||
|
||||
namespace android {
|
||||
namespace android
|
||||
{
|
||||
|
||||
status_t ppOpInit(PP_OP_HANDLE *hnd, PP_OPERATION *init)
|
||||
{
|
||||
@@ -122,8 +123,7 @@ int main()
|
||||
#if 0
|
||||
int i, j;
|
||||
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);
|
||||
tmp += SRC_WIDTH;
|
||||
}
|
||||
@@ -132,8 +132,7 @@ int main()
|
||||
#if 1
|
||||
char *tmp = (char *)src.vir_addr;
|
||||
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);
|
||||
tmp += src_vir_width;
|
||||
}
|
||||
@@ -141,10 +140,8 @@ int main()
|
||||
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
|
||||
{
|
||||
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];
|
||||
}
|
||||
@@ -155,8 +152,7 @@ int main()
|
||||
VPUMemClean(&src);
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
while (1) {
|
||||
printf("framecnt=%d\n", framecnt);
|
||||
|
||||
if (framecnt++ >= 1)
|
||||
@@ -229,10 +225,8 @@ 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++)
|
||||
{
|
||||
for (i = 0; i < DST_HEIGHT; i++) {
|
||||
for (j = 0; j < DST_WIDTH; j++) {
|
||||
if ( tmp[i * DST_WIDTH + j] != (i & 0xff))
|
||||
ret = 1;
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -79,7 +79,9 @@ RK_S32 VpuApi::flush(VpuCodecContext *ctx)
|
||||
{
|
||||
(void)ctx;
|
||||
mpp_log_f("in\n");
|
||||
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: {
|
||||
|
Reference in New Issue
Block a user