Added support for calling sampling functions via pointers.

Change-Id: Ic4d72e6b175a6b27bcdcc8cd97828e44ea93e743
This commit is contained in:
Djordje Pesut 2014-01-25 18:12:09 +01:00
parent d16c69749b
commit 53520911c3
3 changed files with 28 additions and 17 deletions

View File

@ -553,8 +553,8 @@ static int CustomSetup(VP8Io* io) {
} else {
if (is_rgb) {
p->emit = EmitSampledRGB; // default
#ifdef FANCY_UPSAMPLING
if (io->fancy_upsampling) {
#ifdef FANCY_UPSAMPLING
const int uv_width = (io->mb_w + 1) >> 1;
p->memory = malloc(io->mb_w + 2 * uv_width);
if (p->memory == NULL) {
@ -565,8 +565,10 @@ static int CustomSetup(VP8Io* io) {
p->tmp_v = p->tmp_u + uv_width;
p->emit = EmitFancyRGB;
WebPInitUpsamplers();
}
#endif
} else {
WebPInitSamplers();
}
} else {
p->emit = EmitYUV;
}

View File

@ -186,7 +186,8 @@ typedef void (*WebPSampleLinePairFunc)(
const uint8_t* u, const uint8_t* v,
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.
// '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
void WebPInitUpsamplers(void);
void WebPInitSamplers(void);
//------------------------------------------------------------------------------
// Pre-multiply planes with alpha values

View File

@ -109,6 +109,9 @@ UPSAMPLE_FUNC(UpsampleRgb565LinePair, VP8YuvToRgb565, 2)
//------------------------------------------------------------------------------
// simple point-sampling
WebPSampleLinePairFunc WebPSamplers[MODE_LAST];
#define SAMPLE_FUNC(FUNC_NAME, FUNC, XSTEP) \
static void FUNC_NAME(const uint8_t* top_y, const uint8_t* bottom_y, \
const uint8_t* u, const uint8_t* v, \
@ -143,20 +146,6 @@ SAMPLE_FUNC(SampleRgb565LinePair, VP8YuvToRgb565, 2)
#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)
@ -339,6 +328,24 @@ void WebPInitUpsamplers(void) {
#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) {
WebPApplyAlphaMultiply = ApplyAlphaMultiply;
WebPApplyAlphaMultiply4444 = ApplyAlphaMultiply4444;