diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-12-18 23:34:26 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-12-23 12:59:56 +0100 |
| commit | c0733033923d369cce3d76b318e969bf89a130b9 (patch) | |
| tree | 3631101ddc1dfb2366e7c6ba3d1df38dc8b921cd /test/test.cc | |
| parent | f09bbf9d037975b5a6113c4d5634c82625a51683 (diff) | |
Add image_as_jpeg()
Diffstat (limited to 'test/test.cc')
| -rw-r--r-- | test/test.cc | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/test/test.cc b/test/test.cc index 08b37bcb1..c225fc1d8 100644 --- a/test/test.cc +++ b/test/test.cc @@ -369,8 +369,10 @@ rms_error (boost::filesystem::path ref, boost::filesystem::path check) FFmpegImageProxy check_proxy (check); auto check_image = check_proxy.image(Image::Alignment::COMPACT).image; + BOOST_REQUIRE_EQUAL (ref_image->planes(), check_image->planes()); + BOOST_REQUIRE_EQUAL (ref_image->pixel_format(), check_image->pixel_format()); - AVPixelFormat const format = ref_image->pixel_format(); + auto const format = ref_image->pixel_format(); BOOST_REQUIRE (ref_image->size() == check_image->size()); int const width = ref_image->size().width; @@ -417,6 +419,19 @@ rms_error (boost::filesystem::path ref, boost::filesystem::path check) } break; } + case AV_PIX_FMT_YUVJ420P: + { + for (int c = 0; c < ref_image->planes(); ++c) { + for (int y = 0; y < height / ref_image->vertical_factor(c); ++y) { + auto p = ref_image->data()[c] + y * ref_image->stride()[c]; + auto q = check_image->data()[c] + y * check_image->stride()[c]; + for (int x = 0; x < ref_image->line_size()[c]; ++x) { + sum_square += pow((*p++ - *q++), 2); + } + } + } + break; + } default: BOOST_REQUIRE_MESSAGE (false, "unrecognised pixel format " << format); } |
