+ const video::frame_params & lookup_frame_params(const char * str)
+ {
+ assert(str);
+ static const struct { const char * str; bool is_ntsc; }
+ known_strings[] = {
+ { "NTSC", true },
+ { "ntsc", true },
+ { "PAL", false },
+ { "pal", false },
+ // For DVD purposes, SECAM can be treated identically to PAL.
+ { "SECAM", false },
+ { "secam", false }
+ };
+ for (std::size_t i = 0;
+ i != sizeof(known_strings)/sizeof(known_strings[0]);
+ ++i)
+ if (std::strcmp(str, known_strings[i].str) == 0)
+ return known_strings[i].is_ntsc ?
+ video::ntsc_params : video::pal_params;
+ throw std::runtime_error(
+ std::string("Invalid video standard: ").append(str));
+ }
+
+ void print_usage(std::ostream & stream, const char * command_name)
+ {
+ stream << "Usage: " << command_name
+ << (" [gtk-options] [--video-std std-name]"
+ " [--preview] menu-url [output-dir]\n");
+ }
+
+ void set_browser_preferences()
+ {
+ nsCOMPtr<nsIPrefService> pref_service;
+ static const nsCID pref_service_cid = NS_PREFSERVICE_CID;
+ check(CallGetService<nsIPrefService>(pref_service_cid,
+ getter_AddRefs(pref_service)));
+ nsCOMPtr<nsIPrefBranch> pref_branch;
+
+ // Disable IE-compatibility kluge that causes backgrounds to
+ // sometimes/usually be missing from snapshots. This is only
+ // effective from Mozilla 1.8 onward.
+# if MOZ_VERSION_MAJOR > 1 \
+ || (MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR >= 8)
+ check(pref_service->GetDefaultBranch("layout",
+ getter_AddRefs(pref_branch)));
+ check(pref_branch->SetBoolPref(
+ "fire_onload_after_image_background_loads",
+ true));
+# endif
+
+ // Set display resolution. With standard-definition video we
+ // will be fitting ~600 pixels across a screen typically
+ // ranging from 10 to 25 inches wide, for a resolution of
+ // 24-60 dpi. I therefore declare the average horizontal
+ // resolution to be 40 dpi. The vertical resolution will be
+ // slightly higher (PAL/SECAM) or lower (NTSC), but
+ // unfortunately Mozilla doesn't support non-square pixels
+ // (and neither do fontconfig or Xft anyway).
+ check(pref_service->GetDefaultBranch("browser.display",
+ getter_AddRefs(pref_branch)));
+ check(pref_branch->SetIntPref("screen_resolution", 40));
+ }
+