+/** @param size Size of picture that the subtitle will be overlaid onto */
+void
+emit_subtitle_image (ContentTimePeriod period, dcp::SubtitleImage sub, dcp::Size size, shared_ptr<TextDecoder> decoder)
+{
+ /* XXX: this is rather inefficient; decoding the image just to get its size */
+ FFmpegImageProxy proxy (sub.png_image());
+ shared_ptr<Image> image = proxy.image().first;
+ /* set up rect with height and width */
+ dcpomatic::Rect<double> rect(0, 0, image->size().width / double(size.width), image->size().height / double(size.height));
+
+ /* add in position */
+
+ switch (sub.h_align()) {
+ case dcp::HALIGN_LEFT:
+ rect.x += sub.h_position();
+ break;
+ case dcp::HALIGN_CENTER:
+ rect.x += 0.5 + sub.h_position() - rect.width / 2;
+ break;
+ case dcp::HALIGN_RIGHT:
+ rect.x += 1 - sub.h_position() - rect.width;
+ break;
+ }
+
+ switch (sub.v_align()) {
+ case dcp::VALIGN_TOP:
+ rect.y += sub.v_position();
+ break;
+ case dcp::VALIGN_CENTER:
+ rect.y += 0.5 + sub.v_position() - rect.height / 2;
+ break;
+ case dcp::VALIGN_BOTTOM:
+ rect.y += 1 - sub.v_position() - rect.height;
+ break;
+ }
+
+ decoder->emit_bitmap (period, image, rect);
+}
+
+bool
+show_jobs_on_console (bool progress)
+{
+ bool first = true;
+ bool error = false;
+ while (true) {
+
+ dcpomatic_sleep_seconds (5);
+
+ list<shared_ptr<Job> > jobs = JobManager::instance()->get();
+
+ if (!first && progress) {
+ for (size_t i = 0; i < jobs.size(); ++i) {
+ cout << "\033[1A\033[2K";
+ }
+ cout.flush ();
+ }
+
+ first = false;
+
+ BOOST_FOREACH (shared_ptr<Job> i, jobs) {
+ if (progress) {
+ cout << i->name();
+ if (!i->sub_name().empty()) {
+ cout << "; " << i->sub_name();
+ }
+ cout << ": ";
+
+ if (i->progress ()) {
+ cout << i->status() << " \n";
+ } else {
+ cout << ": Running \n";
+ }
+ }
+
+ if (!progress && i->finished_in_error()) {
+ /* We won't see this error if we haven't been showing progress,
+ so show it now.
+ */
+ cout << i->status() << "\n";
+ }
+
+ if (i->finished_in_error()) {
+ error = true;
+ }
+ }
+
+ if (!JobManager::instance()->work_to_do()) {
+ break;
+ }
+ }
+
+ return error;
+}
+