Fix CheckDecodedArea() in helpers_incr.cc
Change-Id: Ic03138839ad86bf42617945c12de42b180ebe4b6
Reviewed-on: https://chromium-review.googlesource.com/c/codecs/libwebp2/+/4219431
Tested-by: WebM Builds <builds@webmproject.org>
Reviewed-by: Maryla Ustarroz-Calonge <maryla@google.com>
diff --git a/tests/include/helpers.cc b/tests/include/helpers.cc
index a0cd158..16eedee 100644
--- a/tests/include/helpers.cc
+++ b/tests/include/helpers.cc
@@ -437,10 +437,13 @@
ArgbBuffer buffer(WP2_Argb_32);
if (image.format() == buffer.format()) {
WP2_ASSERT_STATUS(buffer.SetView(image));
+ if (rect.GetArea() != 0) WP2_ASSERT_STATUS(buffer.SetView(buffer, rect));
} else {
- WP2_ASSERT_STATUS(buffer.ConvertFrom(image));
+ ArgbBuffer cropped_image(image.format());
+ WP2_ASSERT_STATUS(cropped_image.SetView(
+ image, rect.GetArea() != 0 ? rect : image.AsRect()));
+ WP2_ASSERT_STATUS(buffer.ConvertFrom(cropped_image));
}
- if (rect.GetArea() != 0) WP2_ASSERT_STATUS(buffer.SetView(buffer, rect));
WP2_ASSERT_STATUS(SaveImage(buffer, file_path.c_str(), /*overwrite=*/true));
}
diff --git a/tests/include/helpers_incr.cc b/tests/include/helpers_incr.cc
index bca2001..f377a5c 100644
--- a/tests/include/helpers_incr.cc
+++ b/tests/include/helpers_incr.cc
@@ -378,7 +378,7 @@
if (i > 0) {
size_t previous_offset, previous_length;
CHECK_OR_DIE(idec.TryGetFrameLocation(i - 1, &previous_offset,
- &previous_length));
+ &previous_length));
CHECK_OR_DIE(offset == previous_offset + previous_length);
}
}
@@ -443,8 +443,9 @@
if (has_true_incremental_output_) {
// Arbitrary formula. There is no theoritical maximum threshold but in
// practice it is unlikely to go beyond this one.
- const uint32_t max_num_block_rows_in_two_bytes =
- std::max(1u, kMinBlockSizePix * kMaxBlockSizePix / features->width);
+ const uint32_t max_num_block_rows_in_two_bytes = std::max(
+ 1u, kMinBlockSizePix * kMaxBlockSizePix /
+ (is_sideways ? features->height : features->width));
max_num_lines = kMaxBlockSizePix * max_num_block_rows_in_two_bytes;
} else {
max_num_lines = features->tile_height;