From e6c4b52f2892617fe7a5d19ff9b58a44e951dc87 Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 27 Aug 2014 07:55:34 -0700 Subject: [PATCH] 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 --- src/dec/io.c | 1 + src/dsp/dsp.h | 2 ++ src/dsp/upsampling.c | 43 +++++++++++++++++++------------- src/dsp/upsampling_mips_dsp_r2.c | 43 +++++++++++++++++++------------- 4 files changed, 55 insertions(+), 34 deletions(-) diff --git a/src/dec/io.c b/src/dec/io.c index 26b34820..623af93c 100644 --- a/src/dec/io.c +++ b/src/dec/io.c @@ -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, diff --git a/src/dsp/dsp.h b/src/dsp/dsp.h index 5c0be204..66e09488 100644 --- a/src/dsp/dsp.h +++ b/src/dsp/dsp.h @@ -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. diff --git a/src/dsp/upsampling.c b/src/dsp/upsampling.c index 5b938b0b..fd4b83ae 100644 --- a/src/dsp/upsampling.c +++ b/src/dsp/upsampling.c @@ -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 } //------------------------------------------------------------------------------ diff --git a/src/dsp/upsampling_mips_dsp_r2.c b/src/dsp/upsampling_mips_dsp_r2.c index 9bd108b1..fa8b3c13 100644 --- a/src/dsp/upsampling_mips_dsp_r2.c +++ b/src/dsp/upsampling_mips_dsp_r2.c @@ -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;