diff --git a/deps/media-playback/media-playback/decode.c b/deps/media-playback/media-playback/decode.c index 16550e415..db59fc9c8 100644 --- a/deps/media-playback/media-playback/decode.c +++ b/deps/media-playback/media-playback/decode.c @@ -24,8 +24,8 @@ static AVCodec *find_hardware_decoder(enum AVCodecID id) while (hwa) { if (hwa->id == id) { - if (hwa->pix_fmt == AV_PIX_FMT_VDA_VLD || - hwa->pix_fmt == AV_PIX_FMT_DXVA2_VLD || + if (hwa->pix_fmt == AV_PIX_FMT_VIDEOTOOLBOX || + hwa->pix_fmt == AV_PIX_FMT_DXVA2_VLD || hwa->pix_fmt == AV_PIX_FMT_VAAPI_VLD) { c = avcodec_find_decoder_by_name(hwa->name); if (c) @@ -142,8 +142,8 @@ bool mp_decode_init(mp_media_t *m, enum AVMediaType type, bool hw) return false; } - if (d->codec->capabilities & AV_CODEC_CAP_TRUNCATED) - d->decoder->flags |= AV_CODEC_FLAG_TRUNCATED; + if (d->codec->capabilities & CODEC_CAP_TRUNC) + d->decoder->flags |= CODEC_FLAG_TRUNC; return true; } diff --git a/deps/media-playback/media-playback/decode.h b/deps/media-playback/media-playback/decode.h index 78a7842f8..4838dad8b 100644 --- a/deps/media-playback/media-playback/decode.h +++ b/deps/media-playback/media-playback/decode.h @@ -36,6 +36,14 @@ extern "C" { #pragma warning(pop) #endif +#if LIBAVCODEC_VERSION_MAJOR >= 58 +#define CODEC_CAP_TRUNC AV_CODEC_CAP_TRUNCATED +#define CODEC_FLAG_TRUNC AV_CODEC_FLAG_TRUNCATED +#else +#define CODEC_CAP_TRUNC CODEC_CAP_TRUNCATED +#define CODEC_FLAG_TRUNC CODEC_FLAG_TRUNCATED +#endif + struct mp_media; struct mp_decode { diff --git a/libobs/media-io/media-remux.c b/libobs/media-io/media-remux.c index 15376e463..781278e01 100644 --- a/libobs/media-io/media-remux.c +++ b/libobs/media-io/media-remux.c @@ -26,6 +26,12 @@ #include #include +#if LIBAVCODEC_VERSION_MAJOR >= 58 +#define CODEC_FLAG_GLOBAL_H AV_CODEC_FLAG_GLOBAL_HEADER +#else +#define CODEC_FLAG_GLOBAL_H CODEC_FLAG_GLOBAL_HEADER +#endif + struct media_remux_job { int64_t in_size; AVFormatContext *ifmt_ctx, *ofmt_ctx; @@ -95,7 +101,7 @@ static inline bool init_output(media_remux_job_t job, const char *out_filename) out_stream->codec->codec_tag = 0; if (job->ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) - out_stream->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; + out_stream->codec->flags |= CODEC_FLAG_GLOBAL_H; } #ifndef _NDEBUG diff --git a/libobs/obs-ffmpeg-compat.h b/libobs/obs-ffmpeg-compat.h index 922891781..0f3f265f0 100644 --- a/libobs/obs-ffmpeg-compat.h +++ b/libobs/obs-ffmpeg-compat.h @@ -20,3 +20,12 @@ # define av_frame_free avcodec_free_frame #endif +#if LIBAVCODEC_VERSION_MAJOR >= 58 +#define CODEC_CAP_TRUNC AV_CODEC_CAP_TRUNCATED +#define CODEC_FLAG_TRUNC AV_CODEC_FLAG_TRUNCATED +#define INPUT_BUFFER_PADDING_SIZE AV_INPUT_BUFFER_PADDING_SIZE +#else +#define CODEC_CAP_TRUNC CODEC_CAP_TRUNCATED +#define CODEC_FLAG_TRUNC CODEC_FLAG_TRUNCATED +#define INPUT_BUFFER_PADDING_SIZE FF_INPUT_BUFFER_PADDING_SIZE +#endif diff --git a/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c b/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c index 358c0f7b9..e5d86ca0f 100644 --- a/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c +++ b/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c @@ -29,6 +29,12 @@ #include +#if LIBAVCODEC_VERSION_MAJOR >= 58 +#define CODEC_FLAG_GLOBAL_H AV_CODEC_FLAG_GLOBAL_HEADER +#else +#define CODEC_FLAG_GLOBAL_H CODEC_FLAG_GLOBAL_HEADER +#endif + /* ------------------------------------------------------------------------- */ struct resize_buf { @@ -312,7 +318,7 @@ static void create_video_stream(struct ffmpeg_mux *ffm) ffm->video_stream->time_base = context->time_base; if (ffm->output->oformat->flags & AVFMT_GLOBALHEADER) - context->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; + context->flags |= CODEC_FLAG_GLOBAL_H; } static void create_audio_stream(struct ffmpeg_mux *ffm, int idx) @@ -348,7 +354,7 @@ static void create_audio_stream(struct ffmpeg_mux *ffm, int idx) av_get_default_channel_layout(context->channels); if (ffm->output->oformat->flags & AVFMT_GLOBALHEADER) - context->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; + context->flags |= CODEC_FLAG_GLOBAL_H; ffm->num_audio_streams++; } diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-audio-encoders.c b/plugins/obs-ffmpeg/obs-ffmpeg-audio-encoders.c index 0bd11f63a..28560b84c 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-audio-encoders.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-audio-encoders.c @@ -214,7 +214,7 @@ static void *enc_create(obs_data_t *settings, obs_encoder_t *encoder, /* enable experimental FFmpeg encoder if the only one available */ enc->context->strict_std_compliance = -2; - enc->context->flags = AV_CODEC_FLAG_GLOBAL_HEADER; + enc->context->flags = CODEC_FLAG_GLOBAL_H; if (initialize_codec(enc)) return enc; diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-compat.h b/plugins/obs-ffmpeg/obs-ffmpeg-compat.h index ba35eba49..1072d70d7 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-compat.h +++ b/plugins/obs-ffmpeg/obs-ffmpeg-compat.h @@ -23,3 +23,13 @@ #if LIBAVCODEC_VERSION_MAJOR >= 57 #define av_free_packet av_packet_unref #endif + +#if LIBAVCODEC_VERSION_MAJOR >= 58 +#define CODEC_CAP_TRUNC AV_CODEC_CAP_TRUNCATED +#define CODEC_FLAG_TRUNC AV_CODEC_FLAG_TRUNCATED +#define CODEC_FLAG_GLOBAL_H AV_CODEC_FLAG_GLOBAL_HEADER +#else +#define CODEC_CAP_TRUNC CODEC_CAP_TRUNCATED +#define CODEC_FLAG_TRUNC CODEC_FLAG_TRUNCATED +#define CODEC_FLAG_GLOBAL_H CODEC_FLAG_GLOBAL_HEADER +#endif diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-output.c b/plugins/obs-ffmpeg/obs-ffmpeg-output.c index 15267805c..36dbdb332 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-output.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-output.c @@ -260,7 +260,7 @@ static bool create_video_stream(struct ffmpeg_data *data) data->video->time_base = context->time_base; if (data->output->oformat->flags & AVFMT_GLOBALHEADER) - context->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; + context->flags |= CODEC_FLAG_GLOBAL_H; if (!open_video_codec(data)) return false; @@ -348,7 +348,7 @@ static bool create_audio_stream(struct ffmpeg_data *data) data->audio_size = get_audio_size(data->audio_format, aoi.speakers, 1); if (data->output->oformat->flags & AVFMT_GLOBALHEADER) - context->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; + context->flags |= CODEC_FLAG_GLOBAL_H; return open_audio_codec(data); } @@ -686,7 +686,7 @@ static void receive_video(void *param, struct video_data *frame) else copy_data(&data->dst_picture, frame, context->height, context->pix_fmt); - if (data->output->flags & AVFMT_RAWPICTURE) { + if (data->output->flags) { packet.flags |= AV_PKT_FLAG_KEY; packet.stream_index = data->video->index; packet.data = data->dst_picture.data[0]; diff --git a/plugins/win-dshow/ffmpeg-decode.c b/plugins/win-dshow/ffmpeg-decode.c index f216cd491..83869d7c0 100644 --- a/plugins/win-dshow/ffmpeg-decode.c +++ b/plugins/win-dshow/ffmpeg-decode.c @@ -16,6 +16,7 @@ ******************************************************************************/ #include "ffmpeg-decode.h" +#include "obs-ffmpeg-compat.h" #include int ffmpeg_decode_init(struct ffmpeg_decode *decode, enum AVCodecID id) @@ -37,8 +38,8 @@ int ffmpeg_decode_init(struct ffmpeg_decode *decode, enum AVCodecID id) return ret; } - if (decode->codec->capabilities & CODEC_CAP_TRUNCATED) - decode->decoder->flags |= CODEC_FLAG_TRUNCATED; + if (decode->codec->capabilities & CODEC_CAP_TRUNC) + decode->decoder->flags |= CODEC_FLAG_TRUNC; return 0; } @@ -96,7 +97,7 @@ static inline enum audio_format convert_sample_format(int f) static inline void copy_data(struct ffmpeg_decode *decode, uint8_t *data, size_t size) { - size_t new_size = size + FF_INPUT_BUFFER_PADDING_SIZE; + size_t new_size = size + INPUT_BUFFER_PADDING_SIZE; if (decode->packet_size < new_size) { decode->packet_buffer = brealloc(decode->packet_buffer, @@ -104,7 +105,7 @@ static inline void copy_data(struct ffmpeg_decode *decode, uint8_t *data, decode->packet_size = new_size; } - memset(decode->packet_buffer + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(decode->packet_buffer + size, 0, INPUT_BUFFER_PADDING_SIZE); memcpy(decode->packet_buffer, data, size); }