[vpu_legacy]:eos set no contain in frame, return in ret

[mpp_dec]:when flush lock codec signal, fixed dead loop in seek status
[mpp_dec]:when flush check first packet if is config keep this packet to decoder avoid extract data has been flush cause decoder err
[h265d]: mark h265 dec error use check ref has error if ref error mark current dec frame error

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@524 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
ChenSiyong
2016-01-13 10:00:49 +00:00
parent 41fcb47315
commit 1975d15c8d
6 changed files with 61 additions and 6 deletions

View File

@@ -1132,10 +1132,11 @@ static RK_S32 hevc_frame_start(HEVCContext *s)
if (ret < 0) if (ret < 0)
goto fail; goto fail;
s->miss_ref_flag = 0;
ret = mpp_hevc_frame_rps(s); ret = mpp_hevc_frame_rps(s);
if(s->miss_ref_flag && !IS_IRAP(s)){ if(s->miss_ref_flag && !IS_IRAP(s)){
mpp_frame_set_errinfo(s->frame,VPU_FRAME_ERR_UNKNOW); mpp_frame_set_errinfo(s->frame,VPU_FRAME_ERR_UNKNOW);
s->ref->error_flag = 1;
} }
mpp_buf_slot_set_prop(s->slots, s->ref->slot_index, SLOT_FRAME, s->ref->frame); mpp_buf_slot_set_prop(s->slots, s->ref->slot_index, SLOT_FRAME, s->ref->frame);
@@ -1484,6 +1485,22 @@ static RK_S32 split_nal_units(HEVCContext *s, RK_U8 *buf, RK_U32 length)
continue; continue;
} }
if (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) { if (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) {
uint32_t state = -1;
int has_nal = 0;
for (i = 0; i < length; i++) {
state = (state << 8) | buf[i];
if (((state >> 8) & 0xFFFFFF) == START_CODE){
has_nal = 1;
i = i -3;
break;
}
}
if(has_nal){
length -= i;
buf += i;
continue;
}
mpp_err( "No start code is found.\n"); mpp_err( "No start code is found.\n");
ret = MPP_ERR_STREAM; ret = MPP_ERR_STREAM;
goto fail; goto fail;
@@ -1857,6 +1874,7 @@ static RK_S32 hevc_init_context(H265dContext_t *h265dctx)
for (i = 0; i < MPP_ARRAY_ELEMS(s->DPB); i++) { for (i = 0; i < MPP_ARRAY_ELEMS(s->DPB); i++) {
s->DPB[i].slot_index = 0xff; s->DPB[i].slot_index = 0xff;
s->DPB[i].poc = INT_MAX; s->DPB[i].poc = INT_MAX;
s->DPB[i].error_flag = 0;
mpp_frame_init(&s->DPB[i].frame); mpp_frame_init(&s->DPB[i].frame);
if (!s->DPB[i].frame) if (!s->DPB[i].frame)
goto fail; goto fail;
@@ -1993,11 +2011,18 @@ MPP_RET h265d_callback(void *ctx, void *err_info)
{ {
H265dContext_t *h265dctx = (H265dContext_t *)ctx; H265dContext_t *h265dctx = (H265dContext_t *)ctx;
HEVCContext *s = (HEVCContext *)h265dctx->priv_data; HEVCContext *s = (HEVCContext *)h265dctx->priv_data;
RK_U32 i = 0;
s->max_ra = INT_MAX; s->max_ra = INT_MAX;
s->miss_ref_flag = 1; // s->miss_ref_flag = 1;
mpp_buf_slot_get_prop(s->slots, s->ref->slot_index,SLOT_FRAME,&s->ref->frame); mpp_buf_slot_get_prop(s->slots, s->ref->slot_index,SLOT_FRAME,&s->ref->frame);
mpp_frame_set_errinfo(s->ref->frame,VPU_FRAME_ERR_UNKNOW); mpp_frame_set_errinfo(s->ref->frame,VPU_FRAME_ERR_UNKNOW);
mpp_buf_slot_set_prop(s->slots, s->ref->slot_index, SLOT_FRAME, s->ref->frame); mpp_buf_slot_set_prop(s->slots, s->ref->slot_index, SLOT_FRAME, s->ref->frame);
for (i = 0; i < MPP_ARRAY_ELEMS(s->DPB); i++) {
if(s->DPB[i].slot_index == s->ref->slot_index){
s->DPB[i].error_flag = 1;
}
}
(void) err_info; (void) err_info;
return MPP_OK; return MPP_OK;

View File

@@ -564,6 +564,7 @@ typedef struct HEVCFrame {
*/ */
RK_U8 flags; RK_U8 flags;
RK_S32 slot_index; RK_S32 slot_index;
RK_U8 error_flag;
} HEVCFrame; } HEVCFrame;
typedef struct HEVCNAL { typedef struct HEVCNAL {

View File

@@ -51,6 +51,7 @@ void mpp_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags)
h265d_dbg(H265D_DBG_REF, "unref_frame poc %d frame->slot_index %d \n", frame->poc, frame->slot_index); h265d_dbg(H265D_DBG_REF, "unref_frame poc %d frame->slot_index %d \n", frame->poc, frame->slot_index);
frame->poc = INT_MAX; frame->poc = INT_MAX;
frame->slot_index = 0xff; frame->slot_index = 0xff;
frame->error_flag = 0;
} }
} }
@@ -145,7 +146,7 @@ int mpp_hevc_set_new_ref(HEVCContext *s, MppFrame *mframe, int poc)
frame->poc == poc && !s->nuh_layer_id) { frame->poc == poc && !s->nuh_layer_id) {
mpp_err( "Duplicate POC in a sequence: %d.\n", mpp_err( "Duplicate POC in a sequence: %d.\n",
poc); poc);
s->miss_ref_flag = 1; //s->miss_ref_flag = 1;
return MPP_ERR_STREAM; return MPP_ERR_STREAM;
} }
} }
@@ -334,10 +335,10 @@ static int add_candidate_ref(HEVCContext *s, RefPicList *list,
return MPP_ERR_STREAM; return MPP_ERR_STREAM;
if (!ref) { if (!ref) {
s->miss_ref_flag = 1;
ref = generate_missing_ref(s, poc); ref = generate_missing_ref(s, poc);
if (!ref) if (!ref)
return MPP_ERR_NOMEM; return MPP_ERR_NOMEM;
ref->error_flag = 1;
} }
list->list[list->nb_refs] = ref->poc; list->list[list->nb_refs] = ref->poc;
@@ -348,7 +349,9 @@ static int add_candidate_ref(HEVCContext *s, RefPicList *list,
mpp_buf_slot_set_flag(s->slots, ref->slot_index, SLOT_CODEC_USE); mpp_buf_slot_set_flag(s->slots, ref->slot_index, SLOT_CODEC_USE);
} }
mark_ref(ref, ref_flag); mark_ref(ref, ref_flag);
if(ref->error_flag){
s->miss_ref_flag = 1;
}
return 0; return 0;
} }

View File

@@ -32,6 +32,7 @@ VpuApi::VpuApi()
#endif #endif
mpp_construct(&mpp_ctx, &mpi); mpp_construct(&mpp_ctx, &mpi);
frame_count = 0; frame_count = 0;
set_eos = 0;
mpp_log_f("ok\n"); mpp_log_f("ok\n");
} }
@@ -129,6 +130,10 @@ RK_S32 VpuApi:: decode_getoutframe(DecoderOut_t *aDecOut)
aDecOut->size = 0; aDecOut->size = 0;
return 0; return 0;
} }
if(set_eos){
aDecOut->size = 0;
return VPU_API_EOS_STREAM_REACHED;
}
if (MPP_OK == mpi->decode_get_frame(mpp_ctx, &mframe)) { if (MPP_OK == mpi->decode_get_frame(mpp_ctx, &mframe)) {
MppBuffer buf; MppBuffer buf;
RK_U64 pts; RK_U64 pts;
@@ -189,7 +194,10 @@ RK_S32 VpuApi:: decode_getoutframe(DecoderOut_t *aDecOut)
vframe->vpumem.offset = (RK_U32*)buf; vframe->vpumem.offset = (RK_U32*)buf;
} }
if (mpp_frame_get_eos(mframe)) { if (mpp_frame_get_eos(mframe)) {
aDecOut->nFlags = VPU_API_EOS_STREAM_REACHED; set_eos = 1;
if(buf == NULL){
aDecOut->size = 0;
}
} }
mpp_free(mframe); mpp_free(mframe);
} else { } else {

View File

@@ -47,6 +47,7 @@ private:
MppCtx mpp_ctx; MppCtx mpp_ctx;
MppApi *mpi; MppApi *mpi;
RK_U32 frame_count; RK_U32 frame_count;
RK_U32 set_eos;
#ifdef DUMP_YUV #ifdef DUMP_YUV
FILE *fp; FILE *fp;
#endif #endif

View File

@@ -304,7 +304,12 @@ MPP_RET Mpp::control(MpiCmd cmd, MppParam param)
MPP_RET Mpp::reset() MPP_RET Mpp::reset()
{ {
MppPacket mpkt = NULL;
RK_U32 flags = 0;
mPackets->lock(); mPackets->lock();
if(mPackets->list_size()){
mPackets->del_at_head(&mpkt, sizeof(mpkt));
}
mPackets->flush(); mPackets->flush();
mPackets->unlock(); mPackets->unlock();
@@ -316,12 +321,24 @@ MPP_RET Mpp::reset()
if (mType == MPP_CTX_DEC) { if (mType == MPP_CTX_DEC) {
mpp_dec_reset(mDec); mpp_dec_reset(mDec);
mThreadCodec->lock();
mThreadCodec->signal(); mThreadCodec->signal();
mThreadCodec->unlock();
mThreadCodec->wait(THREAD_RESET); mThreadCodec->wait(THREAD_RESET);
} else { } else {
mpp_enc_reset(mEnc); mpp_enc_reset(mEnc);
} }
mThreadCodec->unlock(THREAD_RESET); mThreadCodec->unlock(THREAD_RESET);
if(mpkt != NULL){
flags = mpp_packet_get_flag(mpkt);
mpp_log("flags = %d",flags);
if(flags&MPP_PACKET_FLAG_EXTRA_DATA){ //avoid first packet is extara data was flushed & dec can work
put_packet(mpkt);
}
mpp_free(mpp_packet_get_data(mpkt));
mpp_packet_deinit(&mpkt);
mpkt = NULL;
}
return MPP_OK; return MPP_OK;
} }