Merge pull request #9825 from hasenbanck/ffmpeg-deps

Fix ffmpeg core build under linux.
This commit is contained in:
Twinaphex 2019-12-05 23:37:01 +01:00 committed by GitHub
commit c198c0737a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 9 deletions

View File

@ -20,6 +20,7 @@ extern "C" {
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>
#include <libavutil/error.h>
#include <libavutil/hwcontext.h>
#include <libavutil/imgutils.h>
#include <libavutil/time.h>
#include <libavutil/opt.h>
@ -87,12 +88,14 @@ static AVCodecContext *vctx;
static int video_stream_index;
static enum AVColorSpace colorspace;
#if LIBAVUTIL_VERSION_MAJOR > 55
static enum AVPixelFormat pix_fmt;
static enum AVHWDeviceType hw_decoder;
static bool force_sw_decoder;
static int sw_decoder_threads;
static bool force_sw_decoder;
static bool hw_decoding_enabled;
#endif
#define MAX_STREAMS 8
static AVCodecContext *actx[MAX_STREAMS];
@ -278,9 +281,11 @@ void CORE_PREFIX(retro_get_system_av_info)(struct retro_system_av_info *info)
void CORE_PREFIX(retro_set_environment)(retro_environment_t cb)
{
static const struct retro_variable vars[] = {
#if LIBAVUTIL_VERSION_MAJOR > 55
{ "ffmpeg_hw_decoder", "Use Hardware decoder (restart); auto|off|"
"cuda|d3d11va|drm|dxva2|mediacodec|opencl|qsv|vaapi|vdpau|videotoolbox" },
{ "ffmpeg_sw_decoder_threads", "Software decoder thread count (restart); 1|2|4|8" },
#endif
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
{ "ffmpeg_temporal_interp", "Temporal Interpolation; disabled|enabled" },
#ifdef HAVE_GL_FFT
@ -407,6 +412,7 @@ static void check_variables(bool firststart)
slock_unlock(decode_thread_lock);
}
#if LIBAVUTIL_VERSION_MAJOR > 55
if (firststart)
{
hw_var.key = "ffmpeg_hw_decoder";
@ -448,6 +454,7 @@ static void check_variables(bool firststart)
sw_decoder_threads = strtoul(sw_threads_var.value, NULL, 0);
slock_unlock(decode_thread_lock);
}
#endif
}
static void seek_frame(int seek_frames)
@ -815,6 +822,7 @@ void CORE_PREFIX(retro_run)(void)
CORE_PREFIX(audio_batch_cb)(audio_buffer, to_read_frames);
}
#if LIBAVUTIL_VERSION_MAJOR > 55
/* Try to initialize a specific HW decoder defined by type */
static enum AVPixelFormat init_hw_decoder(struct AVCodecContext *ctx,
const enum AVPixelFormat *pix_fmts,
@ -931,6 +939,7 @@ static enum AVPixelFormat get_format(AVCodecContext *ctx,
return pix_fmt;
}
#endif
static bool open_codec(AVCodecContext **ctx, unsigned index)
{
@ -1049,8 +1058,10 @@ static bool open_codecs(void)
{
if (!open_codec(&vctx, i))
return false;
#if LIBAVUTIL_VERSION_MAJOR > 55
pix_fmt = AV_PIX_FMT_NONE;
vctx->get_format = get_format;
#endif
video_stream_index = i;
}
break;
@ -1230,7 +1241,12 @@ static void render_ass_img(AVFrame *conv_frame, ASS_Image *img)
}
#endif
#ifdef HAVE_SSA
static void decode_video(AVCodecContext *ctx, AVPacket *pkt, AVFrame *conv_frame, size_t frame_size, struct SwsContext **sws, ASS_Track *ass_track_active)
#else
static void decode_video(AVCodecContext *ctx, AVPacket *pkt, AVFrame *conv_frame, size_t frame_size, struct SwsContext **sws)
#endif
{
int ret;
AVFrame *frame = NULL;
@ -1264,6 +1280,7 @@ static void decode_video(AVCodecContext *ctx, AVPacket *pkt, AVFrame *conv_frame
goto fail;
}
#if LIBAVUTIL_VERSION_MAJOR > 55
if (hw_decoding_enabled)
{
/* Copy data from VRAM to RAM */
@ -1275,6 +1292,7 @@ static void decode_video(AVCodecContext *ctx, AVPacket *pkt, AVFrame *conv_frame
tmp_frame = sw_frame;
}
else
#endif
tmp_frame = frame;
*sws = sws_getCachedContext(*sws,
@ -1536,7 +1554,11 @@ static void decode_thread(void *data)
slock_unlock(decode_thread_lock);
if (pkt.stream_index == video_stream_index)
#ifdef HAVE_SSA
decode_video(vctx, &pkt, conv_frame, frame_size, &sws, ass_track_active);
#else
decode_video(vctx, &pkt, conv_frame, frame_size, &sws);
#endif
else if (pkt.stream_index == audio_stream && actx_active)
{
audio_buffer = decode_audio(actx_active, &pkt, aud_frame,

View File

@ -387,13 +387,12 @@ check_lib '' DRMINGW -lexchndl
check_enabled THREADS FFMPEG FFmpeg 'Threads are' false
if [ "$HAVE_FFMPEG" != 'no' ]; then
check_val '' AVCODEC -lavcodec '' libavcodec 54 '' false
check_val '' AVFORMAT -lavformat '' libavformat 54 '' false
check_val '' AVDEVICE -lavdevice '' libavdevice '' '' false
check_val '' SWRESAMPLE -lswresample '' libswresample '' '' false
check_val '' AVRESAMPLE -lavresample '' libavresample '' '' false
check_val '' AVUTIL -lavutil '' libavutil 51 '' false
check_val '' SWSCALE -lswscale '' libswscale 2.1 '' false
check_val '' AVCODEC -lavcodec '' libavcodec 57 '' false
check_val '' AVFORMAT -lavformat '' libavformat 57 '' false
check_val '' AVDEVICE -lavdevice '' libavdevice 57 '' false
check_val '' SWRESAMPLE -lswresample '' libswresample 2 '' false
check_val '' AVUTIL -lavutil '' libavutil 55 '' false
check_val '' SWSCALE -lswscale '' libswscale 4 '' false
check_header AV_CHANNEL_LAYOUT libavutil/channel_layout.h