Remove runtime check at codec_desc.c Signed-off-by: Muhammad Faiz <mfc...@gmail.com> --- libavcodec/Makefile | 1 + libavcodec/codec_desc.c | 24 ----------------------- libavcodec/tests/codec_desc.c | 45 +++++++++++++++++++++++++++++++++++++++++++ tests/fate/libavcodec.mak | 5 +++++ 4 files changed, 51 insertions(+), 24 deletions(-) create mode 100644 libavcodec/tests/codec_desc.c
diff --git a/libavcodec/Makefile b/libavcodec/Makefile index beaca9ee51..3d4b738e0b 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1090,6 +1090,7 @@ SKIPHEADERS-$(CONFIG_V4L2_M2M) += v4l2_buffers.h v4l2_context.h v4l2_m2m TESTPROGS = avpacket \ celp_math \ + codec_desc \ htmlsubtitles \ imgconvert \ jpeg2000dwt \ diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 15f6489278..44a54a31c9 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -21,10 +21,8 @@ #include <string.h> -#include "libavutil/avassert.h" #include "libavutil/common.h" #include "libavutil/internal.h" -#include "libavutil/thread.h" #include "avcodec.h" #include "profiles.h" #include "version.h" @@ -3111,26 +3109,6 @@ static const AVCodecDescriptor codec_descriptors[] = { }, }; -#if defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2 -static void check_validity(void) -{ - int i; - - for (i = 0; i < FF_ARRAY_ELEMS(codec_descriptors) - 1; i++) { - if (codec_descriptors[i].id >= codec_descriptors[i+1].id) { - av_log(NULL, AV_LOG_FATAL, "unsorted codec_id '%s' and '%s'.\n", - codec_descriptors[i].name, codec_descriptors[i+1].name); - av_assert0(0); - } - } -} - -static AVOnce check_validity_once = AV_ONCE_INIT; -#define CHECK_VALIDITY() ff_thread_once(&check_validity_once, check_validity); -#else -#define CHECK_VALIDITY() ((void)0) -#endif - static int descriptor_compare(const void *key, const void *member) { enum AVCodecID id = *(const enum AVCodecID *) key; @@ -3141,8 +3119,6 @@ static int descriptor_compare(const void *key, const void *member) const AVCodecDescriptor *avcodec_descriptor_get(enum AVCodecID id) { - CHECK_VALIDITY(); - return bsearch(&id, codec_descriptors, FF_ARRAY_ELEMS(codec_descriptors), sizeof(codec_descriptors[0]), descriptor_compare); } diff --git a/libavcodec/tests/codec_desc.c b/libavcodec/tests/codec_desc.c new file mode 100644 index 0000000000..c9b3497343 --- /dev/null +++ b/libavcodec/tests/codec_desc.c @@ -0,0 +1,45 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavcodec/avcodec.h" + +int main(int argc, char **argv) +{ + const AVCodecDescriptor *old_desc = NULL, *desc; + + while (desc = avcodec_descriptor_next(old_desc)) { + if (old_desc && old_desc->id >= desc->id) { + av_log(NULL, AV_LOG_FATAL, "Unsorted codec_descriptors '%s' and '%s'.\n", old_desc->name, desc->name); + return 1; + } + + if (avcodec_descriptor_get(desc->id) != desc) { + av_log(NULL, AV_LOG_FATAL, "avcodec_descriptor_get() failed with '%s'.\n", desc->name); + return 1; + } + + if (avcodec_descriptor_get_by_name(desc->name) != desc) { + av_log(NULL, AV_LOG_FATAL, "avcodec_descriptor_get_by_name() failed with '%s'.\n", desc->name); + return 1; + } + + old_desc = desc; + } + + return 0; +} diff --git a/tests/fate/libavcodec.mak b/tests/fate/libavcodec.mak index a2d5d9fe33..d3b2dd874e 100644 --- a/tests/fate/libavcodec.mak +++ b/tests/fate/libavcodec.mak @@ -13,6 +13,11 @@ fate-celp_math: libavcodec/tests/celp_math$(EXESUF) fate-celp_math: CMD = run libavcodec/tests/celp_math fate-celp_math: CMP = null +FATE_LIBAVCODEC-yes += fate-codec_desc +fate-codec_desc: libavcodec/tests/codec_desc$(EXESUF) +fate-codec_desc: CMD = run libavcodec/tests/codec_desc +fate-codec_desc: CMP = null + FATE_LIBAVCODEC-$(CONFIG_GOLOMB) += fate-golomb fate-golomb: libavcodec/tests/golomb$(EXESUF) fate-golomb: CMD = run libavcodec/tests/golomb -- 2.13.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel