5#include "testing/testing.h"
10#include <libavcodec/avcodec.h>
11#include <libavutil/channel_layout.h>
12#include <libavutil/log.h>
17bool test_vcodec(
const AVCodec *codec, AVPixelFormat pixelformat)
19 av_log_set_level(AV_LOG_QUIET);
22 AVCodecContext *ctx = avcodec_alloc_context3(codec);
24 ctx->time_base.num = 1;
25 ctx->time_base.den = 25;
26 ctx->pix_fmt = pixelformat;
29 int open = avcodec_open2(ctx, codec,
NULL);
31 avcodec_free_context(&ctx);
38bool test_acodec(
const AVCodec *codec, AVSampleFormat fmt)
40 av_log_set_level(AV_LOG_QUIET);
43 AVCodecContext *ctx = avcodec_alloc_context3(codec);
45 ctx->sample_fmt = fmt;
46 ctx->sample_rate = 48000;
47#ifdef FFMPEG_USE_OLD_CHANNEL_VARS
48 ctx->channel_layout = AV_CH_LAYOUT_MONO;
50 av_channel_layout_from_mask(&ctx->ch_layout, AV_CH_LAYOUT_MONO);
52 ctx->bit_rate = 128000;
53 int open = avcodec_open2(ctx, codec,
NULL);
55 avcodec_free_context(&ctx);
63bool test_codec_video_by_codecid(AVCodecID codec_id, AVPixelFormat pixelformat)
66 const AVCodec *codec = avcodec_find_encoder(codec_id);
68 result = test_vcodec(codec, pixelformat);
73bool test_codec_video_by_name(
const char *codecname, AVPixelFormat pixelformat)
76 const AVCodec *codec = avcodec_find_encoder_by_name(codecname);
78 result = test_vcodec(codec, pixelformat);
83bool test_codec_audio_by_codecid(AVCodecID codec_id, AVSampleFormat fmt)
86 const AVCodec *codec = avcodec_find_encoder(codec_id);
88 result = test_acodec(codec, fmt);
93bool test_codec_audio_by_name(
const char *codecname, AVSampleFormat fmt)
96 const AVCodec *codec = avcodec_find_encoder_by_name(codecname);
98 result = test_acodec(codec, fmt);
104#define FFMPEG_TEST_VCODEC_ID(codec, fmt) \
105 TEST(ffmpeg, codec##_##fmt) \
107 EXPECT_TRUE(test_codec_video_by_codecid(codec, fmt)); \
110#define FFMPEG_TEST_VCODEC_NAME(codec, fmt) \
111 TEST(ffmpeg, codec##_##fmt) \
113 EXPECT_TRUE(test_codec_video_by_name(str(codec), fmt)); \
116#define FFMPEG_TEST_ACODEC_ID(codec, fmt) \
117 TEST(ffmpeg, codec##_##fmt) \
119 EXPECT_TRUE(test_codec_audio_by_codecid(codec, fmt)); \
122#define FFMPEG_TEST_ACODEC_NAME(codec, fmt) \
123 TEST(ffmpeg, codec) \
125 EXPECT_TRUE(test_codec_audio_by_name(str(codec), fmt)); \
168 EXPECT_TRUE(test_codec_video_by_name(
"libaom-av1", AV_PIX_FMT_YUV420P));
#define FFMPEG_TEST_VCODEC_NAME(codec, fmt)
TEST(ffmpeg, libaom_av1_AV_PIX_FMT_YUV420P)
#define FFMPEG_TEST_ACODEC_NAME(codec, fmt)
#define FFMPEG_TEST_ACODEC_ID(codec, fmt)
#define FFMPEG_TEST_VCODEC_ID(codec, fmt)