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/convert_from.cc

    r5358 r5633  
    1616#include "libyuv/planar_functions.h" 
    1717#include "libyuv/rotate.h" 
     18#include "libyuv/row.h" 
    1819#include "libyuv/scale.h"  // For ScalePlane() 
    1920#include "libyuv/video_common.h" 
    20 #include "libyuv/row.h" 
    2121 
    2222#ifdef __cplusplus 
     
    3131 
    3232// I420 To any I4xx YUV format with mirroring. 
    33 static int I420ToI4xx(const uint8* src_y, int src_stride_y, 
    34                       const uint8* src_u, int src_stride_u, 
    35                       const uint8* src_v, int src_stride_v, 
    36                       uint8* dst_y, int dst_stride_y, 
    37                       uint8* dst_u, int dst_stride_u, 
    38                       uint8* dst_v, int dst_stride_v, 
    39                       int src_y_width, int src_y_height, 
    40                       int dst_uv_width, int dst_uv_height) { 
     33static int I420ToI4xx(const uint8* src_y, 
     34                      int src_stride_y, 
     35                      const uint8* src_u, 
     36                      int src_stride_u, 
     37                      const uint8* src_v, 
     38                      int src_stride_v, 
     39                      uint8* dst_y, 
     40                      int dst_stride_y, 
     41                      uint8* dst_u, 
     42                      int dst_stride_u, 
     43                      uint8* dst_v, 
     44                      int dst_stride_v, 
     45                      int src_y_width, 
     46                      int src_y_height, 
     47                      int dst_uv_width, 
     48                      int dst_uv_height) { 
    4149  const int dst_y_width = Abs(src_y_width); 
    4250  const int dst_y_height = Abs(src_y_height); 
    4351  const int src_uv_width = SUBSAMPLE(src_y_width, 1, 1); 
    4452  const int src_uv_height = SUBSAMPLE(src_y_height, 1, 1); 
    45   if (src_y_width == 0 || src_y_height == 0 || 
    46       dst_uv_width <= 0 || dst_uv_height <= 0) { 
    47     return -1; 
    48   } 
    49   ScalePlane(src_y, src_stride_y, src_y_width, src_y_height, 
    50              dst_y, dst_stride_y, dst_y_width, dst_y_height, 
    51              kFilterBilinear); 
    52   ScalePlane(src_u, src_stride_u, src_uv_width, src_uv_height, 
    53              dst_u, dst_stride_u, dst_uv_width, dst_uv_height, 
    54              kFilterBilinear); 
    55   ScalePlane(src_v, src_stride_v, src_uv_width, src_uv_height, 
    56              dst_v, dst_stride_v, dst_uv_width, dst_uv_height, 
    57              kFilterBilinear); 
     53  if (src_y_width == 0 || src_y_height == 0 || dst_uv_width <= 0 || 
     54      dst_uv_height <= 0) { 
     55    return -1; 
     56  } 
     57  if (dst_y) { 
     58    ScalePlane(src_y, src_stride_y, src_y_width, src_y_height, dst_y, 
     59               dst_stride_y, dst_y_width, dst_y_height, kFilterBilinear); 
     60  } 
     61  ScalePlane(src_u, src_stride_u, src_uv_width, src_uv_height, dst_u, 
     62             dst_stride_u, dst_uv_width, dst_uv_height, kFilterBilinear); 
     63  ScalePlane(src_v, src_stride_v, src_uv_width, src_uv_height, dst_v, 
     64             dst_stride_v, dst_uv_width, dst_uv_height, kFilterBilinear); 
    5865  return 0; 
    5966} 
     
    6269// 422 chroma is 1/2 width, 1x height 
    6370LIBYUV_API 
    64 int I420ToI422(const uint8* src_y, int src_stride_y, 
    65                const uint8* src_u, int src_stride_u, 
    66                const uint8* src_v, int src_stride_v, 
    67                uint8* dst_y, int dst_stride_y, 
    68                uint8* dst_u, int dst_stride_u, 
    69                uint8* dst_v, int dst_stride_v, 
    70                int width, int height) { 
     71int I420ToI422(const uint8* src_y, 
     72               int src_stride_y, 
     73               const uint8* src_u, 
     74               int src_stride_u, 
     75               const uint8* src_v, 
     76               int src_stride_v, 
     77               uint8* dst_y, 
     78               int dst_stride_y, 
     79               uint8* dst_u, 
     80               int dst_stride_u, 
     81               uint8* dst_v, 
     82               int dst_stride_v, 
     83               int width, 
     84               int height) { 
    7185  const int dst_uv_width = (Abs(width) + 1) >> 1; 
    7286  const int dst_uv_height = Abs(height); 
    73   return I420ToI4xx(src_y, src_stride_y, 
    74                     src_u, src_stride_u, 
    75                     src_v, src_stride_v, 
    76                     dst_y, dst_stride_y, 
    77                     dst_u, dst_stride_u, 
    78                     dst_v, dst_stride_v, 
    79                     width, height, 
    80                     dst_uv_width, dst_uv_height); 
     87  return I420ToI4xx(src_y, src_stride_y, src_u, src_stride_u, src_v, 
     88                    src_stride_v, dst_y, dst_stride_y, dst_u, dst_stride_u, 
     89                    dst_v, dst_stride_v, width, height, dst_uv_width, 
     90                    dst_uv_height); 
    8191} 
    8292 
     
    8494// 444 chroma is 1x width, 1x height 
    8595LIBYUV_API 
    86 int I420ToI444(const uint8* src_y, int src_stride_y, 
    87                const uint8* src_u, int src_stride_u, 
    88                const uint8* src_v, int src_stride_v, 
    89                uint8* dst_y, int dst_stride_y, 
    90                uint8* dst_u, int dst_stride_u, 
    91                uint8* dst_v, int dst_stride_v, 
    92                int width, int height) { 
     96int I420ToI444(const uint8* src_y, 
     97               int src_stride_y, 
     98               const uint8* src_u, 
     99               int src_stride_u, 
     100               const uint8* src_v, 
     101               int src_stride_v, 
     102               uint8* dst_y, 
     103               int dst_stride_y, 
     104               uint8* dst_u, 
     105               int dst_stride_u, 
     106               uint8* dst_v, 
     107               int dst_stride_v, 
     108               int width, 
     109               int height) { 
    93110  const int dst_uv_width = Abs(width); 
    94111  const int dst_uv_height = Abs(height); 
    95   return I420ToI4xx(src_y, src_stride_y, 
    96                     src_u, src_stride_u, 
    97                     src_v, src_stride_v, 
    98                     dst_y, dst_stride_y, 
    99                     dst_u, dst_stride_u, 
    100                     dst_v, dst_stride_v, 
    101                     width, height, 
    102                     dst_uv_width, dst_uv_height); 
    103 } 
    104  
    105 // 420 chroma is 1/2 width, 1/2 height 
    106 // 411 chroma is 1/4 width, 1x height 
    107 LIBYUV_API 
    108 int I420ToI411(const uint8* src_y, int src_stride_y, 
    109                const uint8* src_u, int src_stride_u, 
    110                const uint8* src_v, int src_stride_v, 
    111                uint8* dst_y, int dst_stride_y, 
    112                uint8* dst_u, int dst_stride_u, 
    113                uint8* dst_v, int dst_stride_v, 
    114                int width, int height) { 
    115   const int dst_uv_width = (Abs(width) + 3) >> 2; 
    116   const int dst_uv_height = Abs(height); 
    117   return I420ToI4xx(src_y, src_stride_y, 
    118                     src_u, src_stride_u, 
    119                     src_v, src_stride_v, 
    120                     dst_y, dst_stride_y, 
    121                     dst_u, dst_stride_u, 
    122                     dst_v, dst_stride_v, 
    123                     width, height, 
    124                     dst_uv_width, dst_uv_height); 
     112  return I420ToI4xx(src_y, src_stride_y, src_u, src_stride_u, src_v, 
     113                    src_stride_v, dst_y, dst_stride_y, dst_u, dst_stride_u, 
     114                    dst_v, dst_stride_v, width, height, dst_uv_width, 
     115                    dst_uv_height); 
    125116} 
    126117 
    127118// Copy to I400. Source can be I420,422,444,400,NV12,NV21 
    128119LIBYUV_API 
    129 int I400Copy(const uint8* src_y, int src_stride_y, 
    130              uint8* dst_y, int dst_stride_y, 
    131              int width, int height) { 
    132   if (!src_y || !dst_y || 
    133       width <= 0 || height == 0) { 
     120int I400Copy(const uint8* src_y, 
     121             int src_stride_y, 
     122             uint8* dst_y, 
     123             int dst_stride_y, 
     124             int width, 
     125             int height) { 
     126  if (!src_y || !dst_y || width <= 0 || height == 0) { 
    134127    return -1; 
    135128  } 
     
    145138 
    146139LIBYUV_API 
    147 int I422ToYUY2(const uint8* src_y, int src_stride_y, 
    148                const uint8* src_u, int src_stride_u, 
    149                const uint8* src_v, int src_stride_v, 
    150                uint8* dst_yuy2, int dst_stride_yuy2, 
    151                int width, int height) { 
     140int I422ToYUY2(const uint8* src_y, 
     141               int src_stride_y, 
     142               const uint8* src_u, 
     143               int src_stride_u, 
     144               const uint8* src_v, 
     145               int src_stride_v, 
     146               uint8* dst_yuy2, 
     147               int dst_stride_yuy2, 
     148               int width, 
     149               int height) { 
    152150  int y; 
    153151  void (*I422ToYUY2Row)(const uint8* src_y, const uint8* src_u, 
    154152                        const uint8* src_v, uint8* dst_yuy2, int width) = 
    155153      I422ToYUY2Row_C; 
    156   if (!src_y || !src_u || !src_v || !dst_yuy2 || 
    157       width <= 0 || height == 0) { 
     154  if (!src_y || !src_u || !src_v || !dst_yuy2 || width <= 0 || height == 0) { 
    158155    return -1; 
    159156  } 
     
    165162  } 
    166163  // Coalesce rows. 
    167   if (src_stride_y == width && 
    168       src_stride_u * 2 == width && 
    169       src_stride_v * 2 == width && 
    170       dst_stride_yuy2 == width * 2) { 
     164  if (src_stride_y == width && src_stride_u * 2 == width && 
     165      src_stride_v * 2 == width && dst_stride_yuy2 == width * 2) { 
    171166    width *= height; 
    172167    height = 1; 
     
    201196 
    202197LIBYUV_API 
    203 int I420ToYUY2(const uint8* src_y, int src_stride_y, 
    204                const uint8* src_u, int src_stride_u, 
    205                const uint8* src_v, int src_stride_v, 
    206                uint8* dst_yuy2, int dst_stride_yuy2, 
    207                int width, int height) { 
     198int I420ToYUY2(const uint8* src_y, 
     199               int src_stride_y, 
     200               const uint8* src_u, 
     201               int src_stride_u, 
     202               const uint8* src_v, 
     203               int src_stride_v, 
     204               uint8* dst_yuy2, 
     205               int dst_stride_yuy2, 
     206               int width, 
     207               int height) { 
    208208  int y; 
    209209  void (*I422ToYUY2Row)(const uint8* src_y, const uint8* src_u, 
    210210                        const uint8* src_v, uint8* dst_yuy2, int width) = 
    211211      I422ToYUY2Row_C; 
    212   if (!src_y || !src_u || !src_v || !dst_yuy2 || 
    213       width <= 0 || height == 0) { 
     212  if (!src_y || !src_u || !src_v || !dst_yuy2 || width <= 0 || height == 0) { 
    214213    return -1; 
    215214  } 
     
    233232    if (IS_ALIGNED(width, 16)) { 
    234233      I422ToYUY2Row = I422ToYUY2Row_NEON; 
     234    } 
     235  } 
     236#endif 
     237#if defined(HAS_I422TOYUY2ROW_MSA) 
     238  if (TestCpuFlag(kCpuHasMSA)) { 
     239    I422ToYUY2Row = I422ToYUY2Row_Any_MSA; 
     240    if (IS_ALIGNED(width, 32)) { 
     241      I422ToYUY2Row = I422ToYUY2Row_MSA; 
    235242    } 
    236243  } 
     
    253260 
    254261LIBYUV_API 
    255 int I422ToUYVY(const uint8* src_y, int src_stride_y, 
    256                const uint8* src_u, int src_stride_u, 
    257                const uint8* src_v, int src_stride_v, 
    258                uint8* dst_uyvy, int dst_stride_uyvy, 
    259                int width, int height) { 
     262int I422ToUYVY(const uint8* src_y, 
     263               int src_stride_y, 
     264               const uint8* src_u, 
     265               int src_stride_u, 
     266               const uint8* src_v, 
     267               int src_stride_v, 
     268               uint8* dst_uyvy, 
     269               int dst_stride_uyvy, 
     270               int width, 
     271               int height) { 
    260272  int y; 
    261273  void (*I422ToUYVYRow)(const uint8* src_y, const uint8* src_u, 
    262274                        const uint8* src_v, uint8* dst_uyvy, int width) = 
    263275      I422ToUYVYRow_C; 
    264   if (!src_y || !src_u || !src_v || !dst_uyvy || 
    265       width <= 0 || height == 0) { 
     276  if (!src_y || !src_u || !src_v || !dst_uyvy || width <= 0 || height == 0) { 
    266277    return -1; 
    267278  } 
     
    273284  } 
    274285  // Coalesce rows. 
    275   if (src_stride_y == width && 
    276       src_stride_u * 2 == width && 
    277       src_stride_v * 2 == width && 
    278       dst_stride_uyvy == width * 2) { 
     286  if (src_stride_y == width && src_stride_u * 2 == width && 
     287      src_stride_v * 2 == width && dst_stride_uyvy == width * 2) { 
    279288    width *= height; 
    280289    height = 1; 
     
    294303    if (IS_ALIGNED(width, 16)) { 
    295304      I422ToUYVYRow = I422ToUYVYRow_NEON; 
     305    } 
     306  } 
     307#endif 
     308#if defined(HAS_I422TOUYVYROW_MSA) 
     309  if (TestCpuFlag(kCpuHasMSA)) { 
     310    I422ToUYVYRow = I422ToUYVYRow_Any_MSA; 
     311    if (IS_ALIGNED(width, 32)) { 
     312      I422ToUYVYRow = I422ToUYVYRow_MSA; 
    296313    } 
    297314  } 
     
    309326 
    310327LIBYUV_API 
    311 int I420ToUYVY(const uint8* src_y, int src_stride_y, 
    312                const uint8* src_u, int src_stride_u, 
    313                const uint8* src_v, int src_stride_v, 
    314                uint8* dst_uyvy, int dst_stride_uyvy, 
    315                int width, int height) { 
     328int I420ToUYVY(const uint8* src_y, 
     329               int src_stride_y, 
     330               const uint8* src_u, 
     331               int src_stride_u, 
     332               const uint8* src_v, 
     333               int src_stride_v, 
     334               uint8* dst_uyvy, 
     335               int dst_stride_uyvy, 
     336               int width, 
     337               int height) { 
    316338  int y; 
    317339  void (*I422ToUYVYRow)(const uint8* src_y, const uint8* src_u, 
    318340                        const uint8* src_v, uint8* dst_uyvy, int width) = 
    319341      I422ToUYVYRow_C; 
    320   if (!src_y || !src_u || !src_v || !dst_uyvy || 
    321       width <= 0 || height == 0) { 
     342  if (!src_y || !src_u || !src_v || !dst_uyvy || width <= 0 || height == 0) { 
    322343    return -1; 
    323344  } 
     
    341362    if (IS_ALIGNED(width, 16)) { 
    342363      I422ToUYVYRow = I422ToUYVYRow_NEON; 
     364    } 
     365  } 
     366#endif 
     367#if defined(HAS_I422TOUYVYROW_MSA) 
     368  if (TestCpuFlag(kCpuHasMSA)) { 
     369    I422ToUYVYRow = I422ToUYVYRow_Any_MSA; 
     370    if (IS_ALIGNED(width, 32)) { 
     371      I422ToUYVYRow = I422ToUYVYRow_MSA; 
    343372    } 
    344373  } 
     
    360389} 
    361390 
    362 LIBYUV_API 
    363 int I420ToNV12(const uint8* src_y, int src_stride_y, 
    364                const uint8* src_u, int src_stride_u, 
    365                const uint8* src_v, int src_stride_v, 
    366                uint8* dst_y, int dst_stride_y, 
    367                uint8* dst_uv, int dst_stride_uv, 
    368                int width, int height) { 
     391// TODO(fbarchard): test negative height for invert. 
     392LIBYUV_API 
     393int I420ToNV12(const uint8* src_y, 
     394               int src_stride_y, 
     395               const uint8* src_u, 
     396               int src_stride_u, 
     397               const uint8* src_v, 
     398               int src_stride_v, 
     399               uint8* dst_y, 
     400               int dst_stride_y, 
     401               uint8* dst_uv, 
     402               int dst_stride_uv, 
     403               int width, 
     404               int height) { 
     405  if (!src_y || !src_u || !src_v || !dst_y || !dst_uv || width <= 0 || 
     406      height == 0) { 
     407    return -1; 
     408  } 
     409  int halfwidth = (width + 1) / 2; 
     410  int halfheight = height > 0 ? (height + 1) / 2 : (height - 1) / 2; 
     411  if (dst_y) { 
     412    CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); 
     413  } 
     414  MergeUVPlane(src_u, src_stride_u, src_v, src_stride_v, dst_uv, dst_stride_uv, 
     415               halfwidth, halfheight); 
     416  return 0; 
     417} 
     418 
     419LIBYUV_API 
     420int I420ToNV21(const uint8* src_y, 
     421               int src_stride_y, 
     422               const uint8* src_u, 
     423               int src_stride_u, 
     424               const uint8* src_v, 
     425               int src_stride_v, 
     426               uint8* dst_y, 
     427               int dst_stride_y, 
     428               uint8* dst_vu, 
     429               int dst_stride_vu, 
     430               int width, 
     431               int height) { 
     432  return I420ToNV12(src_y, src_stride_y, src_v, src_stride_v, src_u, 
     433                    src_stride_u, dst_y, dst_stride_y, dst_vu, dst_stride_vu, 
     434                    width, height); 
     435} 
     436 
     437// Convert I422 to RGBA with matrix 
     438static int I420ToRGBAMatrix(const uint8* src_y, 
     439                            int src_stride_y, 
     440                            const uint8* src_u, 
     441                            int src_stride_u, 
     442                            const uint8* src_v, 
     443                            int src_stride_v, 
     444                            uint8* dst_rgba, 
     445                            int dst_stride_rgba, 
     446                            const struct YuvConstants* yuvconstants, 
     447                            int width, 
     448                            int height) { 
    369449  int y; 
    370   void (*MergeUVRow_)(const uint8* src_u, const uint8* src_v, uint8* dst_uv, 
    371       int width) = MergeUVRow_C; 
    372   // Coalesce rows. 
    373   int halfwidth = (width + 1) >> 1; 
    374   int halfheight = (height + 1) >> 1; 
    375   if (!src_y || !src_u || !src_v || !dst_y || !dst_uv || 
    376       width <= 0 || height == 0) { 
    377     return -1; 
    378   } 
    379   // Negative height means invert the image. 
    380   if (height < 0) { 
    381     height = -height; 
    382     halfheight = (height + 1) >> 1; 
    383     dst_y = dst_y + (height - 1) * dst_stride_y; 
    384     dst_uv = dst_uv + (halfheight - 1) * dst_stride_uv; 
    385     dst_stride_y = -dst_stride_y; 
    386     dst_stride_uv = -dst_stride_uv; 
    387   } 
    388   if (src_stride_y == width && 
    389       dst_stride_y == width) { 
    390     width *= height; 
    391     height = 1; 
    392     src_stride_y = dst_stride_y = 0; 
    393   } 
    394   // Coalesce rows. 
    395   if (src_stride_u == halfwidth && 
    396       src_stride_v == halfwidth && 
    397       dst_stride_uv == halfwidth * 2) { 
    398     halfwidth *= halfheight; 
    399     halfheight = 1; 
    400     src_stride_u = src_stride_v = dst_stride_uv = 0; 
    401   } 
    402 #if defined(HAS_MERGEUVROW_SSE2) 
    403   if (TestCpuFlag(kCpuHasSSE2)) { 
    404     MergeUVRow_ = MergeUVRow_Any_SSE2; 
    405     if (IS_ALIGNED(halfwidth, 16)) { 
    406       MergeUVRow_ = MergeUVRow_SSE2; 
    407     } 
    408   } 
    409 #endif 
    410 #if defined(HAS_MERGEUVROW_AVX2) 
    411   if (TestCpuFlag(kCpuHasAVX2)) { 
    412     MergeUVRow_ = MergeUVRow_Any_AVX2; 
    413     if (IS_ALIGNED(halfwidth, 32)) { 
    414       MergeUVRow_ = MergeUVRow_AVX2; 
    415     } 
    416   } 
    417 #endif 
    418 #if defined(HAS_MERGEUVROW_NEON) 
    419   if (TestCpuFlag(kCpuHasNEON)) { 
    420     MergeUVRow_ = MergeUVRow_Any_NEON; 
    421     if (IS_ALIGNED(halfwidth, 16)) { 
    422       MergeUVRow_ = MergeUVRow_NEON; 
    423     } 
    424   } 
    425 #endif 
    426  
    427   CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); 
    428   for (y = 0; y < halfheight; ++y) { 
    429     // Merge a row of U and V into a row of UV. 
    430     MergeUVRow_(src_u, src_v, dst_uv, halfwidth); 
    431     src_u += src_stride_u; 
    432     src_v += src_stride_v; 
    433     dst_uv += dst_stride_uv; 
    434   } 
    435   return 0; 
    436 } 
    437  
    438 LIBYUV_API 
    439 int I420ToNV21(const uint8* src_y, int src_stride_y, 
    440                const uint8* src_u, int src_stride_u, 
    441                const uint8* src_v, int src_stride_v, 
    442                uint8* dst_y, int dst_stride_y, 
    443                uint8* dst_vu, int dst_stride_vu, 
    444                int width, int height) { 
    445   return I420ToNV12(src_y, src_stride_y, 
    446                     src_v, src_stride_v, 
    447                     src_u, src_stride_u, 
    448                     dst_y, dst_stride_y, 
    449                     dst_vu, dst_stride_vu, 
    450                     width, height); 
    451 } 
    452  
    453 // Convert I422 to RGBA with matrix 
    454 static int I420ToRGBAMatrix(const uint8* src_y, int src_stride_y, 
    455                             const uint8* src_u, int src_stride_u, 
    456                             const uint8* src_v, int src_stride_v, 
    457                             uint8* dst_rgba, int dst_stride_rgba, 
    458                             const struct YuvConstants* yuvconstants, 
    459                             int width, int height) { 
    460   int y; 
    461   void (*I422ToRGBARow)(const uint8* y_buf, 
    462                         const uint8* u_buf, 
    463                         const uint8* v_buf, 
    464                         uint8* rgb_buf, 
    465                         const struct YuvConstants* yuvconstants, 
    466                         int width) = I422ToRGBARow_C; 
    467   if (!src_y || !src_u || !src_v || !dst_rgba || 
    468       width <= 0 || height == 0) { 
     450  void (*I422ToRGBARow)(const uint8* y_buf, const uint8* u_buf, 
     451                        const uint8* v_buf, uint8* rgb_buf, 
     452                        const struct YuvConstants* yuvconstants, int width) = 
     453      I422ToRGBARow_C; 
     454  if (!src_y || !src_u || !src_v || !dst_rgba || width <= 0 || height == 0) { 
    469455    return -1; 
    470456  } 
     
    508494  } 
    509495#endif 
     496#if defined(HAS_I422TORGBAROW_MSA) 
     497  if (TestCpuFlag(kCpuHasMSA)) { 
     498    I422ToRGBARow = I422ToRGBARow_Any_MSA; 
     499    if (IS_ALIGNED(width, 8)) { 
     500      I422ToRGBARow = I422ToRGBARow_MSA; 
     501    } 
     502  } 
     503#endif 
    510504 
    511505  for (y = 0; y < height; ++y) { 
     
    523517// Convert I420 to RGBA. 
    524518LIBYUV_API 
    525 int I420ToRGBA(const uint8* src_y, int src_stride_y, 
    526                const uint8* src_u, int src_stride_u, 
    527                const uint8* src_v, int src_stride_v, 
    528                uint8* dst_rgba, int dst_stride_rgba, 
    529                int width, int height) { 
    530   return I420ToRGBAMatrix(src_y, src_stride_y, 
    531                           src_u, src_stride_u, 
    532                           src_v, src_stride_v, 
    533                           dst_rgba, dst_stride_rgba, 
    534                           &kYuvI601Constants, 
    535                           width, height); 
     519int I420ToRGBA(const uint8* src_y, 
     520               int src_stride_y, 
     521               const uint8* src_u, 
     522               int src_stride_u, 
     523               const uint8* src_v, 
     524               int src_stride_v, 
     525               uint8* dst_rgba, 
     526               int dst_stride_rgba, 
     527               int width, 
     528               int height) { 
     529  return I420ToRGBAMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, 
     530                          src_stride_v, dst_rgba, dst_stride_rgba, 
     531                          &kYuvI601Constants, width, height); 
    536532} 
    537533 
    538534// Convert I420 to BGRA. 
    539535LIBYUV_API 
    540 int I420ToBGRA(const uint8* src_y, int src_stride_y, 
    541                const uint8* src_u, int src_stride_u, 
    542                const uint8* src_v, int src_stride_v, 
    543                uint8* dst_bgra, int dst_stride_bgra, 
    544                int width, int height) { 
    545   return I420ToRGBAMatrix(src_y, src_stride_y, 
    546                           src_v, src_stride_v,  // Swap U and V 
    547                           src_u, src_stride_u, 
    548                           dst_bgra, dst_stride_bgra, 
     536int I420ToBGRA(const uint8* src_y, 
     537               int src_stride_y, 
     538               const uint8* src_u, 
     539               int src_stride_u, 
     540               const uint8* src_v, 
     541               int src_stride_v, 
     542               uint8* dst_bgra, 
     543               int dst_stride_bgra, 
     544               int width, 
     545               int height) { 
     546  return I420ToRGBAMatrix(src_y, src_stride_y, src_v, 
     547                          src_stride_v,  // Swap U and V 
     548                          src_u, src_stride_u, dst_bgra, dst_stride_bgra, 
    549549                          &kYvuI601Constants,  // Use Yvu matrix 
    550550                          width, height); 
     
    552552 
    553553// Convert I420 to RGB24 with matrix 
    554 static int I420ToRGB24Matrix(const uint8* src_y, int src_stride_y, 
    555                              const uint8* src_u, int src_stride_u, 
    556                              const uint8* src_v, int src_stride_v, 
    557                              uint8* dst_rgb24, int dst_stride_rgb24, 
     554static int I420ToRGB24Matrix(const uint8* src_y, 
     555                             int src_stride_y, 
     556                             const uint8* src_u, 
     557                             int src_stride_u, 
     558                             const uint8* src_v, 
     559                             int src_stride_v, 
     560                             uint8* dst_rgb24, 
     561                             int dst_stride_rgb24, 
    558562                             const struct YuvConstants* yuvconstants, 
    559                              int width, int height) { 
     563                             int width, 
     564                             int height) { 
    560565  int y; 
    561   void (*I422ToRGB24Row)(const uint8* y_buf, 
    562                          const uint8* u_buf, 
    563                          const uint8* v_buf, 
    564                          uint8* rgb_buf, 
    565                          const struct YuvConstants* yuvconstants, 
    566                          int width) = I422ToRGB24Row_C; 
    567   if (!src_y || !src_u || !src_v || !dst_rgb24 || 
    568       width <= 0 || height == 0) { 
     566  void (*I422ToRGB24Row)(const uint8* y_buf, const uint8* u_buf, 
     567                         const uint8* v_buf, uint8* rgb_buf, 
     568                         const struct YuvConstants* yuvconstants, int width) = 
     569      I422ToRGB24Row_C; 
     570  if (!src_y || !src_u || !src_v || !dst_rgb24 || width <= 0 || height == 0) { 
    569571    return -1; 
    570572  } 
     
    596598    if (IS_ALIGNED(width, 8)) { 
    597599      I422ToRGB24Row = I422ToRGB24Row_NEON; 
     600    } 
     601  } 
     602#endif 
     603#if defined(HAS_I422TORGB24ROW_MSA) 
     604  if (TestCpuFlag(kCpuHasMSA)) { 
     605    I422ToRGB24Row = I422ToRGB24Row_Any_MSA; 
     606    if (IS_ALIGNED(width, 16)) { 
     607      I422ToRGB24Row = I422ToRGB24Row_MSA; 
    598608    } 
    599609  } 
     
    614624// Convert I420 to RGB24. 
    615625LIBYUV_API 
    616 int I420ToRGB24(const uint8* src_y, int src_stride_y, 
    617                 const uint8* src_u, int src_stride_u, 
    618                 const uint8* src_v, int src_stride_v, 
    619                 uint8* dst_rgb24, int dst_stride_rgb24, 
    620                 int width, int height) { 
    621   return I420ToRGB24Matrix(src_y, src_stride_y, 
    622                            src_u, src_stride_u, 
    623                            src_v, src_stride_v, 
    624                            dst_rgb24, dst_stride_rgb24, 
    625                            &kYuvI601Constants, 
    626                            width, height); 
     626int I420ToRGB24(const uint8* src_y, 
     627                int src_stride_y, 
     628                const uint8* src_u, 
     629                int src_stride_u, 
     630                const uint8* src_v, 
     631                int src_stride_v, 
     632                uint8* dst_rgb24, 
     633                int dst_stride_rgb24, 
     634                int width, 
     635                int height) { 
     636  return I420ToRGB24Matrix(src_y, src_stride_y, src_u, src_stride_u, src_v, 
     637                           src_stride_v, dst_rgb24, dst_stride_rgb24, 
     638                           &kYuvI601Constants, width, height); 
    627639} 
    628640 
    629641// Convert I420 to RAW. 
    630642LIBYUV_API 
    631 int I420ToRAW(const uint8* src_y, int src_stride_y, 
    632               const uint8* src_u, int src_stride_u, 
    633               const uint8* src_v, int src_stride_v, 
    634               uint8* dst_raw, int dst_stride_raw, 
    635               int width, int height) { 
    636   return I420ToRGB24Matrix(src_y, src_stride_y, 
    637                            src_v, src_stride_v,  // Swap U and V 
    638                            src_u, src_stride_u, 
    639                            dst_raw, dst_stride_raw, 
     643int I420ToRAW(const uint8* src_y, 
     644              int src_stride_y, 
     645              const uint8* src_u, 
     646              int src_stride_u, 
     647              const uint8* src_v, 
     648              int src_stride_v, 
     649              uint8* dst_raw, 
     650              int dst_stride_raw, 
     651              int width, 
     652              int height) { 
     653  return I420ToRGB24Matrix(src_y, src_stride_y, src_v, 
     654                           src_stride_v,  // Swap U and V 
     655                           src_u, src_stride_u, dst_raw, dst_stride_raw, 
    640656                           &kYvuI601Constants,  // Use Yvu matrix 
    641657                           width, height); 
     
    644660// Convert I420 to ARGB1555. 
    645661LIBYUV_API 
    646 int I420ToARGB1555(const uint8* src_y, int src_stride_y, 
    647                    const uint8* src_u, int src_stride_u, 
    648                    const uint8* src_v, int src_stride_v, 
    649                    uint8* dst_argb1555, int dst_stride_argb1555, 
    650                    int width, int height) { 
     662int I420ToARGB1555(const uint8* src_y, 
     663                   int src_stride_y, 
     664                   const uint8* src_u, 
     665                   int src_stride_u, 
     666                   const uint8* src_v, 
     667                   int src_stride_v, 
     668                   uint8* dst_argb1555, 
     669                   int dst_stride_argb1555, 
     670                   int width, 
     671                   int height) { 
    651672  int y; 
    652   void (*I422ToARGB1555Row)(const uint8* y_buf, 
    653                             const uint8* u_buf, 
    654                             const uint8* v_buf, 
    655                             uint8* rgb_buf, 
     673  void (*I422ToARGB1555Row)(const uint8* y_buf, const uint8* u_buf, 
     674                            const uint8* v_buf, uint8* rgb_buf, 
    656675                            const struct YuvConstants* yuvconstants, 
    657676                            int width) = I422ToARGB1555Row_C; 
    658   if (!src_y || !src_u || !src_v || !dst_argb1555 || 
    659       width <= 0 || height == 0) { 
     677  if (!src_y || !src_u || !src_v || !dst_argb1555 || width <= 0 || 
     678      height == 0) { 
    660679    return -1; 
    661680  } 
     
    687706    if (IS_ALIGNED(width, 8)) { 
    688707      I422ToARGB1555Row = I422ToARGB1555Row_NEON; 
     708    } 
     709  } 
     710#endif 
     711#if defined(HAS_I422TOARGB1555ROW_DSPR2) 
     712  if (TestCpuFlag(kCpuHasDSPR2)) { 
     713    I422ToARGB1555Row = I422ToARGB1555Row_Any_DSPR2; 
     714    if (IS_ALIGNED(width, 4)) { 
     715      I422ToARGB1555Row = I422ToARGB1555Row_DSPR2; 
     716    } 
     717  } 
     718#endif 
     719#if defined(HAS_I422TOARGB1555ROW_MSA) 
     720  if (TestCpuFlag(kCpuHasMSA)) { 
     721    I422ToARGB1555Row = I422ToARGB1555Row_Any_MSA; 
     722    if (IS_ALIGNED(width, 8)) { 
     723      I422ToARGB1555Row = I422ToARGB1555Row_MSA; 
    689724    } 
    690725  } 
     
    704739} 
    705740 
    706  
    707741// Convert I420 to ARGB4444. 
    708742LIBYUV_API 
    709 int I420ToARGB4444(const uint8* src_y, int src_stride_y, 
    710                    const uint8* src_u, int src_stride_u, 
    711                    const uint8* src_v, int src_stride_v, 
    712                    uint8* dst_argb4444, int dst_stride_argb4444, 
    713                    int width, int height) { 
     743int I420ToARGB4444(const uint8* src_y, 
     744                   int src_stride_y, 
     745                   const uint8* src_u, 
     746                   int src_stride_u, 
     747                   const uint8* src_v, 
     748                   int src_stride_v, 
     749                   uint8* dst_argb4444, 
     750                   int dst_stride_argb4444, 
     751                   int width, 
     752                   int height) { 
    714753  int y; 
    715   void (*I422ToARGB4444Row)(const uint8* y_buf, 
    716                             const uint8* u_buf, 
    717                             const uint8* v_buf, 
    718                             uint8* rgb_buf, 
     754  void (*I422ToARGB4444Row)(const uint8* y_buf, const uint8* u_buf, 
     755                            const uint8* v_buf, uint8* rgb_buf, 
    719756                            const struct YuvConstants* yuvconstants, 
    720757                            int width) = I422ToARGB4444Row_C; 
    721   if (!src_y || !src_u || !src_v || !dst_argb4444 || 
    722       width <= 0 || height == 0) { 
     758  if (!src_y || !src_u || !src_v || !dst_argb4444 || width <= 0 || 
     759      height == 0) { 
    723760    return -1; 
    724761  } 
     
    750787    if (IS_ALIGNED(width, 8)) { 
    751788      I422ToARGB4444Row = I422ToARGB4444Row_NEON; 
     789    } 
     790  } 
     791#endif 
     792#if defined(HAS_I422TOARGB4444ROW_DSPR2) 
     793  if (TestCpuFlag(kCpuHasDSPR2)) { 
     794    I422ToARGB4444Row = I422ToARGB4444Row_Any_DSPR2; 
     795    if (IS_ALIGNED(width, 4)) { 
     796      I422ToARGB4444Row = I422ToARGB4444Row_DSPR2; 
     797    } 
     798  } 
     799#endif 
     800#if defined(HAS_I422TOARGB4444ROW_MSA) 
     801  if (TestCpuFlag(kCpuHasMSA)) { 
     802    I422ToARGB4444Row = I422ToARGB4444Row_Any_MSA; 
     803    if (IS_ALIGNED(width, 8)) { 
     804      I422ToARGB4444Row = I422ToARGB4444Row_MSA; 
    752805    } 
    753806  } 
     
    769822// Convert I420 to RGB565. 
    770823LIBYUV_API 
    771 int I420ToRGB565(const uint8* src_y, int src_stride_y, 
    772                  const uint8* src_u, int src_stride_u, 
    773                  const uint8* src_v, int src_stride_v, 
    774                  uint8* dst_rgb565, int dst_stride_rgb565, 
    775                  int width, int height) { 
     824int I420ToRGB565(const uint8* src_y, 
     825                 int src_stride_y, 
     826                 const uint8* src_u, 
     827                 int src_stride_u, 
     828                 const uint8* src_v, 
     829                 int src_stride_v, 
     830                 uint8* dst_rgb565, 
     831                 int dst_stride_rgb565, 
     832                 int width, 
     833                 int height) { 
    776834  int y; 
    777   void (*I422ToRGB565Row)(const uint8* y_buf, 
    778                           const uint8* u_buf, 
    779                           const uint8* v_buf, 
    780                           uint8* rgb_buf, 
    781                           const struct YuvConstants* yuvconstants, 
    782                           int width) = I422ToRGB565Row_C; 
    783   if (!src_y || !src_u || !src_v || !dst_rgb565 || 
    784       width <= 0 || height == 0) { 
     835  void (*I422ToRGB565Row)(const uint8* y_buf, const uint8* u_buf, 
     836                          const uint8* v_buf, uint8* rgb_buf, 
     837                          const struct YuvConstants* yuvconstants, int width) = 
     838      I422ToRGB565Row_C; 
     839  if (!src_y || !src_u || !src_v || !dst_rgb565 || width <= 0 || height == 0) { 
    785840    return -1; 
    786841  } 
     
    812867    if (IS_ALIGNED(width, 8)) { 
    813868      I422ToRGB565Row = I422ToRGB565Row_NEON; 
     869    } 
     870  } 
     871#endif 
     872#if defined(HAS_I422TORGB565ROW_MSA) 
     873  if (TestCpuFlag(kCpuHasMSA)) { 
     874    I422ToRGB565Row = I422ToRGB565Row_Any_MSA; 
     875    if (IS_ALIGNED(width, 8)) { 
     876      I422ToRGB565Row = I422ToRGB565Row_MSA; 
    814877    } 
    815878  } 
     
    828891} 
    829892 
     893// Convert I422 to RGB565. 
     894LIBYUV_API 
     895int I422ToRGB565(const uint8* src_y, 
     896                 int src_stride_y, 
     897                 const uint8* src_u, 
     898                 int src_stride_u, 
     899                 const uint8* src_v, 
     900                 int src_stride_v, 
     901                 uint8* dst_rgb565, 
     902                 int dst_stride_rgb565, 
     903                 int width, 
     904                 int height) { 
     905  int y; 
     906  void (*I422ToRGB565Row)(const uint8* y_buf, const uint8* u_buf, 
     907                          const uint8* v_buf, uint8* rgb_buf, 
     908                          const struct YuvConstants* yuvconstants, int width) = 
     909      I422ToRGB565Row_C; 
     910  if (!src_y || !src_u || !src_v || !dst_rgb565 || width <= 0 || height == 0) { 
     911    return -1; 
     912  } 
     913  // Negative height means invert the image. 
     914  if (height < 0) { 
     915    height = -height; 
     916    dst_rgb565 = dst_rgb565 + (height - 1) * dst_stride_rgb565; 
     917    dst_stride_rgb565 = -dst_stride_rgb565; 
     918  } 
     919#if defined(HAS_I422TORGB565ROW_SSSE3) 
     920  if (TestCpuFlag(kCpuHasSSSE3)) { 
     921    I422ToRGB565Row = I422ToRGB565Row_Any_SSSE3; 
     922    if (IS_ALIGNED(width, 8)) { 
     923      I422ToRGB565Row = I422ToRGB565Row_SSSE3; 
     924    } 
     925  } 
     926#endif 
     927#if defined(HAS_I422TORGB565ROW_AVX2) 
     928  if (TestCpuFlag(kCpuHasAVX2)) { 
     929    I422ToRGB565Row = I422ToRGB565Row_Any_AVX2; 
     930    if (IS_ALIGNED(width, 16)) { 
     931      I422ToRGB565Row = I422ToRGB565Row_AVX2; 
     932    } 
     933  } 
     934#endif 
     935#if defined(HAS_I422TORGB565ROW_NEON) 
     936  if (TestCpuFlag(kCpuHasNEON)) { 
     937    I422ToRGB565Row = I422ToRGB565Row_Any_NEON; 
     938    if (IS_ALIGNED(width, 8)) { 
     939      I422ToRGB565Row = I422ToRGB565Row_NEON; 
     940    } 
     941  } 
     942#endif 
     943#if defined(HAS_I422TORGB565ROW_MSA) 
     944  if (TestCpuFlag(kCpuHasMSA)) { 
     945    I422ToRGB565Row = I422ToRGB565Row_Any_MSA; 
     946    if (IS_ALIGNED(width, 8)) { 
     947      I422ToRGB565Row = I422ToRGB565Row_MSA; 
     948    } 
     949  } 
     950#endif 
     951 
     952  for (y = 0; y < height; ++y) { 
     953    I422ToRGB565Row(src_y, src_u, src_v, dst_rgb565, &kYuvI601Constants, width); 
     954    dst_rgb565 += dst_stride_rgb565; 
     955    src_y += src_stride_y; 
     956    src_u += src_stride_u; 
     957    src_v += src_stride_v; 
     958  } 
     959  return 0; 
     960} 
     961 
    830962// Ordered 8x8 dither for 888 to 565.  Values from 0 to 7. 
    831963static const uint8 kDither565_4x4[16] = { 
    832   0, 4, 1, 5, 
    833   6, 2, 7, 3, 
    834   1, 5, 0, 4, 
    835   7, 3, 6, 2, 
     964    0, 4, 1, 5, 6, 2, 7, 3, 1, 5, 0, 4, 7, 3, 6, 2, 
    836965}; 
    837966 
    838967// Convert I420 to RGB565 with dithering. 
    839968LIBYUV_API 
    840 int I420ToRGB565Dither(const uint8* src_y, int src_stride_y, 
    841                        const uint8* src_u, int src_stride_u, 
    842                        const uint8* src_v, int src_stride_v, 
    843                        uint8* dst_rgb565, int dst_stride_rgb565, 
    844                        const uint8* dither4x4, int width, int height) { 
     969int I420ToRGB565Dither(const uint8* src_y, 
     970                       int src_stride_y, 
     971                       const uint8* src_u, 
     972                       int src_stride_u, 
     973                       const uint8* src_v, 
     974                       int src_stride_v, 
     975                       uint8* dst_rgb565, 
     976                       int dst_stride_rgb565, 
     977                       const uint8* dither4x4, 
     978                       int width, 
     979                       int height) { 
    845980  int y; 
    846   void (*I422ToARGBRow)(const uint8* y_buf, 
    847                         const uint8* u_buf, 
    848                         const uint8* v_buf, 
    849                         uint8* rgb_buf, 
    850                         const struct YuvConstants* yuvconstants, 
    851                         int width) = I422ToARGBRow_C; 
     981  void (*I422ToARGBRow)(const uint8* y_buf, const uint8* u_buf, 
     982                        const uint8* v_buf, uint8* rgb_buf, 
     983                        const struct YuvConstants* yuvconstants, int width) = 
     984      I422ToARGBRow_C; 
    852985  void (*ARGBToRGB565DitherRow)(const uint8* src_argb, uint8* dst_rgb, 
    853       const uint32 dither4, int width) = ARGBToRGB565DitherRow_C; 
    854   if (!src_y || !src_u || !src_v || !dst_rgb565 || 
    855       width <= 0 || height == 0) { 
     986                                const uint32 dither4, int width) = 
     987      ARGBToRGB565DitherRow_C; 
     988  if (!src_y || !src_u || !src_v || !dst_rgb565 || width <= 0 || height == 0) { 
    856989    return -1; 
    857990  } 
     
    8971030  } 
    8981031#endif 
     1032#if defined(HAS_I422TOARGBROW_MSA) 
     1033  if (TestCpuFlag(kCpuHasMSA)) { 
     1034    I422ToARGBRow = I422ToARGBRow_Any_MSA; 
     1035    if (IS_ALIGNED(width, 8)) { 
     1036      I422ToARGBRow = I422ToARGBRow_MSA; 
     1037    } 
     1038  } 
     1039#endif 
    8991040#if defined(HAS_ARGBTORGB565DITHERROW_SSE2) 
    9001041  if (TestCpuFlag(kCpuHasSSE2)) { 
     
    9181059    if (IS_ALIGNED(width, 8)) { 
    9191060      ARGBToRGB565DitherRow = ARGBToRGB565DitherRow_NEON; 
     1061    } 
     1062  } 
     1063#endif 
     1064#if defined(HAS_ARGBTORGB565DITHERROW_MSA) 
     1065  if (TestCpuFlag(kCpuHasMSA)) { 
     1066    ARGBToRGB565DitherRow = ARGBToRGB565DitherRow_Any_MSA; 
     1067    if (IS_ALIGNED(width, 8)) { 
     1068      ARGBToRGB565DitherRow = ARGBToRGB565DitherRow_MSA; 
    9201069    } 
    9211070  } 
     
    9271076      I422ToARGBRow(src_y, src_u, src_v, row_argb, &kYuvI601Constants, width); 
    9281077      ARGBToRGB565DitherRow(row_argb, dst_rgb565, 
    929                             *(uint32*)(dither4x4 + ((y & 3) << 2)), width); 
     1078                            *(uint32*)(dither4x4 + ((y & 3) << 2)), 
     1079                            width);  // NOLINT 
    9301080      dst_rgb565 += dst_stride_rgb565; 
    9311081      src_y += src_stride_y; 
     
    9421092// Convert I420 to specified format 
    9431093LIBYUV_API 
    944 int ConvertFromI420(const uint8* y, int y_stride, 
    945                     const uint8* u, int u_stride, 
    946                     const uint8* v, int v_stride, 
    947                     uint8* dst_sample, int dst_sample_stride, 
    948                     int width, int height, 
     1094int ConvertFromI420(const uint8* y, 
     1095                    int y_stride, 
     1096                    const uint8* u, 
     1097                    int u_stride, 
     1098                    const uint8* v, 
     1099                    int v_stride, 
     1100                    uint8* dst_sample, 
     1101                    int dst_sample_stride, 
     1102                    int width, 
     1103                    int height, 
    9491104                    uint32 fourcc) { 
    9501105  uint32 format = CanonicalFourCC(fourcc); 
    9511106  int r = 0; 
    952   if (!y || !u|| !v || !dst_sample || 
    953       width <= 0 || height == 0) { 
     1107  if (!y || !u || !v || !dst_sample || width <= 0 || height == 0) { 
    9541108    return -1; 
    9551109  } 
     
    9571111    // Single plane formats 
    9581112    case FOURCC_YUY2: 
    959       r = I420ToYUY2(y, y_stride, 
    960                      u, u_stride, 
    961                      v, v_stride, 
    962                      dst_sample, 
    963                      dst_sample_stride ? dst_sample_stride : width * 2, 
    964                      width, height); 
     1113      r = I420ToYUY2(y, y_stride, u, u_stride, v, v_stride, dst_sample, 
     1114                     dst_sample_stride ? dst_sample_stride : width * 2, width, 
     1115                     height); 
    9651116      break; 
    9661117    case FOURCC_UYVY: 
    967       r = I420ToUYVY(y, y_stride, 
    968                      u, u_stride, 
    969                      v, v_stride, 
    970                      dst_sample, 
    971                      dst_sample_stride ? dst_sample_stride : width * 2, 
    972                      width, height); 
     1118      r = I420ToUYVY(y, y_stride, u, u_stride, v, v_stride, dst_sample, 
     1119                     dst_sample_stride ? dst_sample_stride : width * 2, width, 
     1120                     height); 
    9731121      break; 
    9741122    case FOURCC_RGBP: 
    975       r = I420ToRGB565(y, y_stride, 
    976                        u, u_stride, 
    977                        v, v_stride, 
    978                        dst_sample, 
    979                        dst_sample_stride ? dst_sample_stride : width * 2, 
    980                        width, height); 
     1123      r = I420ToRGB565(y, y_stride, u, u_stride, v, v_stride, dst_sample, 
     1124                       dst_sample_stride ? dst_sample_stride : width * 2, width, 
     1125                       height); 
    9811126      break; 
    9821127    case FOURCC_RGBO: 
    983       r = I420ToARGB1555(y, y_stride, 
    984                          u, u_stride, 
    985                          v, v_stride, 
    986                          dst_sample, 
     1128      r = I420ToARGB1555(y, y_stride, u, u_stride, v, v_stride, dst_sample, 
    9871129                         dst_sample_stride ? dst_sample_stride : width * 2, 
    9881130                         width, height); 
    9891131      break; 
    9901132    case FOURCC_R444: 
    991       r = I420ToARGB4444(y, y_stride, 
    992                          u, u_stride, 
    993                          v, v_stride, 
    994                          dst_sample, 
     1133      r = I420ToARGB4444(y, y_stride, u, u_stride, v, v_stride, dst_sample, 
    9951134                         dst_sample_stride ? dst_sample_stride : width * 2, 
    9961135                         width, height); 
    9971136      break; 
    9981137    case FOURCC_24BG: 
    999       r = I420ToRGB24(y, y_stride, 
    1000                       u, u_stride, 
    1001                       v, v_stride, 
    1002                       dst_sample, 
    1003                       dst_sample_stride ? dst_sample_stride : width * 3, 
    1004                       width, height); 
     1138      r = I420ToRGB24(y, y_stride, u, u_stride, v, v_stride, dst_sample, 
     1139                      dst_sample_stride ? dst_sample_stride : width * 3, width, 
     1140                      height); 
    10051141      break; 
    10061142    case FOURCC_RAW: 
    1007       r = I420ToRAW(y, y_stride, 
    1008                     u, u_stride, 
    1009                     v, v_stride, 
    1010                     dst_sample, 
    1011                     dst_sample_stride ? dst_sample_stride : width * 3, 
    1012                     width, height); 
     1143      r = I420ToRAW(y, y_stride, u, u_stride, v, v_stride, dst_sample, 
     1144                    dst_sample_stride ? dst_sample_stride : width * 3, width, 
     1145                    height); 
    10131146      break; 
    10141147    case FOURCC_ARGB: 
    1015       r = I420ToARGB(y, y_stride, 
    1016                      u, u_stride, 
    1017                      v, v_stride, 
    1018                      dst_sample, 
    1019                      dst_sample_stride ? dst_sample_stride : width * 4, 
    1020                      width, height); 
     1148      r = I420ToARGB(y, y_stride, u, u_stride, v, v_stride, dst_sample, 
     1149                     dst_sample_stride ? dst_sample_stride : width * 4, width, 
     1150                     height); 
    10211151      break; 
    10221152    case FOURCC_BGRA: 
    1023       r = I420ToBGRA(y, y_stride, 
    1024                      u, u_stride, 
    1025                      v, v_stride, 
    1026                      dst_sample, 
    1027                      dst_sample_stride ? dst_sample_stride : width * 4, 
    1028                      width, height); 
     1153      r = I420ToBGRA(y, y_stride, u, u_stride, v, v_stride, dst_sample, 
     1154                     dst_sample_stride ? dst_sample_stride : width * 4, width, 
     1155                     height); 
    10291156      break; 
    10301157    case FOURCC_ABGR: 
    1031       r = I420ToABGR(y, y_stride, 
    1032                      u, u_stride, 
    1033                      v, v_stride, 
    1034                      dst_sample, 
    1035                      dst_sample_stride ? dst_sample_stride : width * 4, 
    1036                      width, height); 
     1158      r = I420ToABGR(y, y_stride, u, u_stride, v, v_stride, dst_sample, 
     1159                     dst_sample_stride ? dst_sample_stride : width * 4, width, 
     1160                     height); 
    10371161      break; 
    10381162    case FOURCC_RGBA: 
    1039       r = I420ToRGBA(y, y_stride, 
    1040                      u, u_stride, 
    1041                      v, v_stride, 
    1042                      dst_sample, 
    1043                      dst_sample_stride ? dst_sample_stride : width * 4, 
    1044                      width, height); 
     1163      r = I420ToRGBA(y, y_stride, u, u_stride, v, v_stride, dst_sample, 
     1164                     dst_sample_stride ? dst_sample_stride : width * 4, width, 
     1165                     height); 
    10451166      break; 
    10461167    case FOURCC_I400: 
    1047       r = I400Copy(y, y_stride, 
    1048                    dst_sample, 
    1049                    dst_sample_stride ? dst_sample_stride : width, 
    1050                    width, height); 
     1168      r = I400Copy(y, y_stride, dst_sample, 
     1169                   dst_sample_stride ? dst_sample_stride : width, width, 
     1170                   height); 
    10511171      break; 
    10521172    case FOURCC_NV12: { 
    10531173      uint8* dst_uv = dst_sample + width * height; 
    1054       r = I420ToNV12(y, y_stride, 
    1055                      u, u_stride, 
    1056                      v, v_stride, 
    1057                      dst_sample, 
    1058                      dst_sample_stride ? dst_sample_stride : width, 
    1059                      dst_uv, 
    1060                      dst_sample_stride ? dst_sample_stride : width, 
    1061                      width, height); 
     1174      r = I420ToNV12(y, y_stride, u, u_stride, v, v_stride, dst_sample, 
     1175                     dst_sample_stride ? dst_sample_stride : width, dst_uv, 
     1176                     dst_sample_stride ? dst_sample_stride : width, width, 
     1177                     height); 
    10621178      break; 
    10631179    } 
    10641180    case FOURCC_NV21: { 
    10651181      uint8* dst_vu = dst_sample + width * height; 
    1066       r = I420ToNV21(y, y_stride, 
    1067                      u, u_stride, 
    1068                      v, v_stride, 
    1069                      dst_sample, 
    1070                      dst_sample_stride ? dst_sample_stride : width, 
    1071                      dst_vu, 
    1072                      dst_sample_stride ? dst_sample_stride : width, 
    1073                      width, height); 
     1182      r = I420ToNV21(y, y_stride, u, u_stride, v, v_stride, dst_sample, 
     1183                     dst_sample_stride ? dst_sample_stride : width, dst_vu, 
     1184                     dst_sample_stride ? dst_sample_stride : width, width, 
     1185                     height); 
    10741186      break; 
    10751187    } 
    10761188    // TODO(fbarchard): Add M420. 
    10771189    // Triplanar formats 
    1078     // TODO(fbarchard): halfstride instead of halfwidth 
    10791190    case FOURCC_I420: 
    10801191    case FOURCC_YV12: { 
    1081       int halfwidth = (width + 1) / 2; 
     1192      dst_sample_stride = dst_sample_stride ? dst_sample_stride : width; 
     1193      int halfstride = (dst_sample_stride + 1) / 2; 
    10821194      int halfheight = (height + 1) / 2; 
    10831195      uint8* dst_u; 
    10841196      uint8* dst_v; 
    10851197      if (format == FOURCC_YV12) { 
    1086         dst_v = dst_sample + width * height; 
    1087         dst_u = dst_v + halfwidth * halfheight; 
     1198        dst_v = dst_sample + dst_sample_stride * height; 
     1199        dst_u = dst_v + halfstride * halfheight; 
    10881200      } else { 
    1089         dst_u = dst_sample + width * height; 
    1090         dst_v = dst_u + halfwidth * halfheight; 
     1201        dst_u = dst_sample + dst_sample_stride * height; 
     1202        dst_v = dst_u + halfstride * halfheight; 
    10911203      } 
    1092       r = I420Copy(y, y_stride, 
    1093                    u, u_stride, 
    1094                    v, v_stride, 
    1095                    dst_sample, width, 
    1096                    dst_u, halfwidth, 
    1097                    dst_v, halfwidth, 
     1204      r = I420Copy(y, y_stride, u, u_stride, v, v_stride, dst_sample, 
     1205                   dst_sample_stride, dst_u, halfstride, dst_v, halfstride, 
    10981206                   width, height); 
    10991207      break; 
     
    11011209    case FOURCC_I422: 
    11021210    case FOURCC_YV16: { 
    1103       int halfwidth = (width + 1) / 2; 
     1211      dst_sample_stride = dst_sample_stride ? dst_sample_stride : width; 
     1212      int halfstride = (dst_sample_stride + 1) / 2; 
    11041213      uint8* dst_u; 
    11051214      uint8* dst_v; 
    11061215      if (format == FOURCC_YV16) { 
    1107         dst_v = dst_sample + width * height; 
    1108         dst_u = dst_v + halfwidth * height; 
     1216        dst_v = dst_sample + dst_sample_stride * height; 
     1217        dst_u = dst_v + halfstride * height; 
    11091218      } else { 
    1110         dst_u = dst_sample + width * height; 
    1111         dst_v = dst_u + halfwidth * height; 
     1219        dst_u = dst_sample + dst_sample_stride * height; 
     1220        dst_v = dst_u + halfstride * height; 
    11121221      } 
    1113       r = I420ToI422(y, y_stride, 
    1114                      u, u_stride, 
    1115                      v, v_stride, 
    1116                      dst_sample, width, 
    1117                      dst_u, halfwidth, 
    1118                      dst_v, halfwidth, 
     1222      r = I420ToI422(y, y_stride, u, u_stride, v, v_stride, dst_sample, 
     1223                     dst_sample_stride, dst_u, halfstride, dst_v, halfstride, 
    11191224                     width, height); 
    11201225      break; 
     
    11221227    case FOURCC_I444: 
    11231228    case FOURCC_YV24: { 
     1229      dst_sample_stride = dst_sample_stride ? dst_sample_stride : width; 
    11241230      uint8* dst_u; 
    11251231      uint8* dst_v; 
    11261232      if (format == FOURCC_YV24) { 
    1127         dst_v = dst_sample + width * height; 
    1128         dst_u = dst_v + width * height; 
     1233        dst_v = dst_sample + dst_sample_stride * height; 
     1234        dst_u = dst_v + dst_sample_stride * height; 
    11291235      } else { 
    1130         dst_u = dst_sample + width * height; 
    1131         dst_v = dst_u + width * height; 
     1236        dst_u = dst_sample + dst_sample_stride * height; 
     1237        dst_v = dst_u + dst_sample_stride * height; 
    11321238      } 
    1133       r = I420ToI444(y, y_stride, 
    1134                      u, u_stride, 
    1135                      v, v_stride, 
    1136                      dst_sample, width, 
    1137                      dst_u, width, 
    1138                      dst_v, width, 
    1139                      width, height); 
    1140       break; 
    1141     } 
    1142     case FOURCC_I411: { 
    1143       int quarterwidth = (width + 3) / 4; 
    1144       uint8* dst_u = dst_sample + width * height; 
    1145       uint8* dst_v = dst_u + quarterwidth * height; 
    1146       r = I420ToI411(y, y_stride, 
    1147                      u, u_stride, 
    1148                      v, v_stride, 
    1149                      dst_sample, width, 
    1150                      dst_u, quarterwidth, 
    1151                      dst_v, quarterwidth, 
    1152                      width, height); 
    1153       break; 
    1154     } 
    1155  
     1239      r = I420ToI444(y, y_stride, u, u_stride, v, v_stride, dst_sample, 
     1240                     dst_sample_stride, dst_u, dst_sample_stride, dst_v, 
     1241                     dst_sample_stride, width, height); 
     1242      break; 
     1243    } 
    11561244    // Formats not supported - MJPG, biplanar, some rgb formats. 
    11571245    default: 
Note: See TracChangeset for help on using the changeset viewer.