mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-06 16:56:55 +08:00
libyuv::MJPGToI420() and libyuv::MJPGToARGB() return failure if callback to JPeg fails.
BUG=309 TESTED=try bots still pass R=braveyao@webrtc.org Review URL: https://webrtc-codereview.appspot.com/7709004 git-svn-id: http://libyuv.googlecode.com/svn/trunk@976 16f28f9a-4ce2-e073-06de-1de4eb20be90
This commit is contained in:
parent
9a46283c6d
commit
16ea9c816b
@ -1,6 +1,6 @@
|
||||
Name: libyuv
|
||||
URL: http://code.google.com/p/libyuv/
|
||||
Version: 975
|
||||
Version: 976
|
||||
License: BSD
|
||||
License File: LICENSE
|
||||
|
||||
|
||||
@ -11,6 +11,6 @@
|
||||
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
|
||||
#define INCLUDE_LIBYUV_VERSION_H_
|
||||
|
||||
#define LIBYUV_VERSION 975
|
||||
#define LIBYUV_VERSION 976
|
||||
|
||||
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
|
||||
|
||||
@ -218,7 +218,7 @@ int MJPGToI420(const uint8* sample,
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return ret ? 0 : 1;
|
||||
}
|
||||
|
||||
#ifdef HAVE_JPEG
|
||||
@ -380,7 +380,7 @@ int MJPGToARGB(const uint8* sample,
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return ret ? 0 : 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -988,6 +988,7 @@ TEST_F(libyuvTest, ValidateJpeg) {
|
||||
|
||||
// No SOI or EOI. Expect fail.
|
||||
memset(orig_pixels, 0, kSize);
|
||||
EXPECT_FALSE(ValidateJpeg(orig_pixels, kSize));
|
||||
|
||||
// EOI, SOI. Expect pass.
|
||||
orig_pixels[0] = 0xff;
|
||||
@ -1028,6 +1029,74 @@ TEST_F(libyuvTest, InvalidateJpeg) {
|
||||
free_aligned_buffer_page_end(orig_pixels);
|
||||
}
|
||||
|
||||
#endif
|
||||
TEST_F(libyuvTest, MJPGToI420) {
|
||||
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;
|
||||
align_buffer_64(orig_pixels, kSize);
|
||||
align_buffer_64(dst_y_opt, benchmark_width_ * benchmark_height_);
|
||||
align_buffer_64(dst_u_opt,
|
||||
SUBSAMPLE(benchmark_width_, 2) *
|
||||
SUBSAMPLE(benchmark_height_, 2));
|
||||
align_buffer_64(dst_v_opt,
|
||||
SUBSAMPLE(benchmark_width_, 2) *
|
||||
SUBSAMPLE(benchmark_height_, 2));
|
||||
|
||||
// EOI, SOI to make MJPG appear valid.
|
||||
memset(orig_pixels, 0, kSize);
|
||||
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) {
|
||||
int ret = MJPGToI420(orig_pixels, kSize,
|
||||
dst_y_opt, benchmark_width_,
|
||||
dst_u_opt, SUBSAMPLE(benchmark_width_, 2),
|
||||
dst_v_opt, SUBSAMPLE(benchmark_width_, 2),
|
||||
benchmark_width_, benchmark_height_,
|
||||
benchmark_width_, benchmark_height_);
|
||||
// Expect failure because image is not really valid.
|
||||
EXPECT_EQ(1, ret);
|
||||
}
|
||||
|
||||
free_aligned_buffer_page_end(dst_y_opt);
|
||||
free_aligned_buffer_page_end(dst_u_opt);
|
||||
free_aligned_buffer_page_end(dst_v_opt);
|
||||
free_aligned_buffer_page_end(orig_pixels);
|
||||
}
|
||||
|
||||
TEST_F(libyuvTest, MJPGToARGB) {
|
||||
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;
|
||||
align_buffer_64(orig_pixels, kSize);
|
||||
align_buffer_64(dst_argb_opt, benchmark_width_ * benchmark_height_ * 4);
|
||||
|
||||
// EOI, SOI to make MJPG appear valid.
|
||||
memset(orig_pixels, 0, kSize);
|
||||
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) {
|
||||
int ret = MJPGToARGB(orig_pixels, kSize,
|
||||
dst_argb_opt, benchmark_width_ * 4,
|
||||
benchmark_width_, benchmark_height_,
|
||||
benchmark_width_, benchmark_height_);
|
||||
// Expect failure because image is not really valid.
|
||||
EXPECT_EQ(1, ret);
|
||||
}
|
||||
|
||||
free_aligned_buffer_page_end(dst_argb_opt);
|
||||
free_aligned_buffer_page_end(orig_pixels);
|
||||
}
|
||||
|
||||
#endif // HAVE_JPEG
|
||||
|
||||
} // namespace libyuv
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user