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)
+ {
+ std::ostringstream oss;
+ oss << "exceeded DVD limit: " << limit_type << " > " << limit;
+ throw std::length_error(oss.str());
+ }
+
+ // dvdauthor uses some menu numbers to represent entry points -
+ // distinct from the actual numbers of the menus assigned as those
+ // entry points - resulting in a practical limit of 119 per
+ // 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;
}
dvd_generator::dvd_generator(const video::frame_params & frame_params,
{
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 == dvdauthor_anonymous_menus_max)
+ throw_length_error("number of menus", dvdauthor_anonymous_menus_max);
menus_.resize(next_menu.index + 1);
return next_menu;
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);
}
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);