source: SHVCSoftware/branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.cpp @ 1005

Last change on this file since 1005 was 930, checked in by seregin, 10 years ago

fix compiler warnings

  • Property svn:eol-style set to native
File size: 20.3 KB
Line 
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-2014, 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 */
33
34/** \file     TDecGop.cpp
35    \brief    GOP decoder class
36*/
37
38#include "TDecGop.h"
39#include "TDecCAVLC.h"
40#include "TDecSbac.h"
41#include "TDecBinCoder.h"
42#include "TDecBinCoderCABAC.h"
43#include "libmd5/MD5.h"
44#include "TLibCommon/SEI.h"
45#if SVC_EXTENSION
46#include "TDecTop.h"
47#endif
48#include <algorithm>
49#include <time.h>
50
51extern Bool g_md5_mismatch; ///< top level flag to signal when there is a decode problem
52
53#if CONFORMANCE_BITSTREAM_MODE
54Bool pocCompareFunction( const TComPic &pic1, const TComPic &pic2 )
55{
56  return (const_cast<TComPic&>(pic1).getPOC() < const_cast<TComPic&>(pic2).getPOC());
57}
58#endif
59//! \ingroup TLibDecoder
60//! \{
61static void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI);
62#if Q0074_COLOUR_REMAPPING_SEI
63static Void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* colourRemappingInfoSEI, UInt layerId=0 );
64static std::vector<SEIColourRemappingInfo> storeCriSEI; //Persistent Colour Remapping Information SEI
65#endif
66// ====================================================================================================================
67// Constructor / destructor / initialization / destroy
68// ====================================================================================================================
69
70TDecGop::TDecGop()
71{
72  m_dDecTime = 0;
73  m_pcSbacDecoders = NULL;
74  m_pcBinCABACs = NULL;
75}
76
77TDecGop::~TDecGop()
78{
79 
80}
81
82#if SVC_EXTENSION
83Void TDecGop::create(UInt layerId)
84{
85  m_layerId = layerId;
86}
87#else
88Void TDecGop::create()
89{
90 
91}
92#endif
93
94Void TDecGop::destroy()
95{
96}
97#if SVC_EXTENSION
98Void TDecGop::init(TDecTop**               ppcDecTop,
99                   TDecEntropy*            pcEntropyDecoder,
100#else
101Void TDecGop::init( TDecEntropy*            pcEntropyDecoder, 
102#endif
103                   TDecSbac*               pcSbacDecoder, 
104                   TDecBinCABAC*           pcBinCABAC,
105                   TDecCavlc*              pcCavlcDecoder, 
106                   TDecSlice*              pcSliceDecoder, 
107                   TComLoopFilter*         pcLoopFilter,
108                   TComSampleAdaptiveOffset* pcSAO
109                   )
110{
111  m_pcEntropyDecoder      = pcEntropyDecoder;
112  m_pcSbacDecoder         = pcSbacDecoder;
113  m_pcBinCABAC            = pcBinCABAC;
114  m_pcCavlcDecoder        = pcCavlcDecoder;
115  m_pcSliceDecoder        = pcSliceDecoder;
116  m_pcLoopFilter          = pcLoopFilter;
117  m_pcSAO  = pcSAO;
118#if SVC_EXTENSION   
119  m_ppcTDecTop            = ppcDecTop;
120#endif
121}
122
123
124// ====================================================================================================================
125// Private member functions
126// ====================================================================================================================
127// ====================================================================================================================
128// Public member functions
129// ====================================================================================================================
130
131Void TDecGop::decompressSlice(TComInputBitstream* pcBitstream, TComPic*& rpcPic)
132{
133  TComSlice*  pcSlice = rpcPic->getSlice(rpcPic->getCurrSliceIdx());
134  // Table of extracted substreams.
135  // These must be deallocated AND their internal fifos, too.
136  TComInputBitstream **ppcSubstreams = NULL;
137
138  //-- For time output for each slice
139  long iBeforeTime = clock();
140  m_pcSbacDecoder->init( (TDecBinIf*)m_pcBinCABAC );
141  m_pcEntropyDecoder->setEntropyDecoder (m_pcSbacDecoder);
142
143  UInt uiNumSubstreams = pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag() ? pcSlice->getNumEntryPointOffsets()+1 : pcSlice->getPPS()->getNumSubstreams();
144
145  // init each couple {EntropyDecoder, Substream}
146  UInt *puiSubstreamSizes = pcSlice->getSubstreamSizes();
147  ppcSubstreams    = new TComInputBitstream*[uiNumSubstreams];
148  m_pcSbacDecoders = new TDecSbac[uiNumSubstreams];
149  m_pcBinCABACs    = new TDecBinCABAC[uiNumSubstreams];
150  for ( UInt ui = 0 ; ui < uiNumSubstreams ; ui++ )
151  {
152    m_pcSbacDecoders[ui].init(&m_pcBinCABACs[ui]);
153    ppcSubstreams[ui] = pcBitstream->extractSubstream(ui+1 < uiNumSubstreams ? puiSubstreamSizes[ui] : pcBitstream->getNumBitsLeft());
154  }
155
156  for ( UInt ui = 0 ; ui+1 < uiNumSubstreams; ui++ )
157  {
158    m_pcEntropyDecoder->setEntropyDecoder ( &m_pcSbacDecoders[uiNumSubstreams - 1 - ui] );
159    m_pcEntropyDecoder->setBitstream      (  ppcSubstreams   [uiNumSubstreams - 1 - ui] );
160    m_pcEntropyDecoder->resetEntropy      (pcSlice);
161  }
162
163  m_pcEntropyDecoder->setEntropyDecoder ( m_pcSbacDecoder  );
164  m_pcEntropyDecoder->setBitstream      ( ppcSubstreams[0] );
165  m_pcEntropyDecoder->resetEntropy      (pcSlice);
166  m_pcSbacDecoders[0].load(m_pcSbacDecoder);
167  m_pcSliceDecoder->decompressSlice( ppcSubstreams, rpcPic, m_pcSbacDecoder, m_pcSbacDecoders);
168  m_pcEntropyDecoder->setBitstream(  ppcSubstreams[uiNumSubstreams-1] );
169  // deallocate all created substreams, including internal buffers.
170  for (UInt ui = 0; ui < uiNumSubstreams; ui++)
171  {
172    ppcSubstreams[ui]->deleteFifo();
173    delete ppcSubstreams[ui];
174  }
175  delete[] ppcSubstreams;
176  delete[] m_pcSbacDecoders; m_pcSbacDecoders = NULL;
177  delete[] m_pcBinCABACs; m_pcBinCABACs = NULL;
178
179  m_dDecTime += (Double)(clock()-iBeforeTime) / CLOCKS_PER_SEC;
180}
181
182Void TDecGop::filterPicture(TComPic*& rpcPic)
183{
184  TComSlice*  pcSlice = rpcPic->getSlice(rpcPic->getCurrSliceIdx());
185
186  //-- For time output for each slice
187  long iBeforeTime = clock();
188
189  // deblocking filter
190  Bool bLFCrossTileBoundary = pcSlice->getPPS()->getLoopFilterAcrossTilesEnabledFlag();
191  m_pcLoopFilter->setCfg(bLFCrossTileBoundary);
192  m_pcLoopFilter->loopFilterPic( rpcPic );
193  if( pcSlice->getSPS()->getUseSAO() )
194  {
195    m_pcSAO->reconstructBlkSAOParams(rpcPic, rpcPic->getPicSym()->getSAOBlkParam());
196    m_pcSAO->SAOProcess(rpcPic);
197    m_pcSAO->PCMLFDisableProcess(rpcPic);
198  }
199  rpcPic->compressMotion(); 
200  Char c = (pcSlice->isIntra() ? 'I' : pcSlice->isInterP() ? 'P' : 'B');
201  if (!pcSlice->isReferenced()) c += 32;
202
203  //-- For time output for each slice
204#if SVC_EXTENSION
205  printf("\nPOC %4d LId: %1d TId: %1d ( %c-SLICE %s, QP%3d ) ", pcSlice->getPOC(),
206                                                    rpcPic->getLayerId(),
207                                                    pcSlice->getTLayer(),
208                                                    c,
209                                                    NaluToStr( pcSlice->getNalUnitType() ).data(),
210                                                    pcSlice->getSliceQp() );
211#else
212  printf("\nPOC %4d TId: %1d ( %c-SLICE, QP%3d ) ", pcSlice->getPOC(),
213                                                    pcSlice->getTLayer(),
214                                                    c,
215                                                    pcSlice->getSliceQp() );
216#endif
217  m_dDecTime += (Double)(clock()-iBeforeTime) / CLOCKS_PER_SEC;
218  printf ("[DT %6.3f] ", m_dDecTime );
219  m_dDecTime  = 0;
220
221  for (Int iRefList = 0; iRefList < 2; iRefList++)
222  {
223    printf ("[L%d ", iRefList);
224    for (Int iRefIndex = 0; iRefIndex < pcSlice->getNumRefIdx(RefPicList(iRefList)); iRefIndex++)
225    {
226#if SVC_EXTENSION
227#if VPS_EXTN_DIRECT_REF_LAYERS
228      if( pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->isILR( m_layerId ) )
229      {
230        UInt refLayerId = pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId();
231        UInt refLayerIdc = pcSlice->getReferenceLayerIdc(refLayerId);
232        assert( g_posScalingFactor[refLayerIdc][0] );
233        assert( g_posScalingFactor[refLayerIdc][1] );
234
235        printf( "%d(%d, {%1.2f, %1.2f}x)", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex), refLayerId, 65536.0/g_posScalingFactor[refLayerIdc][0], 65536.0/g_posScalingFactor[refLayerIdc][1] );
236      }
237      else
238      {
239        printf ("%d", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex));
240      }
241#endif
242      if( pcSlice->getEnableTMVPFlag() && iRefList == 1 - pcSlice->getColFromL0Flag() && iRefIndex == pcSlice->getColRefIdx() )
243      {
244        printf( "c" );
245      }
246
247      printf( " " );
248#else
249      printf ("%d ", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex));
250#endif
251    }
252    printf ("] ");
253  }
254  if (m_decodedPictureHashSEIEnabled)
255  {
256    SEIMessages pictureHashes = getSeisByType(rpcPic->getSEIs(), SEI::DECODED_PICTURE_HASH );
257    const SEIDecodedPictureHash *hash = ( pictureHashes.size() > 0 ) ? (SEIDecodedPictureHash*) *(pictureHashes.begin()) : NULL;
258    if (pictureHashes.size() > 1)
259    {
260      printf ("Warning: Got multiple decoded picture hash SEI messages. Using first.");
261    }
262    calcAndPrintHashStatus(*rpcPic->getPicYuvRec(), hash);
263  }
264#if CONFORMANCE_BITSTREAM_MODE
265  if( this->getLayerDec(rpcPic->getLayerId())->getConfModeFlag() ) 
266  {
267    // Add this reconstructed picture to the parallel buffer.
268    std::vector<TComPic> *thisLayerBuffer = (this->getLayerDec(rpcPic->getLayerId()))->getConfListPic();
269    thisLayerBuffer->push_back(*rpcPic);
270    std::sort( thisLayerBuffer->begin(), thisLayerBuffer->end(), pocCompareFunction );
271  }
272#endif
273#if Q0074_COLOUR_REMAPPING_SEI
274  if (m_colourRemapSEIEnabled)
275  {
276    SEIMessages colourRemappingInfo = getSeisByType(rpcPic->getSEIs(), SEI::COLOUR_REMAPPING_INFO );
277    const SEIColourRemappingInfo *seiColourRemappingInfo = ( colourRemappingInfo.size() > 0 ) ? (SEIColourRemappingInfo*) *(colourRemappingInfo.begin()) : NULL;
278    if (colourRemappingInfo.size() > 1)
279    {
280      printf ("Warning: Got multiple Colour Remapping Information SEI messages. Using first.");
281    }
282    applyColourRemapping(*rpcPic->getPicYuvRec(), seiColourRemappingInfo
283#if SVC_EXTENSION
284     , rpcPic->getLayerId()
285#endif
286     );
287  }
288#endif
289
290#if SETTING_PIC_OUTPUT_MARK
291  rpcPic->setOutputMark(rpcPic->getSlice(0)->getPicOutputFlag() ? true : false);
292#else
293  rpcPic->setOutputMark(true);
294#endif
295  rpcPic->setReconMark(true);
296}
297
298/**
299 * Calculate and print hash for pic, compare to picture_digest SEI if
300 * present in seis.  seis may be NULL.  Hash is printed to stdout, in
301 * a manner suitable for the status line. Theformat is:
302 *  [Hash_type:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,(yyy)]
303 * Where, x..x is the hash
304 *        yyy has the following meanings:
305 *            OK          - calculated hash matches the SEI message
306 *            ***ERROR*** - calculated hash does not match the SEI message
307 *            unk         - no SEI message was available for comparison
308 */
309static void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI)
310{
311  /* calculate MD5sum for entire reconstructed picture */
312  UChar recon_digest[3][16];
313  Int numChar=0;
314  const Char* hashType = "\0";
315
316  if (pictureHashSEI)
317  {
318    switch (pictureHashSEI->method)
319    {
320    case SEIDecodedPictureHash::MD5:
321      {
322        hashType = "MD5";
323        calcMD5(pic, recon_digest);
324        numChar = 16;
325        break;
326      }
327    case SEIDecodedPictureHash::CRC:
328      {
329        hashType = "CRC";
330        calcCRC(pic, recon_digest);
331        numChar = 2;
332        break;
333      }
334    case SEIDecodedPictureHash::CHECKSUM:
335      {
336        hashType = "Checksum";
337        calcChecksum(pic, recon_digest);
338        numChar = 4;
339        break;
340      }
341    default:
342      {
343        assert (!"unknown hash type");
344      }
345    }
346  }
347
348  /* compare digest against received version */
349  const Char* ok = "(unk)";
350  Bool mismatch = false;
351
352  if (pictureHashSEI)
353  {
354    ok = "(OK)";
355    for(Int yuvIdx = 0; yuvIdx < 3; yuvIdx++)
356    {
357      for (UInt i = 0; i < numChar; i++)
358      {
359        if (recon_digest[yuvIdx][i] != pictureHashSEI->digest[yuvIdx][i])
360        {
361          ok = "(***ERROR***)";
362          mismatch = true;
363        }
364      }
365    }
366  }
367
368  printf("[%s:%s,%s] ", hashType, digestToString(recon_digest, numChar), ok);
369
370  if (mismatch)
371  {
372    g_md5_mismatch = true;
373    printf("[rx%s:%s] ", hashType, digestToString(pictureHashSEI->digest, numChar));
374  }
375}
376
377#if Q0074_COLOUR_REMAPPING_SEI
378Void xInitColourRemappingLut( const Int bitDepthY, const Int bitDepthC, std::vector<Int>(&preLut)[3], std::vector<Int>(&postLut)[3], const SEIColourRemappingInfo* const pCriSEI )
379{
380  for ( Int c=0 ; c<3 ; c++ )
381  { 
382    Int bitDepth = c ? bitDepthC : bitDepthY ;
383    preLut[c].resize(1 << bitDepth);
384    postLut[c].resize(1 << pCriSEI->m_colourRemapBitDepth);
385   
386    Int bitDepthDiff = pCriSEI->m_colourRemapBitDepth - bitDepth;
387    Int iShift1 = (bitDepthDiff>0) ? bitDepthDiff : 0; //bit scale from bitdepth to ColourRemapBitdepth (manage only case colourRemapBitDepth>= bitdepth)
388    if( bitDepthDiff<0 )
389      printf ("Warning: CRI SEI - colourRemapBitDepth (%d) <bitDepth (%d) - case not handled\n", pCriSEI->m_colourRemapBitDepth, bitDepth);
390    bitDepthDiff = pCriSEI->m_colourRemapBitDepth - pCriSEI->m_colourRemapInputBitDepth;
391    Int iShift2 = (bitDepthDiff>0) ? bitDepthDiff : 0; //bit scale from ColourRemapInputBitdepth to ColourRemapBitdepth (manage only case colourRemapBitDepth>= colourRemapInputBitDepth)
392    if( bitDepthDiff<0 )
393      printf ("Warning: CRI SEI - colourRemapBitDepth (%d) <colourRemapInputBitDepth (%d) - case not handled\n", pCriSEI->m_colourRemapBitDepth, pCriSEI->m_colourRemapInputBitDepth);
394
395    //Fill preLut
396    for ( Int k=0 ; k<(1<<bitDepth) ; k++ )
397    {
398      Int iSample = k << iShift1 ;
399      for ( Int iPivot=0 ; iPivot<=pCriSEI->m_preLutNumValMinus1[c] ; iPivot++ )
400      {
401        Int iCodedPrev  = pCriSEI->m_preLutCodedValue[c][iPivot]    << iShift2; //Coded in CRInputBitdepth
402        Int iCodedNext  = pCriSEI->m_preLutCodedValue[c][iPivot+1]  << iShift2; //Coded in CRInputBitdepth
403        Int iTargetPrev = pCriSEI->m_preLutTargetValue[c][iPivot];              //Coded in CRBitdepth
404        Int iTargetNext = pCriSEI->m_preLutTargetValue[c][iPivot+1];            //Coded in CRBitdepth
405        if ( iCodedPrev <= iSample && iSample <= iCodedNext )
406        {
407          Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) * 1.f / (Float)(iCodedNext - iCodedPrev);
408          preLut[c][k]  = (Int)( 0.5f + fInterpol );
409          iPivot = pCriSEI->m_preLutNumValMinus1[c] + 1;
410        }
411      }
412    }
413   
414    //Fill postLut
415    for ( Int k=0 ; k<(1<<pCriSEI->m_colourRemapBitDepth) ; k++ )
416    {
417      Int iSample = k;
418      for ( Int iPivot=0 ; iPivot<=pCriSEI->m_postLutNumValMinus1[c] ; iPivot++ )
419      {
420        Int iCodedPrev  = pCriSEI->m_postLutCodedValue[c][iPivot];    //Coded in CRBitdepth
421        Int iCodedNext  = pCriSEI->m_postLutCodedValue[c][iPivot+1];  //Coded in CRBitdepth
422        Int iTargetPrev = pCriSEI->m_postLutTargetValue[c][iPivot];   //Coded in CRBitdepth
423        Int iTargetNext = pCriSEI->m_postLutTargetValue[c][iPivot+1]; //Coded in CRBitdepth
424        if ( iCodedPrev <= iSample && iSample <= iCodedNext )
425        {
426          Float fInterpol =  (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) * 1.f / (Float)(iCodedNext - iCodedPrev) ;
427          postLut[c][k]  = (Int)( 0.5f + fInterpol );
428          iPivot = pCriSEI->m_postLutNumValMinus1[c] + 1;
429        }
430      }
431    }
432  }
433}
434
435static void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* pCriSEI, UInt layerId )
436{ 
437  if( !storeCriSEI.size() )
438#if SVC_EXTENSION
439    storeCriSEI.resize(MAX_LAYERS);
440#else
441    storeCriSEI.resize(1);
442#endif
443
444  if ( pCriSEI ) //if a CRI SEI has just been retrieved, keep it in memory (persistence management)
445    storeCriSEI[layerId] = *pCriSEI;
446
447  if( !storeCriSEI[layerId].m_colourRemapCancelFlag )
448  {
449    Int iHeight  = pic.getHeight();
450    Int iWidth   = pic.getWidth();
451    Int iStride  = pic.getStride();
452    Int iCStride = pic.getCStride();
453
454    Pel *YUVIn[3], *YUVOut[3];
455    YUVIn[0] = pic.getLumaAddr();
456    YUVIn[1] = pic.getCbAddr();
457    YUVIn[2] = pic.getCrAddr();
458   
459    TComPicYuv picColourRemapped;
460#if SVC_EXTENSION
461#if AUXILIARY_PICTURES
462    picColourRemapped.create( pic.getWidth(), pic.getHeight(), pic.getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL );
463#else
464    picColourRemapped.create( pic.getWidth(), pic.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL );
465#endif
466#else
467    picColourRemapped.create( pic.getWidth(), pic.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
468#endif
469    YUVOut[0] = picColourRemapped.getLumaAddr();
470    YUVOut[1] = picColourRemapped.getCbAddr();
471    YUVOut[2] = picColourRemapped.getCrAddr();
472
473#if SVC_EXTENSION
474    Int bitDepthY = g_bitDepthYLayer[layerId];
475    Int bitDepthC = g_bitDepthCLayer[layerId];
476
477    assert( g_bitDepthY == bitDepthY );
478    assert( g_bitDepthC == bitDepthC );
479#else
480    Int bitDepthY = g_bitDepthY;
481    Int bitDepthC = g_bitDepthC;
482#endif
483
484    std::vector<Int> preLut[3];
485    std::vector<Int> postLut[3];
486    xInitColourRemappingLut( bitDepthY, bitDepthC, preLut, postLut, &storeCriSEI[layerId] );
487   
488    Int roundingOffset = (storeCriSEI[layerId].m_log2MatrixDenom==0) ? 0 : (1 << (storeCriSEI[layerId].m_log2MatrixDenom - 1));
489
490    for( Int y = 0; y < iHeight ; y++ )
491    {
492      for( Int x = 0; x < iWidth ; x++ )
493      {
494        Int YUVPre[3], YUVMat[3];
495        YUVPre[0] = preLut[0][ YUVIn[0][x]   ];
496        YUVPre[1] = preLut[1][ YUVIn[1][x>>1] ];
497        YUVPre[2] = preLut[2][ YUVIn[2][x>>1] ];
498
499        YUVMat[0] = ( storeCriSEI[layerId].m_colourRemapCoeffs[0][0]*YUVPre[0]
500                    + storeCriSEI[layerId].m_colourRemapCoeffs[0][1]*YUVPre[1] 
501                    + storeCriSEI[layerId].m_colourRemapCoeffs[0][2]*YUVPre[2] 
502                    + roundingOffset ) >> ( storeCriSEI[layerId].m_log2MatrixDenom );
503        YUVMat[0] = Clip3( 0, (1<<storeCriSEI[layerId].m_colourRemapBitDepth)-1, YUVMat[0] );
504        YUVOut[0][x] = postLut[0][ YUVMat[0] ];
505
506        if( (y&1) && (x&1) )
507        {
508          for(Int c=1 ; c<3 ; c++)
509          {
510            YUVMat[c] = ( storeCriSEI[layerId].m_colourRemapCoeffs[c][0]*YUVPre[0] 
511                        + storeCriSEI[layerId].m_colourRemapCoeffs[c][1]*YUVPre[1] 
512                        + storeCriSEI[layerId].m_colourRemapCoeffs[c][2]*YUVPre[2] 
513                        + roundingOffset ) >> ( storeCriSEI[layerId].m_log2MatrixDenom );
514            YUVMat[c] = Clip3( 0, (1<<storeCriSEI[layerId].m_colourRemapBitDepth)-1, YUVMat[c] );
515            YUVOut[c][x>>1] = postLut[c][ YUVMat[c] ];   
516          }
517        }
518      }
519      YUVIn[0]  += iStride;
520      YUVOut[0] += iStride;
521      if( y&1 )
522      {
523        YUVIn[1]  += iCStride;
524        YUVIn[2]  += iCStride;
525        YUVOut[1] += iCStride;
526        YUVOut[2] += iCStride;
527      }
528    }
529
530    //Write remapped picture in decoding order
531    Char  cTemp[255];
532    sprintf(cTemp, "seiColourRemappedPic_L%d_%dx%d_%dbits.yuv", layerId, iWidth, iHeight, storeCriSEI[layerId].m_colourRemapBitDepth );
533    picColourRemapped.dump( cTemp, true, storeCriSEI[layerId].m_colourRemapBitDepth );
534
535    picColourRemapped.destroy();
536
537    storeCriSEI[layerId].m_colourRemapCancelFlag = !storeCriSEI[layerId].m_colourRemapPersistenceFlag; //Handling persistence
538  }
539}
540#endif
541//! \}
Note: See TracBrowser for help on using the repository browser.