{
switch (_pixel_format) {
case PIX_FMT_YUV420P:
- case PIX_FMT_YUV422P10LE:
case PIX_FMT_YUV422P:
memset (data()[0], 0, lines(0) * stride()[0]);
- memset (data()[1], 0x80, lines(1) * stride()[1]);
- memset (data()[2], 0x80, lines(2) * stride()[2]);
+ memset (data()[1], 0x7f, lines(1) * stride()[1]);
+ memset (data()[2], 0x7f, lines(2) * stride()[2]);
break;
+ case PIX_FMT_YUV422P10LE:
+ memset (data()[0], 0, lines(0) * stride()[0]);
+ for (int i = 1; i < 3; ++i) {
+ int16_t* p = reinterpret_cast<int16_t*> (data()[i]);
+ for (int y = 0; y < size().height; ++y) {
+ for (int x = 0; x < line_size()[i] / 2; ++x) {
+ p[x] = (1 << 9) - 1;
+ }
+ p += stride()[i] / 2;
+ }
+ }
+ break;
+
case PIX_FMT_RGB24:
memset (data()[0], 0, lines(0) * stride()[0]);
break;
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";