[5] | 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-2011, 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 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 | |
---|
| 34 | |
---|
[5] | 35 | |
---|
[2] | 36 | /** \file TAppDecTop.cpp |
---|
| 37 | \brief Decoder application class |
---|
| 38 | */ |
---|
| 39 | |
---|
| 40 | #include <list> |
---|
| 41 | #include <stdio.h> |
---|
| 42 | #include <fcntl.h> |
---|
| 43 | #include <assert.h> |
---|
| 44 | |
---|
| 45 | #include "TAppDecTop.h" |
---|
| 46 | |
---|
| 47 | // ==================================================================================================================== |
---|
| 48 | // Local constants |
---|
| 49 | // ==================================================================================================================== |
---|
| 50 | |
---|
| 51 | /// initial bitstream buffer size |
---|
| 52 | /// should be large enough for parsing SPS |
---|
| 53 | /// resized as a function of picture size after parsing SPS |
---|
| 54 | #define BITS_BUF_SIZE 65536 |
---|
| 55 | |
---|
| 56 | // ==================================================================================================================== |
---|
| 57 | // Constructor / destructor / initialization / destroy |
---|
| 58 | // ==================================================================================================================== |
---|
| 59 | |
---|
| 60 | TAppDecTop::TAppDecTop() |
---|
| 61 | { |
---|
| 62 | ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag)); |
---|
| 63 | m_bUsingDepth = false; |
---|
| 64 | // m_iPOCLastDisplay = -1; |
---|
| 65 | m_pScaleOffsetFile = 0; |
---|
[28] | 66 | |
---|
| 67 | #if POZNAN_MP |
---|
| 68 | m_pcMP = NULL; |
---|
| 69 | #endif |
---|
[2] | 70 | } |
---|
| 71 | |
---|
| 72 | Void TAppDecTop::create() |
---|
| 73 | { |
---|
| 74 | m_apcBitstream = new TComBitstream; |
---|
| 75 | |
---|
| 76 | m_apcBitstream->create( BITS_BUF_SIZE ); |
---|
[28] | 77 | |
---|
| 78 | #if POZNAN_MP |
---|
| 79 | m_pcMP = new TComMP(); |
---|
| 80 | #endif |
---|
[2] | 81 | } |
---|
| 82 | |
---|
| 83 | Void TAppDecTop::destroy() |
---|
| 84 | { |
---|
| 85 | if ( m_apcBitstream ) |
---|
| 86 | { |
---|
| 87 | m_apcBitstream->destroy(); |
---|
| 88 | delete m_apcBitstream; |
---|
| 89 | m_apcBitstream = NULL; |
---|
| 90 | } |
---|
| 91 | if( m_pchBitstreamFile ) |
---|
| 92 | { |
---|
| 93 | free(m_pchBitstreamFile); |
---|
| 94 | } |
---|
| 95 | if( m_pchReconFile ) |
---|
| 96 | { |
---|
| 97 | free(m_pchReconFile); |
---|
| 98 | } |
---|
[28] | 99 | |
---|
| 100 | #if POZNAN_MP |
---|
| 101 | if(m_pcMP) { delete m_pcMP; m_pcMP = NULL; }; |
---|
| 102 | #endif |
---|
[2] | 103 | } |
---|
| 104 | |
---|
| 105 | // ==================================================================================================================== |
---|
| 106 | // Public member functions |
---|
| 107 | // ==================================================================================================================== |
---|
| 108 | |
---|
| 109 | /** |
---|
| 110 | - create internal class |
---|
| 111 | - initialize internal class |
---|
| 112 | - until the end of the bitstream, call decoding function in TDecTop class |
---|
| 113 | - delete allocated buffers |
---|
| 114 | - destroy internal class |
---|
| 115 | . |
---|
| 116 | */ |
---|
| 117 | Void TAppDecTop::decode() |
---|
| 118 | { |
---|
| 119 | TComBitstream* pcBitstream = m_apcBitstream; |
---|
| 120 | UInt uiPOC; |
---|
| 121 | TComList<TComPic*>* pcListPic; |
---|
| 122 | Bool bFirstSliceDecoded = true; |
---|
| 123 | |
---|
| 124 | // create & initialize internal classes |
---|
| 125 | xCreateDecLib(); |
---|
| 126 | xInitDecLib (); |
---|
| 127 | #if DCM_SKIP_DECODING_FRAMES |
---|
| 128 | // m_iPOCLastDisplay += m_iSkipFrame; // set the last displayed POC correctly for skip forward. |
---|
| 129 | #endif |
---|
| 130 | |
---|
| 131 | // main decoder loop |
---|
| 132 | Bool bEos = false; |
---|
| 133 | Bool resizedBitstreamBuffer = false; |
---|
| 134 | |
---|
| 135 | Bool bIsDepth = false; |
---|
| 136 | Int iViewIdx = 0; |
---|
| 137 | TComSPS cComSPS ; |
---|
| 138 | NalUnitType eNalUnitType; |
---|
| 139 | |
---|
[41] | 140 | #if FLEX_CODING_ORDER |
---|
| 141 | Int iDepthViewIdx = 0; |
---|
| 142 | Bool bCountDepthViewIdx = false; // a flag which avoid repeating assign a value to iDepthViewIdx |
---|
| 143 | Bool bNewPictureType =true; |
---|
| 144 | Bool bFirstDepth = false; |
---|
| 145 | #endif |
---|
[2] | 146 | |
---|
| 147 | while ( !bEos ) |
---|
| 148 | { |
---|
| 149 | streampos lLocation = m_cTVideoIOBitstreamFile.getFileLocation(); |
---|
| 150 | bEos = m_cTVideoIOBitstreamFile.readBits( pcBitstream ); |
---|
| 151 | if (bEos) |
---|
| 152 | { |
---|
| 153 | //if (!bFirstSliceDecoded) m_cTDecTop.decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_iPOCLastDisplay); |
---|
| 154 | if( bIsDepth ) |
---|
| 155 | { |
---|
[41] | 156 | #if FLEX_CODING_ORDER |
---|
| 157 | if (!bFirstSliceDecoded) m_acTDecDepthTopList[iDepthViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iDepthViewIdx] ,bNewPictureType); |
---|
| 158 | m_acTDecDepthTopList[iDepthViewIdx]->executeDeblockAndAlf( bEos, pcBitstream, uiPOC, pcListPic, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iDepthViewIdx]); |
---|
| 159 | #else |
---|
[2] | 160 | if (!bFirstSliceDecoded) m_acTDecDepthTopList[iViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iViewIdx] ); |
---|
| 161 | m_acTDecDepthTopList[iViewIdx]->executeDeblockAndAlf( bEos, pcBitstream, uiPOC, pcListPic, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iViewIdx]); |
---|
[41] | 162 | #endif |
---|
[2] | 163 | } |
---|
| 164 | else |
---|
| 165 | { |
---|
[41] | 166 | #if FLEX_CODING_ORDER |
---|
| 167 | if (!bFirstSliceDecoded) m_acTDecTopList[iViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiPOCLastDisplayList[iViewIdx], bNewPictureType); |
---|
| 168 | #else |
---|
[2] | 169 | if (!bFirstSliceDecoded) m_acTDecTopList[iViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiPOCLastDisplayList[iViewIdx] ); |
---|
[41] | 170 | #endif |
---|
[2] | 171 | m_acTDecTopList[iViewIdx]->executeDeblockAndAlf( bEos, pcBitstream, uiPOC, pcListPic, m_iSkipFrame, m_aiPOCLastDisplayList[iViewIdx]); |
---|
| 172 | } |
---|
| 173 | if( pcListPic ) |
---|
| 174 | { |
---|
| 175 | // write reconstuction to file |
---|
| 176 | xWriteOutput( pcListPic ); |
---|
| 177 | } |
---|
| 178 | break; |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | // call actual decoding function |
---|
| 182 | #if DCM_SKIP_DECODING_FRAMES |
---|
| 183 | Bool bNewPicture; |
---|
| 184 | if( bIsDepth ) |
---|
[41] | 185 | #if FLEX_CODING_ORDER |
---|
| 186 | bNewPicture = m_acTDecDepthTopList[iDepthViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iDepthViewIdx], bNewPictureType); |
---|
| 187 | #else |
---|
[2] | 188 | bNewPicture = m_acTDecDepthTopList[iViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iViewIdx] ); |
---|
[41] | 189 | #endif |
---|
[2] | 190 | else |
---|
[41] | 191 | #if FLEX_CODING_ORDER |
---|
| 192 | bNewPicture = m_acTDecTopList[iViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiPOCLastDisplayList[iViewIdx], bNewPictureType ); |
---|
| 193 | #else |
---|
[2] | 194 | bNewPicture = m_acTDecTopList[iViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiPOCLastDisplayList[iViewIdx] ); |
---|
[41] | 195 | #endif |
---|
[2] | 196 | bFirstSliceDecoded = true; |
---|
| 197 | |
---|
[41] | 198 | #if FLEX_CODING_ORDER |
---|
| 199 | if (eNalUnitType == NAL_UNIT_SPS) |
---|
| 200 | { |
---|
| 201 | #if POZNAN_SYNTH |
---|
| 202 | if(cComSPS.getViewId()==0 && !cComSPS.isDepth()) // it should be called at first view at the begining of the stream |
---|
| 203 | initRenderer(cComSPS); |
---|
| 204 | #endif |
---|
| 205 | if( cComSPS.isDepth() && (m_bUsingDepth==false) ) // expected not using depth, but bitstream are using depth |
---|
| 206 | { // know from sps |
---|
| 207 | assert( cComSPS.getViewId() == 0 && iDepthViewIdx == 0 && !bIsDepth ); |
---|
| 208 | startUsingDepth() ; |
---|
| 209 | } |
---|
| 210 | if (cComSPS.isDepth()) |
---|
| 211 | { |
---|
| 212 | if (cComSPS.getViewId() >= m_acTVideoIOYuvDepthReconFileList.size()) |
---|
| 213 | { |
---|
| 214 | assert( cComSPS.getViewId() == m_acTVideoIOYuvReconFileList.size() ); |
---|
| 215 | increaseNumberOfViews(cComSPS.getViewId()+1); |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | m_acTDecDepthTopList[cComSPS.getViewId()]->setSPS(cComSPS); |
---|
| 219 | } |
---|
| 220 | else |
---|
| 221 | { |
---|
| 222 | if (cComSPS.getViewId() >= m_acTVideoIOYuvReconFileList.size()) |
---|
| 223 | { |
---|
| 224 | assert( cComSPS.getViewId() == m_acTVideoIOYuvReconFileList.size() ); |
---|
| 225 | increaseNumberOfViews(cComSPS.getViewId()+1); |
---|
| 226 | } |
---|
| 227 | m_acTDecTopList[cComSPS.getViewId()]->setSPS(cComSPS); |
---|
| 228 | } |
---|
| 229 | bEos = m_cTVideoIOBitstreamFile.readBits( pcBitstream ); |
---|
| 230 | assert( !bEos); |
---|
| 231 | if( cComSPS.isDepth() ) |
---|
| 232 | m_acTDecDepthTopList[cComSPS.getViewId()]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiDepthPOCLastDisplayList[cComSPS.getViewId()], bNewPictureType); // decode PPS |
---|
| 233 | else |
---|
| 234 | m_acTDecTopList[cComSPS.getViewId()]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiPOCLastDisplayList[cComSPS.getViewId()], bNewPictureType); // decode PPS |
---|
| 235 | assert( eNalUnitType == NAL_UNIT_PPS ); |
---|
| 236 | } |
---|
| 237 | #else |
---|
| 238 | |
---|
[2] | 239 | if( eNalUnitType == NAL_UNIT_SPS ) |
---|
| 240 | { |
---|
[28] | 241 | #if POZNAN_SYNTH |
---|
| 242 | if(cComSPS.getViewId()==0 && !cComSPS.isDepth()) // it should be called at first view at the begining of the stream |
---|
| 243 | initRenderer(cComSPS); |
---|
| 244 | #endif |
---|
[2] | 245 | if( cComSPS.isDepth() && (m_bUsingDepth==false) ) // expected not using depth, but bitstream are using depth |
---|
| 246 | { // know from sps |
---|
| 247 | assert( cComSPS.getViewId() == 0 && iViewIdx == 0 && !bIsDepth ); |
---|
| 248 | startUsingDepth() ; |
---|
| 249 | } |
---|
| 250 | if( cComSPS.isDepth() && !bIsDepth ) |
---|
| 251 | { |
---|
| 252 | assert( cComSPS.getViewId() == iViewIdx ); |
---|
| 253 | m_acTDecDepthTopList[iViewIdx]->setSPS(cComSPS); |
---|
| 254 | } |
---|
| 255 | else if( cComSPS.getViewId() >= m_acTVideoIOYuvReconFileList.size() ) // expecting iViewIdx, but got cComSPS.getViewIdx() |
---|
| 256 | { |
---|
| 257 | assert( cComSPS.getViewId() == m_acTVideoIOYuvReconFileList.size() ); |
---|
| 258 | assert( !cComSPS.isDepth() ); |
---|
| 259 | increaseNumberOfViews(cComSPS.getViewId()+1); |
---|
| 260 | m_acTDecTopList[cComSPS.getViewId()]->setSPS(cComSPS); |
---|
| 261 | } |
---|
| 262 | bEos = m_cTVideoIOBitstreamFile.readBits( pcBitstream ); |
---|
| 263 | assert( !bEos); |
---|
| 264 | if( cComSPS.isDepth() ) |
---|
| 265 | m_acTDecDepthTopList[cComSPS.getViewId()]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiDepthPOCLastDisplayList[cComSPS.getViewId()]); // decode PPS |
---|
| 266 | else |
---|
| 267 | m_acTDecTopList[cComSPS.getViewId()]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiPOCLastDisplayList[cComSPS.getViewId()]); // decode PPS |
---|
| 268 | assert( eNalUnitType == NAL_UNIT_PPS ); |
---|
| 269 | } |
---|
[41] | 270 | #endif |
---|
[2] | 271 | assert( eNalUnitType != NAL_UNIT_SEI ); // not yet supported for MVC |
---|
| 272 | if (bNewPicture) |
---|
| 273 | { |
---|
| 274 | if( bIsDepth ) |
---|
[41] | 275 | #if FLEX_CODING_ORDER |
---|
| 276 | m_acTDecDepthTopList[iDepthViewIdx]->executeDeblockAndAlf( bEos, pcBitstream, uiPOC, pcListPic, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iDepthViewIdx]); |
---|
| 277 | #else |
---|
[2] | 278 | m_acTDecDepthTopList[iViewIdx]->executeDeblockAndAlf( bEos, pcBitstream, uiPOC, pcListPic, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iViewIdx]); |
---|
[41] | 279 | #endif |
---|
[2] | 280 | else |
---|
| 281 | m_acTDecTopList[iViewIdx]->executeDeblockAndAlf( bEos, pcBitstream, uiPOC, pcListPic, m_iSkipFrame, m_aiPOCLastDisplayList[iViewIdx]); |
---|
| 282 | if (!m_cTVideoIOBitstreamFile.good()) m_cTVideoIOBitstreamFile.clear(); |
---|
| 283 | m_cTVideoIOBitstreamFile.setFileLocation( lLocation ); |
---|
| 284 | bFirstSliceDecoded = false; |
---|
[41] | 285 | #if FLEX_CODING_ORDER |
---|
| 286 | if (m_bUsingDepth) |
---|
| 287 | { |
---|
| 288 | bIsDepth = bNewPictureType; |
---|
[2] | 289 | |
---|
[41] | 290 | } |
---|
| 291 | if (bCountDepthViewIdx == false ) |
---|
| 292 | { |
---|
| 293 | bCountDepthViewIdx = true; |
---|
| 294 | if (bIsDepth == true) |
---|
| 295 | { |
---|
| 296 | bFirstDepth = true; |
---|
| 297 | bCountDepthViewIdx = true; |
---|
| 298 | } |
---|
| 299 | if (!bFirstDepth && !bIsDepth) |
---|
| 300 | { |
---|
| 301 | iViewIdx++; |
---|
| 302 | bCountDepthViewIdx = false; |
---|
| 303 | } |
---|
| 304 | |
---|
| 305 | } |
---|
| 306 | else |
---|
| 307 | { |
---|
| 308 | if (bIsDepth) |
---|
| 309 | { |
---|
| 310 | iDepthViewIdx++; |
---|
| 311 | } |
---|
| 312 | else |
---|
| 313 | { |
---|
| 314 | iViewIdx ++; |
---|
| 315 | } |
---|
| 316 | |
---|
| 317 | if (iViewIdx >= m_acTDecTopList.size() || iDepthViewIdx >= m_acTDecDepthTopList.size()) |
---|
| 318 | { |
---|
| 319 | bFirstDepth = false; |
---|
| 320 | iViewIdx = 0; |
---|
| 321 | iDepthViewIdx = 0; |
---|
| 322 | bCountDepthViewIdx = false; |
---|
| 323 | // end of access unit: delete extra pic buffers |
---|
| 324 | Int iNumViews = (Int)m_acTVideoIOYuvReconFileList.size(); |
---|
| 325 | for( Int iVId = 0; iVId < iNumViews; iVId++ ) |
---|
| 326 | { |
---|
| 327 | if( iVId < (Int)m_acTDecTopList.size() && m_acTDecTopList[iVId] ) |
---|
| 328 | { |
---|
| 329 | m_acTDecTopList[iVId]->deleteExtraPicBuffers( (Int)uiPOC ); |
---|
| 330 | } |
---|
| 331 | if( iVId < (Int)m_acTDecDepthTopList.size() && m_acTDecDepthTopList[iVId] ) |
---|
| 332 | { |
---|
| 333 | m_acTDecDepthTopList[iVId]->deleteExtraPicBuffers( (Int)uiPOC ); |
---|
| 334 | } |
---|
| 335 | } |
---|
| 336 | |
---|
| 337 | #if AMVP_BUFFERCOMPRESS |
---|
| 338 | // compress motion for entire access unit |
---|
| 339 | for( Int iVId = 0; iVId < iNumViews; iVId++ ) |
---|
| 340 | { |
---|
| 341 | if( iVId < (Int)m_acTDecTopList.size() && m_acTDecTopList[iVId] ) |
---|
| 342 | { |
---|
| 343 | m_acTDecTopList[iVId]->compressMotion( (Int)uiPOC ); |
---|
| 344 | } |
---|
| 345 | if( iVId < (Int)m_acTDecDepthTopList.size() && m_acTDecDepthTopList[iVId] ) |
---|
| 346 | { |
---|
| 347 | m_acTDecDepthTopList[iVId]->compressMotion( (Int)uiPOC ); |
---|
| 348 | } |
---|
| 349 | } |
---|
| 350 | #endif |
---|
| 351 | } |
---|
| 352 | } |
---|
| 353 | |
---|
| 354 | #else |
---|
| 355 | |
---|
[2] | 356 | if( m_bUsingDepth && !bIsDepth ) |
---|
| 357 | { |
---|
| 358 | bIsDepth = true; |
---|
| 359 | } |
---|
| 360 | else |
---|
| 361 | { |
---|
| 362 | bIsDepth = false; |
---|
| 363 | if( iViewIdx<m_acTDecTopList.size()-1) |
---|
| 364 | { |
---|
| 365 | iViewIdx++ ; |
---|
| 366 | } |
---|
| 367 | else |
---|
| 368 | { |
---|
| 369 | iViewIdx = 0; |
---|
| 370 | |
---|
| 371 | // end of access unit: delete extra pic buffers |
---|
| 372 | Int iNumViews = (Int)m_acTVideoIOYuvReconFileList.size(); |
---|
| 373 | for( Int iVId = 0; iVId < iNumViews; iVId++ ) |
---|
| 374 | { |
---|
| 375 | if( iVId < (Int)m_acTDecTopList.size() && m_acTDecTopList[iVId] ) |
---|
| 376 | { |
---|
| 377 | m_acTDecTopList[iVId]->deleteExtraPicBuffers( (Int)uiPOC ); |
---|
| 378 | } |
---|
| 379 | if( iVId < (Int)m_acTDecDepthTopList.size() && m_acTDecDepthTopList[iVId] ) |
---|
| 380 | { |
---|
| 381 | m_acTDecDepthTopList[iVId]->deleteExtraPicBuffers( (Int)uiPOC ); |
---|
| 382 | } |
---|
| 383 | } |
---|
| 384 | |
---|
| 385 | #if AMVP_BUFFERCOMPRESS |
---|
| 386 | // compress motion for entire access unit |
---|
| 387 | for( Int iVId = 0; iVId < iNumViews; iVId++ ) |
---|
| 388 | { |
---|
| 389 | if( iVId < (Int)m_acTDecTopList.size() && m_acTDecTopList[iVId] ) |
---|
| 390 | { |
---|
| 391 | m_acTDecTopList[iVId]->compressMotion( (Int)uiPOC ); |
---|
| 392 | } |
---|
| 393 | if( iVId < (Int)m_acTDecDepthTopList.size() && m_acTDecDepthTopList[iVId] ) |
---|
| 394 | { |
---|
| 395 | m_acTDecDepthTopList[iVId]->compressMotion( (Int)uiPOC ); |
---|
| 396 | } |
---|
| 397 | } |
---|
| 398 | #endif |
---|
| 399 | } |
---|
| 400 | } |
---|
[41] | 401 | #endif |
---|
[2] | 402 | } |
---|
| 403 | #else |
---|
| 404 | #error |
---|
| 405 | m_cTDecTop.decode( bEos, pcBitstream, uiPOC, pcListPic ); |
---|
| 406 | #endif |
---|
| 407 | |
---|
| 408 | |
---|
| 409 | if (!resizedBitstreamBuffer) |
---|
| 410 | { |
---|
| 411 | TComSPS *sps = m_acTDecTopList[0]->getSPS(); |
---|
| 412 | if (sps) |
---|
| 413 | { |
---|
| 414 | pcBitstream->destroy(); |
---|
| 415 | pcBitstream->create(sps->getWidth() * sps->getHeight() * 2); |
---|
| 416 | resizedBitstreamBuffer = true; |
---|
| 417 | } |
---|
| 418 | } |
---|
| 419 | |
---|
| 420 | if( pcListPic ) |
---|
| 421 | { |
---|
| 422 | // write reconstuction to file |
---|
| 423 | xWriteOutput( pcListPic ); |
---|
| 424 | } |
---|
| 425 | } |
---|
| 426 | |
---|
| 427 | // delete buffers |
---|
| 428 | for(Int i=0; i<m_acTDecTopList.size(); i++) |
---|
| 429 | m_acTDecTopList[i]->deletePicBuffer(); |
---|
| 430 | |
---|
| 431 | if (m_bUsingDepth) |
---|
| 432 | { |
---|
| 433 | for(Int i=0; i<m_acTDecDepthTopList.size(); i++) |
---|
| 434 | m_acTDecDepthTopList[i]->deletePicBuffer(); |
---|
| 435 | } |
---|
| 436 | |
---|
| 437 | // destroy internal classes |
---|
| 438 | xDestroyDecLib(); |
---|
| 439 | } |
---|
| 440 | |
---|
| 441 | // ==================================================================================================================== |
---|
| 442 | // Protected member functions |
---|
| 443 | // ==================================================================================================================== |
---|
| 444 | |
---|
| 445 | Void TAppDecTop::xCreateDecLib() |
---|
| 446 | { |
---|
| 447 | // open bitstream file |
---|
| 448 | m_cTVideoIOBitstreamFile.openBits( m_pchBitstreamFile, false); // read mode |
---|
| 449 | |
---|
| 450 | // create decoder class |
---|
| 451 | // m_cTDecTop.create(); |
---|
| 452 | m_acTDecTopList.push_back(new TDecTop) ;// at least one decoder |
---|
| 453 | m_acTDecTopList[0]->create() ; |
---|
| 454 | |
---|
| 455 | m_aiPOCLastDisplayList.push_back(-1+m_iSkipFrame) ; |
---|
| 456 | |
---|
| 457 | if( m_pchScaleOffsetFile ) |
---|
| 458 | { |
---|
| 459 | m_pScaleOffsetFile = ::fopen( m_pchScaleOffsetFile, "wt" ); |
---|
| 460 | AOF( m_pScaleOffsetFile ); |
---|
| 461 | } |
---|
| 462 | m_cCamParsCollector.init( m_pScaleOffsetFile ); |
---|
| 463 | } |
---|
| 464 | |
---|
| 465 | Void TAppDecTop::xDestroyDecLib() |
---|
| 466 | { |
---|
| 467 | // close bitstream file |
---|
| 468 | m_cTVideoIOBitstreamFile.closeBits(); |
---|
| 469 | |
---|
| 470 | for(Int iViewIdx=0; iViewIdx<m_acTVideoIOYuvReconFileList.size() ; iViewIdx++) |
---|
| 471 | { |
---|
| 472 | m_acTVideoIOYuvReconFileList[iViewIdx]->close(); |
---|
| 473 | delete m_acTVideoIOYuvReconFileList[iViewIdx]; m_acTVideoIOYuvReconFileList[iViewIdx] = NULL ; |
---|
| 474 | } |
---|
| 475 | |
---|
| 476 | // destroy decoder class |
---|
| 477 | // m_cTDecTop.destroy(); |
---|
| 478 | for(Int iViewIdx=0; iViewIdx<m_acTDecTopList.size() ; iViewIdx++) |
---|
| 479 | { |
---|
| 480 | m_acTDecTopList[iViewIdx]->destroy() ; |
---|
| 481 | delete m_acTDecTopList[iViewIdx] ; m_acTDecTopList[iViewIdx] = NULL ; |
---|
| 482 | } |
---|
| 483 | |
---|
| 484 | for(Int iViewIdx=0; iViewIdx<m_acTVideoIOYuvDepthReconFileList.size() ; iViewIdx++) |
---|
| 485 | { |
---|
| 486 | m_acTVideoIOYuvDepthReconFileList[iViewIdx]->close(); |
---|
| 487 | delete m_acTVideoIOYuvDepthReconFileList[iViewIdx]; m_acTVideoIOYuvDepthReconFileList[iViewIdx] = NULL ; |
---|
| 488 | } |
---|
| 489 | |
---|
| 490 | for(Int iViewIdx=0; iViewIdx<m_acTDecDepthTopList.size() ; iViewIdx++) |
---|
| 491 | { |
---|
| 492 | m_acTDecDepthTopList[iViewIdx]->destroy() ; |
---|
| 493 | delete m_acTDecDepthTopList[iViewIdx] ; m_acTDecDepthTopList[iViewIdx] = NULL ; |
---|
| 494 | } |
---|
| 495 | |
---|
| 496 | m_cCamParsCollector.uninit(); |
---|
| 497 | if( m_pScaleOffsetFile ) |
---|
| 498 | { |
---|
| 499 | ::fclose( m_pScaleOffsetFile ); |
---|
| 500 | } |
---|
| 501 | } |
---|
| 502 | |
---|
| 503 | Void TAppDecTop::xInitDecLib() |
---|
| 504 | { |
---|
| 505 | // initialize decoder class |
---|
| 506 | m_acTDecTopList[0]->init( this ); |
---|
| 507 | m_acTDecTopList[0]->setViewIdx(0); |
---|
| 508 | m_acTDecTopList[0]->setPictureDigestEnabled(m_pictureDigestEnabled); |
---|
| 509 | m_acTDecTopList[0]->setCamParsCollector( &m_cCamParsCollector ); |
---|
[21] | 510 | #if SONY_COLPIC_AVAILABILITY |
---|
| 511 | m_acTDecTopList[0]->setViewOrderIdx(0); |
---|
| 512 | #endif |
---|
[2] | 513 | } |
---|
| 514 | |
---|
| 515 | /** \param pcListPic list of pictures to be written to file |
---|
| 516 | \param bFirst first picture? |
---|
| 517 | \todo DYN_REF_FREE should be revised |
---|
| 518 | */ |
---|
| 519 | Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic ) |
---|
| 520 | { |
---|
| 521 | TComList<TComPic*>::iterator iterPic = pcListPic->begin(); |
---|
| 522 | |
---|
| 523 | while (iterPic != pcListPic->end()) |
---|
| 524 | { |
---|
| 525 | TComPic* pcPic = *(iterPic); |
---|
| 526 | Int iViewIdx = pcPic->getViewIdx(); |
---|
| 527 | Int bIsDepth = pcPic->getSlice(0)->getSPS()->isDepth() ; |
---|
| 528 | |
---|
| 529 | if (!bIsDepth) |
---|
| 530 | { |
---|
| 531 | if( m_acTVideoIOYuvReconFileList.size() < iViewIdx+1 ) |
---|
| 532 | increaseNumberOfViews( iViewIdx+1 ) ; |
---|
| 533 | |
---|
| 534 | if ( pcPic->getReconMark() && pcPic->getPOC() == (m_aiPOCLastDisplayList[iViewIdx] + 1) ) |
---|
| 535 | { |
---|
| 536 | // write to file |
---|
| 537 | if ( m_pchReconFile ) |
---|
| 538 | { |
---|
| 539 | m_acTVideoIOYuvReconFileList[iViewIdx]->write( pcPic->getPicYuvRec(), pcPic->getSlice(0)->getSPS()->getPad() ); |
---|
| 540 | } |
---|
| 541 | |
---|
| 542 | // update POC of display order |
---|
| 543 | m_aiPOCLastDisplayList[iViewIdx] = pcPic->getPOC(); |
---|
| 544 | |
---|
| 545 | // erase non-referenced picture in the reference picture list after display |
---|
| 546 | if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true ) |
---|
| 547 | { |
---|
| 548 | #if !DYN_REF_FREE |
---|
| 549 | pcPic->setReconMark(false); |
---|
| 550 | |
---|
| 551 | // mark it should be extended later |
---|
| 552 | pcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
| 553 | |
---|
| 554 | #else |
---|
| 555 | pcPic->destroy(); |
---|
| 556 | pcListPic->erase( iterPic ); |
---|
| 557 | iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! |
---|
| 558 | continue; |
---|
| 559 | #endif |
---|
| 560 | } |
---|
| 561 | } |
---|
| 562 | } /// end !bIsDepth |
---|
| 563 | else |
---|
| 564 | { |
---|
| 565 | if( m_acTVideoIOYuvDepthReconFileList.size() < iViewIdx+1 ) |
---|
| 566 | increaseNumberOfViews( iViewIdx+1 ) ; |
---|
| 567 | |
---|
| 568 | if ( pcPic->getReconMark() && pcPic->getPOC() == (m_aiDepthPOCLastDisplayList[iViewIdx] + 1) ) |
---|
| 569 | { |
---|
| 570 | // write to file |
---|
| 571 | if ( m_pchReconFile ) |
---|
| 572 | { |
---|
[28] | 573 | |
---|
| 574 | #if POZNAN_NONLINEAR_DEPTH |
---|
| 575 | TComSPS* pcSPS = pcPic->getSlice(0)->getSPS(); |
---|
[41] | 576 | if( pcSPS->getUseNonlinearDepth() ) |
---|
| 577 | { |
---|
| 578 | TComPicYuv cPicNonlinearDepth; |
---|
[28] | 579 | |
---|
[41] | 580 | //pcPic->getPicYuvRec() |
---|
| 581 | cPicNonlinearDepth.create(pcSPS->getWidth(), pcSPS->getHeight(), pcSPS->getMaxCUWidth(), pcSPS->getMaxCUHeight(), pcSPS->getMaxCUDepth() ); |
---|
[28] | 582 | |
---|
[41] | 583 | pcPic->getPicYuvRec()->nonlinearDepthBackward(&cPicNonlinearDepth, pcSPS->getNonlinearDepthModel()); |
---|
[28] | 584 | |
---|
[41] | 585 | m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write(&cPicNonlinearDepth, pcSPS->getPad()); |
---|
| 586 | cPicNonlinearDepth.destroy(); |
---|
| 587 | } |
---|
| 588 | else |
---|
| 589 | #endif |
---|
[2] | 590 | m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write( pcPic->getPicYuvRec(), pcPic->getSlice(0)->getSPS()->getPad() ); |
---|
| 591 | } |
---|
| 592 | |
---|
| 593 | // update POC of display order |
---|
| 594 | m_aiDepthPOCLastDisplayList[iViewIdx] = pcPic->getPOC(); |
---|
| 595 | |
---|
| 596 | // erase non-referenced picture in the reference picture list after display |
---|
| 597 | if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true ) |
---|
| 598 | { |
---|
| 599 | #if !DYN_REF_FREE |
---|
| 600 | pcPic->setReconMark(false); |
---|
| 601 | |
---|
| 602 | // mark it should be extended later |
---|
| 603 | pcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
| 604 | |
---|
| 605 | #else |
---|
| 606 | pcPic->destroy(); |
---|
| 607 | pcListPic->erase( iterPic ); |
---|
| 608 | iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised! |
---|
| 609 | continue; |
---|
| 610 | #endif |
---|
| 611 | } |
---|
| 612 | } |
---|
| 613 | } // end bIsDepth |
---|
| 614 | |
---|
| 615 | iterPic++; |
---|
| 616 | } |
---|
| 617 | } |
---|
| 618 | |
---|
| 619 | Void TAppDecTop::startUsingDepth() |
---|
| 620 | { |
---|
| 621 | m_bUsingDepth = true ; |
---|
| 622 | increaseNumberOfViews( (Int)m_acTVideoIOYuvReconFileList.size() ); |
---|
| 623 | } |
---|
| 624 | |
---|
| 625 | Void TAppDecTop::increaseNumberOfViews (Int iNewNumberOfViews) |
---|
| 626 | { |
---|
| 627 | while( m_acTVideoIOYuvReconFileList.size() < iNewNumberOfViews) |
---|
| 628 | { |
---|
| 629 | m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv); |
---|
| 630 | |
---|
| 631 | // GT FIX |
---|
| 632 | Char cBuffer[4] ; |
---|
| 633 | sprintf(cBuffer,"_%i",(Int)m_acTVideoIOYuvReconFileList.size()-1 ); |
---|
| 634 | Char* pchNextFilename; |
---|
| 635 | xAppendToFileNameEnd( m_pchReconFile, cBuffer, pchNextFilename); |
---|
| 636 | // GT FIX END |
---|
| 637 | if ( m_outputBitDepth == 0 ) |
---|
| 638 | m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement; |
---|
| 639 | m_acTVideoIOYuvReconFileList.back()->open( pchNextFilename, true, m_outputBitDepth, g_uiBitDepth + g_uiBitIncrement ); |
---|
| 640 | free (pchNextFilename); |
---|
| 641 | } |
---|
| 642 | |
---|
| 643 | while( m_aiPOCLastDisplayList.size() < iNewNumberOfViews ) |
---|
| 644 | m_aiPOCLastDisplayList.push_back(-1+m_iSkipFrame) ; |
---|
| 645 | |
---|
| 646 | while( m_acTDecTopList.size() < iNewNumberOfViews) |
---|
| 647 | { |
---|
| 648 | m_acTDecTopList.push_back(new TDecTop) ;// at least one decoder |
---|
| 649 | m_acTDecTopList.back()->create() ; |
---|
| 650 | m_acTDecTopList.back()->init( this, false ); |
---|
| 651 | m_acTDecTopList.back()->setViewIdx((Int)m_acTDecTopList.size()-1); |
---|
| 652 | m_acTDecTopList.back()->setPictureDigestEnabled(m_pictureDigestEnabled); |
---|
| 653 | m_acTDecTopList.back()->setCamParsCollector( &m_cCamParsCollector ); |
---|
| 654 | } |
---|
| 655 | if( m_bUsingDepth ) |
---|
| 656 | { |
---|
| 657 | while( m_acTVideoIOYuvDepthReconFileList.size() < iNewNumberOfViews ) |
---|
| 658 | { |
---|
| 659 | m_acTVideoIOYuvDepthReconFileList.push_back(new TVideoIOYuv); |
---|
| 660 | // GT FIX |
---|
| 661 | Char* pchTempFilename = NULL; |
---|
| 662 | xAppendToFileNameEnd( m_pchReconFile, "_depth", pchTempFilename); |
---|
| 663 | Char cBuffer[4] ; |
---|
| 664 | sprintf(cBuffer,"_%i",(Int)m_acTVideoIOYuvDepthReconFileList.size()-1 ); |
---|
| 665 | Char* pchDepthFilename = NULL; |
---|
| 666 | xAppendToFileNameEnd( pchTempFilename, cBuffer, pchDepthFilename); |
---|
| 667 | // GT FIX END |
---|
| 668 | if ( m_outputBitDepth == 0 ) |
---|
| 669 | m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement; |
---|
| 670 | m_acTVideoIOYuvDepthReconFileList.back()->open( pchDepthFilename, true, m_outputBitDepth, g_uiBitDepth + g_uiBitIncrement ); |
---|
| 671 | free (pchTempFilename); |
---|
| 672 | free( pchDepthFilename ); |
---|
| 673 | } |
---|
| 674 | while( m_aiDepthPOCLastDisplayList.size() < iNewNumberOfViews ) |
---|
| 675 | m_aiDepthPOCLastDisplayList.push_back(-1+m_iSkipFrame) ; |
---|
| 676 | while( m_acTDecDepthTopList.size() < iNewNumberOfViews) |
---|
| 677 | { |
---|
| 678 | m_acTDecDepthTopList.push_back(new TDecTop) ;// at least one decoder |
---|
| 679 | m_acTDecDepthTopList.back()->create() ; |
---|
| 680 | m_acTDecDepthTopList.back()->init( this, false ); |
---|
[41] | 681 | #if FLEX_CODING_ORDER |
---|
| 682 | Int iNumofgen = (Int)m_acTDecDepthTopList.size(); |
---|
| 683 | m_acTDecDepthTopList.back()->setViewIdx(iNumofgen-1); //Oweczka ?? |
---|
| 684 | #else |
---|
[2] | 685 | m_acTDecDepthTopList.back()->setViewIdx((Int)m_acTDecTopList.size()-1); |
---|
[41] | 686 | #endif |
---|
[2] | 687 | m_acTDecDepthTopList.back()->setPictureDigestEnabled(m_pictureDigestEnabled); |
---|
| 688 | m_acTDecDepthTopList.back()->setToDepth( true ); |
---|
| 689 | m_acTDecDepthTopList.back()->setCamParsCollector( &m_cCamParsCollector ); |
---|
| 690 | } |
---|
| 691 | } |
---|
| 692 | } |
---|
| 693 | |
---|
| 694 | |
---|
| 695 | // GT FIX |
---|
| 696 | std::vector<TComPic*> TAppDecTop::getSpatialRefPics( Int iViewIdx, Int iPoc, Bool bIsDepth ) // only for mvc functionality yet |
---|
| 697 | { |
---|
| 698 | std::vector<TComPic*> apcRefPics( iViewIdx, (TComPic*)NULL ); |
---|
| 699 | for( int iRefViewIdx = 0; iRefViewIdx < iViewIdx; iRefViewIdx++ ) |
---|
| 700 | { |
---|
| 701 | TComPic* pcRefPic = getPicFromView( iRefViewIdx, iPoc, bIsDepth ); |
---|
| 702 | assert( pcRefPic != NULL ); |
---|
| 703 | apcRefPics[iRefViewIdx] = pcRefPic; |
---|
| 704 | } |
---|
| 705 | return apcRefPics; |
---|
| 706 | } |
---|
| 707 | |
---|
| 708 | TComPic* TAppDecTop::getPicFromView( Int iViewIdx, Int iPoc, bool bIsDepth ) |
---|
| 709 | { |
---|
[41] | 710 | #if FLEX_CODING_ORDER //Owieczka ?? flaga Jakuba |
---|
| 711 | if( bIsDepth && ((Int)(m_acTDecDepthTopList.size() - 1) < iViewIdx)) |
---|
| 712 | { |
---|
| 713 | return NULL; |
---|
| 714 | } |
---|
| 715 | if(!bIsDepth && ((Int)( m_acTDecTopList.size() - 1) < iViewIdx)) |
---|
| 716 | { |
---|
| 717 | return NULL; |
---|
| 718 | } |
---|
| 719 | #endif |
---|
[2] | 720 | TComList<TComPic*>* apcListPic = (bIsDepth ? m_acTDecDepthTopList[iViewIdx] : m_acTDecTopList[iViewIdx])->getListPic(); |
---|
| 721 | TComPic* pcRefPic = NULL; |
---|
| 722 | for( TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++ ) |
---|
| 723 | { |
---|
| 724 | if( (*it)->getPOC() == iPoc ) |
---|
| 725 | { |
---|
| 726 | pcRefPic = *it; |
---|
| 727 | break; |
---|
| 728 | } |
---|
| 729 | } |
---|
| 730 | return pcRefPic; |
---|
| 731 | } |
---|
[28] | 732 | |
---|
| 733 | #if POZNAN_SYNTH |
---|
| 734 | Void TAppDecTop::initRenderer(TComSPS &cComSPS) |
---|
| 735 | { |
---|
| 736 | m_cAvailabilityRenderer.init(cComSPS.getWidth(), cComSPS.getHeight(),true,0,LOG2_DISP_PREC_LUT,true, 0,0,0,0,0,6,4,1,0,6 ); //GT: simplest configuration |
---|
| 737 | } |
---|
| 738 | //* |
---|
| 739 | Void TAppDecTop::storeSynthPicsInBuffer(Int iCoddedViewIdx,Int iCoddedViewOrderIdx, Int iCurPoc, Bool bDepth) |
---|
| 740 | { |
---|
| 741 | Int iNearestViewIdx = -1; |
---|
| 742 | Bool bRenderFromLeft; |
---|
| 743 | |
---|
| 744 | Int iRelDistToLeft = 128; |
---|
| 745 | if(iCoddedViewIdx==0) //First on View Coded List |
---|
| 746 | { |
---|
| 747 | //TComPic* pcPic = getPicFromView( iCoddedViewIdx, iCurPoc, false ); |
---|
| 748 | return; |
---|
| 749 | } |
---|
| 750 | iNearestViewIdx = 0; |
---|
[29] | 751 | bRenderFromLeft = iCoddedViewOrderIdx>0?true:false; |
---|
[28] | 752 | //bRenderFromLeft = iCoddedViewOrderIdx<0?true:false; |
---|
| 753 | //m_cCamParsCollector.getNearestBaseView(iCoddedViewIdx, iNearestViewIdx, iRelDistToLeft, bRenderFromLeft); |
---|
| 754 | |
---|
| 755 | m_cAvailabilityRenderer.setShiftLUTs( |
---|
| 756 | m_cCamParsCollector.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx], |
---|
| 757 | m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx], |
---|
| 758 | m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx], |
---|
| 759 | m_cCamParsCollector.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],//right |
---|
| 760 | m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx], |
---|
| 761 | m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx], |
---|
| 762 | iRelDistToLeft |
---|
| 763 | ); |
---|
| 764 | |
---|
| 765 | TComPic* pcPic = getPicFromView( iCoddedViewIdx, iCurPoc, bDepth ); |
---|
| 766 | |
---|
| 767 | TComPicYuv* pcPicYuvSynthView = pcPic->getPicYuvSynth(); |
---|
| 768 | TComPicYuv* pcPicYuvAvailView = pcPic->getPicYuvAvail(); |
---|
| 769 | if(!pcPicYuvSynthView) |
---|
| 770 | { |
---|
| 771 | pcPic->addSynthesisBuffer(); |
---|
| 772 | pcPicYuvSynthView = pcPic->getPicYuvSynth(); |
---|
| 773 | } |
---|
| 774 | if(!pcPicYuvAvailView) |
---|
| 775 | { |
---|
| 776 | pcPic->addAvailabilityBuffer(); |
---|
| 777 | pcPicYuvAvailView = pcPic->getPicYuvAvail(); |
---|
| 778 | } |
---|
| 779 | // usun i uzyj syntezy Krzysztofa tylko przesun ja przed dekodowanie tekstury to do |
---|
| 780 | /* |
---|
| 781 | #if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH |
---|
| 782 | if(!bDepth) |
---|
| 783 | { |
---|
| 784 | TComPicYuv* pcPicYuvSynthDepthView = pcPic->getPicYuvSynthDepth(); |
---|
| 785 | if(!pcPicYuvSynthDepthView) |
---|
| 786 | { |
---|
| 787 | pcPic->addSynthesisDepthBuffer(); |
---|
| 788 | pcPicYuvSynthDepthView = pcPic->getPicYuvSynthDepth(); |
---|
| 789 | } |
---|
| 790 | m_cAvailabilityRenderer.extrapolateAvailabilityView( getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvSynthDepthView, pcPicYuvAvailView, bRenderFromLeft ); |
---|
| 791 | |
---|
| 792 | #if POZNAN_OUTPUT_SYNTH |
---|
| 793 | Char acFilenameBaseD[1024]; |
---|
| 794 | //printf("\niNearestViewIdx: %d, iCurPoc: %d, bRenderFromLeft: %s\n", iNearestViewIdx, iCurPoc, (bRenderFromLeft)?"true":"false"); |
---|
| 795 | ::sprintf( acFilenameBaseD, "SynthInputDepth_%s_V%d.yuv", ( true ? "Dec" : "Enc" ),iCoddedViewIdx ); |
---|
| 796 | getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec()->dump(acFilenameBaseD, iCurPoc!=0); |
---|
| 797 | ::sprintf( acFilenameBaseD, "SynthDepth_%s_V%d.yuv", ( true ? "Dec" : "Enc" ),iCoddedViewIdx ); |
---|
| 798 | pcPicYuvSynthDepthView->dump(acFilenameBaseD, iCurPoc!=0); |
---|
| 799 | #endif |
---|
| 800 | } |
---|
| 801 | #endif//*/ |
---|
| 802 | |
---|
| 803 | //m_cAvailabilityRenderer.extrapolateAvailabilityView( xGetPicFromView( iNearestViewIdx, iCurPoc, false )->getPicYuvRec(), xGetPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvERView, pcPicYuvAvailView, bRenderFromLeft ); |
---|
| 804 | m_cAvailabilityRenderer.extrapolateAvailabilityView( getPicFromView( iNearestViewIdx, iCurPoc, bDepth )->getPicYuvRec(), getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvSynthView, pcPicYuvAvailView, bRenderFromLeft ); |
---|
| 805 | |
---|
| 806 | pcPicYuvAvailView->setBorderExtension( false );//Needed?? |
---|
| 807 | pcPicYuvAvailView->extendPicBorder();//Needed?? |
---|
| 808 | |
---|
| 809 | #if POZNAN_OUTPUT_AVAILABLE_MAP |
---|
| 810 | { |
---|
| 811 | Char acFilenameBase[1024]; |
---|
| 812 | ::sprintf( acFilenameBase, "Available_%s_%s_V%d.yuv", (bDepth ? "Depth":"Tex"),( true ? "Dec" : "Enc" ), iCoddedViewIdx); |
---|
| 813 | pcPicYuvAvailView->dump(acFilenameBase, iCurPoc!=0); |
---|
| 814 | } |
---|
| 815 | #endif |
---|
| 816 | #if POZNAN_OUTPUT_SYNTH |
---|
| 817 | { |
---|
| 818 | Char acFilenameBase[1024]; |
---|
| 819 | ::sprintf( acFilenameBase, "Synth_%s_%s_V%d.yuv", (bDepth ? "Depth":"Tex"),( true ? "Dec" : "Enc" ), iCoddedViewIdx ); |
---|
| 820 | pcPicYuvSynthView->dump(acFilenameBase, iCurPoc!=0); |
---|
| 821 | } |
---|
| 822 | #endif |
---|
| 823 | } |
---|
| 824 | #endif |
---|
| 825 | |
---|
| 826 | //* |
---|
| 827 | #if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH |
---|
| 828 | Void TAppDecTop::storeDepthSynthPicsInBuffer(Int iCoddedViewIdx,Int iCoddedViewOrderIdx, Int iCurPoc) |
---|
| 829 | { |
---|
| 830 | Int iNearestViewIdx = -1; |
---|
| 831 | Bool bRenderFromLeft; |
---|
| 832 | |
---|
| 833 | Int iRelDistToLeft = 128; |
---|
| 834 | if(iCoddedViewIdx==0) //First on View Coded List |
---|
| 835 | { |
---|
| 836 | //TComPic* pcPic = getPicFromView( iCoddedViewIdx, iCurPoc, false ); |
---|
| 837 | return; |
---|
| 838 | } |
---|
| 839 | iNearestViewIdx = 0; |
---|
[30] | 840 | //m_cCamParsCollector.getNearestBaseView(iCoddedViewIdx, iNearestViewIdx, iRelDistToLeft, bRenderFromLeft); |
---|
| 841 | //bRenderFromLeft = iCoddedViewIdx>1?true:false; |
---|
| 842 | bRenderFromLeft = iCoddedViewOrderIdx>0?true:false; |
---|
[28] | 843 | //bRenderFromLeft = iCoddedViewOrderIdx<0?true:false; |
---|
| 844 | |
---|
| 845 | m_cAvailabilityRenderer.setShiftLUTs( |
---|
| 846 | m_cCamParsCollector.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx], |
---|
| 847 | m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx], |
---|
| 848 | m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx], |
---|
| 849 | m_cCamParsCollector.getBaseViewShiftLUTD()[iNearestViewIdx][iCoddedViewIdx],//right |
---|
| 850 | m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx], |
---|
| 851 | m_cCamParsCollector.getBaseViewShiftLUTI()[iNearestViewIdx][iCoddedViewIdx], |
---|
| 852 | iRelDistToLeft |
---|
| 853 | ); |
---|
| 854 | |
---|
| 855 | TComPic* pcPic = getPicFromView( iCoddedViewIdx, iCurPoc, false ); |
---|
| 856 | |
---|
| 857 | TComPicYuv* pcPicYuvSynthDepthView = pcPic->getPicYuvSynthDepth(); |
---|
| 858 | if(!pcPicYuvSynthDepthView) |
---|
| 859 | { |
---|
| 860 | pcPic->addSynthesisDepthBuffer(); |
---|
| 861 | pcPicYuvSynthDepthView = pcPic->getPicYuvSynthDepth(); |
---|
| 862 | } |
---|
| 863 | |
---|
| 864 | Int iWidth = pcPicYuvSynthDepthView->getWidth (); |
---|
| 865 | Int iHeight = pcPicYuvSynthDepthView->getHeight (); |
---|
| 866 | UInt uiMaxCuWidth = pcPicYuvSynthDepthView->getMaxCuWidth (); |
---|
| 867 | UInt uiMaxCuHeight = pcPicYuvSynthDepthView->getMaxCuHeight(); |
---|
| 868 | UInt uiMaxCuDepth = pcPicYuvSynthDepthView->getMaxCuDepth (); |
---|
| 869 | |
---|
| 870 | TComPicYuv* pcPicYuvAvailView = new TComPicYuv; |
---|
| 871 | pcPicYuvAvailView->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth ); |
---|
| 872 | |
---|
| 873 | m_cAvailabilityRenderer.extrapolateAvailabilityView( getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec(), pcPicYuvSynthDepthView, pcPicYuvAvailView, bRenderFromLeft ); |
---|
| 874 | |
---|
| 875 | pcPicYuvAvailView->destroy(); |
---|
| 876 | delete pcPicYuvAvailView; |
---|
| 877 | |
---|
| 878 | #if POZNAN_OUTPUT_SYNTH |
---|
| 879 | Char acFilenameBaseD[1024]; |
---|
| 880 | //printf("\niNearestViewIdx: %d, iCurPoc: %d, bRenderFromLeft: %s\n", iNearestViewIdx, iCurPoc, (bRenderFromLeft)?"true":"false"); |
---|
| 881 | ::sprintf( acFilenameBaseD, "SynthInputDepth_%s_V%d.yuv", ( true ? "Dec" : "Enc" ),iCoddedViewIdx ); |
---|
| 882 | getPicFromView( iNearestViewIdx, iCurPoc, true )->getPicYuvRec()->dump(acFilenameBaseD, iCurPoc!=0); |
---|
| 883 | ::sprintf( acFilenameBaseD, "SynthDepth_%s_V%d.yuv", ( true ? "Dec" : "Enc" ),iCoddedViewIdx ); |
---|
| 884 | pcPicYuvSynthDepthView->dump(acFilenameBaseD, iCurPoc!=0); |
---|
| 885 | #endif |
---|
| 886 | |
---|
| 887 | } |
---|
| 888 | #endif//*/ |
---|