Changeset 1215 in SHVCSoftware


Ignore:
Timestamp:
8 Jul 2015, 23:43:06 (9 years ago)
Author:
seregin
Message:

macro cleanup: R0300_CGS_RES_COEFF_CODING

Location:
branches/SHM-dev/source/Lib
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-dev/source/Lib/TLibCommon/TCom3DAsymLUT.h

    r1214 r1215  
    3030  virtual Void destroy();
    3131
    32   Int   getMaxOctantDepth() { return m_nMaxOctantDepth; }
    33   Int   getCurOctantDepth() { return m_nCurOctantDepth; }
    34   Int   getInputBitDepthY()  { return m_nInputBitDepthY;  }
    35   Int   getOutputBitDepthY()  { return m_nOutputBitDepthY;  }
    36   Int   getInputBitDepthC()  { return m_nInputBitDepthC;  }
    37   Int   getOutputBitDepthC()  { return m_nOutputBitDepthC;  }
    38   Int   getResQuantBit()     { return m_nResQuanBit; }
    39   Void  setResQuantBit(Int n){ m_nResQuanBit = n; }
    40 #if R0300_CGS_RES_COEFF_CODING
    41   Int   getMappingShift()     { return m_nMappingShift; }
    42   Int   getDeltaBits()        { return m_nDeltaBits; }
    43   Void  setDeltaBits(Int n)   { m_nDeltaBits = n; }
    44 #endif
    45   Int   getMaxYPartNumLog2() { return m_nMaxYPartNumLog2; }
    46   Int   getCurYPartNumLog2() { return m_nCurYPartNumLog2; }
     32  Int   getMaxOctantDepth()   { return m_nMaxOctantDepth; }
     33  Int   getCurOctantDepth()   { return m_nCurOctantDepth; }
     34  Int   getInputBitDepthY()   { return m_nInputBitDepthY;  }
     35  Int   getOutputBitDepthY()  { return m_nOutputBitDepthY; }
     36  Int   getInputBitDepthC()   { return m_nInputBitDepthC;  }
     37  Int   getOutputBitDepthC()  { return m_nOutputBitDepthC; }
     38  Int   getResQuantBit()      { return m_nResQuanBit;      }
     39  Void  setResQuantBit(Int n) { m_nResQuanBit = n;        }
     40
     41  Int   getMappingShift()     { return m_nMappingShift;    }
     42  Int   getDeltaBits()        { return m_nDeltaBits;       }
     43  Void  setDeltaBits(Int n)   { m_nDeltaBits = n;          }
     44
     45  Int   getMaxYPartNumLog2()  { return m_nMaxYPartNumLog2; }
     46  Int   getCurYPartNumLog2()  { return m_nCurYPartNumLog2; }
    4747
    4848  Void  addRefLayerId( UInt uiRefLayerId ) 
     
    101101  Int   m_nMappingOffset;
    102102  Int   m_nResQuanBit;
    103 #if R0300_CGS_RES_COEFF_CODING
    104103  Int   m_nDeltaBits;
    105 #endif
     104
    106105  SCuboid *** m_pCuboid;
    107106  const static Int m_nVertexIdxOffset[4][3];
  • branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h

    r1214 r1215  
    5757#define CGS_3D_ASYMLUT                   1      ///< Colour gamut scalability with look-up table
    5858#if CGS_3D_ASYMLUT
    59 #define CGS_GCC_NO_VECTORIZATION         1
     59#define CGS_GCC_NO_VECTORIZATION         1      ///< disable victorization to avoid issues with some compilers
    6060#define R0164_CGS_LUT_BUGFIX             1      ///< JCTVC-R0164: Bug fix with LUT syntax
    6161#define R0164_CGS_LUT_BUGFIX_CHECK       0      ///< JCTVC-R0164: Add traces explicitly/non-explicitly encoded vertices and check if 3DLUT is correctly filled
    6262#define R0179_CGS_SIZE_8x1x1             1      ///< JCTVC-R0179: allow CGS LUT size to be 8x1x1 as well
    63 #define R0300_CGS_RES_COEFF_CODING       1      ///< JCTVC-R0300: improved residual coefficient coding for R0151
    6463#define R0179_ENC_OPT_3DLUT_SIZE         0      ///< JCTVC-R0179: RD decision based LUT size selection
    6564#endif
  • branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r1214 r1215  
    35163516  }
    35173517
    3518   UInt uiCurOctantDepth , uiCurPartNumLog2 , uiInputBitDepthM8 , uiOutputBitDepthM8 , uiResQaunBit;
    3519 #if R0300_CGS_RES_COEFF_CODING
    3520   UInt uiDeltaBits;
    3521 #endif
     3518  UInt uiCurOctantDepth, uiCurPartNumLog2, uiInputBitDepthM8, uiOutputBitDepthM8, uiResQaunBit, uiDeltaBits;;
     3519 
    35223520  READ_CODE( 2 , uiCurOctantDepth , "cm_octant_depth" );
    35233521  READ_CODE( 2 , uiCurPartNumLog2 , "cm_y_part_num_log2" );     
     
    35303528  READ_UVLC( uiChromaOutputBitDepthM8 , "cm_output_chroma_bit_depth_minus8" );
    35313529  READ_CODE( 2 , uiResQaunBit , "cm_res_quant_bit" );
    3532 #if R0300_CGS_RES_COEFF_CODING
     3530
    35333531  READ_CODE( 2 , uiDeltaBits , "cm_flc_bits" );
    35343532  pc3DAsymLUT->setDeltaBits(uiDeltaBits + 1);
    3535 #endif
    35363533
    35373534  Int nAdaptCThresholdU = 1 << ( uiChromaInputBitDepthM8 + 8 - 1 );
     
    35883585  else
    35893586  {
    3590 #if R0300_CGS_RES_COEFF_CODING
    35913587    Int nFLCbits = pc3DAsymLUT->getMappingShift()-pc3DAsymLUT->getResQuantBit()-pc3DAsymLUT->getDeltaBits() ;
    35923588    nFLCbits = nFLCbits >= 0 ? nFLCbits:0;
    3593 #endif
     3589
    35943590    for( Int l = 0 ; l < nYPartNum ; l++ )
    35953591    {
     
    36043600        if( uiCodeVertex )
    36053601        {
    3606 #if R0300_CGS_RES_COEFF_CODING
    36073602          xReadParam( deltaY, nFLCbits );
    36083603          xReadParam( deltaU, nFLCbits );
    36093604          xReadParam( deltaV, nFLCbits );
    3610 #else
    3611           xReadParam( deltaY );
    3612           xReadParam( deltaU );
    3613           xReadParam( deltaV );
    3614 #endif
    36153605        }
    36163606#if R0164_CGS_LUT_BUGFIX
     
    36503640}
    36513641
    3652 #if R0300_CGS_RES_COEFF_CODING
    36533642Void TDecCavlc::xReadParam( Int& param, Int rParam )
    3654 #else
    3655 Void TDecCavlc::xReadParam( Int& param )
    3656 #endif
    3657 {
    3658 #if !R0300_CGS_RES_COEFF_CODING
    3659   const UInt rParam = 7;
    3660 #endif
     3643{
    36613644  UInt prefix;
    36623645  UInt codeWord ;
  • branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.h

    r1214 r1215  
    148148  Void xParse3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT );
    149149  Void xParse3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength );
    150 #if R0300_CGS_RES_COEFF_CODING
    151150  Void xReadParam( Int& param, Int flc_bits );
    152 #else
    153   Void xReadParam( Int& param );
    154 #endif
    155151#endif
    156152#endif //SVC_EXTENSION
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp

    r1214 r1215  
    24672467}
    24682468
    2469 #if CGS_3D_ASYMLUT
    2470 Void TEncCavlc::xCode3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT )
    2471 {
    2472   UInt uiNumRefLayers = ( UInt )pc3DAsymLUT->getRefLayerNum();
    2473   WRITE_UVLC( uiNumRefLayers - 1 , "num_cm_ref_layers_minus1" );
    2474   for( UInt i = 0 ; i < uiNumRefLayers ; i++ )
    2475   {
    2476     WRITE_CODE( pc3DAsymLUT->getRefLayerId( i ) , 6 , "cm_ref_layer_id" );
    2477   }
    2478 
    2479   assert( pc3DAsymLUT->getCurOctantDepth() < 4 );
    2480   WRITE_CODE( pc3DAsymLUT->getCurOctantDepth() , 2 , "cm_octant_depth" );
    2481   assert( pc3DAsymLUT->getCurYPartNumLog2() < 4 );
    2482   WRITE_CODE( pc3DAsymLUT->getCurYPartNumLog2() , 2 , "cm_y_part_num_log2" );
    2483   assert( pc3DAsymLUT->getInputBitDepthY() < 16 );
    2484 
    2485   WRITE_UVLC( pc3DAsymLUT->getInputBitDepthY() - 8 , "cm_input_luma_bit_depth_minus8" );
    2486   WRITE_UVLC( pc3DAsymLUT->getInputBitDepthC() - 8 , "cm_input_chroma_bit_depth_minus8" );
    2487   WRITE_UVLC( pc3DAsymLUT->getOutputBitDepthY() - 8 , "cm_output_luma_bit_depth_minus8" );
    2488   WRITE_UVLC( pc3DAsymLUT->getOutputBitDepthC() - 8 , "cm_output_chroma_bit_depth_minus8" );
    2489 
    2490   assert( pc3DAsymLUT->getResQuantBit() < 4 );
    2491   WRITE_CODE( pc3DAsymLUT->getResQuantBit() , 2 , "cm_res_quant_bit" );
    2492 #if R0300_CGS_RES_COEFF_CODING
    2493   xFindDeltaBits( pc3DAsymLUT );
    2494   assert(pc3DAsymLUT->getDeltaBits() >=1 && pc3DAsymLUT->getDeltaBits() <= 4);
    2495   WRITE_CODE( pc3DAsymLUT->getDeltaBits()-1 , 2 , "cm_delta_bit" );
    2496 #endif
    2497 
    2498   if( pc3DAsymLUT->getCurOctantDepth() == 1 )
    2499   {
    2500     WRITE_SVLC( pc3DAsymLUT->getAdaptChromaThresholdU() - ( 1 << ( pc3DAsymLUT->getInputBitDepthC() - 1 ) ) , "cm_adapt_threshold_u_delta" );
    2501     WRITE_SVLC( pc3DAsymLUT->getAdaptChromaThresholdV() - ( 1 << ( pc3DAsymLUT->getInputBitDepthC() - 1 ) ) , "cm_adapt_threshold_v_delta" );
    2502   }
    2503 
    2504 #if R0164_CGS_LUT_BUGFIX_CHECK
    2505   pc3DAsymLUT->xInitCuboids();
    2506 #endif
    2507   xCode3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() );
    2508 #if R0164_CGS_LUT_BUGFIX_CHECK
    2509   xCuboidsFilledCheck( false );
    2510   pc3DAsymLUT->display( false );
    2511 #endif
    2512 }
    2513 
    2514 Void TEncCavlc::xCode3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength )
    2515 {
    2516   UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth();
    2517   if( nDepth < pc3DAsymLUT->getCurOctantDepth() )
    2518     WRITE_FLAG( uiOctantSplit , "split_octant_flag" );
    2519   Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2();
    2520   if( uiOctantSplit )
    2521   {
    2522     Int nHalfLength = nLength >> 1;
    2523     for( Int l = 0 ; l < 2 ; l++ )
    2524     {
    2525       for( Int m = 0 ; m < 2 ; m++ )
    2526       {
    2527         for( Int n = 0 ; n < 2 ; n++ )
    2528         {
    2529           xCode3DAsymLUTOctant( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength );
    2530         }
    2531       }
    2532     }
    2533   }
    2534   else
    2535   {
    2536 #if R0300_CGS_RES_COEFF_CODING
    2537     Int nFLCbits = pc3DAsymLUT->getMappingShift()-pc3DAsymLUT->getResQuantBit()-pc3DAsymLUT->getDeltaBits() ;
    2538     nFLCbits = nFLCbits >= 0 ? nFLCbits : 0;
    2539 #endif
    2540     for( Int l = 0 ; l < nYPartNum ; l++ )
    2541     {
    2542 #if R0164_CGS_LUT_BUGFIX     
    2543       Int shift = pc3DAsymLUT->getCurOctantDepth() - nDepth ;
    2544 #endif
    2545       for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ )
    2546       {
    2547 #if R0164_CGS_LUT_BUGFIX
    2548         SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + (l<<shift) , uIdx , vIdx , nVertexIdx );
    2549 #else
    2550         SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx );
    2551 #endif
    2552         UInt uiCodeVertex = sRes.Y != 0 || sRes.U != 0 || sRes.V != 0;
    2553         WRITE_FLAG( uiCodeVertex , "coded_vertex_flag" );
    2554         if( uiCodeVertex )
    2555         {
    2556 #if R0300_CGS_RES_COEFF_CODING
    2557           xWriteParam( sRes.Y, nFLCbits );
    2558           xWriteParam( sRes.U, nFLCbits );
    2559           xWriteParam( sRes.V, nFLCbits );
    2560 #else
    2561           xWriteParam( sRes.Y );
    2562           xWriteParam( sRes.U );
    2563           xWriteParam( sRes.V );
    2564 #endif
    2565         }
    2566       }
    2567 #if R0164_CGS_LUT_BUGFIX_CHECK
    2568       pc3DAsymLUT->xSetExplicit( yIdx + (l<<shift) , uIdx , vIdx );
    2569 #endif
    2570     }
    2571   }
    2572 }
    2573 
    2574 #if R0300_CGS_RES_COEFF_CODING
    2575 Void TEncCavlc::xWriteParam( Int param, UInt rParam)
    2576 #else
    2577 Void TEncCavlc::xWriteParam( Int param)
    2578 #endif
    2579 {
    2580 #if !R0300_CGS_RES_COEFF_CODING
    2581   const UInt rParam = 7;
    2582 #endif
    2583   Int codeNumber = abs(param);
    2584   WRITE_UVLC(codeNumber / (1 << rParam), "quotient");
    2585   WRITE_CODE((codeNumber % (1 << rParam)), rParam, "remainder");
    2586   if (abs(param))
    2587     WRITE_FLAG( param <0, "sign");
    2588 }
    2589 
    2590 #if R0300_CGS_RES_COEFF_CODING
    2591 Void TEncCavlc::xFindDeltaBits( TCom3DAsymLUT * pc3DAsymLUT )
    2592 {
    2593   Int nDeltaBits;
    2594   Int nBestDeltaBits = -1;
    2595   Int nBestBits = MAX_INT;
    2596   for( nDeltaBits = 1; nDeltaBits < 5; nDeltaBits++)
    2597   {
    2598     Int nCurBits = 0;
    2599     xTally3DAsymLUTOctantBits( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth(), nDeltaBits, nCurBits );
    2600     //printf("%d, %d, %d\n", nDeltaBits, nCurBits, nBestBits);
    2601     if(nCurBits < nBestBits)
    2602     {
    2603       nBestDeltaBits = nDeltaBits;
    2604       nBestBits = nCurBits;
    2605     }
    2606   }
    2607 
    2608   assert(nBestDeltaBits >=1 && nBestDeltaBits < 5);
    2609   pc3DAsymLUT->setDeltaBits(nBestDeltaBits);
    2610 }
    2611 
    2612 Void TEncCavlc::xTally3DAsymLUTOctantBits( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength, Int nDeltaBits, Int& nCurBits )
    2613 {
    2614   UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth();
    2615   if( nDepth < pc3DAsymLUT->getCurOctantDepth() )
    2616     nCurBits ++;
    2617   Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2();
    2618   if( uiOctantSplit )
    2619   {
    2620     Int nHalfLength = nLength >> 1;
    2621     for( Int l = 0 ; l < 2 ; l++ )
    2622     {
    2623       for( Int m = 0 ; m < 2 ; m++ )
    2624       {
    2625         for( Int n = 0 ; n < 2 ; n++ )
    2626         {
    2627           xTally3DAsymLUTOctantBits( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength, nDeltaBits, nCurBits );
    2628         }
    2629       }
    2630     }
    2631   }
    2632   else
    2633   {
    2634     Int nFLCbits = pc3DAsymLUT->getMappingShift()-pc3DAsymLUT->getResQuantBit()-nDeltaBits ;
    2635     nFLCbits = nFLCbits >= 0 ? nFLCbits:0;
    2636     //printf("nFLCbits = %d\n", nFLCbits);
    2637 
    2638     for( Int l = 0 ; l < nYPartNum ; l++ )
    2639     {
    2640       for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ )
    2641       {
    2642         SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx );
    2643 
    2644         UInt uiCodeVertex = sRes.Y != 0 || sRes.U != 0 || sRes.V != 0;
    2645         nCurBits++;
    2646         if( uiCodeVertex )
    2647         {
    2648           xCheckParamBits( sRes.Y, nFLCbits, nCurBits );
    2649           xCheckParamBits( sRes.U, nFLCbits, nCurBits );
    2650           xCheckParamBits( sRes.V, nFLCbits, nCurBits );
    2651         }
    2652       }
    2653     }
    2654   }
    2655 }
    2656 
    2657 Void TEncCavlc::xCheckParamBits( Int param, Int rParam, Int &nBits)
    2658 {
    2659   Int codeNumber = abs(param);
    2660   Int codeQuotient = codeNumber >> rParam;
    2661   Int qLen;
    2662 
    2663   UInt uiLength = 1;
    2664   UInt uiTemp = ++codeQuotient;
    2665    
    2666   while( 1 != uiTemp )
    2667   {
    2668     uiTemp >>= 1;
    2669     uiLength += 2;
    2670   }
    2671 
    2672   qLen  = (uiLength >> 1);
    2673   qLen += ((uiLength+1) >> 1);
    2674 
    2675   nBits += qLen;
    2676   nBits += rParam;
    2677   if (abs(param))
    2678     nBits++;
    2679 }
    2680 #endif
    2681 #endif
    2682 
    26832469Void TEncCavlc::codeVpsVuiBspHrdParams(TComVPS * const vps)
    26842470{
     
    27482534}
    27492535
     2536
     2537#if CGS_3D_ASYMLUT
     2538Void TEncCavlc::xCode3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT )
     2539{
     2540  UInt uiNumRefLayers = ( UInt )pc3DAsymLUT->getRefLayerNum();
     2541  WRITE_UVLC( uiNumRefLayers - 1 , "num_cm_ref_layers_minus1" );
     2542  for( UInt i = 0 ; i < uiNumRefLayers ; i++ )
     2543  {
     2544    WRITE_CODE( pc3DAsymLUT->getRefLayerId( i ) , 6 , "cm_ref_layer_id" );
     2545  }
     2546
     2547  assert( pc3DAsymLUT->getCurOctantDepth() < 4 );
     2548  WRITE_CODE( pc3DAsymLUT->getCurOctantDepth() , 2 , "cm_octant_depth" );
     2549  assert( pc3DAsymLUT->getCurYPartNumLog2() < 4 );
     2550  WRITE_CODE( pc3DAsymLUT->getCurYPartNumLog2() , 2 , "cm_y_part_num_log2" );
     2551  assert( pc3DAsymLUT->getInputBitDepthY() < 16 );
     2552
     2553  WRITE_UVLC( pc3DAsymLUT->getInputBitDepthY() - 8 , "cm_input_luma_bit_depth_minus8" );
     2554  WRITE_UVLC( pc3DAsymLUT->getInputBitDepthC() - 8 , "cm_input_chroma_bit_depth_minus8" );
     2555  WRITE_UVLC( pc3DAsymLUT->getOutputBitDepthY() - 8 , "cm_output_luma_bit_depth_minus8" );
     2556  WRITE_UVLC( pc3DAsymLUT->getOutputBitDepthC() - 8 , "cm_output_chroma_bit_depth_minus8" );
     2557
     2558  assert( pc3DAsymLUT->getResQuantBit() < 4 );
     2559  WRITE_CODE( pc3DAsymLUT->getResQuantBit() , 2 , "cm_res_quant_bit" );
     2560
     2561  xFindDeltaBits( pc3DAsymLUT );
     2562  assert(pc3DAsymLUT->getDeltaBits() >=1 && pc3DAsymLUT->getDeltaBits() <= 4);
     2563  WRITE_CODE( pc3DAsymLUT->getDeltaBits()-1 , 2 , "cm_delta_bit" );
     2564
     2565  if( pc3DAsymLUT->getCurOctantDepth() == 1 )
     2566  {
     2567    WRITE_SVLC( pc3DAsymLUT->getAdaptChromaThresholdU() - ( 1 << ( pc3DAsymLUT->getInputBitDepthC() - 1 ) ) , "cm_adapt_threshold_u_delta" );
     2568    WRITE_SVLC( pc3DAsymLUT->getAdaptChromaThresholdV() - ( 1 << ( pc3DAsymLUT->getInputBitDepthC() - 1 ) ) , "cm_adapt_threshold_v_delta" );
     2569  }
     2570
     2571#if R0164_CGS_LUT_BUGFIX_CHECK
     2572  pc3DAsymLUT->xInitCuboids();
     2573#endif
     2574  xCode3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() );
     2575#if R0164_CGS_LUT_BUGFIX_CHECK
     2576  xCuboidsFilledCheck( false );
     2577  pc3DAsymLUT->display( false );
     2578#endif
     2579}
     2580
     2581Void TEncCavlc::xCode3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength )
     2582{
     2583  UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth();
     2584  if( nDepth < pc3DAsymLUT->getCurOctantDepth() )
     2585    WRITE_FLAG( uiOctantSplit , "split_octant_flag" );
     2586  Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2();
     2587  if( uiOctantSplit )
     2588  {
     2589    Int nHalfLength = nLength >> 1;
     2590    for( Int l = 0 ; l < 2 ; l++ )
     2591    {
     2592      for( Int m = 0 ; m < 2 ; m++ )
     2593      {
     2594        for( Int n = 0 ; n < 2 ; n++ )
     2595        {
     2596          xCode3DAsymLUTOctant( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength );
     2597        }
     2598      }
     2599    }
     2600  }
     2601  else
     2602  {
     2603    Int nFLCbits = pc3DAsymLUT->getMappingShift()-pc3DAsymLUT->getResQuantBit()-pc3DAsymLUT->getDeltaBits() ;
     2604    nFLCbits = nFLCbits >= 0 ? nFLCbits : 0;
     2605
     2606    for( Int l = 0 ; l < nYPartNum ; l++ )
     2607    {
     2608#if R0164_CGS_LUT_BUGFIX     
     2609      Int shift = pc3DAsymLUT->getCurOctantDepth() - nDepth ;
     2610#endif
     2611      for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ )
     2612      {
     2613#if R0164_CGS_LUT_BUGFIX
     2614        SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + (l<<shift) , uIdx , vIdx , nVertexIdx );
     2615#else
     2616        SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx );
     2617#endif
     2618        UInt uiCodeVertex = sRes.Y != 0 || sRes.U != 0 || sRes.V != 0;
     2619        WRITE_FLAG( uiCodeVertex , "coded_vertex_flag" );
     2620        if( uiCodeVertex )
     2621        {
     2622          xWriteParam( sRes.Y, nFLCbits );
     2623          xWriteParam( sRes.U, nFLCbits );
     2624          xWriteParam( sRes.V, nFLCbits );
     2625        }
     2626      }
     2627#if R0164_CGS_LUT_BUGFIX_CHECK
     2628      pc3DAsymLUT->xSetExplicit( yIdx + (l<<shift) , uIdx , vIdx );
     2629#endif
     2630    }
     2631  }
     2632}
     2633
     2634Void TEncCavlc::xWriteParam( Int param, UInt rParam)
     2635{
     2636  Int codeNumber = abs(param);
     2637  WRITE_UVLC(codeNumber / (1 << rParam), "quotient");
     2638  WRITE_CODE((codeNumber % (1 << rParam)), rParam, "remainder");
     2639  if (abs(param))
     2640    WRITE_FLAG( param <0, "sign");
     2641}
     2642
     2643Void TEncCavlc::xFindDeltaBits( TCom3DAsymLUT * pc3DAsymLUT )
     2644{
     2645  Int nDeltaBits;
     2646  Int nBestDeltaBits = -1;
     2647  Int nBestBits = MAX_INT;
     2648  for( nDeltaBits = 1; nDeltaBits < 5; nDeltaBits++)
     2649  {
     2650    Int nCurBits = 0;
     2651    xTally3DAsymLUTOctantBits( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth(), nDeltaBits, nCurBits );
     2652    //printf("%d, %d, %d\n", nDeltaBits, nCurBits, nBestBits);
     2653    if(nCurBits < nBestBits)
     2654    {
     2655      nBestDeltaBits = nDeltaBits;
     2656      nBestBits = nCurBits;
     2657    }
     2658  }
     2659
     2660  assert(nBestDeltaBits >=1 && nBestDeltaBits < 5);
     2661  pc3DAsymLUT->setDeltaBits(nBestDeltaBits);
     2662}
     2663
     2664Void TEncCavlc::xTally3DAsymLUTOctantBits( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength, Int nDeltaBits, Int& nCurBits )
     2665{
     2666  UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth();
     2667  if( nDepth < pc3DAsymLUT->getCurOctantDepth() )
     2668    nCurBits ++;
     2669  Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2();
     2670  if( uiOctantSplit )
     2671  {
     2672    Int nHalfLength = nLength >> 1;
     2673    for( Int l = 0 ; l < 2 ; l++ )
     2674    {
     2675      for( Int m = 0 ; m < 2 ; m++ )
     2676      {
     2677        for( Int n = 0 ; n < 2 ; n++ )
     2678        {
     2679          xTally3DAsymLUTOctantBits( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength, nDeltaBits, nCurBits );
     2680        }
     2681      }
     2682    }
     2683  }
     2684  else
     2685  {
     2686    Int nFLCbits = pc3DAsymLUT->getMappingShift()-pc3DAsymLUT->getResQuantBit()-nDeltaBits ;
     2687    nFLCbits = nFLCbits >= 0 ? nFLCbits:0;
     2688    //printf("nFLCbits = %d\n", nFLCbits);
     2689
     2690    for( Int l = 0 ; l < nYPartNum ; l++ )
     2691    {
     2692      for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ )
     2693      {
     2694        SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx );
     2695
     2696        UInt uiCodeVertex = sRes.Y != 0 || sRes.U != 0 || sRes.V != 0;
     2697        nCurBits++;
     2698        if( uiCodeVertex )
     2699        {
     2700          xCheckParamBits( sRes.Y, nFLCbits, nCurBits );
     2701          xCheckParamBits( sRes.U, nFLCbits, nCurBits );
     2702          xCheckParamBits( sRes.V, nFLCbits, nCurBits );
     2703        }
     2704      }
     2705    }
     2706  }
     2707}
     2708
     2709Void TEncCavlc::xCheckParamBits( Int param, Int rParam, Int &nBits)
     2710{
     2711  Int codeNumber = abs(param);
     2712  Int codeQuotient = codeNumber >> rParam;
     2713  Int qLen;
     2714
     2715  UInt uiLength = 1;
     2716  UInt uiTemp = ++codeQuotient;
     2717   
     2718  while( 1 != uiTemp )
     2719  {
     2720    uiTemp >>= 1;
     2721    uiLength += 2;
     2722  }
     2723
     2724  qLen  = (uiLength >> 1);
     2725  qLen += ((uiLength+1) >> 1);
     2726
     2727  nBits += qLen;
     2728  nBits += rParam;
     2729  if (abs(param))
     2730    nBits++;
     2731}
     2732#endif //CGS_3D_ASYMLUT
     2733
    27502734#endif //SVC_EXTENSION
    27512735//! \}
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.h

    r1214 r1215  
    163163#endif
    164164  Void  codeVpsVuiBspHrdParams  (TComVPS * const);
     165
    165166#if CGS_3D_ASYMLUT
    166167#if R0179_ENC_OPT_3DLUT_SIZE
     
    174175  Void xCode3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength );
    175176#endif
    176 #if R0300_CGS_RES_COEFF_CODING
    177177  Void xWriteParam( Int param, UInt nFLCBits);
    178178  Void xCheckParamBits( Int param, Int nFLCBits, Int & nCurBits);
    179179  Void xTally3DAsymLUTOctantBits( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength, Int nDeltaBits, Int &nCurBits);
    180180  Void xFindDeltaBits( TCom3DAsymLUT * pc3DAsymLUT );
    181 #else
    182   Void xWriteParam( Int param);
    183 #endif
    184 #endif
     181#endif //CGS_3D_ASYMLUT
    185182#endif //SVC_EXTENSION
    186183
Note: See TracChangeset for help on using the changeset viewer.