X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=generate_dvd.cpp;h=1d43a9aba9e9527c1dce6ba1a0a23fd8238b4850;hb=refs%2Ftags%2F1.2;hp=eb8fc0498fe0895cde21234810bfa5cc671773b6;hpb=2bc553f13070e61f28fb28ec333d9abd710d2b51;p=videolink.git
diff --git a/generate_dvd.cpp b/generate_dvd.cpp
index eb8fc04..1d43a9a 100644
--- a/generate_dvd.cpp
+++ b/generate_dvd.cpp
@@ -88,8 +88,8 @@ namespace
double menu_duration_seconds(const video::frame_params & params)
{
return double(menu_duration_frames(params))
- * double(params.rate_numer)
- / double(params.rate_denom);
+ / double(params.rate_numer)
+ * double(params.rate_denom);
}
void throw_length_error(const char * limit_type, std::size_t limit)
@@ -105,6 +105,17 @@ namespace
// domain. This seems to be an oddity of the parser that could be
// fixed, but for now we'll have to work with it.
const unsigned dvdauthor_anonymous_menus_max = dvd::domain_pgcs_max - 8;
+
+ // The current navigation code packs menu and button number into a
+ // single register, so the number of menus is limited to
+ // dvd::reg_s8_button_mult - 1 == 1023. However temp_file_name()
+ // is limited to 999 numbered files and it seems pointless to
+ // change it to get another 24.
+ // If people really need more we could use separate menu and
+ // button number registers, possibly allowing up to 11900 menus
+ // (the size of the indirect jump tables might become a problem
+ // though).
+ const unsigned menus_max = 999;
}
dvd_generator::dvd_generator(const video::frame_params & frame_params,
@@ -118,8 +129,8 @@ dvd_generator::pgc_ref dvd_generator::add_menu()
{
pgc_ref next_menu(menu_pgc, menus_.size());
- if (next_menu.index == dvdauthor_anonymous_menus_max)
- throw_length_error("number of menus", dvdauthor_anonymous_menus_max);
+ if (next_menu.index == menus_max)
+ throw_length_error("number of menus", menus_max);
menus_.resize(next_menu.index + 1);
return next_menu;
@@ -150,12 +161,12 @@ void dvd_generator::generate_menu_vob(unsigned index,
std::string background_name(
temp_file_name(temp_dir_, "menu-%3d-back.png", 1 + index));
- std::cout << "saving " << background_name << std::endl;
+ std::cout << "INFO: Saving " << background_name << std::endl;
background->save(background_name, "png");
std::string highlights_name(
temp_file_name(temp_dir_, "menu-%3d-links.png", 1 + index));
- std::cout << "saving " << highlights_name << std::endl;
+ std::cout << "INFO: Saving " << highlights_name << std::endl;
highlights->save(highlights_name, "png");
std::string spumux_name(
@@ -200,11 +211,15 @@ void dvd_generator::generate_menu_vob(unsigned index,
}
}
}
+ // Pad vertically to even y coordinates since dvdauthor claims
+ // odd values may result in incorrect display.
+ // XXX This may cause overlappping where it wasn't previously
+ // a problem.
spumux_file << " \n";
+ file <<
+ " \n";
}
- file <<
- " \n";
- }
+ file << " \n";
- file <<
- " \n"
- " \n";
-
- // Generate a titleset for each title. This appears to make
- // jumping to titles a whole lot simpler (but limits us to 99
- // titles).
- for (unsigned title_index = 0;
- title_index != titles_.size();
- ++title_index)
- {
- file <<
- " \n"
- // Generate a dummy menu so that the "menu" button will
- // work. This returns to the source menu via the title
- // menu.
- " \n"
- " \n"
- "
g1 = g2; jump vmgm menu;
\n"
- " \n"
- " \n"
- " \n"
- " \n"
- "
\n";
-
- // Count chapters in the title.
- unsigned n_chapters = 0;
- for (vob_list::const_iterator
- it = titles_[title_index].begin(),
- end = titles_[title_index].end();
- it != end;
- ++it)
+ if (have_real_title)
{
- // Chapter start times may be specified in the "chapters"
- // attribute as a comma-separated list. If this is not
- // specified then the beginning of each file starts a new
- // chapter. Thus the number of chapters in each file is
- // the number of commas in the chapter attribute, plus 1.
- ++n_chapters;
- std::size_t pos = 0;
- while ((pos = it->chapters.find(',', pos)) != std::string::npos)
+ file <<
+ " \n"
+ " \n";
+
+ file << "
\n";
+
+ // Count chapters in the title.
+ unsigned n_chapters = 0;
+ for (vob_list::const_iterator
+ it = titles_[titleset_num - 1].begin(),
+ end = titles_[titleset_num - 1].end();
+ it != end;
+ ++it)
{
+ // Chapter start times may be specified in the "chapters"
+ // attribute as a comma-separated list. If this is not
+ // specified then the beginning of each file starts a new
+ // chapter. Thus the number of chapters in each file is
+ // the number of commas in the chapter attribute, plus 1.
++n_chapters;
- ++pos;
+ std::size_t pos = 0;
+ while ((pos = it->chapters.find(',', pos)) != std::string::npos)
+ {
+ ++n_chapters;
+ ++pos;
+ }
}
- }
- // Generate jump "table" for chapters.
- for (unsigned chapter_num = 1;
- chapter_num <= n_chapters;
- ++chapter_num)
- file <<
- " if (g3 == " << chapter_num << ")\n"
- " jump chapter " << chapter_num << ";\n";
+ // Move the chapter number to scratch so the root menu can
+ // distinguish cases 4 and 5.
+ file << " g0 = g3; g3 = 0;\n";
- file <<
- "
\n";
+ // Copy the latest menu location for use by the post-routine.
+ file << " g4 = g2;\n";
+
+ // Jump to the correct chapter.
+ for (unsigned chapter_num = 1;
+ chapter_num <= n_chapters;
+ ++chapter_num)
+ file <<
+ " if (g0 eq " << 1 + chapter_num << ")\n"
+ " jump chapter " << chapter_num << ";\n";
- for (vob_list::const_iterator
- it = titles_[title_index].begin(),
- end = titles_[title_index].end();
- it != end;
- ++it)
+ file << "
\n";
+
+ for (vob_list::const_iterator
+ it = titles_[titleset_num - 1].begin(),
+ end = titles_[titleset_num - 1].end();
+ it != end;
+ ++it)
+ {
+ file << " chapters.empty())
+ file << " chapters='" << xml_escape(it->chapters) << "'";
+ if (!it->pause.empty())
+ file << " pause='" << xml_escape(it->pause) << "'";
+ file << "/>\n";
+ }
+
+ // If the user has not exited to the menus and then
+ // resumed the title, set the latest menu location to be
+ // the button after the one that linked to this title.
+ // In any case, return to the (root) menu which will
+ // then jump to the correct menu.
+ file <<
+ " \n"
+ " if (g2 eq g4)\n"
+ " g2 = g2 + " << button_mult << ";\n"
+ " call menu;\n"
+ " \n"
+ " \n"
+ " \n";
+ }
+ else if (titleset_num != 0) // && !have_real_title
{
- file << " chapters.empty())
- file << " chapters='" << xml_escape(it->chapters) << "'";
- if (!it->pause.empty())
- file << " pause='" << xml_escape(it->pause) << "'";
- file << "/>\n";
+ file << " \n";
}
- file <<
- " \n"
- // Return to the source menu, but highlight the next button.
- " g2 = g2 + " << button_mult << ";\n"
- " call menu;\n"
- " \n"
- " \n"
- " \n"
- " \n";
+ file << " " << outer_element_name << ">\n";
}
- file <<
- "\n";
-
+ file << "\n";
file.close();
{
@@ -566,7 +711,7 @@ void dvd_generator::generate(const std::string & output_dir) const
Glib::OWNERSHIP_NONE),
Glib::SPAWN_SEARCH_PATH
| Glib::SPAWN_STDOUT_TO_DEV_NULL,
- SigC::Slot0(),
+ sigc::slot(),
0, 0,
&command_result);
if (command_result != 0)