// Copyright 2014 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. // ----------------------------------------------------------------------------- // // Near-lossless image preprocessing adjusts pixel values to help // compressibility with a guarantee of maximum deviation between original and // resulting pixel values. // // Author: Jyrki Alakuijala ([email protected]) // Converted to C by Aleksander Kramarz ([email protected]) #include <assert.h> #include <stdlib.h> #include "src/dsp/lossless_common.h" #include "src/utils/utils.h" #include "src/enc/vp8li_enc.h" #if (WEBP_NEAR_LOSSLESS == 1) #define MIN_DIM_FOR_NEAR_LOSSLESS … #define MAX_LIMIT_BITS … // Quantizes the value up or down to a multiple of 1<<bits (or to 255), // choosing the closer one, resolving ties using bankers' rounding. static uint32_t FindClosestDiscretized(uint32_t a, int bits) { … } // Applies FindClosestDiscretized to all channels of pixel. static uint32_t ClosestDiscretizedArgb(uint32_t a, int bits) { … } // Checks if distance between corresponding channel values of pixels a and b // is within the given limit. static int IsNear(uint32_t a, uint32_t b, int limit) { … } static int IsSmooth(const uint32_t* const prev_row, const uint32_t* const curr_row, const uint32_t* const next_row, int ix, int limit) { … } // Adjusts pixel values of image with given maximum error. static void NearLossless(int xsize, int ysize, const uint32_t* argb_src, int stride, int limit_bits, uint32_t* copy_buffer, uint32_t* argb_dst) { … } int VP8ApplyNearLossless(const WebPPicture* const picture, int quality, uint32_t* const argb_dst) { … } #else // (WEBP_NEAR_LOSSLESS == 1) // Define a stub to suppress compiler warnings. extern void VP8LNearLosslessStub(void); void VP8LNearLosslessStub(void) {} #endif // (WEBP_NEAR_LOSSLESS == 1)