Ignore:
Timestamp:
11 Dec 2015, 00:05:48 (8 years ago)
Author:
seregin
Message:

infer parameters in SPS after activation, fixing chroma scaling for non 4:2:0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp

    r1497 r1502  
    506506                            );
    507507
    508         Bool sameBitDepths = ( getBitDepth(CHANNEL_TYPE_LUMA) == ilpPic[refLayerIdc]->getSlice(0)->getBitDepth(CHANNEL_TYPE_LUMA) ) && ( getBitDepth(CHANNEL_TYPE_CHROMA) == ilpPic[refLayerIdc]->getSlice(0)->getBitDepth(CHANNEL_TYPE_CHROMA) );
     508        Bool sameBitDepths = ( m_pcSPS->getBitDepth(CHANNEL_TYPE_LUMA) == ilpPic[refLayerIdc]->getSlice(0)->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) ) && ( m_pcSPS->getBitDepth(CHANNEL_TYPE_CHROMA) == ilpPic[refLayerIdc]->getSlice(0)->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA) );
    509509
    510510        // motion resampling constraint
     
    18241824        }
    18251825
    1826 #if SVC_EXTENSION
    1827         const Int offsetScalingFactor = bUseHighPrecisionPredictionWeighting ? 1 : (1 << (getBitDepth(toChannelType(ComponentID(yuv)))-8));
    1828 #else
    18291826        const Int offsetScalingFactor = bUseHighPrecisionPredictionWeighting ? 1 : (1 << (sps->getBitDepth(toChannelType(ComponentID(yuv)))-8));
    1830 #endif
    18311827
    18321828        pwp->w      = pwp->iWeight;
     
    32803276}
    32813277
    3282 UInt TComSlice::getPicWidthInLumaSamples()
    3283 {
    3284   UInt retVal, layerId = getLayerId();
    3285 
    3286   if ( layerId == 0 || m_pcSPS->getV1CompatibleSPSFlag() == 1 )
    3287   {
    3288     if( layerId == 0 && m_pcVPS->getNonHEVCBaseLayerFlag() )
    3289     {
    3290       retVal = m_pcVPS->getVpsRepFormat(layerId)->getPicWidthVpsInLumaSamples();
    3291     }
    3292     else
    3293     {
    3294       retVal = m_pcSPS->getPicWidthInLumaSamples();
    3295     }
    3296   }
    3297   else
    3298   {
    3299     retVal = m_pcVPS->getVpsRepFormat(m_pcSPS->getUpdateRepFormatFlag() ? m_pcSPS->getUpdateRepFormatIndex() : m_pcVPS->getVpsRepFormatIdx(m_pcVPS->getLayerIdxInVps(layerId)))->getPicWidthVpsInLumaSamples();
    3300   }
    3301 
    3302   return retVal;
    3303 }
    3304 
    3305 UInt TComVPS::getPicWidthInLumaSamples( const TComSPS* sps, const UInt layerId ) const
    3306 {
    3307   UInt retVal;
    3308 
    3309   if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 )
    3310   {
    3311     if( layerId == 0 && m_nonHEVCBaseLayerFlag )
    3312     {
    3313       retVal = m_vpsRepFormat[layerId].getPicWidthVpsInLumaSamples();
    3314     }
    3315     else
    3316     {
    3317       retVal = sps->getPicWidthInLumaSamples();
    3318     }
    3319   }
    3320   else
    3321   {
    3322     retVal = m_vpsRepFormat[sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : m_vpsRepFormatIdx[m_layerIdxInVps[layerId]]].getPicWidthVpsInLumaSamples();
    3323   }
    3324 
    3325   return retVal;
    3326 }
    3327 
    3328 UInt TComSlice::getPicHeightInLumaSamples()
    3329 {
    3330   UInt retVal, layerId = getLayerId();
    3331 
    3332   if ( layerId == 0 || m_pcSPS->getV1CompatibleSPSFlag() == 1 )
    3333   {
    3334     if( layerId == 0 && m_pcVPS->getNonHEVCBaseLayerFlag() )
    3335     {
    3336       retVal = m_pcVPS->getVpsRepFormat(layerId)->getPicHeightVpsInLumaSamples();
    3337     }
    3338     else
    3339     {
    3340       retVal = m_pcSPS->getPicHeightInLumaSamples();
    3341     }
    3342   }
    3343   else
    3344   {
    3345     retVal = m_pcVPS->getVpsRepFormat(m_pcSPS->getUpdateRepFormatFlag() ? m_pcSPS->getUpdateRepFormatIndex() : m_pcVPS->getVpsRepFormatIdx(m_pcVPS->getLayerIdxInVps(layerId)))->getPicHeightVpsInLumaSamples();
    3346   }
    3347 
    3348   return retVal;
    3349 }
    3350 
    3351 UInt TComVPS::getPicHeightInLumaSamples( const TComSPS* sps, const UInt layerId ) const
    3352 {
    3353   UInt retVal;
    3354 
    3355   if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 )
    3356   {
    3357     if( layerId == 0 && m_nonHEVCBaseLayerFlag )
    3358     {
    3359       retVal = m_vpsRepFormat[layerId].getPicHeightVpsInLumaSamples();
    3360     }
    3361     else
    3362     {
    3363       retVal = sps->getPicHeightInLumaSamples();
    3364     }
    3365   }
    3366   else
    3367   {
    3368     retVal = m_vpsRepFormat[sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : m_vpsRepFormatIdx[m_layerIdxInVps[layerId]]].getPicHeightVpsInLumaSamples();
    3369   }
    3370 
    3371   return retVal;
    3372 }
    3373 
    3374 ChromaFormat TComSlice::getChromaFormatIdc()
    3375 {
    3376   ChromaFormat retVal;
    3377   UInt layerId = getLayerId();
    3378 
    3379   if( layerId == 0 || m_pcSPS->getV1CompatibleSPSFlag() == 1 )
    3380   {
    3381     if( layerId == 0 && m_pcVPS->getNonHEVCBaseLayerFlag() )
    3382     {
    3383       retVal = m_pcVPS->getVpsRepFormat(layerId)->getChromaFormatVpsIdc();
    3384     }
    3385     else
    3386     {
    3387       retVal = m_pcSPS->getChromaFormatIdc();
    3388     }
    3389   }
    3390   else
    3391   {
    3392     retVal = m_pcVPS->getVpsRepFormat(m_pcSPS->getUpdateRepFormatFlag() ? m_pcSPS->getUpdateRepFormatIndex() : m_pcVPS->getVpsRepFormatIdx(m_pcVPS->getLayerIdxInVps(layerId)))->getChromaFormatVpsIdc();
    3393   }
    3394 
    3395   return retVal;
    3396 }
    3397 
    3398 ChromaFormat TComVPS::getChromaFormatIdc( const TComSPS* sps, const UInt layerId ) const
    3399 {
    3400   ChromaFormat retVal;
    3401 
    3402   if( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 )
    3403   {
    3404     if( layerId == 0 && m_nonHEVCBaseLayerFlag )
    3405     {
    3406       retVal = m_vpsRepFormat[layerId].getChromaFormatVpsIdc();
    3407     }
    3408     else
    3409     {
    3410       retVal = sps->getChromaFormatIdc();
    3411     }
    3412   }
    3413   else
    3414   {
    3415     retVal = m_vpsRepFormat[sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : m_vpsRepFormatIdx[m_layerIdxInVps[layerId]]].getChromaFormatVpsIdc();
    3416   }
    3417 
    3418   return retVal;
    3419 }
    3420 
    3421 BitDepths& TComSlice::getBitDepths()
    3422 {
    3423   static BitDepths bitDepths;
    3424 
    3425   bitDepths.recon[CHANNEL_TYPE_LUMA] = getBitDepth(CHANNEL_TYPE_LUMA);
    3426   bitDepths.recon[CHANNEL_TYPE_CHROMA] = getBitDepth(CHANNEL_TYPE_CHROMA);
    3427 
    3428   return bitDepths;
    3429 }
    3430 
    3431 UInt TComSlice::getBitDepth(ChannelType type) const
    3432 {
    3433   UInt retVal, layerId = getLayerId();
    3434 
    3435   if( layerId == 0 || m_pcSPS->getV1CompatibleSPSFlag() == 1 )
    3436   {
    3437     if( layerId == 0 && m_pcVPS->getNonHEVCBaseLayerFlag() )
    3438     {
    3439       retVal = m_pcVPS->getVpsRepFormat(layerId)->getBitDepthVps(type);
    3440     }
    3441     else
    3442     {
    3443       retVal = m_pcSPS->getBitDepth(type);
    3444     }
    3445   }
    3446   else
    3447   {
    3448     retVal = m_pcVPS->getVpsRepFormat(m_pcSPS->getUpdateRepFormatFlag() ? m_pcSPS->getUpdateRepFormatIndex() : m_pcVPS->getVpsRepFormatIdx(m_pcVPS->getLayerIdxInVps(layerId)))->getBitDepthVps(type);
    3449   }
    3450 
    3451   return retVal;
    3452 }
    3453 
    3454 UInt TComVPS::getBitDepth( ChannelType type, const TComSPS* sps, const UInt layerId ) const
    3455 {
    3456   UInt retVal;
    3457 
    3458   if( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 )
    3459   {
    3460     if( layerId == 0 && m_nonHEVCBaseLayerFlag )
    3461     {
    3462       retVal = m_vpsRepFormat[layerId].getBitDepthVps(type);
    3463     }
    3464     else
    3465     {
    3466       retVal = sps->getBitDepth(type);
    3467     }
    3468   }
    3469   else
    3470   {
    3471     retVal = m_vpsRepFormat[sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : m_vpsRepFormatIdx[m_layerIdxInVps[layerId]]].getBitDepthVps(type);
    3472   }
    3473 
    3474   return retVal;
    3475 }
    3476 
    3477 const BitDepths& TComVPS::getBitDepths( const TComSPS* sps, const UInt layerId ) const
    3478 {
    3479   static BitDepths bitDepths;
    3480   bitDepths.recon[CHANNEL_TYPE_LUMA]   = getBitDepth(CHANNEL_TYPE_LUMA, sps, layerId);
    3481   bitDepths.recon[CHANNEL_TYPE_CHROMA] = getBitDepth(CHANNEL_TYPE_CHROMA, sps, layerId);
    3482   return bitDepths;
    3483 }
    3484 
    3485 const Window& TComSlice::getConformanceWindow() const
    3486 {
    3487   if ( m_layerId == 0 || m_pcSPS->getV1CompatibleSPSFlag() == 1 )
    3488   {
    3489     if( m_layerId == 0 && m_pcVPS->getNonHEVCBaseLayerFlag() )
    3490     {
    3491       return m_pcVPS->getVpsRepFormat(m_layerId)->getConformanceWindowVps();
    3492     }
    3493     else
    3494     {
    3495       return m_pcSPS->getConformanceWindow();
    3496     }
    3497   }
    3498   else
    3499   {
    3500     return m_pcVPS->getVpsRepFormat(m_pcSPS->getUpdateRepFormatFlag() ? m_pcSPS->getUpdateRepFormatIndex() : m_pcVPS->getVpsRepFormatIdx(m_pcVPS->getLayerIdxInVps(m_layerId)))->getConformanceWindowVps();
    3501   }
    3502 }
    3503 
    3504 const Window& TComVPS::getConformanceWindow( const TComSPS* sps, const UInt layerId ) const
    3505 {
    3506   if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 )
    3507   {
    3508     if( layerId == 0 && m_nonHEVCBaseLayerFlag )
    3509     {
    3510       return m_vpsRepFormat[layerId].getConformanceWindowVps();
    3511     }
    3512     else
    3513     {
    3514       return sps->getConformanceWindow();
    3515     }
    3516   }
    3517   else
    3518   {
    3519     return m_vpsRepFormat[sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : m_vpsRepFormatIdx[m_layerIdxInVps[layerId]]].getConformanceWindowVps();
    3520   }
    3521 }
    3522 
    35233278RepFormat::RepFormat()
    35243279#if AUXILIARY_PICTURES
     
    38563611  return numPocBeforeCurr;
    38573612}
     3613
     3614Void TComSPS::inferSPS( const UInt layerId, TComVPS* vps )
     3615{
     3616  RepFormat* repFormat = NULL;
     3617
     3618  if( layerId == 0 || m_bV1CompatibleSPSFlag == 1 )
     3619  {
     3620    if( layerId == 0 && vps->getNonHEVCBaseLayerFlag() )
     3621    {
     3622      repFormat = vps->getVpsRepFormat(layerId);
     3623    }
     3624  }
     3625  else
     3626  {
     3627    repFormat = vps->getVpsRepFormat(m_updateRepFormatFlag ? m_updateRepFormatIndex : vps->getVpsRepFormatIdx(vps->getLayerIdxInVps(layerId)));
     3628  }
     3629
     3630  if( repFormat )
     3631  {
     3632    m_chromaFormatIdc = repFormat->getChromaFormatVpsIdc();
     3633    m_picWidthInLumaSamples = repFormat->getPicWidthVpsInLumaSamples();
     3634    m_picHeightInLumaSamples = repFormat->getPicHeightVpsInLumaSamples();
     3635
     3636    m_bitDepths.recon[CHANNEL_TYPE_LUMA] = repFormat->getBitDepthVps(CHANNEL_TYPE_LUMA);
     3637    m_bitDepths.recon[CHANNEL_TYPE_CHROMA] = repFormat->getBitDepthVps(CHANNEL_TYPE_CHROMA);
     3638
     3639    m_qpBDOffset[CHANNEL_TYPE_LUMA] = (m_bitDepths.recon[CHANNEL_TYPE_LUMA] - 8) * 6;
     3640    m_qpBDOffset[CHANNEL_TYPE_CHROMA] = (m_bitDepths.recon[CHANNEL_TYPE_CHROMA] - 8) * 6;
     3641
     3642    m_conformanceWindow = repFormat->getConformanceWindowVps();
     3643  }
     3644}
    38583645#endif //SVC_EXTENSION
    38593646
Note: See TracChangeset for help on using the changeset viewer.