Don't emit subtitle images that have a zero dimension (#2743).
authorCarl Hetherington <cth@carlh.net>
Thu, 1 Feb 2024 12:29:53 +0000 (13:29 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 3 Feb 2024 08:57:25 +0000 (09:57 +0100)
They cause problems later when trying to blend them into the image.

run/tests
src/lib/player.cc
test/burnt_subtitle_test.cc
test/data

index 12d59346d9a7020fc55654dd5ea0043b44e2a5aa..4315e227f8f5171f999461e67c804395120c3905 100755 (executable)
--- a/run/tests
+++ b/run/tests
@@ -3,7 +3,7 @@
 # e.g. --run_tests=foo
 set -e
 
-PRIVATE_GIT="59b62615a48a1f3a70e9c028b92dfba75c1719ba"
+PRIVATE_GIT="f4b0c41b263a17cf33edae7565f16bd21eb80b65"
 
 if [ "$1" == "--check" ]; then
        shift 1
index ef7ecde5a4d762bdf2dfc86d24344b2f03fd66b8..79b48ea71cd13f70191bba0690d3969eea2b68b4 100644 (file)
@@ -921,7 +921,7 @@ Player::open_subtitles_for_frame (DCPTime time) const
 
                /* Bitmap subtitles */
                for (auto i: j.bitmap) {
-                       if (!i.image) {
+                       if (!i.image || i.image->size().width == 0 || i.image->size().height == 0) {
                                continue;
                        }
 
@@ -942,7 +942,10 @@ Player::open_subtitles_for_frame (DCPTime time) const
                /* String subtitles (rendered to an image) */
                if (!j.string.empty()) {
                        auto s = render_text(j.string, _video_container_size, time, vfr);
-                       copy (s.begin(), s.end(), back_inserter (captions));
+                       copy_if(s.begin(), s.end(), back_inserter(captions), [](PositionImage const& image) {
+                               return image.image->size().width && image.image->size().height;
+                       });
+
                }
        }
 
index 9c6863a1dd407262e86f7060879fea006f19cc74..8d7dcd143f872357fec0f542aceb3a7289e9e9cb 100644 (file)
@@ -30,6 +30,7 @@
 #include "lib/dcp_content.h"
 #include "lib/dcp_content_type.h"
 #include "lib/film.h"
+#include "lib/ffmpeg_encoder.h"
 #include "lib/log_entry.h"
 #include "lib/ratio.h"
 #include "lib/text_content.h"
@@ -184,3 +185,24 @@ BOOST_AUTO_TEST_CASE(burnt_subtitle_test_position)
        /* Should have a baseline 864 pixels from the top ((1 - 0.2) * 1080) */
        check("bottom");
 }
+
+
+/* Bug #2743 */
+BOOST_AUTO_TEST_CASE(burn_empty_subtitle_test)
+{
+       Cleanup cl;
+
+       auto content = content_factory("test/data/empty_sub.xml")[0];
+       auto film = new_test_film2("burnt_empty_subtitle_test", { content });
+       content->text[0]->set_use(true);
+
+       auto job = make_shared<TranscodeJob>(film, TranscodeJob::ChangedBehaviour::IGNORE);
+       auto file = boost::filesystem::path("build") / "test" / "burnt_empty_subtitle_test.mov";
+       cl.add(file);
+       FFmpegEncoder encoder(film, job, file, ExportFormat::PRORES_4444, false, false, false, 23);
+       encoder.go();
+
+       cl.run();
+}
+
+
index a81d5737e54105f95d3d0cbf602dd355b8814244..704f7643393caa29d77ddba138bff3642b273c46 160000 (submodule)
--- a/test/data
+++ b/test/data
@@ -1 +1 @@
-Subproject commit a81d5737e54105f95d3d0cbf602dd355b8814244
+Subproject commit 704f7643393caa29d77ddba138bff3642b273c46