mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-28 14:38:21 +01:00
Added support for calling sampling functions via pointers.
Change-Id: Ic4d72e6b175a6b27bcdcc8cd97828e44ea93e743
This commit is contained in:
parent
d16c69749b
commit
53520911c3
@ -553,8 +553,8 @@ static int CustomSetup(VP8Io* io) {
|
|||||||
} else {
|
} else {
|
||||||
if (is_rgb) {
|
if (is_rgb) {
|
||||||
p->emit = EmitSampledRGB; // default
|
p->emit = EmitSampledRGB; // default
|
||||||
#ifdef FANCY_UPSAMPLING
|
|
||||||
if (io->fancy_upsampling) {
|
if (io->fancy_upsampling) {
|
||||||
|
#ifdef FANCY_UPSAMPLING
|
||||||
const int uv_width = (io->mb_w + 1) >> 1;
|
const int uv_width = (io->mb_w + 1) >> 1;
|
||||||
p->memory = malloc(io->mb_w + 2 * uv_width);
|
p->memory = malloc(io->mb_w + 2 * uv_width);
|
||||||
if (p->memory == NULL) {
|
if (p->memory == NULL) {
|
||||||
@ -565,8 +565,10 @@ static int CustomSetup(VP8Io* io) {
|
|||||||
p->tmp_v = p->tmp_u + uv_width;
|
p->tmp_v = p->tmp_u + uv_width;
|
||||||
p->emit = EmitFancyRGB;
|
p->emit = EmitFancyRGB;
|
||||||
WebPInitUpsamplers();
|
WebPInitUpsamplers();
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
} else {
|
||||||
|
WebPInitSamplers();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
p->emit = EmitYUV;
|
p->emit = EmitYUV;
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,8 @@ typedef void (*WebPSampleLinePairFunc)(
|
|||||||
const uint8_t* u, const uint8_t* v,
|
const uint8_t* u, const uint8_t* v,
|
||||||
uint8_t* top_dst, uint8_t* bottom_dst, int len);
|
uint8_t* top_dst, uint8_t* bottom_dst, int len);
|
||||||
|
|
||||||
extern const WebPSampleLinePairFunc WebPSamplers[/* MODE_LAST */];
|
// Sampling functions to convert YUV to RGB(A) modes
|
||||||
|
extern WebPSampleLinePairFunc WebPSamplers[/* MODE_LAST */];
|
||||||
|
|
||||||
// General function for converting two lines of ARGB or RGBA.
|
// General function for converting two lines of ARGB or RGBA.
|
||||||
// 'alpha_is_last' should be true if 0xff000000 is stored in memory as
|
// 'alpha_is_last' should be true if 0xff000000 is stored in memory as
|
||||||
@ -202,6 +203,7 @@ extern const WebPYUV444Converter WebPYUV444Converters[/* MODE_LAST */];
|
|||||||
|
|
||||||
// Main function to be called
|
// Main function to be called
|
||||||
void WebPInitUpsamplers(void);
|
void WebPInitUpsamplers(void);
|
||||||
|
void WebPInitSamplers(void);
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Pre-multiply planes with alpha values
|
// Pre-multiply planes with alpha values
|
||||||
|
@ -109,6 +109,9 @@ UPSAMPLE_FUNC(UpsampleRgb565LinePair, VP8YuvToRgb565, 2)
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// simple point-sampling
|
// simple point-sampling
|
||||||
|
|
||||||
|
|
||||||
|
WebPSampleLinePairFunc WebPSamplers[MODE_LAST];
|
||||||
|
|
||||||
#define SAMPLE_FUNC(FUNC_NAME, FUNC, XSTEP) \
|
#define SAMPLE_FUNC(FUNC_NAME, FUNC, XSTEP) \
|
||||||
static void FUNC_NAME(const uint8_t* top_y, const uint8_t* bottom_y, \
|
static void FUNC_NAME(const uint8_t* top_y, const uint8_t* bottom_y, \
|
||||||
const uint8_t* u, const uint8_t* v, \
|
const uint8_t* u, const uint8_t* v, \
|
||||||
@ -143,20 +146,6 @@ SAMPLE_FUNC(SampleRgb565LinePair, VP8YuvToRgb565, 2)
|
|||||||
|
|
||||||
#undef SAMPLE_FUNC
|
#undef SAMPLE_FUNC
|
||||||
|
|
||||||
const WebPSampleLinePairFunc WebPSamplers[MODE_LAST] = {
|
|
||||||
SampleRgbLinePair, // MODE_RGB
|
|
||||||
SampleRgbaLinePair, // MODE_RGBA
|
|
||||||
SampleBgrLinePair, // MODE_BGR
|
|
||||||
SampleBgraLinePair, // MODE_BGRA
|
|
||||||
SampleArgbLinePair, // MODE_ARGB
|
|
||||||
SampleRgba4444LinePair, // MODE_RGBA_4444
|
|
||||||
SampleRgb565LinePair, // MODE_RGB_565
|
|
||||||
SampleRgbaLinePair, // MODE_rgbA
|
|
||||||
SampleBgraLinePair, // MODE_bgrA
|
|
||||||
SampleArgbLinePair, // MODE_Argb
|
|
||||||
SampleRgba4444LinePair // MODE_rgbA_4444
|
|
||||||
};
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
#if !defined(FANCY_UPSAMPLING)
|
#if !defined(FANCY_UPSAMPLING)
|
||||||
@ -339,6 +328,24 @@ void WebPInitUpsamplers(void) {
|
|||||||
#endif // FANCY_UPSAMPLING
|
#endif // FANCY_UPSAMPLING
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebPInitSamplers(void) {
|
||||||
|
WebPSamplers[MODE_RGB] = SampleRgbLinePair;
|
||||||
|
WebPSamplers[MODE_RGBA] = SampleRgbaLinePair;
|
||||||
|
WebPSamplers[MODE_BGR] = SampleBgrLinePair;
|
||||||
|
WebPSamplers[MODE_BGRA] = SampleBgraLinePair;
|
||||||
|
WebPSamplers[MODE_ARGB] = SampleArgbLinePair;
|
||||||
|
WebPSamplers[MODE_RGBA_4444] = SampleRgba4444LinePair;
|
||||||
|
WebPSamplers[MODE_RGB_565] = SampleRgb565LinePair;
|
||||||
|
WebPSamplers[MODE_rgbA] = SampleRgbaLinePair;
|
||||||
|
WebPSamplers[MODE_bgrA] = SampleBgraLinePair;
|
||||||
|
WebPSamplers[MODE_Argb] = SampleArgbLinePair;
|
||||||
|
WebPSamplers[MODE_rgbA_4444] = SampleRgba4444LinePair;
|
||||||
|
|
||||||
|
// If defined, use CPUInfo() to overwrite some pointers with faster versions.
|
||||||
|
if (VP8GetCPUInfo != NULL) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WebPInitPremultiply(void) {
|
void WebPInitPremultiply(void) {
|
||||||
WebPApplyAlphaMultiply = ApplyAlphaMultiply;
|
WebPApplyAlphaMultiply = ApplyAlphaMultiply;
|
||||||
WebPApplyAlphaMultiply4444 = ApplyAlphaMultiply4444;
|
WebPApplyAlphaMultiply4444 = ApplyAlphaMultiply4444;
|
||||||
|
Loading…
Reference in New Issue
Block a user