Commit 398de7d0 authored by fbarchard@google.com's avatar fbarchard@google.com

ARGBScale down bilinear clip to edge of image to avoid overread.

BUG=317
TESTED=drmemory out\debug\libyuv_unittest.exe --gtest_catch_exceptions=0 --gtest_filter=*ARGBScale*
R=tpsiaki@google.com

Review URL: https://webrtc-codereview.appspot.com/10159004

git-svn-id: http://libyuv.googlecode.com/svn/trunk@984 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent 6e618676
Name: libyuv
URL: http://code.google.com/p/libyuv/
Version: 982
Version: 984
License: BSD
License File: LICENSE
......
......@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 982
#define LIBYUV_VERSION 984
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
......@@ -181,8 +181,12 @@ static void ScaleARGBBilinearDown(int src_width, int src_height,
int64 xr = (dx >= 0) ? xlast : x;
int clip_src_width;
xl = (xl >> 16) & ~3; // Left edge aligned.
xr = (xr >> 16) + 1; // Right most pixel used.
clip_src_width = (((xr - xl) + 1 + 3) & ~3) * 4; // Width aligned to 4.
xr = (xr >> 16) + 1; // Right most pixel used. Bilinear uses 2 pixels.
xr = (xr + 1 + 3) & ~3; // 1 beyond 4 pixel aligned right most pixel.
if (xr > src_width) {
xr = src_width;
}
clip_src_width = (xr - xl) * 4; // Width aligned to 4.
src_argb += xl * 4;
x -= (int)(xl << 16);
#if defined(HAS_INTERPOLATEROW_SSE2)
......
......@@ -22,21 +22,21 @@ namespace libyuv {
static int ARGBTestFilter(int src_width, int src_height,
int dst_width, int dst_height,
FilterMode f, int benchmark_iterations) {
const int b = 128;
int i, j;
const int b = 0; // 128 to test for padding/stride.
int src_argb_plane_size = (Abs(src_width) + b * 2) *
(Abs(src_height) + b * 2) * 4;
int src_stride_argb = (b * 2 + Abs(src_width)) * 4;
align_buffer_64(src_argb, src_argb_plane_size);
align_buffer_page_end(src_argb, src_argb_plane_size);
srandom(time(NULL));
MemRandomize(src_argb, src_argb_plane_size);
int dst_argb_plane_size = (dst_width + b * 2) * (dst_height + b * 2) * 4;
int dst_stride_argb = (b * 2 + dst_width) * 4;
align_buffer_64(dst_argb_c, dst_argb_plane_size);
align_buffer_64(dst_argb_opt, dst_argb_plane_size);
align_buffer_page_end(dst_argb_c, dst_argb_plane_size);
align_buffer_page_end(dst_argb_opt, dst_argb_plane_size);
memset(dst_argb_c, 2, dst_argb_plane_size);
memset(dst_argb_opt, 3, dst_argb_plane_size);
......@@ -90,9 +90,9 @@ static int ARGBTestFilter(int src_width, int src_height,
}
}
free_aligned_buffer_64(dst_argb_c);
free_aligned_buffer_64(dst_argb_opt);
free_aligned_buffer_64(src_argb);
free_aligned_buffer_page_end(dst_argb_c);
free_aligned_buffer_page_end(dst_argb_opt);
free_aligned_buffer_page_end(src_argb);
return max_diff;
}
......@@ -262,6 +262,7 @@ TEST_FACTOR(3by4, 3 / 4, 3 / 4)
TEST_SCALETO(ARGBScale, 1, 1)
TEST_SCALETO(ARGBScale, 320, 240)
TEST_SCALETO(ARGBScale, 352, 288)
TEST_SCALETO(ARGBScale, 569, 480)
TEST_SCALETO(ARGBScale, 640, 360)
TEST_SCALETO(ARGBScale, 1280, 720)
#undef TEST_SCALETO1
......
......@@ -22,7 +22,7 @@ static int TestFilter(int src_width, int src_height,
int dst_width, int dst_height,
FilterMode f, int benchmark_iterations) {
int i, j;
const int b = 128;
const int b = 0; // 128 to test for padding/stride.
int src_width_uv = (Abs(src_width) + 1) >> 1;
int src_height_uv = (Abs(src_height) + 1) >> 1;
......@@ -180,6 +180,7 @@ TEST_FACTOR(3by4, 3 / 4, 3 / 4)
TEST_SCALETO(Scale, 1, 1)
TEST_SCALETO(Scale, 320, 240)
TEST_SCALETO(Scale, 352, 288)
TEST_SCALETO(Scale, 569, 480)
TEST_SCALETO(Scale, 640, 360)
TEST_SCALETO(Scale, 1280, 720)
#undef TEST_SCALETO1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment