Changeset 758 in 3DVCSoftware for trunk/source/Lib/TLibEncoder/TEncCavlc.cpp


Ignore:
Timestamp:
3 Jan 2014, 17:43:40 (10 years ago)
Author:
tech
Message:

Merged HTM-9.1-dev0-MediaTek@757. (3D-HEVC HLS)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibEncoder/TEncCavlc.cpp

    r738 r758  
    256256  WRITE_UVLC( pcPPS->getLog2ParallelMergeLevelMinus2(), "log2_parallel_merge_level_minus2");
    257257  WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_segment_header_extension_present_flag");
     258
     259#if !DLT_DIFF_CODING_IN_PPS
    258260  WRITE_FLAG( 0, "pps_extension_flag" );
    259 }
     261#else
     262  WRITE_FLAG( 1, "pps_extension_flag" );
     263  codePPSExtension( pcPPS );
     264  WRITE_FLAG( 0, "pps_extension2_flag" );
     265#endif
     266}
     267
     268#if DLT_DIFF_CODING_IN_PPS
     269Void  TEncCavlc::codePPSExtension        ( TComPPS* pcPPS )
     270{
     271  // Assuming that all PPS indirectly refer to the same VPS via different SPS
     272  // There is no parsing dependency in decoding DLT in PPS.
     273  // The VPS information passed to decodePPS() is used to arrange the decoded DLT tables to their corresponding layers.
     274  // This is equivalent to the process of
     275  //   Step 1) decoding DLT tables based on the number of depth layers, and
     276  //   Step 2) mapping DLT tables to the depth layers
     277  // as descripted in the 3D-HEVC WD.
     278  TComVPS* pcVPS = pcPPS->getSPS()->getVPS();
     279
     280  TComDLT* pcDLT = pcPPS->getDLT();
     281
     282  WRITE_FLAG( pcDLT->getDltPresentFlag() ? 1 : 0, "dlt_present_flag" );
     283
     284  if ( pcDLT->getDltPresentFlag() )
     285  {
     286    WRITE_CODE(pcDLT->getNumDepthViews(), 6, "pps_depth_layers_minus1");
     287    WRITE_CODE((pcDLT->getDepthViewBitDepth() - 8), 4, "pps_bit_depth_for_depth_views_minus8");
     288
     289    for( Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ )
     290    {
     291      if ( i != 0 )
     292      {
     293        if ( pcVPS->getDepthId( i ) == 1 )
     294        {
     295          WRITE_FLAG( pcDLT->getUseDLTFlag( i ) ? 1 : 0, "dlt_flag[i]" );
     296
     297          if ( pcDLT->getUseDLTFlag( i ) )
     298          {
     299            WRITE_FLAG( pcDLT->getInterViewDltPredEnableFlag( i ) ? 1 : 0, "inter_view_dlt_pred_enable_flag[ i ]");
     300
     301            // ----------------------------- determine whether to use bit-map -----------------------------
     302            Bool bDltBitMapRepFlag       = false;
     303            UInt uiNumBitsNonBitMap      = 0;
     304            UInt uiNumBitsBitMap         = 0;
     305
     306            UInt uiMaxDiff               = 0;
     307            UInt uiMinDiff               = 0xffffffff;
     308            UInt uiLengthMinDiff         = 0;
     309            UInt uiLengthDltDiffMinusMin = 0;
     310
     311            UInt* puiDltDiffValues       = NULL;
     312           
     313            Int aiIdx2DepthValue_coded[256];
     314            UInt uiNumDepthValues_coded = 0;
     315           
     316            uiNumDepthValues_coded = pcDLT->getNumDepthValues(i);
     317            for( UInt ui = 0; ui<uiNumDepthValues_coded; ui++ )
     318            {
     319              aiIdx2DepthValue_coded[ui] = pcDLT->idx2DepthValue(i, ui);
     320            }
     321           
     322#if H_3D_DELTA_DLT
     323            if( pcDLT->getInterViewDltPredEnableFlag( i ) )
     324            {
     325              AOF( pcVPS->getDepthId( 1 ) == 1 );
     326              AOF( i > 1 );
     327              // assumes ref layer id to be 1
     328              Int* piRefDLT = pcDLT->idx2DepthValue( 1 );
     329              UInt uiRefNum = pcDLT->getNumDepthValues( 1 );
     330              pcDLT->getDeltaDLT(i, piRefDLT, uiRefNum, aiIdx2DepthValue_coded, &uiNumDepthValues_coded);
     331            }
     332#endif
     333
     334            if ( NULL == (puiDltDiffValues = (UInt *)calloc(uiNumDepthValues_coded, sizeof(UInt))) )
     335            {
     336              exit(-1);
     337            }
     338
     339            for (UInt d = 1; d < uiNumDepthValues_coded; d++)
     340            {
     341              puiDltDiffValues[d] = aiIdx2DepthValue_coded[d] - aiIdx2DepthValue_coded[d-1];
     342
     343              if ( uiMaxDiff < puiDltDiffValues[d] )
     344              {
     345                uiMaxDiff = puiDltDiffValues[d];
     346              }
     347
     348              if ( uiMinDiff > puiDltDiffValues[d] )
     349              {
     350                uiMinDiff = puiDltDiffValues[d];
     351              }
     352            }
     353
     354            // counting bits
     355            // diff coding branch
     356            uiNumBitsNonBitMap += 8;                          // u(v) bits for num_depth_values_in_dlt[layerId] (i.e. num_entry[ layerId ])
     357
     358            if ( uiNumDepthValues_coded > 1 )
     359            {
     360              uiNumBitsNonBitMap += 8;                        // u(v) bits for max_diff[ layerId ]
     361            }
     362
     363            if ( uiNumDepthValues_coded > 2 )
     364            {
     365              uiLengthMinDiff    = (UInt) ceil(Log2(uiMaxDiff + 1));
     366              uiNumBitsNonBitMap += uiLengthMinDiff;          // u(v)  bits for min_diff[ layerId ]
     367            }
     368
     369            uiNumBitsNonBitMap += 8;                          // u(v) bits for dlt_depth_value0[ layerId ]
     370
     371            if (uiMaxDiff > uiMinDiff)
     372            {
     373              uiLengthDltDiffMinusMin = (UInt) ceil(Log2(uiMaxDiff - uiMinDiff + 1));
     374              uiNumBitsNonBitMap += uiLengthDltDiffMinusMin * (uiNumDepthValues_coded - 1);  // u(v) bits for dlt_depth_value_diff_minus_min[ layerId ][ j ]
     375            }
     376
     377            // bit map branch
     378            uiNumBitsBitMap = 256;   // uiNumBitsBitMap = 1 << pcDLT->getDepthViewBitDepth();
     379
     380            // determine bDltBitMapFlag
     381            bDltBitMapRepFlag = (uiNumBitsBitMap > uiNumBitsNonBitMap) ? false : true;
     382
     383            // ----------------------------- Actual coding -----------------------------
     384            if ( pcDLT->getInterViewDltPredEnableFlag( i ) == false )
     385            {
     386              WRITE_FLAG( bDltBitMapRepFlag ? 1 : 0, "dlt_bit_map_rep_flag[ layerId ]" );
     387            }
     388            else
     389            {
     390              bDltBitMapRepFlag = false;
     391            }
     392
     393            // bit map coding
     394            if ( bDltBitMapRepFlag )
     395            {
     396              UInt uiDltArrayIndex = 0;
     397              for (UInt d=0; d < 256; d++)
     398              {
     399                if ( d == aiIdx2DepthValue_coded[uiDltArrayIndex] )
     400                {                 
     401                  WRITE_FLAG(1, "dlt_bit_map_flag[ layerId ][ j ]");
     402                  uiDltArrayIndex++;
     403                }
     404                else
     405                {
     406                  WRITE_FLAG(0, "dlt_bit_map_flag[ layerId ][ j ]");
     407                }
     408              }
     409            }
     410            // Diff Coding
     411            else
     412            {
     413              WRITE_CODE(uiNumDepthValues_coded, 8, "num_depth_values_in_dlt[layerId]");    // num_entry
     414
     415#if !H_3D_DELTA_DLT
     416              if ( pcDLT->getInterViewDltPredEnableFlag( i ) == false )   // Single-view DLT Diff Coding
     417#endif
     418              {
     419                // The condition if( uiNumDepthValues_coded > 0 ) is always true since for Single-view Diff Coding, there is at least one depth value in depth component.
     420                if ( uiNumDepthValues_coded > 1 )
     421                {
     422                  WRITE_CODE(uiMaxDiff, 8, "max_diff[ layerId ]");        // max_diff
     423                }
     424
     425                if ( uiNumDepthValues_coded > 2 )
     426                {
     427                  WRITE_CODE((uiMinDiff - 1), uiLengthMinDiff, "min_diff_minus1[ layerId ]");     // min_diff_minus1
     428                }
     429
     430                WRITE_CODE(aiIdx2DepthValue_coded[0], 8, "dlt_depth_value0[layerId]");          // entry0
     431
     432                if (uiMaxDiff > uiMinDiff)
     433                {
     434                  for (UInt d=1; d < uiNumDepthValues_coded; d++)
     435                  {
     436                    WRITE_CODE( (puiDltDiffValues[d] - uiMinDiff), uiLengthDltDiffMinusMin, "dlt_depth_value_diff_minus_min[ layerId ][ j ]");    // entry_value_diff_minus_min[ k ]
     437                  }
     438                }
     439              }
     440            }
     441
     442            free(puiDltDiffValues);
     443          }
     444        }
     445      }
     446    }
     447  }
     448}
     449#endif
    260450
    261451Void TEncCavlc::codeVUI( TComVUI *pcVUI, TComSPS* pcSPS )
     
    671861}
    672862#endif
    673   if (!depthFlag )
    674   {
    675     WRITE_UVLC( pcSPS->getCamParPrecision(), "cp_precision" );
    676     WRITE_FLAG( pcSPS->hasCamParInSliceHeader() ? 1 : 0, "cp_in_slice_header_flag" );
    677     if( !pcSPS->hasCamParInSliceHeader() )
    678     {
    679       for( UInt uiIndex = 0; uiIndex < viewIndex; uiIndex++ )
    680       {
    681         WRITE_SVLC( pcSPS->getCodedScale    ()[ uiIndex ],                                      "cp_scale" );
    682         WRITE_SVLC( pcSPS->getCodedOffset   ()[ uiIndex ],                                      "cp_off" );
    683         WRITE_SVLC( pcSPS->getInvCodedScale ()[ uiIndex ] + pcSPS->getCodedScale ()[ uiIndex ], "cp_inv_scale_plus_scale" );
    684         WRITE_SVLC( pcSPS->getInvCodedOffset()[ uiIndex ] + pcSPS->getCodedOffset()[ uiIndex ], "cp_inv_off_plus_off" );
    685       }
    686     }
    687   }
     863#if !CAM_HLS_F0136_F0045_F0082
     864if (!depthFlag )
     865{
     866  WRITE_UVLC( pcSPS->getCamParPrecision(), "cp_precision" );
     867  WRITE_FLAG( pcSPS->hasCamParInSliceHeader() ? 1 : 0, "cp_in_slice_header_flag" );
     868  if( !pcSPS->hasCamParInSliceHeader() )
     869  {
     870    for( UInt uiIndex = 0; uiIndex < viewIndex; uiIndex++ )
     871    {
     872      WRITE_SVLC( pcSPS->getCodedScale    ()[ uiIndex ],                                      "cp_scale" );
     873      WRITE_SVLC( pcSPS->getCodedOffset   ()[ uiIndex ],                                      "cp_off" );
     874      WRITE_SVLC( pcSPS->getInvCodedScale ()[ uiIndex ] + pcSPS->getCodedScale ()[ uiIndex ], "cp_inv_scale_plus_scale" );
     875      WRITE_SVLC( pcSPS->getInvCodedOffset()[ uiIndex ] + pcSPS->getCodedOffset()[ uiIndex ], "cp_inv_off_plus_off" );
     876    }
     877  }
     878}
     879#endif
    688880}
    689881#endif
     
    14631655        //WRITE_FLAG( pcVPS->getLimQtPredFlag    ( i ) ? 1 : 0 ,          "lim_qt_pred_flag[i]"     );
    14641656#if H_3D_DIM_DLT
     1657#if !DLT_DIFF_CODING_IN_PPS
    14651658        if( pcVPS->getVpsDepthModesFlag( i ) )
    14661659        {
     
    14751668            WRITE_UVLC( pcVPS->idx2DepthValue(i, d), "dlt_depth_value[i][d]" );
    14761669          }
    1477         }       
     1670        }
     1671#endif
    14781672#endif
    14791673#if H_3D_INTER_SDC
     
    14831677    } 
    14841678  }
     1679#if CAM_HLS_F0136_F0045_F0082
     1680  WRITE_UVLC( pcVPS->getCamParPrecision(), "cp_precision" );
     1681  for (UInt viewIndex=0; viewIndex<pcVPS->getNumViews(); viewIndex++)
     1682  {
     1683    WRITE_FLAG( pcVPS->getCamParPresent(viewIndex) ? 1 : 0, "cp_present_flag[i]" );
     1684    if ( pcVPS->getCamParPresent(viewIndex) )
     1685    {
     1686      WRITE_FLAG( pcVPS->hasCamParInSliceHeader(viewIndex) ? 1 : 0, "cp_in_slice_segment_header_flag[i]" );
     1687      if ( !pcVPS->hasCamParInSliceHeader(viewIndex) )
     1688      {
     1689        for( UInt uiIndex = 0; uiIndex < viewIndex; uiIndex++ )
     1690        {
     1691          WRITE_SVLC( pcVPS->getCodedScale    (viewIndex)[ uiIndex ],                                               "vps_cp_scale" );
     1692          WRITE_SVLC( pcVPS->getCodedOffset   (viewIndex)[ uiIndex ],                                               "vps_cp_off" );
     1693          WRITE_SVLC( pcVPS->getInvCodedScale (viewIndex)[ uiIndex ] + pcVPS->getCodedScale (viewIndex)[ uiIndex ], "vps_cp_inv_scale_plus_scale" );
     1694          WRITE_SVLC( pcVPS->getInvCodedOffset(viewIndex)[ uiIndex ] + pcVPS->getCodedOffset(viewIndex)[ uiIndex ], "vps_cp_inv_off_plus_off" );
     1695        }
     1696      }
     1697    }
     1698  }
     1699#endif
    14851700#if H_3D_TMVP
    14861701  WRITE_FLAG( pcVPS->getIvMvScalingFlag( ) ? 1 : 0 ,          "iv_mv_scaling_flag" );
     
    19472162    }
    19482163  }
     2164#if CAM_HLS_F0044
     2165#if QC_DEPTH_IV_MRG_F0125
     2166#if CAM_HLS_F0136_F0045_F0082
     2167  if( pcSlice->getVPS()->hasCamParInSliceHeader( pcSlice->getViewIndex() ) && !pcSlice->getIsDepth() )
     2168#else
     2169  if( pcSlice->getSPS()->hasCamParInSliceHeader() && !pcSlice->getIsDepth() )
     2170#endif
     2171#else
     2172  if( pcSlice->getSPS()->hasCamParInSliceHeader() )
     2173#endif
     2174  {
     2175    for( UInt uiId = 0; uiId < pcSlice->getViewIndex(); uiId++ )
     2176    {
     2177      WRITE_SVLC( pcSlice->getCodedScale    ()[ uiId ],                                     "cp_scale" );
     2178      WRITE_SVLC( pcSlice->getCodedOffset   ()[ uiId ],                                     "cp_off" );
     2179      WRITE_SVLC( pcSlice->getInvCodedScale ()[ uiId ] + pcSlice->getCodedScale ()[ uiId ], "cp_inv_scale_plus_scale" );
     2180      WRITE_SVLC( pcSlice->getInvCodedOffset()[ uiId ] + pcSlice->getCodedOffset()[ uiId ], "cp_inv_off_plus_off" );
     2181    }
     2182  }
     2183#endif
     2184
    19492185  if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag())
    19502186  {
    1951 #if !H_3D
     2187#if !H_3D || CAM_HLS_F0044
    19522188    WRITE_UVLC(0,"slice_header_extension_length");
    19532189#else
    19542190    WRITE_UVLC(0,"slice_header_extension_length"); //<- this element needs to be set to the correct value!!
    1955 
    19562191#if QC_DEPTH_IV_MRG_F0125
     2192#if CAM_HLS_F0136_F0045_F0082
     2193    if( pcSlice->getVPS()->hasCamParInSliceHeader( pcSlice->getViewIndex() ) && !pcSlice->getIsDepth() )
     2194#else
    19572195    if( pcSlice->getSPS()->hasCamParInSliceHeader() && !pcSlice->getIsDepth() )
     2196#endif
    19582197#else
    19592198    if( pcSlice->getSPS()->hasCamParInSliceHeader() )
Note: See TracChangeset for help on using the changeset viewer.