History

avcodec/tests/avcodec: Check consistency of function pointers

Andreas Rheinhardt committed 5 years ago

Commit 497c4901 parent d7779831 file · +22 −1Browse files

Unified · Split

libavcodec/tests/avcodec.c+22−1
@@ -41,6 +41,7 @@ int main(void){ · 40 unmodified lines
4141
4242 while (codec = av_codec_iterate(&iter)) {
4343 const AVCodecDescriptor *desc;
44+ int is_decoder, is_encoder;
4445
4546 if (!codec->name) {
4647 AV_LOG("Codec for format %s has no name\n",
@@ -63,13 +64,33 @@ int main(void){ · 16 unmodified lines
6364 ERR("Non-video codec %s has video-only fields set\n");
6465 }
6566
66− if (av_codec_is_encoder(codec)) {
67+ is_decoder = av_codec_is_decoder(codec);
68+ is_encoder = av_codec_is_encoder(codec);
69+ if (!!is_decoder + !!is_encoder != 1) {
70+ ERR("Codec %s is decoder and encoder or neither.\n");
71+ continue;
72+ }
73+ if (is_encoder) {
74+ if (codec->type == AVMEDIA_TYPE_SUBTITLE ^ !!codec->encode_sub)
75+ ERR("Encoder %s is both subtitle encoder and not subtitle encoder.");
76+ if (!!codec->encode_sub + !!codec->encode2 + !!codec->receive_packet != 1)
77+ ERR("Encoder %s does not implement exactly one encode API.\n");
78+ if (codec->update_thread_context || codec->update_thread_context_for_user || codec->bsfs)
79+ ERR("Encoder %s has decoder-only thread functions or bsf.\n");
6780 if (codec->type == AVMEDIA_TYPE_AUDIO) {
6881 if (!codec->sample_fmts) {
6982 av_log(NULL, AV_LOG_FATAL, "Encoder %s is missing the sample_fmts field\n", codec->name);
7083 ret = 1;
7184 }
7285 }
86+ } else {
87+ if (codec->type == AVMEDIA_TYPE_SUBTITLE && !codec->decode)
88+ ERR("Subtitle decoder %s does not implement decode callback\n");
89+ if (codec->type == AVMEDIA_TYPE_SUBTITLE && codec->bsfs)
90+ ERR("Automatic bitstream filtering unsupported for subtitles; "
91+ "yet decoder %s has it set\n");
92+ if (!!codec->decode + !!codec->receive_frame != 1)
93+ ERR("Decoder %s does not implement exactly one decode API.\n");
7394 }
7495 if (!(desc = avcodec_descriptor_get(codec->id))) {
7596 ERR("Codec %s lacks a corresponding descriptor\n");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t