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

Side by Side Diff: third_party/libwebp/utils/rescaler.c

Issue 2584033003: libwebp-0.5.2-rc2 (Closed)
Patch Set: layout tests Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 Google Inc. All Rights Reserved. 1 // Copyright 2012 Google Inc. All Rights Reserved.
2 // 2 //
3 // Use of this source code is governed by a BSD-style license 3 // Use of this source code is governed by a BSD-style license
4 // that can be found in the COPYING file in the root of the source 4 // that can be found in the COPYING file in the root of the source
5 // tree. An additional intellectual property rights grant can be found 5 // tree. An additional intellectual property rights grant can be found
6 // in the file PATENTS. All contributing project authors may 6 // in the file PATENTS. All contributing project authors may
7 // be found in the AUTHORS file in the root of the source tree. 7 // be found in the AUTHORS file in the root of the source tree.
8 // ----------------------------------------------------------------------------- 8 // -----------------------------------------------------------------------------
9 // 9 //
10 // Rescaling functions 10 // Rescaling functions
(...skipping 30 matching lines...) Expand all
41 wrk->x_add = wrk->x_expand ? (x_sub - 1) : x_add; 41 wrk->x_add = wrk->x_expand ? (x_sub - 1) : x_add;
42 wrk->x_sub = wrk->x_expand ? (x_add - 1) : x_sub; 42 wrk->x_sub = wrk->x_expand ? (x_add - 1) : x_sub;
43 if (!wrk->x_expand) { // fx_scale is not used otherwise 43 if (!wrk->x_expand) { // fx_scale is not used otherwise
44 wrk->fx_scale = WEBP_RESCALER_FRAC(1, wrk->x_sub); 44 wrk->fx_scale = WEBP_RESCALER_FRAC(1, wrk->x_sub);
45 } 45 }
46 // vertical scaling parameters 46 // vertical scaling parameters
47 wrk->y_add = wrk->y_expand ? y_add - 1 : y_add; 47 wrk->y_add = wrk->y_expand ? y_add - 1 : y_add;
48 wrk->y_sub = wrk->y_expand ? y_sub - 1 : y_sub; 48 wrk->y_sub = wrk->y_expand ? y_sub - 1 : y_sub;
49 wrk->y_accum = wrk->y_expand ? wrk->y_sub : wrk->y_add; 49 wrk->y_accum = wrk->y_expand ? wrk->y_sub : wrk->y_add;
50 if (!wrk->y_expand) { 50 if (!wrk->y_expand) {
51 // this is WEBP_RESCALER_FRAC(dst_height, x_add * y_add) without the cast. 51 // This is WEBP_RESCALER_FRAC(dst_height, x_add * y_add) without the cast.
52 // Its value is <= WEBP_RESCALER_ONE, because dst_height <= wrk->y_add, and
53 // wrk->x_add >= 1;
52 const uint64_t ratio = 54 const uint64_t ratio =
53 (uint64_t)dst_height * WEBP_RESCALER_ONE / (wrk->x_add * wrk->y_add); 55 (uint64_t)dst_height * WEBP_RESCALER_ONE / (wrk->x_add * wrk->y_add);
54 if (ratio != (uint32_t)ratio) { 56 if (ratio != (uint32_t)ratio) {
55 // We can't represent the ratio with the current fixed-point precision. 57 // When ratio == WEBP_RESCALER_ONE, we can't represent the ratio with the
58 // current fixed-point precision. This happens when src_height ==
59 // wrk->y_add (which == src_height), and wrk->x_add == 1.
56 // => We special-case fxy_scale = 0, in WebPRescalerExportRow(). 60 // => We special-case fxy_scale = 0, in WebPRescalerExportRow().
57 wrk->fxy_scale = 0; 61 wrk->fxy_scale = 0;
58 } else { 62 } else {
59 wrk->fxy_scale = (uint32_t)ratio; 63 wrk->fxy_scale = (uint32_t)ratio;
60 } 64 }
61 wrk->fy_scale = WEBP_RESCALER_FRAC(1, wrk->y_sub); 65 wrk->fy_scale = WEBP_RESCALER_FRAC(1, wrk->y_sub);
62 } else { 66 } else {
63 wrk->fy_scale = WEBP_RESCALER_FRAC(1, wrk->x_add); 67 wrk->fy_scale = WEBP_RESCALER_FRAC(1, wrk->x_add);
64 // wrk->fxy_scale is unused here. 68 // wrk->fxy_scale is unused here.
65 } 69 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 int WebPRescalerExport(WebPRescaler* const rescaler) { 137 int WebPRescalerExport(WebPRescaler* const rescaler) {
134 int total_exported = 0; 138 int total_exported = 0;
135 while (WebPRescalerHasPendingOutput(rescaler)) { 139 while (WebPRescalerHasPendingOutput(rescaler)) {
136 WebPRescalerExportRow(rescaler); 140 WebPRescalerExportRow(rescaler);
137 ++total_exported; 141 ++total_exported;
138 } 142 }
139 return total_exported; 143 return total_exported;
140 } 144 }
141 145
142 //------------------------------------------------------------------------------ 146 //------------------------------------------------------------------------------
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698