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

    r5358 r5633  
    1111#include "libyuv/rotate.h" 
    1212 
     13#include "libyuv/convert.h" 
    1314#include "libyuv/cpu_id.h" 
    14 #include "libyuv/convert.h" 
    1515#include "libyuv/planar_functions.h" 
    1616#include "libyuv/rotate_row.h" 
     
    2323 
    2424LIBYUV_API 
    25 void TransposePlane(const uint8* src, int src_stride, 
    26                     uint8* dst, int dst_stride, 
    27                     int width, int height) { 
     25void TransposePlane(const uint8* src, 
     26                    int src_stride, 
     27                    uint8* dst, 
     28                    int dst_stride, 
     29                    int width, 
     30                    int height) { 
    2831  int i = height; 
    29   void (*TransposeWx8)(const uint8* src, int src_stride, 
    30                        uint8* dst, int dst_stride, int width) = TransposeWx8_C; 
     32#if defined(HAS_TRANSPOSEWX16_MSA) 
     33  void (*TransposeWx16)(const uint8* src, int src_stride, uint8* dst, 
     34                        int dst_stride, int width) = TransposeWx16_C; 
     35#else 
     36  void (*TransposeWx8)(const uint8* src, int src_stride, uint8* dst, 
     37                       int dst_stride, int width) = TransposeWx8_C; 
     38#endif 
    3139#if defined(HAS_TRANSPOSEWX8_NEON) 
    3240  if (TestCpuFlag(kCpuHasNEON)) { 
     
    5260#if defined(HAS_TRANSPOSEWX8_DSPR2) 
    5361  if (TestCpuFlag(kCpuHasDSPR2)) { 
    54     if (IS_ALIGNED(width, 4) && 
    55         IS_ALIGNED(src, 4) && IS_ALIGNED(src_stride, 4)) { 
     62    if (IS_ALIGNED(width, 4) && IS_ALIGNED(src, 4) && 
     63        IS_ALIGNED(src_stride, 4)) { 
    5664      TransposeWx8 = TransposeWx8_Fast_DSPR2; 
    5765    } else { 
     
    6068  } 
    6169#endif 
    62  
     70#if defined(HAS_TRANSPOSEWX16_MSA) 
     71  if (TestCpuFlag(kCpuHasMSA)) { 
     72    TransposeWx16 = TransposeWx16_Any_MSA; 
     73    if (IS_ALIGNED(width, 16)) { 
     74      TransposeWx16 = TransposeWx16_MSA; 
     75    } 
     76  } 
     77#endif 
     78 
     79#if defined(HAS_TRANSPOSEWX16_MSA) 
     80  // Work across the source in 16x16 tiles 
     81  while (i >= 16) { 
     82    TransposeWx16(src, src_stride, dst, dst_stride, width); 
     83    src += 16 * src_stride;  // Go down 16 rows. 
     84    dst += 16;               // Move over 16 columns. 
     85    i -= 16; 
     86  } 
     87#else 
    6388  // Work across the source in 8x8 tiles 
    6489  while (i >= 8) { 
    6590    TransposeWx8(src, src_stride, dst, dst_stride, width); 
    66     src += 8 * src_stride;    // Go down 8 rows. 
    67     dst += 8;                 // Move over 8 columns. 
     91    src += 8 * src_stride;  // Go down 8 rows. 
     92    dst += 8;               // Move over 8 columns. 
    6893    i -= 8; 
    6994  } 
     95#endif 
    7096 
    7197  if (i > 0) { 
     
    75101 
    76102LIBYUV_API 
    77 void RotatePlane90(const uint8* src, int src_stride, 
    78                    uint8* dst, int dst_stride, 
    79                    int width, int height) { 
     103void RotatePlane90(const uint8* src, 
     104                   int src_stride, 
     105                   uint8* dst, 
     106                   int dst_stride, 
     107                   int width, 
     108                   int height) { 
    80109  // Rotate by 90 is a transpose with the source read 
    81110  // from bottom to top. So set the source pointer to the end 
     
    87116 
    88117LIBYUV_API 
    89 void RotatePlane270(const uint8* src, int src_stride, 
    90                     uint8* dst, int dst_stride, 
    91                     int width, int height) { 
     118void RotatePlane270(const uint8* src, 
     119                    int src_stride, 
     120                    uint8* dst, 
     121                    int dst_stride, 
     122                    int width, 
     123                    int height) { 
    92124  // Rotate by 270 is a transpose with the destination written 
    93125  // from bottom to top. So set the destination pointer to the end 
     
    99131 
    100132LIBYUV_API 
    101 void RotatePlane180(const uint8* src, int src_stride, 
    102                     uint8* dst, int dst_stride, 
    103                     int width, int height) { 
     133void RotatePlane180(const uint8* src, 
     134                    int src_stride, 
     135                    uint8* dst, 
     136                    int dst_stride, 
     137                    int width, 
     138                    int height) { 
    104139  // Swap first and last row and mirror the content. Uses a temporary row. 
    105140  align_buffer_64(row, width); 
     
    136171// TODO(fbarchard): Mirror on mips handle unaligned memory. 
    137172#if defined(HAS_MIRRORROW_DSPR2) 
    138   if (TestCpuFlag(kCpuHasDSPR2) && 
    139       IS_ALIGNED(src, 4) && IS_ALIGNED(src_stride, 4) && 
    140       IS_ALIGNED(dst, 4) && IS_ALIGNED(dst_stride, 4)) { 
     173  if (TestCpuFlag(kCpuHasDSPR2) && IS_ALIGNED(src, 4) && 
     174      IS_ALIGNED(src_stride, 4) && IS_ALIGNED(dst, 4) && 
     175      IS_ALIGNED(dst_stride, 4)) { 
    141176    MirrorRow = MirrorRow_DSPR2; 
     177  } 
     178#endif 
     179#if defined(HAS_MIRRORROW_MSA) 
     180  if (TestCpuFlag(kCpuHasMSA)) { 
     181    MirrorRow = MirrorRow_Any_MSA; 
     182    if (IS_ALIGNED(width, 64)) { 
     183      MirrorRow = MirrorRow_MSA; 
     184    } 
    142185  } 
    143186#endif 
     
    182225 
    183226LIBYUV_API 
    184 void TransposeUV(const uint8* src, int src_stride, 
    185                  uint8* dst_a, int dst_stride_a, 
    186                  uint8* dst_b, int dst_stride_b, 
    187                  int width, int height) { 
     227void TransposeUV(const uint8* src, 
     228                 int src_stride, 
     229                 uint8* dst_a, 
     230                 int dst_stride_a, 
     231                 uint8* dst_b, 
     232                 int dst_stride_b, 
     233                 int width, 
     234                 int height) { 
    188235  int i = height; 
    189   void (*TransposeUVWx8)(const uint8* src, int src_stride, 
    190                          uint8* dst_a, int dst_stride_a, 
    191                          uint8* dst_b, int dst_stride_b, 
     236#if defined(HAS_TRANSPOSEUVWX16_MSA) 
     237  void (*TransposeUVWx16)(const uint8* src, int src_stride, uint8* dst_a, 
     238                          int dst_stride_a, uint8* dst_b, int dst_stride_b, 
     239                          int width) = TransposeUVWx16_C; 
     240#else 
     241  void (*TransposeUVWx8)(const uint8* src, int src_stride, uint8* dst_a, 
     242                         int dst_stride_a, uint8* dst_b, int dst_stride_b, 
    192243                         int width) = TransposeUVWx8_C; 
     244#endif 
    193245#if defined(HAS_TRANSPOSEUVWX8_NEON) 
    194246  if (TestCpuFlag(kCpuHasNEON)) { 
     
    205257#endif 
    206258#if defined(HAS_TRANSPOSEUVWX8_DSPR2) 
    207   if (TestCpuFlag(kCpuHasDSPR2) && IS_ALIGNED(width, 2) && 
    208       IS_ALIGNED(src, 4) && IS_ALIGNED(src_stride, 4)) { 
     259  if (TestCpuFlag(kCpuHasDSPR2) && IS_ALIGNED(width, 2) && IS_ALIGNED(src, 4) && 
     260      IS_ALIGNED(src_stride, 4)) { 
    209261    TransposeUVWx8 = TransposeUVWx8_DSPR2; 
    210262  } 
    211263#endif 
    212  
     264#if defined(HAS_TRANSPOSEUVWX16_MSA) 
     265  if (TestCpuFlag(kCpuHasMSA)) { 
     266    TransposeUVWx16 = TransposeUVWx16_Any_MSA; 
     267    if (IS_ALIGNED(width, 8)) { 
     268      TransposeUVWx16 = TransposeUVWx16_MSA; 
     269    } 
     270  } 
     271#endif 
     272 
     273#if defined(HAS_TRANSPOSEUVWX16_MSA) 
     274  // Work through the source in 8x8 tiles. 
     275  while (i >= 16) { 
     276    TransposeUVWx16(src, src_stride, dst_a, dst_stride_a, dst_b, dst_stride_b, 
     277                    width); 
     278    src += 16 * src_stride;  // Go down 16 rows. 
     279    dst_a += 16;             // Move over 8 columns. 
     280    dst_b += 16;             // Move over 8 columns. 
     281    i -= 16; 
     282  } 
     283#else 
    213284  // Work through the source in 8x8 tiles. 
    214285  while (i >= 8) { 
    215     TransposeUVWx8(src, src_stride, 
    216                    dst_a, dst_stride_a, 
    217                    dst_b, dst_stride_b, 
     286    TransposeUVWx8(src, src_stride, dst_a, dst_stride_a, dst_b, dst_stride_b, 
    218287                   width); 
    219     src += 8 * src_stride;    // Go down 8 rows. 
    220     dst_a += 8;               // Move over 8 columns. 
    221     dst_b += 8;               // Move over 8 columns. 
     288    src += 8 * src_stride;  // Go down 8 rows. 
     289    dst_a += 8;             // Move over 8 columns. 
     290    dst_b += 8;             // Move over 8 columns. 
    222291    i -= 8; 
    223292  } 
     293#endif 
    224294 
    225295  if (i > 0) { 
    226     TransposeUVWxH_C(src, src_stride, 
    227                      dst_a, dst_stride_a, 
    228                      dst_b, dst_stride_b, 
     296    TransposeUVWxH_C(src, src_stride, dst_a, dst_stride_a, dst_b, dst_stride_b, 
    229297                     width, i); 
    230298  } 
     
    232300 
    233301LIBYUV_API 
    234 void RotateUV90(const uint8* src, int src_stride, 
    235                 uint8* dst_a, int dst_stride_a, 
    236                 uint8* dst_b, int dst_stride_b, 
    237                 int width, int height) { 
     302void RotateUV90(const uint8* src, 
     303                int src_stride, 
     304                uint8* dst_a, 
     305                int dst_stride_a, 
     306                uint8* dst_b, 
     307                int dst_stride_b, 
     308                int width, 
     309                int height) { 
    238310  src += src_stride * (height - 1); 
    239311  src_stride = -src_stride; 
    240312 
    241   TransposeUV(src, src_stride, 
    242               dst_a, dst_stride_a, 
    243               dst_b, dst_stride_b, 
    244               width, height); 
    245 } 
    246  
    247 LIBYUV_API 
    248 void RotateUV270(const uint8* src, int src_stride, 
    249                  uint8* dst_a, int dst_stride_a, 
    250                  uint8* dst_b, int dst_stride_b, 
    251                  int width, int height) { 
     313  TransposeUV(src, src_stride, dst_a, dst_stride_a, dst_b, dst_stride_b, width, 
     314              height); 
     315} 
     316 
     317LIBYUV_API 
     318void RotateUV270(const uint8* src, 
     319                 int src_stride, 
     320                 uint8* dst_a, 
     321                 int dst_stride_a, 
     322                 uint8* dst_b, 
     323                 int dst_stride_b, 
     324                 int width, 
     325                 int height) { 
    252326  dst_a += dst_stride_a * (width - 1); 
    253327  dst_b += dst_stride_b * (width - 1); 
     
    255329  dst_stride_b = -dst_stride_b; 
    256330 
    257   TransposeUV(src, src_stride, 
    258               dst_a, dst_stride_a, 
    259               dst_b, dst_stride_b, 
    260               width, height); 
     331  TransposeUV(src, src_stride, dst_a, dst_stride_a, dst_b, dst_stride_b, width, 
     332              height); 
    261333} 
    262334 
    263335// Rotate 180 is a horizontal and vertical flip. 
    264336LIBYUV_API 
    265 void RotateUV180(const uint8* src, int src_stride, 
    266                  uint8* dst_a, int dst_stride_a, 
    267                  uint8* dst_b, int dst_stride_b, 
    268                  int width, int height) { 
     337void RotateUV180(const uint8* src, 
     338                 int src_stride, 
     339                 uint8* dst_a, 
     340                 int dst_stride_a, 
     341                 uint8* dst_b, 
     342                 int dst_stride_b, 
     343                 int width, 
     344                 int height) { 
    269345  int i; 
    270346  void (*MirrorUVRow)(const uint8* src, uint8* dst_u, uint8* dst_v, int width) = 
     
    281357#endif 
    282358#if defined(HAS_MIRRORUVROW_DSPR2) 
    283   if (TestCpuFlag(kCpuHasDSPR2) && 
    284       IS_ALIGNED(src, 4) && IS_ALIGNED(src_stride, 4)) { 
     359  if (TestCpuFlag(kCpuHasDSPR2) && IS_ALIGNED(src, 4) && 
     360      IS_ALIGNED(src_stride, 4)) { 
    285361    MirrorUVRow = MirrorUVRow_DSPR2; 
    286362  } 
     
    299375 
    300376LIBYUV_API 
    301 int RotatePlane(const uint8* src, int src_stride, 
    302                 uint8* dst, int dst_stride, 
    303                 int width, int height, 
     377int RotatePlane(const uint8* src, 
     378                int src_stride, 
     379                uint8* dst, 
     380                int dst_stride, 
     381                int width, 
     382                int height, 
    304383                enum RotationMode mode) { 
    305384  if (!src || width <= 0 || height == 0 || !dst) { 
     
    317396    case kRotate0: 
    318397      // copy frame 
    319       CopyPlane(src, src_stride, 
    320                 dst, dst_stride, 
    321                 width, height); 
     398      CopyPlane(src, src_stride, dst, dst_stride, width, height); 
    322399      return 0; 
    323400    case kRotate90: 
    324       RotatePlane90(src, src_stride, 
    325                     dst, dst_stride, 
    326                     width, height); 
     401      RotatePlane90(src, src_stride, dst, dst_stride, width, height); 
    327402      return 0; 
    328403    case kRotate270: 
    329       RotatePlane270(src, src_stride, 
    330                      dst, dst_stride, 
    331                      width, height); 
     404      RotatePlane270(src, src_stride, dst, dst_stride, width, height); 
    332405      return 0; 
    333406    case kRotate180: 
    334       RotatePlane180(src, src_stride, 
    335                      dst, dst_stride, 
    336                      width, height); 
     407      RotatePlane180(src, src_stride, dst, dst_stride, width, height); 
    337408      return 0; 
    338409    default: 
     
    343414 
    344415LIBYUV_API 
    345 int I420Rotate(const uint8* src_y, int src_stride_y, 
    346                const uint8* src_u, int src_stride_u, 
    347                const uint8* src_v, int src_stride_v, 
    348                uint8* dst_y, int dst_stride_y, 
    349                uint8* dst_u, int dst_stride_u, 
    350                uint8* dst_v, int dst_stride_v, 
    351                int width, int height, 
     416int I420Rotate(const uint8* src_y, 
     417               int src_stride_y, 
     418               const uint8* src_u, 
     419               int src_stride_u, 
     420               const uint8* src_v, 
     421               int src_stride_v, 
     422               uint8* dst_y, 
     423               int dst_stride_y, 
     424               uint8* dst_u, 
     425               int dst_stride_u, 
     426               uint8* dst_v, 
     427               int dst_stride_v, 
     428               int width, 
     429               int height, 
    352430               enum RotationMode mode) { 
    353431  int halfwidth = (width + 1) >> 1; 
    354432  int halfheight = (height + 1) >> 1; 
    355   if (!src_y || !src_u || !src_v || width <= 0 || height == 0 || 
    356       !dst_y || !dst_u || !dst_v) { 
     433  if (!src_y || !src_u || !src_v || width <= 0 || height == 0 || !dst_y || 
     434      !dst_u || !dst_v) { 
    357435    return -1; 
    358436  } 
     
    373451    case kRotate0: 
    374452      // copy frame 
    375       return I420Copy(src_y, src_stride_y, 
    376                       src_u, src_stride_u, 
    377                       src_v, src_stride_v, 
    378                       dst_y, dst_stride_y, 
    379                       dst_u, dst_stride_u, 
    380                       dst_v, dst_stride_v, 
    381                       width, height); 
     453      return I420Copy(src_y, src_stride_y, src_u, src_stride_u, src_v, 
     454                      src_stride_v, dst_y, dst_stride_y, dst_u, dst_stride_u, 
     455                      dst_v, dst_stride_v, width, height); 
    382456    case kRotate90: 
    383       RotatePlane90(src_y, src_stride_y, 
    384                     dst_y, dst_stride_y, 
    385                     width, height); 
    386       RotatePlane90(src_u, src_stride_u, 
    387                     dst_u, dst_stride_u, 
    388                     halfwidth, halfheight); 
    389       RotatePlane90(src_v, src_stride_v, 
    390                     dst_v, dst_stride_v, 
    391                     halfwidth, halfheight); 
     457      RotatePlane90(src_y, src_stride_y, dst_y, dst_stride_y, width, height); 
     458      RotatePlane90(src_u, src_stride_u, dst_u, dst_stride_u, halfwidth, 
     459                    halfheight); 
     460      RotatePlane90(src_v, src_stride_v, dst_v, dst_stride_v, halfwidth, 
     461                    halfheight); 
    392462      return 0; 
    393463    case kRotate270: 
    394       RotatePlane270(src_y, src_stride_y, 
    395                      dst_y, dst_stride_y, 
    396                      width, height); 
    397       RotatePlane270(src_u, src_stride_u, 
    398                      dst_u, dst_stride_u, 
    399                      halfwidth, halfheight); 
    400       RotatePlane270(src_v, src_stride_v, 
    401                      dst_v, dst_stride_v, 
    402                      halfwidth, halfheight); 
     464      RotatePlane270(src_y, src_stride_y, dst_y, dst_stride_y, width, height); 
     465      RotatePlane270(src_u, src_stride_u, dst_u, dst_stride_u, halfwidth, 
     466                     halfheight); 
     467      RotatePlane270(src_v, src_stride_v, dst_v, dst_stride_v, halfwidth, 
     468                     halfheight); 
    403469      return 0; 
    404470    case kRotate180: 
    405       RotatePlane180(src_y, src_stride_y, 
    406                      dst_y, dst_stride_y, 
    407                      width, height); 
    408       RotatePlane180(src_u, src_stride_u, 
    409                      dst_u, dst_stride_u, 
    410                      halfwidth, halfheight); 
    411       RotatePlane180(src_v, src_stride_v, 
    412                      dst_v, dst_stride_v, 
    413                      halfwidth, halfheight); 
     471      RotatePlane180(src_y, src_stride_y, dst_y, dst_stride_y, width, height); 
     472      RotatePlane180(src_u, src_stride_u, dst_u, dst_stride_u, halfwidth, 
     473                     halfheight); 
     474      RotatePlane180(src_v, src_stride_v, dst_v, dst_stride_v, halfwidth, 
     475                     halfheight); 
    414476      return 0; 
    415477    default: 
     
    420482 
    421483LIBYUV_API 
    422 int NV12ToI420Rotate(const uint8* src_y, int src_stride_y, 
    423                      const uint8* src_uv, int src_stride_uv, 
    424                      uint8* dst_y, int dst_stride_y, 
    425                      uint8* dst_u, int dst_stride_u, 
    426                      uint8* dst_v, int dst_stride_v, 
    427                      int width, int height, 
     484int NV12ToI420Rotate(const uint8* src_y, 
     485                     int src_stride_y, 
     486                     const uint8* src_uv, 
     487                     int src_stride_uv, 
     488                     uint8* dst_y, 
     489                     int dst_stride_y, 
     490                     uint8* dst_u, 
     491                     int dst_stride_u, 
     492                     uint8* dst_v, 
     493                     int dst_stride_v, 
     494                     int width, 
     495                     int height, 
    428496                     enum RotationMode mode) { 
    429497  int halfwidth = (width + 1) >> 1; 
    430498  int halfheight = (height + 1) >> 1; 
    431   if (!src_y || !src_uv || width <= 0 || height == 0 || 
    432       !dst_y || !dst_u || !dst_v) { 
     499  if (!src_y || !src_uv || width <= 0 || height == 0 || !dst_y || !dst_u || 
     500      !dst_v) { 
    433501    return -1; 
    434502  } 
     
    447515    case kRotate0: 
    448516      // copy frame 
    449       return NV12ToI420(src_y, src_stride_y, 
    450                         src_uv, src_stride_uv, 
    451                         dst_y, dst_stride_y, 
    452                         dst_u, dst_stride_u, 
    453                         dst_v, dst_stride_v, 
     517      return NV12ToI420(src_y, src_stride_y, src_uv, src_stride_uv, dst_y, 
     518                        dst_stride_y, dst_u, dst_stride_u, dst_v, dst_stride_v, 
    454519                        width, height); 
    455520    case kRotate90: 
    456       RotatePlane90(src_y, src_stride_y, 
    457                     dst_y, dst_stride_y, 
    458                     width, height); 
    459       RotateUV90(src_uv, src_stride_uv, 
    460                  dst_u, dst_stride_u, 
    461                  dst_v, dst_stride_v, 
    462                  halfwidth, halfheight); 
     521      RotatePlane90(src_y, src_stride_y, dst_y, dst_stride_y, width, height); 
     522      RotateUV90(src_uv, src_stride_uv, dst_u, dst_stride_u, dst_v, 
     523                 dst_stride_v, halfwidth, halfheight); 
    463524      return 0; 
    464525    case kRotate270: 
    465       RotatePlane270(src_y, src_stride_y, 
    466                      dst_y, dst_stride_y, 
    467                      width, height); 
    468       RotateUV270(src_uv, src_stride_uv, 
    469                   dst_u, dst_stride_u, 
    470                   dst_v, dst_stride_v, 
    471                   halfwidth, halfheight); 
     526      RotatePlane270(src_y, src_stride_y, dst_y, dst_stride_y, width, height); 
     527      RotateUV270(src_uv, src_stride_uv, dst_u, dst_stride_u, dst_v, 
     528                  dst_stride_v, halfwidth, halfheight); 
    472529      return 0; 
    473530    case kRotate180: 
    474       RotatePlane180(src_y, src_stride_y, 
    475                      dst_y, dst_stride_y, 
    476                      width, height); 
    477       RotateUV180(src_uv, src_stride_uv, 
    478                   dst_u, dst_stride_u, 
    479                   dst_v, dst_stride_v, 
    480                   halfwidth, halfheight); 
     531      RotatePlane180(src_y, src_stride_y, dst_y, dst_stride_y, width, height); 
     532      RotateUV180(src_uv, src_stride_uv, dst_u, dst_stride_u, dst_v, 
     533                  dst_stride_v, halfwidth, halfheight); 
    481534      return 0; 
    482535    default: 
Note: See TracChangeset for help on using the changeset viewer.