Commit 09cfb2bb authored by Frank Barchard's avatar Frank Barchard Committed by Frank Barchard

Update to r1732 for more robust jpeg

Includes a rounding change for neon.
BUG=b/135532289

Change-Id: I36ffb57b55db6c64804ad169def865be1ac6d66e
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/1684439
Commit-Queue: Frank Barchard <fbarchard@chromium.org>
Reviewed-by: 's avatarChong Zhang <chz@google.com>
parent af9bc4f6
...@@ -12,6 +12,7 @@ pin-log.txt ...@@ -12,6 +12,7 @@ pin-log.txt
/native_client /native_client
/net /net
/out /out
/source/out
/sde-avx-sse-transition-out.txt /sde-avx-sse-transition-out.txt
/testing /testing
/third_party /third_party
......
Name: libyuv Name: libyuv
URL: http://code.google.com/p/libyuv/ URL: http://code.google.com/p/libyuv/
Version: 1731 Version: 1732
License: BSD License: BSD
License File: LICENSE License File: LICENSE
......
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ #ifndef INCLUDE_LIBYUV_VERSION_H_
#define INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 1731 #define LIBYUV_VERSION 1732
#endif // INCLUDE_LIBYUV_VERSION_H_ #endif // INCLUDE_LIBYUV_VERSION_H_
...@@ -25,7 +25,8 @@ ...@@ -25,7 +25,8 @@
#endif #endif
#endif #endif
struct FILE; // For jpeglib.h.
#include <stdio.h> // For jpeglib.h.
// C++ build requires extern C for jpeg internals. // C++ build requires extern C for jpeg internals.
#ifdef __cplusplus #ifdef __cplusplus
...@@ -427,7 +428,15 @@ boolean fill_input_buffer(j_decompress_ptr cinfo) { ...@@ -427,7 +428,15 @@ boolean fill_input_buffer(j_decompress_ptr cinfo) {
} }
void skip_input_data(j_decompress_ptr cinfo, long num_bytes) { // NOLINT void skip_input_data(j_decompress_ptr cinfo, long num_bytes) { // NOLINT
cinfo->src->next_input_byte += num_bytes; jpeg_source_mgr* src = cinfo->src;
size_t bytes = static_cast<size_t>(num_bytes);
if(bytes > src->bytes_in_buffer) {
src->next_input_byte = nullptr;
src->bytes_in_buffer = 0;
} else {
src->next_input_byte += bytes;
src->bytes_in_buffer -= bytes;
}
} }
void term_source(j_decompress_ptr cinfo) { void term_source(j_decompress_ptr cinfo) {
......
...@@ -47,7 +47,8 @@ LIBYUV_BOOL ValidateJpeg(const uint8_t* src_mjpg, size_t src_size_mjpg) { ...@@ -47,7 +47,8 @@ LIBYUV_BOOL ValidateJpeg(const uint8_t* src_mjpg, size_t src_size_mjpg) {
// ERROR: Invalid jpeg size: src_size_mjpg // ERROR: Invalid jpeg size: src_size_mjpg
return LIBYUV_FALSE; return LIBYUV_FALSE;
} }
if (src_mjpg[0] != 0xff || src_mjpg[1] != 0xd8) { // SOI marker // SOI marker
if (src_mjpg[0] != 0xff || src_mjpg[1] != 0xd8 || src_mjpg[2] != 0xff) {
// ERROR: Invalid jpeg initial start code // ERROR: Invalid jpeg initial start code
return LIBYUV_FALSE; return LIBYUV_FALSE;
} }
......
...@@ -2986,8 +2986,8 @@ void FloatDivToByteRow_NEON(const float* src_weights, ...@@ -2986,8 +2986,8 @@ void FloatDivToByteRow_NEON(const float* src_weights,
"fdiv v1.4s, v3.4s, v1.4s \n" // values / weights "fdiv v1.4s, v3.4s, v1.4s \n" // values / weights
"fdiv v2.4s, v4.4s, v2.4s \n" "fdiv v2.4s, v4.4s, v2.4s \n"
"fcvtzu v1.4s, v1.4s \n" // float to int "fcvtas v1.4s, v1.4s \n" // float to int
"fcvtzu v2.4s, v2.4s \n" // float to int "fcvtas v2.4s, v2.4s \n" // float to int
"uqxtn v1.4h, v1.4s \n" // 8 shorts "uqxtn v1.4h, v1.4s \n" // 8 shorts
"uqxtn2 v1.8h, v2.4s \n" "uqxtn2 v1.8h, v2.4s \n"
"uqxtn v1.8b, v1.8h \n" // 8 bytes "uqxtn v1.8b, v1.8h \n" // 8 bytes
......
...@@ -1390,6 +1390,7 @@ TEST_F(LibYUVConvertTest, ValidateJpeg) { ...@@ -1390,6 +1390,7 @@ TEST_F(LibYUVConvertTest, ValidateJpeg) {
// EOI, SOI. Expect pass. // EOI, SOI. Expect pass.
orig_pixels[0] = 0xff; orig_pixels[0] = 0xff;
orig_pixels[1] = 0xd8; // SOI. orig_pixels[1] = 0xd8; // SOI.
orig_pixels[2] = 0xff;
orig_pixels[kSize - kOff + 0] = 0xff; orig_pixels[kSize - kOff + 0] = 0xff;
orig_pixels[kSize - kOff + 1] = 0xd9; // EOI. orig_pixels[kSize - kOff + 1] = 0xd9; // EOI.
for (int times = 0; times < benchmark_iterations_; ++times) { for (int times = 0; times < benchmark_iterations_; ++times) {
...@@ -1416,6 +1417,7 @@ TEST_F(LibYUVConvertTest, ValidateJpegLarge) { ...@@ -1416,6 +1417,7 @@ TEST_F(LibYUVConvertTest, ValidateJpegLarge) {
// EOI, SOI. Expect pass. // EOI, SOI. Expect pass.
orig_pixels[0] = 0xff; orig_pixels[0] = 0xff;
orig_pixels[1] = 0xd8; // SOI. orig_pixels[1] = 0xd8; // SOI.
orig_pixels[2] = 0xff;
orig_pixels[kSize - kOff + 0] = 0xff; orig_pixels[kSize - kOff + 0] = 0xff;
orig_pixels[kSize - kOff + 1] = 0xd9; // EOI. orig_pixels[kSize - kOff + 1] = 0xd9; // EOI.
for (int times = 0; times < benchmark_iterations_; ++times) { for (int times = 0; times < benchmark_iterations_; ++times) {
...@@ -1449,6 +1451,7 @@ TEST_F(LibYUVConvertTest, InvalidateJpeg) { ...@@ -1449,6 +1451,7 @@ TEST_F(LibYUVConvertTest, InvalidateJpeg) {
// SOI but no EOI. Expect fail. // SOI but no EOI. Expect fail.
orig_pixels[0] = 0xff; orig_pixels[0] = 0xff;
orig_pixels[1] = 0xd8; // SOI. orig_pixels[1] = 0xd8; // SOI.
orig_pixels[2] = 0xff;
for (int times = 0; times < benchmark_iterations_; ++times) { for (int times = 0; times < benchmark_iterations_; ++times) {
EXPECT_FALSE(ValidateJpeg(orig_pixels, kSize)); EXPECT_FALSE(ValidateJpeg(orig_pixels, kSize));
} }
...@@ -1466,13 +1469,14 @@ TEST_F(LibYUVConvertTest, InvalidateJpeg) { ...@@ -1466,13 +1469,14 @@ TEST_F(LibYUVConvertTest, InvalidateJpeg) {
TEST_F(LibYUVConvertTest, FuzzJpeg) { TEST_F(LibYUVConvertTest, FuzzJpeg) {
// SOI but no EOI. Expect fail. // SOI but no EOI. Expect fail.
for (int times = 0; times < benchmark_iterations_; ++times) { for (int times = 0; times < benchmark_iterations_; ++times) {
const int kSize = fastrand() % 5000 + 2; const int kSize = fastrand() % 5000 + 3;
align_buffer_page_end(orig_pixels, kSize); align_buffer_page_end(orig_pixels, kSize);
MemRandomize(orig_pixels, kSize); MemRandomize(orig_pixels, kSize);
// Add SOI so frame will be scanned. // Add SOI so frame will be scanned.
orig_pixels[0] = 0xff; orig_pixels[0] = 0xff;
orig_pixels[1] = 0xd8; // SOI. orig_pixels[1] = 0xd8; // SOI.
orig_pixels[2] = 0xff;
orig_pixels[kSize - 1] = 0xff; orig_pixels[kSize - 1] = 0xff;
ValidateJpeg(orig_pixels, ValidateJpeg(orig_pixels,
kSize); // Failure normally expected. kSize); // Failure normally expected.
......
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