Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: third_party/libwebp/utils/filters.c

Issue 2651883004: libwebp-0.6.0-rc1 (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/libwebp/utils/filters.h ('k') | third_party/libwebp/utils/filters_utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/libwebp/utils/filters.c
diff --git a/third_party/libwebp/utils/filters.c b/third_party/libwebp/utils/filters.c
deleted file mode 100644
index 15543b1271e67904991a419d3babbaeb161973c4..0000000000000000000000000000000000000000
--- a/third_party/libwebp/utils/filters.c
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright 2011 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.
-// -----------------------------------------------------------------------------
-//
-// filter estimation
-//
-// Author: Urvang (urvang@google.com)
-
-#include "./filters.h"
-#include <stdlib.h>
-#include <string.h>
-
-// -----------------------------------------------------------------------------
-// Quick estimate of a potentially interesting filter mode to try.
-
-#define SMAX 16
-#define SDIFF(a, b) (abs((a) - (b)) >> 4) // Scoring diff, in [0..SMAX)
-
-static WEBP_INLINE int GradientPredictor(uint8_t a, uint8_t b, uint8_t c) {
- const int g = a + b - c;
- return ((g & ~0xff) == 0) ? g : (g < 0) ? 0 : 255; // clip to 8bit
-}
-
-WEBP_FILTER_TYPE WebPEstimateBestFilter(const uint8_t* data,
- int width, int height, int stride) {
- int i, j;
- int bins[WEBP_FILTER_LAST][SMAX];
- memset(bins, 0, sizeof(bins));
-
- // We only sample every other pixels. That's enough.
- for (j = 2; j < height - 1; j += 2) {
- const uint8_t* const p = data + j * stride;
- int mean = p[0];
- for (i = 2; i < width - 1; i += 2) {
- const int diff0 = SDIFF(p[i], mean);
- const int diff1 = SDIFF(p[i], p[i - 1]);
- const int diff2 = SDIFF(p[i], p[i - width]);
- const int grad_pred =
- GradientPredictor(p[i - 1], p[i - width], p[i - width - 1]);
- const int diff3 = SDIFF(p[i], grad_pred);
- bins[WEBP_FILTER_NONE][diff0] = 1;
- bins[WEBP_FILTER_HORIZONTAL][diff1] = 1;
- bins[WEBP_FILTER_VERTICAL][diff2] = 1;
- bins[WEBP_FILTER_GRADIENT][diff3] = 1;
- mean = (3 * mean + p[i] + 2) >> 2;
- }
- }
- {
- int filter;
- WEBP_FILTER_TYPE best_filter = WEBP_FILTER_NONE;
- int best_score = 0x7fffffff;
- for (filter = WEBP_FILTER_NONE; filter < WEBP_FILTER_LAST; ++filter) {
- int score = 0;
- for (i = 0; i < SMAX; ++i) {
- if (bins[filter][i] > 0) {
- score += i;
- }
- }
- if (score < best_score) {
- best_score = score;
- best_filter = (WEBP_FILTER_TYPE)filter;
- }
- }
- return best_filter;
- }
-}
-
-#undef SMAX
-#undef SDIFF
-
-//------------------------------------------------------------------------------
« no previous file with comments | « third_party/libwebp/utils/filters.h ('k') | third_party/libwebp/utils/filters_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698