summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--audio/aframe.c6
-rw-r--r--audio/decode/ad_lavc.c9
-rw-r--r--audio/decode/ad_spdif.c4
-rw-r--r--common/av_log.c23
-rw-r--r--common/recorder.c2
-rw-r--r--demux/codec_tags.c6
-rw-r--r--demux/demux_lavf.c2
-rw-r--r--demux/packet.c4
-rw-r--r--filters/f_lavfi.c16
-rw-r--r--filters/f_swresample.c74
-rw-r--r--stream/stream_lavf.c4
-rw-r--r--sub/lavc_conv.c15
-rw-r--r--sub/sd_lavc.c4
-rw-r--r--video/decode/vd_lavc.c5
-rw-r--r--video/fmt-conversion.c19
-rw-r--r--video/img_format.c8
-rw-r--r--video/mp_image.c7
-rw-r--r--video/out/gpu/hwdec.c2
-rw-r--r--video/sws_utils.c2
-rw-r--r--wscript72
-rw-r--r--wscript_build.py4
21 files changed, 31 insertions, 257 deletions
diff --git a/audio/aframe.c b/audio/aframe.c
index 655a4a38c3..35259ba208 100644
--- a/audio/aframe.c
+++ b/audio/aframe.c
@@ -121,11 +121,9 @@ struct mp_aframe *mp_aframe_from_avframe(struct AVFrame *av_frame)
frame->format = format;
mp_chmap_from_lavc(&frame->chmap, frame->av_frame->channel_layout);
-#if LIBAVUTIL_VERSION_MICRO >= 100
// FFmpeg being a stupid POS again
if (frame->chmap.num != frame->av_frame->channels)
mp_chmap_from_channels(&frame->chmap, av_frame->channels);
-#endif
if (av_frame->opaque_ref) {
struct avframe_opaque *op = (void *)av_frame->opaque_ref->data;
@@ -194,10 +192,8 @@ void mp_aframe_config_copy(struct mp_aframe *dst, struct mp_aframe *src)
dst->av_frame->sample_rate = src->av_frame->sample_rate;
dst->av_frame->format = src->av_frame->format;
dst->av_frame->channel_layout = src->av_frame->channel_layout;
-#if LIBAVUTIL_VERSION_MICRO >= 100
// FFmpeg being a stupid POS again
dst->av_frame->channels = src->av_frame->channels;
-#endif
}
// Copy "soft" attributes from src to dst, excluding things which affect
@@ -311,10 +307,8 @@ bool mp_aframe_set_chmap(struct mp_aframe *frame, struct mp_chmap *in)
return false;
frame->chmap = *in;
frame->av_frame->channel_layout = lavc_layout;
-#if LIBAVUTIL_VERSION_MICRO >= 100
// FFmpeg being a stupid POS again
frame->av_frame->channels = frame->chmap.num;
-#endif
return true;
}
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c
index 8362e918f3..63f9aa0cbe 100644
--- a/audio/decode/ad_lavc.c
+++ b/audio/decode/ad_lavc.c
@@ -103,10 +103,7 @@ static bool init(struct mp_filter *da, struct mp_codec_params *codec,
ctx->avframe = av_frame_alloc();
lavc_context->codec_type = AVMEDIA_TYPE_AUDIO;
lavc_context->codec_id = lavc_codec->id;
-
-#if LIBAVCODEC_VERSION_MICRO >= 100
lavc_context->pkt_timebase = ctx->codec_timebase;
-#endif
if (opts->downmix && mpopts->audio_output_channels.num_chmaps == 1) {
lavc_context->request_channel_layout =
@@ -117,10 +114,8 @@ static bool init(struct mp_filter *da, struct mp_codec_params *codec,
av_opt_set_double(lavc_context, "drc_scale", opts->ac3drc,
AV_OPT_SEARCH_CHILDREN);
-#if LIBAVCODEC_VERSION_MICRO >= 100
// Let decoder add AV_FRAME_DATA_SKIP_SAMPLES.
av_opt_set(lavc_context, "flags2", "+skip_manual", AV_OPT_SEARCH_CHILDREN);
-#endif
mp_set_avopts(da->log, lavc_context, opts->avopts);
@@ -199,10 +194,8 @@ static int receive_frame(struct mp_filter *da, struct mp_frame *out)
MP_ERR(da, "Error decoding audio.\n");
}
-#if LIBAVCODEC_VERSION_MICRO >= 100
if (priv->avframe->flags & AV_FRAME_FLAG_DISCARD)
av_frame_unref(priv->avframe);
-#endif
if (!priv->avframe->buf[0])
return ret;
@@ -224,7 +217,6 @@ static int receive_frame(struct mp_filter *da, struct mp_frame *out)
priv->next_pts = mp_aframe_end_pts(mpframe);
-#if LIBAVCODEC_VERSION_MICRO >= 100
AVFrameSideData *sd =
av_frame_get_side_data(priv->avframe, AV_FRAME_DATA_SKIP_SAMPLES);
if (sd && sd->size >= 10) {
@@ -232,7 +224,6 @@ static int receive_frame(struct mp_filter *da, struct mp_frame *out)
priv->skip_samples += AV_RL32(d + 0);
priv->trim_samples += AV_RL32(d + 4);
}
-#endif
if (!priv->preroll_done) {
// Skip only if this isn't already handled by AV_FRAME_DATA_SKIP_SAMPLES.
diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c
index ef34042990..0b1977769a 100644
--- a/audio/decode/ad_spdif.c
+++ b/audio/decode/ad_spdif.c
@@ -176,10 +176,8 @@ static int init_filter(struct mp_filter *da, AVPacket *pkt)
goto fail;
}
- // Request minimal buffering (not available on Libav)
-#if LIBAVFORMAT_VERSION_MICRO >= 100
+ // Request minimal buffering
lavf_ctx->pb->direct = 1;
-#endif
AVStream *stream = avformat_new_stream(lavf_ctx, 0);
if (!stream)
diff --git a/common/av_log.c b/common/av_log.c
index 8b0cb09efa..d7df24e05c 100644
--- a/common/av_log.c
+++ b/common/av_log.c
@@ -35,6 +35,7 @@
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
+#include <libswresample/swresample.h>
#include <libswscale/swscale.h>
#include <libavfilter/avfilter.h>
@@ -42,18 +43,6 @@
#include <libavdevice/avdevice.h>
#endif
-#if HAVE_LIBAV
-#include <libavresample/avresample.h>
-#else
-#include <libswresample/swresample.h>
-#endif
-
-#if LIBAVCODEC_VERSION_MICRO >= 100
-#define LIB_PREFIX "ffmpeg"
-#else
-#define LIB_PREFIX "libav"
-#endif
-
// Needed because the av_log callback does not provide a library-safe message
// callback.
static pthread_mutex_t log_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -151,7 +140,7 @@ void init_libav(struct mpv_global *global)
pthread_mutex_lock(&log_lock);
if (!log_mpv_instance) {
log_mpv_instance = global;
- log_root = mp_log_new(NULL, global->log, LIB_PREFIX);
+ log_root = mp_log_new(NULL, global->log, "ffmpeg");
log_decaudio = mp_log_new(log_root, log_root, "audio");
log_decvideo = mp_log_new(log_root, log_root, "video");
log_demuxer = mp_log_new(log_root, log_root, "demuxer");
@@ -195,14 +184,10 @@ bool print_libav_versions(struct mp_log *log, int v)
{"libavformat", LIBAVFORMAT_VERSION_INT, avformat_version()},
{"libswscale", LIBSWSCALE_VERSION_INT, swscale_version()},
{"libavfilter", LIBAVFILTER_VERSION_INT, avfilter_version()},
-#if HAVE_LIBAV
- {"libavresample", LIBAVRESAMPLE_VERSION_INT, avresample_version()},
-#else
{"libswresample", LIBSWRESAMPLE_VERSION_INT, swresample_version()},
-#endif
};
- mp_msg(log, v, "%s library versions:\n", LIB_PREFIX);
+ mp_msg(log, v, "FFmpeg library versions:\n");
bool mismatch = false;
for (int n = 0; n < MP_ARRAY_SIZE(libs); n++) {
@@ -216,7 +201,7 @@ bool print_libav_versions(struct mp_log *log, int v)
mp_msg(log, v, "\n");
}
- mp_msg(log, v, "%s version: %s\n", LIB_PREFIX, av_version_info());
+ mp_msg(log, v, "FFmpeg version: %s\n", av_version_info());
return !mismatch;
}
diff --git a/common/recorder.c b/common/recorder.c
index 1af736a71d..58bf257883 100644
--- a/common/recorder.c
+++ b/common/recorder.c
@@ -91,14 +91,12 @@ static int add_stream(struct mp_recorder *priv, struct sh_stream *sh)
if (!avp)
return -1;
-#if LIBAVCODEC_VERSION_MICRO >= 100
// We don't know the delay, so make something up. If the format requires
// DTS, the result will probably be broken. FFmpeg provides nothing better
// yet (unless you demux with libavformat, which contains tons of hacks
// that try to determine a PTS).
if (!sh->codec->lav_codecpar)
avp->video_delay = 16;
-#endif
if (avp->codec_id == AV_CODEC_ID_NONE)
return -1;
diff --git a/demux/codec_tags.c b/demux/codec_tags.c
index ea6c8fe19d..8f8c97ec38 100644
--- a/demux/codec_tags.c
+++ b/demux/codec_tags.c
@@ -24,24 +24,18 @@
#include "stheader.h"
#include "common/av_common.h"
-#define HAVE_QT_TAGS (LIBAVFORMAT_VERSION_MICRO >= 100)
-
static const char *lookup_tag(int type, uint32_t tag)
{
const struct AVCodecTag *av_tags[3] = {0};
switch (type) {
case STREAM_VIDEO: {
av_tags[0] = avformat_get_riff_video_tags();
-#if HAVE_QT_TAGS
av_tags[1] = avformat_get_mov_video_tags();
-#endif
break;
}
case STREAM_AUDIO: {
av_tags[0] = avformat_get_riff_audio_tags();
-#if HAVE_QT_TAGS
av_tags[1] = avformat_get_mov_audio_tags();
-#endif
break;
}
}
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index c2f6a65395..f4bbfc5739 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -1161,10 +1161,8 @@ static bool demux_lavf_read_packet(struct demuxer *demux,
dp->duration = pkt->duration * av_q2d(st->time_base);
dp->pos = pkt->pos;
dp->keyframe = pkt->flags & AV_PKT_FLAG_KEY;
-#if LIBAVFORMAT_VERSION_MICRO >= 100
if (pkt->flags & AV_PKT_FLAG_DISCARD)
MP_ERR(demux, "Edit lists are not correctly supported (FFmpeg issue).\n");
-#endif
av_packet_unref(pkt);
if (priv->format_hack.clear_filepos)
diff --git a/demux/packet.c b/demux/packet.c
index de47c28dbc..1a460b0ccb 100644
--- a/demux/packet.c
+++ b/demux/packet.c
@@ -198,7 +198,6 @@ size_t demux_packet_estimate_total_size(struct demux_packet *dp)
int demux_packet_set_padding(struct demux_packet *dp, int start, int end)
{
-#if LIBAVCODEC_VERSION_MICRO >= 100
if (!start && !end)
return 0;
if (!dp->avpacket)
@@ -209,14 +208,12 @@ int demux_packet_set_padding(struct demux_packet *dp, int start, int end)
AV_WL32(p + 0, start);
AV_WL32(p + 4, end);
-#endif
return 0;
}
int demux_packet_add_blockadditional(struct demux_packet *dp, uint64_t id,
void *data, size_t size)
{
-#if LIBAVCODEC_VERSION_MICRO >= 100
if (!dp->avpacket)
return -1;
uint8_t *sd = av_packet_new_side_data(dp->avpacket,
@@ -227,6 +224,5 @@ int demux_packet_add_blockadditional(struct demux_packet *dp, uint64_t id,
AV_WB64(sd, id);
if (size > 0)
memcpy(sd + 8, data, size);
-#endif
return 0;
}
diff --git a/filters/f_lavfi.c b/filters/f_lavfi.c
index db01e27e3e..18bad4b5f4 100644
--- a/filters/f_lavfi.c
+++ b/filters/f_lavfi.c
@@ -50,11 +50,6 @@
#include "filter_internal.h"
#include "user_filters.h"
-#if LIBAVFILTER_VERSION_MICRO < 100
-#define av_buffersink_get_frame_flags(a, b, c) av_buffersink_get_frame(a, b)
-#define AV_BUFFERSINK_FLAG_NO_REQUEST 0
-#endif
-
struct lavfi {
struct mp_log *log;
struct mp_filter *f;
@@ -529,13 +524,11 @@ error:
static void dump_graph(struct lavfi *c)
{
-#if LIBAVFILTER_VERSION_MICRO >= 100
MP_DBG(c, "Filter graph:\n");
char *s = avfilter_graph_dump(c->graph, NULL);
if (s)
MP_DBG(c, "%s\n", s);
av_free(s);
-#endif
}
// Initialize the graph if all inputs have formats set. If it's already
@@ -591,10 +584,7 @@ static bool feed_input_pads(struct lavfi *c)
for (int n = 0; n < c->num_in_pads; n++) {
struct lavfi_pad *pad = c->in_pads[n];
- bool requested = true;
-#if LIBAVFILTER_VERSION_MICRO >= 100
- requested = av_buffersrc_get_nb_failed_requests(pad->buffer) > 0;
-#endif
+ bool requested = av_buffersrc_get_nb_failed_requests(pad->buffer) > 0;
// Always request a frame after EOF so that we can know if the EOF state
// changes (e.g. for sparse streams with midstream EOF).
@@ -705,9 +695,7 @@ static bool read_output_pads(struct lavfi *c)
}
if (r >= 0) {
-#if LIBAVUTIL_VERSION_MICRO >= 100
mp_tags_copy_from_av_dictionary(pad->metadata, c->tmp_frame->metadata);
-#endif
struct mp_frame frame =
mp_frame_from_av(pad->type, c->tmp_frame, &pad->timebase);
if (c->emulate_audio_pts && frame.type == MP_FRAME_AUDIO) {
@@ -807,12 +795,10 @@ static bool lavfi_command(struct mp_filter *f, struct mp_filter_command *cmd)
return false;
switch (cmd->type) {
-#if LIBAVFILTER_VERSION_MICRO >= 100
case MP_FILTER_COMMAND_TEXT: {
return avfilter_graph_send_command(c->graph, "all", cmd->cmd, cmd->arg,
&(char){0}, 0, 0) >= 0;
}
-#endif
case MP_FILTER_COMMAND_GET_META: {
// We can worry later about what it should do to multi output filters.
if (c->num_out_pads < 1)
diff --git a/filters/f_swresample.c b/filters/f_swresample.c
index 8ee44195a8..0f4033b26a 100644
--- a/filters/f_swresample.c
+++ b/filters/f_swresample.c
@@ -20,6 +20,7 @@
#include <libavutil/samplefmt.h>
#include <libavutil/channel_layout.h>
#include <libavutil/mathematics.h>
+#include <libswresample/swresample.h>
#include "config.h"
@@ -35,35 +36,14 @@
#include "f_swresample.h"
#include "filter_internal.h"
-#define HAVE_LIBSWRESAMPLE (!HAVE_LIBAV)
-#define HAVE_LIBAVRESAMPLE HAVE_LIBAV
-
-#if HAVE_LIBAVRESAMPLE
-#include <libavresample/avresample.h>
-#elif HAVE_LIBSWRESAMPLE
-#include <libswresample/swresample.h>
-#define AVAudioResampleContext SwrContext
-#define avresample_alloc_context swr_alloc
-#define avresample_open swr_init
-#define avresample_close(x) do { } while(0)
-#define avresample_free swr_free
-#define avresample_available(x) 0
-#define avresample_convert(ctx, out, out_planesize, out_samples, in, in_planesize, in_samples) \
- swr_convert(ctx, out, out_samples, (const uint8_t**)(in), in_samples)
-#define avresample_set_channel_mapping swr_set_channel_mapping
-#define avresample_set_compensation swr_set_compensation
-#else
-#error "config.h broken or no resampler found"
-#endif
-
struct priv {
struct mp_log *log;
bool is_resampling;
- struct AVAudioResampleContext *avrctx;
+ struct SwrContext *avrctx;
struct mp_aframe *avrctx_fmt; // output format of avrctx
struct mp_aframe *pool_fmt; // format used to allocate frames for avrctx output
struct mp_aframe *pre_out_fmt; // format before final conversion
- struct AVAudioResampleContext *avrctx_out; // for output channel reordering
+ struct SwrContext *avrctx_out; // for output channel reordering
struct mp_resample_opts *opts; // opts requested by the user
// At least libswresample keeps a pointer around for this:
int reorder_in[MP_NUM_CHANNELS];
@@ -106,17 +86,6 @@ const struct m_sub_options resample_conf = {
.change_flags = UPDATE_AUDIO,
};
-#if HAVE_LIBAVRESAMPLE
-static double get_delay(struct priv *p)
-{
- return avresample_get_delay(p->avrctx) / (double)p->in_rate +
- avresample_available(p->avrctx) / (double)p->out_rate;
-}
-static int get_out_samples(struct priv *p, int in_samples)
-{
- return avresample_get_out_samples(p->avrctx, in_samples);
-}
-#else
static double get_delay(struct priv *p)
{
int64_t base = p->in_rate * (int64_t)p->out_rate;
@@ -126,16 +95,11 @@ static int get_out_samples(struct priv *p, int in_samples)
{
return swr_get_out_samples(p->avrctx, in_samples);
}
-#endif
static void close_lavrr(struct priv *p)
{
- if (p->avrctx)
- avresample_close(p->avrctx);
- avresample_free(&p->avrctx);
- if (p->avrctx_out)
- avresample_close(p->avrctx_out);
- avresample_free(&p->avrctx_out);
+ swr_free(&p->avrctx);
+ swr_free(&p->avrctx_out);
TA_FREEP(&p->pre_out_fmt);
TA_FREEP(&p->avrctx_fmt);
@@ -206,8 +170,8 @@ static bool configure_lavrr(struct priv *p, bool verbose)
p->out_rate, mp_chmap_to_str(&p->out_channels),
af_fmt_to_str(p->out_format));
- p->avrctx = avresample_alloc_context();
- p->avrctx_out = avresample_alloc_context();
+ p->avrctx = swr_alloc();
+ p->avrctx_out = swr_alloc();
if (!p->avrctx || !p->avrctx_out)
goto error;
@@ -234,11 +198,7 @@ static bool configure_lavrr(struct priv *p, bool verbose)
av_opt_set_double(p->avrctx, "cutoff", cutoff, 0);
int normalize = p->opts->normalize;
-#if HAVE_LIBSWRESAMPLE
av_opt_set_double(p->avrctx, "rematrix_maxval", normalize ? 1 : 1000, 0);
-#else
- av_opt_set_int(p->avrctx, "normalize_mix_level", !!normalize, 0);
-#endif
if (mp_set_avopts(p->log, p->avrctx, p->opts->avopts) < 0)
goto error;
@@ -337,11 +297,11 @@ static bool configure_lavrr(struct priv *p, bool verbose)
// API has weird requirements, quoting avresample.h:
// * This function can only be called when the allocated context is not open.
// * Also, the input channel layout must have already been set.
- avresample_set_channel_mapping(p->avrctx, p->reorder_in);
+ swr_set_channel_mapping(p->avrctx, p->reorder_in);
p->is_resampling = false;
- if (avresample_open(p->avrctx) < 0 || avresample_open(p->avrctx_out) < 0) {
+ if (swr_init(p->avrctx) < 0 || swr_init(p->avrctx_out) < 0) {
MP_ERR(p, "Cannot open Libavresample context.\n");
goto error;
}
@@ -363,13 +323,9 @@ static void reset(struct mp_filter *f)
if (!p->avrctx)
return;
-#if HAVE_LIBSWRESAMPLE
swr_close(p->avrctx);
if (swr_init(p->avrctx) < 0)
close_lavrr(p);
-#else
- while (avresample_read(p->avrctx, NULL, 1000) > 0) {}
-#endif
}
static void extra_output_conversion(struct mp_aframe *mpa)
@@ -428,7 +384,7 @@ static bool reorder_planes(struct mp_aframe *mpa, int *reorder,
return true;
}
-static int resample_frame(struct AVAudioResampleContext *r,
+static int resample_frame(struct SwrContext *r,
struct mp_aframe *out, struct mp_aframe *in,
int consume_in)
{
@@ -437,12 +393,10 @@ static int resample_frame(struct AVAudioResampleContext *r,
// or after conversion. The sample rates can also be different.
AVFrame *av_i = in ? mp_aframe_get_raw_avframe(in) : NULL;
AVFrame *av_o = out ? mp_aframe_get_raw_avframe(out) : NULL;
- return avresample_convert(r,
+ return swr_convert(r,
av_o ? av_o->extended_data : NULL,
- av_o ? av_o->linesize[0] : 0,
av_o ? av_o->nb_samples : 0,
- av_i ? av_i->extended_data : NULL,
- av_i ? av_i->linesize[0] : 0,
+ (const uint8_t **)(av_i ? av_i->extended_data : NULL),
av_i ? MPMIN(av_i->nb_samples, consume_in) : 0);
}
@@ -634,7 +588,7 @@ static void process(struct mp_filter *f)
if (p->avrctx && use_comp) {
AVRational r =
av_d2q(p->speed * p->in_rate_user / p->in_rate, INT_MAX / 2);
- // Essentially, swr/avresample_set_compensation() does 2 things:
+ // Essentially, swr_set_compensation() does 2 things:
// - adjust output sample rate by sample_delta/compensation_distance
// - reset the adjustment after compensation_distance output samples
// Increase the compensation_distance to avoid undesired reset
@@ -644,7 +598,7 @@ static void process(struct mp_filter *f)
r = (AVRational){ r.num * mult, r.den * mult };
if (r.den == r.num)
r = (AVRational){0}; // fully disable
- if (avresample_set_compensation(p->avrctx, r.den - r.num, r.den) >= 0) {
+ if (swr_set_compensation(p->avrctx, r.den - r.num, r.den) >= 0) {
exact_rate = true;
p->is_resampling = true; // libswresample can auto-enable it
}
diff --git a/stream/stream_lavf.c b/stream/stream_lavf.c
index 9762253799..8180a8e69f 100644
--- a/stream/stream_lavf.c
+++ b/stream/stream_lavf.c
@@ -81,11 +81,7 @@ static struct mp_tags *read_icy(stream_t *stream);
static int fill_buffer(stream_t *s, void *buffer, int max_len)
{
AVIOContext *avio = s->priv;
-#if LIBAVFORMAT_VERSION_MICRO >= 100 && LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 81, 100)
int r = avio_read_partial(avio, buffer, max_len);
-#else
- int r = avio_read(avio, buffer, max_len);
-#endif
return (r <= 0) ? -1 : r;
}
diff --git a/sub/lavc_conv.c b/sub/lavc_conv.c
index 4824344a19..d47b0c4c07 100644
--- a/sub/lavc_conv.c
+++ b/sub/lavc_conv.c
@@ -31,8 +31,6 @@
#include "misc/bstr.h"
#include "sd.h"
-#define HAVE_AV_WEBVTT (LIBAVCODEC_VERSION_MICRO >= 100)
-
struct lavc_conv {
struct mp_log *log;
AVCodecContext *avctx;
@@ -94,10 +92,8 @@ struct lavc_conv *lavc_conv_create(struct mp_log *log, const char *codec_name,
av_dict_free(&opts);
// Documented as "set by libavcodec", but there is no other way
avctx->time_base = (AVRational) {1, 1000};
-#if LIBAVCODEC_VERSION_MICRO >= 100
avctx->pkt_timebase = avctx->time_base;
avctx->sub_charenc_mode = FF_SUB_CHARENC_MODE_IGNORE;
-#endif
priv->avctx = avctx;
priv->extradata = talloc_strndup(priv, avctx->subtitle_header,
avctx->subtitle_header_size);
@@ -117,8 +113,6 @@ char *lavc_conv_get_extradata(struct lavc_conv *priv)
return priv->extradata;
}
-#if HAVE_AV_WEBVTT
-
// FFmpeg WebVTT packets are pre-parsed in some way. The FFmpeg Matroska
// demuxer does this on its own. In order to free our demuxer_mkv.c from
// codec-specific crud, we do this here.
@@ -220,15 +214,6 @@ static int parse_webvtt(AVPacket *in, AVPacket *pkt)
return 0;
}
-#else
-
-static int parse_webvtt(AVPacket *in, AVPacket *pkt)
-{
- return -1;
-}
-
-#endif
-
// Return a NULL-terminated list of ASS event lines and have
// the AVSubtitle display PTS and duration set to input
// double variables.
diff --git a/sub/sd_lavc.c b/sub/sd_lavc.c
index 3febe023d6..3ae8fc8905 100644
--- a/sub/sd_lavc.c
+++ b/sub/sd_lavc.c
@@ -78,9 +78,7 @@ static int init(struct sd *sd)
// Supported codecs must be known to decode to paletted bitmaps
switch (cid) {
case AV_CODEC_ID_DVB_SUBTITLE:
-#if LIBAVCODEC_VERSION_MICRO >= 100
case AV_CODEC_ID_DVB_TELETEXT:
-#endif
case AV_CODEC_ID_HDMV_PGS_SUBTITLE:
case AV_CODEC_ID_XSUB:
case AV_CODEC_ID_DVD_SUBTITLE:
@@ -99,9 +97,7 @@ static int init(struct sd *sd)
goto error;
mp_lavc_set_extradata(ctx, sd->codec->extradata, sd->codec->extradata_size);
priv->pkt_timebase = mp_get_codec_timebase(sd->codec);
-#if LIBAVCODEC_VERSION_MICRO >= 100
ctx->pkt_timebase = priv->pkt_timebase;
-#endif
if (avcodec_open2(ctx, sub_codec, NULL) < 0)
goto error;
priv->avctx = ctx;
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index 8f892462a1..b41c4c48c6 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -628,10 +628,7 @@ static void init_avctx(struct mp_filter *vd)
goto error;
avctx->codec_type = AVMEDIA_TYPE_VIDEO;
avctx->codec_id = lavc_codec->id;
-
-#if LIBAVCODEC_VERSION_MICRO >= 100
avctx->pkt_timebase = ctx->codec_timebase;
-#endif
ctx->pic = av_frame_alloc();
if (!ctx->pic)
@@ -1105,10 +1102,8 @@ static int decode_frame(struct mp_filter *vd)
mpi->pts = mp_pts_from_av(ctx->pic->pts, &ctx->codec_timebase);
mpi->dts = mp_pts_from_av(ctx->pic->pkt_dts, &ctx->codec_timebase);
-#if LIBAVCODEC_VERSION_MICRO >= 100
mpi->pkt_duration =
mp_pts_from_av(ctx->pic->pkt_duration, &ctx->codec_timebase);
-#endif
av_frame_unref(ctx->pic);
diff --git a/video/fmt-conversion.c b/video/fmt-conversion.c
index 9f3c6380ff..e18b6a1f8f 100644
--- a/video/fmt-conversion.c
+++ b/video/fmt-conversion.c
@@ -36,9 +36,7 @@ static const struct {
{IMGFMT_PAL8, AV_PIX_FMT_PAL8},
{IMGFMT_UYVY, AV_PIX_FMT_UYVY422},
{IMGFMT_NV12, AV_PIX_FMT_NV12},
-#if LIBAVUTIL_VERSION_MICRO >= 100 && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(56, 27, 0)
{IMGFMT_NV24, AV_PIX_FMT_NV24},
-#endif
{IMGFMT_Y8, AV_PIX_FMT_GRAY8},
{IMGFMT_Y16, AV_PIX_FMT_GRAY16},
{IMGFMT_420P, AV_PIX_FMT_YUV420P},
@@ -49,40 +47,23 @@ static const struct {
{IMGFMT_420P, AV_PIX_FMT_YUVJ420P},
{IMGFMT_444P, AV_PIX_FMT_YUVJ444P},
-#if LIBAVUTIL_VERSION_MICRO >= 100
{IMGFMT_BGR0, AV_PIX_FMT_BGR0},
{IMGFMT_0RGB, AV_PIX_FMT_0RGB},
{IMGFMT_RGB0, AV_PIX_FMT_RGB0},
{IMGFMT_0BGR, AV_PIX_FMT_0BGR},
-#else
- {IMGFMT_BGR0, AV_PIX_FMT_BGRA},
- {IMGFMT_0RGB, AV_PIX_FMT_ARGB},
- {IMGFMT_RGB0, AV_PIX_FMT_RGBA},
- {IMGFMT_0BGR, AV_PIX_FMT_ABGR},
-#endif
{IMGFMT_RGBA64, AV_PIX_FMT_RGBA64},
{IMGFMT_VDPAU, AV_PIX_FMT_VDPAU},
-#if HAVE_VIDEOTOOLBOX_HWACCEL
{IMGFMT_VIDEOTOOLBOX, AV_PIX_FMT_VIDEOTOOLBOX},
-#endif
-#if HAVE_ANDROID
{IMGFMT_MEDIACODEC, AV_PIX_FMT_MEDIACODEC},
-#endif
{IMGFMT_VAAPI, AV_PIX_FMT_VAAPI},
{IMGFMT_DXVA2, AV_PIX_FMT_DXVA2_VLD},
-#if HAVE_D3D_HWACCEL
{IMGFMT_D3D11, AV_PIX_FMT_D3D11},
-#endif
{IMGFMT_MMAL, AV_PIX_FMT_MMAL},
-#if HAVE_CUDA_HWACCEL
{IMGFMT_CUDA, AV_PIX_FMT_CUDA},
-#endif
{IMGFMT_P010, AV_PIX_FMT_P010},
-#if HAVE_DRMPRIME
{IMGFMT_DRMPRIME, AV_PIX_FMT_DRM_PRIME},
-#endif
{0, AV_PIX_FMT_NONE}
};
diff --git a/video/img_format.c b/video/img_format.c
index a21ba6f9cb..63fdb34898 100644
--- a/video/img_format.c
+++ b/video/img_format.c
@@ -377,10 +377,8 @@ enum mp_component_type mp_imgfmt_get_component_type(int imgfmt)
if (!pixdesc || (pixdesc->flags & AV_PIX_FMT_FLAG_HWACCEL))
return MP_COMPONENT_TYPE_UNKNOWN;
-#if LIBAVUTIL_VERSION_MICRO >= 100
if (pixdesc->flags & AV_PIX_FMT_FLAG_FLOAT)
return MP_COMPONENT_TYPE_FLOAT;
-#endif
return MP_COMPONENT_TYPE_UINT;
}
@@ -509,10 +507,8 @@ bool mp_get_regular_imgfmt(struct mp_regular_imgfmt *dst, int imgfmt)
res.chroma_w = 1 << pixdesc->log2_chroma_w;
res.chroma_h = 1 << pixdesc->log2_chroma_h;
-#if LIBAVUTIL_VERSION_MICRO >= 100
if (pixdesc->flags & AV_PIX_FMT_FLAG_BAYER)
return false; // it's satan himself
-#endif
res.forced_csp = mp_imgfmt_get_forced_csp(imgfmt);
@@ -574,10 +570,6 @@ int mp_imgfmt_find(int xs, int ys, int planes, int component_bits, int flags)
return 0;
}
-#if LIBAVUTIL_VERSION_MICRO < 100
-#define avcodec_find_best_pix_fmt_of_list avcodec_find_best_pix_fmt2
-#endif
-
// Compare the dst image formats, and return the one which can carry more data
// (e.g. higher depth, more color components, lower chroma subsampling, etc.),
// with respect to what is required to keep most of the src format.
diff --git a/video/mp_image.c b/video/mp_image.c
index ef2fa488ad..ea04bab26e 100644
--- a/video/mp_image.c
+++ b/video/mp_image.c
@@ -25,10 +25,7 @@
#include <libavutil/hwcontext.h>
#include <libavutil/rational.h>
#include <libavcodec/avcodec.h>
-
-#if LIBAVUTIL_VERSION_MICRO >= 100
#include <libavutil/mastering_display_metadata.h>
-#endif
#include "mpv_talloc.h"
@@ -867,7 +864,6 @@ struct mp_image *mp_image_from_av_frame(struct AVFrame *src)
dst->params.color.light = p->color.light;
}
-#if LIBAVUTIL_VERSION_MICRO >= 100
sd = av_frame_get_side_data(src, AV_FRAME_DATA_ICC_PROFILE);
if (sd)
dst->icc_profile = sd->buf;
@@ -899,7 +895,6 @@ struct mp_image *mp_image_from_av_frame(struct AVFrame *src)
};
MP_TARRAY_APPEND(NULL, dst->ff_side_data, dst->num_ff_side_data, mpsd);
}
-#endif
if (dst->hwctx) {
AVHWFramesContext *fctx = (void *)dst->hwctx->data;
@@ -968,7 +963,6 @@ struct AVFrame *mp_image_to_av_frame(struct mp_image *src)
abort();
*(struct mp_image_params *)dst->opaque_ref->data = src->params;
-#if LIBAVUTIL_VERSION_MICRO >= 100
if (src->icc_profile) {
AVFrameSideData *sd =
av_frame_new_side_data_from_buf(dst, AV_FRAME_DATA_ICC_PROFILE,
@@ -998,7 +992,6 @@ struct AVFrame *mp_image_to_av_frame(struct mp_image *src)
mpsd->buf = NULL;
}
}
-#endif
talloc_free(new_ref);
diff --git a/video/out/gpu/hwdec.c b/video/out/gpu/hwdec.c
index c07dbf9fd0..db75c64b05 100644
--- a/video/out/gpu/hwdec.c
+++ b/video/out/gpu/hwdec.c
@@ -73,7 +73,7 @@ const struct ra_hwdec_driver *const ra_hwdec_drivers[] = {
#if HAVE_RPI_MMAL
&ra_hwdec_rpi_overlay,
#endif
-#if HAVE_DRMPRIME && HAVE_DRM
+#if HAVE_DRM
&ra_hwdec_drmprime_drm,
#endif
diff --git a/video/sws_utils.c b/video/sws_utils.c
index 855c1ba821..55faadb1ee 100644
--- a/video/sws_utils.c
+++ b/video/sws_utils.c
@@ -285,7 +285,6 @@ int mp_sws_reinit(struct mp_sws_context *ctx)
av_opt_set_double(ctx->sws, "param0", ctx->params[0], 0);
av_opt_set_double(ctx->sws, "param1", ctx->params[1], 0);
-#if LIBAVCODEC_VERSION_MICRO >= 100
int cr_src = mp_chroma_location_to_av(src->chroma_location);
int cr_dst = mp_chroma_location_to_av(dst->chroma_location);
int cr_xpos, cr_ypos;
@@ -297,7 +296,6 @@ int mp_sws_reinit(struct mp_sws_context *ctx)
av_opt_set_int(ctx->sws, "dst_h_chr_pos", cr_xpos, 0);
av_opt_set_int(ctx->sws, "dst_v_chr_pos", cr_ypos, 0);
}
-#endif
// This can fail even with normal operation, e.g. if a conversion path
// simply does not support these settings.
diff --git a/wscript b/wscript
index d47133e6a6..b918d7cfc0 100644
--- a/wscript
+++ b/wscript
@@ -434,69 +434,19 @@ iconv support use --disable-iconv.",
}
]
-ffmpeg_pkg_config_checks = [
- 'libavutil', '>= 56.12.100',
- 'libavcodec', '>= 58.16.100',
- 'libavformat', '>= 58.9.100',
- 'libswscale', '>= 5.0.101',
- 'libavfilter', '>= 7.14.100',
- 'libswresample', '>= 3.0.100',
-]
-libav_pkg_config_checks = [
- 'libavutil', '>= 56.6.0',
- 'libavcodec', '>= 58.8.0',
- 'libavformat', '>= 58.1.0',
- 'libswscale', '>= 5.0.0',
- 'libavfilter', '>= 7.0.0',
- 'libavresample', '>= 4.0.0',
-]
-
-def check_ffmpeg_or_libav_versions():
- def fn(ctx, dependency_identifier, **kw):
- versions = ffmpeg_pkg_config_checks
- if ctx.dependency_satisfied('libav'):
- versions = libav_pkg_config_checks
- return check_pkg_config(*versions)(ctx, dependency_identifier, **kw)
- return fn
-
libav_dependencies = [
{
- 'name': 'libavcodec',
- 'desc': 'FFmpeg/Libav present',
- 'func': check_pkg_config('libavcodec'),
- 'req': True,
- 'fmsg': "FFmpeg/Libav development files not found.",
- }, {
- 'name': 'libavutil',
- 'desc': 'FFmpeg/Libav libavutil present',
- 'func': check_pkg_config('libavutil'),
- 'req': True,
- 'fmsg': "FFmpeg/Libav libavutil not found.",
- }, {
'name': 'ffmpeg',
- 'desc': 'libav* is FFmpeg',
- # FFmpeg <=> LIBAVUTIL_VERSION_MICRO>=100
- 'func': check_statement('libavcodec/version.h',
- 'int x[LIBAVCODEC_VERSION_MICRO >= 100 ? 1 : -1]',
- use='libavcodec'),
- }, {
- # This check should always result in the opposite of ffmpeg-*.
- # Run it to make sure is_ffmpeg didn't fail for some other reason than
- # the actual version check.
- 'name': 'libav',
- 'desc': 'libav* is Libav',
- # FFmpeg <=> LIBAVUTIL_VERSION_MICRO>=100
- 'func': check_statement('libavcodec/version.h',
- 'int x[LIBAVCODEC_VERSION_MICRO >= 100 ? -1 : 1]',
- use='libavcodec')
- }, {
- 'name': 'libav-any',
- 'desc': 'Libav/FFmpeg library versions',
- 'deps': 'ffmpeg || libav',
- 'func': check_ffmpeg_or_libav_versions(),
+ 'desc': 'FFmpeg library',
+ 'func': check_pkg_config('libavutil', '>= 56.12.100',
+ 'libavcodec', '>= 58.16.100',
+ 'libavformat', '>= 58.9.100',
+ 'libswscale', '>= 5.0.101',
+ 'libavfilter', '>= 7.14.100',
+ 'libswresample', '>= 3.0.100'),
'req': True,
'fmsg': "Unable to find development files for some of the required \
-FFmpeg/Libav libraries. Git master is recommended."
+FFmpeg libraries. Git master is recommended."
}, {
'name': '--libavdevice',
'desc': 'libavdevice',
@@ -590,12 +540,6 @@ video_output_features = [
'deps': 'vt.h',
'func': check_pkg_config('libdrm', '>= 2.4.74'),
}, {
- 'name': '--drmprime',
- 'desc': 'DRM Prime ffmpeg support',
- 'func': check_statement('libavutil/pixfmt.h',
- 'int i = AV_PIX_FMT_DRM_PRIME',
- use='libavutil')
- }, {
'name': '--gbm',
'desc': 'GBM',
'deps': 'gbm.h',
diff --git a/wscript_build.py b/wscript_build.py
index a95effca76..aa41aa06ea 100644
--- a/wscript_build.py
+++ b/wscript_build.py
@@ -446,7 +446,7 @@ def build(ctx):
( "video/out/dr_helper.c" ),
( "video/out/drm_atomic.c", "drm" ),
( "video/out/drm_common.c", "drm" ),
- ( "video/out/drm_prime.c", "drm && drmprime" ),
+ ( "video/out/drm_prime.c", "drm" ),
( "video/out/filter_kernels.c" ),
( "video/out/gpu/context.c" ),
( "video/out/gpu/d3d11_helpers.c", "d3d11 || egl-angle-win32" ),
@@ -487,7 +487,7 @@ def build(ctx):
( "video/out/opengl/egl_helpers.c", "egl-helpers" ),
( "video/out/opengl/formats.c", "gl" ),
( "video/out/opengl/hwdec_d3d11egl.c", "d3d-hwaccel && egl-angle" ),
- ( "video/out/opengl/hwdec_drmprime_drm.c","drmprime && drm" ),
+ ( "video/out/opengl/hwdec_drmprime_drm.c","drm" ),
( "video/out/opengl/hwdec_dxva2egl.c", "d3d9-hwaccel && egl-angle" ),
( "video/out/opengl/hwdec_dxva2gldx.c", "gl-dxinterop-d3d9" ),
( "video/out/opengl/hwdec_ios.m", "ios-gl" ),