add colorspace for premultiplied alpha

The new modes are
       MODE_rgbA
       MODE_bgrA
       MODE_Argb
       MODE_rgbA_4444
It's binary incompatible, since the enums changed.

While at it, i removed the now unneeded KeepAlpha methods.
-> Saved ~12k of code!

* made explicit mention that alpha_plane is persistent,
so we have access to the full alpha plane data at all time.
Incremental decoding of alpha was planned for, but not
implemented. So better not dragged this constaint for now
and make the code easier until we revisit that.

Change-Id: Idaba281a6ca819965ca062d1c23329f36d90c7ff
This commit is contained in:
Pascal Massimino
2012-06-04 07:40:32 -07:00
parent 5f7bb3f53a
commit 48f827574e
13 changed files with 303 additions and 122 deletions

View File

@ -155,7 +155,6 @@ typedef void (*WebPUpsampleLinePairFunc)(
// Fancy upsampling functions to convert YUV to RGB(A) modes
extern WebPUpsampleLinePairFunc WebPUpsamplers[/* MODE_LAST */];
extern WebPUpsampleLinePairFunc WebPUpsamplersKeepAlpha[/* MODE_LAST */];
// Initializes SSE2 version of the fancy upsamplers.
void WebPInitUpsamplersSSE2(void);
@ -169,7 +168,6 @@ typedef void (*WebPSampleLinePairFunc)(
uint8_t* top_dst, uint8_t* bottom_dst, int len);
extern const WebPSampleLinePairFunc WebPSamplers[/* MODE_LAST */];
extern const WebPSampleLinePairFunc WebPSamplersKeepAlpha[/* MODE_LAST */];
// YUV444->RGB converters
typedef void (*WebPYUV444Converter)(const uint8_t* y,
@ -181,6 +179,23 @@ extern const WebPYUV444Converter WebPYUV444Converters[/* MODE_LAST */];
// Main function to be called
void WebPInitUpsamplers(void);
//------------------------------------------------------------------------------
// Pre-multiply planes with alpha values
// Apply alpha pre-multiply on an rgba, bgra or argb plane of size w * h.
// alpha_first should be 0 for argb, 1 for rgba or bgra (where alpha is last).
extern void (*WebPApplyAlphaMultiply)(
uint8_t* rgba, int alpha_first, int w, int h, int stride);
// Same, buf specifically for RGBA4444 format
extern void (*WebPApplyAlphaMultiply4444)(
uint8_t* rgba4444, int w, int h, int stride);
// To be called first before using the above.
void WebPInitPremultiply(void);
void WebPInitPremultiplySSE2(void); // should not be called directly.
//------------------------------------------------------------------------------
#if defined(__cplusplus) || defined(c_plusplus)