5#include "testing/testing.h"
12#include <libavcodec/avcodec.h>
13#include <libavutil/channel_layout.h>
14#include <libavutil/log.h>
19bool test_vcodec(
const AVCodec *codec, AVPixelFormat pixelformat)
21 av_log_set_level(AV_LOG_QUIET);
24 AVCodecContext *ctx = avcodec_alloc_context3(codec);
26 ctx->time_base.num = 1;
27 ctx->time_base.den = 25;
28 ctx->pix_fmt = pixelformat;
31 int open = avcodec_open2(ctx, codec,
nullptr);
33 avcodec_free_context(&ctx);
40bool test_acodec(
const AVCodec *codec, AVSampleFormat fmt)
42 av_log_set_level(AV_LOG_QUIET);
45 AVCodecContext *ctx = avcodec_alloc_context3(codec);
47 ctx->sample_fmt = fmt;
48 ctx->sample_rate = 48000;
49#ifdef FFMPEG_USE_OLD_CHANNEL_VARS
50 ctx->channel_layout = AV_CH_LAYOUT_MONO;
52 av_channel_layout_from_mask(&ctx->ch_layout, AV_CH_LAYOUT_MONO);
54 ctx->bit_rate = 128000;
55 int open = avcodec_open2(ctx, codec,
nullptr);
57 avcodec_free_context(&ctx);
65bool test_codec_video_by_codecid(AVCodecID codec_id, AVPixelFormat pixelformat)
68 const AVCodec *codec = avcodec_find_encoder(codec_id);
70 result = test_vcodec(codec, pixelformat);
75bool test_codec_video_by_name(
const char *codecname, AVPixelFormat pixelformat)
78 const AVCodec *codec = avcodec_find_encoder_by_name(codecname);
80 result = test_vcodec(codec, pixelformat);
85bool test_codec_audio_by_codecid(AVCodecID codec_id, AVSampleFormat fmt)
88 const AVCodec *codec = avcodec_find_encoder(codec_id);
90 result = test_acodec(codec, fmt);
95bool test_codec_audio_by_name(
const char *codecname, AVSampleFormat fmt)
98 const AVCodec *codec = avcodec_find_encoder_by_name(codecname);
100 result = test_acodec(codec, fmt);
108#define FFMPEG_TEST_VCODEC_ID(codec, fmt) \
109 TEST_F(FFmpegTest, codec##_##fmt) \
111 EXPECT_TRUE(test_codec_video_by_codecid(codec, fmt)); \
114#define FFMPEG_TEST_VCODEC_NAME(codec, fmt) \
115 TEST_F(FFmpegTest, codec##_##fmt) \
117 EXPECT_TRUE(test_codec_video_by_name(str(codec), fmt)); \
120#define FFMPEG_TEST_ACODEC_ID(codec, fmt) \
121 TEST_F(FFmpegTest, codec##_##fmt) \
123 EXPECT_TRUE(test_codec_audio_by_codecid(codec, fmt)); \
126#define FFMPEG_TEST_ACODEC_NAME(codec, fmt) \
127 TEST_F(FFmpegTest, codec) \
129 EXPECT_TRUE(test_codec_audio_by_name(str(codec), fmt)); \
174TEST_F(FFmpegTest, libaom_av1_AV_PIX_FMT_YUV420P)
176 EXPECT_TRUE(test_codec_video_by_name(
"libaom-av1", AV_PIX_FMT_YUV420P));
#define FFMPEG_TEST_VCODEC_NAME(codec, fmt)
TEST_F(FFmpegTest, 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)
#define EXPECT_TRUE(result)