diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-05-31 14:19:50 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-05-31 14:19:50 +0100 |
| commit | f385ef03e5ea27519a31c0839447735a7fba0602 (patch) | |
| tree | 310902e785a95c2e3be1ba389f29cd7bd480f2a2 /test | |
| parent | c13771610ef9a01cb29342bca82f9999f8b5ddbc (diff) | |
Various stuff; mostly change to decoder scaling and adding subtitle; scaling test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/client_server_test.cc | 6 | ||||
| -rw-r--r-- | test/container_test.cc | 73 | ||||
| -rw-r--r-- | test/dcp_test.cc | 2 | ||||
| -rw-r--r-- | test/film_metadata_test.cc | 4 | ||||
| -rw-r--r-- | test/format_test.cc | 33 | ||||
| -rw-r--r-- | test/make_black_test.cc | 2 | ||||
| -rw-r--r-- | test/ratio_test.cc | 73 | ||||
| -rw-r--r-- | test/scaling_test.cc | 43 | ||||
| -rw-r--r-- | test/test.cc | 64 |
9 files changed, 179 insertions, 121 deletions
diff --git a/test/client_server_test.cc b/test/client_server_test.cc index 9c4482d3c..51b52331a 100644 --- a/test/client_server_test.cc +++ b/test/client_server_test.cc @@ -63,12 +63,6 @@ BOOST_AUTO_TEST_CASE (client_server_test) shared_ptr<DCPVideoFrame> frame ( new DCPVideoFrame ( image, - subtitle, - libdcp::Size (1998, 1080), - 0, - 0, - 1, - Scaler::from_id ("bicubic"), 0, 24, 0, diff --git a/test/container_test.cc b/test/container_test.cc deleted file mode 100644 index 825a8cdc4..000000000 --- a/test/container_test.cc +++ /dev/null @@ -1,73 +0,0 @@ -/* - Copyright (C) 2012 Carl Hetherington <cth@carlh.net> - - 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 - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -using std::ostream; - -namespace libdcp { - -ostream& -operator<< (ostream& s, libdcp::Size const & t) -{ - s << t.width << "x" << t.height; - return s; -} - -} - -BOOST_AUTO_TEST_CASE (container_test) -{ - Container::setup_containers (); - - Container const * c = Container::from_id ("119"); - BOOST_CHECK (c); - BOOST_CHECK_EQUAL (c->size(libdcp::Size (2048, 1080)), libdcp::Size (1285, 1080)); - - c = Container::from_id ("133"); - BOOST_CHECK (c); - BOOST_CHECK_EQUAL (c->size(libdcp::Size (2048, 1080)), libdcp::Size (1436, 1080)); - - c = Container::from_id ("137"); - BOOST_CHECK (c); - BOOST_CHECK_EQUAL (c->size(libdcp::Size (2048, 1080)), libdcp::Size (1480, 1080)); - - c = Container::from_id ("138"); - BOOST_CHECK (c); - BOOST_CHECK_EQUAL (c->size(libdcp::Size (2048, 1080)), libdcp::Size (1485, 1080)); - - c = Container::from_id ("166"); - BOOST_CHECK (c); - BOOST_CHECK_EQUAL (c->size(libdcp::Size (2048, 1080)), libdcp::Size (1793, 1080)); - - c = Container::from_id ("178"); - BOOST_CHECK (c); - BOOST_CHECK_EQUAL (c->size(libdcp::Size (2048, 1080)), libdcp::Size (1920, 1080)); - - c = Container::from_id ("185"); - BOOST_CHECK (c); - BOOST_CHECK_EQUAL (c->size(libdcp::Size (2048, 1080)), libdcp::Size (1998, 1080)); - - c = Container::from_id ("239"); - BOOST_CHECK (c); - BOOST_CHECK_EQUAL (c->size(libdcp::Size (2048, 1080)), libdcp::Size (2048, 858)); - - c = Container::from_id ("full-frame"); - BOOST_CHECK (c); - BOOST_CHECK_EQUAL (c->size(libdcp::Size (2048, 1080)), libdcp::Size (2048, 1080)); -} - diff --git a/test/dcp_test.cc b/test/dcp_test.cc index 795b4dfe3..cf31d674e 100644 --- a/test/dcp_test.cc +++ b/test/dcp_test.cc @@ -29,7 +29,7 @@ BOOST_AUTO_TEST_CASE (make_dcp_test) dcpomatic_sleep (1); } - film->set_container (Container::from_id ("185")); + film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_pretty_name ("Test")); film->make_dcp (); film->write_metadata (); diff --git a/test/film_metadata_test.cc b/test/film_metadata_test.cc index 315461b22..397b9e43a 100644 --- a/test/film_metadata_test.cc +++ b/test/film_metadata_test.cc @@ -32,7 +32,7 @@ BOOST_AUTO_TEST_CASE (film_metadata_test) f->set_name ("fred"); f->set_dcp_content_type (DCPContentType::from_pretty_name ("Short")); - f->set_container (Container::from_id ("185")); + f->set_container (Ratio::from_id ("185")); f->set_ab (true); f->write_metadata (); @@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE (film_metadata_test) BOOST_CHECK_EQUAL (g->name(), "fred"); BOOST_CHECK_EQUAL (g->dcp_content_type(), DCPContentType::from_pretty_name ("Short")); - BOOST_CHECK_EQUAL (g->container(), Container::from_id ("185")); + BOOST_CHECK_EQUAL (g->container(), Ratio::from_id ("185")); BOOST_CHECK_EQUAL (g->ab(), true); g->write_metadata (); diff --git a/test/format_test.cc b/test/format_test.cc deleted file mode 100644 index 71bc00359..000000000 --- a/test/format_test.cc +++ /dev/null @@ -1,33 +0,0 @@ -/* - Copyright (C) 2012 Carl Hetherington <cth@carlh.net> - - 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 - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -BOOST_AUTO_TEST_CASE (format_test) -{ - Format::setup_formats (); - - Format const * f = Format::from_nickname ("Flat"); - BOOST_CHECK (f); - BOOST_CHECK_EQUAL (f->dcp_size().width, 1998); - BOOST_CHECK_EQUAL (f->dcp_size().height, 1080); - - f = Format::from_nickname ("Scope"); - BOOST_CHECK (f); - BOOST_CHECK_EQUAL (f->dcp_size().width, 2048); - BOOST_CHECK_EQUAL (f->dcp_size().height, 858); -} diff --git a/test/make_black_test.cc b/test/make_black_test.cc index 3c0b979ff..c70870915 100644 --- a/test/make_black_test.cc +++ b/test/make_black_test.cc @@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE (make_black_test) for (list<AVPixelFormat>::const_iterator i = pix_fmts.begin(); i != pix_fmts.end(); ++i) { boost::shared_ptr<Image> foo (new SimpleImage (*i, in_size, true)); foo->make_black (); - boost::shared_ptr<Image> bar = foo->scale_and_convert_to_rgb (out_size, 0, Scaler::from_id ("bicubic"), true); + boost::shared_ptr<Image> bar = foo->scale_and_convert_to_rgb (out_size, Scaler::from_id ("bicubic"), true); uint8_t* p = bar->data()[0]; for (int y = 0; y < bar->size().height; ++y) { diff --git a/test/ratio_test.cc b/test/ratio_test.cc new file mode 100644 index 000000000..6311976a3 --- /dev/null +++ b/test/ratio_test.cc @@ -0,0 +1,73 @@ +/* + Copyright (C) 2012 Carl Hetherington <cth@carlh.net> + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +using std::ostream; + +namespace libdcp { + +ostream& +operator<< (ostream& s, libdcp::Size const & t) +{ + s << t.width << "x" << t.height; + return s; +} + +} + +BOOST_AUTO_TEST_CASE (ratio_test) +{ + Ratio::setup_ratios (); + + Ratio const * r = Ratio::from_id ("119"); + BOOST_CHECK (r); + BOOST_CHECK_EQUAL (r->size(libdcp::Size (2048, 1080)), libdcp::Size (1285, 1080)); + + r = Ratio::from_id ("133"); + BOOST_CHECK (r); + BOOST_CHECK_EQUAL (r->size(libdcp::Size (2048, 1080)), libdcp::Size (1436, 1080)); + + r = Ratio::from_id ("137"); + BOOST_CHECK (r); + BOOST_CHECK_EQUAL (r->size(libdcp::Size (2048, 1080)), libdcp::Size (1480, 1080)); + + r = Ratio::from_id ("138"); + BOOST_CHECK (r); + BOOST_CHECK_EQUAL (r->size(libdcp::Size (2048, 1080)), libdcp::Size (1485, 1080)); + + r = Ratio::from_id ("166"); + BOOST_CHECK (r); + BOOST_CHECK_EQUAL (r->size(libdcp::Size (2048, 1080)), libdcp::Size (1793, 1080)); + + r = Ratio::from_id ("178"); + BOOST_CHECK (r); + BOOST_CHECK_EQUAL (r->size(libdcp::Size (2048, 1080)), libdcp::Size (1920, 1080)); + + r = Ratio::from_id ("185"); + BOOST_CHECK (r); + BOOST_CHECK_EQUAL (r->size(libdcp::Size (2048, 1080)), libdcp::Size (1998, 1080)); + + r = Ratio::from_id ("239"); + BOOST_CHECK (r); + BOOST_CHECK_EQUAL (r->size(libdcp::Size (2048, 1080)), libdcp::Size (2048, 858)); + + r = Ratio::from_id ("full-frame"); + BOOST_CHECK (r); + BOOST_CHECK_EQUAL (r->size(libdcp::Size (2048, 1080)), libdcp::Size (2048, 1080)); +} + diff --git a/test/scaling_test.cc b/test/scaling_test.cc index 60009f10b..dba611043 100644 --- a/test/scaling_test.cc +++ b/test/scaling_test.cc @@ -17,15 +17,56 @@ */ +#include "imagemagick_content.h" + /** @file test/scaling_test.cc * @brief Test scaling and black-padding of images from a still-image source. */ using boost::shared_ptr; +static void scaling_test_for (shared_ptr<Film> film, shared_ptr<VideoContent> content, string image, string container) +{ + content->set_ratio (Ratio::from_id (image)); + film->set_container (Ratio::from_id (container)); + film->make_dcp (); + + while (JobManager::instance()->work_to_do ()); + + BOOST_CHECK (!JobManager::instance()->errors()); + + boost::filesystem::path ref; + ref = "test"; + ref /= "data"; + ref /= "scaling_test_" + image + "_" + container; + + boost::filesystem::path check; + check = "build"; + check /= "test"; + check /= "scaling_test"; + check /= film->dcp_name(); + + check_dcp (ref.string(), check.string()); +} + BOOST_AUTO_TEST_CASE (scaling_test) { shared_ptr<Film> film = new_test_film ("scaling_test"); - film->examine_and_add_content (shared_ptr<Content> (new ImageMagickContent ("test/data/simple_testcard_640x480.png"))); + film->set_dcp_content_type (DCPContentType::from_dci_name ("FTR")); + film->set_name ("scaling_test"); + shared_ptr<ImageMagickContent> imc (new ImageMagickContent (film, "test/data/simple_testcard_640x480.png")); + + film->examine_and_add_content (imc); + while (JobManager::instance()->work_to_do ()); + imc->set_video_length (1); + + scaling_test_for (film, imc, "133", "185"); + scaling_test_for (film, imc, "185", "185"); + scaling_test_for (film, imc, "239", "185"); + + scaling_test_for (film, imc, "133", "239"); + scaling_test_for (film, imc, "185", "239"); + scaling_test_for (film, imc, "239", "239"); } + diff --git a/test/test.cc b/test/test.cc index 7d49bb66a..2837729c5 100644 --- a/test/test.cc +++ b/test/test.cc @@ -22,7 +22,8 @@ #include <boost/filesystem.hpp> #include <boost/algorithm/string/predicate.hpp> #include <boost/date_time.hpp> -#include "format.h" +#include <libdcp/dcp.h> +#include "ratio.h" #include "film.h" #include "filter.h" #include "job_manager.h" @@ -40,7 +41,6 @@ #include "ffmpeg_decoder.h" #include "sndfile_decoder.h" #include "dcp_content_type.h" -#include "container.h" #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE dcpomatic_test #include <boost/test/unit_test.hpp> @@ -49,6 +49,8 @@ using std::string; using std::list; using std::stringstream; using std::vector; +using std::min; +using std::cout; using boost::shared_ptr; using boost::thread; using boost::dynamic_pointer_cast; @@ -93,13 +95,67 @@ new_test_film (string name) return f; } +void +check_file (string ref, string check) +{ + uintmax_t N = boost::filesystem::file_size (ref); + BOOST_CHECK_EQUAL (N, boost::filesystem::file_size(check)); + FILE* ref_file = fopen (ref.c_str(), "rb"); + BOOST_CHECK (ref_file); + FILE* check_file = fopen (check.c_str(), "rb"); + BOOST_CHECK (check_file); + + int const buffer_size = 65536; + uint8_t* ref_buffer = new uint8_t[buffer_size]; + uint8_t* check_buffer = new uint8_t[buffer_size]; + + while (N) { + uintmax_t this_time = min (uintmax_t (buffer_size), N); + size_t r = fread (ref_buffer, 1, this_time, ref_file); + BOOST_CHECK_EQUAL (r, this_time); + r = fread (check_buffer, 1, this_time, check_file); + BOOST_CHECK_EQUAL (r, this_time); + + BOOST_CHECK_EQUAL (memcmp (ref_buffer, check_buffer, this_time), 0); + N -= this_time; + } + + delete[] ref_buffer; + delete[] check_buffer; + + fclose (ref_file); + fclose (check_file); +} + +static void +note (libdcp::NoteType, string n) +{ + cout << n << "\n"; +} + +void +check_dcp (string ref, string check) +{ + libdcp::DCP ref_dcp (ref); + ref_dcp.read (); + libdcp::DCP check_dcp (check); + check_dcp.read (); + + libdcp::EqualityOptions options; + options.max_mean_pixel_error = 5; + options.max_std_dev_pixel_error = 5; + options.max_audio_sample_error = 255; + + BOOST_CHECK (ref_dcp.equals (check_dcp, options, boost::bind (note, _1, _2))); +} + + #include "scaling_test.cc" -#include "container_test.cc" +#include "ratio_test.cc" #include "pixel_formats_test.cc" #include "make_black_test.cc" #include "film_metadata_test.cc" #include "stream_test.cc" -#include "format_test.cc" #include "util_test.cc" #include "dcp_test.cc" #include "frame_rate_test.cc" |
