/*
//
// INTEL CORPORATION PROPRIETARY INFORMATION
// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Intel Corporation and may not be copied
// or disclosed except in accordance with the terms of that agreement.
// Copyright (c) 2003-2005 Intel Corporation. All Rights Reserved.
//
//
*/
#include "umc_h264_dec.h"
#include "umc_h264_deblocking_tools.h"
#include "umc_h264_dec_conversion.h"
#include "umc_video_data.h"
#include "umc_media_data_ex.h"
#include "umc_color_space_converter.h"
#include "vm_debug.h"
#include "vm_sys_info.h"
namespace UMC
{
enum
{
ALIGN_VALUE = 16
};
H264VideoDecoder::H264DecoderFrame::H264DecoderFrame()
: m_pPreviousFrame(0)
, m_pFutureFrame(0)
, m_cumulativeTR(0.0)
, m_wasOutputted(false)
, m_isDisplayable(false)
, m_lockedForDisplay(false)
// , m_FrameNum((unsigned)-1)
, m_bIsIDRPic(false)
, m_pParsedFrameData(0)
, m_paddedParsedFrameDataSize(sDimensions(0,0))
, m_pRefPicList(0)
, m_num_slice_start(0)
, m_wasDisplayed(false)
, m_dFrameTime(-1.0)
{
m_pParsedFrameDataNew = NULL;
m_isShortTermRef[0] = m_isShortTermRef[1] = false;
m_isLongTermRef[0] = m_isLongTermRef[1] = false;
m_FrameNumWrap = m_FrameNum = -1;
m_LongTermFrameIdx = -1;
m_RefPicListResetCount[0] = m_RefPicListResetCount[1] = 0;
m_PicNum[0] = m_PicNum[1] = -1;
m_LongTermPicNum[0] = m_PicNum[1] = -1;
}
void
H264VideoDecoder::H264DecoderFrame::deallocateParsedFrameData()
{
if (m_pParsedFrameData)
{
// Free the old buffer.
ippsFree(m_pParsedFrameData);
m_pParsedFrameData = 0;
m_pRefPicList = 0;
}
// new structure(s) hold pointer
if (m_pParsedFrameDataNew)
{
ippsFree(m_pParsedFrameDataNew);
m_pParsedFrameDataNew = NULL;
}
m_paddedParsedFrameDataSize = sDimensions(0,0);
} // deallocateParsedFrameData
Status
H264VideoDecoder::H264DecoderFrame::allocateParsedFrameData(const sDimensions &size)
{
Status ps = UMC_OK;
sDimensions desiredPaddedSize;
desiredPaddedSize.width = (size.width + 15) & ~15;
desiredPaddedSize.height = (size.height + 15) & ~15;
// If our buffer and internal pointers are already set up for this
// image size, then there's nothing more to do.
if (m_paddedParsedFrameDataSize != desiredPaddedSize)
{
//
// Determine how much space we need
//
Ipp32u MB_Frame_Width = desiredPaddedSize.width >> 4;
Ipp32u MB_Frame_Height = desiredPaddedSize.height >> 4;
// Ipp32u Sub_Block_Width = MB_Frame_Width << 2;
// Ipp32u Sub_Block_Height = MB_Frame_Height << 2;
Ipp32u uMaxNumSlices = MAX_SLICE_NUM <0?MB_Frame_Width * MB_Frame_Height:MIN(MAX_SLICE_NUM,MB_Frame_Width * MB_Frame_Height);
Ipp32u uRefPicListSize = uMaxNumSlices * sizeof(H264DecoderRefPicList);
Ipp32u totalSize = Ipp32u(
+ uRefPicListSize + 7
+ YUV_ALIGNMENT);
deallocateParsedFrameData();
int len = MAX(1, totalSize);
m_pParsedFrameData = ippsMalloc_8u(len);
if (!m_pParsedFrameData)
return UMC_FAILED_TO_ALLOCATE_BUFFER;
ippsZero_8u(m_pParsedFrameData, len);
// Reassign our internal pointers
{
m_paddedParsedFrameDataSize = desiredPaddedSize;
Ipp8u *pAlignedParsedData;
Ipp32u offset = 0;
pAlignedParsedData = _ALIGN(m_pParsedFrameData, YUV_ALIGNMENT);
// align to 8-byte boundary
if (offset & 0x7)
offset = (offset + 7) & ~7;
m_pRefPicList = (H264DecoderRefPicList*)(pAlignedParsedData + offset);
offset += uRefPicListSize;
VM_ASSERT(offset <= totalSize);
}
// allocate new MB structure(s)
{
size_t nMBCount = (desiredPaddedSize.width>>4) * (desiredPaddedSize.height>>4);
// allocate buffer
int len = (sizeof(H264DecoderMacroblockMVs) +
sizeof(H264DecoderMacroblockMVs) +
sizeof(H264DecoderMacroblockRefIdxs) +
sizeof(H264DecoderMacroblockRefIdxs) +
sizeof(H264DecoderMacroblockGlobalInfo)) * nMBCount + 16 * 5;
// allocate buffer
m_pParsedFrameDataNew = ippsMalloc_8u(len);
if (NULL == m_pParsedFrameDataNew)
return UMC_FAILED_TO_ALLOCATE_BUFFER;
ippsZero_8u(m_pParsedFrameDataNew, len);
// set pointer(s)
m_mbinfo.MV[0] = align_pointer<H264DecoderMacroblockMVs *> (m_pParsedFrameDataNew, ALIGN_VALUE);
m_mbinfo.MV[1] = align_pointer<H264DecoderMacroblockMVs *> (m_mbinfo.MV[0]+ nMBCount, ALIGN_VALUE);
m_mbinfo.RefIdxs[0] = align_pointer<H264DecoderMacroblockRefIdxs *> (m_mbinfo.MV[1] + nMBCount, ALIGN_VALUE);
m_mbinfo.RefIdxs[1] = align_pointer<H264DecoderMacroblockRefIdxs *> (m_mbinfo.RefIdxs[0] + nMBCount, ALIGN_VALUE);
m_mbinfo.mbs = align_pointer<H264DecoderMacroblockGlobalInfo *> (m_mbinfo.RefIdxs[1] + nMBCount, ALIGN_VALUE);
}
}
return ps;
} // H264VideoDecoder::H264DecoderFrame::allocateParsedFrameData(const sDimensions &size)
H264VideoDecoder::H264DecoderFrame::~H264DecoderFrame()
{
// Just to be safe.
m_pPreviousFrame = 0;
m_pFutureFrame = 0;
deallocateParsedFrameData();
}
Status
H264VideoDecoder::H264DecoderFrame::allocate(const sDimensions &lumaSize)
{
Status ps = UMC_OK;
// Clear our state, since allocate is called when we are about
// to decode into this frame buffer.
m_wasOutputted = false;
m_isDisplayable = false;
m_cumulativeTR = 0.0;
m_dimensions = lumaSize;
// Don't reset m_activeReference or m_lockedForDisplay as these are handled
// depending on frame type or by the calling application, respectively
ps = allocateParsedFrameData(lumaSize);
if (ps == UMC_OK)
ps = H264DecYUVWorkSpace::allocate(lumaSize);
return ps;
}
//////////////////////////////////////////////////////////////////////////////
// H264Decoder constructor
//////////////////////////////////////////////////////////////////////////////
H264VideoDecoder::H264VideoDecoder ()
:m_pBitStream(0)
, m_initialTR(0.0)
, m_bIsDecodingStarted(false)
#ifdef USE_SEI
, m_FrameProcessingStage(0)
#endif
, m_pCurrentFrame(0)
, m_pDisplayFrame(0)
, m_pParsedData(0)
, m_pParsedDataNew(0)
, m_parsedDataLength(0)
, m_pMBIntraTypes(0)
, m_field_index(0)
, m_broken_buffer(0)
, m_broken_buffer_start_mb(0)
, m_broken_buffer_start_slice(0)
, m_pCoeffBlocksWrite(0)
, m_pCoeffBlocksRead(0)
, m_bSeqParamSetRead(false)
, m_bPicParamSetRead(false)
, m_CurrentSeqParamSet(-1)
, m_CurrentPicParamSet(-1)
, m_bDPBSizeChanged(false)
, m_dpbSize(1)
, m_bSeqParamSetChanged(true)
, m_getframe_calls(0)
, m_WaitForDR(true)
, m_SkipFlag(0)
,m_SkipCycle(1)
,m_ModSkipCycle(1)
,m_VideoDecodingSpeed(0)
,m_PreviousPicSkipped(false)
{
int i;
m_local_delta_frame_time = 1.0/30;
m_local_frame_time = 0;
m_pConverter = NULL;
for (i=0; i<MAX_NUM_SEQ_PARAM_SETS; i++)
{
m_SeqParamSet[i].poffset_for_ref_frame = NULL;
}
for (i=0; i<MAX_NUM_PIC_PARAM_SETS; i++)
{
m_PicParamSet[i].pFMOMap = NULL;
}
ulResized = 0;
m_uiSwpBuffSize = SWAP_BUFFER_SIZE;
m_nAllocatedLimitedSliceInfo = 0;
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
h264_dec.rar (44个子文件)
h264_dec
readme.htm 7KB
Makefile.win 8KB
build32.bat 3KB
obj_list.ini 1KB
buildwcex86.bat 3KB
include
umc_h264_dec_defs_dec.h 34KB
umc_h264_dec_coeff_token_map.h 24KB
umc_h264_dec_deblocking.h 4KB
umc_h264_dec.h 73KB
umc_h264_dec_run_before.h 13KB
umc_h264_dec_init_tables_cabac.h 4KB
umc_h264_dec_total_zero.h 36KB
umc_h264_dec_defs_yuv.h 9KB
umc_h264_deblocking_tools.h 3KB
umc_h264_dec_tables.h 2KB
umc_h264_dec_ipplevel.h 3KB
umc_h264_dec_conversion.h 770B
umc_h264_dec_internal_cabac.h 3KB
umc_h264_bitstream.h 19KB
buildem64t.bat 3KB
src
umc_h264_dec_tables.cpp 11KB
umc_h264_dec_reconstruct_mb_aff.cpp 48KB
umc_h264_dec_reconstruct_mb.cpp 40KB
umc_h264_deblocking_tools.cpp 10KB
umc_h264_dec_bitstream.cpp 62KB
umc_h264_dec_decode_mb_types.cpp 30KB
umc_h264_dec_ipplevel.cpp 10KB
umc_h264_dec_decode_reconstruct.cpp 145KB
umc_h264_dec_defs_yuv.cpp 10KB
umc_h264_dec_sei.cpp 11KB
umc_h264_dec_decode_cabac.cpp 36KB
umc_h264_dec_decode_pic.cpp 178KB
umc_h264_dec_mblevel_calc.cpp 41KB
umc_h264_dec_decode_mb.cpp 113KB
umc_h264_dec_decode_mb_types_cabac.cpp 41KB
umc_h264_dec_reconstruct_mb_fld.cpp 43KB
umc_h264_dec_conversion.cpp 20KB
umc_h264_dec_deblocking_mbaff.cpp 62KB
umc_h264_dec_decode_mb_cabac.cpp 40KB
umc_h264_dec_deblocking.cpp 112KB
build64.bat 3KB
include.ini 164B
buildwcearmv4i.bat 3KB
www.pudn.com.txt 218B
共 44 条
- 1
资源评论
御道御小黑
- 粉丝: 58
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功