Skip to content
Snippets Groups Projects
Commit 64322318 authored by Philippe Gorley's avatar Philippe Gorley Committed by Kateryna Kostiuk
Browse files

osx: bump ffmpeg


Bumps FFmpeg to match the other platforms. Modifies the acceleration
code to work under the new API.

Enables bitstream filters, as some of libavcodec's components, such as
VideoToolbox, use them.

Change-Id: I3a6cee2cf06881bba4602c0ed635ff45908e7b85
Reviewed-by: default avatarKateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
parent 5f042df9
Branches
No related tags found
No related merge requests found
......@@ -425,18 +425,6 @@ AS_IF([test "x$with_restcpp" = "xyes"], [
);
dnl Check for libav
AS_IF([test "${SYS}" = "darwin"], [
PKG_CHECK_MODULES(LIBAVUTIL, libavutil >= 55.58.100,, AC_MSG_ERROR([Missing libavutil development files]))
PKG_CHECK_MODULES(LIBAVCODEC, libavcodec >= 53.89.100,, AC_MSG_ERROR([Missing libavcodec development files]))
LIBAVCODEC_CFLAGS="${LIBAVCODEC_CFLAGS} -D__STDC_CONSTANT_MACROS"
PKG_CHECK_MODULES(LIBAVFORMAT, libavformat >= 57.71.100,, AC_MSG_ERROR([Missing libavformat development files]))
PKG_CHECK_MODULES(LIBAVDEVICE, libavdevice >= 57.6.100,, AC_MSG_ERROR([Missing libavdevice development files]))
PKG_CHECK_MODULES(LIBSWSCALE, libswscale >= 4.6.100,, AC_MSG_ERROR([Missing libswscale development files]))
],[
PKG_CHECK_MODULES(LIBAVUTIL, libavutil >= 55.75.100,, AC_MSG_ERROR([Missing libavutil development files]))
PKG_CHECK_MODULES(LIBAVCODEC, libavcodec >= 53.106.101,, AC_MSG_ERROR([Missing libavcodec development files]))
......@@ -447,7 +435,6 @@ AS_IF([test "${SYS}" = "darwin"], [
PKG_CHECK_MODULES(LIBAVDEVICE, libavdevice >= 57.8.101,, AC_MSG_ERROR([Missing libavdevice development files]))
PKG_CHECK_MODULES(LIBSWSCALE, libswscale >= 4.7.103,, AC_MSG_ERROR([Missing libswscale development files]))
]);
dnl Video is default-enabled
AC_ARG_ENABLE([video], AS_HELP_STRING([--disable-video], [Disable video]))
......
ifndef HAVE_MACOSX
FFMPEG_HASH := 18516d3e695980525bd9758dc7b8a8e36cd3f09e
else
FFMPEG_HASH := n3.3.3
endif
FFMPEG_URL := https://git.ffmpeg.org/gitweb/ffmpeg.git/snapshot/$(FFMPEG_HASH).tar.gz
PKGS+=ffmpeg
......@@ -24,6 +20,7 @@ FFMPEGCONF += \
--enable-gpl \
--enable-swscale \
--enable-protocols \
--enable-bsfs \
--disable-programs
#enable muxers/demuxers
......@@ -136,7 +133,7 @@ endif
ifdef HAVE_MACOSX
FFMPEGCONF += \
--disable-sdl \
--enable-avfoundation \
--enable-indev=avfoundation \
--enable-videotoolbox \
--enable-hwaccel=h263_videotoolbox \
......
......@@ -28,6 +28,7 @@
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavutil/hwcontext.h>
#include <libavcodec/videotoolbox.h>
#include <libavutil/imgutils.h>
}
......@@ -48,6 +49,10 @@ class VideoToolboxAccel : public HardwareAccel {
bool init() override;
int allocateBuffer(AVFrame* frame, int flags) override;
void extractData(VideoFrame& input, VideoFrame& output) override;
private:
using AVBufferRefPtr = std::unique_ptr<AVBufferRef, std::function<void(AVBufferRef*)>>;
AVBufferRefPtr deviceBufferRef_;
};
}} // namespace ring::video
......
......@@ -35,8 +35,11 @@
namespace ring { namespace video {
static auto avBufferRefDeleter = [](AVBufferRef* buf){ av_buffer_unref(&buf); };
VideoToolboxAccel::VideoToolboxAccel(const std::string name, const AVPixelFormat format)
: HardwareAccel(name, format)
, deviceBufferRef_(nullptr, avBufferRefDeleter)
{
}
......@@ -127,16 +130,22 @@ VideoToolboxAccel::extractData(VideoFrame& input, VideoFrame& output)
bool
VideoToolboxAccel::checkAvailability()
{
// VideoToolbox is always present on Mac 10.8+ and iOS 8+
// VDA is always present on Mac 10.6.3+
AVBufferRef* hardwareDeviceCtx;
if (av_hwdevice_ctx_create(&hardwareDeviceCtx, AV_HWDEVICE_TYPE_VIDEOTOOLBOX, nullptr, nullptr, 0) == 0) {
deviceBufferRef_.reset(hardwareDeviceCtx);
return true;
}
av_buffer_unref(&hardwareDeviceCtx);
return false;
}
bool
VideoToolboxAccel::init()
{
if (av_videotoolbox_default_init(codecCtx_) >= 0) {
RING_DBG("VideoToolbox decoder initialized");
codecCtx_->hw_device_ctx = av_buffer_ref(deviceBufferRef_.get());
return true;
} else {
RING_ERR("Failed to initialize VideoToolbox decoder");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment