Commit b7d476b1 authored by Muhammad Faiz's avatar Muhammad Faiz

fate/libavcodec: add codec_desc test

Remove runtime check at codec_desc.c
Reviewed-by: 's avatarwm4 <nfxjfg@googlemail.com>
Reviewed-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
Signed-off-by: 's avatarMuhammad Faiz <mfcc64@gmail.com>
parent dced1f6c
......@@ -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 \
......
......@@ -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);
}
......
/*
* 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;
}
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment