X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Fpixel_formats_test.cc;h=a104e620b516180f284ae5abdf8a80ccc5eaab16;hb=9a3613d9a68440db5cb648ac3ee05a0ef53a8811;hp=84f2a33ce325209614ae519a36a5fc4113104dab;hpb=5a57b5631518ce9711e6b44a65a0bb87aa434561;p=dcpomatic.git diff --git a/test/pixel_formats_test.cc b/test/pixel_formats_test.cc index 84f2a33ce..a104e620b 100644 --- a/test/pixel_formats_test.cc +++ b/test/pixel_formats_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Carl Hetherington + Copyright (C) 2013-2014 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,14 +17,32 @@ */ +/** @file src/pixel_formats_test.cc + * @brief Make sure that Image::sample_size() and Image::bytes_per_pixel() return the right + * things for various pixel formats. + * + * @see test/image_test.cc + */ + +#include +#include +extern "C" { +#include +#include +} +#include "lib/image.h" + using std::list; using std::cout; +/** @struct Case + * @brief A test case for pixel_formats_test. + */ struct Case { Case (AVPixelFormat f, int c, int l0, int l1, int l2, float b0, float b1, float b2) : format(f) - , components(c) + , planes(c) { lines[0] = l0; lines[1] = l1; @@ -33,9 +51,9 @@ struct Case bpp[1] = b1; bpp[2] = b2; } - + AVPixelFormat format; - int components; + int planes; int lines[3]; float bpp[3]; }; @@ -43,9 +61,6 @@ struct Case BOOST_AUTO_TEST_CASE (pixel_formats_test) { - /* This needs to happen in the first test */ - dvdomatic_setup (); - list cases; cases.push_back(Case(AV_PIX_FMT_RGB24, 1, 480, 480, 480, 3, 0, 0 )); cases.push_back(Case(AV_PIX_FMT_RGBA, 1, 480, 480, 480, 4, 0, 0 )); @@ -65,11 +80,12 @@ BOOST_AUTO_TEST_CASE (pixel_formats_test) f->width = 640; f->height = 480; f->format = static_cast (i->format); - SimpleImage t (f); - BOOST_CHECK_EQUAL(t.components(), i->components); - BOOST_CHECK_EQUAL(t.lines(0), i->lines[0]); - BOOST_CHECK_EQUAL(t.lines(1), i->lines[1]); - BOOST_CHECK_EQUAL(t.lines(2), i->lines[2]); + av_frame_get_buffer (f, true); + Image t (f); + BOOST_CHECK_EQUAL(t.planes(), i->planes); + BOOST_CHECK_EQUAL(t.sample_size(0).height, i->lines[0]); + BOOST_CHECK_EQUAL(t.sample_size(1).height, i->lines[1]); + BOOST_CHECK_EQUAL(t.sample_size(2).height, i->lines[2]); BOOST_CHECK_EQUAL(t.bytes_per_pixel(0), i->bpp[0]); BOOST_CHECK_EQUAL(t.bytes_per_pixel(1), i->bpp[1]); BOOST_CHECK_EQUAL(t.bytes_per_pixel(2), i->bpp[2]);