a76a32c2622166dbfba6c9f96b81c0c16e8a7475
1 /*****************************************************************************
2 * Copyright (C) 2013 x265 project
4 * Authors: Deepthi Nandakumar <deepthi@multicorewareinc.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
20 * This program is also available under a commercial proprietary license.
21 * For more information, contact us at license @ x265.com.
22 *****************************************************************************/
24 #ifndef X265_PREDICT_H
25 #define X265_PREDICT_H
43 enum { ADI_BUF_STRIDE
= (2 * MAX_CU_SIZE
+ 1 + 15) }; // alignment to 16 bytes
45 /* Weighted prediction scaling values built from slice parameters (bitdepth scaled) */
48 int w
, o
, offset
, shift
, round
;
61 bool bNeighborFlags
[4 * MAX_NUM_SPU_W
+ 1];
64 ShortYuv m_predShortYuv
[2]; /* temporary storage for weighted prediction */
67 /* Intra prediction buffers */
74 /* Slice information */
75 const Slice
* m_predSlice
;
80 /* cached CU information for prediction */
81 uint32_t m_ctuAddr
; // raster index of current CTU within its picture
82 uint32_t m_cuAbsPartIdx
; // z-order index of current CU within its CTU
83 uint32_t m_puAbsPartIdx
; // z-order index of current PU with its CU
89 /* TODO: Need to investigate clipping while writing into the TComDataCU fields itself */
95 bool allocBuffers(int csp
);
97 // motion compensation functions
98 void predInterLumaPixel(Yuv
& dstYuv
, const PicYuv
& refPic
, const MV
& mv
) const;
99 void predInterChromaPixel(Yuv
& dstYuv
, const PicYuv
& refPic
, const MV
& mv
) const;
101 void predInterLumaShort(ShortYuv
& dstSYuv
, const PicYuv
& refPic
, const MV
& mv
) const;
102 void predInterChromaShort(ShortYuv
& dstSYuv
, const PicYuv
& refPic
, const MV
& mv
) const;
104 void addWeightBi(Yuv
& predYuv
, const ShortYuv
& srcYuv0
, const ShortYuv
& srcYuv1
, const WeightValues wp0
[3], const WeightValues wp1
[3], bool bLuma
, bool bChroma
) const;
105 void addWeightUni(Yuv
& predYuv
, const ShortYuv
& srcYuv
, const WeightValues wp
[3], bool bLuma
, bool bChroma
) const;
107 /* Intra prediction helper functions */
108 static void initIntraNeighbors(const CUData
& cu
, uint32_t zOrderIdxInPart
, uint32_t partDepth
, bool isLuma
, IntraNeighbors
*IntraNeighbors
);
109 static void fillReferenceSamples(const pixel
* adiOrigin
, intptr_t picStride
, pixel
* adiRef
, const IntraNeighbors
& intraNeighbors
);
111 static bool isAboveLeftAvailable(const CUData
& cu
, uint32_t partIdxLT
);
112 static int isAboveAvailable(const CUData
& cu
, uint32_t partIdxLT
, uint32_t partIdxRT
, bool* bValidFlags
);
113 static int isLeftAvailable(const CUData
& cu
, uint32_t partIdxLT
, uint32_t partIdxLB
, bool* bValidFlags
);
114 static int isAboveRightAvailable(const CUData
& cu
, uint32_t partIdxLT
, uint32_t partIdxRT
, bool* bValidFlags
);
115 static int isBelowLeftAvailable(const CUData
& cu
, uint32_t partIdxLT
, uint32_t partIdxLB
, bool* bValidFlags
);
119 /* prepMotionCompensation needs to be called to prepare MC with CU-relevant data */
120 void initMotionCompensation(const CUData
& cu
, const CUGeom
& cuGeom
, int partIdx
);
121 void prepMotionCompensation(const CUData
& cu
, const CUGeom
& cuGeom
, int partIdx
);
122 void motionCompensation(Yuv
& predYuv
, bool bLuma
, bool bChroma
);
125 void predIntraLumaAng(uint32_t dirMode
, pixel
* pred
, intptr_t stride
, uint32_t log2TrSize
);
126 void predIntraChromaAng(pixel
* src
, uint32_t dirMode
, pixel
* pred
, intptr_t stride
, uint32_t log2TrSizeC
, int chFmt
);
128 void initAdiPattern(const CUData
& cu
, const CUGeom
& cuGeom
, uint32_t absPartIdx
, uint32_t partDepth
, int dirMode
);
129 void initAdiPatternChroma(const CUData
& cu
, const CUGeom
& cuGeom
, uint32_t absPartIdx
, uint32_t partDepth
, uint32_t chromaId
);
130 pixel
* getAdiChromaBuf(uint32_t chromaId
, int tuSize
)
132 return m_predBuf
+ (chromaId
== 1 ? 0 : 2 * ADI_BUF_STRIDE
* (tuSize
* 2 + 1));
137 #endif // ifndef X265_PREDICT_H