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

Side by Side Diff: unit_test/unit_test.h

Issue 1947783002: If image sizes are greater than 32768, fixed point stepping will overflow an int. This CL changes t… (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: comments updated Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « unit_test/scale_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 10 matching lines...) Expand all
21 #include <gtest/gtest.h> 21 #include <gtest/gtest.h>
22 22
23 #include "libyuv/basic_types.h" 23 #include "libyuv/basic_types.h"
24 24
25 static __inline int Abs(int v) { 25 static __inline int Abs(int v) {
26 return v >= 0 ? v : -v; 26 return v >= 0 ? v : -v;
27 } 27 }
28 28
29 #define OFFBY 0 29 #define OFFBY 0
30 30
31 // Scaling uses 16.16 fixed point to step thru the source image, so a
32 // maximum size of 32767.999 can be expressed. 32768 is valid because
33 // the step is 1 beyond the image but not used.
34 // Destination size is mainly constrained by valid scale step not the
35 // absolute size, so it may be possible to relax the destination size
36 // constraint.
37 // Source size is unconstrained for most specialized scalers. e.g.
38 // An image of 65536 scaled to half size would be valid. The test
39 // could be relaxed for special scale factors.
40 // If this test is removed, the scaling function should gracefully
41 // fail with a return code. The test could be changed to know that
42 // libyuv failed in a controlled way.
43
44 static const int kMaxWidth = 32768;
45 static const int kMaxHeight = 32768;
46
47 static inline bool SizeValid(int src_width, int src_height,
48 int dst_width, int dst_height) {
49 if (src_width > kMaxWidth || src_height > kMaxHeight ||
50 dst_width > kMaxWidth || dst_height > kMaxHeight) {
51 printf("Warning - size too large to test. Skipping\n");
52 return false;
53 }
54 return true;
55 }
56
31 #define align_buffer_page_end(var, size) \ 57 #define align_buffer_page_end(var, size) \
32 uint8* var; \ 58 uint8* var; \
33 uint8* var##_mem; \ 59 uint8* var##_mem; \
34 var##_mem = reinterpret_cast<uint8*>(malloc((((size) + 4095) & ~4095) + \ 60 var##_mem = reinterpret_cast<uint8*>(malloc((((size) + 4095) & ~4095) + \
35 OFFBY)); \ 61 OFFBY)); \
36 var = var##_mem + (-(size) & 4095) + OFFBY; 62 var = var##_mem + (-(size) & 4095) + OFFBY;
37 63
38 #define free_aligned_buffer_page_end(var) \ 64 #define free_aligned_buffer_page_end(var) \
39 free(var##_mem); \ 65 free(var##_mem); \
40 var = 0; 66 var = 0;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 int benchmark_iterations_; // Default 1. Use 1000 for benchmarking. 170 int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
145 int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA. 171 int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
146 int benchmark_height_; // Default 720. Use 360 for benchmarking VGA. 172 int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
147 int benchmark_pixels_div256_; // Total pixels to benchmark / 256. 173 int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
148 int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280. 174 int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
149 int disable_cpu_flags_; // Default 1. Use -1 for benchmarking. 175 int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
150 int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD. 176 int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
151 }; 177 };
152 178
153 #endif // UNIT_TEST_UNIT_TEST_H_ NOLINT 179 #endif // UNIT_TEST_UNIT_TEST_H_ NOLINT
OLDNEW
« no previous file with comments | « unit_test/scale_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698