src/enc/picture_csp.c
static int PictureARGBToYUVA(WebPPicture* picture, WebPEncCSP colorspace,
                             float dithering, int use_iterative_conversion) {
  if (picture == NULL) return 0;
  if (picture->argb == NULL) {
    return WebPEncodingSetError(picture, VP8_ENC_ERROR_NULL_PARAMETER);
  } else if ((colorspace & WEBP_CSP_UV_MASK) != WEBP_YUV420) {
    return WebPEncodingSetError(picture, VP8_ENC_ERROR_INVALID_CONFIGURATION);
  } else {
    const uint8_t* const argb = (const uint8_t*)picture->argb;
    const uint8_t* const r = ALPHA_IS_LAST ? argb + 2 : argb + 1;
    const uint8_t* const g = ALPHA_IS_LAST ? argb + 1 : argb + 2;
    const uint8_t* const b = ALPHA_IS_LAST ? argb + 0 : argb + 3;
    const uint8_t* const a = ALPHA_IS_LAST ? argb + 3 : argb + 0;

    picture->colorspace = WEBP_YUV420;
    return ImportYUVAFromRGBA(r, g, b, a, 4, 4 * picture->argb_stride,
                              dithering, use_iterative_conversion, picture);
  }
}
//------------------------------------------------------------------------------
// call for ARGB->YUVA conversion
call for ARGB->YUVA conversion
call for ARGB - > YUVA conversion
static int PictureARGBToYUVA(WebPPicture* picture, WebPEncCSP colorspace,
                             float dithering, int use_iterative_conversion) {
  if (picture == NULL) return 0;
  if (picture->argb == NULL) {
    return WebPEncodingSetError(picture, VP8_ENC_ERROR_NULL_PARAMETER);
  } else if ((colorspace & WEBP_CSP_UV_MASK) != WEBP_YUV420) {
    return WebPEncodingSetError(picture, VP8_ENC_ERROR_INVALID_CONFIGURATION);
  } else {
    const uint8_t* const argb = (const uint8_t*)picture->argb;
    const uint8_t* const r = ALPHA_IS_LAST ? argb + 2 : argb + 1;
    const uint8_t* const g = ALPHA_IS_LAST ? argb + 1 : argb + 2;
    const uint8_t* const b = ALPHA_IS_LAST ? argb + 0 : argb + 3;
    const uint8_t* const a = ALPHA_IS_LAST ? argb + 3 : argb + 0;
    picture->colorspace = WEBP_YUV420;
    return ImportYUVAFromRGBA(r, g, b, a, 4, 4 * picture->argb_stride,
                              dithering, use_iterative_conversion, picture);
  }
}
static int PictureARGBToYUVA ( WebPPicture * picture , WebPEncCSP colorspace , float dithering , int use_iterative_conversion ) { if ( picture == NULL ) return 0 ; if ( picture -> argb == NULL ) { return WebPEncodingSetError ( picture , VP8_ENC_ERROR_NULL_PARAMETER ) ; } else if ( ( colorspace & WEBP_CSP_UV_MASK ) != WEBP_YUV420 ) { return WebPEncodingSetError ( picture , VP8_ENC_ERROR_INVALID_CONFIGURATION ) ; } else { const uint8_t * const argb = ( const uint8_t * ) picture -> argb ; const uint8_t * const r = ALPHA_IS_LAST ? argb + 2 : argb + 1 ; const uint8_t * const g = ALPHA_IS_LAST ? argb + 1 : argb + 2 ; const uint8_t * const b = ALPHA_IS_LAST ? argb + 0 : argb + 3 ; const uint8_t * const a = ALPHA_IS_LAST ? argb + 3 : argb + 0 ; picture -> colorspace = WEBP_YUV420 ; return ImportYUVAFromRGBA ( r , g , b , a , 4 , 4 * picture -> argb_stride , dithering , use_iterative_conversion , picture ) ; } }
call for ARGB->YUVA conversion
call for ARGB - > YUVA conversion