add missing WebPDecodeARGBInto() and switch ARGB4444 to RGBA4444 as was intended

This commit is contained in:
Pascal Massimino 2011-07-14 11:41:23 -07:00
parent cd7c5292e9
commit 78aeed4088
4 changed files with 27 additions and 19 deletions

View File

@ -99,13 +99,13 @@ UPSAMPLE_FUNC(UpsampleBgrLinePair, VP8YuvToBgr, 3)
UPSAMPLE_FUNC(UpsampleRgbaLinePair, VP8YuvToRgba, 4)
UPSAMPLE_FUNC(UpsampleBgraLinePair, VP8YuvToBgra, 4)
UPSAMPLE_FUNC(UpsampleArgbLinePair, VP8YuvToArgb, 4)
UPSAMPLE_FUNC(UpsampleArgb4444LinePair, VP8YuvToArgb4444, 2)
UPSAMPLE_FUNC(UpsampleRgba4444LinePair, VP8YuvToRgba4444, 2)
UPSAMPLE_FUNC(UpsampleRgb565LinePair, VP8YuvToRgb565, 2)
// These two don't erase the alpha value
UPSAMPLE_FUNC(UpsampleRgbKeepAlphaLinePair, VP8YuvToRgb, 4)
UPSAMPLE_FUNC(UpsampleBgrKeepAlphaLinePair, VP8YuvToBgr, 4)
UPSAMPLE_FUNC(UpsampleArgbKeepAlphaLinePair, VP8YuvToArgbKeepA, 4)
UPSAMPLE_FUNC(UpsampleArgb4444KeepAlphaLinePair, VP8YuvToArgb4444KeepA, 2)
UPSAMPLE_FUNC(UpsampleRgba4444KeepAlphaLinePair, VP8YuvToRgba4444KeepA, 2)
#undef LOAD_UV
#undef UPSAMPLE_FUNC
@ -120,7 +120,7 @@ static void InitUpsamplers(void) {
WebPUpsamplers[MODE_BGR] = UpsampleBgrLinePair;
WebPUpsamplers[MODE_BGRA] = UpsampleBgraLinePair;
WebPUpsamplers[MODE_ARGB] = UpsampleArgbLinePair;
WebPUpsamplers[MODE_ARGB_4444] = UpsampleArgb4444LinePair;
WebPUpsamplers[MODE_RGBA_4444] = UpsampleRgba4444LinePair;
WebPUpsamplers[MODE_RGB_565] = UpsampleRgb565LinePair;
WebPUpsamplersKeepAlpha[MODE_RGB] = UpsampleRgbLinePair;
@ -128,7 +128,7 @@ static void InitUpsamplers(void) {
WebPUpsamplersKeepAlpha[MODE_BGR] = UpsampleBgrLinePair;
WebPUpsamplersKeepAlpha[MODE_BGRA] = UpsampleBgrKeepAlphaLinePair;
WebPUpsamplersKeepAlpha[MODE_ARGB] = UpsampleArgbKeepAlphaLinePair;
WebPUpsamplersKeepAlpha[MODE_ARGB_4444] = UpsampleArgb4444KeepAlphaLinePair;
WebPUpsamplersKeepAlpha[MODE_RGBA_4444] = UpsampleRgba4444KeepAlphaLinePair;
WebPUpsamplersKeepAlpha[MODE_RGB_565] = UpsampleRgb565LinePair;
// If defined, use CPUInfo() to overwrite some pointers with faster versions.
@ -175,7 +175,7 @@ SAMPLE_FUNC(SampleBgrLinePair, VP8YuvToBgr, 3)
SAMPLE_FUNC(SampleRgbaLinePair, VP8YuvToRgba, 4)
SAMPLE_FUNC(SampleBgraLinePair, VP8YuvToBgra, 4)
SAMPLE_FUNC(SampleArgbLinePair, VP8YuvToArgb, 4)
SAMPLE_FUNC(SampleArgb4444LinePair, VP8YuvToArgb4444, 2)
SAMPLE_FUNC(SampleRgba4444LinePair, VP8YuvToRgba4444, 2)
SAMPLE_FUNC(SampleRgb565LinePair, VP8YuvToRgb565, 2)
#undef SAMPLE_FUNC
@ -192,7 +192,7 @@ static const SampleLinePairFunc kSamplers[MODE_LAST] = {
SampleBgrLinePair, // MODE_BGR
SampleBgraLinePair, // MODE_BGRA
SampleArgbLinePair, // MODE_ARGB
SampleArgb4444LinePair, // MODE_ARGB_4444
SampleRgba4444LinePair, // MODE_RGBA_4444
SampleRgb565LinePair // MODE_RGB_565
};
@ -211,7 +211,7 @@ YUV444_FUNC(Yuv444ToBgr, VP8YuvToBgr, 3)
YUV444_FUNC(Yuv444ToRgba, VP8YuvToRgba, 4)
YUV444_FUNC(Yuv444ToBgra, VP8YuvToBgra, 4)
YUV444_FUNC(Yuv444ToArgb, VP8YuvToArgb, 4)
YUV444_FUNC(Yuv444ToArgb4444, VP8YuvToArgb4444, 2)
YUV444_FUNC(Yuv444ToRgba4444, VP8YuvToRgba4444, 2)
YUV444_FUNC(Yuv444ToRgb565, VP8YuvToRgb565, 2)
#undef YUV444_FUNC
@ -225,7 +225,7 @@ static const YUV444Func kYUV444Converters[MODE_LAST] = {
Yuv444ToBgr, // MODE_BGR
Yuv444ToBgra, // MODE_BGRA
Yuv444ToArgb, // MODE_ARGB
Yuv444ToArgb4444, // MODE_ARGB_4444
Yuv444ToRgba4444, // MODE_RGBA_4444
Yuv444ToRgb565 // MODE_RGB_565
};
@ -539,7 +539,7 @@ static int EmitRescaledAlphaYUV(const VP8Io* const io, WebPDecParams* const p) {
static int IsAlphaMode(WEBP_CSP_MODE mode) {
return (mode == MODE_RGBA || mode == MODE_BGRA || mode == MODE_ARGB ||
mode == MODE_ARGB_4444 || mode == MODE_YUVA);
mode == MODE_RGBA_4444 || mode == MODE_YUVA);
}
static int InitYUVRescaler(const VP8Io* const io, WebPDecParams* const p) {

View File

@ -146,6 +146,11 @@ uint8_t* WebPDecodeRGBAInto(const uint8_t* data, uint32_t data_size,
return DecodeIntoRGBABuffer(MODE_RGBA, data, data_size, output, stride, size);
}
uint8_t* WebPDecodeARGBInto(const uint8_t* data, uint32_t data_size,
uint8_t* output, int size, int stride) {
return DecodeIntoRGBABuffer(MODE_ARGB, data, data_size, output, stride, size);
}
uint8_t* WebPDecodeBGRInto(const uint8_t* data, uint32_t data_size,
uint8_t* output, int size, int stride) {
return DecodeIntoRGBABuffer(MODE_BGR, data, data_size, output, stride, size);

View File

@ -60,21 +60,21 @@ static inline void VP8YuvToArgb(uint8_t y, uint8_t u, uint8_t v,
VP8YuvToArgbKeepA(y, u, v, argb);
}
static inline void VP8YuvToArgb4444KeepA(uint8_t y, uint8_t u, uint8_t v,
static inline void VP8YuvToRgba4444KeepA(uint8_t y, uint8_t u, uint8_t v,
uint8_t* const argb) {
const int r_off = VP8kVToR[v];
const int g_off = (VP8kVToG[v] + VP8kUToG[u]) >> YUV_FIX;
const int b_off = VP8kUToB[u];
// Don't update Aplha (first 4 bits of argb[0])
argb[0] = VP8kClip4Bits[y + r_off - YUV_RANGE_MIN];
argb[1] = ((VP8kClip[y + g_off - YUV_RANGE_MIN] & 0xf0) |
VP8kClip4Bits[y + b_off - YUV_RANGE_MIN]);
// Don't update Aplha (last 4 bits of argb[1])
argb[0] = ((VP8kClip4Bits[y + r_off - YUV_RANGE_MIN] << 4) |
VP8kClip4Bits[y + g_off - YUV_RANGE_MIN]);
argb[1] = (argb[1] & 0x0f) | (VP8kClip4Bits[y + b_off - YUV_RANGE_MIN] << 4);
}
static inline void VP8YuvToArgb4444(uint8_t y, uint8_t u, uint8_t v,
static inline void VP8YuvToRgba4444(uint8_t y, uint8_t u, uint8_t v,
uint8_t* const argb) {
argb[0] = 0xf0;
VP8YuvToArgb4444KeepA(y, u, v, argb);
argb[1] = 0x0f;
VP8YuvToRgba4444KeepA(y, u, v, argb);
}
static inline void VP8YuvToBgr(uint8_t y, uint8_t u, uint8_t v,

View File

@ -67,7 +67,7 @@ WEBP_EXTERN(uint8_t*) WebPDecodeYUV(const uint8_t* data, uint32_t data_size,
uint8_t** u, uint8_t** v,
int* stride, int* uv_stride);
// These three functions are variants of the above ones, that decode the image
// These five functions are variants of the above ones, that decode the image
// directly into a pre-allocated buffer 'output_buffer'. The maximum storage
// available in this buffer is indicated by 'output_buffer_size'. If this
// storage is not sufficient (or an error occurred), NULL is returned.
@ -81,6 +81,9 @@ WEBP_EXTERN(uint8_t*) WebPDecodeRGBInto(
WEBP_EXTERN(uint8_t*) WebPDecodeRGBAInto(
const uint8_t* data, uint32_t data_size,
uint8_t* output_buffer, int output_buffer_size, int output_stride);
WEBP_EXTERN(uint8_t*) WebPDecodeARGBInto(
const uint8_t* data, uint32_t data_size,
uint8_t* output_buffer, int output_buffer_size, int output_stride);
// BGR variants
WEBP_EXTERN(uint8_t*) WebPDecodeBGRInto(
const uint8_t* data, uint32_t data_size,
@ -108,7 +111,7 @@ WEBP_EXTERN(uint8_t*) WebPDecodeYUVInto(
// Colorspaces
typedef enum { MODE_RGB = 0, MODE_RGBA = 1,
MODE_BGR = 2, MODE_BGRA = 3,
MODE_ARGB = 4, MODE_ARGB_4444 = 5,
MODE_ARGB = 4, MODE_RGBA_4444 = 5,
MODE_RGB_565 = 6,
// YUV modes must come after RGB ones.
MODE_YUV = 7, MODE_YUVA = 8, // yuv 4:2:0