Automatically set the aspect ratio when opening anamorphic video with ffms

Originally committed to SVN as r6506.
This commit is contained in:
Thomas Goyne 2012-02-23 01:30:59 +00:00
parent 7e87e95526
commit ea130d9af2
8 changed files with 20 additions and 4 deletions

View File

@ -60,6 +60,7 @@ public:
virtual int GetFrameCount() const=0; ///< Get total number of frames
virtual int GetWidth() const=0; ///< Returns the video width in pixels
virtual int GetHeight() const=0; ///< Returns the video height in pixels
virtual double GetDAR() const=0; ///< Returns the video display aspect ratio
virtual agi::vfr::Framerate GetFPS() const=0; ///< Get frame rate
virtual std::vector<int> GetKeyFrames() const=0;///< Returns list of keyframes

View File

@ -186,6 +186,11 @@ void VideoContext::SetVideo(const wxString &filename) {
}
}
// Set aspect ratio
double dar = videoProvider->GetDAR();
if (dar > 0)
SetAspectRatio(4, dar);
// Set filename
config::mru->Add("Video", STD_STR(filename));
StandardPaths::SetPathValue("?video", wxFileName(filename).GetPath());

View File

@ -70,6 +70,7 @@ public:
agi::vfr::Framerate GetFPS() const { return fps; };
int GetWidth() const { return vi.width; };
int GetHeight() const { return vi.height; };
double GetDAR() const { return 0; }
std::vector<int> GetKeyFrames() const { return KeyFrames; };
wxString GetWarning() const { return warning; }
wxString GetDecoderName() const { return decoderName; }

View File

@ -68,6 +68,7 @@ public:
int GetFrameCount() const { return master->GetFrameCount(); }
int GetWidth() const { return master->GetWidth(); }
int GetHeight() const { return master->GetHeight(); }
double GetDAR() const { return master->GetDAR(); }
agi::vfr::Framerate GetFPS() const { return master->GetFPS(); }
std::vector<int> GetKeyFrames() const { return master->GetKeyFrames(); }
wxString GetWarning() const { return master->GetWarning(); }

View File

@ -88,6 +88,7 @@ public:
int GetFrameCount() const { return framecount; }
int GetWidth() const { return width; }
int GetHeight() const { return height; }
double GetDAR() const { return 0; }
agi::vfr::Framerate GetFPS() const { return fps; }
std::vector<int> GetKeyFrames() const { return std::vector<int>(); };
wxString GetDecoderName() const { return "Dummy Video Provider"; }

View File

@ -167,11 +167,15 @@ void FFmpegSourceVideoProvider::LoadVideo(wxString filename) {
VideoInfo = FFMS_GetVideoProperties(VideoSource);
const FFMS_Frame *TempFrame = FFMS_GetFrame(VideoSource, 0, &ErrInfo);
if (TempFrame == NULL) {
if (!TempFrame)
throw VideoOpenError(std::string("Failed to decode first frame: ") + ErrInfo.Buffer);
}
Width = TempFrame->EncodedWidth;
Height = TempFrame->EncodedHeight;
Width = TempFrame->EncodedWidth;
Height = TempFrame->EncodedHeight;
if (VideoInfo->SARDen > 0 && VideoInfo->SARNum > 0)
DAR = double(Width * VideoInfo->SARNum) / (Height * VideoInfo->SARDen);
else
DAR = double(Width) / Height;
switch (TempFrame->ColorSpace) {
case FFMS_CS_RGB: ColorSpace = "RGB"; break;

View File

@ -52,6 +52,7 @@ class FFmpegSourceVideoProvider : public VideoProvider, FFmpegSourceProvider {
int Width; ///< width in pixels
int Height; ///< height in pixels
double DAR; ///< display aspect ratio
int FrameNumber; ///< current framenumber
std::vector<int> KeyFramesList; ///< list of keyframes
agi::vfr::Framerate Timecodes; ///< vfr object
@ -72,6 +73,7 @@ public:
int GetFrameCount() const { return VideoInfo->NumFrames; }
int GetWidth() const { return Width; }
int GetHeight() const { return Height; }
double GetDAR() const { return DAR; }
agi::vfr::Framerate GetFPS() const { return Timecodes; }
wxString GetColorSpace() const { return ColorSpace; }

View File

@ -146,6 +146,7 @@ public:
int GetFrameCount() const { return num_frames; }
int GetWidth() const { return w; }
int GetHeight() const { return h; }
double GetDAR() const { return 0; }
agi::vfr::Framerate GetFPS() const { return fps; }
std::vector<int> GetKeyFrames() const { return std::vector<int>(); };
wxString GetDecoderName() const { return "YU4MPEG"; };