Skip to content

Commit

Permalink
build(deps): Raise ffmpeg minimum to 4.0 (released in 2018) (AcademyS…
Browse files Browse the repository at this point in the history
…oftwareFoundation#4352)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
  • Loading branch information
lgritz authored Jul 21, 2024
1 parent 10d6bff commit a8d06f3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 31 deletions.
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**.
* If you want support for camera "RAW" formats:
* **LibRaw >= 0.20** (tested though 0.21.2)
* If you want support for a wide variety of video formats:
* ffmpeg >= 3.0 (tested through 7.0)
* **ffmpeg >= 4.0** (tested through 7.0)
* If you want support for jpeg 2000 images:
* OpenJpeg >= 2.0 (tested through 2.5; we recommend 2.4 or higher
for multithreading support)
Expand Down
2 changes: 1 addition & 1 deletion src/cmake/externalpackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ checked_find_package (TBB 2017
# DCMTK is used to read DICOM images
checked_find_package (DCMTK CONFIG VERSION_MIN 3.6.1)

checked_find_package (FFmpeg VERSION_MIN 3.0)
checked_find_package (FFmpeg VERSION_MIN 4.0)
checked_find_package (GIF
VERSION_MIN 4
RECOMMEND_MIN 5.0
Expand Down
40 changes: 11 additions & 29 deletions src/ffmpeg.imageio/ffmpeginput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@
// SPDX-License-Identifier: BSD-3-Clause and Apache-2.0
// https://github.com/AcademySoftwareFoundation/OpenImageIO

extern "C" { // ffmpeg is a C api
#include <cerrno>

extern "C" { // ffmpeg is a C api
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 24, 100)
# error "OIIO FFmpeg support requires FFmpeg >= 3.0"
#endif
#include <libavutil/imgutils.h>
}

// It's hard to figure out FFMPEG versions from what they give us, so
// record some of the milestones once and for all for easy reference.
Expand All @@ -29,6 +25,12 @@ extern "C" { // ffmpeg is a C api
#define USE_FFMPEG_4_3 (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58, 91, 100))
#define USE_FFMPEG_4_4 (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58, 134, 100))

#if !USE_FFMPEG_4_0
# error "OIIO FFmpeg support requires FFmpeg >= 4.0"
#endif

#include <libavutil/imgutils.h>
}


inline int
Expand All @@ -41,9 +43,9 @@ avpicture_fill(AVFrame* picture, uint8_t* ptr, enum AVPixelFormat pix_fmt,
}


#if USE_FFMPEG_3_1
// AVStream::codec was changed to AVStream::codecpar
# define stream_codec(ix) m_format_context->streams[(ix)]->codecpar
#define stream_codec(ix) m_format_context->streams[(ix)]->codecpar


// avcodec_decode_video2 was deprecated.
// This now works by sending `avpkt` to the decoder, which buffers the
// decoded image in `avctx`. Then `avcodec_receive_frame` will copy the
Expand All @@ -65,16 +67,6 @@ receive_frame(AVCodecContext* avctx, AVFrame* picture, AVPacket* avpkt)

return 1;
}
#else
# define stream_codec(ix) m_format_context->streams[(ix)]->codec
inline int
receive_frame(AVCodecContext* avctx, AVFrame* picture, AVPacket* avpkt)
{
int ret;
avcodec_decode_video2(avctx, picture, &ret, avpkt);
return ret;
}
#endif



Expand Down Expand Up @@ -265,7 +257,6 @@ FFmpegInput::open(const std::string& name, ImageSpec& spec)
}

// codec context for videostream
#if USE_FFMPEG_3_1
AVCodecParameters* par = stream_codec(m_video_stream);

m_codec = avcodec_find_decoder(par->codec_id);
Expand All @@ -287,15 +278,6 @@ FFmpegInput::open(const std::string& name, ImageSpec& spec)
errorfmt("\"{}\" unsupported codec", file_name);
return false;
}
#else
m_codec_context = stream_codec(m_video_stream);

m_codec = avcodec_find_decoder(m_codec_context->codec_id);
if (!m_codec) {
errorfmt("\"{}\" unsupported codec", file_name);
return false;
}
#endif

if (avcodec_open2(m_codec_context, m_codec, NULL) < 0) {
errorfmt("\"{}\" could not open codec", file_name);
Expand Down

0 comments on commit a8d06f3

Please sign in to comment.