From ca2bc6b4b06efe1d59d5100b620eee871bbf2aee Mon Sep 17 00:00:00 2001 From: derrod Date: Fri, 17 Feb 2017 17:37:25 +0100 Subject: [PATCH] libff: Add override for codec compatability check In some cases the result of the compatability check is wrong. For example the format "mpegts" only shows "mpeg2video" as an encoder even though other codecs such as h.264 are supported by ffmpeg's muxer for that container and are used within that container in some applications. Closes jp9000/obs-studio#804 --- deps/libff/libff/ff-util.c | 25 +++++++++++++++---------- deps/libff/libff/ff-util.h | 3 ++- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/deps/libff/libff/ff-util.c b/deps/libff/libff/ff-util.c index 814ca1b93..ca6aa9151 100644 --- a/deps/libff/libff/ff-util.c +++ b/deps/libff/libff/ff-util.c @@ -99,7 +99,8 @@ static const AVCodec *next_codec_for_id(enum AVCodecID id, const AVCodec *prev) static void add_codec_to_list(const struct ff_format_desc *format_desc, struct ff_codec_desc **first, struct ff_codec_desc **current, - enum AVCodecID id, const AVCodec *codec) + enum AVCodecID id, const AVCodec *codec, + bool ignore_compatability) { if (codec == NULL) codec = avcodec_find_encoder(id); @@ -112,11 +113,13 @@ static void add_codec_to_list(const struct ff_format_desc *format_desc, if (!av_codec_is_encoder(codec)) return; - // Format doesn't support this codec - unsigned int tag = av_codec_get_tag(format_desc->codec_tags, - codec->id); - if (tag == 0) - return; + if (!ignore_compatability) { + // Format doesn't support this codec + unsigned int tag = av_codec_get_tag(format_desc->codec_tags, + codec->id); + if (tag == 0) + return; + } struct ff_codec_desc *d = av_mallocz(sizeof(struct ff_codec_desc)); @@ -150,16 +153,17 @@ static void add_codec_to_list(const struct ff_format_desc *format_desc, static void get_codecs_for_id(const struct ff_format_desc *format_desc, struct ff_codec_desc **first, struct ff_codec_desc **current, - enum AVCodecID id) + enum AVCodecID id, bool ignore_compatability) { const AVCodec *codec = NULL; while ((codec = next_codec_for_id(id, codec))) add_codec_to_list(format_desc, first, current, codec->id, - codec); + codec, ignore_compatability); } const struct ff_codec_desc *ff_codec_supported( - const struct ff_format_desc *format_desc) + const struct ff_format_desc *format_desc, + bool ignore_compatability) { const AVCodecDescriptor **codecs; unsigned int size; @@ -172,7 +176,8 @@ const struct ff_codec_desc *ff_codec_supported( for(i = 0; i < size; i++) { const AVCodecDescriptor *codec = codecs[i]; - get_codecs_for_id(format_desc, &first, ¤t, codec->id); + get_codecs_for_id(format_desc, &first, ¤t, codec->id, + ignore_compatability); } av_free((void *)codecs); diff --git a/deps/libff/libff/ff-util.h b/deps/libff/libff/ff-util.h index 759467694..ca6875d81 100644 --- a/deps/libff/libff/ff-util.h +++ b/deps/libff/libff/ff-util.h @@ -37,7 +37,8 @@ const char *ff_codec_name_from_id(int codec_id); // Codec Description const struct ff_codec_desc *ff_codec_supported( - const struct ff_format_desc *format_desc); + const struct ff_format_desc *format_desc, + bool ignore_compatability); void ff_codec_desc_free(const struct ff_codec_desc *codec_desc); const char *ff_codec_desc_name(const struct ff_codec_desc *codec_desc); const char *ff_codec_desc_long_name(const struct ff_codec_desc *codec_desc);