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_argb.cc

    r5358 r5633  
    3131// This is an optimized version for scaling down a ARGB to 1/2 of 
    3232// its original size. 
    33 static void ScaleARGBDown2(int src_width, int src_height, 
    34                            int dst_width, int dst_height, 
    35                            int src_stride, int dst_stride, 
    36                            const uint8* src_argb, uint8* dst_argb, 
    37                            int x, int dx, int y, int dy, 
     33static void ScaleARGBDown2(int src_width, 
     34                           int src_height, 
     35                           int dst_width, 
     36                           int dst_height, 
     37                           int src_stride, 
     38                           int dst_stride, 
     39                           const uint8* src_argb, 
     40                           uint8* dst_argb, 
     41                           int x, 
     42                           int dx, 
     43                           int y, 
     44                           int dy, 
    3845                           enum FilterMode filtering) { 
    3946  int j; 
     
    4148  void (*ScaleARGBRowDown2)(const uint8* src_argb, ptrdiff_t src_stride, 
    4249                            uint8* dst_argb, int dst_width) = 
    43     filtering == kFilterNone ? ScaleARGBRowDown2_C : 
    44         (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_C : 
    45         ScaleARGBRowDown2Box_C); 
    46   assert(dx == 65536 * 2);  // Test scale factor of 2. 
     50      filtering == kFilterNone 
     51          ? ScaleARGBRowDown2_C 
     52          : (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_C 
     53                                        : ScaleARGBRowDown2Box_C); 
     54  (void)src_width; 
     55  (void)src_height; 
     56  (void)dx; 
     57  assert(dx == 65536 * 2);      // Test scale factor of 2. 
    4758  assert((dy & 0x1ffff) == 0);  // Test vertical scale is multiple of 2. 
    4859  // Advance to odd row, even column. 
     
    5566#if defined(HAS_SCALEARGBROWDOWN2_SSE2) 
    5667  if (TestCpuFlag(kCpuHasSSE2)) { 
    57     ScaleARGBRowDown2 = filtering == kFilterNone ? ScaleARGBRowDown2_Any_SSE2 : 
    58         (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_Any_SSE2 : 
    59         ScaleARGBRowDown2Box_Any_SSE2); 
    60     if (IS_ALIGNED(dst_width, 4)) { 
    61       ScaleARGBRowDown2 = filtering == kFilterNone ? ScaleARGBRowDown2_SSE2 : 
    62           (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_SSE2 : 
    63           ScaleARGBRowDown2Box_SSE2); 
     68    ScaleARGBRowDown2 = 
     69        filtering == kFilterNone 
     70            ? ScaleARGBRowDown2_Any_SSE2 
     71            : (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_Any_SSE2 
     72                                          : ScaleARGBRowDown2Box_Any_SSE2); 
     73    if (IS_ALIGNED(dst_width, 4)) { 
     74      ScaleARGBRowDown2 = 
     75          filtering == kFilterNone 
     76              ? ScaleARGBRowDown2_SSE2 
     77              : (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_SSE2 
     78                                            : ScaleARGBRowDown2Box_SSE2); 
    6479    } 
    6580  } 
     
    6782#if defined(HAS_SCALEARGBROWDOWN2_NEON) 
    6883  if (TestCpuFlag(kCpuHasNEON)) { 
    69     ScaleARGBRowDown2 = filtering == kFilterNone ? ScaleARGBRowDown2_Any_NEON : 
    70         (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_Any_NEON : 
    71         ScaleARGBRowDown2Box_Any_NEON); 
     84    ScaleARGBRowDown2 = 
     85        filtering == kFilterNone 
     86            ? ScaleARGBRowDown2_Any_NEON 
     87            : (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_Any_NEON 
     88                                          : ScaleARGBRowDown2Box_Any_NEON); 
    7289    if (IS_ALIGNED(dst_width, 8)) { 
    73       ScaleARGBRowDown2 = filtering == kFilterNone ? ScaleARGBRowDown2_NEON : 
    74           (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_NEON : 
    75           ScaleARGBRowDown2Box_NEON); 
     90      ScaleARGBRowDown2 = 
     91          filtering == kFilterNone 
     92              ? ScaleARGBRowDown2_NEON 
     93              : (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_NEON 
     94                                            : ScaleARGBRowDown2Box_NEON); 
     95    } 
     96  } 
     97#endif 
     98#if defined(HAS_SCALEARGBROWDOWN2_MSA) 
     99  if (TestCpuFlag(kCpuHasMSA)) { 
     100    ScaleARGBRowDown2 = 
     101        filtering == kFilterNone 
     102            ? ScaleARGBRowDown2_Any_MSA 
     103            : (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_Any_MSA 
     104                                          : ScaleARGBRowDown2Box_Any_MSA); 
     105    if (IS_ALIGNED(dst_width, 4)) { 
     106      ScaleARGBRowDown2 = 
     107          filtering == kFilterNone 
     108              ? ScaleARGBRowDown2_MSA 
     109              : (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_MSA 
     110                                            : ScaleARGBRowDown2Box_MSA); 
    76111    } 
    77112  } 
     
    91126// This is an optimized version for scaling down a ARGB to 1/4 of 
    92127// its original size. 
    93 static void ScaleARGBDown4Box(int src_width, int src_height, 
    94                               int dst_width, int dst_height, 
    95                               int src_stride, int dst_stride, 
    96                               const uint8* src_argb, uint8* dst_argb, 
    97                               int x, int dx, int y, int dy) { 
     128static void ScaleARGBDown4Box(int src_width, 
     129                              int src_height, 
     130                              int dst_width, 
     131                              int dst_height, 
     132                              int src_stride, 
     133                              int dst_stride, 
     134                              const uint8* src_argb, 
     135                              uint8* dst_argb, 
     136                              int x, 
     137                              int dx, 
     138                              int y, 
     139                              int dy) { 
    98140  int j; 
    99141  // Allocate 2 rows of ARGB. 
     
    102144  int row_stride = src_stride * (dy >> 16); 
    103145  void (*ScaleARGBRowDown2)(const uint8* src_argb, ptrdiff_t src_stride, 
    104     uint8* dst_argb, int dst_width) = ScaleARGBRowDown2Box_C; 
     146                            uint8* dst_argb, int dst_width) = 
     147      ScaleARGBRowDown2Box_C; 
    105148  // Advance to odd row, even column. 
    106149  src_argb += (y >> 16) * src_stride + (x >> 16) * 4; 
    107   assert(dx == 65536 * 4);  // Test scale factor of 4. 
     150  (void)src_width; 
     151  (void)src_height; 
     152  (void)dx; 
     153  assert(dx == 65536 * 4);      // Test scale factor of 4. 
    108154  assert((dy & 0x3ffff) == 0);  // Test vertical scale is multiple of 4. 
    109155#if defined(HAS_SCALEARGBROWDOWN2_SSE2) 
     
    126172  for (j = 0; j < dst_height; ++j) { 
    127173    ScaleARGBRowDown2(src_argb, src_stride, row, dst_width * 2); 
    128     ScaleARGBRowDown2(src_argb + src_stride * 2, src_stride, 
    129                       row + kRowSize, dst_width * 2); 
     174    ScaleARGBRowDown2(src_argb + src_stride * 2, src_stride, row + kRowSize, 
     175                      dst_width * 2); 
    130176    ScaleARGBRowDown2(row, kRowSize, dst_argb, dst_width); 
    131177    src_argb += row_stride; 
     
    138184// This is an optimized version for scaling down a ARGB to even 
    139185// multiple of its original size. 
    140 static void ScaleARGBDownEven(int src_width, int src_height, 
    141                               int dst_width, int dst_height, 
    142                               int src_stride, int dst_stride, 
    143                               const uint8* src_argb, uint8* dst_argb, 
    144                               int x, int dx, int y, int dy, 
     186static void ScaleARGBDownEven(int src_width, 
     187                              int src_height, 
     188                              int dst_width, 
     189                              int dst_height, 
     190                              int src_stride, 
     191                              int dst_stride, 
     192                              const uint8* src_argb, 
     193                              uint8* dst_argb, 
     194                              int x, 
     195                              int dx, 
     196                              int y, 
     197                              int dy, 
    145198                              enum FilterMode filtering) { 
    146199  int j; 
     
    150203                               int src_step, uint8* dst_argb, int dst_width) = 
    151204      filtering ? ScaleARGBRowDownEvenBox_C : ScaleARGBRowDownEven_C; 
     205  (void)src_width; 
     206  (void)src_height; 
    152207  assert(IS_ALIGNED(src_width, 2)); 
    153208  assert(IS_ALIGNED(src_height, 2)); 
     
    155210#if defined(HAS_SCALEARGBROWDOWNEVEN_SSE2) 
    156211  if (TestCpuFlag(kCpuHasSSE2)) { 
    157     ScaleARGBRowDownEven = filtering ? ScaleARGBRowDownEvenBox_Any_SSE2 : 
    158         ScaleARGBRowDownEven_Any_SSE2; 
    159     if (IS_ALIGNED(dst_width, 4)) { 
    160       ScaleARGBRowDownEven = filtering ? ScaleARGBRowDownEvenBox_SSE2 : 
    161           ScaleARGBRowDownEven_SSE2; 
     212    ScaleARGBRowDownEven = filtering ? ScaleARGBRowDownEvenBox_Any_SSE2 
     213                                     : ScaleARGBRowDownEven_Any_SSE2; 
     214    if (IS_ALIGNED(dst_width, 4)) { 
     215      ScaleARGBRowDownEven = 
     216          filtering ? ScaleARGBRowDownEvenBox_SSE2 : ScaleARGBRowDownEven_SSE2; 
    162217    } 
    163218  } 
     
    165220#if defined(HAS_SCALEARGBROWDOWNEVEN_NEON) 
    166221  if (TestCpuFlag(kCpuHasNEON)) { 
    167     ScaleARGBRowDownEven = filtering ? ScaleARGBRowDownEvenBox_Any_NEON : 
    168         ScaleARGBRowDownEven_Any_NEON; 
    169     if (IS_ALIGNED(dst_width, 4)) { 
    170       ScaleARGBRowDownEven = filtering ? ScaleARGBRowDownEvenBox_NEON : 
    171           ScaleARGBRowDownEven_NEON; 
     222    ScaleARGBRowDownEven = filtering ? ScaleARGBRowDownEvenBox_Any_NEON 
     223                                     : ScaleARGBRowDownEven_Any_NEON; 
     224    if (IS_ALIGNED(dst_width, 4)) { 
     225      ScaleARGBRowDownEven = 
     226          filtering ? ScaleARGBRowDownEvenBox_NEON : ScaleARGBRowDownEven_NEON; 
     227    } 
     228  } 
     229#endif 
     230#if defined(HAS_SCALEARGBROWDOWNEVEN_MSA) 
     231  if (TestCpuFlag(kCpuHasMSA)) { 
     232    ScaleARGBRowDownEven = filtering ? ScaleARGBRowDownEvenBox_Any_MSA 
     233                                     : ScaleARGBRowDownEven_Any_MSA; 
     234    if (IS_ALIGNED(dst_width, 4)) { 
     235      ScaleARGBRowDownEven = 
     236          filtering ? ScaleARGBRowDownEvenBox_MSA : ScaleARGBRowDownEven_MSA; 
    172237    } 
    173238  } 
     
    185250 
    186251// Scale ARGB down with bilinear interpolation. 
    187 static void ScaleARGBBilinearDown(int src_width, int src_height, 
    188                                   int dst_width, int dst_height, 
    189                                   int src_stride, int dst_stride, 
    190                                   const uint8* src_argb, uint8* dst_argb, 
    191                                   int x, int dx, int y, int dy, 
     252static void ScaleARGBBilinearDown(int src_width, 
     253                                  int src_height, 
     254                                  int dst_width, 
     255                                  int dst_height, 
     256                                  int src_stride, 
     257                                  int dst_stride, 
     258                                  const uint8* src_argb, 
     259                                  uint8* dst_argb, 
     260                                  int x, 
     261                                  int dx, 
     262                                  int y, 
     263                                  int dy, 
    192264                                  enum FilterMode filtering) { 
    193265  int j; 
    194   void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb, 
    195       ptrdiff_t src_stride, int dst_width, int source_y_fraction) = 
    196       InterpolateRow_C; 
    197   void (*ScaleARGBFilterCols)(uint8* dst_argb, const uint8* src_argb, 
    198       int dst_width, int x, int dx) = 
     266  void (*InterpolateRow)(uint8 * dst_argb, const uint8* src_argb, 
     267                         ptrdiff_t src_stride, int dst_width, 
     268                         int source_y_fraction) = InterpolateRow_C; 
     269  void (*ScaleARGBFilterCols)(uint8 * dst_argb, const uint8* src_argb, 
     270                              int dst_width, int x, int dx) = 
    199271      (src_width >= 32768) ? ScaleARGBFilterCols64_C : ScaleARGBFilterCols_C; 
    200272  int64 xlast = x + (int64)(dst_width - 1) * dx; 
     
    202274  int64 xr = (dx >= 0) ? xlast : x; 
    203275  int clip_src_width; 
    204   xl = (xl >> 16) & ~3;  // Left edge aligned. 
    205   xr = (xr >> 16) + 1;  // Right most pixel used.  Bilinear uses 2 pixels. 
     276  xl = (xl >> 16) & ~3;    // Left edge aligned. 
     277  xr = (xr >> 16) + 1;     // Right most pixel used.  Bilinear uses 2 pixels. 
    206278  xr = (xr + 1 + 3) & ~3;  // 1 beyond 4 pixel aligned right most pixel. 
    207279  if (xr > src_width) { 
     
    236308#endif 
    237309#if defined(HAS_INTERPOLATEROW_DSPR2) 
    238   if (TestCpuFlag(kCpuHasDSPR2) && 
    239       IS_ALIGNED(src_argb, 4) && IS_ALIGNED(src_stride, 4)) { 
     310  if (TestCpuFlag(kCpuHasDSPR2) && IS_ALIGNED(src_argb, 4) && 
     311      IS_ALIGNED(src_stride, 4)) { 
    240312    InterpolateRow = InterpolateRow_Any_DSPR2; 
    241313    if (IS_ALIGNED(clip_src_width, 4)) { 
    242314      InterpolateRow = InterpolateRow_DSPR2; 
     315    } 
     316  } 
     317#endif 
     318#if defined(HAS_INTERPOLATEROW_MSA) 
     319  if (TestCpuFlag(kCpuHasMSA)) { 
     320    InterpolateRow = InterpolateRow_Any_MSA; 
     321    if (IS_ALIGNED(clip_src_width, 32)) { 
     322      InterpolateRow = InterpolateRow_MSA; 
    243323    } 
    244324  } 
     
    287367 
    288368// Scale ARGB up with bilinear interpolation. 
    289 static void ScaleARGBBilinearUp(int src_width, int src_height, 
    290                                 int dst_width, int dst_height, 
    291                                 int src_stride, int dst_stride, 
    292                                 const uint8* src_argb, uint8* dst_argb, 
    293                                 int x, int dx, int y, int dy, 
     369static void ScaleARGBBilinearUp(int src_width, 
     370                                int src_height, 
     371                                int dst_width, 
     372                                int dst_height, 
     373                                int src_stride, 
     374                                int dst_stride, 
     375                                const uint8* src_argb, 
     376                                uint8* dst_argb, 
     377                                int x, 
     378                                int dx, 
     379                                int y, 
     380                                int dy, 
    294381                                enum FilterMode filtering) { 
    295382  int j; 
    296   void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb, 
    297       ptrdiff_t src_stride, int dst_width, int source_y_fraction) = 
    298       InterpolateRow_C; 
    299   void (*ScaleARGBFilterCols)(uint8* dst_argb, const uint8* src_argb, 
    300       int dst_width, int x, int dx) = 
     383  void (*InterpolateRow)(uint8 * dst_argb, const uint8* src_argb, 
     384                         ptrdiff_t src_stride, int dst_width, 
     385                         int source_y_fraction) = InterpolateRow_C; 
     386  void (*ScaleARGBFilterCols)(uint8 * dst_argb, const uint8* src_argb, 
     387                              int dst_width, int x, int dx) = 
    301388      filtering ? ScaleARGBFilterCols_C : ScaleARGBCols_C; 
    302389  const int max_y = (src_height - 1) << 16; 
     
    326413#endif 
    327414#if defined(HAS_INTERPOLATEROW_DSPR2) 
    328   if (TestCpuFlag(kCpuHasDSPR2) && 
    329       IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride, 4)) { 
     415  if (TestCpuFlag(kCpuHasDSPR2) && IS_ALIGNED(dst_argb, 4) && 
     416      IS_ALIGNED(dst_stride, 4)) { 
    330417    InterpolateRow = InterpolateRow_DSPR2; 
    331418  } 
    332419#endif 
     420#if defined(HAS_INTERPOLATEROW_MSA) 
     421  if (TestCpuFlag(kCpuHasMSA)) { 
     422    InterpolateRow = InterpolateRow_Any_MSA; 
     423    if (IS_ALIGNED(dst_width, 8)) { 
     424      InterpolateRow = InterpolateRow_MSA; 
     425    } 
     426  } 
     427#endif 
    333428  if (src_width >= 32768) { 
    334     ScaleARGBFilterCols = filtering ? 
    335         ScaleARGBFilterCols64_C : ScaleARGBCols64_C; 
     429    ScaleARGBFilterCols = 
     430        filtering ? ScaleARGBFilterCols64_C : ScaleARGBCols64_C; 
    336431  } 
    337432#if defined(HAS_SCALEARGBFILTERCOLS_SSSE3) 
     
    424519#ifdef YUVSCALEUP 
    425520// Scale YUV to ARGB up with bilinear interpolation. 
    426 static void ScaleYUVToARGBBilinearUp(int src_width, int src_height, 
    427                                      int dst_width, int dst_height, 
     521static void ScaleYUVToARGBBilinearUp(int src_width, 
     522                                     int src_height, 
     523                                     int dst_width, 
     524                                     int dst_height, 
    428525                                     int src_stride_y, 
    429526                                     int src_stride_u, 
     
    434531                                     const uint8* src_v, 
    435532                                     uint8* dst_argb, 
    436                                      int x, int dx, int y, int dy, 
     533                                     int x, 
     534                                     int dx, 
     535                                     int y, 
     536                                     int dy, 
    437537                                     enum FilterMode filtering) { 
    438538  int j; 
    439   void (*I422ToARGBRow)(const uint8* y_buf, 
    440                         const uint8* u_buf, 
    441                         const uint8* v_buf, 
    442                         uint8* rgb_buf, 
    443                         int width) = I422ToARGBRow_C; 
     539  void (*I422ToARGBRow)(const uint8* y_buf, const uint8* u_buf, 
     540                        const uint8* v_buf, uint8* rgb_buf, int width) = 
     541      I422ToARGBRow_C; 
    444542#if defined(HAS_I422TOARGBROW_SSSE3) 
    445543  if (TestCpuFlag(kCpuHasSSSE3)) { 
     
    475573  } 
    476574#endif 
    477  
    478   void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb, 
    479       ptrdiff_t src_stride, int dst_width, int source_y_fraction) = 
    480       InterpolateRow_C; 
     575#if defined(HAS_I422TOARGBROW_MSA) 
     576  if (TestCpuFlag(kCpuHasMSA)) { 
     577    I422ToARGBRow = I422ToARGBRow_Any_MSA; 
     578    if (IS_ALIGNED(src_width, 8)) { 
     579      I422ToARGBRow = I422ToARGBRow_MSA; 
     580    } 
     581  } 
     582#endif 
     583 
     584  void (*InterpolateRow)(uint8 * dst_argb, const uint8* src_argb, 
     585                         ptrdiff_t src_stride, int dst_width, 
     586                         int source_y_fraction) = InterpolateRow_C; 
    481587#if defined(HAS_INTERPOLATEROW_SSSE3) 
    482588  if (TestCpuFlag(kCpuHasSSSE3)) { 
     
    504610#endif 
    505611#if defined(HAS_INTERPOLATEROW_DSPR2) 
    506   if (TestCpuFlag(kCpuHasDSPR2) && 
    507       IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) { 
     612  if (TestCpuFlag(kCpuHasDSPR2) && IS_ALIGNED(dst_argb, 4) && 
     613      IS_ALIGNED(dst_stride_argb, 4)) { 
    508614    InterpolateRow = InterpolateRow_DSPR2; 
    509615  } 
    510616#endif 
    511  
    512   void (*ScaleARGBFilterCols)(uint8* dst_argb, const uint8* src_argb, 
    513       int dst_width, int x, int dx) = 
     617#if defined(HAS_INTERPOLATEROW_MSA) 
     618  if (TestCpuFlag(kCpuHasMSA)) { 
     619    InterpolateRow = InterpolateRow_Any_MSA; 
     620    if (IS_ALIGNED(dst_width, 8)) { 
     621      InterpolateRow = InterpolateRow_MSA; 
     622    } 
     623  } 
     624#endif 
     625 
     626  void (*ScaleARGBFilterCols)(uint8 * dst_argb, const uint8* src_argb, 
     627                              int dst_width, int x, int dx) = 
    514628      filtering ? ScaleARGBFilterCols_C : ScaleARGBCols_C; 
    515629  if (src_width >= 32768) { 
    516     ScaleARGBFilterCols = filtering ? 
    517         ScaleARGBFilterCols64_C : ScaleARGBCols64_C; 
     630    ScaleARGBFilterCols = 
     631        filtering ? ScaleARGBFilterCols64_C : ScaleARGBCols64_C; 
    518632  } 
    519633#if defined(HAS_SCALEARGBFILTERCOLS_SSSE3) 
     
    636750// the lower 16 bits are the fixed decimal part. 
    637751 
    638 static void ScaleARGBSimple(int src_width, int src_height, 
    639                             int dst_width, int dst_height, 
    640                             int src_stride, int dst_stride, 
    641                             const uint8* src_argb, uint8* dst_argb, 
    642                             int x, int dx, int y, int dy) { 
     752static void ScaleARGBSimple(int src_width, 
     753                            int src_height, 
     754                            int dst_width, 
     755                            int dst_height, 
     756                            int src_stride, 
     757                            int dst_stride, 
     758                            const uint8* src_argb, 
     759                            uint8* dst_argb, 
     760                            int x, 
     761                            int dx, 
     762                            int y, 
     763                            int dy) { 
    643764  int j; 
    644   void (*ScaleARGBCols)(uint8* dst_argb, const uint8* src_argb, 
    645       int dst_width, int x, int dx) = 
     765  void (*ScaleARGBCols)(uint8 * dst_argb, const uint8* src_argb, int dst_width, 
     766                        int x, int dx) = 
    646767      (src_width >= 32768) ? ScaleARGBCols64_C : ScaleARGBCols_C; 
     768  (void)src_height; 
    647769#if defined(HAS_SCALEARGBCOLS_SSE2) 
    648770  if (TestCpuFlag(kCpuHasSSE2) && src_width < 32768) { 
     
    668790 
    669791  for (j = 0; j < dst_height; ++j) { 
    670     ScaleARGBCols(dst_argb, src_argb + (y >> 16) * src_stride, 
    671                   dst_width, x, dx); 
     792    ScaleARGBCols(dst_argb, src_argb + (y >> 16) * src_stride, dst_width, x, 
     793                  dx); 
    672794    dst_argb += dst_stride; 
    673795    y += dy; 
     
    678800// This function in turn calls a scaling function 
    679801// suitable for handling the desired resolutions. 
    680 static void ScaleARGB(const uint8* src, int src_stride, 
    681                       int src_width, int src_height, 
    682                       uint8* dst, int dst_stride, 
    683                       int dst_width, int dst_height, 
    684                       int clip_x, int clip_y, int clip_width, int clip_height, 
     802static void ScaleARGB(const uint8* src, 
     803                      int src_stride, 
     804                      int src_width, 
     805                      int src_height, 
     806                      uint8* dst, 
     807                      int dst_stride, 
     808                      int dst_width, 
     809                      int dst_height, 
     810                      int clip_x, 
     811                      int clip_y, 
     812                      int clip_width, 
     813                      int clip_height, 
    685814                      enum FilterMode filtering) { 
    686815  // Initial source x/y coordinate and step values as 16.16 fixed point. 
     
    691820  // ARGB does not support box filter yet, but allow the user to pass it. 
    692821  // Simplify filtering when possible. 
    693   filtering = ScaleFilterReduce(src_width, src_height, 
    694                                 dst_width, dst_height, 
     822  filtering = ScaleFilterReduce(src_width, src_height, dst_width, dst_height, 
    695823                                filtering); 
    696824 
     
    701829    src_stride = -src_stride; 
    702830  } 
    703   ScaleSlope(src_width, src_height, dst_width, dst_height, filtering, 
    704              &x, &y, &dx, &dy); 
     831  ScaleSlope(src_width, src_height, dst_width, dst_height, filtering, &x, &y, 
     832             &dx, &dy); 
    705833  src_width = Abs(src_width); 
    706834  if (clip_x) { 
    707     int64 clipf = (int64)(clip_x) * dx; 
     835    int64 clipf = (int64)(clip_x)*dx; 
    708836    x += (clipf & 0xffff); 
    709837    src += (clipf >> 16) * 4; 
     
    711839  } 
    712840  if (clip_y) { 
    713     int64 clipf = (int64)(clip_y) * dy; 
     841    int64 clipf = (int64)(clip_y)*dy; 
    714842    y += (clipf & 0xffff); 
    715843    src += (clipf >> 16) * src_stride; 
     
    726854        if (dx == 0x20000) { 
    727855          // Optimized 1/2 downsample. 
    728           ScaleARGBDown2(src_width, src_height, 
    729                          clip_width, clip_height, 
    730                          src_stride, dst_stride, src, dst, 
    731                          x, dx, y, dy, filtering); 
     856          ScaleARGBDown2(src_width, src_height, clip_width, clip_height, 
     857                         src_stride, dst_stride, src, dst, x, dx, y, dy, 
     858                         filtering); 
    732859          return; 
    733860        } 
    734861        if (dx == 0x40000 && filtering == kFilterBox) { 
    735862          // Optimized 1/4 box downsample. 
    736           ScaleARGBDown4Box(src_width, src_height, 
    737                             clip_width, clip_height, 
    738                             src_stride, dst_stride, src, dst, 
    739                             x, dx, y, dy); 
     863          ScaleARGBDown4Box(src_width, src_height, clip_width, clip_height, 
     864                            src_stride, dst_stride, src, dst, x, dx, y, dy); 
    740865          return; 
    741866        } 
    742         ScaleARGBDownEven(src_width, src_height, 
    743                           clip_width, clip_height, 
    744                           src_stride, dst_stride, src, dst, 
    745                           x, dx, y, dy, filtering); 
     867        ScaleARGBDownEven(src_width, src_height, clip_width, clip_height, 
     868                          src_stride, dst_stride, src, dst, x, dx, y, dy, 
     869                          filtering); 
    746870        return; 
    747871      } 
     
    760884  if (dx == 0x10000 && (x & 0xffff) == 0) { 
    761885    // Arbitrary scale vertically, but unscaled vertically. 
    762     ScalePlaneVertical(src_height, 
    763                        clip_width, clip_height, 
    764                        src_stride, dst_stride, src, dst, 
    765                        x, y, dy, 4, filtering); 
     886    ScalePlaneVertical(src_height, clip_width, clip_height, src_stride, 
     887                       dst_stride, src, dst, x, y, dy, 4, filtering); 
    766888    return; 
    767889  } 
    768890  if (filtering && dy < 65536) { 
    769     ScaleARGBBilinearUp(src_width, src_height, 
    770                         clip_width, clip_height, 
    771                         src_stride, dst_stride, src, dst, 
    772                         x, dx, y, dy, filtering); 
     891    ScaleARGBBilinearUp(src_width, src_height, clip_width, clip_height, 
     892                        src_stride, dst_stride, src, dst, x, dx, y, dy, 
     893                        filtering); 
    773894    return; 
    774895  } 
    775896  if (filtering) { 
    776     ScaleARGBBilinearDown(src_width, src_height, 
    777                           clip_width, clip_height, 
    778                           src_stride, dst_stride, src, dst, 
    779                           x, dx, y, dy, filtering); 
     897    ScaleARGBBilinearDown(src_width, src_height, clip_width, clip_height, 
     898                          src_stride, dst_stride, src, dst, x, dx, y, dy, 
     899                          filtering); 
    780900    return; 
    781901  } 
    782   ScaleARGBSimple(src_width, src_height, clip_width, clip_height, 
    783                   src_stride, dst_stride, src, dst, 
    784                   x, dx, y, dy); 
     902  ScaleARGBSimple(src_width, src_height, clip_width, clip_height, src_stride, 
     903                  dst_stride, src, dst, x, dx, y, dy); 
    785904} 
    786905 
    787906LIBYUV_API 
    788 int ARGBScaleClip(const uint8* src_argb, int src_stride_argb, 
    789                   int src_width, int src_height, 
    790                   uint8* dst_argb, int dst_stride_argb, 
    791                   int dst_width, int dst_height, 
    792                   int clip_x, int clip_y, int clip_width, int clip_height, 
     907int ARGBScaleClip(const uint8* src_argb, 
     908                  int src_stride_argb, 
     909                  int src_width, 
     910                  int src_height, 
     911                  uint8* dst_argb, 
     912                  int dst_stride_argb, 
     913                  int dst_width, 
     914                  int dst_height, 
     915                  int clip_x, 
     916                  int clip_y, 
     917                  int clip_width, 
     918                  int clip_height, 
    793919                  enum FilterMode filtering) { 
    794   if (!src_argb || src_width == 0 || src_height == 0 || 
    795       !dst_argb || dst_width <= 0 || dst_height <= 0 || 
    796       clip_x < 0 || clip_y < 0 || 
     920  if (!src_argb || src_width == 0 || src_height == 0 || !dst_argb || 
     921      dst_width <= 0 || dst_height <= 0 || clip_x < 0 || clip_y < 0 || 
    797922      clip_width > 32768 || clip_height > 32768 || 
    798923      (clip_x + clip_width) > dst_width || 
     
    800925    return -1; 
    801926  } 
    802   ScaleARGB(src_argb, src_stride_argb, src_width, src_height, 
    803             dst_argb, dst_stride_argb, dst_width, dst_height, 
    804             clip_x, clip_y, clip_width, clip_height, filtering); 
     927  ScaleARGB(src_argb, src_stride_argb, src_width, src_height, dst_argb, 
     928            dst_stride_argb, dst_width, dst_height, clip_x, clip_y, clip_width, 
     929            clip_height, filtering); 
    805930  return 0; 
    806931} 
     
    808933// Scale an ARGB image. 
    809934LIBYUV_API 
    810 int ARGBScale(const uint8* src_argb, int src_stride_argb, 
    811               int src_width, int src_height, 
    812               uint8* dst_argb, int dst_stride_argb, 
    813               int dst_width, int dst_height, 
     935int ARGBScale(const uint8* src_argb, 
     936              int src_stride_argb, 
     937              int src_width, 
     938              int src_height, 
     939              uint8* dst_argb, 
     940              int dst_stride_argb, 
     941              int dst_width, 
     942              int dst_height, 
    814943              enum FilterMode filtering) { 
    815   if (!src_argb || src_width == 0 || src_height == 0 || 
    816       src_width > 32768 || src_height > 32768 || 
    817       !dst_argb || dst_width <= 0 || dst_height <= 0) { 
     944  if (!src_argb || src_width == 0 || src_height == 0 || src_width > 32768 || 
     945      src_height > 32768 || !dst_argb || dst_width <= 0 || dst_height <= 0) { 
    818946    return -1; 
    819947  } 
    820   ScaleARGB(src_argb, src_stride_argb, src_width, src_height, 
    821             dst_argb, dst_stride_argb, dst_width, dst_height, 
    822             0, 0, dst_width, dst_height, filtering); 
     948  ScaleARGB(src_argb, src_stride_argb, src_width, src_height, dst_argb, 
     949            dst_stride_argb, dst_width, dst_height, 0, 0, dst_width, dst_height, 
     950            filtering); 
    823951  return 0; 
    824952} 
     
    826954// Scale with YUV conversion to ARGB and clipping. 
    827955LIBYUV_API 
    828 int YUVToARGBScaleClip(const uint8* src_y, int src_stride_y, 
    829                        const uint8* src_u, int src_stride_u, 
    830                        const uint8* src_v, int src_stride_v, 
     956int YUVToARGBScaleClip(const uint8* src_y, 
     957                       int src_stride_y, 
     958                       const uint8* src_u, 
     959                       int src_stride_u, 
     960                       const uint8* src_v, 
     961                       int src_stride_v, 
    831962                       uint32 src_fourcc, 
    832                        int src_width, int src_height, 
    833                        uint8* dst_argb, int dst_stride_argb, 
     963                       int src_width, 
     964                       int src_height, 
     965                       uint8* dst_argb, 
     966                       int dst_stride_argb, 
    834967                       uint32 dst_fourcc, 
    835                        int dst_width, int dst_height, 
    836                        int clip_x, int clip_y, int clip_width, int clip_height, 
     968                       int dst_width, 
     969                       int dst_height, 
     970                       int clip_x, 
     971                       int clip_y, 
     972                       int clip_width, 
     973                       int clip_height, 
    837974                       enum FilterMode filtering) { 
    838975  uint8* argb_buffer = (uint8*)malloc(src_width * src_height * 4); 
    839976  int r; 
    840   I420ToARGB(src_y, src_stride_y, 
    841              src_u, src_stride_u, 
    842              src_v, src_stride_v, 
    843              argb_buffer, src_width * 4, 
    844              src_width, src_height); 
    845  
    846   r = ARGBScaleClip(argb_buffer, src_width * 4, 
    847                     src_width, src_height, 
    848                     dst_argb, dst_stride_argb, 
    849                     dst_width, dst_height, 
    850                     clip_x, clip_y, clip_width, clip_height, 
    851                     filtering); 
     977  (void)src_fourcc;  // TODO(fbarchard): implement and/or assert. 
     978  (void)dst_fourcc; 
     979  I420ToARGB(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v, 
     980             argb_buffer, src_width * 4, src_width, src_height); 
     981 
     982  r = ARGBScaleClip(argb_buffer, src_width * 4, src_width, src_height, dst_argb, 
     983                    dst_stride_argb, dst_width, dst_height, clip_x, clip_y, 
     984                    clip_width, clip_height, filtering); 
    852985  free(argb_buffer); 
    853986  return r; 
Note: See TracChangeset for help on using the changeset viewer.