aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMuhammad Faiz <mfcc64@gmail.com>2018-02-10 16:30:14 +0700
committerMuhammad Faiz <mfcc64@gmail.com>2018-02-12 06:06:37 +0700
commitb7d476b1384fe0e4a2c4d424d880d9c4f0b6f7ca (patch)
tree52525cc2af973b3c14e6c8e78d69a85a7d3dade8
parentdced1f6cdfe479965898bed3cb5219d2ddbb0ad9 (diff)
downloadffmpeg-b7d476b1384fe0e4a2c4d424d880d9c4f0b6f7ca.tar.gz
fate/libavcodec: add codec_desc test
Remove runtime check at codec_desc.c Reviewed-by: wm4 <nfxjfg@googlemail.com> Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
-rw-r--r--libavcodec/Makefile1
-rw-r--r--libavcodec/codec_desc.c24
-rw-r--r--libavcodec/tests/codec_desc.c45
-rw-r--r--tests/fate/libavcodec.mak5
4 files changed, 51 insertions, 24 deletions
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