Skip to content

Commit

Permalink
Add iloc extents test (#2095)
Browse files Browse the repository at this point in the history
  • Loading branch information
y-guyon committed May 6, 2024
1 parent d715425 commit c4d9767
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ if(AVIF_ENABLE_GTEST)
endif()

add_avif_gtest(avifgridapitest)
add_avif_gtest_with_data(avifilocextenttest)
add_avif_gtest(avifimagetest)

add_executable(avifincrtest gtest/avifincrtest.cc)
Expand Down
20 changes: 20 additions & 0 deletions tests/data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ It's a color image tagged as sRGB.

License: Creative Commons Attribution-NonCommercial 2.5 License

Attribution: Greg Roelofs

Source: Picture from the libpng test page
http://www.libpng.org/pub/png/png-colortest.html.

Expand All @@ -314,6 +316,8 @@ It's a image tagged as gamma 2.2 and BT709 primaries.

License: Creative Commons Attribution-NonCommercial 2.5 License

Attribution: Greg Roelofs

Source: Picture from the libpng test page
http://www.libpng.org/pub/png/png-colortest.html.

Expand All @@ -325,13 +329,29 @@ It's a image tagged as gamma 2.2 and BT709 primaries but red and green swapped.

License: Creative Commons Attribution-NonCommercial 2.5 License

Attribution: Greg Roelofs

Source: Picture from the libpng test page
http://www.libpng.org/pub/png/png-colortest.html.

It's [ArcTriomphe-cHRM-red-green-swap.png](ArcTriomphe-cHRM-red-green-swap.png)
converted into sRGB colorspace by Chrome using "Capture Node Screenshot"
in DevTools.

### File [arc_triomphe_extent1000_nullbyte_extent1310.avif](arc_triomphe_extent1000_nullbyte_extent1310.avif)

![](arc_triomphe_extent1000_nullbyte_extent1310.avif)

License: Creative Commons Attribution-NonCommercial 2.5 License

Attribution: Greg Roelofs

Source: `ArcTriomphe-cHRM-orig.png` compressed with
`avifenc --ignore-exif --ignore-xmp --ignore-icc`.

The file is manually edited. The `iloc` property of the primary item has two
extents. A null byte was inserted between the two extents in the `mdat` payload.

## Grid

### File [sofa_grid1x5_420.avif](sofa_grid1x5_420.avif)
Expand Down
Binary file not shown.
48 changes: 48 additions & 0 deletions tests/gtest/avifilocextenttest.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2024 Google LLC
// SPDX-License-Identifier: BSD-2-Clause

#include "avif/avif.h"
#include "aviftest_helpers.h"
#include "gtest/gtest.h"

namespace avif {
namespace {

// Used to pass the data folder path to the GoogleTest suites.
const char* data_path = nullptr;

//------------------------------------------------------------------------------

TEST(IlocTest, TwoExtents) {
if (!testutil::Av1DecoderAvailable()) {
GTEST_SKIP() << "AV1 Codec unavailable, skip test.";
}

const ImagePtr source =
testutil::ReadImage(data_path, "ArcTriomphe-cHRM-orig.png");
const ImagePtr decoded =
testutil::DecodeFile(std::string(data_path) +
"arc_triomphe_extent1000_nullbyte_extent1310.avif");
ASSERT_NE(source, nullptr);
ASSERT_NE(decoded, nullptr);
const double psnr = testutil::GetPsnr(*source, *decoded);
EXPECT_GT(psnr, 30.0);
EXPECT_LT(psnr, 45.0);
}

//------------------------------------------------------------------------------

} // namespace
} // namespace avif

int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
if (argc != 2) {
std::cerr << "There must be exactly one argument containing the path to "
"the test data folder"
<< std::endl;
return 1;
}
avif::data_path = argv[1];
return RUN_ALL_TESTS();
}

0 comments on commit c4d9767

Please sign in to comment.