third_party/libyuv/source/planar_functions.cc
// Convert I422 to RGBA with matrix
Convert I422 to RGBA with matrix
Convert I422 to RGBA with matrix
static int I422ToRGBAMatrix(const uint8_t* src_y,
                            int src_stride_y,
                            const uint8_t* src_u,
                            int src_stride_u,
                            const uint8_t* src_v,
                            int src_stride_v,
                            uint8_t* dst_rgba,
                            int dst_stride_rgba,
                            const struct YuvConstants* yuvconstants,
                            int width,
                            int height) {
  int y;
  void (*I422ToRGBARow)(const uint8_t* y_buf, const uint8_t* u_buf,
                        const uint8_t* v_buf, uint8_t* rgb_buf,
                        const struct YuvConstants* yuvconstants, int width) =
      I422ToRGBARow_C;
  if (!src_y || !src_u || !src_v || !dst_rgba || width <= 0 || height == 0) {
    return -1;
  }
  if (height < 0) {
    height = -height;
    dst_rgba = dst_rgba + (height - 1) * dst_stride_rgba;
    dst_stride_rgba = -dst_stride_rgba;
  }
#if defined(HAS_I422TORGBAROW_SSSE3)
  if (TestCpuFlag(kCpuHasSSSE3)) {
    I422ToRGBARow = I422ToRGBARow_Any_SSSE3;
    if (IS_ALIGNED(width, 8)) {
      I422ToRGBARow = I422ToRGBARow_SSSE3;
    }
  }
#endif
#if defined(HAS_I422TORGBAROW_AVX2)
  if (TestCpuFlag(kCpuHasAVX2)) {
    I422ToRGBARow = I422ToRGBARow_Any_AVX2;
    if (IS_ALIGNED(width, 16)) {
      I422ToRGBARow = I422ToRGBARow_AVX2;
    }
  }
#endif
#if defined(HAS_I422TORGBAROW_NEON)
  if (TestCpuFlag(kCpuHasNEON)) {
    I422ToRGBARow = I422ToRGBARow_Any_NEON;
    if (IS_ALIGNED(width, 8)) {
      I422ToRGBARow = I422ToRGBARow_NEON;
    }
  }
#endif
#if defined(HAS_I422TORGBAROW_MSA)
  if (TestCpuFlag(kCpuHasMSA)) {
    I422ToRGBARow = I422ToRGBARow_Any_MSA;
    if (IS_ALIGNED(width, 8)) {
      I422ToRGBARow = I422ToRGBARow_MSA;
    }
  }
#endif
  for (y = 0; y < height; ++y) {
    I422ToRGBARow(src_y, src_u, src_v, dst_rgba, yuvconstants, width);
    dst_rgba += dst_stride_rgba;
    src_y += src_stride_y;
    src_u += src_stride_u;
    src_v += src_stride_v;
  }
  return 0;
}
static int I422ToRGBAMatrix ( const uint8_t * src_y , int src_stride_y , const uint8_t * src_u , int src_stride_u , const uint8_t * src_v , int src_stride_v , uint8_t * dst_rgba , int dst_stride_rgba , const struct YuvConstants * yuvconstants , int width , int height ) { int y ; void ( * I422ToRGBARow ) ( const uint8_t * y_buf , const uint8_t * u_buf , const uint8_t * v_buf , uint8_t * rgb_buf , const struct YuvConstants * yuvconstants , int width ) = I422ToRGBARow_C ; if ( ! src_y || ! src_u || ! src_v || ! dst_rgba || width <= 0 || height == 0 ) { return -1 ; } if ( height < 0 ) { height = - height ; dst_rgba = dst_rgba + ( height - 1 ) * dst_stride_rgba ; dst_stride_rgba = - dst_stride_rgba ; } #if defined ( HAS_I422TORGBAROW_SSSE3 ) if ( TestCpuFlag ( kCpuHasSSSE3 ) ) { I422ToRGBARow = I422ToRGBARow_Any_SSSE3 ; if ( IS_ALIGNED ( width , 8 ) ) { I422ToRGBARow = I422ToRGBARow_SSSE3 ; } } #endif #if defined ( HAS_I422TORGBAROW_AVX2 ) if ( TestCpuFlag ( kCpuHasAVX2 ) ) { I422ToRGBARow = I422ToRGBARow_Any_AVX2 ; if ( IS_ALIGNED ( width , 16 ) ) { I422ToRGBARow = I422ToRGBARow_AVX2 ; } } #endif #if defined ( HAS_I422TORGBAROW_NEON ) if ( TestCpuFlag ( kCpuHasNEON ) ) { I422ToRGBARow = I422ToRGBARow_Any_NEON ; if ( IS_ALIGNED ( width , 8 ) ) { I422ToRGBARow = I422ToRGBARow_NEON ; } } #endif #if defined ( HAS_I422TORGBAROW_MSA ) if ( TestCpuFlag ( kCpuHasMSA ) ) { I422ToRGBARow = I422ToRGBARow_Any_MSA ; if ( IS_ALIGNED ( width , 8 ) ) { I422ToRGBARow = I422ToRGBARow_MSA ; } } #endif for ( y = 0 ; y < height ; ++ y ) { I422ToRGBARow ( src_y , src_u , src_v , dst_rgba , yuvconstants , width ) ; dst_rgba += dst_stride_rgba ; src_y += src_stride_y ; src_u += src_stride_u ; src_v += src_stride_v ; } return 0 ; }
Convert I422 to RGBA with matrix
Convert I422 to RGBA with matrix
// Negative height means invert the image.