Commit a965a97d authored by fbarchard@google.com's avatar fbarchard@google.com

Unittest to test ValidateJpeg when jpeg is small but buffer is large

BUG=404
TESTED=libyuvTest.ValidateJpegLarge
R=harryjin@google.com

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

git-svn-id: http://libyuv.googlecode.com/svn/trunk@1284 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent 975dd5a6
Name: libyuv
URL: http://code.google.com/p/libyuv/
Version: 1283
Version: 1284
License: BSD
License File: LICENSE
......
......@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 1283
#define LIBYUV_VERSION 1284
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
......@@ -1029,6 +1029,30 @@ TEST_F(libyuvTest, ValidateJpeg) {
free_aligned_buffer_page_end(orig_pixels);
}
TEST_F(libyuvTest, ValidateJpegLarge) {
const int kOff = 10;
const int kMinJpeg = 64;
const int kImageSize = benchmark_width_ * benchmark_height_ >= kMinJpeg ?
benchmark_width_ * benchmark_height_ : kMinJpeg;
const int kSize = kImageSize + kOff;
const int kBufSize = kImageSize * 10 + kOff;
align_buffer_64(orig_pixels, kBufSize);
// No SOI or EOI. Expect fail.
memset(orig_pixels, 0, kBufSize);
EXPECT_FALSE(ValidateJpeg(orig_pixels, kBufSize));
// EOI, SOI. Expect pass.
orig_pixels[0] = 0xff;
orig_pixels[1] = 0xd8; // SOI.
orig_pixels[kSize - kOff + 0] = 0xff;
orig_pixels[kSize - kOff + 1] = 0xd9; // EOI.
for (int times = 0; times < benchmark_iterations_; ++times) {
EXPECT_TRUE(ValidateJpeg(orig_pixels, kBufSize));
}
free_aligned_buffer_page_end(orig_pixels);
}
TEST_F(libyuvTest, InvalidateJpeg) {
const int kOff = 10;
const int kMinJpeg = 64;
......
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