Skip to content

Commit

Permalink
Remove ffms2 version ifdefs
Browse files Browse the repository at this point in the history
  • Loading branch information
arch1t3cht committed Jan 12, 2025
1 parent 2eb7364 commit 08e9e80
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/video_provider_ffmpegsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,9 @@ class FFmpegSourceVideoProvider final : public VideoProvider, FFmpegSourceProvid

int GetFrameCount() const override { return VideoInfo->NumFrames; }

#if FFMS_VERSION >= ((2 << 24) | (24 << 16) | (0 << 8) | 0)
int GetWidth() const override { return (VideoInfo->Rotation % 180 == 90 || VideoInfo->Rotation % 180 == -90) ? Height : Width; }
int GetHeight() const override { return (VideoInfo->Rotation % 180 == 90 || VideoInfo->Rotation % 180 == -90) ? Width : Height; }
double GetDAR() const override { return (VideoInfo->Rotation % 180 == 90 || VideoInfo->Rotation % 180 == -90) ? 1 / DAR : DAR; }
#else
int GetWidth() const override { return Width; }
int GetHeight() const override { return Height; }
double GetDAR() const override { return DAR; }
#endif

agi::vfr::Framerate GetFPS() const override { return Timecodes; }
std::string GetColorSpace() const override { return ColorSpace; }
Expand Down Expand Up @@ -230,10 +224,6 @@ void FFmpegSourceVideoProvider::LoadVideo(agi::fs::path const& filename, std::st

// set thread count
int Threads = OPT_GET("Provider/Video/FFmpegSource/Decoding Threads")->GetInt();
#if FFMS_VERSION < ((2 << 24) | (30 << 16) | (0 << 8) | 0)
if (FFMS_GetVersion() < ((2 << 24) | (17 << 16) | (2 << 8) | 1) && FFMS_GetSourceType(Index) == FFMS_SOURCE_LAVF)
Threads = 1;
#endif

// set seekmode
// TODO: give this its own option?
Expand Down Expand Up @@ -323,7 +313,7 @@ void FFmpegSourceVideoProvider::GetFrame(int n, VideoFrame &out) {
out.width = Width;
out.height = Height;
out.pitch = frame->Linesize[0];
#if FFMS_VERSION >= ((2 << 24) | (31 << 16) | (0 << 8) | 0)

// Handle flip
if (VideoInfo->Flip > 0)
for (int x = 0; x < Height; ++x)
Expand All @@ -336,8 +326,7 @@ void FFmpegSourceVideoProvider::GetFrame(int n, VideoFrame &out) {
for (int y = 0; y < Width; ++y)
for (int ch = 0; ch < 4; ++ch)
std::swap(out.data[frame->Linesize[0] * x + 4 * y + ch], out.data[frame->Linesize[0] * (Height - 1 - x) + 4 * y + ch]);
#endif
#if FFMS_VERSION >= ((2 << 24) | (24 << 16) | (0 << 8) | 0)

// Handle rotation
if (VideoInfo->Rotation % 360 == 180 || VideoInfo->Rotation % 360 == -180) {
std::vector<unsigned char> data(std::move(out.data));
Expand Down Expand Up @@ -370,7 +359,6 @@ void FFmpegSourceVideoProvider::GetFrame(int n, VideoFrame &out) {
out.height = Width;
out.pitch = 4 * Height;
}
#endif
}
}

Expand Down

0 comments on commit 08e9e80

Please sign in to comment.