主要解码部分代码
void VideoPlayChannel::Decode()
{
int ret =-1;
int dec_out;
int err_cnt =0;
int dec_cnt =0;
uint32_t length =0;
uint64_t cur_time =0,last_time =0;
uint32_t sleep_time = 0;
if(mDecodeType == DECODE_H265)
{
sleep_time = 40000; // 根据实际情况来
}else
{
sleep_time = mFps==0?33000:1000000/mFps;
}
uint32_t decode_time =1;
uint32_t count = 0;
int n = 0;
ALOGD("%d doDecode start!!!",mIndex);
while(mIsStarted) {
usleep(1000);
decode_time =0;
if(mResetflag) {
if(mDecoder !=NULL) {
mDecoder->close();
mDecoder.clear();
mDecoder =NULL;
}
if(mCodecSurface ==NULL) {
pause();
continue;
}
mDecoder = new MyAvcDecoder(mWidth, mHeight, mCodecSurface, true);
if(mDecoder ==NULL) {
ALOGD("%d decode creat failed",mIndex);
pause();
continue;
}
// init decode engine type;0 is 264 mode, 1 is 265mode
mDecoder->init(mDecodeType);
ALOGD("reset myavcDecoder decode type %d,index %d\n",mDecodeType,mIndex);
ums_pipe_reset(mDecode_pipe);
mNeedIDR =true;
mResetflag =false;
mState =START;
continue;
}
if((ums_pipe_get_used_len(mDecode_pipe) >= 16) && (mState ==START) &&