Ignore:
Timestamp:
Jul 28, 2017 2:51:44 AM (7 years ago)
Author:
nanang
Message:

Re #2004: Update libyuv version from libyuv git master repo dated 27 July 2017, the compile errors on old gcc versions issue persists though.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/third_party/yuv/source/scale.cc

    r5358 r5633  
    3434// its original size. 
    3535 
    36 static void ScalePlaneDown2(int src_width, int src_height, 
    37                             int dst_width, int dst_height, 
    38                             int src_stride, int dst_stride, 
    39                             const uint8* src_ptr, uint8* dst_ptr, 
     36static void ScalePlaneDown2(int src_width, 
     37                            int src_height, 
     38                            int dst_width, 
     39                            int dst_height, 
     40                            int src_stride, 
     41                            int dst_stride, 
     42                            const uint8* src_ptr, 
     43                            uint8* dst_ptr, 
    4044                            enum FilterMode filtering) { 
    4145  int y; 
    4246  void (*ScaleRowDown2)(const uint8* src_ptr, ptrdiff_t src_stride, 
    4347                        uint8* dst_ptr, int dst_width) = 
    44       filtering == kFilterNone ? ScaleRowDown2_C : 
    45       (filtering == kFilterLinear ? ScaleRowDown2Linear_C : ScaleRowDown2Box_C); 
     48      filtering == kFilterNone 
     49          ? ScaleRowDown2_C 
     50          : (filtering == kFilterLinear ? ScaleRowDown2Linear_C 
     51                                        : ScaleRowDown2Box_C); 
    4652  int row_stride = src_stride << 1; 
     53  (void)src_width; 
     54  (void)src_height; 
    4755  if (!filtering) { 
    4856    src_ptr += src_stride;  // Point to odd rows. 
     
    5260#if defined(HAS_SCALEROWDOWN2_NEON) 
    5361  if (TestCpuFlag(kCpuHasNEON)) { 
    54     ScaleRowDown2 = filtering == kFilterNone ? ScaleRowDown2_Any_NEON : 
    55         (filtering == kFilterLinear ? ScaleRowDown2Linear_Any_NEON : 
    56         ScaleRowDown2Box_Any_NEON); 
     62    ScaleRowDown2 = 
     63        filtering == kFilterNone 
     64            ? ScaleRowDown2_Any_NEON 
     65            : (filtering == kFilterLinear ? ScaleRowDown2Linear_Any_NEON 
     66                                          : ScaleRowDown2Box_Any_NEON); 
    5767    if (IS_ALIGNED(dst_width, 16)) { 
    58       ScaleRowDown2 = filtering == kFilterNone ? ScaleRowDown2_NEON : 
    59           (filtering == kFilterLinear ? ScaleRowDown2Linear_NEON : 
    60           ScaleRowDown2Box_NEON); 
     68      ScaleRowDown2 = filtering == kFilterNone ? ScaleRowDown2_NEON 
     69                                               : (filtering == kFilterLinear 
     70                                                      ? ScaleRowDown2Linear_NEON 
     71                                                      : ScaleRowDown2Box_NEON); 
    6172    } 
    6273  } 
     
    6475#if defined(HAS_SCALEROWDOWN2_SSSE3) 
    6576  if (TestCpuFlag(kCpuHasSSSE3)) { 
    66     ScaleRowDown2 = filtering == kFilterNone ? ScaleRowDown2_Any_SSSE3 : 
    67         (filtering == kFilterLinear ? ScaleRowDown2Linear_Any_SSSE3 : 
    68         ScaleRowDown2Box_Any_SSSE3); 
     77    ScaleRowDown2 = 
     78        filtering == kFilterNone 
     79            ? ScaleRowDown2_Any_SSSE3 
     80            : (filtering == kFilterLinear ? ScaleRowDown2Linear_Any_SSSE3 
     81                                          : ScaleRowDown2Box_Any_SSSE3); 
    6982    if (IS_ALIGNED(dst_width, 16)) { 
    70       ScaleRowDown2 = filtering == kFilterNone ? ScaleRowDown2_SSSE3 : 
    71           (filtering == kFilterLinear ? ScaleRowDown2Linear_SSSE3 : 
    72           ScaleRowDown2Box_SSSE3); 
     83      ScaleRowDown2 = 
     84          filtering == kFilterNone 
     85              ? ScaleRowDown2_SSSE3 
     86              : (filtering == kFilterLinear ? ScaleRowDown2Linear_SSSE3 
     87                                            : ScaleRowDown2Box_SSSE3); 
    7388    } 
    7489  } 
     
    7691#if defined(HAS_SCALEROWDOWN2_AVX2) 
    7792  if (TestCpuFlag(kCpuHasAVX2)) { 
    78     ScaleRowDown2 = filtering == kFilterNone ? ScaleRowDown2_Any_AVX2 : 
    79         (filtering == kFilterLinear ? ScaleRowDown2Linear_Any_AVX2 : 
    80         ScaleRowDown2Box_Any_AVX2); 
     93    ScaleRowDown2 = 
     94        filtering == kFilterNone 
     95            ? ScaleRowDown2_Any_AVX2 
     96            : (filtering == kFilterLinear ? ScaleRowDown2Linear_Any_AVX2 
     97                                          : ScaleRowDown2Box_Any_AVX2); 
    8198    if (IS_ALIGNED(dst_width, 32)) { 
    82       ScaleRowDown2 = filtering == kFilterNone ? ScaleRowDown2_AVX2 : 
    83           (filtering == kFilterLinear ? ScaleRowDown2Linear_AVX2 : 
    84           ScaleRowDown2Box_AVX2); 
     99      ScaleRowDown2 = filtering == kFilterNone ? ScaleRowDown2_AVX2 
     100                                               : (filtering == kFilterLinear 
     101                                                      ? ScaleRowDown2Linear_AVX2 
     102                                                      : ScaleRowDown2Box_AVX2); 
    85103    } 
    86104  } 
     
    90108      IS_ALIGNED(src_stride, 4) && IS_ALIGNED(row_stride, 4) && 
    91109      IS_ALIGNED(dst_ptr, 4) && IS_ALIGNED(dst_stride, 4)) { 
    92     ScaleRowDown2 = filtering ? 
    93         ScaleRowDown2Box_DSPR2 : ScaleRowDown2_DSPR2; 
     110    ScaleRowDown2 = filtering ? ScaleRowDown2Box_DSPR2 : ScaleRowDown2_DSPR2; 
     111  } 
     112#endif 
     113#if defined(HAS_SCALEROWDOWN2_MSA) 
     114  if (TestCpuFlag(kCpuHasMSA)) { 
     115    ScaleRowDown2 = 
     116        filtering == kFilterNone 
     117            ? ScaleRowDown2_Any_MSA 
     118            : (filtering == kFilterLinear ? ScaleRowDown2Linear_Any_MSA 
     119                                          : ScaleRowDown2Box_Any_MSA); 
     120    if (IS_ALIGNED(dst_width, 32)) { 
     121      ScaleRowDown2 = filtering == kFilterNone ? ScaleRowDown2_MSA 
     122                                               : (filtering == kFilterLinear 
     123                                                      ? ScaleRowDown2Linear_MSA 
     124                                                      : ScaleRowDown2Box_MSA); 
     125    } 
    94126  } 
    95127#endif 
     
    106138} 
    107139 
    108 static void ScalePlaneDown2_16(int src_width, int src_height, 
    109                                int dst_width, int dst_height, 
    110                                int src_stride, int dst_stride, 
    111                                const uint16* src_ptr, uint16* dst_ptr, 
     140static void ScalePlaneDown2_16(int src_width, 
     141                               int src_height, 
     142                               int dst_width, 
     143                               int dst_height, 
     144                               int src_stride, 
     145                               int dst_stride, 
     146                               const uint16* src_ptr, 
     147                               uint16* dst_ptr, 
    112148                               enum FilterMode filtering) { 
    113149  int y; 
    114150  void (*ScaleRowDown2)(const uint16* src_ptr, ptrdiff_t src_stride, 
    115151                        uint16* dst_ptr, int dst_width) = 
    116     filtering == kFilterNone ? ScaleRowDown2_16_C : 
    117         (filtering == kFilterLinear ? ScaleRowDown2Linear_16_C : 
    118         ScaleRowDown2Box_16_C); 
     152      filtering == kFilterNone 
     153          ? ScaleRowDown2_16_C 
     154          : (filtering == kFilterLinear ? ScaleRowDown2Linear_16_C 
     155                                        : ScaleRowDown2Box_16_C); 
    119156  int row_stride = src_stride << 1; 
     157  (void)src_width; 
     158  (void)src_height; 
    120159  if (!filtering) { 
    121160    src_ptr += src_stride;  // Point to odd rows. 
     
    125164#if defined(HAS_SCALEROWDOWN2_16_NEON) 
    126165  if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(dst_width, 16)) { 
    127     ScaleRowDown2 = filtering ? ScaleRowDown2Box_16_NEON : 
    128         ScaleRowDown2_16_NEON; 
     166    ScaleRowDown2 = 
     167        filtering ? ScaleRowDown2Box_16_NEON : ScaleRowDown2_16_NEON; 
    129168  } 
    130169#endif 
    131170#if defined(HAS_SCALEROWDOWN2_16_SSE2) 
    132171  if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(dst_width, 16)) { 
    133     ScaleRowDown2 = filtering == kFilterNone ? ScaleRowDown2_16_SSE2 : 
    134         (filtering == kFilterLinear ? ScaleRowDown2Linear_16_SSE2 : 
    135         ScaleRowDown2Box_16_SSE2); 
     172    ScaleRowDown2 = 
     173        filtering == kFilterNone 
     174            ? ScaleRowDown2_16_SSE2 
     175            : (filtering == kFilterLinear ? ScaleRowDown2Linear_16_SSE2 
     176                                          : ScaleRowDown2Box_16_SSE2); 
    136177  } 
    137178#endif 
     
    140181      IS_ALIGNED(src_stride, 4) && IS_ALIGNED(row_stride, 4) && 
    141182      IS_ALIGNED(dst_ptr, 4) && IS_ALIGNED(dst_stride, 4)) { 
    142     ScaleRowDown2 = filtering ? 
    143         ScaleRowDown2Box_16_DSPR2 : ScaleRowDown2_16_DSPR2; 
     183    ScaleRowDown2 = 
     184        filtering ? ScaleRowDown2Box_16_DSPR2 : ScaleRowDown2_16_DSPR2; 
    144185  } 
    145186#endif 
     
    160201// its original size. 
    161202 
    162 static void ScalePlaneDown4(int src_width, int src_height, 
    163                             int dst_width, int dst_height, 
    164                             int src_stride, int dst_stride, 
    165                             const uint8* src_ptr, uint8* dst_ptr, 
     203static void ScalePlaneDown4(int src_width, 
     204                            int src_height, 
     205                            int dst_width, 
     206                            int dst_height, 
     207                            int src_stride, 
     208                            int dst_stride, 
     209                            const uint8* src_ptr, 
     210                            uint8* dst_ptr, 
    166211                            enum FilterMode filtering) { 
    167212  int y; 
     
    170215      filtering ? ScaleRowDown4Box_C : ScaleRowDown4_C; 
    171216  int row_stride = src_stride << 2; 
     217  (void)src_width; 
     218  (void)src_height; 
    172219  if (!filtering) { 
    173220    src_ptr += src_stride * 2;  // Point to row 2. 
     
    176223#if defined(HAS_SCALEROWDOWN4_NEON) 
    177224  if (TestCpuFlag(kCpuHasNEON)) { 
    178     ScaleRowDown4 = filtering ? 
    179         ScaleRowDown4Box_Any_NEON : ScaleRowDown4_Any_NEON; 
     225    ScaleRowDown4 = 
     226        filtering ? ScaleRowDown4Box_Any_NEON : ScaleRowDown4_Any_NEON; 
    180227    if (IS_ALIGNED(dst_width, 8)) { 
    181228      ScaleRowDown4 = filtering ? ScaleRowDown4Box_NEON : ScaleRowDown4_NEON; 
     
    185232#if defined(HAS_SCALEROWDOWN4_SSSE3) 
    186233  if (TestCpuFlag(kCpuHasSSSE3)) { 
    187     ScaleRowDown4 = filtering ? 
    188         ScaleRowDown4Box_Any_SSSE3 : ScaleRowDown4_Any_SSSE3; 
     234    ScaleRowDown4 = 
     235        filtering ? ScaleRowDown4Box_Any_SSSE3 : ScaleRowDown4_Any_SSSE3; 
    189236    if (IS_ALIGNED(dst_width, 8)) { 
    190237      ScaleRowDown4 = filtering ? ScaleRowDown4Box_SSSE3 : ScaleRowDown4_SSSE3; 
     
    194241#if defined(HAS_SCALEROWDOWN4_AVX2) 
    195242  if (TestCpuFlag(kCpuHasAVX2)) { 
    196     ScaleRowDown4 = filtering ? 
    197         ScaleRowDown4Box_Any_AVX2 : ScaleRowDown4_Any_AVX2; 
     243    ScaleRowDown4 = 
     244        filtering ? ScaleRowDown4Box_Any_AVX2 : ScaleRowDown4_Any_AVX2; 
    198245    if (IS_ALIGNED(dst_width, 16)) { 
    199246      ScaleRowDown4 = filtering ? ScaleRowDown4Box_AVX2 : ScaleRowDown4_AVX2; 
     
    205252      IS_ALIGNED(src_ptr, 4) && IS_ALIGNED(src_stride, 4) && 
    206253      IS_ALIGNED(dst_ptr, 4) && IS_ALIGNED(dst_stride, 4)) { 
    207     ScaleRowDown4 = filtering ? 
    208         ScaleRowDown4Box_DSPR2 : ScaleRowDown4_DSPR2; 
     254    ScaleRowDown4 = filtering ? ScaleRowDown4Box_DSPR2 : ScaleRowDown4_DSPR2; 
     255  } 
     256#endif 
     257#if defined(HAS_SCALEROWDOWN4_MSA) 
     258  if (TestCpuFlag(kCpuHasMSA)) { 
     259    ScaleRowDown4 = 
     260        filtering ? ScaleRowDown4Box_Any_MSA : ScaleRowDown4_Any_MSA; 
     261    if (IS_ALIGNED(dst_width, 16)) { 
     262      ScaleRowDown4 = filtering ? ScaleRowDown4Box_MSA : ScaleRowDown4_MSA; 
     263    } 
    209264  } 
    210265#endif 
     
    220275} 
    221276 
    222 static void ScalePlaneDown4_16(int src_width, int src_height, 
    223                                int dst_width, int dst_height, 
    224                                int src_stride, int dst_stride, 
    225                                const uint16* src_ptr, uint16* dst_ptr, 
     277static void ScalePlaneDown4_16(int src_width, 
     278                               int src_height, 
     279                               int dst_width, 
     280                               int dst_height, 
     281                               int src_stride, 
     282                               int dst_stride, 
     283                               const uint16* src_ptr, 
     284                               uint16* dst_ptr, 
    226285                               enum FilterMode filtering) { 
    227286  int y; 
     
    230289      filtering ? ScaleRowDown4Box_16_C : ScaleRowDown4_16_C; 
    231290  int row_stride = src_stride << 2; 
     291  (void)src_width; 
     292  (void)src_height; 
    232293  if (!filtering) { 
    233294    src_ptr += src_stride * 2;  // Point to row 2. 
     
    236297#if defined(HAS_SCALEROWDOWN4_16_NEON) 
    237298  if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(dst_width, 8)) { 
    238     ScaleRowDown4 = filtering ? ScaleRowDown4Box_16_NEON : 
    239         ScaleRowDown4_16_NEON; 
     299    ScaleRowDown4 = 
     300        filtering ? ScaleRowDown4Box_16_NEON : ScaleRowDown4_16_NEON; 
    240301  } 
    241302#endif 
    242303#if defined(HAS_SCALEROWDOWN4_16_SSE2) 
    243304  if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(dst_width, 8)) { 
    244     ScaleRowDown4 = filtering ? ScaleRowDown4Box_16_SSE2 : 
    245         ScaleRowDown4_16_SSE2; 
     305    ScaleRowDown4 = 
     306        filtering ? ScaleRowDown4Box_16_SSE2 : ScaleRowDown4_16_SSE2; 
    246307  } 
    247308#endif 
     
    250311      IS_ALIGNED(src_ptr, 4) && IS_ALIGNED(src_stride, 4) && 
    251312      IS_ALIGNED(dst_ptr, 4) && IS_ALIGNED(dst_stride, 4)) { 
    252     ScaleRowDown4 = filtering ? 
    253         ScaleRowDown4Box_16_DSPR2 : ScaleRowDown4_16_DSPR2; 
     313    ScaleRowDown4 = 
     314        filtering ? ScaleRowDown4Box_16_DSPR2 : ScaleRowDown4_16_DSPR2; 
    254315  } 
    255316#endif 
     
    266327 
    267328// Scale plane down, 3/4 
    268  
    269 static void ScalePlaneDown34(int src_width, int src_height, 
    270                              int dst_width, int dst_height, 
    271                              int src_stride, int dst_stride, 
    272                              const uint8* src_ptr, uint8* dst_ptr, 
     329static void ScalePlaneDown34(int src_width, 
     330                             int src_height, 
     331                             int dst_width, 
     332                             int dst_height, 
     333                             int src_stride, 
     334                             int dst_stride, 
     335                             const uint8* src_ptr, 
     336                             uint8* dst_ptr, 
    273337                             enum FilterMode filtering) { 
    274338  int y; 
     
    278342                           uint8* dst_ptr, int dst_width); 
    279343  const int filter_stride = (filtering == kFilterLinear) ? 0 : src_stride; 
     344  (void)src_width; 
     345  (void)src_height; 
    280346  assert(dst_width % 3 == 0); 
    281347  if (!filtering) { 
     
    347413    src_ptr += src_stride; 
    348414    dst_ptr += dst_stride; 
    349     ScaleRowDown34_0(src_ptr + src_stride, -filter_stride, 
    350                      dst_ptr, dst_width); 
     415    ScaleRowDown34_0(src_ptr + src_stride, -filter_stride, dst_ptr, dst_width); 
    351416    src_ptr += src_stride * 2; 
    352417    dst_ptr += dst_stride; 
     
    364429} 
    365430 
    366 static void ScalePlaneDown34_16(int src_width, int src_height, 
    367                                 int dst_width, int dst_height, 
    368                                 int src_stride, int dst_stride, 
    369                                 const uint16* src_ptr, uint16* dst_ptr, 
     431static void ScalePlaneDown34_16(int src_width, 
     432                                int src_height, 
     433                                int dst_width, 
     434                                int dst_height, 
     435                                int src_stride, 
     436                                int dst_stride, 
     437                                const uint16* src_ptr, 
     438                                uint16* dst_ptr, 
    370439                                enum FilterMode filtering) { 
    371440  int y; 
     
    375444                           uint16* dst_ptr, int dst_width); 
    376445  const int filter_stride = (filtering == kFilterLinear) ? 0 : src_stride; 
     446  (void)src_width; 
     447  (void)src_height; 
    377448  assert(dst_width % 3 == 0); 
    378449  if (!filtering) { 
     
    426497    src_ptr += src_stride; 
    427498    dst_ptr += dst_stride; 
    428     ScaleRowDown34_0(src_ptr + src_stride, -filter_stride, 
    429                      dst_ptr, dst_width); 
     499    ScaleRowDown34_0(src_ptr + src_stride, -filter_stride, dst_ptr, dst_width); 
    430500    src_ptr += src_stride * 2; 
    431501    dst_ptr += dst_stride; 
     
    442512  } 
    443513} 
    444  
    445514 
    446515// Scale plane, 3/8 
     
    459528// Boxes are 3x3, 2x3, 3x2 and 2x2 
    460529 
    461 static void ScalePlaneDown38(int src_width, int src_height, 
    462                              int dst_width, int dst_height, 
    463                              int src_stride, int dst_stride, 
    464                              const uint8* src_ptr, uint8* dst_ptr, 
     530static void ScalePlaneDown38(int src_width, 
     531                             int src_height, 
     532                             int dst_width, 
     533                             int dst_height, 
     534                             int src_stride, 
     535                             int dst_stride, 
     536                             const uint8* src_ptr, 
     537                             uint8* dst_ptr, 
    465538                             enum FilterMode filtering) { 
    466539  int y; 
     
    471544  const int filter_stride = (filtering == kFilterLinear) ? 0 : src_stride; 
    472545  assert(dst_width % 3 == 0); 
     546  (void)src_width; 
     547  (void)src_height; 
    473548  if (!filtering) { 
    474549    ScaleRowDown38_3 = ScaleRowDown38_C; 
     
    531606  } 
    532607#endif 
     608#if defined(HAS_SCALEROWDOWN38_MSA) 
     609  if (TestCpuFlag(kCpuHasMSA)) { 
     610    if (!filtering) { 
     611      ScaleRowDown38_3 = ScaleRowDown38_Any_MSA; 
     612      ScaleRowDown38_2 = ScaleRowDown38_Any_MSA; 
     613    } else { 
     614      ScaleRowDown38_3 = ScaleRowDown38_3_Box_Any_MSA; 
     615      ScaleRowDown38_2 = ScaleRowDown38_2_Box_Any_MSA; 
     616    } 
     617    if (dst_width % 12 == 0) { 
     618      if (!filtering) { 
     619        ScaleRowDown38_3 = ScaleRowDown38_MSA; 
     620        ScaleRowDown38_2 = ScaleRowDown38_MSA; 
     621      } else { 
     622        ScaleRowDown38_3 = ScaleRowDown38_3_Box_MSA; 
     623        ScaleRowDown38_2 = ScaleRowDown38_2_Box_MSA; 
     624      } 
     625    } 
     626  } 
     627#endif 
    533628 
    534629  for (y = 0; y < dst_height - 2; y += 3) { 
     
    555650} 
    556651 
    557 static void ScalePlaneDown38_16(int src_width, int src_height, 
    558                                 int dst_width, int dst_height, 
    559                                 int src_stride, int dst_stride, 
    560                                 const uint16* src_ptr, uint16* dst_ptr, 
     652static void ScalePlaneDown38_16(int src_width, 
     653                                int src_height, 
     654                                int dst_width, 
     655                                int dst_height, 
     656                                int src_stride, 
     657                                int dst_stride, 
     658                                const uint16* src_ptr, 
     659                                uint16* dst_ptr, 
    561660                                enum FilterMode filtering) { 
    562661  int y; 
     
    566665                           uint16* dst_ptr, int dst_width); 
    567666  const int filter_stride = (filtering == kFilterLinear) ? 0 : src_stride; 
     667  (void)src_width; 
     668  (void)src_height; 
    568669  assert(dst_width % 3 == 0); 
    569670  if (!filtering) { 
     
    655756} 
    656757 
    657 static void ScaleAddCols2_C(int dst_width, int boxheight, int x, int dx, 
    658                             const uint16* src_ptr, uint8* dst_ptr) { 
     758static void ScaleAddCols2_C(int dst_width, 
     759                            int boxheight, 
     760                            int x, 
     761                            int dx, 
     762                            const uint16* src_ptr, 
     763                            uint8* dst_ptr) { 
    659764  int i; 
    660765  int scaletbl[2]; 
     
    667772    x += dx; 
    668773    boxwidth = MIN1((x >> 16) - ix); 
    669     *dst_ptr++ = SumPixels(boxwidth, src_ptr + ix) * 
    670         scaletbl[boxwidth - minboxwidth] >> 16; 
    671   } 
    672 } 
    673  
    674 static void ScaleAddCols2_16_C(int dst_width, int boxheight, int x, int dx, 
    675                                const uint32* src_ptr, uint16* dst_ptr) { 
     774    *dst_ptr++ = 
     775        SumPixels(boxwidth, src_ptr + ix) * scaletbl[boxwidth - minboxwidth] >> 
     776        16; 
     777  } 
     778} 
     779 
     780static void ScaleAddCols2_16_C(int dst_width, 
     781                               int boxheight, 
     782                               int x, 
     783                               int dx, 
     784                               const uint32* src_ptr, 
     785                               uint16* dst_ptr) { 
    676786  int i; 
    677787  int scaletbl[2]; 
     
    685795    boxwidth = MIN1((x >> 16) - ix); 
    686796    *dst_ptr++ = SumPixels_16(boxwidth, src_ptr + ix) * 
    687         scaletbl[boxwidth - minboxwidth]  >> 16; 
    688   } 
    689 } 
    690  
    691 static void ScaleAddCols0_C(int dst_width, int boxheight, int x, int, 
    692                             const uint16* src_ptr, uint8* dst_ptr) { 
     797                     scaletbl[boxwidth - minboxwidth] >> 
     798                 16; 
     799  } 
     800} 
     801 
     802static void ScaleAddCols0_C(int dst_width, 
     803                            int boxheight, 
     804                            int x, 
     805                            int, 
     806                            const uint16* src_ptr, 
     807                            uint8* dst_ptr) { 
    693808  int scaleval = 65536 / boxheight; 
    694809  int i; 
     
    699814} 
    700815 
    701 static void ScaleAddCols1_C(int dst_width, int boxheight, int x, int dx, 
    702                             const uint16* src_ptr, uint8* dst_ptr) { 
     816static void ScaleAddCols1_C(int dst_width, 
     817                            int boxheight, 
     818                            int x, 
     819                            int dx, 
     820                            const uint16* src_ptr, 
     821                            uint8* dst_ptr) { 
    703822  int boxwidth = MIN1(dx >> 16); 
    704823  int scaleval = 65536 / (boxwidth * boxheight); 
     
    711830} 
    712831 
    713 static void ScaleAddCols1_16_C(int dst_width, int boxheight, int x, int dx, 
    714                                const uint32* src_ptr, uint16* dst_ptr) { 
     832static void ScaleAddCols1_16_C(int dst_width, 
     833                               int boxheight, 
     834                               int x, 
     835                               int dx, 
     836                               const uint32* src_ptr, 
     837                               uint16* dst_ptr) { 
    715838  int boxwidth = MIN1(dx >> 16); 
    716839  int scaleval = 65536 / (boxwidth * boxheight); 
     
    729852// through source, sampling a box of pixel with simple 
    730853// averaging. 
    731 static void ScalePlaneBox(int src_width, int src_height, 
    732                           int dst_width, int dst_height, 
    733                           int src_stride, int dst_stride, 
    734                           const uint8* src_ptr, uint8* dst_ptr) { 
     854static void ScalePlaneBox(int src_width, 
     855                          int src_height, 
     856                          int dst_width, 
     857                          int dst_height, 
     858                          int src_stride, 
     859                          int dst_stride, 
     860                          const uint8* src_ptr, 
     861                          uint8* dst_ptr) { 
    735862  int j, k; 
    736863  // Initial source x/y coordinate and step values as 16.16 fixed point. 
     
    740867  int dy = 0; 
    741868  const int max_y = (src_height << 16); 
    742   ScaleSlope(src_width, src_height, dst_width, dst_height, kFilterBox, 
    743              &x, &y, &dx, &dy); 
     869  ScaleSlope(src_width, src_height, dst_width, dst_height, kFilterBox, &x, &y, 
     870             &dx, &dy); 
    744871  src_width = Abs(src_width); 
    745872  { 
     
    747874    align_buffer_64(row16, src_width * 2); 
    748875    void (*ScaleAddCols)(int dst_width, int boxheight, int x, int dx, 
    749         const uint16* src_ptr, uint8* dst_ptr) = 
    750         (dx & 0xffff) ? ScaleAddCols2_C: 
    751         ((dx != 0x10000) ? ScaleAddCols1_C : ScaleAddCols0_C); 
     876                         const uint16* src_ptr, uint8* dst_ptr) = 
     877        (dx & 0xffff) ? ScaleAddCols2_C 
     878                      : ((dx != 0x10000) ? ScaleAddCols1_C : ScaleAddCols0_C); 
    752879    void (*ScaleAddRow)(const uint8* src_ptr, uint16* dst_ptr, int src_width) = 
    753880        ScaleAddRow_C; 
     
    773900      if (IS_ALIGNED(src_width, 16)) { 
    774901        ScaleAddRow = ScaleAddRow_NEON; 
     902      } 
     903    } 
     904#endif 
     905#if defined(HAS_SCALEADDROW_MSA) 
     906    if (TestCpuFlag(kCpuHasMSA)) { 
     907      ScaleAddRow = ScaleAddRow_Any_MSA; 
     908      if (IS_ALIGNED(src_width, 16)) { 
     909        ScaleAddRow = ScaleAddRow_MSA; 
     910      } 
     911    } 
     912#endif 
     913#if defined(HAS_SCALEADDROW_DSPR2) 
     914    if (TestCpuFlag(kCpuHasDSPR2)) { 
     915      ScaleAddRow = ScaleAddRow_Any_DSPR2; 
     916      if (IS_ALIGNED(src_width, 16)) { 
     917        ScaleAddRow = ScaleAddRow_DSPR2; 
    775918      } 
    776919    } 
     
    788931      memset(row16, 0, src_width * 2); 
    789932      for (k = 0; k < boxheight; ++k) { 
    790         ScaleAddRow(src, (uint16 *)(row16), src_width); 
     933        ScaleAddRow(src, (uint16*)(row16), src_width); 
    791934        src += src_stride; 
    792935      } 
     
    798941} 
    799942 
    800 static void ScalePlaneBox_16(int src_width, int src_height, 
    801                              int dst_width, int dst_height, 
    802                              int src_stride, int dst_stride, 
    803                              const uint16* src_ptr, uint16* dst_ptr) { 
     943static void ScalePlaneBox_16(int src_width, 
     944                             int src_height, 
     945                             int dst_width, 
     946                             int dst_height, 
     947                             int src_stride, 
     948                             int dst_stride, 
     949                             const uint16* src_ptr, 
     950                             uint16* dst_ptr) { 
    804951  int j, k; 
    805952  // Initial source x/y coordinate and step values as 16.16 fixed point. 
     
    809956  int dy = 0; 
    810957  const int max_y = (src_height << 16); 
    811   ScaleSlope(src_width, src_height, dst_width, dst_height, kFilterBox, 
    812              &x, &y, &dx, &dy); 
     958  ScaleSlope(src_width, src_height, dst_width, dst_height, kFilterBox, &x, &y, 
     959             &dx, &dy); 
    813960  src_width = Abs(src_width); 
    814961  { 
     
    816963    align_buffer_64(row32, src_width * 4); 
    817964    void (*ScaleAddCols)(int dst_width, int boxheight, int x, int dx, 
    818         const uint32* src_ptr, uint16* dst_ptr) = 
    819         (dx & 0xffff) ? ScaleAddCols2_16_C: ScaleAddCols1_16_C; 
     965                         const uint32* src_ptr, uint16* dst_ptr) = 
     966        (dx & 0xffff) ? ScaleAddCols2_16_C : ScaleAddCols1_16_C; 
    820967    void (*ScaleAddRow)(const uint16* src_ptr, uint32* dst_ptr, int src_width) = 
    821968        ScaleAddRow_16_C; 
     
    838985      memset(row32, 0, src_width * 4); 
    839986      for (k = 0; k < boxheight; ++k) { 
    840         ScaleAddRow(src, (uint32 *)(row32), src_width); 
     987        ScaleAddRow(src, (uint32*)(row32), src_width); 
    841988        src += src_stride; 
    842989      } 
     
    849996 
    850997// Scale plane down with bilinear interpolation. 
    851 void ScalePlaneBilinearDown(int src_width, int src_height, 
    852                             int dst_width, int dst_height, 
    853                             int src_stride, int dst_stride, 
    854                             const uint8* src_ptr, uint8* dst_ptr, 
     998void ScalePlaneBilinearDown(int src_width, 
     999                            int src_height, 
     1000                            int dst_width, 
     1001                            int dst_height, 
     1002                            int src_stride, 
     1003                            int dst_stride, 
     1004                            const uint8* src_ptr, 
     1005                            uint8* dst_ptr, 
    8551006                            enum FilterMode filtering) { 
    8561007  // Initial source x/y coordinate and step values as 16.16 fixed point. 
     
    8651016  const int max_y = (src_height - 1) << 16; 
    8661017  int j; 
    867   void (*ScaleFilterCols)(uint8* dst_ptr, const uint8* src_ptr, 
    868       int dst_width, int x, int dx) = 
     1018  void (*ScaleFilterCols)(uint8 * dst_ptr, const uint8* src_ptr, int dst_width, 
     1019                          int x, int dx) = 
    8691020      (src_width >= 32768) ? ScaleFilterCols64_C : ScaleFilterCols_C; 
    870   void (*InterpolateRow)(uint8* dst_ptr, const uint8* src_ptr, 
    871       ptrdiff_t src_stride, int dst_width, int source_y_fraction) = 
    872       InterpolateRow_C; 
    873   ScaleSlope(src_width, src_height, dst_width, dst_height, filtering, 
    874              &x, &y, &dx, &dy); 
     1021  void (*InterpolateRow)(uint8 * dst_ptr, const uint8* src_ptr, 
     1022                         ptrdiff_t src_stride, int dst_width, 
     1023                         int source_y_fraction) = InterpolateRow_C; 
     1024  ScaleSlope(src_width, src_height, dst_width, dst_height, filtering, &x, &y, 
     1025             &dx, &dy); 
    8751026  src_width = Abs(src_width); 
    8761027 
     
    9071058  } 
    9081059#endif 
    909  
     1060#if defined(HAS_INTERPOLATEROW_MSA) 
     1061  if (TestCpuFlag(kCpuHasMSA)) { 
     1062    InterpolateRow = InterpolateRow_Any_MSA; 
     1063    if (IS_ALIGNED(src_width, 32)) { 
     1064      InterpolateRow = InterpolateRow_MSA; 
     1065    } 
     1066  } 
     1067#endif 
    9101068 
    9111069#if defined(HAS_SCALEFILTERCOLS_SSSE3) 
     
    9451103} 
    9461104 
    947 void ScalePlaneBilinearDown_16(int src_width, int src_height, 
    948                                int dst_width, int dst_height, 
    949                                int src_stride, int dst_stride, 
    950                                const uint16* src_ptr, uint16* dst_ptr, 
     1105void ScalePlaneBilinearDown_16(int src_width, 
     1106                               int src_height, 
     1107                               int dst_width, 
     1108                               int dst_height, 
     1109                               int src_stride, 
     1110                               int dst_stride, 
     1111                               const uint16* src_ptr, 
     1112                               uint16* dst_ptr, 
    9511113                               enum FilterMode filtering) { 
    9521114  // Initial source x/y coordinate and step values as 16.16 fixed point. 
     
    9611123  const int max_y = (src_height - 1) << 16; 
    9621124  int j; 
    963   void (*ScaleFilterCols)(uint16* dst_ptr, const uint16* src_ptr, 
    964       int dst_width, int x, int dx) = 
     1125  void (*ScaleFilterCols)(uint16 * dst_ptr, const uint16* src_ptr, 
     1126                          int dst_width, int x, int dx) = 
    9651127      (src_width >= 32768) ? ScaleFilterCols64_16_C : ScaleFilterCols_16_C; 
    966   void (*InterpolateRow)(uint16* dst_ptr, const uint16* src_ptr, 
    967       ptrdiff_t src_stride, int dst_width, int source_y_fraction) = 
    968       InterpolateRow_16_C; 
    969   ScaleSlope(src_width, src_height, dst_width, dst_height, filtering, 
    970              &x, &y, &dx, &dy); 
     1128  void (*InterpolateRow)(uint16 * dst_ptr, const uint16* src_ptr, 
     1129                         ptrdiff_t src_stride, int dst_width, 
     1130                         int source_y_fraction) = InterpolateRow_16_C; 
     1131  ScaleSlope(src_width, src_height, dst_width, dst_height, filtering, &x, &y, 
     1132             &dx, &dy); 
    9711133  src_width = Abs(src_width); 
    9721134 
     
    10111173  } 
    10121174#endif 
    1013  
    10141175 
    10151176#if defined(HAS_SCALEFILTERCOLS_16_SSSE3) 
     
    10421203 
    10431204// Scale up down with bilinear interpolation. 
    1044 void ScalePlaneBilinearUp(int src_width, int src_height, 
    1045                           int dst_width, int dst_height, 
    1046                           int src_stride, int dst_stride, 
    1047                           const uint8* src_ptr, uint8* dst_ptr, 
     1205void ScalePlaneBilinearUp(int src_width, 
     1206                          int src_height, 
     1207                          int dst_width, 
     1208                          int dst_height, 
     1209                          int src_stride, 
     1210                          int dst_stride, 
     1211                          const uint8* src_ptr, 
     1212                          uint8* dst_ptr, 
    10481213                          enum FilterMode filtering) { 
    10491214  int j; 
     
    10541219  int dy = 0; 
    10551220  const int max_y = (src_height - 1) << 16; 
    1056   void (*InterpolateRow)(uint8* dst_ptr, const uint8* src_ptr, 
    1057       ptrdiff_t src_stride, int dst_width, int source_y_fraction) = 
    1058       InterpolateRow_C; 
    1059   void (*ScaleFilterCols)(uint8* dst_ptr, const uint8* src_ptr, 
    1060       int dst_width, int x, int dx) = 
     1221  void (*InterpolateRow)(uint8 * dst_ptr, const uint8* src_ptr, 
     1222                         ptrdiff_t src_stride, int dst_width, 
     1223                         int source_y_fraction) = InterpolateRow_C; 
     1224  void (*ScaleFilterCols)(uint8 * dst_ptr, const uint8* src_ptr, int dst_width, 
     1225                          int x, int dx) = 
    10611226      filtering ? ScaleFilterCols_C : ScaleCols_C; 
    1062   ScaleSlope(src_width, src_height, dst_width, dst_height, filtering, 
    1063              &x, &y, &dx, &dy); 
     1227  ScaleSlope(src_width, src_height, dst_width, dst_height, filtering, &x, &y, 
     1228             &dx, &dy); 
    10641229  src_width = Abs(src_width); 
    10651230 
     
    11731338} 
    11741339 
    1175 void ScalePlaneBilinearUp_16(int src_width, int src_height, 
    1176                              int dst_width, int dst_height, 
    1177                              int src_stride, int dst_stride, 
    1178                              const uint16* src_ptr, uint16* dst_ptr, 
     1340void ScalePlaneBilinearUp_16(int src_width, 
     1341                             int src_height, 
     1342                             int dst_width, 
     1343                             int dst_height, 
     1344                             int src_stride, 
     1345                             int dst_stride, 
     1346                             const uint16* src_ptr, 
     1347                             uint16* dst_ptr, 
    11791348                             enum FilterMode filtering) { 
    11801349  int j; 
     
    11851354  int dy = 0; 
    11861355  const int max_y = (src_height - 1) << 16; 
    1187   void (*InterpolateRow)(uint16* dst_ptr, const uint16* src_ptr, 
    1188       ptrdiff_t src_stride, int dst_width, int source_y_fraction) = 
    1189       InterpolateRow_16_C; 
    1190   void (*ScaleFilterCols)(uint16* dst_ptr, const uint16* src_ptr, 
    1191       int dst_width, int x, int dx) = 
     1356  void (*InterpolateRow)(uint16 * dst_ptr, const uint16* src_ptr, 
     1357                         ptrdiff_t src_stride, int dst_width, 
     1358                         int source_y_fraction) = InterpolateRow_16_C; 
     1359  void (*ScaleFilterCols)(uint16 * dst_ptr, const uint16* src_ptr, 
     1360                          int dst_width, int x, int dx) = 
    11921361      filtering ? ScaleFilterCols_16_C : ScaleCols_16_C; 
    1193   ScaleSlope(src_width, src_height, dst_width, dst_height, filtering, 
    1194              &x, &y, &dx, &dy); 
     1362  ScaleSlope(src_width, src_height, dst_width, dst_height, filtering, &x, &y, 
     1363             &dx, &dy); 
    11951364  src_width = Abs(src_width); 
    11961365 
     
    13091478// the lower 16 bits are the fixed decimal part. 
    13101479 
    1311 static void ScalePlaneSimple(int src_width, int src_height, 
    1312                              int dst_width, int dst_height, 
    1313                              int src_stride, int dst_stride, 
    1314                              const uint8* src_ptr, uint8* dst_ptr) { 
     1480static void ScalePlaneSimple(int src_width, 
     1481                             int src_height, 
     1482                             int dst_width, 
     1483                             int dst_height, 
     1484                             int src_stride, 
     1485                             int dst_stride, 
     1486                             const uint8* src_ptr, 
     1487                             uint8* dst_ptr) { 
    13151488  int i; 
    1316   void (*ScaleCols)(uint8* dst_ptr, const uint8* src_ptr, 
    1317       int dst_width, int x, int dx) = ScaleCols_C; 
     1489  void (*ScaleCols)(uint8 * dst_ptr, const uint8* src_ptr, int dst_width, int x, 
     1490                    int dx) = ScaleCols_C; 
    13181491  // Initial source x/y coordinate and step values as 16.16 fixed point. 
    13191492  int x = 0; 
     
    13211494  int dx = 0; 
    13221495  int dy = 0; 
    1323   ScaleSlope(src_width, src_height, dst_width, dst_height, kFilterNone, 
    1324              &x, &y, &dx, &dy); 
     1496  ScaleSlope(src_width, src_height, dst_width, dst_height, kFilterNone, &x, &y, 
     1497             &dx, &dy); 
    13251498  src_width = Abs(src_width); 
    13261499 
     
    13411514} 
    13421515 
    1343 static void ScalePlaneSimple_16(int src_width, int src_height, 
    1344                                 int dst_width, int dst_height, 
    1345                                 int src_stride, int dst_stride, 
    1346                                 const uint16* src_ptr, uint16* dst_ptr) { 
     1516static void ScalePlaneSimple_16(int src_width, 
     1517                                int src_height, 
     1518                                int dst_width, 
     1519                                int dst_height, 
     1520                                int src_stride, 
     1521                                int dst_stride, 
     1522                                const uint16* src_ptr, 
     1523                                uint16* dst_ptr) { 
    13471524  int i; 
    1348   void (*ScaleCols)(uint16* dst_ptr, const uint16* src_ptr, 
    1349       int dst_width, int x, int dx) = ScaleCols_16_C; 
     1525  void (*ScaleCols)(uint16 * dst_ptr, const uint16* src_ptr, int dst_width, 
     1526                    int x, int dx) = ScaleCols_16_C; 
    13501527  // Initial source x/y coordinate and step values as 16.16 fixed point. 
    13511528  int x = 0; 
     
    13531530  int dx = 0; 
    13541531  int dy = 0; 
    1355   ScaleSlope(src_width, src_height, dst_width, dst_height, kFilterNone, 
    1356              &x, &y, &dx, &dy); 
     1532  ScaleSlope(src_width, src_height, dst_width, dst_height, kFilterNone, &x, &y, 
     1533             &dx, &dy); 
    13571534  src_width = Abs(src_width); 
    13581535 
     
    13671544 
    13681545  for (i = 0; i < dst_height; ++i) { 
    1369     ScaleCols(dst_ptr, src_ptr + (y >> 16) * src_stride, 
    1370               dst_width, x, dx); 
     1546    ScaleCols(dst_ptr, src_ptr + (y >> 16) * src_stride, dst_width, x, dx); 
    13711547    dst_ptr += dst_stride; 
    13721548    y += dy; 
     
    13781554 
    13791555LIBYUV_API 
    1380 void ScalePlane(const uint8* src, int src_stride, 
    1381                 int src_width, int src_height, 
    1382                 uint8* dst, int dst_stride, 
    1383                 int dst_width, int dst_height, 
     1556void ScalePlane(const uint8* src, 
     1557                int src_stride, 
     1558                int src_width, 
     1559                int src_height, 
     1560                uint8* dst, 
     1561                int dst_stride, 
     1562                int dst_width, 
     1563                int dst_height, 
    13841564                enum FilterMode filtering) { 
    13851565  // Simplify filtering when possible. 
    1386   filtering = ScaleFilterReduce(src_width, src_height, 
    1387                                 dst_width, dst_height, filtering); 
     1566  filtering = ScaleFilterReduce(src_width, src_height, dst_width, dst_height, 
     1567                                filtering); 
    13881568 
    13891569  // Negative height means invert the image. 
     
    14041584    int dy = FixedDiv(src_height, dst_height); 
    14051585    // Arbitrary scale vertically, but unscaled horizontally. 
    1406     ScalePlaneVertical(src_height, 
    1407                        dst_width, dst_height, 
    1408                        src_stride, dst_stride, src, dst, 
    1409                        0, 0, dy, 1, filtering); 
     1586    ScalePlaneVertical(src_height, dst_width, dst_height, src_stride, 
     1587                       dst_stride, src, dst, 0, 0, dy, 1, filtering); 
    14101588    return; 
    14111589  } 
    14121590  if (dst_width <= Abs(src_width) && dst_height <= src_height) { 
    14131591    // Scale down. 
    1414     if (4 * dst_width == 3 * src_width && 
    1415         4 * dst_height == 3 * src_height) { 
     1592    if (4 * dst_width == 3 * src_width && 4 * dst_height == 3 * src_height) { 
    14161593      // optimized, 3/4 
    1417       ScalePlaneDown34(src_width, src_height, dst_width, dst_height, 
    1418                        src_stride, dst_stride, src, dst, filtering); 
     1594      ScalePlaneDown34(src_width, src_height, dst_width, dst_height, src_stride, 
     1595                       dst_stride, src, dst, filtering); 
    14191596      return; 
    14201597    } 
    14211598    if (2 * dst_width == src_width && 2 * dst_height == src_height) { 
    14221599      // optimized, 1/2 
    1423       ScalePlaneDown2(src_width, src_height, dst_width, dst_height, 
    1424                       src_stride, dst_stride, src, dst, filtering); 
     1600      ScalePlaneDown2(src_width, src_height, dst_width, dst_height, src_stride, 
     1601                      dst_stride, src, dst, filtering); 
    14251602      return; 
    14261603    } 
    14271604    // 3/8 rounded up for odd sized chroma height. 
    1428     if (8 * dst_width == 3 * src_width && 
    1429         dst_height == ((src_height * 3 + 7) / 8)) { 
     1605    if (8 * dst_width == 3 * src_width && 8 * dst_height == 3 * src_height) { 
    14301606      // optimized, 3/8 
    1431       ScalePlaneDown38(src_width, src_height, dst_width, dst_height, 
    1432                        src_stride, dst_stride, src, dst, filtering); 
     1607      ScalePlaneDown38(src_width, src_height, dst_width, dst_height, src_stride, 
     1608                       dst_stride, src, dst, filtering); 
    14331609      return; 
    14341610    } 
     
    14361612        (filtering == kFilterBox || filtering == kFilterNone)) { 
    14371613      // optimized, 1/4 
    1438       ScalePlaneDown4(src_width, src_height, dst_width, dst_height, 
    1439                       src_stride, dst_stride, src, dst, filtering); 
     1614      ScalePlaneDown4(src_width, src_height, dst_width, dst_height, src_stride, 
     1615                      dst_stride, src, dst, filtering); 
    14401616      return; 
    14411617    } 
    14421618  } 
    14431619  if (filtering == kFilterBox && dst_height * 2 < src_height) { 
    1444     ScalePlaneBox(src_width, src_height, dst_width, dst_height, 
    1445                   src_stride, dst_stride, src, dst); 
     1620    ScalePlaneBox(src_width, src_height, dst_width, dst_height, src_stride, 
     1621                  dst_stride, src, dst); 
    14461622    return; 
    14471623  } 
     
    14561632    return; 
    14571633  } 
    1458   ScalePlaneSimple(src_width, src_height, dst_width, dst_height, 
    1459                    src_stride, dst_stride, src, dst); 
     1634  ScalePlaneSimple(src_width, src_height, dst_width, dst_height, src_stride, 
     1635                   dst_stride, src, dst); 
    14601636} 
    14611637 
    14621638LIBYUV_API 
    1463 void ScalePlane_16(const uint16* src, int src_stride, 
    1464                   int src_width, int src_height, 
    1465                   uint16* dst, int dst_stride, 
    1466                   int dst_width, int dst_height, 
    1467                   enum FilterMode filtering) { 
     1639void ScalePlane_16(const uint16* src, 
     1640                   int src_stride, 
     1641                   int src_width, 
     1642                   int src_height, 
     1643                   uint16* dst, 
     1644                   int dst_stride, 
     1645                   int dst_width, 
     1646                   int dst_height, 
     1647                   enum FilterMode filtering) { 
    14681648  // Simplify filtering when possible. 
    1469   filtering = ScaleFilterReduce(src_width, src_height, 
    1470                                 dst_width, dst_height, filtering); 
     1649  filtering = ScaleFilterReduce(src_width, src_height, dst_width, dst_height, 
     1650                                filtering); 
    14711651 
    14721652  // Negative height means invert the image. 
     
    14871667    int dy = FixedDiv(src_height, dst_height); 
    14881668    // Arbitrary scale vertically, but unscaled vertically. 
    1489     ScalePlaneVertical_16(src_height, 
    1490                           dst_width, dst_height, 
    1491                           src_stride, dst_stride, src, dst, 
    1492                           0, 0, dy, 1, filtering); 
     1669    ScalePlaneVertical_16(src_height, dst_width, dst_height, src_stride, 
     1670                          dst_stride, src, dst, 0, 0, dy, 1, filtering); 
    14931671    return; 
    14941672  } 
    14951673  if (dst_width <= Abs(src_width) && dst_height <= src_height) { 
    14961674    // Scale down. 
    1497     if (4 * dst_width == 3 * src_width && 
    1498         4 * dst_height == 3 * src_height) { 
     1675    if (4 * dst_width == 3 * src_width && 4 * dst_height == 3 * src_height) { 
    14991676      // optimized, 3/4 
    15001677      ScalePlaneDown34_16(src_width, src_height, dst_width, dst_height, 
     
    15091686    } 
    15101687    // 3/8 rounded up for odd sized chroma height. 
    1511     if (8 * dst_width == 3 * src_width && 
    1512         dst_height == ((src_height * 3 + 7) / 8)) { 
     1688    if (8 * dst_width == 3 * src_width && 8 * dst_height == 3 * src_height) { 
    15131689      // optimized, 3/8 
    15141690      ScalePlaneDown38_16(src_width, src_height, dst_width, dst_height, 
     
    15171693    } 
    15181694    if (4 * dst_width == src_width && 4 * dst_height == src_height && 
    1519                filtering != kFilterBilinear) { 
     1695        filtering != kFilterBilinear) { 
    15201696      // optimized, 1/4 
    15211697      ScalePlaneDown4_16(src_width, src_height, dst_width, dst_height, 
     
    15251701  } 
    15261702  if (filtering == kFilterBox && dst_height * 2 < src_height) { 
    1527     ScalePlaneBox_16(src_width, src_height, dst_width, dst_height, 
    1528                      src_stride, dst_stride, src, dst); 
     1703    ScalePlaneBox_16(src_width, src_height, dst_width, dst_height, src_stride, 
     1704                     dst_stride, src, dst); 
    15291705    return; 
    15301706  } 
     
    15391715    return; 
    15401716  } 
    1541   ScalePlaneSimple_16(src_width, src_height, dst_width, dst_height, 
    1542                       src_stride, dst_stride, src, dst); 
     1717  ScalePlaneSimple_16(src_width, src_height, dst_width, dst_height, src_stride, 
     1718                      dst_stride, src, dst); 
    15431719} 
    15441720 
     
    15471723 
    15481724LIBYUV_API 
    1549 int I420Scale(const uint8* src_y, int src_stride_y, 
    1550               const uint8* src_u, int src_stride_u, 
    1551               const uint8* src_v, int src_stride_v, 
    1552               int src_width, int src_height, 
    1553               uint8* dst_y, int dst_stride_y, 
    1554               uint8* dst_u, int dst_stride_u, 
    1555               uint8* dst_v, int dst_stride_v, 
    1556               int dst_width, int dst_height, 
     1725int I420Scale(const uint8* src_y, 
     1726              int src_stride_y, 
     1727              const uint8* src_u, 
     1728              int src_stride_u, 
     1729              const uint8* src_v, 
     1730              int src_stride_v, 
     1731              int src_width, 
     1732              int src_height, 
     1733              uint8* dst_y, 
     1734              int dst_stride_y, 
     1735              uint8* dst_u, 
     1736              int dst_stride_u, 
     1737              uint8* dst_v, 
     1738              int dst_stride_v, 
     1739              int dst_width, 
     1740              int dst_height, 
    15571741              enum FilterMode filtering) { 
    15581742  int src_halfwidth = SUBSAMPLE(src_width, 1, 1); 
     
    15611745  int dst_halfheight = SUBSAMPLE(dst_height, 1, 1); 
    15621746  if (!src_y || !src_u || !src_v || src_width == 0 || src_height == 0 || 
    1563       src_width > 32768 || src_height > 32768 || 
    1564       !dst_y || !dst_u || !dst_v || dst_width <= 0 || dst_height <= 0) { 
     1747      src_width > 32768 || src_height > 32768 || !dst_y || !dst_u || !dst_v || 
     1748      dst_width <= 0 || dst_height <= 0) { 
    15651749    return -1; 
    15661750  } 
    15671751 
    1568   ScalePlane(src_y, src_stride_y, src_width, src_height, 
    1569              dst_y, dst_stride_y, dst_width, dst_height, 
    1570              filtering); 
    1571   ScalePlane(src_u, src_stride_u, src_halfwidth, src_halfheight, 
    1572              dst_u, dst_stride_u, dst_halfwidth, dst_halfheight, 
    1573              filtering); 
    1574   ScalePlane(src_v, src_stride_v, src_halfwidth, src_halfheight, 
    1575              dst_v, dst_stride_v, dst_halfwidth, dst_halfheight, 
    1576              filtering); 
     1752  ScalePlane(src_y, src_stride_y, src_width, src_height, dst_y, dst_stride_y, 
     1753             dst_width, dst_height, filtering); 
     1754  ScalePlane(src_u, src_stride_u, src_halfwidth, src_halfheight, dst_u, 
     1755             dst_stride_u, dst_halfwidth, dst_halfheight, filtering); 
     1756  ScalePlane(src_v, src_stride_v, src_halfwidth, src_halfheight, dst_v, 
     1757             dst_stride_v, dst_halfwidth, dst_halfheight, filtering); 
    15771758  return 0; 
    15781759} 
    15791760 
    15801761LIBYUV_API 
    1581 int I420Scale_16(const uint16* src_y, int src_stride_y, 
    1582                  const uint16* src_u, int src_stride_u, 
    1583                  const uint16* src_v, int src_stride_v, 
    1584                  int src_width, int src_height, 
    1585                  uint16* dst_y, int dst_stride_y, 
    1586                  uint16* dst_u, int dst_stride_u, 
    1587                  uint16* dst_v, int dst_stride_v, 
    1588                  int dst_width, int dst_height, 
     1762int I420Scale_16(const uint16* src_y, 
     1763                 int src_stride_y, 
     1764                 const uint16* src_u, 
     1765                 int src_stride_u, 
     1766                 const uint16* src_v, 
     1767                 int src_stride_v, 
     1768                 int src_width, 
     1769                 int src_height, 
     1770                 uint16* dst_y, 
     1771                 int dst_stride_y, 
     1772                 uint16* dst_u, 
     1773                 int dst_stride_u, 
     1774                 uint16* dst_v, 
     1775                 int dst_stride_v, 
     1776                 int dst_width, 
     1777                 int dst_height, 
    15891778                 enum FilterMode filtering) { 
    15901779  int src_halfwidth = SUBSAMPLE(src_width, 1, 1); 
     
    15931782  int dst_halfheight = SUBSAMPLE(dst_height, 1, 1); 
    15941783  if (!src_y || !src_u || !src_v || src_width == 0 || src_height == 0 || 
    1595       src_width > 32768 || src_height > 32768 || 
    1596       !dst_y || !dst_u || !dst_v || dst_width <= 0 || dst_height <= 0) { 
     1784      src_width > 32768 || src_height > 32768 || !dst_y || !dst_u || !dst_v || 
     1785      dst_width <= 0 || dst_height <= 0) { 
    15971786    return -1; 
    15981787  } 
    15991788 
    1600   ScalePlane_16(src_y, src_stride_y, src_width, src_height, 
    1601                 dst_y, dst_stride_y, dst_width, dst_height, 
    1602                 filtering); 
    1603   ScalePlane_16(src_u, src_stride_u, src_halfwidth, src_halfheight, 
    1604                 dst_u, dst_stride_u, dst_halfwidth, dst_halfheight, 
    1605                 filtering); 
    1606   ScalePlane_16(src_v, src_stride_v, src_halfwidth, src_halfheight, 
    1607                 dst_v, dst_stride_v, dst_halfwidth, dst_halfheight, 
    1608                 filtering); 
     1789  ScalePlane_16(src_y, src_stride_y, src_width, src_height, dst_y, dst_stride_y, 
     1790                dst_width, dst_height, filtering); 
     1791  ScalePlane_16(src_u, src_stride_u, src_halfwidth, src_halfheight, dst_u, 
     1792                dst_stride_u, dst_halfwidth, dst_halfheight, filtering); 
     1793  ScalePlane_16(src_v, src_stride_v, src_halfwidth, src_halfheight, dst_v, 
     1794                dst_stride_v, dst_halfwidth, dst_halfheight, filtering); 
    16091795  return 0; 
    16101796} 
     
    16121798// Deprecated api 
    16131799LIBYUV_API 
    1614 int Scale(const uint8* src_y, const uint8* src_u, const uint8* src_v, 
    1615           int src_stride_y, int src_stride_u, int src_stride_v, 
    1616           int src_width, int src_height, 
    1617           uint8* dst_y, uint8* dst_u, uint8* dst_v, 
    1618           int dst_stride_y, int dst_stride_u, int dst_stride_v, 
    1619           int dst_width, int dst_height, 
     1800int Scale(const uint8* src_y, 
     1801          const uint8* src_u, 
     1802          const uint8* src_v, 
     1803          int src_stride_y, 
     1804          int src_stride_u, 
     1805          int src_stride_v, 
     1806          int src_width, 
     1807          int src_height, 
     1808          uint8* dst_y, 
     1809          uint8* dst_u, 
     1810          uint8* dst_v, 
     1811          int dst_stride_y, 
     1812          int dst_stride_u, 
     1813          int dst_stride_v, 
     1814          int dst_width, 
     1815          int dst_height, 
    16201816          LIBYUV_BOOL interpolate) { 
    1621   return I420Scale(src_y, src_stride_y, 
    1622                    src_u, src_stride_u, 
    1623                    src_v, src_stride_v, 
    1624                    src_width, src_height, 
    1625                    dst_y, dst_stride_y, 
    1626                    dst_u, dst_stride_u, 
    1627                    dst_v, dst_stride_v, 
    1628                    dst_width, dst_height, 
    1629                    interpolate ? kFilterBox : kFilterNone); 
     1817  return I420Scale(src_y, src_stride_y, src_u, src_stride_u, src_v, 
     1818                   src_stride_v, src_width, src_height, dst_y, dst_stride_y, 
     1819                   dst_u, dst_stride_u, dst_v, dst_stride_v, dst_width, 
     1820                   dst_height, interpolate ? kFilterBox : kFilterNone); 
    16301821} 
    16311822 
    16321823// Deprecated api 
    16331824LIBYUV_API 
    1634 int ScaleOffset(const uint8* src, int src_width, int src_height, 
    1635                 uint8* dst, int dst_width, int dst_height, int dst_yoffset, 
     1825int ScaleOffset(const uint8* src, 
     1826                int src_width, 
     1827                int src_height, 
     1828                uint8* dst, 
     1829                int dst_width, 
     1830                int dst_height, 
     1831                int dst_yoffset, 
    16361832                LIBYUV_BOOL interpolate) { 
    16371833  // Chroma requires offset to multiple of 2. 
     
    16441840  const uint8* src_y = src; 
    16451841  const uint8* src_u = src + src_width * src_height; 
    1646   const uint8* src_v = src + src_width * src_height + 
    1647                             src_halfwidth * src_halfheight; 
     1842  const uint8* src_v = 
     1843      src + src_width * src_height + src_halfwidth * src_halfheight; 
    16481844  uint8* dst_y = dst + dst_yoffset_even * dst_width; 
    1649   uint8* dst_u = dst + dst_width * dst_height + 
    1650                 (dst_yoffset_even >> 1) * dst_halfwidth; 
     1845  uint8* dst_u = 
     1846      dst + dst_width * dst_height + (dst_yoffset_even >> 1) * dst_halfwidth; 
    16511847  uint8* dst_v = dst + dst_width * dst_height + dst_halfwidth * dst_halfheight + 
    16521848                 (dst_yoffset_even >> 1) * dst_halfwidth; 
    1653   if (!src || src_width <= 0 || src_height <= 0 || 
    1654       !dst || dst_width <= 0 || dst_height <= 0 || dst_yoffset_even < 0 || 
     1849  if (!src || src_width <= 0 || src_height <= 0 || !dst || dst_width <= 0 || 
     1850      dst_height <= 0 || dst_yoffset_even < 0 || 
    16551851      dst_yoffset_even >= dst_height) { 
    16561852    return -1; 
    16571853  } 
    1658   return I420Scale(src_y, src_width, 
    1659                    src_u, src_halfwidth, 
    1660                    src_v, src_halfwidth, 
    1661                    src_width, src_height, 
    1662                    dst_y, dst_width, 
    1663                    dst_u, dst_halfwidth, 
    1664                    dst_v, dst_halfwidth, 
    1665                    dst_width, aheight, 
     1854  return I420Scale(src_y, src_width, src_u, src_halfwidth, src_v, src_halfwidth, 
     1855                   src_width, src_height, dst_y, dst_width, dst_u, 
     1856                   dst_halfwidth, dst_v, dst_halfwidth, dst_width, aheight, 
    16661857                   interpolate ? kFilterBox : kFilterNone); 
    16671858} 
Note: See TracChangeset for help on using the changeset viewer.