various: remove no longer needed availability checks

image_writer: remove jpegxl availability check

meson: remove check for lavu vulkan support

image_writer: remove avif availability check

ad_spdif: remove no longer needed definitions

demux_lavf: remove side data extraction compatibility code

demux/packet: remove ITU T.35 availability check

filters/f_lavfi: remove avfilter_filter_pad_count availability check

image_writer: remove PNG cICP support check

mp_image: remove AV_FRAME_DATA_DOVI_METADATA availability check

mp_image: remove AV_FRAME_FLAG_INTERLACED availability check

vd_lavc: remove ctx->pic->duration availability check

sws_utils: remove av_chroma_location_enum_to_pos availability check

vd_lavc: remove AV_CODEC_EXPORT_DATA_FILM_GRAIN availability check

demux_lavf: always use io_close2
This commit is contained in:
Kacper Michajłow 2024-06-21 18:35:11 +02:00
parent 0d8f74231f
commit 687eb4c875
10 changed files with 8 additions and 139 deletions

View File

@ -37,12 +37,6 @@
#define OUTBUF_SIZE 65536
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(60, 26, 100)
#define AV_PROFILE_UNKNOWN FF_PROFILE_UNKNOWN
#define AV_PROFILE_DTS_HD_HRA FF_PROFILE_DTS_HD_HRA
#define AV_PROFILE_DTS_HD_MA FF_PROFILE_DTS_HD_MA
#endif
struct spdifContext {
struct mp_log *log;
struct mp_codec_params *codec;

View File

@ -228,12 +228,6 @@ struct stream_info {
double ts_offset;
};
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 10, 100)
#define HAVE_IO_CLOSE2 1
#else
#define HAVE_IO_CLOSE2 0
#endif
typedef struct lavf_priv {
struct stream *stream;
bool own_stream;
@ -266,11 +260,7 @@ typedef struct lavf_priv {
int num_nested;
int (*default_io_open)(struct AVFormatContext *s, AVIOContext **pb,
const char *url, int flags, AVDictionary **options);
#if HAVE_IO_CLOSE2
int (*default_io_close2)(struct AVFormatContext *s, AVIOContext *pb);
#else
void (*default_io_close)(struct AVFormatContext *s, AVIOContext *pb);
#endif
} lavf_priv_t;
static void update_read_stats(struct demuxer *demuxer)
@ -613,13 +603,8 @@ static void select_tracks(struct demuxer *demuxer, int start)
static void export_replaygain(demuxer_t *demuxer, struct sh_stream *sh,
AVStream *st)
{
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(60, 15, 100)
AVPacketSideData *side_data = st->codecpar->coded_side_data;
int nb_side_data = st->codecpar->nb_coded_side_data;
#else
AVPacketSideData *side_data = st->side_data;
int nb_side_data = st->nb_side_data;
#endif
for (int i = 0; i < nb_side_data; i++) {
AVReplayGain *av_rgain;
struct replaygain_data *rgain;
@ -688,7 +673,6 @@ static bool is_image(AVStream *st, bool attached_picture, const AVInputFormat *a
);
}
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(60, 15, 100)
static inline const uint8_t *mp_av_stream_get_side_data(const AVStream *st,
enum AVPacketSideDataType type)
{
@ -698,9 +682,6 @@ static inline const uint8_t *mp_av_stream_get_side_data(const AVStream *st,
type);
return sd ? sd->data : NULL;
}
#else
#define mp_av_stream_get_side_data(st, type) av_stream_get_side_data(st, type, NULL)
#endif
static void handle_new_stream(demuxer_t *demuxer, int i)
{
@ -971,11 +952,7 @@ static int nested_io_open(struct AVFormatContext *s, AVIOContext **pb,
return r;
}
#if HAVE_IO_CLOSE2
static int nested_io_close2(struct AVFormatContext *s, AVIOContext *pb)
#else
static void nested_io_close(struct AVFormatContext *s, AVIOContext *pb)
#endif
{
struct demuxer *demuxer = s->opaque;
lavf_priv_t *priv = demuxer->priv;
@ -987,11 +964,7 @@ static void nested_io_close(struct AVFormatContext *s, AVIOContext *pb)
}
}
#if HAVE_IO_CLOSE2
return priv->default_io_close2(s, pb);
#else
priv->default_io_close(s, pb);
#endif
}
static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
@ -1081,13 +1054,8 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
if (demuxer->access_references) {
priv->default_io_open = avfc->io_open;
avfc->io_open = nested_io_open;
#if HAVE_IO_CLOSE2
priv->default_io_close2 = avfc->io_close2;
avfc->io_close2 = nested_io_close2;
#else
priv->default_io_close = avfc->io_close;
avfc->io_close = nested_io_close;
#endif
} else {
avfc->io_open = block_io_open;
}

View File

@ -237,7 +237,6 @@ int demux_packet_add_blockadditional(struct demux_packet *dp, uint64_t id,
return -1;
switch (id) {
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(58, 5, 100)
case MATROSKA_BLOCK_ADD_ID_TYPE_ITU_T_T35: {
static const uint8_t ITU_T_T35_COUNTRY_CODE_US = 0xB5;
static const uint16_t ITU_T_T35_PROVIDER_CODE_SMTPE = 0x3C;
@ -278,7 +277,6 @@ int demux_packet_add_blockadditional(struct demux_packet *dp, uint64_t id,
return 0;
}
#endif
default:
break;
}

View File

@ -976,13 +976,8 @@ static struct mp_filter *lavfi_create(struct mp_filter *parent, void *options)
// Does it have exactly one video input and one video output?
static bool is_usable(const AVFilter *filter, int media_type)
{
#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(8, 3, 0)
int nb_inputs = avfilter_filter_pad_count(filter, 0),
nb_outputs = avfilter_filter_pad_count(filter, 1);
#else
int nb_inputs = avfilter_pad_count(filter->inputs),
nb_outputs = avfilter_pad_count(filter->outputs);
#endif
if (nb_inputs > 1 || nb_outputs > 1)
return false;
bool input_ok = filter->flags & AVFILTER_FLAG_DYNAMIC_INPUTS;

View File

@ -47,8 +47,6 @@ features = {
'debug': get_option('debug'),
'ffmpeg': true,
'gpl': get_option('gpl'),
'jpegxl': libavformat.version().version_compare('>= 59.27.100'),
'avif-muxer': libavformat.version().version_compare('>= 59.24.100'),
'libass': true,
'libplacebo': true,
}
@ -1347,9 +1345,8 @@ if features['android-media-ndk']
endif
vulkan_interop = get_option('vulkan-interop').require(
features['vulkan'] and vulkan.version().version_compare('>=1.3.238') and
libavutil.version().version_compare('>=58.11.100'),
error_message: 'Vulkan Interop requires vulkan headers >= 1.3.238, and libavutil >= 58.11.100',
features['vulkan'] and vulkan.version().version_compare('>=1.3.238'),
error_message: 'Vulkan Interop requires vulkan headers >= 1.3.238',
)
features += {'vulkan-interop': vulkan_interop.allowed()}
if features['vulkan-interop']

View File

@ -87,9 +87,7 @@ struct lavc_conv *lavc_conv_create(struct sd *sd)
break;
}
#if LIBAVCODEC_VERSION_MAJOR < 59
av_dict_set(&opts, "sub_text_format", "ass", 0);
#endif
av_dict_set(&opts, "flags2", "+ass_ro_flush_noop", 0);
if (strcmp(priv->codec, "eia_608") == 0)
av_dict_set(&opts, "real_time", "1", 0);

View File

@ -759,11 +759,6 @@ static void init_avctx(struct mp_filter *vd)
if (!ctx->use_hwdec && ctx->vo && lavc_param->dr) {
avctx->opaque = vd;
avctx->get_buffer2 = get_buffer2_direct;
#if LIBAVCODEC_VERSION_MAJOR < 60
AV_NOWARN_DEPRECATED({
avctx->thread_safe_callbacks = 1;
});
#endif
}
avctx->flags |= lavc_param->bitexact ? AV_CODEC_FLAG_BITEXACT : 0;
@ -780,12 +775,6 @@ static void init_avctx(struct mp_filter *vd)
if (lavc_codec->id == AV_CODEC_ID_H264 && lavc_param->old_x264)
av_opt_set(avctx, "x264_build", "150", AV_OPT_SEARCH_CHILDREN);
#ifndef AV_CODEC_EXPORT_DATA_FILM_GRAIN
if (ctx->opts->film_grain == 1)
MP_WARN(vd, "GPU film grain requested, but FFmpeg too old to expose "
"film grain parameters. Please update to latest master, "
"or at least to release 4.4.\n");
#else
switch(ctx->opts->film_grain) {
case 0: /*CPU*/
// default lavc flags handle film grain within the decoder.
@ -808,7 +797,6 @@ static void init_avctx(struct mp_filter *vd)
break;
}
#endif
mp_set_avopts(vd->log, avctx, lavc_param->avopts);
@ -1238,13 +1226,7 @@ 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);
mpi->pkt_duration =
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 30, 100)
mp_pts_from_av(ctx->pic->duration, &ctx->codec_timebase);
#else
mp_pts_from_av(ctx->pic->pkt_duration, &ctx->codec_timebase);
#endif
mpi->pkt_duration = mp_pts_from_av(ctx->pic->duration, &ctx->codec_timebase);
av_frame_unref(ctx->pic);

View File

@ -75,12 +75,8 @@ const struct m_opt_choice_alternatives mp_image_writer_formats[] = {
{"jpeg", AV_CODEC_ID_MJPEG},
{"png", AV_CODEC_ID_PNG},
{"webp", AV_CODEC_ID_WEBP},
#if HAVE_JPEGXL
{"jxl", AV_CODEC_ID_JPEGXL},
#endif
#if HAVE_AVIF_MUXER
{"avif", AV_CODEC_ID_AV1},
#endif
{0}
};
@ -95,15 +91,11 @@ const struct m_option image_writer_opts[] = {
{"webp-lossless", OPT_BOOL(webp_lossless)},
{"webp-quality", OPT_INT(webp_quality), M_RANGE(0, 100)},
{"webp-compression", OPT_INT(webp_compression), M_RANGE(0, 6)},
#if HAVE_JPEGXL
{"jxl-distance", OPT_DOUBLE(jxl_distance), M_RANGE(0.0, 15.0)},
{"jxl-effort", OPT_INT(jxl_effort), M_RANGE(1, 9)},
#endif
#if HAVE_AVIF_MUXER
{"avif-encoder", OPT_STRING(avif_encoder)},
{"avif-opts", OPT_KEYVALUELIST(avif_opts)},
{"avif-pixfmt", OPT_STRING(avif_pixfmt)},
#endif
{"high-bit-depth", OPT_BOOL(high_bit_depth)},
{"tag-colorspace", OPT_BOOL(tag_csp)},
{0},
@ -210,13 +202,11 @@ static bool write_lavc(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp
AV_OPT_SEARCH_CHILDREN);
av_opt_set_int(avctx, "quality", ctx->opts->webp_quality,
AV_OPT_SEARCH_CHILDREN);
#if HAVE_JPEGXL
} else if (codec->id == AV_CODEC_ID_JPEGXL) {
av_opt_set_double(avctx, "distance", ctx->opts->jxl_distance,
AV_OPT_SEARCH_CHILDREN);
av_opt_set_int(avctx, "effort", ctx->opts->jxl_effort,
AV_OPT_SEARCH_CHILDREN);
#endif
}
if (avcodec_open2(avctx, codec, NULL) < 0) {
@ -320,8 +310,6 @@ static bool write_jpeg(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp
#endif
#if HAVE_AVIF_MUXER
static void log_side_data(struct image_writer_ctx *ctx, AVPacketSideData *data,
size_t size)
{
@ -500,8 +488,6 @@ free_data:
return success;
}
#endif
static int get_encoder_format(const AVCodec *codec, int srcfmt, bool highdepth)
{
const enum AVPixelFormat *pix_fmts = codec->pix_fmts;
@ -562,31 +548,17 @@ const char *image_writer_file_ext(const struct image_writer_opts *opts)
bool image_writer_high_depth(const struct image_writer_opts *opts)
{
return opts->format == AV_CODEC_ID_PNG
#if HAVE_JPEGXL
|| opts->format == AV_CODEC_ID_JPEGXL
#endif
#if HAVE_AVIF_MUXER
|| opts->format == AV_CODEC_ID_AV1
#endif
;
|| opts->format == AV_CODEC_ID_AV1;
}
bool image_writer_flexible_csp(const struct image_writer_opts *opts)
{
if (!opts->tag_csp)
return false;
return false
#if HAVE_JPEGXL
|| opts->format == AV_CODEC_ID_JPEGXL
#endif
#if HAVE_AVIF_MUXER
return opts->format == AV_CODEC_ID_JPEGXL
|| opts->format == AV_CODEC_ID_AV1
#endif
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59, 58, 100)
// This version added support for cICP tag writing
|| opts->format == AV_CODEC_ID_PNG
#endif
;
|| opts->format == AV_CODEC_ID_PNG;
}
int image_writer_format_from_ext(const char *ext)
@ -700,14 +672,11 @@ bool write_image(struct mp_image *image, const struct image_writer_opts *opts,
destfmt = IMGFMT_RGB24;
}
#endif
#if HAVE_AVIF_MUXER
if (opts->format == AV_CODEC_ID_AV1) {
write = write_avif;
if (opts->avif_pixfmt && opts->avif_pixfmt[0])
destfmt = mp_imgfmt_from_name(bstr0(opts->avif_pixfmt));
}
#endif
if (opts->format == AV_CODEC_ID_WEBP && !opts->webp_lossless) {
} else if (opts->format == AV_CODEC_ID_WEBP && !opts->webp_lossless) {
// For lossy images, libwebp has its own RGB->YUV conversion.
// We don't want that, so force YUV/YUVA here.
int alpha = image->fmt.flags & MP_IMGFLAG_ALPHA;

View File

@ -21,6 +21,7 @@
#include <libavutil/mem.h>
#include <libavutil/common.h>
#include <libavutil/display.h>
#include <libavutil/dovi_meta.h>
#include <libavutil/bswap.h>
#include <libavutil/hwcontext.h>
#include <libavutil/intreadwrite.h>
@ -29,10 +30,6 @@
#include <libavutil/mastering_display_metadata.h>
#include <libplacebo/utils/libav.h>
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 16, 100)
# include <libavutil/dovi_meta.h>
#endif
#include "mpv_talloc.h"
#include "common/av_common.h"
@ -1031,17 +1028,10 @@ struct mp_image *mp_image_from_av_frame(struct AVFrame *src)
dst->params.crop.y1 = src->height - src->crop_bottom;
dst->fields = 0;
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(58, 7, 100)
if (src->flags & AV_FRAME_FLAG_INTERLACED)
dst->fields |= MP_IMGFIELD_INTERLACED;
if (src->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST)
dst->fields |= MP_IMGFIELD_TOP_FIRST;
#else
if (src->interlaced_frame)
dst->fields |= MP_IMGFIELD_INTERLACED;
if (src->top_field_first)
dst->fields |= MP_IMGFIELD_TOP_FIRST;
#endif
if (src->repeat_pict == 1)
dst->fields |= MP_IMGFIELD_REPEAT_FIRST;
@ -1090,7 +1080,6 @@ struct mp_image *mp_image_from_av_frame(struct AVFrame *src)
dst->a53_cc = sd->buf;
AVBufferRef *dovi = NULL;
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 16, 100)
sd = av_frame_get_side_data(src, AV_FRAME_DATA_DOVI_METADATA);
if (sd) {
#ifdef PL_HAVE_LAV_DOLBY_VISION
@ -1119,7 +1108,6 @@ struct mp_image *mp_image_from_av_frame(struct AVFrame *src)
pl_hdr_metadata_from_dovi_rpu(&dst->params.color.hdr, sd->buf->data,
sd->buf->size);
}
#endif
sd = av_frame_get_side_data(src, AV_FRAME_DATA_FILM_GRAIN_PARAMS);
if (sd)
@ -1187,17 +1175,10 @@ struct AVFrame *mp_image_to_av_frame(struct mp_image *src)
dst->extended_data = dst->data;
dst->pict_type = src->pict_type;
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(58, 7, 100)
if (src->fields & MP_IMGFIELD_INTERLACED)
dst->flags |= AV_FRAME_FLAG_INTERLACED;
if (src->fields & MP_IMGFIELD_TOP_FIRST)
dst->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
#else
if (src->fields & MP_IMGFIELD_INTERLACED)
dst->interlaced_frame = 1;
if (src->fields & MP_IMGFIELD_TOP_FIRST)
dst->top_field_first = 1;
#endif
if (src->fields & MP_IMGFIELD_REPEAT_FIRST)
dst->repeat_pict = 1;

View File

@ -21,9 +21,7 @@
#include <libavcodec/avcodec.h>
#include <libavutil/bswap.h>
#include <libavutil/opt.h>
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 37, 100)
#include <libavutil/pixdesc.h>
#endif
#include <libplacebo/utils/libav.h>
#include "config.h"
@ -312,7 +310,6 @@ int mp_sws_reinit(struct mp_sws_context *ctx)
int cr_src = pl_chroma_to_av(src.chroma_location);
int cr_dst = pl_chroma_to_av(dst.chroma_location);
int cr_xpos, cr_ypos;
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 37, 100)
if (av_chroma_location_enum_to_pos(&cr_xpos, &cr_ypos, cr_src) >= 0) {
av_opt_set_int(ctx->sws, "src_h_chr_pos", cr_xpos, 0);
av_opt_set_int(ctx->sws, "src_v_chr_pos", cr_ypos, 0);
@ -321,16 +318,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);
}
#else
if (avcodec_enum_to_chroma_pos(&cr_xpos, &cr_ypos, cr_src) >= 0) {
av_opt_set_int(ctx->sws, "src_h_chr_pos", cr_xpos, 0);
av_opt_set_int(ctx->sws, "src_v_chr_pos", cr_ypos, 0);
}
if (avcodec_enum_to_chroma_pos(&cr_xpos, &cr_ypos, cr_dst) >= 0) {
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.