📄 umc_mpeg4_video_decoder.cpp
字号:
status = UMC_NOT_ENOUGH_DATA; break; } if ((m_Param.lFlags & FLAG_VDEC_REORDER) && (m_decInfo->VisualObject.vFrame == NULL)) { // buffer first frame in VDEC_REORDER mode status = UMC_NOT_ENOUGH_DATA; break; } if (!(m_Param.lFlags & FLAG_VDEC_REORDER)) m_decInfo->VisualObject.vFrame = &m_decInfo->VisualObject.cFrame; } if (out) { VideoData* pOutVideoData = DynamicCast<VideoData>(out); FrameType ft; if (m_decInfo->VisualObject.VideoObject.sprite_enable == MP4_SPRITE_STATIC) ft = I_PICTURE; else ft = (m_decInfo->VisualObject.vFrame->type) == MP4_VOP_TYPE_I ? I_PICTURE : (m_decInfo->VisualObject.vFrame->type) == MP4_VOP_TYPE_B ? B_PICTURE : P_PICTURE; pOutVideoData->SetFrameType(ft); // set source pointer(s) m_Convert.lpSource0 = m_decInfo->VisualObject.vFrame->pY; m_Convert.lpSource2 = m_decInfo->VisualObject.vFrame->pCb; m_Convert.lpSource1 = m_decInfo->VisualObject.vFrame->pCr; m_Convert.PitchSource0 = m_decInfo->VisualObject.vFrame->stepY; m_Convert.PitchSource2 = m_decInfo->VisualObject.vFrame->stepCb; m_Convert.PitchSource1 = m_decInfo->VisualObject.vFrame->stepCr; m_Convert.lpDest0 = (Ipp8u*)pOutVideoData->m_lpDest[0]; m_Convert.lpDest1 = (Ipp8u*)pOutVideoData->m_lpDest[1]; m_Convert.lpDest2 = (Ipp8u*)pOutVideoData->m_lpDest[2]; m_Convert.PitchDest0 = pOutVideoData->m_lPitch[0]; m_Convert.PitchDest1 = pOutVideoData->m_lPitch[1]; m_Convert.PitchDest2 = pOutVideoData->m_lPitch[2]; if (NULL != m_pConverter) { status = m_pConverter->ConvertFrame(&m_Convert); } else { pOutVideoData->SetDest(m_Convert.lpSource0, m_Convert.lpSource1, m_Convert.lpSource2); pOutVideoData->SetPitch(m_Convert.PitchSource0, m_Convert.PitchSource1, m_Convert.PitchSource2); } } break; } if (in) if (in->GetTime() >= 0.0 && m_dec_time_base < 0.0) m_dec_time_base = in->GetTime(); if (m_Param.lFlags & FLAG_VDEC_REORDER) { if ((m_decInfo->ftype == 2 && m_dec_time_frinc > 0.0) || (m_decInfo->ftype == 1)) { // for AVI the splitter's PTS and fixed framerate is used // for MP4 the splitter's PTS is used (only I-P- frames, it might not works for MP4 with B-frames) if (in) if (in->GetTime() >= 0.0 && m_dec_time_prev < 0.0) m_dec_time_prev = in->GetTime(); pts = m_dec_time_prev; if (in) { if (in->GetTime() >= 0.0) { // take right PTS for I-, P- frames in decoded order m_dec_time_prev = in->GetTime(); } else { // when PBB... are in one chunk, first PTS from in->GetTime() is right and other are -1.0 m_dec_time_prev += m_dec_time_frinc; } } } else { if (m_Param.info.framerate > 0) { // for (XVID, 3IVX) fixed framerate streams is used (can be joint to stream_subtype == MPEG4_VIDEO_DIVX5) if (in) if (in->GetTime() >= 0.0 && m_dec_time_prev < 0.0) m_dec_time_prev = in->GetTime(); pts = m_dec_time_prev; if (in) { if (in->GetTime() >= 0.0) { // take right PTS for I-, P- frames in decoded order m_dec_time_prev = in->GetTime(); } else { // when PBB... are in one chunk, first PTS from in->GetTime() is right and other are -1.0 m_dec_time_prev += m_dec_time_frinc; } } } else { // for other internal MPEG-4 PTS is used (assume that splitter can not provide right PTS in in->GetTime) if (m_decInfo->VisualObject.vFrame) pts = (double)m_decInfo->VisualObject.vFrame->time / m_decInfo->VisualObject.VideoObject.vop_time_increment_resolution; else { pts = 0.0; } if (m_dec_time_base >= 0.0) pts += m_dec_time_base; } } } else { if (m_decInfo->ftype == 1) { // for MP4 the splitter's PTS is used (only I-P- frames, it might not works for MP4 with B-frames) if (in) pts = in->GetTime(); else { pts = (double)m_decInfo->VisualObject.vFrame->time / m_decInfo->VisualObject.VideoObject.vop_time_increment_resolution; if (m_dec_time_base >= 0.0) pts += m_dec_time_base; } } else { // for other internal MPEG-4 PTS is used (because there is some problem with B-frames) pts = (double)m_decInfo->VisualObject.vFrame->time / m_decInfo->VisualObject.VideoObject.vop_time_increment_resolution; if (m_dec_time_base >= 0.0) pts += m_dec_time_base; } } if (out) out->SetTime(pts); if (in) { size_t stDecidedData; if ((size_t)m_decInfo->bufptr - (size_t)m_decInfo->buffer < m_decInfo->buflen) stDecidedData = m_decInfo->buflen - ((size_t)m_decInfo->bufptr - (size_t)m_decInfo->buffer); else stDecidedData = 0; in->MoveDataPointer(in->GetDataSize() - static_cast<vm_var32>(stDecidedData)); // can't calculate time for the next frame in->SetTime(-1.0); } // set interlaced info if (!m_decInfo->VisualObject.VideoObject.interlaced) m_Param.info.interlace_type = PROGRESSIVE; else m_Param.info.interlace_type = (m_decInfo->VisualObject.VideoObject.VideoObjectPlane.top_field_first) ? INTERLEAVED_TOP_FIELD_FIRST : INTERLEAVED_BOTTOM_FIELD_FIRST; return status;}Status MPEG4VideoDecoder::GetInfo(BaseCodecParams *lpInfo){ Status umcRes = UMC_OK; VideoDecoderParams *lpParams = DynamicCast<VideoDecoderParams> (lpInfo);// if (!m_IsInit)// return UMC_NOT_INITIALIZED; if (NULL == lpParams) return UMC_NULL_PTR; umcRes = VideoDecoder::GetInfo(lpInfo); if (UMC_OK == umcRes) { lpParams->info = m_Param.info; if (NULL != m_pConverter) { lpParams->info.clip_info.width = m_Convert.ConversionInit.SizeDest.width; lpParams->info.clip_info.height = m_Convert.ConversionInit.SizeDest.height; } } return umcRes;}Status MPEG4VideoDecoder::Close(void){ if (m_IsInit) { mp4_FreeVOL(m_decInfo); m_IsInit = false; return UMC_OK; } else return UMC_NOT_INITIALIZED;}MPEG4VideoDecoder::MPEG4VideoDecoder(void){ m_IsInit = false; m_decInfo = new mp4_Info;}MPEG4VideoDecoder::~MPEG4VideoDecoder(void){ Close(); delete m_decInfo;}Status MPEG4VideoDecoder::ResetSkipCount(){ return UMC_NOT_IMPLEMENTED;}Status MPEG4VideoDecoder::SkipVideoFrame(int count){ if (!m_IsInit) return UMC_NOT_INITIALIZED; if (count < 0) { m_is_skipped_b = 0; return UMC_OK; } m_is_skipped_b += count; return UMC_OK;}vm_var32 MPEG4VideoDecoder::GetSkipedFrame(void){ return m_skipped_fr;}Status MPEG4VideoDecoder::Reset(void){ if (!m_IsInit) return UMC_NOT_INITIALIZED; else return UMC_OK;}Status MPEG4VideoDecoder::GetPerformance(double *perf){ return UMC_NOT_IMPLEMENTED;}mp4_Frame* MPEG4VideoDecoder::GetCurrentFramePtr(void){ return m_decInfo->VisualObject.vFrame;} // MPEG4VideoDecoder::GetCurrentFramePtr()} // end namespace UMC
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -