diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-01-23 14:42:56 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-01-23 14:42:56 +0000 |
| commit | d58f9adc515ac0c0193a4998fed3605f4e2c6e11 (patch) | |
| tree | 8b9c48af8f50af93aa6dfd5e9852f4a6ffb21865 /test | |
| parent | 3886847e2dafdaec4ad780dac606802356beb31d (diff) | |
Fix and test Image::make_black().
Diffstat (limited to 'test')
| -rw-r--r-- | test/test.cc | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/test/test.cc b/test/test.cc index 7e1d92e06..13eb1f17f 100644 --- a/test/test.cc +++ b/test/test.cc @@ -69,9 +69,69 @@ new_test_film (string name) return shared_ptr<Film> (new Film (d, false)); } -BOOST_AUTO_TEST_CASE (film_metadata_test) + +/* Check that Image::make_black works, and doesn't use values which crash + sws_scale(). +*/ +BOOST_AUTO_TEST_CASE (make_black_test) { + /* This needs to happen in the first test */ dvdomatic_setup (); + + libdcp::Size in_size (512, 512); + libdcp::Size out_size (1024, 1024); + + { + /* Plain RGB input */ + boost::shared_ptr<Image> foo (new SimpleImage (AV_PIX_FMT_RGB24, 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); + + uint8_t* p = bar->data()[0]; + for (int y = 0; y < bar->size().height; ++y) { + uint8_t* q = p; + for (int x = 0; x < bar->line_size()[0]; ++x) { + BOOST_CHECK_EQUAL (*q++, 0); + } + p += bar->stride()[0]; + } + } + + { + /* YUV420P input */ + boost::shared_ptr<Image> foo (new SimpleImage (AV_PIX_FMT_YUV420P, 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); + + uint8_t* p = bar->data()[0]; + for (int y = 0; y < bar->size().height; ++y) { + uint8_t* q = p; + for (int x = 0; x < bar->line_size()[0]; ++x) { + BOOST_CHECK_EQUAL (*q++, 0); + } + p += bar->stride()[0]; + } + } + + { + /* YUV422P10LE input */ + boost::shared_ptr<Image> foo (new SimpleImage (AV_PIX_FMT_YUV422P10LE, 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); + + uint8_t* p = bar->data()[0]; + for (int y = 0; y < bar->size().height; ++y) { + uint8_t* q = p; + for (int x = 0; x < bar->line_size()[0]; ++x) { + BOOST_CHECK_EQUAL (*q++, 0); + } + p += bar->stride()[0]; + } + } +} + +BOOST_AUTO_TEST_CASE (film_metadata_test) +{ setup_test_config (); string const test_film = "build/test/film_metadata_test"; |
