mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-17 22:39:52 +02:00
add automatic YUVA/ARGB conversion during WebPEncode()
Adds new methods WebPPictureARGBToYUVA() and WebPPictureYUVAToARGB() Depending on the value of picture->use_argb_input, the main call WebPEncode() will convert appropriately. Note that both conversions are lossy, so it's recommended to: * use YUVA input for lossy compression (picture->use_argb_input=0) * use ARGB input for lossless compression (picture->use_argb_input=1) Change-Id: I8269d607723ee8a1136b9f4999f7ff4e657bbb04
This commit is contained in:
@ -156,6 +156,48 @@ const WebPSampleLinePairFunc WebPSamplers[MODE_LAST] = {
|
||||
SampleRgba4444LinePair // MODE_rgbA_4444
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if !defined(FANCY_UPSAMPLING)
|
||||
#define DUAL_SAMPLE_FUNC(FUNC_NAME, FUNC) \
|
||||
static void FUNC_NAME(const uint8_t* top_y, const uint8_t* bot_y, \
|
||||
const uint8_t* top_u, const uint8_t* top_v, \
|
||||
const uint8_t* bot_u, const uint8_t* bot_v, \
|
||||
uint8_t* top_dst, uint8_t* bot_dst, int len) { \
|
||||
const int half_len = len >> 1; \
|
||||
int x; \
|
||||
if (top_dst != NULL) { \
|
||||
for (x = 0; x < half_len; ++x) { \
|
||||
FUNC(top_y[2 * x + 0], top_u[x], top_v[x], top_dst + 8 * x + 0); \
|
||||
FUNC(top_y[2 * x + 1], top_u[x], top_v[x], top_dst + 8 * x + 4); \
|
||||
} \
|
||||
if (len & 1) FUNC(top_y[2 * x + 0], top_u[x], top_v[x], top_dst + 8 * x); \
|
||||
} \
|
||||
if (bot_dst != NULL) { \
|
||||
for (x = 0; x < half_len; ++x) { \
|
||||
FUNC(bot_y[2 * x + 0], bot_u[x], bot_v[x], bot_dst + 8 * x + 0); \
|
||||
FUNC(bot_y[2 * x + 1], bot_u[x], bot_v[x], bot_dst + 8 * x + 4); \
|
||||
} \
|
||||
if (len & 1) FUNC(bot_y[2 * x + 0], bot_u[x], bot_v[x], bot_dst + 8 * x); \
|
||||
} \
|
||||
}
|
||||
|
||||
DUAL_SAMPLE_FUNC(DualLineSamplerBGRA, VP8YuvToBgra)
|
||||
DUAL_SAMPLE_FUNC(DualLineSamplerARGB, VP8YuvToArgb)
|
||||
#undef DUAL_SAMPLE_FUNC
|
||||
|
||||
#endif // !FANCY_UPSAMPLING
|
||||
|
||||
WebPUpsampleLinePairFunc WebPGetLinePairConverter(int alpha_is_last) {
|
||||
WebPInitUpsamplers();
|
||||
VP8YUVInit();
|
||||
#ifdef FANCY_UPSAMPLING
|
||||
return WebPUpsamplers[alpha_is_last ? MODE_BGRA : MODE_ARGB];
|
||||
#else
|
||||
return (alpha_is_last ? DualLineSamplerBGRA : DualLineSamplerARGB);
|
||||
#endif
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// YUV444 converter
|
||||
|
||||
|
Reference in New Issue
Block a user