📄 umc_h264_padd.h
字号:
//// 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) 2004 - 2005 Intel Corporation. All Rights Reserved.//#ifndef YUVDEFS_H__#define YUVDEFS_H__#include "umc_h264_pub.h"namespace UMC{//// Define classes that encapsulate pitched YUV image data.//// The YUVPointers class is simply a struct containing pointers to the// three planes. It has no methods for performing allocation or deallocation// of the planes. However, it has a virtual destructor so that derived class// destructors are guaranteed to be called.class YUVPointers{public: // Allow the plane pointers to be directly accessed Ipp8u *m_pYPlane; Ipp8u *m_pUPlane; Ipp8u *m_pVPlane; // METHODS void clear() { m_pYPlane = m_pUPlane = m_pVPlane = 0; } YUVPointers() { clear(); }virtual ~YUVPointers() { }};// The PaddedYUVBuffer class represents a YUV image laid out in memory such// that there are padding bytes surrounding the three planes. This extra// padding allows pixels at the edge of the planes to be replicated, as// well as facilitating algorithms that need to read or write a few bytes// beyond the end of a line of pixels. The frame is laid out as shown below.//// +---------------------+// | |// | +-----------+ | The amount of padding around the// | | | | U and V planes is half the amount// | | Y | | around the Y plane. The dotted line// | | | | separating the planes is there just// | +-----------+ | to emphasize that the padding around// | | each plane does not overlap the// | . . . . . . . | padding around the other planes.// | . |// | +----+ . +----+ | Note that all three planes have// | | U | . | V | | the same pitch.// | +----+ . +----+ |// +---------------------+//// Note that the class is designed to allow reusing existing buffer space// for a smaller image size. For example, if the frame buffer was originally// allocated to hold a CIF image, and is then adjusted to hold a QCIF image,// then the QCIF Y, U and V planes will reside in or about the upper left// quadrant of the CIF-size frame buffer. Such reuse can result in much// wasted space. If this is undesireable, then the existing large buffer// should be explicitly deallocated prior to allocating the smaller size.//// To be fully general, this class should allow the amount of padding to be// specified via a constructor parameter. However, we don't need such// generality currently. To simplify the class, we will use the hard coded// padding amounts defined below.class PaddedYUVBuffer : public YUVPointers{ Ipp8u *m_pAllocatedBuffer; // m_pAllocatedBuffer contains the pointer returned when // we allocated space for the data. Ipp32u m_allocatedSize; // This is the size with which m_pAllocatedBuffer was allocated. Ipp8u *m_pBuffer; // m_pBuffer is a "YUV_ALIGNMENT"-byte aligned address, pointing // to the beginning of the padded YUV data within // m_pAllocatedBuffer. sDimensions m_lumaSize; // m_lumaSize specifies the dimensions of the Y plane, as // specified when allocate() was most recently called. // // For clarity, it should be noted that in the context of our // codec, these dimensions have typically already been rounded // up to a multiple of 16. However, such rounding is performed // outside of this class. We use whatever dimensions come into // allocate(). Ipp32u m_pitch; // m_pitch is 0 if the buffer hasn't been allocated. // Otherwise it is the current pitch in effect (typically // 2*Y_PADDING + m_lumaSize.width).public: PaddedYUVBuffer();virtual ~PaddedYUVBuffer();virtual Status allocate(const sDimensions &lumaSize); // Reallocate the buffer, if necessary, so that it is large enough // to hold a YUV image of the given dimensions, and set the plane // pointers and pitch appropriately. If the existing buffer is // already big enough, then we reuse it. If this behavior is not // desired, then call deallocate() prior to calling allocate().virtual void deallocate(); // Deallocate the buffer and clear all state information.virtual void conditionalDeallocate(const sDimensions&); // Deallocate the buffer only if its current luma dimensions // differ from those specified in the parameter. const sDimensions &lumaSize() { return m_lumaSize; } Ipp32u pitch() { return m_pitch; }};} //namespace UMC#endif // CYUVEFS_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -