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

    r5358 r5633  
    4141  return (v + m) ^ m; 
    4242} 
    43 #else  // USE_BRANCHLESS 
     43#else   // USE_BRANCHLESS 
    4444static __inline int32 clamp0(int32 v) { 
    4545  return (v < 0) ? 0 : v; 
     
    130130} 
    131131 
    132 void ARGB1555ToARGBRow_C(const uint8* src_argb1555, uint8* dst_argb, 
     132void ARGB1555ToARGBRow_C(const uint8* src_argb1555, 
     133                         uint8* dst_argb, 
    133134                         int width) { 
    134135  int x; 
     
    147148} 
    148149 
    149 void ARGB4444ToARGBRow_C(const uint8* src_argb4444, uint8* dst_argb, 
     150void ARGB4444ToARGBRow_C(const uint8* src_argb4444, 
     151                         uint8* dst_argb, 
    150152                         int width) { 
    151153  int x; 
     
    201203    uint8 g1 = src_argb[5] >> 2; 
    202204    uint8 r1 = src_argb[6] >> 3; 
    203     WRITEWORD(dst_rgb, b0 | (g0 << 5) | (r0 << 11) | 
    204               (b1 << 16) | (g1 << 21) | (r1 << 27)); 
     205    WRITEWORD(dst_rgb, b0 | (g0 << 5) | (r0 << 11) | (b1 << 16) | (g1 << 21) | 
     206                          (r1 << 27)); 
    205207    dst_rgb += 4; 
    206208    src_argb += 8; 
     
    222224// will containing the first pixel in the lower byte for little endian 
    223225// or the upper byte for big endian. 
    224 void ARGBToRGB565DitherRow_C(const uint8* src_argb, uint8* dst_rgb, 
    225                              const uint32 dither4, int width) { 
     226void ARGBToRGB565DitherRow_C(const uint8* src_argb, 
     227                             uint8* dst_rgb, 
     228                             const uint32 dither4, 
     229                             int width) { 
    226230  int x; 
    227231  for (x = 0; x < width - 1; x += 2) { 
     
    234238    uint8 g1 = clamp255(src_argb[5] + dither1) >> 2; 
    235239    uint8 r1 = clamp255(src_argb[6] + dither1) >> 3; 
    236     WRITEWORD(dst_rgb, b0 | (g0 << 5) | (r0 << 11) | 
    237               (b1 << 16) | (g1 << 21) | (r1 << 27)); 
     240    WRITEWORD(dst_rgb, b0 | (g0 << 5) | (r0 << 11) | (b1 << 16) | (g1 << 21) | 
     241                          (r1 << 27)); 
    238242    dst_rgb += 4; 
    239243    src_argb += 8; 
     
    259263    uint8 r1 = src_argb[6] >> 3; 
    260264    uint8 a1 = src_argb[7] >> 7; 
    261     *(uint32*)(dst_rgb) = 
    262         b0 | (g0 << 5) | (r0 << 10) | (a0 << 15) | 
    263         (b1 << 16) | (g1 << 21) | (r1 << 26) | (a1 << 31); 
     265    *(uint32*)(dst_rgb) = b0 | (g0 << 5) | (r0 << 10) | (a0 << 15) | 
     266                          (b1 << 16) | (g1 << 21) | (r1 << 26) | (a1 << 31); 
    264267    dst_rgb += 4; 
    265268    src_argb += 8; 
     
    270273    uint8 r0 = src_argb[2] >> 3; 
    271274    uint8 a0 = src_argb[3] >> 7; 
    272     *(uint16*)(dst_rgb) = 
    273         b0 | (g0 << 5) | (r0 << 10) | (a0 << 15); 
     275    *(uint16*)(dst_rgb) = b0 | (g0 << 5) | (r0 << 10) | (a0 << 15); 
    274276  } 
    275277} 
     
    286288    uint8 r1 = src_argb[6] >> 4; 
    287289    uint8 a1 = src_argb[7] >> 4; 
    288     *(uint32*)(dst_rgb) = 
    289         b0 | (g0 << 4) | (r0 << 8) | (a0 << 12) | 
    290         (b1 << 16) | (g1 << 20) | (r1 << 24) | (a1 << 28); 
     290    *(uint32*)(dst_rgb) = b0 | (g0 << 4) | (r0 << 8) | (a0 << 12) | (b1 << 16) | 
     291                          (g1 << 20) | (r1 << 24) | (a1 << 28); 
    291292    dst_rgb += 4; 
    292293    src_argb += 8; 
     
    297298    uint8 r0 = src_argb[2] >> 4; 
    298299    uint8 a0 = src_argb[3] >> 4; 
    299     *(uint16*)(dst_rgb) = 
    300         b0 | (g0 << 4) | (r0 << 8) | (a0 << 12); 
     300    *(uint16*)(dst_rgb) = b0 | (g0 << 4) | (r0 << 8) | (a0 << 12); 
    301301  } 
    302302} 
    303303 
    304304static __inline int RGBToY(uint8 r, uint8 g, uint8 b) { 
    305   return (66 * r + 129 * g +  25 * b + 0x1080) >> 8; 
     305  return (66 * r + 129 * g + 25 * b + 0x1080) >> 8; 
    306306} 
    307307 
     
    313313} 
    314314 
    315 #define MAKEROWY(NAME, R, G, B, BPP) \ 
    316 void NAME ## ToYRow_C(const uint8* src_argb0, uint8* dst_y, int width) {       \ 
    317   int x;                                                                       \ 
    318   for (x = 0; x < width; ++x) {                                                \ 
    319     dst_y[0] = RGBToY(src_argb0[R], src_argb0[G], src_argb0[B]);               \ 
    320     src_argb0 += BPP;                                                          \ 
    321     dst_y += 1;                                                                \ 
    322   }                                                                            \ 
    323 }                                                                              \ 
    324 void NAME ## ToUVRow_C(const uint8* src_rgb0, int src_stride_rgb,              \ 
    325                        uint8* dst_u, uint8* dst_v, int width) {                \ 
    326   const uint8* src_rgb1 = src_rgb0 + src_stride_rgb;                           \ 
    327   int x;                                                                       \ 
    328   for (x = 0; x < width - 1; x += 2) {                                         \ 
    329     uint8 ab = (src_rgb0[B] + src_rgb0[B + BPP] +                              \ 
    330                src_rgb1[B] + src_rgb1[B + BPP]) >> 2;                          \ 
    331     uint8 ag = (src_rgb0[G] + src_rgb0[G + BPP] +                              \ 
    332                src_rgb1[G] + src_rgb1[G + BPP]) >> 2;                          \ 
    333     uint8 ar = (src_rgb0[R] + src_rgb0[R + BPP] +                              \ 
    334                src_rgb1[R] + src_rgb1[R + BPP]) >> 2;                          \ 
    335     dst_u[0] = RGBToU(ar, ag, ab);                                             \ 
    336     dst_v[0] = RGBToV(ar, ag, ab);                                             \ 
    337     src_rgb0 += BPP * 2;                                                       \ 
    338     src_rgb1 += BPP * 2;                                                       \ 
    339     dst_u += 1;                                                                \ 
    340     dst_v += 1;                                                                \ 
    341   }                                                                            \ 
    342   if (width & 1) {                                                             \ 
    343     uint8 ab = (src_rgb0[B] + src_rgb1[B]) >> 1;                               \ 
    344     uint8 ag = (src_rgb0[G] + src_rgb1[G]) >> 1;                               \ 
    345     uint8 ar = (src_rgb0[R] + src_rgb1[R]) >> 1;                               \ 
    346     dst_u[0] = RGBToU(ar, ag, ab);                                             \ 
    347     dst_v[0] = RGBToV(ar, ag, ab);                                             \ 
    348   }                                                                            \ 
    349 } 
     315// ARGBToY_C and ARGBToUV_C 
     316#define MAKEROWY(NAME, R, G, B, BPP)                                     \ 
     317  void NAME##ToYRow_C(const uint8* src_argb0, uint8* dst_y, int width) { \ 
     318    int x;                                                               \ 
     319    for (x = 0; x < width; ++x) {                                        \ 
     320      dst_y[0] = RGBToY(src_argb0[R], src_argb0[G], src_argb0[B]);       \ 
     321      src_argb0 += BPP;                                                  \ 
     322      dst_y += 1;                                                        \ 
     323    }                                                                    \ 
     324  }                                                                      \ 
     325  void NAME##ToUVRow_C(const uint8* src_rgb0, int src_stride_rgb,        \ 
     326                       uint8* dst_u, uint8* dst_v, int width) {          \ 
     327    const uint8* src_rgb1 = src_rgb0 + src_stride_rgb;                   \ 
     328    int x;                                                               \ 
     329    for (x = 0; x < width - 1; x += 2) {                                 \ 
     330      uint8 ab = (src_rgb0[B] + src_rgb0[B + BPP] + src_rgb1[B] +        \ 
     331                  src_rgb1[B + BPP]) >>                                  \ 
     332                 2;                                                      \ 
     333      uint8 ag = (src_rgb0[G] + src_rgb0[G + BPP] + src_rgb1[G] +        \ 
     334                  src_rgb1[G + BPP]) >>                                  \ 
     335                 2;                                                      \ 
     336      uint8 ar = (src_rgb0[R] + src_rgb0[R + BPP] + src_rgb1[R] +        \ 
     337                  src_rgb1[R + BPP]) >>                                  \ 
     338                 2;                                                      \ 
     339      dst_u[0] = RGBToU(ar, ag, ab);                                     \ 
     340      dst_v[0] = RGBToV(ar, ag, ab);                                     \ 
     341      src_rgb0 += BPP * 2;                                               \ 
     342      src_rgb1 += BPP * 2;                                               \ 
     343      dst_u += 1;                                                        \ 
     344      dst_v += 1;                                                        \ 
     345    }                                                                    \ 
     346    if (width & 1) {                                                     \ 
     347      uint8 ab = (src_rgb0[B] + src_rgb1[B]) >> 1;                       \ 
     348      uint8 ag = (src_rgb0[G] + src_rgb1[G]) >> 1;                       \ 
     349      uint8 ar = (src_rgb0[R] + src_rgb1[R]) >> 1;                       \ 
     350      dst_u[0] = RGBToU(ar, ag, ab);                                     \ 
     351      dst_v[0] = RGBToV(ar, ag, ab);                                     \ 
     352    }                                                                    \ 
     353  } 
    350354 
    351355MAKEROWY(ARGB, 2, 1, 0, 4) 
     
    383387 
    384388static __inline int RGBToYJ(uint8 r, uint8 g, uint8 b) { 
    385   return (38 * r + 75 * g +  15 * b + 64) >> 7; 
     389  return (38 * r + 75 * g + 15 * b + 64) >> 7; 
    386390} 
    387391 
     
    395399#define AVGB(a, b) (((a) + (b) + 1) >> 1) 
    396400 
    397 #define MAKEROWYJ(NAME, R, G, B, BPP) \ 
    398 void NAME ## ToYJRow_C(const uint8* src_argb0, uint8* dst_y, int width) {      \ 
    399   int x;                                                                       \ 
    400   for (x = 0; x < width; ++x) {                                                \ 
    401     dst_y[0] = RGBToYJ(src_argb0[R], src_argb0[G], src_argb0[B]);              \ 
    402     src_argb0 += BPP;                                                          \ 
    403     dst_y += 1;                                                                \ 
    404   }                                                                            \ 
    405 }                                                                              \ 
    406 void NAME ## ToUVJRow_C(const uint8* src_rgb0, int src_stride_rgb,             \ 
    407                         uint8* dst_u, uint8* dst_v, int width) {               \ 
    408   const uint8* src_rgb1 = src_rgb0 + src_stride_rgb;                           \ 
    409   int x;                                                                       \ 
    410   for (x = 0; x < width - 1; x += 2) {                                         \ 
    411     uint8 ab = AVGB(AVGB(src_rgb0[B], src_rgb1[B]),                            \ 
    412                     AVGB(src_rgb0[B + BPP], src_rgb1[B + BPP]));               \ 
    413     uint8 ag = AVGB(AVGB(src_rgb0[G], src_rgb1[G]),                            \ 
    414                     AVGB(src_rgb0[G + BPP], src_rgb1[G + BPP]));               \ 
    415     uint8 ar = AVGB(AVGB(src_rgb0[R], src_rgb1[R]),                            \ 
    416                     AVGB(src_rgb0[R + BPP], src_rgb1[R + BPP]));               \ 
    417     dst_u[0] = RGBToUJ(ar, ag, ab);                                            \ 
    418     dst_v[0] = RGBToVJ(ar, ag, ab);                                            \ 
    419     src_rgb0 += BPP * 2;                                                       \ 
    420     src_rgb1 += BPP * 2;                                                       \ 
    421     dst_u += 1;                                                                \ 
    422     dst_v += 1;                                                                \ 
    423   }                                                                            \ 
    424   if (width & 1) {                                                             \ 
    425     uint8 ab = AVGB(src_rgb0[B], src_rgb1[B]);                                 \ 
    426     uint8 ag = AVGB(src_rgb0[G], src_rgb1[G]);                                 \ 
    427     uint8 ar = AVGB(src_rgb0[R], src_rgb1[R]);                                 \ 
    428     dst_u[0] = RGBToUJ(ar, ag, ab);                                            \ 
    429     dst_v[0] = RGBToVJ(ar, ag, ab);                                            \ 
    430   }                                                                            \ 
    431 } 
     401// ARGBToYJ_C and ARGBToUVJ_C 
     402#define MAKEROWYJ(NAME, R, G, B, BPP)                                     \ 
     403  void NAME##ToYJRow_C(const uint8* src_argb0, uint8* dst_y, int width) { \ 
     404    int x;                                                                \ 
     405    for (x = 0; x < width; ++x) {                                         \ 
     406      dst_y[0] = RGBToYJ(src_argb0[R], src_argb0[G], src_argb0[B]);       \ 
     407      src_argb0 += BPP;                                                   \ 
     408      dst_y += 1;                                                         \ 
     409    }                                                                     \ 
     410  }                                                                       \ 
     411  void NAME##ToUVJRow_C(const uint8* src_rgb0, int src_stride_rgb,        \ 
     412                        uint8* dst_u, uint8* dst_v, int width) {          \ 
     413    const uint8* src_rgb1 = src_rgb0 + src_stride_rgb;                    \ 
     414    int x;                                                                \ 
     415    for (x = 0; x < width - 1; x += 2) {                                  \ 
     416      uint8 ab = AVGB(AVGB(src_rgb0[B], src_rgb1[B]),                     \ 
     417                      AVGB(src_rgb0[B + BPP], src_rgb1[B + BPP]));        \ 
     418      uint8 ag = AVGB(AVGB(src_rgb0[G], src_rgb1[G]),                     \ 
     419                      AVGB(src_rgb0[G + BPP], src_rgb1[G + BPP]));        \ 
     420      uint8 ar = AVGB(AVGB(src_rgb0[R], src_rgb1[R]),                     \ 
     421                      AVGB(src_rgb0[R + BPP], src_rgb1[R + BPP]));        \ 
     422      dst_u[0] = RGBToUJ(ar, ag, ab);                                     \ 
     423      dst_v[0] = RGBToVJ(ar, ag, ab);                                     \ 
     424      src_rgb0 += BPP * 2;                                                \ 
     425      src_rgb1 += BPP * 2;                                                \ 
     426      dst_u += 1;                                                         \ 
     427      dst_v += 1;                                                         \ 
     428    }                                                                     \ 
     429    if (width & 1) {                                                      \ 
     430      uint8 ab = AVGB(src_rgb0[B], src_rgb1[B]);                          \ 
     431      uint8 ag = AVGB(src_rgb0[G], src_rgb1[G]);                          \ 
     432      uint8 ar = AVGB(src_rgb0[R], src_rgb1[R]);                          \ 
     433      dst_u[0] = RGBToUJ(ar, ag, ab);                                     \ 
     434      dst_v[0] = RGBToVJ(ar, ag, ab);                                     \ 
     435    }                                                                     \ 
     436  } 
    432437 
    433438MAKEROWYJ(ARGB, 2, 1, 0, 4) 
     
    479484} 
    480485 
    481 void RGB565ToUVRow_C(const uint8* src_rgb565, int src_stride_rgb565, 
    482                      uint8* dst_u, uint8* dst_v, int width) { 
     486void RGB565ToUVRow_C(const uint8* src_rgb565, 
     487                     int src_stride_rgb565, 
     488                     uint8* dst_u, 
     489                     uint8* dst_v, 
     490                     int width) { 
    483491  const uint8* next_rgb565 = src_rgb565 + src_stride_rgb565; 
    484492  int x; 
     
    526534} 
    527535 
    528 void ARGB1555ToUVRow_C(const uint8* src_argb1555, int src_stride_argb1555, 
    529                        uint8* dst_u, uint8* dst_v, int width) { 
     536void ARGB1555ToUVRow_C(const uint8* src_argb1555, 
     537                       int src_stride_argb1555, 
     538                       uint8* dst_u, 
     539                       uint8* dst_v, 
     540                       int width) { 
    530541  const uint8* next_argb1555 = src_argb1555 + src_stride_argb1555; 
    531542  int x; 
     
    574585} 
    575586 
    576 void ARGB4444ToUVRow_C(const uint8* src_argb4444, int src_stride_argb4444, 
    577                        uint8* dst_u, uint8* dst_v, int width) { 
     587void ARGB4444ToUVRow_C(const uint8* src_argb4444, 
     588                       int src_stride_argb4444, 
     589                       uint8* dst_u, 
     590                       uint8* dst_v, 
     591                       int width) { 
    578592  const uint8* next_argb4444 = src_argb4444 + src_stride_argb4444; 
    579593  int x; 
     
    623637 
    624638void ARGBToUV444Row_C(const uint8* src_argb, 
    625                       uint8* dst_u, uint8* dst_v, int width) { 
     639                      uint8* dst_u, 
     640                      uint8* dst_v, 
     641                      int width) { 
    626642  int x; 
    627643  for (x = 0; x < width; ++x) { 
     
    634650    dst_u += 1; 
    635651    dst_v += 1; 
    636   } 
    637 } 
    638  
    639 void ARGBToUV411Row_C(const uint8* src_argb, 
    640                       uint8* dst_u, uint8* dst_v, int width) { 
    641   int x; 
    642   for (x = 0; x < width - 3; x += 4) { 
    643     uint8 ab = (src_argb[0] + src_argb[4] + src_argb[8] + src_argb[12]) >> 2; 
    644     uint8 ag = (src_argb[1] + src_argb[5] + src_argb[9] + src_argb[13]) >> 2; 
    645     uint8 ar = (src_argb[2] + src_argb[6] + src_argb[10] + src_argb[14]) >> 2; 
    646     dst_u[0] = RGBToU(ar, ag, ab); 
    647     dst_v[0] = RGBToV(ar, ag, ab); 
    648     src_argb += 16; 
    649     dst_u += 1; 
    650     dst_v += 1; 
    651   } 
    652   // Odd width handling mimics 'any' function which replicates last pixel. 
    653   if ((width & 3) == 3) { 
    654     uint8 ab = (src_argb[0] + src_argb[4] + src_argb[8] + src_argb[8]) >> 2; 
    655     uint8 ag = (src_argb[1] + src_argb[5] + src_argb[9] + src_argb[9]) >> 2; 
    656     uint8 ar = (src_argb[2] + src_argb[6] + src_argb[10] + src_argb[10]) >> 2; 
    657     dst_u[0] = RGBToU(ar, ag, ab); 
    658     dst_v[0] = RGBToV(ar, ag, ab); 
    659   } else if ((width & 3) == 2) { 
    660     uint8 ab = (src_argb[0] + src_argb[4]) >> 1; 
    661     uint8 ag = (src_argb[1] + src_argb[5]) >> 1; 
    662     uint8 ar = (src_argb[2] + src_argb[6]) >> 1; 
    663     dst_u[0] = RGBToU(ar, ag, ab); 
    664     dst_v[0] = RGBToV(ar, ag, ab); 
    665   } else if ((width & 3) == 1) { 
    666     uint8 ab = src_argb[0]; 
    667     uint8 ag = src_argb[1]; 
    668     uint8 ar = src_argb[2]; 
    669     dst_u[0] = RGBToU(ar, ag, ab); 
    670     dst_v[0] = RGBToV(ar, ag, ab); 
    671652  } 
    672653} 
     
    703684// Apply color matrix to a row of image. Matrix is signed. 
    704685// TODO(fbarchard): Consider adding rounding (+32). 
    705 void ARGBColorMatrixRow_C(const uint8* src_argb, uint8* dst_argb, 
    706                           const int8* matrix_argb, int width) { 
     686void ARGBColorMatrixRow_C(const uint8* src_argb, 
     687                          uint8* dst_argb, 
     688                          const int8* matrix_argb, 
     689                          int width) { 
    707690  int x; 
    708691  for (x = 0; x < width; ++x) { 
     
    711694    int r = src_argb[2]; 
    712695    int a = src_argb[3]; 
    713     int sb = (b * matrix_argb[0] + g * matrix_argb[1] + 
    714               r * matrix_argb[2] + a * matrix_argb[3]) >> 6; 
    715     int sg = (b * matrix_argb[4] + g * matrix_argb[5] + 
    716               r * matrix_argb[6] + a * matrix_argb[7]) >> 6; 
    717     int sr = (b * matrix_argb[8] + g * matrix_argb[9] + 
    718               r * matrix_argb[10] + a * matrix_argb[11]) >> 6; 
    719     int sa = (b * matrix_argb[12] + g * matrix_argb[13] + 
    720               r * matrix_argb[14] + a * matrix_argb[15]) >> 6; 
     696    int sb = (b * matrix_argb[0] + g * matrix_argb[1] + r * matrix_argb[2] + 
     697              a * matrix_argb[3]) >> 
     698             6; 
     699    int sg = (b * matrix_argb[4] + g * matrix_argb[5] + r * matrix_argb[6] + 
     700              a * matrix_argb[7]) >> 
     701             6; 
     702    int sr = (b * matrix_argb[8] + g * matrix_argb[9] + r * matrix_argb[10] + 
     703              a * matrix_argb[11]) >> 
     704             6; 
     705    int sa = (b * matrix_argb[12] + g * matrix_argb[13] + r * matrix_argb[14] + 
     706              a * matrix_argb[15]) >> 
     707             6; 
    721708    dst_argb[0] = Clamp(sb); 
    722709    dst_argb[1] = Clamp(sg); 
     
    758745} 
    759746 
    760 void ARGBQuantizeRow_C(uint8* dst_argb, int scale, int interval_size, 
    761                        int interval_offset, int width) { 
     747void ARGBQuantizeRow_C(uint8* dst_argb, 
     748                       int scale, 
     749                       int interval_size, 
     750                       int interval_offset, 
     751                       int width) { 
    762752  int x; 
    763753  for (x = 0; x < width; ++x) { 
     
    773763 
    774764#define REPEAT8(v) (v) | ((v) << 8) 
    775 #define SHADE(f, v) v * f >> 24 
    776  
    777 void ARGBShadeRow_C(const uint8* src_argb, uint8* dst_argb, int width, 
     765#define SHADE(f, v) v* f >> 24 
     766 
     767void ARGBShadeRow_C(const uint8* src_argb, 
     768                    uint8* dst_argb, 
     769                    int width, 
    778770                    uint32 value) { 
    779771  const uint32 b_scale = REPEAT8(value & 0xff); 
     
    800792 
    801793#define REPEAT8(v) (v) | ((v) << 8) 
    802 #define SHADE(f, v) v * f >> 16 
    803  
    804 void ARGBMultiplyRow_C(const uint8* src_argb0, const uint8* src_argb1, 
    805                        uint8* dst_argb, int width) { 
     794#define SHADE(f, v) v* f >> 16 
     795 
     796void ARGBMultiplyRow_C(const uint8* src_argb0, 
     797                       const uint8* src_argb1, 
     798                       uint8* dst_argb, 
     799                       int width) { 
    806800  int i; 
    807801  for (i = 0; i < width; ++i) { 
     
    828822#define SHADE(f, v) clamp255(v + f) 
    829823 
    830 void ARGBAddRow_C(const uint8* src_argb0, const uint8* src_argb1, 
    831                   uint8* dst_argb, int width) { 
     824void ARGBAddRow_C(const uint8* src_argb0, 
     825                  const uint8* src_argb1, 
     826                  uint8* dst_argb, 
     827                  int width) { 
    832828  int i; 
    833829  for (i = 0; i < width; ++i) { 
     
    853849#define SHADE(f, v) clamp0(f - v) 
    854850 
    855 void ARGBSubtractRow_C(const uint8* src_argb0, const uint8* src_argb1, 
    856                        uint8* dst_argb, int width) { 
     851void ARGBSubtractRow_C(const uint8* src_argb0, 
     852                       const uint8* src_argb1, 
     853                       uint8* dst_argb, 
     854                       int width) { 
    857855  int i; 
    858856  for (i = 0; i < width; ++i) { 
     
    877875 
    878876// Sobel functions which mimics SSSE3. 
    879 void SobelXRow_C(const uint8* src_y0, const uint8* src_y1, const uint8* src_y2, 
    880                  uint8* dst_sobelx, int width) { 
     877void SobelXRow_C(const uint8* src_y0, 
     878                 const uint8* src_y1, 
     879                 const uint8* src_y2, 
     880                 uint8* dst_sobelx, 
     881                 int width) { 
    881882  int i; 
    882883  for (i = 0; i < width; ++i) { 
     
    895896} 
    896897 
    897 void SobelYRow_C(const uint8* src_y0, const uint8* src_y1, 
    898                  uint8* dst_sobely, int width) { 
     898void SobelYRow_C(const uint8* src_y0, 
     899                 const uint8* src_y1, 
     900                 uint8* dst_sobely, 
     901                 int width) { 
    899902  int i; 
    900903  for (i = 0; i < width; ++i) { 
     
    913916} 
    914917 
    915 void SobelRow_C(const uint8* src_sobelx, const uint8* src_sobely, 
    916                 uint8* dst_argb, int width) { 
     918void SobelRow_C(const uint8* src_sobelx, 
     919                const uint8* src_sobely, 
     920                uint8* dst_argb, 
     921                int width) { 
    917922  int i; 
    918923  for (i = 0; i < width; ++i) { 
     
    928933} 
    929934 
    930 void SobelToPlaneRow_C(const uint8* src_sobelx, const uint8* src_sobely, 
    931                        uint8* dst_y, int width) { 
     935void SobelToPlaneRow_C(const uint8* src_sobelx, 
     936                       const uint8* src_sobely, 
     937                       uint8* dst_y, 
     938                       int width) { 
    932939  int i; 
    933940  for (i = 0; i < width; ++i) { 
     
    939946} 
    940947 
    941 void SobelXYRow_C(const uint8* src_sobelx, const uint8* src_sobely, 
    942                   uint8* dst_argb, int width) { 
     948void SobelXYRow_C(const uint8* src_sobelx, 
     949                  const uint8* src_sobely, 
     950                  uint8* dst_argb, 
     951                  int width) { 
    943952  int i; 
    944953  for (i = 0; i < width; ++i) { 
     
    975984 
    976985// Y contribution to R,G,B.  Scale and bias. 
    977 #define YG 18997 /* round(1.164 * 64 * 256 * 256 / 257) */ 
     986#define YG 18997  /* round(1.164 * 64 * 256 * 256 / 257) */ 
    978987#define YGB -1160 /* 1.164 * 64 * -16 + 64 / 2 */ 
    979988 
    980989// U and V contributions to R,G,B. 
    981990#define UB -128 /* max(-128, round(-2.018 * 64)) */ 
    982 #define UG 25 /* round(0.391 * 64) */ 
    983 #define VG 52 /* round(0.813 * 64) */ 
     991#define UG 25   /* round(0.391 * 64) */ 
     992#define VG 52   /* round(0.813 * 64) */ 
    984993#define VR -102 /* round(-1.596 * 64) */ 
    985994 
    986995// Bias values to subtract 16 from Y and 128 from U and V. 
    987 #define BB (UB * 128            + YGB) 
     996#define BB (UB * 128 + YGB) 
    988997#define BG (UG * 128 + VG * 128 + YGB) 
    989 #define BR            (VR * 128 + YGB) 
    990  
    991 #if defined(__aarch64__) 
    992 const YuvConstants SIMD_ALIGNED(kYuvI601Constants) = { 
    993   { -UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR }, 
    994   { -UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR }, 
    995   { UG, VG, UG, VG, UG, VG, UG, VG }, 
    996   { UG, VG, UG, VG, UG, VG, UG, VG }, 
    997   { BB, BG, BR, 0, 0, 0, 0, 0 }, 
    998   { 0x0101 * YG, 0, 0, 0 } 
    999 }; 
    1000 const YuvConstants SIMD_ALIGNED(kYvuI601Constants) = { 
    1001   { -VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB }, 
    1002   { -VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB }, 
    1003   { VG, UG, VG, UG, VG, UG, VG, UG }, 
    1004   { VG, UG, VG, UG, VG, UG, VG, UG }, 
    1005   { BR, BG, BB, 0, 0, 0, 0, 0 }, 
    1006   { 0x0101 * YG, 0, 0, 0 } 
    1007 }; 
    1008 #elif defined(__arm__) 
    1009 const YuvConstants SIMD_ALIGNED(kYuvI601Constants) = { 
    1010   { -UB, -UB, -UB, -UB, -VR, -VR, -VR, -VR, 0, 0, 0, 0, 0, 0, 0, 0 }, 
    1011   { UG, UG, UG, UG, VG, VG, VG, VG, 0, 0, 0, 0, 0, 0, 0, 0 }, 
    1012   { BB, BG, BR, 0, 0, 0, 0, 0 }, 
    1013   { 0x0101 * YG, 0, 0, 0 } 
    1014 }; 
    1015 const YuvConstants SIMD_ALIGNED(kYvuI601Constants) = { 
    1016   { -VR, -VR, -VR, -VR, -UB, -UB, -UB, -UB, 0, 0, 0, 0, 0, 0, 0, 0 }, 
    1017   { VG, VG, VG, VG, UG, UG, UG, UG, 0, 0, 0, 0, 0, 0, 0, 0 }, 
    1018   { BR, BG, BB, 0, 0, 0, 0, 0 }, 
    1019   { 0x0101 * YG, 0, 0, 0 } 
    1020 }; 
     998#define BR (VR * 128 + YGB) 
     999 
     1000#if defined(__aarch64__)  // 64 bit arm 
     1001const struct YuvConstants SIMD_ALIGNED(kYuvI601Constants) = { 
     1002    {-UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR}, 
     1003    {-UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR}, 
     1004    {UG, VG, UG, VG, UG, VG, UG, VG}, 
     1005    {UG, VG, UG, VG, UG, VG, UG, VG}, 
     1006    {BB, BG, BR, 0, 0, 0, 0, 0}, 
     1007    {0x0101 * YG, 0, 0, 0}}; 
     1008const struct YuvConstants SIMD_ALIGNED(kYvuI601Constants) = { 
     1009    {-VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB}, 
     1010    {-VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB}, 
     1011    {VG, UG, VG, UG, VG, UG, VG, UG}, 
     1012    {VG, UG, VG, UG, VG, UG, VG, UG}, 
     1013    {BR, BG, BB, 0, 0, 0, 0, 0}, 
     1014    {0x0101 * YG, 0, 0, 0}}; 
     1015#elif defined(__arm__)  // 32 bit arm 
     1016const struct YuvConstants SIMD_ALIGNED(kYuvI601Constants) = { 
     1017    {-UB, -UB, -UB, -UB, -VR, -VR, -VR, -VR, 0, 0, 0, 0, 0, 0, 0, 0}, 
     1018    {UG, UG, UG, UG, VG, VG, VG, VG, 0, 0, 0, 0, 0, 0, 0, 0}, 
     1019    {BB, BG, BR, 0, 0, 0, 0, 0}, 
     1020    {0x0101 * YG, 0, 0, 0}}; 
     1021const struct YuvConstants SIMD_ALIGNED(kYvuI601Constants) = { 
     1022    {-VR, -VR, -VR, -VR, -UB, -UB, -UB, -UB, 0, 0, 0, 0, 0, 0, 0, 0}, 
     1023    {VG, VG, VG, VG, UG, UG, UG, UG, 0, 0, 0, 0, 0, 0, 0, 0}, 
     1024    {BR, BG, BB, 0, 0, 0, 0, 0}, 
     1025    {0x0101 * YG, 0, 0, 0}}; 
    10211026#else 
    1022 const YuvConstants SIMD_ALIGNED(kYuvI601Constants) = { 
    1023   { UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, 
    1024     UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0 }, 
    1025   { UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, 
    1026     UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG }, 
    1027   { 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 
    1028     0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR }, 
    1029   { BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB }, 
    1030   { BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG }, 
    1031   { BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR }, 
    1032   { YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG } 
    1033 }; 
    1034 const YuvConstants SIMD_ALIGNED(kYvuI601Constants) = { 
    1035   { VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, 
    1036     VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0 }, 
    1037   { VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, 
    1038     VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG }, 
    1039   { 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 
    1040     0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB }, 
    1041   { BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR }, 
    1042   { BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG }, 
    1043   { BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB }, 
    1044   { YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG } 
    1045 }; 
     1027const struct YuvConstants SIMD_ALIGNED(kYuvI601Constants) = { 
     1028    {UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, 
     1029     UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0}, 
     1030    {UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, 
     1031     UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG}, 
     1032    {0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 
     1033     0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR}, 
     1034    {BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB}, 
     1035    {BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG}, 
     1036    {BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR}, 
     1037    {YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG}}; 
     1038const struct YuvConstants SIMD_ALIGNED(kYvuI601Constants) = { 
     1039    {VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, 
     1040     VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0}, 
     1041    {VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, 
     1042     VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG}, 
     1043    {0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 
     1044     0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB}, 
     1045    {BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR}, 
     1046    {BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG}, 
     1047    {BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB}, 
     1048    {YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG}}; 
    10461049#endif 
    10471050 
     
    10631066// Y contribution to R,G,B.  Scale and bias. 
    10641067#define YG 16320 /* round(1.000 * 64 * 256 * 256 / 257) */ 
    1065 #define YGB 32  /* 64 / 2 */ 
     1068#define YGB 32   /* 64 / 2 */ 
    10661069 
    10671070// U and V contributions to R,G,B. 
    10681071#define UB -113 /* round(-1.77200 * 64) */ 
    1069 #define UG 22 /* round(0.34414 * 64) */ 
    1070 #define VG 46 /* round(0.71414  * 64) */ 
    1071 #define VR -90 /* round(-1.40200 * 64) */ 
     1072#define UG 22   /* round(0.34414 * 64) */ 
     1073#define VG 46   /* round(0.71414  * 64) */ 
     1074#define VR -90  /* round(-1.40200 * 64) */ 
    10721075 
    10731076// Bias values to round, and subtract 128 from U and V. 
    1074 #define BB (UB * 128            + YGB) 
     1077#define BB (UB * 128 + YGB) 
    10751078#define BG (UG * 128 + VG * 128 + YGB) 
    1076 #define BR            (VR * 128 + YGB) 
     1079#define BR (VR * 128 + YGB) 
    10771080 
    10781081#if defined(__aarch64__) 
    1079 const YuvConstants SIMD_ALIGNED(kYuvJPEGConstants) = { 
    1080   { -UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR }, 
    1081   { -UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR }, 
    1082   { UG, VG, UG, VG, UG, VG, UG, VG }, 
    1083   { UG, VG, UG, VG, UG, VG, UG, VG }, 
    1084   { BB, BG, BR, 0, 0, 0, 0, 0 }, 
    1085   { 0x0101 * YG, 0, 0, 0 } 
    1086 }; 
    1087 const YuvConstants SIMD_ALIGNED(kYvuJPEGConstants) = { 
    1088   { -VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB }, 
    1089   { -VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB }, 
    1090   { VG, UG, VG, UG, VG, UG, VG, UG }, 
    1091   { VG, UG, VG, UG, VG, UG, VG, UG }, 
    1092   { BR, BG, BB, 0, 0, 0, 0, 0 }, 
    1093   { 0x0101 * YG, 0, 0, 0 } 
    1094 }; 
     1082const struct YuvConstants SIMD_ALIGNED(kYuvJPEGConstants) = { 
     1083    {-UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR}, 
     1084    {-UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR}, 
     1085    {UG, VG, UG, VG, UG, VG, UG, VG}, 
     1086    {UG, VG, UG, VG, UG, VG, UG, VG}, 
     1087    {BB, BG, BR, 0, 0, 0, 0, 0}, 
     1088    {0x0101 * YG, 0, 0, 0}}; 
     1089const struct YuvConstants SIMD_ALIGNED(kYvuJPEGConstants) = { 
     1090    {-VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB}, 
     1091    {-VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB}, 
     1092    {VG, UG, VG, UG, VG, UG, VG, UG}, 
     1093    {VG, UG, VG, UG, VG, UG, VG, UG}, 
     1094    {BR, BG, BB, 0, 0, 0, 0, 0}, 
     1095    {0x0101 * YG, 0, 0, 0}}; 
    10951096#elif defined(__arm__) 
    1096 const YuvConstants SIMD_ALIGNED(kYuvJPEGConstants) = { 
    1097   { -UB, -UB, -UB, -UB, -VR, -VR, -VR, -VR, 0, 0, 0, 0, 0, 0, 0, 0 }, 
    1098   { UG, UG, UG, UG, VG, VG, VG, VG, 0, 0, 0, 0, 0, 0, 0, 0 }, 
    1099   { BB, BG, BR, 0, 0, 0, 0, 0 }, 
    1100   { 0x0101 * YG, 0, 0, 0 } 
    1101 }; 
    1102 const YuvConstants SIMD_ALIGNED(kYvuJPEGConstants) = { 
    1103   { -VR, -VR, -VR, -VR, -UB, -UB, -UB, -UB, 0, 0, 0, 0, 0, 0, 0, 0 }, 
    1104   { VG, VG, VG, VG, UG, UG, UG, UG, 0, 0, 0, 0, 0, 0, 0, 0 }, 
    1105   { BR, BG, BB, 0, 0, 0, 0, 0 }, 
    1106   { 0x0101 * YG, 0, 0, 0 } 
    1107 }; 
     1097const struct YuvConstants SIMD_ALIGNED(kYuvJPEGConstants) = { 
     1098    {-UB, -UB, -UB, -UB, -VR, -VR, -VR, -VR, 0, 0, 0, 0, 0, 0, 0, 0}, 
     1099    {UG, UG, UG, UG, VG, VG, VG, VG, 0, 0, 0, 0, 0, 0, 0, 0}, 
     1100    {BB, BG, BR, 0, 0, 0, 0, 0}, 
     1101    {0x0101 * YG, 0, 0, 0}}; 
     1102const struct YuvConstants SIMD_ALIGNED(kYvuJPEGConstants) = { 
     1103    {-VR, -VR, -VR, -VR, -UB, -UB, -UB, -UB, 0, 0, 0, 0, 0, 0, 0, 0}, 
     1104    {VG, VG, VG, VG, UG, UG, UG, UG, 0, 0, 0, 0, 0, 0, 0, 0}, 
     1105    {BR, BG, BB, 0, 0, 0, 0, 0}, 
     1106    {0x0101 * YG, 0, 0, 0}}; 
    11081107#else 
    1109 const YuvConstants SIMD_ALIGNED(kYuvJPEGConstants) = { 
    1110   { UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, 
    1111     UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0 }, 
    1112   { UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, 
    1113     UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG }, 
    1114   { 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 
    1115     0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR }, 
    1116   { BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB }, 
    1117   { BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG }, 
    1118   { BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR }, 
    1119   { YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG } 
    1120 }; 
    1121 const YuvConstants SIMD_ALIGNED(kYvuJPEGConstants) = { 
    1122   { VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, 
    1123     VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0 }, 
    1124   { VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, 
    1125     VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG }, 
    1126   { 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 
    1127     0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB }, 
    1128   { BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR }, 
    1129   { BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG }, 
    1130   { BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB }, 
    1131   { YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG } 
    1132 }; 
     1108const struct YuvConstants SIMD_ALIGNED(kYuvJPEGConstants) = { 
     1109    {UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, 
     1110     UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0}, 
     1111    {UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, 
     1112     UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG}, 
     1113    {0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 
     1114     0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR}, 
     1115    {BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB}, 
     1116    {BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG}, 
     1117    {BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR}, 
     1118    {YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG}}; 
     1119const struct YuvConstants SIMD_ALIGNED(kYvuJPEGConstants) = { 
     1120    {VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, 
     1121     VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0}, 
     1122    {VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, 
     1123     VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG}, 
     1124    {0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 
     1125     0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB}, 
     1126    {BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR}, 
     1127    {BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG}, 
     1128    {BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB}, 
     1129    {YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG}}; 
    11331130#endif 
    11341131 
     
    11441141 
    11451142// BT.709 YUV to RGB reference 
    1146 // *  R = Y                - V * -1.28033 
    1147 // *  G = Y - U *  0.21482 - V *  0.38059 
    1148 // *  B = Y - U * -2.12798 
     1143//  R = (Y - 16) * 1.164              - V * -1.793 
     1144//  G = (Y - 16) * 1.164 - U *  0.213 - V *  0.533 
     1145//  B = (Y - 16) * 1.164 - U * -2.112 
     1146// See also http://www.equasys.de/colorconversion.html 
    11491147 
    11501148// Y contribution to R,G,B.  Scale and bias. 
    1151 #define YG 16320 /* round(1.000 * 64 * 256 * 256 / 257) */ 
    1152 #define YGB 32  /* 64 / 2 */ 
    1153  
    1154 // TODO(fbarchard): Find way to express 2.12 instead of 2.0. 
     1149#define YG 18997  /* round(1.164 * 64 * 256 * 256 / 257) */ 
     1150#define YGB -1160 /* 1.164 * 64 * -16 + 64 / 2 */ 
     1151 
     1152// TODO(fbarchard): Find way to express 2.112 instead of 2.0. 
    11551153// U and V contributions to R,G,B. 
    1156 #define UB -128 /* max(-128, round(-2.12798 * 64)) */ 
    1157 #define UG 14 /* round(0.21482 * 64) */ 
    1158 #define VG 24 /* round(0.38059  * 64) */ 
    1159 #define VR -82 /* round(-1.28033 * 64) */ 
     1154#define UB -128 /* max(-128, round(-2.112 * 64)) */ 
     1155#define UG 14   /* round(0.213 * 64) */ 
     1156#define VG 34   /* round(0.533  * 64) */ 
     1157#define VR -115 /* round(-1.793 * 64) */ 
    11601158 
    11611159// Bias values to round, and subtract 128 from U and V. 
    1162 #define BB (UB * 128            + YGB) 
     1160#define BB (UB * 128 + YGB) 
    11631161#define BG (UG * 128 + VG * 128 + YGB) 
    1164 #define BR            (VR * 128 + YGB) 
     1162#define BR (VR * 128 + YGB) 
    11651163 
    11661164#if defined(__aarch64__) 
    1167 const YuvConstants SIMD_ALIGNED(kYuvH709Constants) = { 
    1168   { -UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR }, 
    1169   { -UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR }, 
    1170   { UG, VG, UG, VG, UG, VG, UG, VG }, 
    1171   { UG, VG, UG, VG, UG, VG, UG, VG }, 
    1172   { BB, BG, BR, 0, 0, 0, 0, 0 }, 
    1173   { 0x0101 * YG, 0, 0, 0 } 
    1174 }; 
    1175 const YuvConstants SIMD_ALIGNED(kYvuH709Constants) = { 
    1176   { -VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB }, 
    1177   { -VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB }, 
    1178   { VG, UG, VG, UG, VG, UG, VG, UG }, 
    1179   { VG, UG, VG, UG, VG, UG, VG, UG }, 
    1180   { BR, BG, BB, 0, 0, 0, 0, 0 }, 
    1181   { 0x0101 * YG, 0, 0, 0 } 
    1182 }; 
     1165const struct YuvConstants SIMD_ALIGNED(kYuvH709Constants) = { 
     1166    {-UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR}, 
     1167    {-UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR}, 
     1168    {UG, VG, UG, VG, UG, VG, UG, VG}, 
     1169    {UG, VG, UG, VG, UG, VG, UG, VG}, 
     1170    {BB, BG, BR, 0, 0, 0, 0, 0}, 
     1171    {0x0101 * YG, 0, 0, 0}}; 
     1172const struct YuvConstants SIMD_ALIGNED(kYvuH709Constants) = { 
     1173    {-VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB}, 
     1174    {-VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB}, 
     1175    {VG, UG, VG, UG, VG, UG, VG, UG}, 
     1176    {VG, UG, VG, UG, VG, UG, VG, UG}, 
     1177    {BR, BG, BB, 0, 0, 0, 0, 0}, 
     1178    {0x0101 * YG, 0, 0, 0}}; 
    11831179#elif defined(__arm__) 
    1184 const YuvConstants SIMD_ALIGNED(kYuvH709Constants) = { 
    1185   { -UB, -UB, -UB, -UB, -VR, -VR, -VR, -VR, 0, 0, 0, 0, 0, 0, 0, 0 }, 
    1186   { UG, UG, UG, UG, VG, VG, VG, VG, 0, 0, 0, 0, 0, 0, 0, 0 }, 
    1187   { BB, BG, BR, 0, 0, 0, 0, 0 }, 
    1188   { 0x0101 * YG, 0, 0, 0 } 
    1189 }; 
    1190 const YuvConstants SIMD_ALIGNED(kYvuH709Constants) = { 
    1191   { -VR, -VR, -VR, -VR, -UB, -UB, -UB, -UB, 0, 0, 0, 0, 0, 0, 0, 0 }, 
    1192   { VG, VG, VG, VG, UG, UG, UG, UG, 0, 0, 0, 0, 0, 0, 0, 0 }, 
    1193   { BR, BG, BB, 0, 0, 0, 0, 0 }, 
    1194   { 0x0101 * YG, 0, 0, 0 } 
    1195 }; 
     1180const struct YuvConstants SIMD_ALIGNED(kYuvH709Constants) = { 
     1181    {-UB, -UB, -UB, -UB, -VR, -VR, -VR, -VR, 0, 0, 0, 0, 0, 0, 0, 0}, 
     1182    {UG, UG, UG, UG, VG, VG, VG, VG, 0, 0, 0, 0, 0, 0, 0, 0}, 
     1183    {BB, BG, BR, 0, 0, 0, 0, 0}, 
     1184    {0x0101 * YG, 0, 0, 0}}; 
     1185const struct YuvConstants SIMD_ALIGNED(kYvuH709Constants) = { 
     1186    {-VR, -VR, -VR, -VR, -UB, -UB, -UB, -UB, 0, 0, 0, 0, 0, 0, 0, 0}, 
     1187    {VG, VG, VG, VG, UG, UG, UG, UG, 0, 0, 0, 0, 0, 0, 0, 0}, 
     1188    {BR, BG, BB, 0, 0, 0, 0, 0}, 
     1189    {0x0101 * YG, 0, 0, 0}}; 
    11961190#else 
    1197 const YuvConstants SIMD_ALIGNED(kYuvH709Constants) = { 
    1198   { UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, 
    1199     UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0 }, 
    1200   { UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, 
    1201     UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG }, 
    1202   { 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 
    1203     0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR }, 
    1204   { BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB }, 
    1205   { BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG }, 
    1206   { BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR }, 
    1207   { YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG } 
    1208 }; 
    1209 const YuvConstants SIMD_ALIGNED(kYvuH709Constants) = { 
    1210   { VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, 
    1211     VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0 }, 
    1212   { VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, 
    1213     VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG }, 
    1214   { 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 
    1215     0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB }, 
    1216   { BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR }, 
    1217   { BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG }, 
    1218   { BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB }, 
    1219   { YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG } 
    1220 }; 
     1191const struct YuvConstants SIMD_ALIGNED(kYuvH709Constants) = { 
     1192    {UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, 
     1193     UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0}, 
     1194    {UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, 
     1195     UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG}, 
     1196    {0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 
     1197     0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR}, 
     1198    {BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB}, 
     1199    {BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG}, 
     1200    {BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR}, 
     1201    {YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG}}; 
     1202const struct YuvConstants SIMD_ALIGNED(kYvuH709Constants) = { 
     1203    {VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, 
     1204     VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0}, 
     1205    {VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, 
     1206     VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG}, 
     1207    {0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 
     1208     0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB}, 
     1209    {BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR}, 
     1210    {BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG, BG}, 
     1211    {BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB, BB}, 
     1212    {YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG}}; 
    12211213#endif 
    12221214 
     
    12321224 
    12331225// C reference code that mimics the YUV assembly. 
    1234 static __inline void YuvPixel(uint8 y, uint8 u, uint8 v, 
    1235                               uint8* b, uint8* g, uint8* r, 
     1226static __inline void YuvPixel(uint8 y, 
     1227                              uint8 u, 
     1228                              uint8 v, 
     1229                              uint8* b, 
     1230                              uint8* g, 
     1231                              uint8* r, 
    12361232                              const struct YuvConstants* yuvconstants) { 
    12371233#if defined(__aarch64__) 
     
    12651261 
    12661262  uint32 y1 = (uint32)(y * 0x0101 * yg) >> 16; 
    1267   *b = Clamp((int32)(-(u * ub         ) + y1 + bb) >> 6); 
     1263  *b = Clamp((int32)(-(u * ub) + y1 + bb) >> 6); 
    12681264  *g = Clamp((int32)(-(u * ug + v * vg) + y1 + bg) >> 6); 
    1269   *r = Clamp((int32)(-(         v * vr) + y1 + br) >> 6); 
     1265  *r = Clamp((int32)(-(v * vr) + y1 + br) >> 6); 
    12701266} 
    12711267 
    12721268// Y contribution to R,G,B.  Scale and bias. 
    1273 #define YG 18997 /* round(1.164 * 64 * 256 * 256 / 257) */ 
     1269#define YG 18997  /* round(1.164 * 64 * 256 * 256 / 257) */ 
    12741270#define YGB -1160 /* 1.164 * 64 * -16 + 64 / 2 */ 
    12751271 
     
    13111307  } 
    13121308  if (width & 1) { 
    1313     YuvPixel(src_y[0], src_u[0], src_v[0], 
    1314              rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); 
     1309    YuvPixel(src_y[0], src_u[0], src_v[0], rgb_buf + 0, rgb_buf + 1, 
     1310             rgb_buf + 2, yuvconstants); 
    13151311    rgb_buf[3] = 255; 
    13161312  } 
     
    13251321  int x; 
    13261322  for (x = 0; x < width; ++x) { 
    1327     YuvPixel(src_y[0], src_u[0], src_v[0], 
    1328              rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); 
     1323    YuvPixel(src_y[0], src_u[0], src_v[0], rgb_buf + 0, rgb_buf + 1, 
     1324             rgb_buf + 2, yuvconstants); 
    13291325    rgb_buf[3] = 255; 
    13301326    src_y += 1; 
     
    13451341  int x; 
    13461342  for (x = 0; x < width - 1; x += 2) { 
    1347     YuvPixel(src_y[0], src_u[0], src_v[0], 
    1348              rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); 
     1343    YuvPixel(src_y[0], src_u[0], src_v[0], rgb_buf + 0, rgb_buf + 1, 
     1344             rgb_buf + 2, yuvconstants); 
    13491345    rgb_buf[3] = 255; 
    1350     YuvPixel(src_y[1], src_u[0], src_v[0], 
    1351              rgb_buf + 4, rgb_buf + 5, rgb_buf + 6, yuvconstants); 
     1346    YuvPixel(src_y[1], src_u[0], src_v[0], rgb_buf + 4, rgb_buf + 5, 
     1347             rgb_buf + 6, yuvconstants); 
    13521348    rgb_buf[7] = 255; 
    13531349    src_y += 2; 
     
    13571353  } 
    13581354  if (width & 1) { 
    1359     YuvPixel(src_y[0], src_u[0], src_v[0], 
    1360              rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); 
     1355    YuvPixel(src_y[0], src_u[0], src_v[0], rgb_buf + 0, rgb_buf + 1, 
     1356             rgb_buf + 2, yuvconstants); 
    13611357    rgb_buf[3] = 255; 
    13621358  } 
     
    13721368  int x; 
    13731369  for (x = 0; x < width - 1; x += 2) { 
    1374     YuvPixel(src_y[0], src_u[0], src_v[0], 
    1375              rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); 
     1370    YuvPixel(src_y[0], src_u[0], src_v[0], rgb_buf + 0, rgb_buf + 1, 
     1371             rgb_buf + 2, yuvconstants); 
    13761372    rgb_buf[3] = src_a[0]; 
    1377     YuvPixel(src_y[1], src_u[0], src_v[0], 
    1378              rgb_buf + 4, rgb_buf + 5, rgb_buf + 6, yuvconstants); 
     1373    YuvPixel(src_y[1], src_u[0], src_v[0], rgb_buf + 4, rgb_buf + 5, 
     1374             rgb_buf + 6, yuvconstants); 
    13791375    rgb_buf[7] = src_a[1]; 
    13801376    src_y += 2; 
     
    13851381  } 
    13861382  if (width & 1) { 
    1387     YuvPixel(src_y[0], src_u[0], src_v[0], 
    1388              rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); 
     1383    YuvPixel(src_y[0], src_u[0], src_v[0], rgb_buf + 0, rgb_buf + 1, 
     1384             rgb_buf + 2, yuvconstants); 
    13891385    rgb_buf[3] = src_a[0]; 
    13901386  } 
     
    13991395  int x; 
    14001396  for (x = 0; x < width - 1; x += 2) { 
    1401     YuvPixel(src_y[0], src_u[0], src_v[0], 
    1402              rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); 
    1403     YuvPixel(src_y[1], src_u[0], src_v[0], 
    1404              rgb_buf + 3, rgb_buf + 4, rgb_buf + 5, yuvconstants); 
     1397    YuvPixel(src_y[0], src_u[0], src_v[0], rgb_buf + 0, rgb_buf + 1, 
     1398             rgb_buf + 2, yuvconstants); 
     1399    YuvPixel(src_y[1], src_u[0], src_v[0], rgb_buf + 3, rgb_buf + 4, 
     1400             rgb_buf + 5, yuvconstants); 
    14051401    src_y += 2; 
    14061402    src_u += 1; 
     
    14091405  } 
    14101406  if (width & 1) { 
    1411     YuvPixel(src_y[0], src_u[0], src_v[0], 
    1412              rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); 
     1407    YuvPixel(src_y[0], src_u[0], src_v[0], rgb_buf + 0, rgb_buf + 1, 
     1408             rgb_buf + 2, yuvconstants); 
    14131409  } 
    14141410} 
     
    14361432    g1 = g1 >> 4; 
    14371433    r1 = r1 >> 4; 
    1438     *(uint32*)(dst_argb4444) = b0 | (g0 << 4) | (r0 << 8) | 
    1439         (b1 << 16) | (g1 << 20) | (r1 << 24) | 0xf000f000; 
     1434    *(uint32*)(dst_argb4444) = b0 | (g0 << 4) | (r0 << 8) | (b1 << 16) | 
     1435                              (g1 << 20) | (r1 << 24) | 0xf000f000; 
    14401436    src_y += 2; 
    14411437    src_u += 1; 
     
    14481444    g0 = g0 >> 4; 
    14491445    r0 = r0 >> 4; 
    1450     *(uint16*)(dst_argb4444) = b0 | (g0 << 4) | (r0 << 8) | 
    1451         0xf000; 
     1446    *(uint16*)(dst_argb4444) = b0 | (g0 << 4) | (r0 << 8) | 0xf000; 
    14521447  } 
    14531448} 
     
    14751470    g1 = g1 >> 3; 
    14761471    r1 = r1 >> 3; 
    1477     *(uint32*)(dst_argb1555) = b0 | (g0 << 5) | (r0 << 10) | 
    1478         (b1 << 16) | (g1 << 21) | (r1 << 26) | 0x80008000; 
     1472    *(uint32*)(dst_argb1555) = b0 | (g0 << 5) | (r0 << 10) | (b1 << 16) | 
     1473                              (g1 << 21) | (r1 << 26) | 0x80008000; 
    14791474    src_y += 2; 
    14801475    src_u += 1; 
     
    14871482    g0 = g0 >> 3; 
    14881483    r0 = r0 >> 3; 
    1489     *(uint16*)(dst_argb1555) = b0 | (g0 << 5) | (r0 << 10) | 
    1490         0x8000; 
     1484    *(uint16*)(dst_argb1555) = b0 | (g0 << 5) | (r0 << 10) | 0x8000; 
    14911485  } 
    14921486} 
     
    15141508    g1 = g1 >> 2; 
    15151509    r1 = r1 >> 3; 
    1516     *(uint32*)(dst_rgb565) = b0 | (g0 << 5) | (r0 << 11) | 
    1517         (b1 << 16) | (g1 << 21) | (r1 << 27); 
     1510    *(uint32*)(dst_rgb565) = 
     1511        b0 | (g0 << 5) | (r0 << 11) | (b1 << 16) | (g1 << 21) | (r1 << 27); 
    15181512    src_y += 2; 
    15191513    src_u += 1; 
     
    15301524} 
    15311525 
    1532 void I411ToARGBRow_C(const uint8* src_y, 
    1533                      const uint8* src_u, 
    1534                      const uint8* src_v, 
    1535                      uint8* rgb_buf, 
    1536                      const struct YuvConstants* yuvconstants, 
    1537                      int width) { 
    1538   int x; 
    1539   for (x = 0; x < width - 3; x += 4) { 
    1540     YuvPixel(src_y[0], src_u[0], src_v[0], 
    1541              rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); 
    1542     rgb_buf[3] = 255; 
    1543     YuvPixel(src_y[1], src_u[0], src_v[0], 
    1544              rgb_buf + 4, rgb_buf + 5, rgb_buf + 6, yuvconstants); 
    1545     rgb_buf[7] = 255; 
    1546     YuvPixel(src_y[2], src_u[0], src_v[0], 
    1547              rgb_buf + 8, rgb_buf + 9, rgb_buf + 10, yuvconstants); 
    1548     rgb_buf[11] = 255; 
    1549     YuvPixel(src_y[3], src_u[0], src_v[0], 
    1550              rgb_buf + 12, rgb_buf + 13, rgb_buf + 14, yuvconstants); 
    1551     rgb_buf[15] = 255; 
    1552     src_y += 4; 
    1553     src_u += 1; 
    1554     src_v += 1; 
    1555     rgb_buf += 16;  // Advance 4 pixels. 
    1556   } 
    1557   if (width & 2) { 
    1558     YuvPixel(src_y[0], src_u[0], src_v[0], 
    1559              rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); 
    1560     rgb_buf[3] = 255; 
    1561     YuvPixel(src_y[1], src_u[0], src_v[0], 
    1562              rgb_buf + 4, rgb_buf + 5, rgb_buf + 6, yuvconstants); 
    1563     rgb_buf[7] = 255; 
    1564     src_y += 2; 
    1565     rgb_buf += 8;  // Advance 2 pixels. 
    1566   } 
    1567   if (width & 1) { 
    1568     YuvPixel(src_y[0], src_u[0], src_v[0], 
    1569              rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); 
    1570     rgb_buf[3] = 255; 
    1571   } 
    1572 } 
    1573  
    15741526void NV12ToARGBRow_C(const uint8* src_y, 
    15751527                     const uint8* src_uv, 
     
    15791531  int x; 
    15801532  for (x = 0; x < width - 1; x += 2) { 
    1581     YuvPixel(src_y[0], src_uv[0], src_uv[1], 
    1582              rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); 
     1533    YuvPixel(src_y[0], src_uv[0], src_uv[1], rgb_buf + 0, rgb_buf + 1, 
     1534             rgb_buf + 2, yuvconstants); 
    15831535    rgb_buf[3] = 255; 
    1584     YuvPixel(src_y[1], src_uv[0], src_uv[1], 
    1585              rgb_buf + 4, rgb_buf + 5, rgb_buf + 6, yuvconstants); 
     1536    YuvPixel(src_y[1], src_uv[0], src_uv[1], rgb_buf + 4, rgb_buf + 5, 
     1537             rgb_buf + 6, yuvconstants); 
    15861538    rgb_buf[7] = 255; 
    15871539    src_y += 2; 
     
    15901542  } 
    15911543  if (width & 1) { 
    1592     YuvPixel(src_y[0], src_uv[0], src_uv[1], 
    1593              rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); 
     1544    YuvPixel(src_y[0], src_uv[0], src_uv[1], rgb_buf + 0, rgb_buf + 1, 
     1545             rgb_buf + 2, yuvconstants); 
    15941546    rgb_buf[3] = 255; 
    15951547  } 
     
    16031555  int x; 
    16041556  for (x = 0; x < width - 1; x += 2) { 
    1605     YuvPixel(src_y[0], src_vu[1], src_vu[0], 
    1606              rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); 
     1557    YuvPixel(src_y[0], src_vu[1], src_vu[0], rgb_buf + 0, rgb_buf + 1, 
     1558             rgb_buf + 2, yuvconstants); 
    16071559    rgb_buf[3] = 255; 
    1608     YuvPixel(src_y[1], src_vu[1], src_vu[0], 
    1609              rgb_buf + 4, rgb_buf + 5, rgb_buf + 6, yuvconstants); 
     1560    YuvPixel(src_y[1], src_vu[1], src_vu[0], rgb_buf + 4, rgb_buf + 5, 
     1561             rgb_buf + 6, yuvconstants); 
    16101562    rgb_buf[7] = 255; 
    16111563    src_y += 2; 
     
    16141566  } 
    16151567  if (width & 1) { 
    1616     YuvPixel(src_y[0], src_vu[1], src_vu[0], 
    1617              rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); 
     1568    YuvPixel(src_y[0], src_vu[1], src_vu[0], rgb_buf + 0, rgb_buf + 1, 
     1569             rgb_buf + 2, yuvconstants); 
    16181570    rgb_buf[3] = 255; 
    16191571  } 
     
    16411593    g1 = g1 >> 2; 
    16421594    r1 = r1 >> 3; 
    1643     *(uint32*)(dst_rgb565) = b0 | (g0 << 5) | (r0 << 11) | 
    1644         (b1 << 16) | (g1 << 21) | (r1 << 27); 
     1595    *(uint32*)(dst_rgb565) = 
     1596        b0 | (g0 << 5) | (r0 << 11) | (b1 << 16) | (g1 << 21) | (r1 << 27); 
    16451597    src_y += 2; 
    16461598    src_uv += 2; 
     
    16621614  int x; 
    16631615  for (x = 0; x < width - 1; x += 2) { 
    1664     YuvPixel(src_yuy2[0], src_yuy2[1], src_yuy2[3], 
    1665              rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); 
     1616    YuvPixel(src_yuy2[0], src_yuy2[1], src_yuy2[3], rgb_buf + 0, rgb_buf + 1, 
     1617             rgb_buf + 2, yuvconstants); 
    16661618    rgb_buf[3] = 255; 
    1667     YuvPixel(src_yuy2[2], src_yuy2[1], src_yuy2[3], 
    1668              rgb_buf + 4, rgb_buf + 5, rgb_buf + 6, yuvconstants); 
     1619    YuvPixel(src_yuy2[2], src_yuy2[1], src_yuy2[3], rgb_buf + 4, rgb_buf + 5, 
     1620             rgb_buf + 6, yuvconstants); 
    16691621    rgb_buf[7] = 255; 
    16701622    src_yuy2 += 4; 
     
    16721624  } 
    16731625  if (width & 1) { 
    1674     YuvPixel(src_yuy2[0], src_yuy2[1], src_yuy2[3], 
    1675              rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); 
     1626    YuvPixel(src_yuy2[0], src_yuy2[1], src_yuy2[3], rgb_buf + 0, rgb_buf + 1, 
     1627             rgb_buf + 2, yuvconstants); 
    16761628    rgb_buf[3] = 255; 
    16771629  } 
     
    16841636  int x; 
    16851637  for (x = 0; x < width - 1; x += 2) { 
    1686     YuvPixel(src_uyvy[1], src_uyvy[0], src_uyvy[2], 
    1687              rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); 
     1638    YuvPixel(src_uyvy[1], src_uyvy[0], src_uyvy[2], rgb_buf + 0, rgb_buf + 1, 
     1639             rgb_buf + 2, yuvconstants); 
    16881640    rgb_buf[3] = 255; 
    1689     YuvPixel(src_uyvy[3], src_uyvy[0], src_uyvy[2], 
    1690              rgb_buf + 4, rgb_buf + 5, rgb_buf + 6, yuvconstants); 
     1641    YuvPixel(src_uyvy[3], src_uyvy[0], src_uyvy[2], rgb_buf + 4, rgb_buf + 5, 
     1642             rgb_buf + 6, yuvconstants); 
    16911643    rgb_buf[7] = 255; 
    16921644    src_uyvy += 4; 
     
    16941646  } 
    16951647  if (width & 1) { 
    1696     YuvPixel(src_uyvy[1], src_uyvy[0], src_uyvy[2], 
    1697              rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); 
     1648    YuvPixel(src_uyvy[1], src_uyvy[0], src_uyvy[2], rgb_buf + 0, rgb_buf + 1, 
     1649             rgb_buf + 2, yuvconstants); 
    16981650    rgb_buf[3] = 255; 
    16991651  } 
     
    17081660  int x; 
    17091661  for (x = 0; x < width - 1; x += 2) { 
    1710     YuvPixel(src_y[0], src_u[0], src_v[0], 
    1711              rgb_buf + 1, rgb_buf + 2, rgb_buf + 3, yuvconstants); 
     1662    YuvPixel(src_y[0], src_u[0], src_v[0], rgb_buf + 1, rgb_buf + 2, 
     1663             rgb_buf + 3, yuvconstants); 
    17121664    rgb_buf[0] = 255; 
    1713     YuvPixel(src_y[1], src_u[0], src_v[0], 
    1714              rgb_buf + 5, rgb_buf + 6, rgb_buf + 7, yuvconstants); 
     1665    YuvPixel(src_y[1], src_u[0], src_v[0], rgb_buf + 5, rgb_buf + 6, 
     1666             rgb_buf + 7, yuvconstants); 
    17151667    rgb_buf[4] = 255; 
    17161668    src_y += 2; 
     
    17201672  } 
    17211673  if (width & 1) { 
    1722     YuvPixel(src_y[0], src_u[0], src_v[0], 
    1723              rgb_buf + 1, rgb_buf + 2, rgb_buf + 3, yuvconstants); 
     1674    YuvPixel(src_y[0], src_u[0], src_v[0], rgb_buf + 1, rgb_buf + 2, 
     1675             rgb_buf + 3, yuvconstants); 
    17241676    rgb_buf[0] = 255; 
    17251677  } 
     
    18011753} 
    18021754 
    1803 void MergeUVRow_C(const uint8* src_u, const uint8* src_v, uint8* dst_uv, 
     1755void MergeUVRow_C(const uint8* src_u, 
     1756                  const uint8* src_v, 
     1757                  uint8* dst_uv, 
    18041758                  int width) { 
    18051759  int x; 
     
    18381792 
    18391793// Filter 2 rows of YUY2 UV's (422) into U and V (420). 
    1840 void YUY2ToUVRow_C(const uint8* src_yuy2, int src_stride_yuy2, 
    1841                    uint8* dst_u, uint8* dst_v, int width) { 
     1794void YUY2ToUVRow_C(const uint8* src_yuy2, 
     1795                   int src_stride_yuy2, 
     1796                   uint8* dst_u, 
     1797                   uint8* dst_v, 
     1798                   int width) { 
    18421799  // Output a row of UV values, filtering 2 rows of YUY2. 
    18431800  int x; 
     
    18531810// Copy row of YUY2 UV's (422) into U and V (422). 
    18541811void YUY2ToUV422Row_C(const uint8* src_yuy2, 
    1855                       uint8* dst_u, uint8* dst_v, int width) { 
     1812                      uint8* dst_u, 
     1813                      uint8* dst_v, 
     1814                      int width) { 
    18561815  // Output a row of UV values. 
    18571816  int x; 
     
    18801839 
    18811840// Filter 2 rows of UYVY UV's (422) into U and V (420). 
    1882 void UYVYToUVRow_C(const uint8* src_uyvy, int src_stride_uyvy, 
    1883                    uint8* dst_u, uint8* dst_v, int width) { 
     1841void UYVYToUVRow_C(const uint8* src_uyvy, 
     1842                   int src_stride_uyvy, 
     1843                   uint8* dst_u, 
     1844                   uint8* dst_v, 
     1845                   int width) { 
    18841846  // Output a row of UV values. 
    18851847  int x; 
     
    18951857// Copy row of UYVY UV's (422) into U and V (422). 
    18961858void UYVYToUV422Row_C(const uint8* src_uyvy, 
    1897                       uint8* dst_u, uint8* dst_v, int width) { 
     1859                      uint8* dst_u, 
     1860                      uint8* dst_v, 
     1861                      int width) { 
    18981862  // Output a row of UV values. 
    18991863  int x; 
     
    19261890// dst_argb may be src_argb0 or src_argb1. 
    19271891// This code mimics the SSSE3 version for better testability. 
    1928 void ARGBBlendRow_C(const uint8* src_argb0, const uint8* src_argb1, 
    1929                     uint8* dst_argb, int width) { 
     1892void ARGBBlendRow_C(const uint8* src_argb0, 
     1893                    const uint8* src_argb1, 
     1894                    uint8* dst_argb, 
     1895                    int width) { 
    19301896  int x; 
    19311897  for (x = 0; x < width - 1; x += 2) { 
     
    19741940#undef BLEND 
    19751941 
    1976 #define UBLEND(f, b, a) (((a) * f) + ((255 - a) * b) + 255) >> 8 
    1977 void BlendPlaneRow_C(const uint8* src0, const uint8* src1, 
    1978                      const uint8* alpha, uint8* dst, int width) { 
     1942#define UBLEND(f, b, a) (((a)*f) + ((255 - a) * b) + 255) >> 8 
     1943void BlendPlaneRow_C(const uint8* src0, 
     1944                     const uint8* src1, 
     1945                     const uint8* alpha, 
     1946                     uint8* dst, 
     1947                     int width) { 
    19791948  int x; 
    19801949  for (x = 0; x < width - 1; x += 2) { 
     
    20402009#define T(a) 0x01000000 + (0x10000 / a) 
    20412010const uint32 fixed_invtbl8[256] = { 
    2042   0x01000000, 0x0100ffff, T(0x02), T(0x03), T(0x04), T(0x05), T(0x06), T(0x07), 
    2043   T(0x08), T(0x09), T(0x0a), T(0x0b), T(0x0c), T(0x0d), T(0x0e), T(0x0f), 
    2044   T(0x10), T(0x11), T(0x12), T(0x13), T(0x14), T(0x15), T(0x16), T(0x17), 
    2045   T(0x18), T(0x19), T(0x1a), T(0x1b), T(0x1c), T(0x1d), T(0x1e), T(0x1f), 
    2046   T(0x20), T(0x21), T(0x22), T(0x23), T(0x24), T(0x25), T(0x26), T(0x27), 
    2047   T(0x28), T(0x29), T(0x2a), T(0x2b), T(0x2c), T(0x2d), T(0x2e), T(0x2f), 
    2048   T(0x30), T(0x31), T(0x32), T(0x33), T(0x34), T(0x35), T(0x36), T(0x37), 
    2049   T(0x38), T(0x39), T(0x3a), T(0x3b), T(0x3c), T(0x3d), T(0x3e), T(0x3f), 
    2050   T(0x40), T(0x41), T(0x42), T(0x43), T(0x44), T(0x45), T(0x46), T(0x47), 
    2051   T(0x48), T(0x49), T(0x4a), T(0x4b), T(0x4c), T(0x4d), T(0x4e), T(0x4f), 
    2052   T(0x50), T(0x51), T(0x52), T(0x53), T(0x54), T(0x55), T(0x56), T(0x57), 
    2053   T(0x58), T(0x59), T(0x5a), T(0x5b), T(0x5c), T(0x5d), T(0x5e), T(0x5f), 
    2054   T(0x60), T(0x61), T(0x62), T(0x63), T(0x64), T(0x65), T(0x66), T(0x67), 
    2055   T(0x68), T(0x69), T(0x6a), T(0x6b), T(0x6c), T(0x6d), T(0x6e), T(0x6f), 
    2056   T(0x70), T(0x71), T(0x72), T(0x73), T(0x74), T(0x75), T(0x76), T(0x77), 
    2057   T(0x78), T(0x79), T(0x7a), T(0x7b), T(0x7c), T(0x7d), T(0x7e), T(0x7f), 
    2058   T(0x80), T(0x81), T(0x82), T(0x83), T(0x84), T(0x85), T(0x86), T(0x87), 
    2059   T(0x88), T(0x89), T(0x8a), T(0x8b), T(0x8c), T(0x8d), T(0x8e), T(0x8f), 
    2060   T(0x90), T(0x91), T(0x92), T(0x93), T(0x94), T(0x95), T(0x96), T(0x97), 
    2061   T(0x98), T(0x99), T(0x9a), T(0x9b), T(0x9c), T(0x9d), T(0x9e), T(0x9f), 
    2062   T(0xa0), T(0xa1), T(0xa2), T(0xa3), T(0xa4), T(0xa5), T(0xa6), T(0xa7), 
    2063   T(0xa8), T(0xa9), T(0xaa), T(0xab), T(0xac), T(0xad), T(0xae), T(0xaf), 
    2064   T(0xb0), T(0xb1), T(0xb2), T(0xb3), T(0xb4), T(0xb5), T(0xb6), T(0xb7), 
    2065   T(0xb8), T(0xb9), T(0xba), T(0xbb), T(0xbc), T(0xbd), T(0xbe), T(0xbf), 
    2066   T(0xc0), T(0xc1), T(0xc2), T(0xc3), T(0xc4), T(0xc5), T(0xc6), T(0xc7), 
    2067   T(0xc8), T(0xc9), T(0xca), T(0xcb), T(0xcc), T(0xcd), T(0xce), T(0xcf), 
    2068   T(0xd0), T(0xd1), T(0xd2), T(0xd3), T(0xd4), T(0xd5), T(0xd6), T(0xd7), 
    2069   T(0xd8), T(0xd9), T(0xda), T(0xdb), T(0xdc), T(0xdd), T(0xde), T(0xdf), 
    2070   T(0xe0), T(0xe1), T(0xe2), T(0xe3), T(0xe4), T(0xe5), T(0xe6), T(0xe7), 
    2071   T(0xe8), T(0xe9), T(0xea), T(0xeb), T(0xec), T(0xed), T(0xee), T(0xef), 
    2072   T(0xf0), T(0xf1), T(0xf2), T(0xf3), T(0xf4), T(0xf5), T(0xf6), T(0xf7), 
    2073   T(0xf8), T(0xf9), T(0xfa), T(0xfb), T(0xfc), T(0xfd), T(0xfe), 0x01000100 }; 
     2011    0x01000000, 0x0100ffff, T(0x02), T(0x03),   T(0x04), T(0x05), T(0x06), 
     2012    T(0x07),    T(0x08),    T(0x09), T(0x0a),   T(0x0b), T(0x0c), T(0x0d), 
     2013    T(0x0e),    T(0x0f),    T(0x10), T(0x11),   T(0x12), T(0x13), T(0x14), 
     2014    T(0x15),    T(0x16),    T(0x17), T(0x18),   T(0x19), T(0x1a), T(0x1b), 
     2015    T(0x1c),    T(0x1d),    T(0x1e), T(0x1f),   T(0x20), T(0x21), T(0x22), 
     2016    T(0x23),    T(0x24),    T(0x25), T(0x26),   T(0x27), T(0x28), T(0x29), 
     2017    T(0x2a),    T(0x2b),    T(0x2c), T(0x2d),   T(0x2e), T(0x2f), T(0x30), 
     2018    T(0x31),    T(0x32),    T(0x33), T(0x34),   T(0x35), T(0x36), T(0x37), 
     2019    T(0x38),    T(0x39),    T(0x3a), T(0x3b),   T(0x3c), T(0x3d), T(0x3e), 
     2020    T(0x3f),    T(0x40),    T(0x41), T(0x42),   T(0x43), T(0x44), T(0x45), 
     2021    T(0x46),    T(0x47),    T(0x48), T(0x49),   T(0x4a), T(0x4b), T(0x4c), 
     2022    T(0x4d),    T(0x4e),    T(0x4f), T(0x50),   T(0x51), T(0x52), T(0x53), 
     2023    T(0x54),    T(0x55),    T(0x56), T(0x57),   T(0x58), T(0x59), T(0x5a), 
     2024    T(0x5b),    T(0x5c),    T(0x5d), T(0x5e),   T(0x5f), T(0x60), T(0x61), 
     2025    T(0x62),    T(0x63),    T(0x64), T(0x65),   T(0x66), T(0x67), T(0x68), 
     2026    T(0x69),    T(0x6a),    T(0x6b), T(0x6c),   T(0x6d), T(0x6e), T(0x6f), 
     2027    T(0x70),    T(0x71),    T(0x72), T(0x73),   T(0x74), T(0x75), T(0x76), 
     2028    T(0x77),    T(0x78),    T(0x79), T(0x7a),   T(0x7b), T(0x7c), T(0x7d), 
     2029    T(0x7e),    T(0x7f),    T(0x80), T(0x81),   T(0x82), T(0x83), T(0x84), 
     2030    T(0x85),    T(0x86),    T(0x87), T(0x88),   T(0x89), T(0x8a), T(0x8b), 
     2031    T(0x8c),    T(0x8d),    T(0x8e), T(0x8f),   T(0x90), T(0x91), T(0x92), 
     2032    T(0x93),    T(0x94),    T(0x95), T(0x96),   T(0x97), T(0x98), T(0x99), 
     2033    T(0x9a),    T(0x9b),    T(0x9c), T(0x9d),   T(0x9e), T(0x9f), T(0xa0), 
     2034    T(0xa1),    T(0xa2),    T(0xa3), T(0xa4),   T(0xa5), T(0xa6), T(0xa7), 
     2035    T(0xa8),    T(0xa9),    T(0xaa), T(0xab),   T(0xac), T(0xad), T(0xae), 
     2036    T(0xaf),    T(0xb0),    T(0xb1), T(0xb2),   T(0xb3), T(0xb4), T(0xb5), 
     2037    T(0xb6),    T(0xb7),    T(0xb8), T(0xb9),   T(0xba), T(0xbb), T(0xbc), 
     2038    T(0xbd),    T(0xbe),    T(0xbf), T(0xc0),   T(0xc1), T(0xc2), T(0xc3), 
     2039    T(0xc4),    T(0xc5),    T(0xc6), T(0xc7),   T(0xc8), T(0xc9), T(0xca), 
     2040    T(0xcb),    T(0xcc),    T(0xcd), T(0xce),   T(0xcf), T(0xd0), T(0xd1), 
     2041    T(0xd2),    T(0xd3),    T(0xd4), T(0xd5),   T(0xd6), T(0xd7), T(0xd8), 
     2042    T(0xd9),    T(0xda),    T(0xdb), T(0xdc),   T(0xdd), T(0xde), T(0xdf), 
     2043    T(0xe0),    T(0xe1),    T(0xe2), T(0xe3),   T(0xe4), T(0xe5), T(0xe6), 
     2044    T(0xe7),    T(0xe8),    T(0xe9), T(0xea),   T(0xeb), T(0xec), T(0xed), 
     2045    T(0xee),    T(0xef),    T(0xf0), T(0xf1),   T(0xf2), T(0xf3), T(0xf4), 
     2046    T(0xf5),    T(0xf6),    T(0xf7), T(0xf8),   T(0xf9), T(0xfa), T(0xfb), 
     2047    T(0xfc),    T(0xfd),    T(0xfe), 0x01000100}; 
    20742048#undef T 
    20752049 
     
    20952069} 
    20962070 
    2097 void ComputeCumulativeSumRow_C(const uint8* row, int32* cumsum, 
    2098                                const int32* previous_cumsum, int width) { 
     2071void ComputeCumulativeSumRow_C(const uint8* row, 
     2072                               int32* cumsum, 
     2073                               const int32* previous_cumsum, 
     2074                               int width) { 
    20992075  int32 row_sum[4] = {0, 0, 0, 0}; 
    21002076  int x; 
     
    21042080    row_sum[2] += row[x * 4 + 2]; 
    21052081    row_sum[3] += row[x * 4 + 3]; 
    2106     cumsum[x * 4 + 0] = row_sum[0]  + previous_cumsum[x * 4 + 0]; 
    2107     cumsum[x * 4 + 1] = row_sum[1]  + previous_cumsum[x * 4 + 1]; 
    2108     cumsum[x * 4 + 2] = row_sum[2]  + previous_cumsum[x * 4 + 2]; 
    2109     cumsum[x * 4 + 3] = row_sum[3]  + previous_cumsum[x * 4 + 3]; 
    2110   } 
    2111 } 
    2112  
    2113 void CumulativeSumToAverageRow_C(const int32* tl, const int32* bl, 
    2114                                 int w, int area, uint8* dst, int count) { 
     2082    cumsum[x * 4 + 0] = row_sum[0] + previous_cumsum[x * 4 + 0]; 
     2083    cumsum[x * 4 + 1] = row_sum[1] + previous_cumsum[x * 4 + 1]; 
     2084    cumsum[x * 4 + 2] = row_sum[2] + previous_cumsum[x * 4 + 2]; 
     2085    cumsum[x * 4 + 3] = row_sum[3] + previous_cumsum[x * 4 + 3]; 
     2086  } 
     2087} 
     2088 
     2089void CumulativeSumToAverageRow_C(const int32* tl, 
     2090                                 const int32* bl, 
     2091                                 int w, 
     2092                                 int area, 
     2093                                 uint8* dst, 
     2094                                 int count) { 
    21152095  float ooa = 1.0f / area; 
    21162096  int i; 
     
    21282108// Copy pixels from rotated source to destination row with a slope. 
    21292109LIBYUV_API 
    2130 void ARGBAffineRow_C(const uint8* src_argb, int src_argb_stride, 
    2131                      uint8* dst_argb, const float* uv_dudv, int width) { 
     2110void ARGBAffineRow_C(const uint8* src_argb, 
     2111                     int src_argb_stride, 
     2112                     uint8* dst_argb, 
     2113                     const float* uv_dudv, 
     2114                     int width) { 
    21322115  int i; 
    21332116  // Render a row of pixels from source into a buffer. 
     
    21392122    int y = (int)(uv[1]); 
    21402123    *(uint32*)(dst_argb) = 
    2141         *(const uint32*)(src_argb + y * src_argb_stride + 
    2142                                          x * 4); 
     2124        *(const uint32*)(src_argb + y * src_argb_stride + x * 4); 
    21432125    dst_argb += 4; 
    21442126    uv[0] += uv_dudv[2]; 
     
    21482130 
    21492131// Blend 2 rows into 1. 
    2150 static void HalfRow_C(const uint8* src_uv, ptrdiff_t src_uv_stride, 
    2151                       uint8* dst_uv, int width) { 
     2132static void HalfRow_C(const uint8* src_uv, 
     2133                      ptrdiff_t src_uv_stride, 
     2134                      uint8* dst_uv, 
     2135                      int width) { 
    21522136  int x; 
    21532137  for (x = 0; x < width; ++x) { 
     
    21562140} 
    21572141 
    2158 static void HalfRow_16_C(const uint16* src_uv, ptrdiff_t src_uv_stride, 
    2159                          uint16* dst_uv, int width) { 
     2142static void HalfRow_16_C(const uint16* src_uv, 
     2143                         ptrdiff_t src_uv_stride, 
     2144                         uint16* dst_uv, 
     2145                         int width) { 
    21602146  int x; 
    21612147  for (x = 0; x < width; ++x) { 
     
    21652151 
    21662152// C version 2x2 -> 2x1. 
    2167 void InterpolateRow_C(uint8* dst_ptr, const uint8* src_ptr, 
     2153void InterpolateRow_C(uint8* dst_ptr, 
     2154                      const uint8* src_ptr, 
    21682155                      ptrdiff_t src_stride, 
    2169                       int width, int source_y_fraction) { 
    2170   int y1_fraction = source_y_fraction ; 
     2156                      int width, 
     2157                      int source_y_fraction) { 
     2158  int y1_fraction = source_y_fraction; 
    21712159  int y0_fraction = 256 - y1_fraction; 
    21722160  const uint8* src_ptr1 = src_ptr + src_stride; 
     
    21952183} 
    21962184 
    2197 void InterpolateRow_16_C(uint16* dst_ptr, const uint16* src_ptr, 
     2185void InterpolateRow_16_C(uint16* dst_ptr, 
     2186                         const uint16* src_ptr, 
    21982187                         ptrdiff_t src_stride, 
    2199                          int width, int source_y_fraction) { 
     2188                         int width, 
     2189                         int source_y_fraction) { 
    22002190  int y1_fraction = source_y_fraction; 
    22012191  int y0_fraction = 256 - y1_fraction; 
     
    22232213 
    22242214// Use first 4 shuffler values to reorder ARGB channels. 
    2225 void ARGBShuffleRow_C(const uint8* src_argb, uint8* dst_argb, 
    2226                       const uint8* shuffler, int width) { 
     2215void ARGBShuffleRow_C(const uint8* src_argb, 
     2216                      uint8* dst_argb, 
     2217                      const uint8* shuffler, 
     2218                      int width) { 
    22272219  int index0 = shuffler[0]; 
    22282220  int index1 = shuffler[1]; 
     
    22492241                     const uint8* src_u, 
    22502242                     const uint8* src_v, 
    2251                      uint8* dst_frame, int width) { 
     2243                     uint8* dst_frame, 
     2244                     int width) { 
    22522245  int x; 
    22532246  for (x = 0; x < width - 1; x += 2) { 
     
    22722265                     const uint8* src_u, 
    22732266                     const uint8* src_v, 
    2274                      uint8* dst_frame, int width) { 
     2267                     uint8* dst_frame, 
     2268                     int width) { 
    22752269  int x; 
    22762270  for (x = 0; x < width - 1; x += 2) { 
     
    22912285  } 
    22922286} 
    2293  
    22942287 
    22952288void ARGBPolynomialRow_C(const uint8* src_argb, 
     
    23332326} 
    23342327 
    2335 void ARGBLumaColorTableRow_C(const uint8* src_argb, uint8* dst_argb, int width, 
    2336                              const uint8* luma, uint32 lumacoeff) { 
     2328// Samples assumed to be unsigned in low 9, 10 or 12 bits.  Scale factor 
     2329// adjust the source integer range to the half float range desired. 
     2330 
     2331// This magic constant is 2^-112. Multiplying by this 
     2332// is the same as subtracting 112 from the exponent, which 
     2333// is the difference in exponent bias between 32-bit and 
     2334// 16-bit floats. Once we've done this subtraction, we can 
     2335// simply extract the low bits of the exponent and the high 
     2336// bits of the mantissa from our float and we're done. 
     2337 
     2338void HalfFloatRow_C(const uint16* src, uint16* dst, float scale, int width) { 
     2339  int i; 
     2340  float mult = 1.9259299444e-34f * scale; 
     2341  for (i = 0; i < width; ++i) { 
     2342    float value = src[i] * mult; 
     2343    dst[i] = (uint16)((*(uint32_t*)&value) >> 13); 
     2344  } 
     2345} 
     2346 
     2347void ARGBLumaColorTableRow_C(const uint8* src_argb, 
     2348                             uint8* dst_argb, 
     2349                             int width, 
     2350                             const uint8* luma, 
     2351                             uint32 lumacoeff) { 
    23372352  uint32 bc = lumacoeff & 0xff; 
    23382353  uint32 gc = (lumacoeff >> 8) & 0xff; 
     
    23422357  for (i = 0; i < width - 1; i += 2) { 
    23432358    // Luminance in rows, color values in columns. 
    2344     const uint8* luma0 = ((src_argb[0] * bc + src_argb[1] * gc + 
    2345                            src_argb[2] * rc) & 0x7F00u) + luma; 
     2359    const uint8* luma0 = 
     2360        ((src_argb[0] * bc + src_argb[1] * gc + src_argb[2] * rc) & 0x7F00u) + 
     2361        luma; 
    23462362    const uint8* luma1; 
    23472363    dst_argb[0] = luma0[src_argb[0]]; 
     
    23492365    dst_argb[2] = luma0[src_argb[2]]; 
    23502366    dst_argb[3] = src_argb[3]; 
    2351     luma1 = ((src_argb[4] * bc + src_argb[5] * gc + 
    2352               src_argb[6] * rc) & 0x7F00u) + luma; 
     2367    luma1 = 
     2368        ((src_argb[4] * bc + src_argb[5] * gc + src_argb[6] * rc) & 0x7F00u) + 
     2369        luma; 
    23532370    dst_argb[4] = luma1[src_argb[4]]; 
    23542371    dst_argb[5] = luma1[src_argb[5]]; 
     
    23602377  if (width & 1) { 
    23612378    // Luminance in rows, color values in columns. 
    2362     const uint8* luma0 = ((src_argb[0] * bc + src_argb[1] * gc + 
    2363                            src_argb[2] * rc) & 0x7F00u) + luma; 
     2379    const uint8* luma0 = 
     2380        ((src_argb[0] * bc + src_argb[1] * gc + src_argb[2] * rc) & 0x7F00u) + 
     2381        luma; 
    23642382    dst_argb[0] = luma0[src_argb[0]]; 
    23652383    dst_argb[1] = luma0[src_argb[1]]; 
     
    25052523                          const struct YuvConstants* yuvconstants, 
    25062524                          int width) { 
    2507   SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]); 
     2525  SIMD_ALIGNED(uint8 row[MAXTWIDTH * 4]); 
    25082526  while (width > 0) { 
    25092527    int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; 
     
    25312549                            int width) { 
    25322550  // Row buffer for intermediate ARGB pixels. 
    2533   SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]); 
     2551  SIMD_ALIGNED(uint8 row[MAXTWIDTH * 4]); 
    25342552  while (width > 0) { 
    25352553    int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; 
     
    25572575                            int width) { 
    25582576  // Row buffer for intermediate ARGB pixels. 
    2559   SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]); 
     2577  SIMD_ALIGNED(uint8 row[MAXTWIDTH * 4]); 
    25602578  while (width > 0) { 
    25612579    int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; 
     
    25772595#if defined(HAS_I422TORGB24ROW_AVX2) 
    25782596void I422ToRGB24Row_AVX2(const uint8* src_y, 
    2579                             const uint8* src_u, 
    2580                             const uint8* src_v, 
    2581                             uint8* dst_rgb24, 
    2582                             const struct YuvConstants* yuvconstants, 
    2583                             int width) { 
     2597                         const uint8* src_u, 
     2598                         const uint8* src_v, 
     2599                         uint8* dst_rgb24, 
     2600                         const struct YuvConstants* yuvconstants, 
     2601                         int width) { 
    25842602  // Row buffer for intermediate ARGB pixels. 
    2585   SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]); 
     2603  SIMD_ALIGNED(uint8 row[MAXTWIDTH * 4]); 
    25862604  while (width > 0) { 
    25872605    int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; 
     
    26052623                          int width) { 
    26062624  // Row buffer for intermediate ARGB pixels. 
    2607   SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]); 
     2625  SIMD_ALIGNED(uint8 row[MAXTWIDTH * 4]); 
    26082626  while (width > 0) { 
    26092627    int twidth = width > MAXTWIDTH ? MAXTWIDTH : width; 
Note: See TracChangeset for help on using the changeset viewer.