[mpp]: move init flag to private data, add comment for extra data

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@536 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
ChenHengming
2016-01-20 07:53:55 +00:00
parent cb0d12ec49
commit 0f36c7e195
3 changed files with 29 additions and 19 deletions

View File

@@ -131,9 +131,7 @@ static MPP_RET mpi_reset(MppCtx ctx)
MpiImpl *p = (MpiImpl *)ctx;
MPP_RET ret = MPP_OK;
MPI_FUNCTION_ENTER();
if (p->ctx->mInitDone) {
ret = p->ctx->reset();
}
ret = p->ctx->reset();
MPI_FUNCTION_LEAVE();
return ret;
}

View File

@@ -50,14 +50,14 @@ Mpp::Mpp()
mThreadHal(NULL),
mDec(NULL),
mEnc(NULL),
mFastMode(0),
mInitDone(0),
mType(MPP_CTX_BUTT),
mCoding(MPP_VIDEO_CodingUnused),
mInitDone(0),
mPacketBlock(0),
mOutputBlock(0),
mMultiFrame(0),
mStatus(0)
mStatus(0),
mFastMode(0)
{
}
@@ -305,11 +305,21 @@ MPP_RET Mpp::control(MpiCmd cmd, MppParam param)
MPP_RET Mpp::reset()
{
MppPacket mpkt = NULL;
RK_U32 flags = 0;
if (!mInitDone)
return MPP_OK;
MppPacket pkt = NULL;
/*
* On mp4 case extra data of sps/pps will be put at the beginning
* If these packet was reset before they are send to decoder then
* decoder can not get these important information to continue decoding
* To avoid this case happen we need to save it on reset beginning
* then restore it on reset end.
*/
mPackets->lock();
if (mPackets->list_size()) {
mPackets->del_at_head(&mpkt, sizeof(mpkt));
mPackets->del_at_head(&pkt, sizeof(pkt));
}
mPackets->flush();
mPackets->unlock();
@@ -330,15 +340,17 @@ MPP_RET Mpp::reset()
mpp_enc_reset(mEnc);
}
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);
if (pkt != NULL) {
RK_U32 flags = mpp_packet_get_flag(pkt);
if (flags & MPP_PACKET_FLAG_EXTRA_DATA) {
put_packet(pkt);
}
mpp_packet_deinit(&mpkt);
mpkt = NULL;
mpp_packet_deinit(&pkt);
pkt = NULL;
}
return MPP_OK;
}

View File

@@ -101,20 +101,20 @@ public:
MppDec *mDec;
MppEnc *mEnc;
RK_U32 mFastMode;
RK_U32 mInitDone;
private:
void clear();
MppCtxType mType;
MppCodingType mCoding;
RK_U32 mInitDone;
RK_U32 mPacketBlock;
RK_U32 mOutputBlock;
RK_U32 mMultiFrame;
RK_U32 mStatus;
RK_U32 mFastMode;
Mpp(const Mpp &);
Mpp &operator=(const Mpp &);