Ticket #1365: add-display-res-option.diff

File add-display-res-option.diff, 2.7 KB (added by cantabile, 18 months ago)
  • src/dialog_options.cpp

     
    385385                Bind(control,_T("Show keyframes on video slider")); 
    386386                videoSizer3->Add(control,0,wxEXPAND); 
    387387                videoSizer3->AddGrowableCol(1,1); 
     388                control = new wxCheckBox(videoPage,-1,_("Use display aspect ratio (ffmpegsource only)")); 
     389                Bind(control,_T("Use display aspect ratio")); 
     390                videoSizer3->Add(control,0,wxEXPAND); 
     391                videoSizer3->AddGrowableCol(1,1); 
    388392 
    389393                // Second sizer 
    390394                videoSizer4->Add(new wxStaticText(videoPage,-1,_("Video provider: ")),0,wxALIGN_CENTER_VERTICAL | wxRIGHT,10); 
  • src/options.cpp

     
    159159        SetBool(_T("Show keyframes on video slider"),true); 
    160160        SetBool(_T("Show overscan mask"),false); 
    161161 
     162        SetModificationType(MOD_VIDEO_RELOAD); 
     163        SetBool(_T("Use display aspect ratio"),false); 
     164 
    162165        // Video Provider (Advanced) 
    163166        SetModificationType(MOD_VIDEO_RELOAD); 
    164167        SetInt(_T("Avisynth MemoryMax"),64,1700); 
  • src/video_context.cpp

     
    216216                int n = frame_n; 
    217217                SetVideo(_T("")); 
    218218                SetVideo(name); 
     219                // without this, subtitles don't appear anymore 
     220                Refresh(true, true); 
     221                // without this, the video doesn't get resized 
     222                UpdateDisplays(true); 
    219223                JumpToFrame(n); 
    220224        } 
    221225} 
  • src/video_provider_ffmpegsource.cpp

     
    224224                ErrorMsg.Append(wxString::Format(_T("Failed to decode first frame: %s"), ErrInfo.Buffer)); 
    225225                throw ErrorMsg; 
    226226        } 
     227 
    227228        Width   = TempFrame->EncodedWidth; 
    228229        Height  = TempFrame->EncodedHeight; 
    229230 
     231        // possibly request the frames at their display resolution 
     232        if (Options.AsBool(_T("Use display aspect ratio"))) { 
     233                int sarNumerator   = VideoInfo->SARNum; 
     234                int sarDenominator = VideoInfo->SARDen; 
     235                // check them both lest we divide by zero 
     236                if (sarNumerator != 0 && sarDenominator != 0) { 
     237                        if (sarNumerator > sarDenominator) { 
     238                                Width = Width * sarNumerator / sarDenominator; 
     239                        } 
     240                        else if (sarNumerator < sarDenominator) { 
     241                                Height = Height * sarDenominator / sarNumerator; 
     242                        } 
     243                } 
     244        } 
     245 
    230246        if (FFMS_SetOutputFormatV(VideoSource, 1 << FFMS_GetPixFmt("bgra"), Width, Height, FFMS_RESIZER_BICUBIC, &ErrInfo)) { 
    231247                ErrorMsg.Append(wxString::Format(_T("Failed to set output format: %s"), ErrInfo.Buffer)); 
    232248                throw ErrorMsg;