📄 umc_h264_enc_cpb.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 - 2007 Intel Corporation. All Rights Reserved.
//
#ifndef __UMC_H264_ENC_CPB_H__
#define __UMC_H264_ENC_CPB_H__
#include "umc_memory_allocator.h"
#include "umc_h264_pub.h"
#include "vm_debug.h"
namespace UMC_H264_ENCODER
{
template <class PixType> class H264EncoderFrame;
//template <class PixType> void exchangeFrameYUVPointers( H264EncoderFrame<PixType>* frame1, H264EncoderFrame<PixType>* frame2 );
template <class PixType> class H264EncoderFrame : public VideoData
{
// These point to the previous and future reference frames
// used to decode this frame.
// These are also used to maintain a doubly-linked list of
// reference frames in the H264EncoderFrameList class. So, these
// may be non-NULL even if the current frame is an I frame,
// for example. m_pPreviousFrame will always be valid when
// decoding a P or B frame, and m_pFutureFrame will always
// be valid when decoding a B frame.
public:
Ipp64f pts_start;
Ipp64f pts_end;
// L0 and L1 refer to RefList 0 and RefList 1 in JVT spec.
// In this implementation, L0 is Forward MVs in B slices, and all MVs in P slices
// L1 is Backward MVs in B slices and unused in P slices.
H264GlobalMacroblocksDescriptor m_mbinfo;
#if defined ALPHA_BLENDING_H264
H264GlobalMacroblocksDescriptor m_mbinfo_alpha;
H264GlobalMacroblocksDescriptor m_mbinfo_prim;
#endif
Ipp32u uWidth;
Ipp32u uHeight;
H264EncoderFrame<PixType> *m_pPreviousFrame;
H264EncoderFrame<PixType> *m_pFutureFrame;
bool m_wasEncoded;
public:
//Description of picture, NULL if no picture
PixType *m_pYPlane;
PixType *m_pUPlane;
PixType *m_pVPlane;
//Frame Data
IppiSize m_lumaSize;
Ipp32u m_pitchPixels;
Ipp32u m_pitchBytes;
Ipp8u m_PictureStructureForRef;
Ipp8u m_PictureStructureForDec;
EnumSliceType m_SlicesType;
EnumPicCodType m_PicCodType;
Ipp32s m_RefPic;
Ipp32s totalMBs;
// For type 1 calculation of m_PicOrderCnt. m_FrameNum is needed to
// be used as previous frame num.
Ipp32s m_PicNum[2];
Ipp32s m_LongTermPicNum[2];
Ipp32s m_FrameNum;
Ipp32s m_FrameNumWrap;
Ipp32s m_LongTermFrameIdx;
Ipp32s m_RefPicListResetCount[2];
Ipp32s m_PicOrderCnt[2]; // Display order picture count mod MAX_PIC_ORDER_CNT.
Ipp32u m_PicOrderCounterAccumulated; // Display order picture counter, but with compensation of IDR POC resets.
Ipp32s m_crop_left;
Ipp32s m_crop_right;
Ipp32s m_crop_top;
Ipp32s m_crop_bottom;
Ipp8s m_crop_flag;
bool m_isShortTermRef[2];
bool m_isLongTermRef[2];
//Ipp32u m_FrameNum; // Decode order frame label, from slice header
Ipp8u m_PQUANT; // Picture QP (from first slice header)
Ipp8u m_PQUANT_S; // Picture QS (from first slice header)
IppiSize m_dimensions;
Ipp8u m_bottom_field_flag[2];
// The above variables are used for management of reference frames
// on reference picture lists maintained in m_RefPicList. They are
// updated as reference picture management information is decoded
// from the bitstream. The picture and frame number variables determine
// reference picture ordering on the lists.
friend void exchangeFrameYUVPointers( H264EncoderFrame<PixType>* frame1, H264EncoderFrame<PixType>* frame2 )
{
PixType* tmp1;
PixType* tmp2;
PixType* tmp3;
MemID id_tmp;
Ipp8u* tmp;
Ipp32s i;
tmp1 = frame1->m_pYPlane;
tmp2 = frame1->m_pUPlane;
tmp3 = frame1->m_pVPlane;
frame1->m_pYPlane = frame2->m_pYPlane;
frame1->m_pUPlane = frame2->m_pUPlane;
frame1->m_pVPlane = frame2->m_pVPlane;
frame2->m_pYPlane = tmp1;
frame2->m_pUPlane = tmp2;
frame2->m_pVPlane = tmp3;
id_tmp = frame1->frameDataID;
frame1->frameDataID = frame2->frameDataID;
frame2->frameDataID = id_tmp;
tmp = frame1->frameData;
frame1->frameData = frame2->frameData;
frame2->frameData = tmp;
for( i=0; i < frame1->GetNumPlanes(); i++ ){
void* tmp = frame1->GetPlanePointer( i );
frame1->SetPlanePointer( frame2->GetPlanePointer(i), i );
frame2->SetPlanePointer( tmp, i );
}
return;
}
private:
MemoryAllocator* memAlloc;
MemID frameDataID;
MemID mbsDataID;
MemID refListDataID;
Ipp8u *frameData;
Ipp8u *mbsData;
Ipp8u *refListData;
public:
H264EncoderFrame( VideoData* ref, MemoryAllocator *pMemAlloc
#if defined ALPHA_BLENDING_H264
, Ipp32s alpha
#endif
, Ipp32s downScale = 0
);
virtual ~H264EncoderFrame();
void SetPicCodType(EnumPicCodType pic_type) {m_PicCodType = pic_type;}
virtual Status allocate(const IppiSize & paddedSize, Ipp32s num_slices);
Ipp32u pitchPixels() { return m_pitchPixels; }
Ipp32u pitchBytes() { return m_pitchBytes; }
// The following methods provide access to the H264Decoder's doubly
// linked list of H264EncoderFrames. Note that m_pPreviousFrame can
// be non-NULL even for an I frame.
H264EncoderFrame<PixType> *previous() { return m_pPreviousFrame; }
H264EncoderFrame<PixType> *future() { return m_pFutureFrame; }
void setPrevious(H264EncoderFrame<PixType> *pPrev)
{
m_pPreviousFrame = pPrev;
}
void setFuture(H264EncoderFrame<PixType> *pFut)
{
m_pFutureFrame = pFut;
}
bool wasEncoded() { return m_wasEncoded; }
void setWasEncoded() { m_wasEncoded = true; }
void unsetWasEncoded() { m_wasEncoded = false; }
bool isDisposable()
{
return (!m_isShortTermRef[0] &&
!m_isShortTermRef[1] &&
!m_isLongTermRef[0] &&
!m_isLongTermRef[0] &&
m_wasEncoded );
}
// A decoded frame can be "disposed" if it is not an active reference
// and it is not locked by the calling application and it has been
// output for display.
Ipp32s PicNum(Ipp8u f,Ipp8u force=0)
{
if ((m_PictureStructureForRef>=FRM_STRUCTURE && force==0) || force==3)
{
return MIN(m_PicNum[0],m_PicNum[1]);
}
else if (force==2)
{
if (isShortTermRef(0) && isShortTermRef(1)) return MIN(m_PicNum[0],m_PicNum[1]);
else if (isShortTermRef(0)) return m_PicNum[0];
else return m_PicNum[0];
}
return m_PicNum[f];
}
void setPicNum(Ipp32s PicNum,Ipp8u f)
{
if (m_PictureStructureForRef>=FRM_STRUCTURE)
{
m_PicNum[0] = m_PicNum[1]=PicNum;
}
else
m_PicNum[f] = PicNum;
}
// Updates m_LongTermPicNum for if long term reference, based upon
// m_LongTermFrameIdx.
Ipp32s FrameNum()
{
return m_FrameNum;
}
void setFrameNum(Ipp32s FrameNum)
{
m_FrameNum = FrameNum;
}
Ipp32s FrameNumWrap()
{
return m_FrameNumWrap;
}
void setFrameNumWrap(Ipp32s FrameNumWrap)
{
m_FrameNumWrap = FrameNumWrap;
}
void UpdateFrameNumWrap(Ipp32s CurrFrameNum, Ipp32s MaxFrameNum, Ipp32s CurrPicStruct);
// Updates m_FrameNumWrap and m_PicNum if the frame is a short-term
// reference and a frame number wrap has occurred.
Ipp32s LongTermFrameIdx()
{
return m_LongTermFrameIdx;
}
void setLongTermFrameIdx(Ipp32s LongTermFrameIdx)
{
m_LongTermFrameIdx = LongTermFrameIdx;
}
bool isShortTermRef(Ipp32s WhichField)
{
if (m_PictureStructureForRef>=FRM_STRUCTURE )
return m_isShortTermRef[0] && m_isShortTermRef[1];
else
return m_isShortTermRef[WhichField];
}
Ipp8u isShortTermRef()
{
return m_isShortTermRef[0] + m_isShortTermRef[1]*2;
}
void SetisShortTermRef(Ipp32s WhichField)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -