📄 macroblock.h
字号:
/*COPYRIGHT, LICENSE AND WARRANTY INFORMATIONThis software module has been originally developed by Nokia Corporation. Provided that a person, entity or a company willing to use the Software (hereinafter Licensee) comply with all the terms and conditions of this Statement and subject to the limitations set forth in this Statement Nokia grants to such Licensee a non-exclusive, sub-licensable, worldwide, limited license under copyrights owned by Nokia to use the Software for the sole purpose of creating, manufacturing, selling, marketing, or distributing (including the right to make modifications to the Software) a fully compliant decoder implementation (hereinafter "Decoder") of ITU-T Recommendation H.264 / ISO/IEC International Standard 14496-10 and an encoder implementation producing output that is decodable with the Decoder.Nokia retains the ownership of copyrights to the Software. There is no patent nor other intellectual property right of Nokia licensed under this Statement (except the copyright license above). Licensee hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if patent licenses are required, it is their responsibility to acquire the license before utilizing the Software.The license by Nokia is subject to that the Licensee grants to Nokia the non-exclusive, worldwide, royalty-free, perpetual and irrevocable covenant that the Licensee(s) shall not bring a suit before any court or administrative agency or otherwise assert a claim for infringement under the Licensee intellectual property rights that, but for a license, would be infringed by the Software against (a) Nokia or Nokia's Affiliate; or (b) other recipient of a license and covenant not to sue with respect to the Software from Nokia; or (c) contractor, customer or distributor of a party listed above in a or b, which suit or claim is related to the Software or use thereof.The Licensee(s) further agrees to grant a reciprocal license to Nokia (as granted by Nokia to the Licensee(s) on the modifications made by Licensee(s) to the Software. THE SOFTWARE IS PROVIDED "AS IS" AND THE ORIGINAL DEVELOPER DISCLAIMS ANY AND ALL WARRANTIES WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. THOSE INTENDING TO USE THE SOFTWARE ARE EXPRESSLY ADVISED THAT ITS USE MAY INFRINGE EXISTING PATENTS AND BE SUBJECT TO ROYALTY PAYMENTS TO PATENT OWNERS. ANYONE USING THE SOFTWARE ON THE BASIS OF THIS LICENSE AGREES TO OBTAIN THE NECESSARY PERMISSIONS FROM ANY AND ALL APPLICABLE PATENT OWNERS FOR SUCH USE.IN NO EVENT SHALL THE ORIGINAL DEVELOPER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.This copyright, license and warranty information notice must be retained in all copies and derivative works of the Software or substantial portions thereof.*/#ifndef _MACROBLOCK_H_#define _MACROBLOCK_H_#include "globals.h"#include "bitbuffer.h"#include "RefFrame.h"#include "macroblock.h"#include "encparams.h"/* * Structures */typedef struct _macroblock_s{ // position of the macroblock int isLastMb; int idxX, idxY; // index to first block of MB in raster order not in coding order int blkAddr; int mbAddr; // index to this macroblock in raster order // availability flags of the neighboring MBs, and intra MBs int mbAvailMap[4]; int mbAvailMapIntra[4]; // pointers to the current and neighboring macroblocks mbState_s *mbThis; mbState_s *mbLeft; mbState_s *mbUp; mbState_s *mbUpLeft; mbState_s *mbUpRight; // availablility of the up-right and up-left neighboring blocks for i4x4 u_int8 i4x4CornersAvail[4][4]; int8 ipTab[16]; // i4x4Mode transformed, ready to be stored in stream // parameters used in prediction mode decision // minSad should be equal to "minActualSad + lambda * syntaxBits", // syntaxBits is not the same as headerBits, which has more information // except for inter16x16, and MV = 0. A fixed bias is added for this mode int minSad; // minimal SAD, rate constrained, intra/inter int minActualSad; // non-rate constrained SAD, corresponding to minSad int actualIntraSad; // actual intra SAD, non-rate constrained, int actualIntra16x16Sad;// actual intra16x16 SAD, non-rate constrained, int actualIntra4x4Sad;// actual intra4x4 SAD, non-rate constrained, int actualInterSad; // actual inter SAD, non-rate constrained, int intraSyntaxBits; // bits included in intra rate-constrained decision, int interSyntaxBits; // bits included in inter rate-constrained decision, int minMSE; int type; // macroblock type, and prediction mode information int intraType; int intra16x16enabled; int intra16x16mode; int intraModeChroma; int interMode; u_int8 interSubMbModes[4]; int interModeFlags; // coding parameters int numSkipped; int prevQp, qp, qpC, deltaQp; int lambda;#ifndef DISABLE_RDO int rdoLambda, rdoLambdaIntra; // all are derived from qp#endif // These are returned from ME, and may be encoded in the bitstream int numVecs; int16 diffVecs[16][2]; // differential motion vectors u_int8 refIndices[4]; // ref frame indices for up to 4 MB partitions motVec_s skipPredMv; // predictor for 16x16 MB skipping int skipPredMvValid; // these are for motion vector prediction blkState_s surround[10]; blkState_s current[4][4]; blkState_s *blkLeft[16]; blkState_s *blkUp[16]; blkState_s *blkUpRight[3][16]; // 16 MV-ref pairs for one macroblock, for each mode // index 0 is reserved for MOT_COPY blkState_s modeMvRef[MOT_8x8 + 1][16]; motVec_s skipMVs[4][16]; // store additional MVs for tree-pruning // for test encoding bitbuffer_s mbBs; // for test purpose int headerBits; // corresponding positions in reco buffer for current MB u_int8 *recoY; u_int8 *recoU; u_int8 *recoV; u_int8 origY[MBK_SIZE][MBK_SIZE]; u_int8 origC[MBK_SIZE/2][2*(MBK_SIZE/2)]; // partial sum of the luma of a macroblock int partSums4x4[4][4]; int partSums[4][4]; // effective 2x2, make it 4x4, easier to address // stores possible intra16x16 predictors u_int8 predBlk2[IPR_NUM_MODES2][MBK_SIZE][MBK_SIZE]; u_int8 predY[MBK_SIZE][MBK_SIZE]; // stores possible intra chroma predictors u_int8 predIntraC[IPR_CHROMA_NUM_MODES][MBK_SIZE/2][2 * (MBK_SIZE/2)]; u_int8 predC[MBK_SIZE/2][2 * (MBK_SIZE/2)]; int cbpY, cbpC, cbpChromaDC; int rastercbpY; // cbpY in raster order int lumaNonzeroDC; // nonzero coeffs in luma DC block, I16x16 only // perform coefficient elimination int coeffElim; int coeffElimTh8x8; // threshold for 8x8 luma block int coeffElimThLuma; // threshold for 16x16 luma block int coeffElimThChroma; // threshold for 8x8 chroma block#ifndef DISABLE_RDO // these are only used in RDO int intra16x16CbpY, intra4x4CbpY;#endif int dcCoefY[BLK_PER_MB][BLK_PER_MB]; int dcCoefC[2][BLK_PER_MB/2][BLK_PER_MB/2]; int coefY[BLK_PER_MB * BLK_PER_MB][BLK_SIZE][BLK_SIZE]; int coefC[2][BLK_PER_MB/2][BLK_PER_MB/2][BLK_SIZE][BLK_SIZE]; int plr; // packet loss rate} macroblock_s;/* * Function prototypes */void mbkLoad();void mbkInit(macroblock_s *mb, int plr);void mbkRelease(macroblock_s *mb);void mbkBeforeSlice(macroblock_s *mb, int sliceQp);void mbkStartEnc(macroblock_s *mb, mbState_s *mbStateArr, frmBuf_s *orig, frmBuf_s *reco, encParams_s *encPar, int qp, int tuneFactor);void mbkProcessData(macroblock_s *mb, int picType, encParams_s *encPar);int mbkSend(void *stream, macroblock_s *mb, int nRefFrames, int picType, statSlice_s *stat);void mbkFinishEnc(macroblock_s *mb, statSlice_s *stat);void mesPrepareProfile(meProfile_s *pMeProf, refFrmBuf_s *pRefFrm, encParams_s *encPar, int nRefFrames);int mesFindMotionFullSearch(macroblock_s *pMb, meProfile_s *pMeProf, refFrmBuf_s **refBufList, int nRefFrames);#endif // _MACROBLOCK_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -