Changeset 235 in SHVCSoftware for branches/SHM-2.1-dev/source


Ignore:
Timestamp:
24 May 2013, 00:25:51 (12 years ago)
Author:
seregin
Message:

PHASE_DERIVATION_IN_INTEGER macro clean up

Location:
branches/SHM-2.1-dev/source/Lib/TLibCommon
Files:
3 edited

Legend:

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

    r233 r235  
    44
    55#if SVC_UPSAMPLING
    6 // ====================================================================================================================
    7 // Tables:
    8 // 1. PHASE_DERIVATION_IN_INTEGER = 0 is the implementation using 2 multi-phase (12 phase and 8 phase) filter sets
    9 //    by following K0378.
    10 // 2. PHASE_DERIVATION_IN_INTEGER = 1 is the implemetation using a 16-phase filter set just for speed up. Some phases
    11 //    is approximated to x/16 (e.g. 1/3 -> 5/16).
    12 // 3. It was confirmed that two implementations provides the identical result.
    13 // 4. By default, PHASE_DERIVATION_IN_INTEGER is set to 1.
    14 // ====================================================================================================================
    156#define CNU -1 ///< Coefficients Not Used
    167
    17 #if PHASE_DERIVATION_IN_INTEGER
    188const Int TComUpsampleFilter::m_lumaFixedFilter[16][NTAPS_US_LUMA] =
    199{
     
    7464#endif
    7565};
    76 #else
    77 const Int TComUpsampleFilter::m_lumaFixedFilter[12][NTAPS_US_LUMA] =
    78 {
    79   { 0,  0,   0, 64,  0,   0, 0,  0},
    80   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU},//1/12
    81   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU},//2/12
    82   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU},//3/12
    83   { -1, 4, -11, 52, 26,  -8, 3, -1},//4/12
    84   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU},//5/12
    85   { -1, 4, -11, 40, 40, -11, 4, -1},//6/12       
    86   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU},//7/12
    87   { -1, 3,  -8, 26, 52, -11, 4, -1},//8/12
    88   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU},//9/12
    89   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU},//10/12
    90   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU},//11/12
    91 };
    92 
    93 const Int TComUpsampleFilter::m_chromaFixedFilter15[12][NTAPS_US_CHROMA] =
    94 {
    95   {  0, 64,  0,  0},
    96   {CNU,CNU,CNU,CNU},//1/12
    97   {CNU,CNU,CNU,CNU},//2/12
    98   { -4, 54, 16, -2},//3/12
    99   { -5, 50, 22, -3},//4/12
    100   {CNU,CNU,CNU,CNU},//5/12
    101   {CNU,CNU,CNU,CNU},//6/12
    102   { -4, 30, 43, -5},//7/12
    103   { -3, 22, 50, -5},//8/12
    104   {CNU,CNU,CNU,CNU},//9/12
    105   {CNU,CNU,CNU,CNU},//10/12
    106   { -1,  5, 62, -2} //11/12
    107 };
    108 
    109 const Int TComUpsampleFilter::m_chromaFixedFilter20[8][NTAPS_US_CHROMA] =
    110 {
    111   {  0, 64,  0,  0},
    112   {CNU,CNU,CNU,CNU},//1/8
    113   {CNU,CNU,CNU,CNU},//2/8
    114   { -6, 46, 28, -4},//3/8
    115   { -4, 36, 36, -4},//4/8
    116   {CNU,CNU,CNU,CNU},//5/8
    117   {CNU,CNU,CNU,CNU},//6/8
    118   { -2, 10, 58, -2},//7/8
    119 };
    120 #endif
    12166
    12267TComUpsampleFilter::TComUpsampleFilter(void)
     
    248193  else
    249194  {
    250 #if PHASE_DERIVATION_IN_INTEGER
    251195  Int refPos16 = 0;
    252196  Int phase    = 0;
     
    258202    memcpy( m_chromaFilter[i], m_chromaFixedFilter[i], sizeof(Int) * NTAPS_US_CHROMA );
    259203  }
    260 #else
    261   for ( i = 0; i < 12; i++)
    262   {
    263     memcpy( m_lumaFilter[i], m_lumaFixedFilter[i], sizeof(Int) * NTAPS_US_LUMA );
    264   }
    265 
    266   Int chromaPhaseDenominator;
    267   if (widthEL == 2*widthBL) // 2x scalability
    268   {
    269     for ( i = 0; i < 8; i++)
    270     {
    271       memcpy( m_chromaFilter[i], m_chromaFixedFilter20[i], sizeof(Int) * NTAPS_US_CHROMA );
    272     }
    273     chromaPhaseDenominator = 8;
    274   }
    275   else
    276   {
    277     for ( i = 0; i < 12; i++) // 1.5x scalability
    278     {
    279       memcpy( m_chromaFilter[i], m_chromaFixedFilter15[i], sizeof(Int) * NTAPS_US_CHROMA );
    280     }
    281     chromaPhaseDenominator = 12;
    282   }
    283 #endif
    284204
    285205  assert ( widthEL == widthBL || widthEL == 2*widthBL || 2*widthEL == 3*widthBL );
     
    360280  pcBasePic->extendPicBorder   (); // extend the border.
    361281
    362 #if PHASE_DERIVATION_IN_INTEGER
    363282  Int   shiftX = 16;
    364283  Int   shiftY = 16;
     
    378297  Int   scaleX     = ( ( widthBL << shiftX ) + ( widthEL >> 1 ) ) / widthEL;
    379298  Int   scaleY     = ( ( heightBL << shiftY ) + ( heightEL >> 1 ) ) / heightEL;
    380 #else
    381   const Double sFactor = 1.0 * widthBL / widthEL;
    382   const Double sFactor12 = sFactor * 12;
    383 #endif
     299
    384300#if ILP_DECODED_PICTURE
    385301  widthEL   = pcUsPic->getWidth ();
     
    401317#if SCALED_REF_LAYER_OFFSETS
    402318    Int x = Clip3( leftStartL, rightEndL - 1, i );
    403 #endif
    404 #if PHASE_DERIVATION_IN_INTEGER
    405 #if SCALED_REF_LAYER_OFFSETS
    406319    refPos16 = (((x - leftStartL)*scaleX + addX) >> shiftXM4) - deltaX;
    407320#else
     
    411324    refPos   = refPos16 >> 4;
    412325    coeff = m_lumaFilter[phase];
    413 #else
    414     Int refPos12 = (Int) ( i * sFactor12 );
    415     Int refPos = (Int)( i * sFactor );
    416     Int phase = (refPos12 + 12) % 12;
    417     Int* coeff = m_lumaFilter[phase];
    418 #endif
    419326
    420327    piSrcY = piSrcBufY + refPos -((NTAPS_US_LUMA>>1) - 1);
     
    447354#if SCALED_REF_LAYER_OFFSETS
    448355    Int y = Clip3(topStartL, bottomEndL - 1, j);
    449 #endif
    450 #if PHASE_DERIVATION_IN_INTEGER
    451 #if SCALED_REF_LAYER_OFFSETS
    452356    refPos16 = ((( y - topStartL )*scaleY + addY) >> shiftYM4) - deltaY;
    453357#else
     
    457361    refPos   = refPos16 >> 4;
    458362    coeff = m_lumaFilter[phase];
    459 #else
    460     Int refPos12 = (Int) (j * sFactor12 );
    461     Int refPos = (Int)( j * sFactor );
    462     Int phase = (refPos12 + 12) % 12;
    463     Int* coeff = m_lumaFilter[phase];
    464 #endif
    465363
    466364    piSrcY = piTempBufY + (refPos -((NTAPS_US_LUMA>>1) - 1))*strideEL;
     
    520418#endif
    521419
    522 #if PHASE_DERIVATION_IN_INTEGER
    523420  shiftX = 16;
    524421  shiftY = 16;
     
    538435  scaleX     = ( ( widthBL << shiftX ) + ( widthEL >> 1 ) ) / widthEL;
    539436  scaleY     = ( ( heightBL << shiftY ) + ( heightEL >> 1 ) ) / heightEL;
    540 #endif
    541437
    542438#if ILP_DECODED_PICTURE
     
    553449#if SCALED_REF_LAYER_OFFSETS
    554450    Int x = Clip3(leftStartC, rightEndC - 1, i);
    555 #endif
    556 #if PHASE_DERIVATION_IN_INTEGER
    557 #if SCALED_REF_LAYER_OFFSETS
    558451    refPos16 = (((x - leftStartC)*scaleX + addX) >> shiftXM4) - deltaX;
    559452#else
     
    563456    refPos   = refPos16 >> 4;
    564457    coeff = m_chromaFilter[phase];
    565 #else
    566     Int refPosM = (Int) ( i * chromaPhaseDenominator * sFactor );
    567     Int refPos = (Int)( i * sFactor );
    568     Int phase = (refPosM + chromaPhaseDenominator) % chromaPhaseDenominator;
    569     Int* coeff = m_chromaFilter[phase];
    570 #endif
    571458
    572459    piSrcU = piSrcBufU + refPos -((NTAPS_US_CHROMA>>1) - 1);
     
    601488#if SCALED_REF_LAYER_OFFSETS
    602489    Int y = Clip3(topStartC, bottomEndC - 1, j);
    603 #endif
    604 #if PHASE_DERIVATION_IN_INTEGER
    605 #if SCALED_REF_LAYER_OFFSETS
    606490    refPos16 = (((y - topStartC)*scaleY + addY) >> shiftYM4) - deltaY;
    607491#else
     
    611495    refPos   = refPos16 >> 4;
    612496    coeff = m_chromaFilter[phase];
    613 #else
    614     Int refPosM = (Int) (j * chromaPhaseDenominator * sFactor) - 1;
    615     Int refPos;
    616     if ( refPosM < 0 )
    617     {
    618       refPos = (Int)( j * sFactor ) - 1;
    619     }
    620     else
    621     {
    622       refPos = refPosM / chromaPhaseDenominator;
    623     }
    624     Int phase = (refPosM + chromaPhaseDenominator) % chromaPhaseDenominator;
    625     Int* coeff = m_chromaFilter[phase];
    626 #endif
    627497
    628498    piSrcU = piTempBufU  + (refPos -((NTAPS_US_CHROMA>>1) - 1))*strideEL;
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TComUpsampleFilter.h

    r189 r235  
    1313{
    1414private:
    15 #if PHASE_DERIVATION_IN_INTEGER
    1615  static const Int m_lumaFixedFilter[16][NTAPS_US_LUMA];     ///< Luma filter taps for both 1.5x and 2x scalability
    1716  static const Int m_chromaFixedFilter[16][NTAPS_US_CHROMA]; ///< Chroma filter taps for 1.5x scalability
     
    1918  Int m_lumaFilter[16][NTAPS_US_LUMA];
    2019  Int m_chromaFilter[16][NTAPS_US_CHROMA];
    21 #else
    22   static const Int m_lumaFixedFilter[12][NTAPS_US_LUMA];     ///< Luma filter taps for both 1.5x and 2x scalability
    23   static const Int m_chromaFixedFilter20[8][NTAPS_US_CHROMA]; ///< Chroma filter taps for 2x scalability
    24   static const Int m_chromaFixedFilter15[12][NTAPS_US_CHROMA]; ///< Chroma filter taps for 1.5x scalability
    25 
    26   Int m_lumaFilter[12][NTAPS_US_LUMA];
    27   Int m_chromaFilter[12][NTAPS_US_CHROMA];
    28 #endif
    2920
    3021  static inline Int sumLumaHor( Pel* pel, Int* coeff )
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TypeDef.h

    r228 r235  
    6767#define SVC_COL_BLK                      1      ///< get co-located block
    6868#define SVC_UPSAMPLING                   1      ///< upsampling filters
    69 #define PHASE_DERIVATION_IN_INTEGER      1      ///< upsampling filters implementation using only integer arithmetic
    7069#define ENCODER_BUGFIX                   1      ///< L0167: encoder bug fix for inter mode
    7170#define CHROMA_UPSAMPLING                1      ///< L0335: Chroma upsampling with 5 bits coefficients
Note: See TracChangeset for help on using the changeset viewer.