Never ask to change the script resolution when opening dummy video

This commit is contained in:
Thomas Goyne 2014-01-24 07:43:47 -08:00
parent 4dd76012cd
commit ab44e51edc
3 changed files with 15 additions and 7 deletions

View file

@ -71,6 +71,9 @@ public:
/// @brief Does this provider want Aegisub to cache video frames?
/// @return Returns true if caching is desired, false otherwise.
virtual bool WantsCaching() const { return false; }
/// Should the video properties in the script be set to this video's property if they already have values?
virtual bool ShouldSetVideoProperties() const { return true; }
};
DEFINE_BASE_EXCEPTION_NOINNER(VideoProviderError, agi::Exception)

View file

@ -122,14 +122,17 @@ void VideoContext::SetVideo(const agi::fs::path &filename) {
bool commit_subs = false;
try {
provider.reset(new ThreadedFrameSource(filename, context->ass->GetScriptInfo("YCbCr Matrix"), this));
auto old_matrix = context->ass->GetScriptInfo("YCbCr Matrix");
provider.reset(new ThreadedFrameSource(filename, old_matrix, this));
video_provider = provider->GetVideoProvider();
video_filename = filename;
// Video provider handles the case where matrix is different but
// compatible, so no need to handle it here
// When opening dummy video only want to set the script properties if
// they were previously unset
bool set_properties = video_provider->ShouldSetVideoProperties();
auto matrix = video_provider->GetColorSpace();
if (!matrix.empty() && matrix != context->ass->GetScriptInfo("YCbCr Matrix")) {
if (set_properties && matrix != old_matrix) {
context->ass->SetScriptInfo("YCbCr Matrix", matrix);
commit_subs = true;
}
@ -149,7 +152,7 @@ void VideoContext::SetVideo(const agi::fs::path &filename) {
}
// If it has been set to something other than a multiple of the video
// resolution, ask the user if they want it to be fixed
else if (sx % vx != 0 || sy % vy != 0) {
else if (set_properties && (sx % vx != 0 || sy % vy != 0)) {
switch (OPT_GET("Video/Check Script Res")->GetInt()) {
case 1: // Ask to change on mismatch
if (wxYES != wxMessageBox(
@ -175,7 +178,8 @@ void VideoContext::SetVideo(const agi::fs::path &filename) {
// Set frame rate
video_fps = video_provider->GetFPS();
if (ovr_fps.IsLoaded()) {
int ovr = wxMessageBox(_("You already have timecodes loaded. Would you like to replace them with timecodes from the video file?"), _("Replace timecodes?"), wxYES_NO | wxICON_QUESTION);
int ovr = wxMessageBox(_("You already have timecodes loaded. Would you like to replace them with timecodes from the video file?"),
_("Replace timecodes?"), wxYES_NO | wxICON_QUESTION);
if (ovr == wxYES) {
ovr_fps = agi::vfr::Framerate();
timecodes_filename.clear();

View file

@ -86,6 +86,7 @@ public:
double GetDAR() const override { return 0; }
agi::vfr::Framerate GetFPS() const override { return fps; }
std::vector<int> GetKeyFrames() const override { return {}; }
std::string GetColorSpace() const override { return ""; }
std::string GetColorSpace() const override { return "None"; }
std::string GetDecoderName() const override { return "Dummy Video Provider"; }
bool ShouldSetVideoProperties() const override { return false; }
};