Changeset 56 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComPicSym.cpp
- Timestamp:
- 11 May 2012, 21:20:17 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibCommon/TComPicSym.cpp
r2 r56 1 1 /* The copyright in this software is being made available under the BSD 2 * License, included below. This software may be subject to other third party 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 5 * 6 * Copyright (c) 2010-2012, ITU/ISO/IEC 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions are met: 11 * 12 * * Redistributions of source code must retain the above copyright notice, 13 * this list of conditions and the following disclaimer. 14 * * Redistributions in binary form must reproduce the above copyright notice, 15 * this list of conditions and the following disclaimer in the documentation 16 * and/or other materials provided with the distribution. 17 * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may 18 * be used to endorse or promote products derived from this software without 19 * specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 31 * THE POSSIBILITY OF SUCH DAMAGE. 32 */ 2 33 3 34 /** \file TComPicSym.cpp … … 7 38 #include "TComPicSym.h" 8 39 40 //! \ingroup TLibCommon 41 //! \{ 42 9 43 // ==================================================================================================================== 10 44 // Constructor / destructor / create / destroy … … 41 75 delete [] m_apcTComSlice; 42 76 } 43 m_apcTComSlice = new TComSlice*[m_uiNumCUsInFrame ];77 m_apcTComSlice = new TComSlice*[m_uiNumCUsInFrame*m_uiNumPartitions]; 44 78 m_apcTComSlice[0] = new TComSlice; 45 79 m_uiNumAllocatedSlice = 1; … … 47 81 { 48 82 m_apcTComDataCU[i] = new TComDataCU; 49 m_apcTComDataCU[i]->create( m_uiNumPartitions, m_uiMaxCUWidth, m_uiMaxCUHeight, false ); 83 m_apcTComDataCU[i]->create( m_uiNumPartitions, m_uiMaxCUWidth, m_uiMaxCUHeight, false, m_uiMaxCUWidth >> m_uhTotalDepth 84 #if ADAPTIVE_QP_SELECTION 85 , true 86 #endif 87 ); 88 } 89 90 m_puiCUOrderMap = new UInt[m_uiNumCUsInFrame+1]; 91 m_puiTileIdxMap = new UInt[m_uiNumCUsInFrame]; 92 m_puiInverseCUOrderMap = new UInt[m_uiNumCUsInFrame+1]; 93 94 for( i=0; i<m_uiNumCUsInFrame; i++ ) 95 { 96 m_puiCUOrderMap[i] = i; 97 m_puiInverseCUOrderMap[i] = i; 50 98 } 51 99 } … … 73 121 delete [] m_apcTComDataCU; 74 122 m_apcTComDataCU = NULL; 123 124 delete [] m_apcTComTile; 125 m_apcTComTile = NULL; 126 127 delete [] m_puiCUOrderMap; 128 m_puiCUOrderMap = NULL; 129 130 delete [] m_puiTileIdxMap; 131 m_puiTileIdxMap = NULL; 132 133 delete [] m_puiInverseCUOrderMap; 134 m_puiInverseCUOrderMap = NULL; 75 135 } 76 136 77 137 Void TComPicSym::allocateNewSlice() 78 138 { 79 assert(m_uiNumCUsInFrame >= m_uiNumAllocatedSlice);80 139 m_apcTComSlice[m_uiNumAllocatedSlice ++] = new TComSlice; 140 if (m_uiNumAllocatedSlice>=2) 141 { 142 m_apcTComSlice[m_uiNumAllocatedSlice-1]->copySliceInfo( m_apcTComSlice[m_uiNumAllocatedSlice-2] ); 143 m_apcTComSlice[m_uiNumAllocatedSlice-1]->initSlice(); 144 m_apcTComSlice[m_uiNumAllocatedSlice-1]->initTiles(); 145 146 } 81 147 } 82 148 … … 90 156 m_uiNumAllocatedSlice = 1; 91 157 } 158 159 UInt TComPicSym::getPicSCUEncOrder( UInt SCUAddr ) 160 { 161 return getInverseCUOrderMap(SCUAddr/m_uiNumPartitions)*m_uiNumPartitions + SCUAddr%m_uiNumPartitions; 162 } 163 164 UInt TComPicSym::getPicSCUAddr( UInt SCUEncOrder ) 165 { 166 return getCUOrderMap(SCUEncOrder/m_uiNumPartitions)*m_uiNumPartitions + SCUEncOrder%m_uiNumPartitions; 167 } 168 169 Void TComPicSym::xCreateTComTileArray() 170 { 171 m_apcTComTile = new TComTile*[(m_iNumColumnsMinus1+1)*(m_iNumRowsMinus1+1)]; 172 for( UInt i=0; i<(m_iNumColumnsMinus1+1)*(m_iNumRowsMinus1+1); i++ ) 173 { 174 m_apcTComTile[i] = new TComTile; 175 } 176 } 177 178 Void TComPicSym::xInitTiles() 179 { 180 UInt uiTileIdx; 181 UInt uiColumnIdx = 0; 182 UInt uiRowIdx = 0; 183 UInt uiRightEdgePosInCU; 184 UInt uiBottomEdgePosInCU; 185 Int i, j; 186 187 //initialize each tile of the current picture 188 for( uiRowIdx=0; uiRowIdx < m_iNumRowsMinus1+1; uiRowIdx++ ) 189 for( uiColumnIdx=0; uiColumnIdx < m_iNumColumnsMinus1+1; uiColumnIdx++ ) 190 { 191 uiTileIdx = uiRowIdx * (m_iNumColumnsMinus1+1) + uiColumnIdx; 192 193 //initialize the RightEdgePosInCU for each tile 194 uiRightEdgePosInCU = 0; 195 for( i=0; i <= uiColumnIdx; i++ ) 196 { 197 uiRightEdgePosInCU += this->getTComTile(uiRowIdx * (m_iNumColumnsMinus1+1) + i)->getTileWidth(); 198 } 199 this->getTComTile(uiTileIdx)->setRightEdgePosInCU(uiRightEdgePosInCU-1); 200 201 //initialize the BottomEdgePosInCU for each tile 202 uiBottomEdgePosInCU = 0; 203 for( i=0; i <= uiRowIdx; i++ ) 204 { 205 uiBottomEdgePosInCU += this->getTComTile(i * (m_iNumColumnsMinus1+1) + uiColumnIdx)->getTileHeight(); 206 } 207 this->getTComTile(uiTileIdx)->setBottomEdgePosInCU(uiBottomEdgePosInCU-1); 208 209 //initialize the FirstCUAddr for each tile 210 this->getTComTile(uiTileIdx)->setFirstCUAddr( (this->getTComTile(uiTileIdx)->getBottomEdgePosInCU() - this->getTComTile(uiTileIdx)->getTileHeight() +1)*m_uiWidthInCU + 211 this->getTComTile(uiTileIdx)->getRightEdgePosInCU() - this->getTComTile(uiTileIdx)->getTileWidth() + 1); 212 } 213 214 //initialize the TileIdxMap 215 for( i=0; i<m_uiNumCUsInFrame; i++) 216 { 217 for(j=0; j < m_iNumColumnsMinus1+1; j++) 218 { 219 if(i % m_uiWidthInCU <= this->getTComTile(j)->getRightEdgePosInCU()) 220 { 221 uiColumnIdx = j; 222 j = m_iNumColumnsMinus1+1; 223 } 224 } 225 for(j=0; j < m_iNumRowsMinus1+1; j++) 226 { 227 if(i/m_uiWidthInCU <= this->getTComTile(j*(m_iNumColumnsMinus1 + 1))->getBottomEdgePosInCU()) 228 { 229 uiRowIdx = j; 230 j = m_iNumRowsMinus1 + 1; 231 } 232 } 233 m_puiTileIdxMap[i] = uiRowIdx * (m_iNumColumnsMinus1 + 1) + uiColumnIdx; 234 } 235 236 // Determine bits required for tile index 237 Int uiTilesCount = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1); 238 m_uiBitsUsedByTileIdx = 0; 239 while (uiTilesCount) 240 { 241 m_uiBitsUsedByTileIdx++; 242 uiTilesCount >>= 1; 243 } 244 } 245 246 UInt TComPicSym::xCalculateNxtCUAddr( UInt uiCurrCUAddr ) 247 { 248 UInt uiNxtCUAddr; 249 UInt uiTileIdx; 250 251 //get the tile index for the current LCU 252 uiTileIdx = this->getTileIdxMap(uiCurrCUAddr); 253 254 //get the raster scan address for the next LCU 255 if( uiCurrCUAddr % m_uiWidthInCU == this->getTComTile(uiTileIdx)->getRightEdgePosInCU() && uiCurrCUAddr / m_uiWidthInCU == this->getTComTile(uiTileIdx)->getBottomEdgePosInCU() ) 256 //the current LCU is the last LCU of the tile 257 { 258 if(uiTileIdx == (m_iNumColumnsMinus1+1)*(m_iNumRowsMinus1+1)-1) 259 { 260 uiNxtCUAddr = m_uiNumCUsInFrame; 261 } 262 else 263 { 264 uiNxtCUAddr = this->getTComTile(uiTileIdx+1)->getFirstCUAddr(); 265 } 266 } 267 else //the current LCU is not the last LCU of the tile 268 { 269 if( uiCurrCUAddr % m_uiWidthInCU == this->getTComTile(uiTileIdx)->getRightEdgePosInCU() ) //the current LCU is on the rightmost edge of the tile 270 { 271 uiNxtCUAddr = uiCurrCUAddr + m_uiWidthInCU - this->getTComTile(uiTileIdx)->getTileWidth() + 1; 272 } 273 else 274 { 275 uiNxtCUAddr = uiCurrCUAddr + 1; 276 } 277 } 278 279 return uiNxtCUAddr; 280 } 281 282 TComTile::TComTile() 283 { 284 } 285 286 TComTile::~TComTile() 287 { 288 } 289 //! \}
Note: See TracChangeset for help on using the changeset viewer.