move static initialization of WebPYUV444Converters[] to the Init function.

Split initialization of YUV444Converters[] out of Upsamplers init.

update test for NULL function pointers

Change-Id: I9603f54250f90c85a12ffbecfd6c59e9b06c47e0
This commit is contained in:
skal 2014-08-27 07:55:34 -07:00
parent 49911d4df2
commit e6c4b52f28
4 changed files with 55 additions and 34 deletions

View File

@ -516,6 +516,7 @@ static int InitRGBRescaler(const VP8Io* const io, WebPDecParams* const p) {
io->mb_w, 2 * out_width, io->mb_h, 2 * out_height,
work + 2 * work_size);
p->emit = EmitRescaledRGB;
WebPInitYUV444Converters();
if (has_alpha) {
WebPRescalerInit(&p->scaler_a, io->mb_w, io->mb_h,

View File

@ -243,6 +243,8 @@ extern WebPYUV444Converter WebPYUV444Converters[/* MODE_LAST */];
void WebPInitUpsamplers(void);
// Must be called before using WebPSamplers[]
void WebPInitSamplers(void);
// Must be called before using WebPYUV444Converters[]
void WebPInitYUV444Converters(void);
//------------------------------------------------------------------------------
// Utilities for processing transparent channel.

View File

@ -169,19 +169,31 @@ YUV444_FUNC(Yuv444ToRgb565, VP8YuvToRgb565, 2)
#undef YUV444_FUNC
WebPYUV444Converter WebPYUV444Converters[MODE_LAST] = {
Yuv444ToRgb, // MODE_RGB
Yuv444ToRgba, // MODE_RGBA
Yuv444ToBgr, // MODE_BGR
Yuv444ToBgra, // MODE_BGRA
Yuv444ToArgb, // MODE_ARGB
Yuv444ToRgba4444, // MODE_RGBA_4444
Yuv444ToRgb565, // MODE_RGB_565
Yuv444ToRgba, // MODE_rgbA
Yuv444ToBgra, // MODE_bgrA
Yuv444ToArgb, // MODE_Argb
Yuv444ToRgba4444 // MODE_rgbA_4444
};
WebPYUV444Converter WebPYUV444Converters[MODE_LAST];
extern void WebPInitYUV444ConvertersMIPSdspR2(void);
void WebPInitYUV444Converters(void) {
WebPYUV444Converters[MODE_RGB] = Yuv444ToRgb;
WebPYUV444Converters[MODE_RGBA] = Yuv444ToRgba;
WebPYUV444Converters[MODE_BGR] = Yuv444ToBgr;
WebPYUV444Converters[MODE_BGRA] = Yuv444ToBgra;
WebPYUV444Converters[MODE_ARGB] = Yuv444ToArgb;
WebPYUV444Converters[MODE_RGBA_4444] = Yuv444ToRgba4444;
WebPYUV444Converters[MODE_RGB_565] = Yuv444ToRgb565;
WebPYUV444Converters[MODE_rgbA] = Yuv444ToRgba;
WebPYUV444Converters[MODE_bgrA] = Yuv444ToBgra;
WebPYUV444Converters[MODE_Argb] = Yuv444ToArgb;
WebPYUV444Converters[MODE_rgbA_4444] = Yuv444ToRgba4444;
if (VP8GetCPUInfo != NULL) {
#if defined(WEBP_USE_MIPS_DSP_R2)
if (VP8GetCPUInfo(kMIPSdspR2)) {
WebPInitYUV444ConvertersMIPSdspR2();
}
#endif
}
}
//------------------------------------------------------------------------------
// Main calls
@ -216,16 +228,13 @@ void WebPInitUpsamplers(void) {
WebPInitUpsamplersNEON();
}
#endif
}
#endif // FANCY_UPSAMPLING
if (VP8GetCPUInfo != NULL) {
#if defined(WEBP_USE_MIPS_DSP_R2)
if (VP8GetCPUInfo(kMIPSdspR2)) {
WebPInitUpsamplersMIPSdspR2();
}
#endif
}
#endif // FANCY_UPSAMPLING
}
//------------------------------------------------------------------------------

View File

@ -213,9 +213,33 @@ UPSAMPLE_FUNC(UpsampleRgb565LinePair, YuvToRgb565, 2)
#endif // FANCY_UPSAMPLING
#endif // WEBP_USE_MIPS_DSP_R2
extern void WebPInitUpsamplersMIPSdspR2(void);
void WebPInitUpsamplersMIPSdspR2(void) {
#if defined(WEBP_USE_MIPS_DSP_R2)
#ifdef FANCY_UPSAMPLING
WebPUpsamplers[MODE_RGB] = UpsampleRgbLinePair;
WebPUpsamplers[MODE_RGBA] = UpsampleRgbaLinePair;
WebPUpsamplers[MODE_BGR] = UpsampleBgrLinePair;
WebPUpsamplers[MODE_BGRA] = UpsampleBgraLinePair;
WebPUpsamplers[MODE_ARGB] = UpsampleArgbLinePair;
WebPUpsamplers[MODE_RGBA_4444] = UpsampleRgba4444LinePair;
WebPUpsamplers[MODE_RGB_565] = UpsampleRgb565LinePair;
WebPUpsamplers[MODE_rgbA] = UpsampleRgbaLinePair;
WebPUpsamplers[MODE_bgrA] = UpsampleBgraLinePair;
WebPUpsamplers[MODE_Argb] = UpsampleArgbLinePair;
WebPUpsamplers[MODE_rgbA_4444] = UpsampleRgba4444LinePair;
#endif // FANCY_UPSAMPLING
#endif // WEBP_USE_MIPS_DSP_R2
}
//------------------------------------------------------------------------------
// YUV444 converter
#if defined(WEBP_USE_MIPS_DSP_R2)
#define YUV444_FUNC(FUNC_NAME, FUNC, XSTEP) \
static void FUNC_NAME(const uint8_t* y, const uint8_t* u, const uint8_t* v, \
uint8_t* dst, int len) { \
@ -235,25 +259,10 @@ YUV444_FUNC(Yuv444ToRgb565, YuvToRgb565, 2)
#endif // WEBP_USE_MIPS_DSP_R2
//------------------------------------------------------------------------------
extern void WebPInitYUV444ConvertersMIPSdspR2(void);
extern void WebPInitUpsamplersMIPSdspR2(void);
void WebPInitUpsamplersMIPSdspR2(void) {
void WebPInitYUV444ConvertersMIPSdspR2(void) {
#if defined(WEBP_USE_MIPS_DSP_R2)
#ifdef FANCY_UPSAMPLING
WebPUpsamplers[MODE_RGB] = UpsampleRgbLinePair;
WebPUpsamplers[MODE_RGBA] = UpsampleRgbaLinePair;
WebPUpsamplers[MODE_BGR] = UpsampleBgrLinePair;
WebPUpsamplers[MODE_BGRA] = UpsampleBgraLinePair;
WebPUpsamplers[MODE_ARGB] = UpsampleArgbLinePair;
WebPUpsamplers[MODE_RGBA_4444] = UpsampleRgba4444LinePair;
WebPUpsamplers[MODE_RGB_565] = UpsampleRgb565LinePair;
WebPUpsamplers[MODE_rgbA] = UpsampleRgbaLinePair;
WebPUpsamplers[MODE_bgrA] = UpsampleBgraLinePair;
WebPUpsamplers[MODE_Argb] = UpsampleArgbLinePair;
WebPUpsamplers[MODE_rgbA_4444] = UpsampleRgba4444LinePair;
#endif // FANCY_UPSAMPLING
WebPYUV444Converters[MODE_RGB] = Yuv444ToRgb;
WebPYUV444Converters[MODE_RGBA] = Yuv444ToRgba;
WebPYUV444Converters[MODE_BGR] = Yuv444ToBgr;