// Copyright 2013 Google Inc. All Rights Reserved. // // Use of this source code is governed by a BSD-style license // that can be found in the COPYING file in the root of the source // tree. An additional intellectual property rights grant can be found // in the file PATENTS. All contributing project authors may // be found in the AUTHORS file in the root of the source tree. // ----------------------------------------------------------------------------- // // Implement gradient smoothing: we replace a current alpha value by its // surrounding average if it's close enough (that is: the change will be less // than the minimum distance between two quantized level). // We use sliding window for computing the 2d moving average. // // Author: Skal ([email protected]) #include "src/utils/quant_levels_dec_utils.h" #include <string.h> // for memset #include "src/utils/utils.h" // #define USE_DITHERING // uncomment to enable ordered dithering (not vital) #define FIX … #define LFIX … #define LUT_SIZE … #if defined(USE_DITHERING) #define DFIX … #define DSIZE … // cf. https://en.wikipedia.org/wiki/Ordered_dithering static const uint8_t kOrderedDither[DSIZE][DSIZE] = { { 0, 8, 2, 10 }, // coefficients are in DFIX fixed-point precision { 12, 4, 14, 6 }, { 3, 11, 1, 9 }, { 15, 7, 13, 5 } }; #else #define DFIX … #endif SmoothParams; //------------------------------------------------------------------------------ #define CLIP_8b_MASK … static WEBP_INLINE uint8_t clip_8b(int v) { … } #undef CLIP_8b_MASK // vertical accumulation static void VFilter(SmoothParams* const p) { … } // horizontal accumulation. We use mirror replication of missing pixels, as it's // a little easier to implement (surprisingly). static void HFilter(SmoothParams* const p) { … } // emit one filtered output row static void ApplyFilter(SmoothParams* const p) { … } //------------------------------------------------------------------------------ // Initialize correction table static void InitCorrectionLUT(int16_t* const lut, int min_dist) { … } static void CountLevels(SmoothParams* const p) { … } // Initialize all params. static int InitParams(uint8_t* const data, int width, int height, int stride, int radius, SmoothParams* const p) { … } static void CleanupParams(SmoothParams* const p) { … } int WebPDequantizeLevels(uint8_t* const data, int width, int height, int stride, int strength) { … }