annotate jctvc/TLibCommon/TComPattern.cpp @ 0:772086c29cc7

Initial import.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 16 Nov 2016 11:16:33 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /* The copyright in this software is being made available under the BSD
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * License, included below. This software may be subject to other third party
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 * and contributor rights, including patent rights, and no such rights are
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 * granted under this license.
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 *
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 * Copyright (c) 2010-2014, ITU/ISO/IEC
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 * All rights reserved.
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 *
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 * Redistribution and use in source and binary forms, with or without
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 * modification, are permitted provided that the following conditions are met:
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 *
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 * * Redistributions of source code must retain the above copyright notice,
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 * this list of conditions and the following disclaimer.
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 * * Redistributions in binary form must reproduce the above copyright notice,
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 * this list of conditions and the following disclaimer in the documentation
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 * and/or other materials provided with the distribution.
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 * be used to endorse or promote products derived from this software without
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 * specific prior written permission.
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 *
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 * THE POSSIBILITY OF SUCH DAMAGE.
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 */
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 /** \file TComPattern.cpp
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 \brief neighbouring pixel access classes
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 */
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 #include "TComPic.h"
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 #include "TComPattern.h"
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 #include "TComDataCU.h"
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 #include "TComTU.h"
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 #include "Debug.h"
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 #include "TComPrediction.h"
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 //! \ingroup TLibCommon
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 //! \{
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 // Forward declarations
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 /// padding of unavailable reference samples for intra prediction
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 #if O0043_BEST_EFFORT_DECODING
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 Void fillReferenceSamples( const Int bitDepth, const Int bitDepthDelta, TComDataCU* pcCU, const Pel* piRoiOrigin, Pel* piAdiTemp, const Bool* bNeighborFlags,
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 #else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 Void fillReferenceSamples( const Int bitDepth, TComDataCU* pcCU, const Pel* piRoiOrigin, Pel* piAdiTemp, const Bool* bNeighborFlags,
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 #endif
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 const Int iNumIntraNeighbor, const Int unitWidth, const Int unitHeight, const Int iAboveUnits, const Int iLeftUnits,
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 const UInt uiCuWidth, const UInt uiCuHeight, const UInt uiWidth, const UInt uiHeight, const Int iPicStride,
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 const ChannelType chType, const ChromaFormat chFmt );
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 /// constrained intra prediction
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 Bool isAboveLeftAvailable ( TComDataCU* pcCU, UInt uiPartIdxLT );
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 Int isAboveAvailable ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool* bValidFlags );
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 Int isLeftAvailable ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool* bValidFlags );
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 Int isAboveRightAvailable ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool* bValidFlags );
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 Int isBelowLeftAvailable ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool* bValidFlags );
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 // ====================================================================================================================
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 // Public member functions (TComPatternParam)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 // ====================================================================================================================
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 /** \param piTexture pixel data
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 \param iRoiWidth pattern width
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 \param iRoiHeight pattern height
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75 \param iStride buffer stride
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76 \param iOffsetLeft neighbour offset (left)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 \param iOffsetRight neighbour offset (right)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 \param iOffsetAbove neighbour offset (above)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 \param iOffsetBottom neighbour offset (bottom)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 */
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 Void TComPatternParam::setPatternParamPel ( Pel* piTexture,
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 Int iRoiWidth,
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 Int iRoiHeight,
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 Int iStride
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 )
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 m_piROIOrigin = piTexture;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88 m_iROIWidth = iRoiWidth;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 m_iROIHeight = iRoiHeight;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 m_iPatternStride = iStride;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 // ====================================================================================================================
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 // Public member functions (TComPattern)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 // ====================================================================================================================
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 Void TComPattern::initPattern (Pel* piY,
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 Int iRoiWidth,
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 Int iRoiHeight,
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 Int iStride)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 m_cPatternY. setPatternParamPel( piY, iRoiWidth, iRoiHeight, iStride);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106 // TODO: move this function to TComPrediction.cpp.
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 Void TComPrediction::initAdiPatternChType( TComTU &rTu, Bool& bAbove, Bool& bLeft, const ComponentID compID, const Bool bFilterRefSamples DEBUG_STRING_FN_DECLARE(sDebug))
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109 const ChannelType chType = toChannelType(compID);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111 TComDataCU *pcCU=rTu.getCU();
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 const UInt uiZorderIdxInPart=rTu.GetAbsPartIdxTU();
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 const UInt uiTuWidth = rTu.getRect(compID).width;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114 const UInt uiTuHeight = rTu.getRect(compID).height;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 const UInt uiTuWidth2 = uiTuWidth << 1;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 const UInt uiTuHeight2 = uiTuHeight << 1;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 const Int iBaseUnitSize = g_uiMaxCUWidth >> g_uiMaxCUDepth;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119 const Int iUnitWidth = iBaseUnitSize >> pcCU->getPic()->getPicYuvRec()->getComponentScaleX(compID);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120 const Int iUnitHeight = iBaseUnitSize >> pcCU->getPic()->getPicYuvRec()->getComponentScaleY(compID);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 const Int iTUWidthInUnits = uiTuWidth / iUnitWidth;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122 const Int iTUHeightInUnits = uiTuHeight / iUnitHeight;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 const Int iAboveUnits = iTUWidthInUnits << 1;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124 const Int iLeftUnits = iTUHeightInUnits << 1;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126 assert(iTUHeightInUnits > 0 && iTUWidthInUnits > 0);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128 const Int iPartIdxStride = pcCU->getPic()->getNumPartInCtuWidth();
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 const UInt uiPartIdxLT = pcCU->getZorderIdxInCtu() + uiZorderIdxInPart;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 const UInt uiPartIdxRT = g_auiRasterToZscan[ g_auiZscanToRaster[ uiPartIdxLT ] + iTUWidthInUnits - 1 ];
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 const UInt uiPartIdxLB = g_auiRasterToZscan[ g_auiZscanToRaster[ uiPartIdxLT ] + ((iTUHeightInUnits - 1) * iPartIdxStride)];
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 Int iPicStride = pcCU->getPic()->getStride(compID);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134 Bool bNeighborFlags[4 * MAX_NUM_SPU_W + 1];
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 Int iNumIntraNeighbor = 0;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137 bNeighborFlags[iLeftUnits] = isAboveLeftAvailable( pcCU, uiPartIdxLT );
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138 iNumIntraNeighbor += bNeighborFlags[iLeftUnits] ? 1 : 0;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139 iNumIntraNeighbor += isAboveAvailable ( pcCU, uiPartIdxLT, uiPartIdxRT, (bNeighborFlags + iLeftUnits + 1) );
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140 iNumIntraNeighbor += isAboveRightAvailable( pcCU, uiPartIdxLT, uiPartIdxRT, (bNeighborFlags + iLeftUnits + 1 + iTUWidthInUnits ) );
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141 iNumIntraNeighbor += isLeftAvailable ( pcCU, uiPartIdxLT, uiPartIdxLB, (bNeighborFlags + iLeftUnits - 1) );
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142 iNumIntraNeighbor += isBelowLeftAvailable ( pcCU, uiPartIdxLT, uiPartIdxLB, (bNeighborFlags + iLeftUnits - 1 - iTUHeightInUnits) );
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144 bAbove = true;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 bLeft = true;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147 const ChromaFormat chFmt = rTu.GetChromaFormat();
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 const UInt uiROIWidth = uiTuWidth2+1;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149 const UInt uiROIHeight = uiTuHeight2+1;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 assert(uiROIWidth*uiROIHeight <= m_iYuvExtSize);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153 #ifdef DEBUG_STRING
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154 std::stringstream ss(stringstream::out);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155 #endif
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158 Pel *piAdiTemp = m_piYuvExt[compID][PRED_BUF_UNFILTERED];
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 Pel *piRoiOrigin = pcCU->getPic()->getPicYuvRec()->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu()+uiZorderIdxInPart);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160 #if O0043_BEST_EFFORT_DECODING
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 fillReferenceSamples (g_bitDepthInStream[chType], g_bitDepthInStream[chType] - g_bitDepth[chType], pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitWidth, iUnitHeight, iAboveUnits, iLeftUnits,
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
162 #else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163 fillReferenceSamples (g_bitDepth[chType], pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitWidth, iUnitHeight, iAboveUnits, iLeftUnits,
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164 #endif
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
165 uiTuWidth, uiTuHeight, uiROIWidth, uiROIHeight, iPicStride, toChannelType(compID), chFmt);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168 #ifdef DEBUG_STRING
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169 if (DebugOptionList::DebugString_Pred.getInt()&DebugStringGetPredModeMask(MODE_INTRA))
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171 ss << "###: generating Ref Samples for channel " << compID << " and " << rTu.getRect(compID).width << " x " << rTu.getRect(compID).height << "\n";
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172 for (UInt y=0; y<uiROIHeight; y++)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174 ss << "###: - ";
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175 for (UInt x=0; x<uiROIWidth; x++)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177 if (x==0 || y==0)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178 ss << piAdiTemp[y*uiROIWidth + x] << ", ";
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179 // if (x%16==15) ss << "\nPart size: ~ ";
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181 ss << "\n";
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
183 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184 #endif
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
186 if (bFilterRefSamples)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
187 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
188 // generate filtered intra prediction samples
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
189
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
190 Int stride = uiROIWidth;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191 const Pel *piSrcPtr = piAdiTemp + (stride * uiTuHeight2); // bottom left
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
192 Pel *piDestPtr = m_piYuvExt[compID][PRED_BUF_FILTERED] + (stride * uiTuHeight2); // bottom left
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 //------------------------------------------------
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196 Bool useStrongIntraSmoothing = isLuma(chType) && pcCU->getSlice()->getSPS()->getUseStrongIntraSmoothing();
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198 const Pel bottomLeft = piAdiTemp[stride * uiTuHeight2];
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199 const Pel topLeft = piAdiTemp[0];
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200 const Pel topRight = piAdiTemp[uiTuWidth2];
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202 if (useStrongIntraSmoothing)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
204 #if O0043_BEST_EFFORT_DECODING
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
205 const Int threshold = 1 << (g_bitDepthInStream[chType] - 5);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206 #else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207 const Int threshold = 1 << (g_bitDepth[chType] - 5);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208 #endif
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209 const Bool bilinearLeft = abs((bottomLeft + topLeft ) - (2 * piAdiTemp[stride * uiTuHeight])) < threshold; //difference between the
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 const Bool bilinearAbove = abs((topLeft + topRight) - (2 * piAdiTemp[ uiTuWidth ])) < threshold; //ends and the middle
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
211 if ((uiTuWidth < 32) || (!bilinearLeft) || (!bilinearAbove))
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
212 useStrongIntraSmoothing = false;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
213 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215 *piDestPtr = *piSrcPtr; // bottom left is not filtered
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216 piDestPtr -= stride;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
217 piSrcPtr -= stride;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
219 //------------------------------------------------
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
221 //left column (bottom to top)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
222
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
223 if (useStrongIntraSmoothing)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
224 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225 const Int shift = g_aucConvertToBit[uiTuHeight] + 3; //log2(uiTuHeight2)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
226
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227 for(UInt i=1; i<uiTuHeight2; i++, piDestPtr-=stride)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
229 *piDestPtr = (((uiTuHeight2 - i) * bottomLeft) + (i * topLeft) + uiTuHeight) >> shift;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
231
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232 piSrcPtr -= stride * (uiTuHeight2 - 1);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
233 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234 else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
236 for(UInt i=1; i<uiTuHeight2; i++, piDestPtr-=stride, piSrcPtr-=stride)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
237 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238 *piDestPtr = ( piSrcPtr[stride] + 2*piSrcPtr[0] + piSrcPtr[-stride] + 2 ) >> 2;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
239 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
240 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
241
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242 //------------------------------------------------
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244 //top-left
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
246 if (useStrongIntraSmoothing)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
247 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248 *piDestPtr = piSrcPtr[0];
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
250 else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
251 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
252 *piDestPtr = ( piSrcPtr[stride] + 2*piSrcPtr[0] + piSrcPtr[1] + 2 ) >> 2;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
253 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254 piDestPtr += 1;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
255 piSrcPtr += 1;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
256
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
257 //------------------------------------------------
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
258
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
259 //top row (left-to-right)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
260
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
261 if (useStrongIntraSmoothing)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
262 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
263 const Int shift = g_aucConvertToBit[uiTuWidth] + 3; //log2(uiTuWidth2)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
264
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
265 for(UInt i=1; i<uiTuWidth2; i++, piDestPtr++)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
266 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
267 *piDestPtr = (((uiTuWidth2 - i) * topLeft) + (i * topRight) + uiTuWidth) >> shift;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
268 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
269
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
270 piSrcPtr += uiTuWidth2 - 1;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
271 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
272 else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
273 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
274 for(UInt i=1; i<uiTuWidth2; i++, piDestPtr++, piSrcPtr++)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
275 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
276 *piDestPtr = ( piSrcPtr[1] + 2*piSrcPtr[0] + piSrcPtr[-1] + 2 ) >> 2;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
277 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
278 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
279
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
280 //------------------------------------------------
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
281
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
282 *piDestPtr=*piSrcPtr; // far right is not filtered
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
283
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
284 #ifdef DEBUG_STRING
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
285 if (DebugOptionList::DebugString_Pred.getInt()&DebugStringGetPredModeMask(MODE_INTRA))
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
286 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
287 ss << "###: filtered result for channel " << compID <<"\n";
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
288 for (UInt y=0; y<uiROIHeight; y++)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
289 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
290 ss << "###: - ";
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
291 for (UInt x=0; x<uiROIWidth; x++)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
292 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
293 if (x==0 || y==0)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
294 ss << m_piYuvExt[compID][PRED_BUF_FILTERED][y*uiROIWidth + x] << ", ";
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
295 // if (x%16==15) ss << "\nPart size: ~ ";
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
296 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
297 ss << "\n";
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
298 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
299 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
300 #endif
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
301
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
302
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
303 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
304 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
305 DEBUG_STRING_APPEND(sDebug, ss.str())
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
306 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
307
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
308 #if O0043_BEST_EFFORT_DECODING
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
309 Void fillReferenceSamples( const Int bitDepth, const Int bitDepthDelta, TComDataCU* pcCU, const Pel* piRoiOrigin, Pel* piAdiTemp, const Bool* bNeighborFlags,
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
310 #else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
311 Void fillReferenceSamples( const Int bitDepth, TComDataCU* pcCU, const Pel* piRoiOrigin, Pel* piAdiTemp, const Bool* bNeighborFlags,
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
312 #endif
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
313 const Int iNumIntraNeighbor, const Int unitWidth, const Int unitHeight, const Int iAboveUnits, const Int iLeftUnits,
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
314 const UInt uiCuWidth, const UInt uiCuHeight, const UInt uiWidth, const UInt uiHeight, const Int iPicStride,
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
315 const ChannelType chType, const ChromaFormat chFmt )
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
316 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
317 const Pel* piRoiTemp;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
318 Int i, j;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
319 Int iDCValue = 1 << (bitDepth - 1);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
320 const Int iTotalUnits = iAboveUnits + iLeftUnits + 1; //+1 for top-left
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
321
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
322 if (iNumIntraNeighbor == 0)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
323 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
324 // Fill border with DC value
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
325 for (i=0; i<uiWidth; i++)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
326 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
327 piAdiTemp[i] = iDCValue;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
328 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
329 for (i=1; i<uiHeight; i++)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
330 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
331 piAdiTemp[i*uiWidth] = iDCValue;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
332 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
333 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
334 else if (iNumIntraNeighbor == iTotalUnits)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
335 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
336 // Fill top-left border and top and top right with rec. samples
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
337 piRoiTemp = piRoiOrigin - iPicStride - 1;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
338
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
339 for (i=0; i<uiWidth; i++)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
340 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
341 #if O0043_BEST_EFFORT_DECODING
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
342 piAdiTemp[i] = piRoiTemp[i] << bitDepthDelta;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
343 #else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
344 piAdiTemp[i] = piRoiTemp[i];
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
345 #endif
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
346 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
347
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
348 // Fill left and below left border with rec. samples
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
349 piRoiTemp = piRoiOrigin - 1;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
350
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
351 for (i=1; i<uiHeight; i++)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
352 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
353 #if O0043_BEST_EFFORT_DECODING
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354 piAdiTemp[i*uiWidth] = (*(piRoiTemp)) << bitDepthDelta;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
355 #else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
356 piAdiTemp[i*uiWidth] = *(piRoiTemp);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
357 #endif
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
358 piRoiTemp += iPicStride;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
359 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
360 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
361 else // reference samples are partially available
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
362 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
363 // all above units have "unitWidth" samples each, all left/below-left units have "unitHeight" samples each
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
364 const Int iTotalSamples = (iLeftUnits * unitHeight) + ((iAboveUnits + 1) * unitWidth);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
365 Pel piAdiLine[5 * MAX_CU_SIZE];
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
366 Pel *piAdiLineTemp;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
367 const Bool *pbNeighborFlags;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
368
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
369
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
370 // Initialize
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
371 for (i=0; i<iTotalSamples; i++)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
372 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
373 piAdiLine[i] = iDCValue;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
374 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
375
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
376 // Fill top-left sample
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
377 piRoiTemp = piRoiOrigin - iPicStride - 1;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
378 piAdiLineTemp = piAdiLine + (iLeftUnits * unitHeight);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
379 pbNeighborFlags = bNeighborFlags + iLeftUnits;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
380 if (*pbNeighborFlags)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
381 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
382 #if O0043_BEST_EFFORT_DECODING
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
383 Pel topLeftVal=piRoiTemp[0] << bitDepthDelta;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
384 #else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
385 Pel topLeftVal=piRoiTemp[0];
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
386 #endif
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
387 for (i=0; i<unitWidth; i++)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
388 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
389 piAdiLineTemp[i] = topLeftVal;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
390 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
391 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
392
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
393 // Fill left & below-left samples (downwards)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
394 piRoiTemp += iPicStride;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
395 piAdiLineTemp--;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
396 pbNeighborFlags--;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
397
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
398 for (j=0; j<iLeftUnits; j++)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
399 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
400 if (*pbNeighborFlags)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
401 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
402 for (i=0; i<unitHeight; i++)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
403 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
404 #if O0043_BEST_EFFORT_DECODING
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
405 piAdiLineTemp[-i] = piRoiTemp[i*iPicStride] << bitDepthDelta;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
406 #else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
407 piAdiLineTemp[-i] = piRoiTemp[i*iPicStride];
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
408 #endif
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
409 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
410 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
411 piRoiTemp += unitHeight*iPicStride;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
412 piAdiLineTemp -= unitHeight;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
413 pbNeighborFlags--;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
414 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
415
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
416 // Fill above & above-right samples (left-to-right) (each unit has "unitWidth" samples)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
417 piRoiTemp = piRoiOrigin - iPicStride;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
418 // offset line buffer by iNumUints2*unitHeight (for left/below-left) + unitWidth (for above-left)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
419 piAdiLineTemp = piAdiLine + (iLeftUnits * unitHeight) + unitWidth;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
420 pbNeighborFlags = bNeighborFlags + iLeftUnits + 1;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
421 for (j=0; j<iAboveUnits; j++)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
422 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
423 if (*pbNeighborFlags)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
424 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
425 for (i=0; i<unitWidth; i++)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
426 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
427 #if O0043_BEST_EFFORT_DECODING
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
428 piAdiLineTemp[i] = piRoiTemp[i] << bitDepthDelta;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
429 #else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
430 piAdiLineTemp[i] = piRoiTemp[i];
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
431 #endif
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
432 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
433 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
434 piRoiTemp += unitWidth;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
435 piAdiLineTemp += unitWidth;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
436 pbNeighborFlags++;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
437 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
438
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
439 // Pad reference samples when necessary
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
440 Int iCurrJnit = 0;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
441 Pel *piAdiLineCur = piAdiLine;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
442 const UInt piAdiLineTopRowOffset = iLeftUnits * (unitHeight - unitWidth);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
443
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
444 if (!bNeighborFlags[0])
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
445 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
446 // very bottom unit of bottom-left; at least one unit will be valid.
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
447 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
448 Int iNext = 1;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
449 while (iNext < iTotalUnits && !bNeighborFlags[iNext])
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
450 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
451 iNext++;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
452 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
453 Pel *piAdiLineNext = piAdiLine + ((iNext < iLeftUnits) ? (iNext * unitHeight) : (piAdiLineTopRowOffset + (iNext * unitWidth)));
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
454 const Pel refSample = *piAdiLineNext;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
455 // Pad unavailable samples with new value
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
456 Int iNextOrTop = std::min<Int>(iNext, iLeftUnits);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
457 // fill left column
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
458 while (iCurrJnit < iNextOrTop)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
459 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
460 for (i=0; i<unitHeight; i++)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
461 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
462 piAdiLineCur[i] = refSample;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
463 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
464 piAdiLineCur += unitHeight;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
465 iCurrJnit++;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
466 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
467 // fill top row
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
468 while (iCurrJnit < iNext)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
469 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
470 for (i=0; i<unitWidth; i++)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
471 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
472 piAdiLineCur[i] = refSample;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
473 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
474 piAdiLineCur += unitWidth;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
475 iCurrJnit++;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
476 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
477 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
478 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
479
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
480 // pad all other reference samples.
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
481 while (iCurrJnit < iTotalUnits)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
482 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
483 if (!bNeighborFlags[iCurrJnit]) // samples not available
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
484 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
485 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
486 const Int numSamplesInCurrUnit = (iCurrJnit >= iLeftUnits) ? unitWidth : unitHeight;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
487 const Pel refSample = *(piAdiLineCur-1);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
488 for (i=0; i<numSamplesInCurrUnit; i++)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
489 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
490 piAdiLineCur[i] = refSample;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
491 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
492 piAdiLineCur += numSamplesInCurrUnit;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
493 iCurrJnit++;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
494 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
495 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
496 else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
497 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
498 piAdiLineCur += (iCurrJnit >= iLeftUnits) ? unitWidth : unitHeight;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
499 iCurrJnit++;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
500 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
501 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
502
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
503 // Copy processed samples
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
504
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
505 piAdiLineTemp = piAdiLine + uiHeight + unitWidth - 2;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
506 // top left, top and top right samples
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
507 for (i=0; i<uiWidth; i++)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
508 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
509 piAdiTemp[i] = piAdiLineTemp[i];
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
510 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
511
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
512 piAdiLineTemp = piAdiLine + uiHeight - 1;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
513 for (i=1; i<uiHeight; i++)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
514 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
515 piAdiTemp[i*uiWidth] = piAdiLineTemp[-i];
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
516 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
517 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
518 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
519
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
520 /** Get pointer to reference samples for intra prediction
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
521 * \param uiDirMode prediction mode index
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
522 * \param log2BlkSize size of block (2 = 4x4, 3 = 8x8, 4 = 16x16, 5 = 32x32, 6 = 64x64)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
523 * \param piAdiBuf pointer to unfiltered reference samples
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
524 * \return pointer to (possibly filtered) reference samples
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
525 *
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
526 * The prediction mode index is used to determine whether a smoothed reference sample buffer is returned.
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
527 */
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
528
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
529 Bool TComPrediction::filteringIntraReferenceSamples(const ComponentID compID, UInt uiDirMode, UInt uiTuChWidth, UInt uiTuChHeight, const ChromaFormat chFmt, const Bool intraReferenceSmoothingDisabled)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
530 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
531 Bool bFilter;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
532
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
533 if (!filterIntraReferenceSamples(toChannelType(compID), chFmt, intraReferenceSmoothingDisabled))
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
534 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
535 bFilter=false;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
536 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
537 else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
538 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
539 assert(uiTuChWidth>=4 && uiTuChHeight>=4 && uiTuChWidth<128 && uiTuChHeight<128);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
540
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
541 if (uiDirMode == DC_IDX)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
542 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
543 bFilter=false; //no smoothing for DC or LM chroma
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
544 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
545 else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
546 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
547 Int diff = min<Int>(abs((Int) uiDirMode - HOR_IDX), abs((Int)uiDirMode - VER_IDX));
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
548 UInt sizeIndex=g_aucConvertToBit[uiTuChWidth];
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
549 assert(sizeIndex < MAX_INTRA_FILTER_DEPTHS);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
550 bFilter = diff > m_aucIntraFilter[toChannelType(compID)][sizeIndex];
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
551 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
552 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
553 return bFilter;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
554 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
555
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
556 Bool isAboveLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT )
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
557 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
558 Bool bAboveLeftFlag;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
559 UInt uiPartAboveLeft;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
560 TComDataCU* pcCUAboveLeft = pcCU->getPUAboveLeft( uiPartAboveLeft, uiPartIdxLT );
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
561 if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
562 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
563 bAboveLeftFlag = ( pcCUAboveLeft && pcCUAboveLeft->isIntra( uiPartAboveLeft ) );
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
564 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
565 else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
566 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
567 bAboveLeftFlag = (pcCUAboveLeft ? true : false);
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
568 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
569 return bAboveLeftFlag;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
570 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
571
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
572 Int isAboveAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
573 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
574 const UInt uiRasterPartBegin = g_auiZscanToRaster[uiPartIdxLT];
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
575 const UInt uiRasterPartEnd = g_auiZscanToRaster[uiPartIdxRT]+1;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
576 const UInt uiIdxStep = 1;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
577 Bool *pbValidFlags = bValidFlags;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
578 Int iNumIntra = 0;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
579
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
580 for ( UInt uiRasterPart = uiRasterPartBegin; uiRasterPart < uiRasterPartEnd; uiRasterPart += uiIdxStep )
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
581 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
582 UInt uiPartAbove;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
583 TComDataCU* pcCUAbove = pcCU->getPUAbove( uiPartAbove, g_auiRasterToZscan[uiRasterPart] );
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
584 if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
585 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
586 if ( pcCUAbove && pcCUAbove->isIntra( uiPartAbove ) )
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
587 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
588 iNumIntra++;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
589 *pbValidFlags = true;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
590 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
591 else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
592 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
593 *pbValidFlags = false;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
594 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
595 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
596 else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
597 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
598 if (pcCUAbove)
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
599 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
600 iNumIntra++;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
601 *pbValidFlags = true;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
602 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
603 else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
604 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
605 *pbValidFlags = false;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
606 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
607 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
608 pbValidFlags++;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
609 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
610 return iNumIntra;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
611 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
612
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
613 Int isLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
614 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
615 const UInt uiRasterPartBegin = g_auiZscanToRaster[uiPartIdxLT];
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
616 const UInt uiRasterPartEnd = g_auiZscanToRaster[uiPartIdxLB]+1;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
617 const UInt uiIdxStep = pcCU->getPic()->getNumPartInCtuWidth();
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
618 Bool *pbValidFlags = bValidFlags;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
619 Int iNumIntra = 0;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
620
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
621 for ( UInt uiRasterPart = uiRasterPartBegin; uiRasterPart < uiRasterPartEnd; uiRasterPart += uiIdxStep )
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
622 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
623 UInt uiPartLeft;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
624 TComDataCU* pcCULeft = pcCU->getPULeft( uiPartLeft, g_auiRasterToZscan[uiRasterPart] );
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
625 if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
626 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
627 if ( pcCULeft && pcCULeft->isIntra( uiPartLeft ) )
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
628 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
629 iNumIntra++;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
630 *pbValidFlags = true;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
631 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
632 else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
633 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
634 *pbValidFlags = false;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
635 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
636 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
637 else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
638 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
639 if ( pcCULeft )
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
640 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
641 iNumIntra++;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
642 *pbValidFlags = true;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
643 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
644 else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
645 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
646 *pbValidFlags = false;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
647 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
648 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
649 pbValidFlags--; // opposite direction
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
650 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
651
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
652 return iNumIntra;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
653 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
654
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
655 Int isAboveRightAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
656 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
657 const UInt uiNumUnitsInPU = g_auiZscanToRaster[uiPartIdxRT] - g_auiZscanToRaster[uiPartIdxLT] + 1;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
658 Bool *pbValidFlags = bValidFlags;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
659 Int iNumIntra = 0;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
660
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
661 for ( UInt uiOffset = 1; uiOffset <= uiNumUnitsInPU; uiOffset++ )
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
662 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
663 UInt uiPartAboveRight;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
664 TComDataCU* pcCUAboveRight = pcCU->getPUAboveRightAdi( uiPartAboveRight, uiPartIdxRT, uiOffset );
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
665 if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
666 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
667 if ( pcCUAboveRight && pcCUAboveRight->isIntra( uiPartAboveRight ) )
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
668 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
669 iNumIntra++;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
670 *pbValidFlags = true;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
671 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
672 else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
673 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
674 *pbValidFlags = false;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
675 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
676 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
677 else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
678 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
679 if ( pcCUAboveRight )
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
680 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
681 iNumIntra++;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
682 *pbValidFlags = true;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
683 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
684 else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
685 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
686 *pbValidFlags = false;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
687 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
688 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
689 pbValidFlags++;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
690 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
691
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
692 return iNumIntra;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
693 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
694
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
695 Int isBelowLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
696 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
697 const UInt uiNumUnitsInPU = (g_auiZscanToRaster[uiPartIdxLB] - g_auiZscanToRaster[uiPartIdxLT]) / pcCU->getPic()->getNumPartInCtuWidth() + 1;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
698 Bool *pbValidFlags = bValidFlags;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
699 Int iNumIntra = 0;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
700
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
701 for ( UInt uiOffset = 1; uiOffset <= uiNumUnitsInPU; uiOffset++ )
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
702 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
703 UInt uiPartBelowLeft;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
704 TComDataCU* pcCUBelowLeft = pcCU->getPUBelowLeftAdi( uiPartBelowLeft, uiPartIdxLB, uiOffset );
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
705 if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
706 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
707 if ( pcCUBelowLeft && pcCUBelowLeft->isIntra( uiPartBelowLeft ) )
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
708 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
709 iNumIntra++;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
710 *pbValidFlags = true;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
711 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
712 else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
713 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
714 *pbValidFlags = false;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
715 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
716 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
717 else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
718 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
719 if ( pcCUBelowLeft )
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
720 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
721 iNumIntra++;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
722 *pbValidFlags = true;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
723 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
724 else
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
725 {
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
726 *pbValidFlags = false;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
727 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
728 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
729 pbValidFlags--; // opposite direction
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
730 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
731
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
732 return iNumIntra;
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
733 }
772086c29cc7 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
734 //! \}