libobs, obs-ffmpeg, win-dshow: Fix FFmpeg 4.0 deprecation

Fixes FFmpeg 4.0 deprecation warnings.
This commit is contained in:
jp9000 2019-07-28 18:31:43 -07:00
parent a3fface27f
commit 68a5a40df9
11 changed files with 50 additions and 3 deletions

View file

@ -56,9 +56,11 @@ struct ff_codec_desc {
void ff_init()
{
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
av_register_all();
//avdevice_register_all();
avcodec_register_all();
#endif
avformat_network_init();
}
@ -101,11 +103,30 @@ static bool get_codecs(const AVCodecDescriptor ***descs, unsigned int *size)
static const AVCodec *next_codec_for_id(enum AVCodecID id, const AVCodec *prev)
{
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58, 9, 100)
const AVCodec *cur = NULL;
void *i = 0;
bool found_prev = false;
while ((cur = av_codec_iterate(&i)) != NULL) {
if (cur->id == id && av_codec_is_encoder(cur)) {
if (!prev) {
return cur;
} else if (!found_prev) {
if (cur == prev) {
found_prev = true;
}
} else {
return cur;
}
}
}
#else
while ((prev = av_codec_next(prev)) != NULL) {
if (prev->id == id && av_codec_is_encoder(prev))
return prev;
}
#endif
return NULL;
}
@ -286,11 +307,17 @@ static inline bool is_output_device(const AVClass *avclass)
const struct ff_format_desc *ff_format_supported()
{
AVOutputFormat *output_format = NULL;
const AVOutputFormat *output_format = NULL;
struct ff_format_desc *desc = NULL;
struct ff_format_desc *current = NULL;
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(58, 9, 100)
void *i = 0;
while ((output_format = av_muxer_iterate(&i)) != NULL) {
#else
while ((output_format = av_oformat_next(output_format)) != NULL) {
#endif
struct ff_format_desc *d;
if (is_output_device(output_format->priv_class))
continue;

View file

@ -722,9 +722,11 @@ bool mp_media_init(mp_media_t *media, const struct mp_media_info *info)
static bool initialized = false;
if (!initialized) {
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
av_register_all();
avdevice_register_all();
avcodec_register_all();
#endif
avdevice_register_all();
avformat_network_init();
initialized = true;
}

View file

@ -202,7 +202,9 @@ fail:
void gs_init_image_deps(void)
{
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
av_register_all();
#endif
}
void gs_free_image_deps(void) {}

View file

@ -154,7 +154,9 @@ bool media_remux_job_create(media_remux_job_t *job, const char *in_filename,
init_size(*job, in_filename);
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
av_register_all();
#endif
if (!init_input(*job, in_filename))
goto fail;

View file

@ -566,7 +566,9 @@ static int ffmpeg_mux_init_internal(struct ffmpeg_mux *ffm, int argc,
calloc(1, sizeof(struct header) * ffm->params.tracks);
}
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
av_register_all();
#endif
if (!ffmpeg_mux_get_extra_data(ffm))
return FFM_ERROR;

View file

@ -190,7 +190,9 @@ static void *enc_create(obs_data_t *settings, obs_encoder_t *encoder,
int bitrate = (int)obs_data_get_int(settings, "bitrate");
audio_t *audio = obs_encoder_audio(encoder);
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
avcodec_register_all();
#endif
enc = bzalloc(sizeof(struct enc_encoder));
enc->encoder = encoder;

View file

@ -265,7 +265,9 @@ static void *nvenc_create(obs_data_t *settings, obs_encoder_t *encoder)
{
struct nvenc_encoder *enc;
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
avcodec_register_all();
#endif
enc = bzalloc(sizeof(*enc));
enc->encoder = encoder;

View file

@ -594,7 +594,9 @@ static bool ffmpeg_data_init(struct ffmpeg_data *data,
if (!config->url || !*config->url)
return false;
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
av_register_all();
#endif
avformat_network_init();
is_rtmp = (astrcmpi_n(config->url, "rtmp://", 7) == 0);

View file

@ -272,7 +272,9 @@ static void vaapi_destroy(void *data)
static void *vaapi_create(obs_data_t *settings, obs_encoder_t *encoder)
{
struct vaapi_encoder *enc;
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
avcodec_register_all();
#endif
enc = bzalloc(sizeof(*enc));
enc->encoder = encoder;

View file

@ -147,7 +147,9 @@ extern bool load_nvenc_lib(void);
static bool nvenc_supported(void)
{
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
av_register_all();
#endif
profile_start(nvenc_check_name);

View file

@ -73,7 +73,9 @@ int ffmpeg_decode_init(struct ffmpeg_decode *decode, enum AVCodecID id,
{
int ret;
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
avcodec_register_all();
#endif
memset(decode, 0, sizeof(*decode));
decode->codec = avcodec_find_decoder(id);