From: Ben Hutchings Date: Wed, 1 Nov 2006 01:19:26 +0000 (+0000) Subject: Placed DVD limit values consistently in dvd.hpp. X-Git-Tag: 1.1~4 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=b463276d863f86a4268b5cac63fc6879ad6517bc;p=videolink.git Placed DVD limit values consistently in dvd.hpp. Made limit checking consistent and placed it all in generate_dvd.cpp. --- diff --git a/dvd.hpp b/dvd.hpp index 9811fa3..db0f983 100644 --- a/dvd.hpp +++ b/dvd.hpp @@ -4,18 +4,27 @@ namespace dvd { // Maximum number of buttons in a menu. - const int menu_buttons_max = 36; + const unsigned menu_buttons_max = 36; // Number of colours allowed in each button. // Buttons can change colour when they are selected. - const int button_n_colours = 4; + const unsigned button_n_colours = 4; // DVD virtual machine register size. - const int reg_bits = 16; + const unsigned reg_bits = 16; // Number by which button numbers must be multiplied when stored in // system register 8. - const int reg_s8_button_mult = 0x400; + const unsigned reg_s8_button_mult = 0x400; + + // Maximum number of PGCs in a domain that can be linked to. + // dvdauthor uses some menu numbers for special purposes, + // resulting in a practical limit of 119 per domain. + const unsigned domain_pgcs_max = 119; + + // Maximum number of titles on a disc. (Also the maximum number of + // titlesets per disc.) + const unsigned titles_max = 99; } #endif // !INC_DVD_HPP diff --git a/generate_dvd.cpp b/generate_dvd.cpp index 64079d2..7f496c2 100644 --- a/generate_dvd.cpp +++ b/generate_dvd.cpp @@ -91,6 +91,13 @@ namespace * double(params.rate_numer) / double(params.rate_denom); } + + void throw_length_error(const char * limit_type, std::size_t limit) + { + std::ostringstream oss; + oss << "exceeded DVD limit: " << limit_type << " > " << limit; + throw std::length_error(oss.str()); + } } dvd_generator::dvd_generator(const video::frame_params & frame_params, @@ -104,13 +111,8 @@ dvd_generator::pgc_ref dvd_generator::add_menu() { pgc_ref next_menu(menu_pgc, menus_.size()); - // Check against maximum number of menus. It appears that no more - // than 128 menus are reachable through LinkPGCN instructions, and - // dvdauthor uses some menu numbers for special purposes, resulting - // in a practical limit of 119 per domain. We can work around this - // later by spreading some menus across titlesets. - if (next_menu.index == 119) - throw std::runtime_error("No more than 119 menus can be used"); + if (next_menu.index == dvd::domain_pgcs_max) + throw_length_error("number of menus", dvd::domain_pgcs_max); menus_.resize(next_menu.index + 1); return next_menu; @@ -123,6 +125,10 @@ void dvd_generator::add_menu_entry(unsigned index, assert(index < menus_.size()); assert(target.type == menu_pgc && target.index < menus_.size() || target.type == title_pgc && target.index < titles_.size()); + + if (menus_[index].entries.size() == dvd::menu_buttons_max) + throw_length_error("number of buttons", dvd::menu_buttons_max); + menu_entry new_entry = { area, target }; menus_[index].entries.push_back(new_entry); } @@ -276,8 +282,8 @@ dvd_generator::pgc_ref dvd_generator::add_title(vob_list & content) pgc_ref next_title(title_pgc, titles_.size()); // Check against maximum number of titles. - if (next_title.index == 99) - throw std::runtime_error("No more than 99 titles can be used"); + if (next_title.index == dvd::titles_max) + throw_length_error("number of titles", dvd::titles_max); titles_.resize(next_title.index + 1); titles_[next_title.index].swap(content); diff --git a/videolink.cpp b/videolink.cpp index 3d88f4e..a5792bb 100644 --- a/videolink.cpp +++ b/videolink.cpp @@ -428,7 +428,6 @@ namespace Gdk::COLORSPACE_RGB, true, 8, // has_alpha, bits_per_sample width, height)), - link_num(0), links_it(doc), link_changing(false) { @@ -437,7 +436,6 @@ namespace Glib::RefPtr norm_pixbuf; Glib::RefPtr diff_pixbuf; - unsigned link_num; link_iterator links_it, links_end; rectangle link_rect; @@ -609,18 +607,6 @@ namespace continue; } - ++state->link_num; - - if (state->link_num >= unsigned(dvd::menu_buttons_max)) - { - if (state->link_num == unsigned(dvd::menu_buttons_max)) - std::cerr << "No more than " << dvd::menu_buttons_max - << " buttons can be placed on a menu\n"; - std::cerr << "Ignoring link to " << uri_and_fragment - << "\n"; - continue; - } - // Check whether this is a link to a video or a page then // add it to the known resources if not already seen; then // add it to the menu entries.