📄 umc_h264_dec_defs_yuv.cpp
字号:
/*//// 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_defs_yuv.h"#include "ippvc.h"IppStatus ippiExpandPlane_H264 (Ipp8u *StartPtr, Ipp32u uFrameWidth, Ipp32u uFrameHeight, Ipp32u uPitch, Ipp32u uPels, IppvcFrameFieldFlag uFrameFieldFlag){ Ipp32u i; Ipp8u *pSrc, *pSrcDst, *pDst; /* check error(s) */ if ((uFrameHeight & 1) || (2 > uFrameHeight)) return ippStsSizeErr; if (0 == uFrameWidth) return ippStsSizeErr; if (0 == uPels) return ippStsNoErr; switch (uFrameFieldFlag) { case IPPVC_FRAME:#if 0 /* Area (1) - bottom */ pSrc = StartPtr + uPitch * (uFrameHeight - 1); pDst = pSrc + uPitch; for (i = 0; i < uPels*2; i++) { ippsCopy_8u(pSrc, pDst, uFrameWidth); pDst += uPitch; }#endif /* Area (2) - sides */ pSrcDst = StartPtr; for (i = 0; i < uFrameHeight + uPels; i += 1) { /* set left site */ ippsSet_8u(pSrcDst[0], pSrcDst - uPels, uPels); /* set right site */ ippsSet_8u(pSrcDst[uFrameWidth - 1], pSrcDst + uFrameWidth, uPels); pSrcDst += uPitch; }#if 0 /* Area (3) - top */ pSrc = StartPtr - uPels; pDst = pSrc - uPitch; for (i = 0; i < uPels*2; i++) { ippsCopy_8u(pSrc, pDst, uFrameWidth + 2*uPels); pDst -= uPitch; }#endif break; case IPPVC_TOP_FIELD:#if 0 /* Area (1) - bottom */ pSrc = StartPtr + uPitch * (uFrameHeight - 2); pDst = pSrc + uPitch * 2; for (i = 0; i < uPels; i++) { ippsCopy_8u(pSrc, pDst, uFrameWidth); pDst += uPitch * 2; }#endif /* Area (2) - sides */ pSrcDst = StartPtr; for (i = 0; i < (uFrameHeight>>1) + uPels; i++) { /* set left site */ ippsSet_8u(pSrcDst[0], pSrcDst - uPels, uPels); /* set right site */ ippsSet_8u(pSrcDst[uFrameWidth - 1], pSrcDst + uFrameWidth, uPels); pSrcDst += uPitch * 2; }#if 0 /* Area (3) - top */ pSrc = StartPtr - uPels; pDst = pSrc - uPitch * 2; for (i = 0; i < uPels; i++) { ippsCopy_8u(pSrc, pDst, uFrameWidth + 2 * uPels); pDst -= uPitch * 2; }#endif break; case IPPVC_BOTTOM_FIELD:#if 0 /* Area (1) - bottom */ pSrc = StartPtr + uPitch * (uFrameHeight - 1); pDst = pSrc + uPitch * 2; for (i = 0; i < uPels ; i++) { ippsCopy_8u(pSrc, pDst, uFrameWidth); pDst += uPitch * 2; }#endif /* Area (2) - sides */ pSrcDst = StartPtr + uPitch; for (i = 0; i < (uFrameHeight>>1) + uPels; i++) { /* set left site */ ippsSet_8u(pSrcDst[0], pSrcDst - uPels, uPels); /* set right site */ ippsSet_8u(pSrcDst[uFrameWidth - 1], pSrcDst + uFrameWidth, uPels); pSrcDst += uPitch * 2; }#if 0 /* Area (3) - top */ pSrc = StartPtr - uPels + uPitch; pDst = pSrc - uPitch * 2; for (i = 0; i < uPels; i++) { ippsCopy_8u(pSrc, pDst, uFrameWidth + 2 * uPels); pDst -= uPitch * 2; }#endif break; default: return ippStsBadArgErr; } return ippStsNoErr;} /* IPPFUN(IppStatus, ippiExpandPlane_H264_8u_C1R, (Ipp8u *StartPtr, */namespace UMC{H264DecYUVBufferPadded::H264DecYUVBufferPadded() : m_pAllocatedBuffer(0) , m_allocatedSize(0) , m_pBuffer(0) , m_lumaSize(0, 0) , m_pitch(0){}H264DecYUVBufferPadded::~H264DecYUVBufferPadded(){ deallocate();}void H264DecYUVBufferPadded::deallocate(){ m_allocatedSize = 0; m_pBuffer = 0; clear(); m_lumaSize = sDimensions(0, 0); m_pitch = 0; if (m_pAllocatedBuffer) { ippsFree(m_pAllocatedBuffer); m_pAllocatedBuffer = 0; }}void H264DecYUVBufferPadded::conditionalDeallocate(const sDimensions &dim){ if (dim != lumaSize()) deallocate();}enum{ DATA_ALIGN = 64, LUMA_PADDING = YUV_Y_PADDING * 2, CHROMA_PADDING = YUV_Y_PADDING};Status H264DecYUVBufferPadded::allocate(const sDimensions &lumaSize){ Ipp32u newSize; Ipp32u nPitch; // Y plane dimensions better be even, so width/2 correctly gives U,V size // YUV_ALIGNMENT must be a power of 2. Since this is unlikely to change, // and since checking for a power of 2 is painful, let's just put a simple // VM_ASSERT here, that can be updated as needed for other powers of 2. nPitch = align_value<Ipp32u> (lumaSize.width + LUMA_PADDING * 2, DATA_ALIGN); newSize = nPitch * (lumaSize.height + LUMA_PADDING * 2) + nPitch * (lumaSize.height / 2 + CHROMA_PADDING * 2); if (m_pAllocatedBuffer) ippsFree(m_pAllocatedBuffer); m_pAllocatedBuffer = (Ipp8u *) ippsMalloc_8u(MAX(1, newSize + DATA_ALIGN * 2)); if (!m_pAllocatedBuffer) { // Reset all our state variables deallocate(); return UMC_ALLOC; } m_allocatedSize = newSize; m_lumaSize = lumaSize; m_pitch = nPitch; m_pYPlane = align_pointer<Ipp8u *> (m_pAllocatedBuffer + LUMA_PADDING * (1 + nPitch), DATA_ALIGN); m_pUPlane = align_pointer<Ipp8u *> (m_pAllocatedBuffer + nPitch * (lumaSize.height + LUMA_PADDING * 2) + CHROMA_PADDING * (1 + nPitch), DATA_ALIGN); m_pVPlane = m_pUPlane + nPitch / 2; return UMC_OK;}// The algorithm fills in (1) the bottom (not including corners),// then (2) the sides (including the bottom corners, but not the// top corners), then (3) the top (including the top// corners) as shown below, replicating the outermost bytes// of the original frame outward://// ----------------------------// | |// | (3) |// | |// |----------------------------|// | | | |// | | | |// | | | |// | | original | |// | | frame | |// | | | |// | (2) | | (2) |// | | | |// | | | |// | |----------------| |// | | | |// | | (1) | |// | | | |// ----------------------------StatusH264DecYUVWorkSpace::allocate(const sDimensions &lumaSize){ sDimensions paddedSize; // rounded up to an integral number of macroblocks paddedSize.width = (lumaSize.width + 15) & ~15; paddedSize.height = (lumaSize.height + 15) & ~15; clearState(); Status ps = H264DecYUVBufferPadded::allocate(paddedSize); if (ps == UMC_OK) { m_macroBlockSize.width = paddedSize.width >> 4; m_macroBlockSize.height = paddedSize.height >> 4; //m_subBlockSize.width = m_macroBlockSize.width << 2; //m_subBlockSize.height = m_macroBlockSize.height << 2; } return ps;}voidH264DecYUVWorkSpace::conditionalDeallocate(const sDimensions &dim){ sDimensions paddedSize; // rounded up to an integral number of macroblocks paddedSize.width = (dim.width + 15) & ~15; paddedSize.height = (dim.height + 15) & ~15; H264DecYUVBufferPadded::conditionalDeallocate(paddedSize);}voidH264DecYUVWorkSpace::expand(bool is_field_flag, Ipp8u is_bottom_field){ IppvcFrameFieldFlag flag; if(!is_field_flag) { flag = IPPVC_FRAME; } else { if(!is_bottom_field) { flag = IPPVC_TOP_FIELD; } else { flag = IPPVC_BOTTOM_FIELD; } } if (!isExpanded()) { ippiExpandPlane_H264(m_pYPlane, lumaSize().width, lumaSize().height, pitch(), YUV_Y_PADDING, //MIN(YUV_Y_PADDING, ((D_MV_CLIP_LIMIT+7)&~7)), flag); ippiExpandPlane_H264(m_pVPlane, lumaSize().width >> 1, lumaSize().height >> 1, pitch(), YUV_UV_PADDING, //MIN(YUV_UV_PADDING, ((D_MV_CLIP_LIMIT/2+7)&~7)), flag); ippiExpandPlane_H264(m_pUPlane, lumaSize().width >> 1, lumaSize().height >> 1, pitch(), YUV_UV_PADDING, //MIN(YUV_UV_PADDING, ((D_MV_CLIP_LIMIT/2+7)&~7)), flag); //setExpanded(); }}} // end namespace UMC
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -