This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 2df918af3e7fa7146f99157a2079d69e427fc1e9 Author: Romain Beauxis <[email protected]> AuthorDate: Mon Nov 16 20:40:51 2026 -0600 Commit: Romain Beauxis <[email protected]> CommitDate: Sat Nov 21 13:32:34 2026 +0000 avformat/tests: add a codec string test Covers av_mime_codec_str() for H.264 and HEVC extradata in Annex-B and ISO/IEC 14496-15 form, with the sample entry names of both codecs. --- libavformat/Makefile | 3 +- libavformat/tests/codecstring.c | 120 ++++++++++++++++++++++++++++++++++++++++ tests/fate/libavformat.mak | 4 ++ tests/ref/fate/codecstring | 9 +++ 4 files changed, 135 insertions(+), 1 deletion(-) diff --git a/libavformat/Makefile b/libavformat/Makefile index 93c9aa5153..698e45adba 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -779,7 +779,8 @@ SKIPHEADERS-$(CONFIG_IMF_DEMUXER) += imf.h SKIPHEADERS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh.h SKIPHEADERS-$(CONFIG_NETWORK) += ip.h network.h rtsp.h -TESTPROGS = demux_probe \ +TESTPROGS = codecstring \ + demux_probe \ id3v2 \ mkdir \ rename \ diff --git a/libavformat/tests/codecstring.c b/libavformat/tests/codecstring.c new file mode 100644 index 0000000000..7b30a865b7 --- /dev/null +++ b/libavformat/tests/codecstring.c @@ -0,0 +1,120 @@ +/* + * 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 <stdio.h> +#include <string.h> + +#include "libavutil/bprint.h" +#include "libavutil/macros.h" +#include "libavutil/mem.h" +#include "libavcodec/codec_par.h" +#include "libavcodec/defs.h" +#include "libavformat/avformat.h" + +/* Extradata of a 160x120 encoding: libx264 High profile, libx265 Main + * profile. */ +static const uint8_t h264_annexb[] = { + 0x00, 0x00, 0x00, 0x01, 0x67, 0x64, 0x00, 0x0b, 0xac, 0xd9, 0x42, 0x84, + 0x7e, 0x5c, 0x04, 0x40, 0x00, 0x00, 0x03, 0x00, 0x40, 0x00, 0x00, 0x0c, + 0x83, 0xc5, 0x0a, 0x65, 0x80, +}; + +static const uint8_t h264_avcc[] = { + 0x01, 0x64, 0x00, 0x0b, 0xff, 0xe1, +}; + +static const uint8_t hevc_annexb[] = { + 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, + 0x00, 0x90, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x1e, 0xa0, 0x14, + 0x20, 0x79, 0x65, 0x95, 0x9a, 0x49, 0x32, 0xbc, 0x05, 0xa0, 0x20, 0x00, + 0x00, 0x03, 0x00, 0x20, 0x00, 0x00, 0x03, 0x03, 0x21, 0x00, +}; + +static const uint8_t hevc_hvcc[] = { + 0x01, 0x01, 0x60, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x1e, 0xf0, 0x00, 0xfc, 0xfd, 0xf8, 0xf8, 0x00, 0x00, 0x0f, 0x00, +}; + +typedef struct TestCase { + const char *name; + enum AVCodecID codec_id; + uint32_t codec_tag; + int profile; + const uint8_t *extradata; + int extradata_size; +} TestCase; + +static const TestCase cases[] = { + { "h264-annexb", AV_CODEC_ID_H264, 0, + AV_PROFILE_UNKNOWN, h264_annexb, sizeof(h264_annexb) }, + { "h264-annexb-avc3", AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '3'), + AV_PROFILE_UNKNOWN, h264_annexb, sizeof(h264_annexb) }, + { "h264-avcc", AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '1'), + AV_PROFILE_UNKNOWN, h264_avcc, sizeof(h264_avcc) }, + { "hevc-annexb-hvc1", AV_CODEC_ID_HEVC, MKTAG('h', 'v', 'c', '1'), + AV_PROFILE_UNKNOWN, hevc_annexb, sizeof(hevc_annexb) }, + { "hevc-annexb-hev1", AV_CODEC_ID_HEVC, MKTAG('h', 'e', 'v', '1'), + AV_PROFILE_UNKNOWN, hevc_annexb, sizeof(hevc_annexb) }, + { "hevc-annexb-untagged", AV_CODEC_ID_HEVC, 0, + AV_PROFILE_UNKNOWN, hevc_annexb, sizeof(hevc_annexb) }, + { "hevc-hvcc-hvc1", AV_CODEC_ID_HEVC, MKTAG('h', 'v', 'c', '1'), + AV_PROFILE_UNKNOWN, hevc_hvcc, sizeof(hevc_hvcc) }, + { "hevc-hvcc-hev1", AV_CODEC_ID_HEVC, MKTAG('h', 'e', 'v', '1'), + AV_PROFILE_UNKNOWN, hevc_hvcc, sizeof(hevc_hvcc) }, + { "aac-lc", AV_CODEC_ID_AAC, 0, + AV_PROFILE_AAC_LOW, NULL, 0 }, +}; + +static int run_case(const TestCase *test) +{ + AVCodecParameters *par = avcodec_parameters_alloc(); + AVBPrint out; + int ret; + + if (!par) + return AVERROR(ENOMEM); + par->codec_id = test->codec_id; + par->codec_tag = test->codec_tag; + par->profile = test->profile; + if (test->extradata_size) { + par->extradata = av_mallocz(test->extradata_size + + AV_INPUT_BUFFER_PADDING_SIZE); + if (!par->extradata) { + avcodec_parameters_free(&par); + return AVERROR(ENOMEM); + } + memcpy(par->extradata, test->extradata, test->extradata_size); + par->extradata_size = test->extradata_size; + } + + av_bprint_init(&out, 0, AV_BPRINT_SIZE_UNLIMITED); + ret = av_mime_codec_str(par, (AVRational){ 1, 0 }, &out); + printf("%s: %s\n", test->name, ret < 0 ? "error" : out.str); + av_bprint_finalize(&out, NULL); + avcodec_parameters_free(&par); + + return ret == AVERROR(ENOMEM) ? ret : 0; +} + +int main(void) +{ + for (size_t i = 0; i < FF_ARRAY_ELEMS(cases); i++) + if (run_case(&cases[i]) < 0) + return 1; + return 0; +} diff --git a/tests/fate/libavformat.mak b/tests/fate/libavformat.mak index 30436cb52b..df5472b6f6 100644 --- a/tests/fate/libavformat.mak +++ b/tests/fate/libavformat.mak @@ -1,3 +1,7 @@ +FATE_LIBAVFORMAT += fate-codecstring +fate-codecstring: libavformat/tests/codecstring$(EXESUF) +fate-codecstring: CMD = run libavformat/tests/codecstring$(EXESUF) + FATE_LIBAVFORMAT += fate-demux-probe fate-demux-probe: libavformat/tests/demux_probe$(EXESUF) fate-demux-probe: CMD = run libavformat/tests/demux_probe$(EXESUF) diff --git a/tests/ref/fate/codecstring b/tests/ref/fate/codecstring new file mode 100644 index 0000000000..472f24f38d --- /dev/null +++ b/tests/ref/fate/codecstring @@ -0,0 +1,9 @@ +h264-annexb: avc1.64000b +h264-annexb-avc3: avc1.64000b +h264-avcc: avc1.64000b +hevc-annexb-hvc1: hvc1.1.6.L30.90 +hevc-annexb-hev1: error +hevc-annexb-untagged: error +hevc-hvcc-hvc1: error +hevc-hvcc-hev1: error +aac-lc: mp4a.40.2 -- To stop receiving notification emails like this one, please contact [email protected]. _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
