#include <cassert>
#include <climits>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include "gtest/gtest.h"
#include "config/aom_config.h"
#include "aom/aomcx.h"
#include "aom/aom_encoder.h"
#include "aom/aom_image.h"
namespace {
#if CONFIG_REALTIME_ONLY
const unsigned int kUsage = …;
#else
const unsigned int kUsage = AOM_USAGE_GOOD_QUALITY;
#endif
static void *Memset16(void *dest, int val, size_t length) { … }
TEST(EncodeAPI, InvalidParams) { … }
TEST(EncodeAPI, InvalidControlId) { … }
void EncodeSetSFrameOnFirstFrame(aom_img_fmt fmt, aom_codec_flags_t flag) { … }
TEST(EncodeAPI, SetSFrameOnFirstFrame) { … }
#if CONFIG_AV1_HIGHBITDEPTH
TEST(EncodeAPI, SetSFrameOnFirstFrameHighbd) {
EncodeSetSFrameOnFirstFrame(AOM_IMG_FMT_I42016, AOM_CODEC_USE_HIGHBITDEPTH);
}
#endif
TEST(EncodeAPI, MonochromeInProfiles) { … }
TEST(EncodeAPI, LowBDEncoderLowBDImage) { … }
TEST(EncodeAPI, HighBDEncoderHighBDImage) { … }
TEST(EncodeAPI, HighBDEncoderLowBDImage) { … }
TEST(EncodeAPI, LowBDEncoderHighBDImage) { … }
aom_image_t *CreateGrayImage(aom_img_fmt_t fmt, unsigned int w,
unsigned int h) { … }
TEST(EncodeAPI, Buganizer310548198) { … }
class AV1Encoder { … };
AV1Encoder::~AV1Encoder() { … }
void AV1Encoder::Configure(unsigned int threads, unsigned int width,
unsigned int height, aom_rc_mode end_usage,
unsigned int usage) { … }
void AV1Encoder::Encode(bool key_frame) { … }
void AV1Encoder::Flush() { … }
TEST(EncodeAPI, Buganizer314858909) { … }
TEST(EncodeAPI, Buganizer310766628) { … }
TEST(EncodeAPI, Buganizer310455204) { … }
TEST(EncodeAPI, Buganizer310457427) { … }
TEST(EncodeAPI, PtsSmallerThanInitialPts) { … }
TEST(EncodeAPI, PtsOrDurationTooBig) { … }
TEST(EncodeAPI, Buganizer339877165) { … }
TEST(EncodeAPI, AomediaIssue3509VbrMinSection2Percent) { … }
TEST(EncodeAPI, AomediaIssue3509VbrMinSection101Percent) { … }
class EncodeAPIParameterized
: public testing::TestWithParam<std::tuple<
unsigned int, int, unsigned int>> { … };
TEST_P(EncodeAPIParameterized, HighBDEncoderHighBDFrames) { … }
const unsigned int kUsages[] = …;
INSTANTIATE_TEST_SUITE_P(…);
#if !CONFIG_REALTIME_ONLY
TEST(EncodeAPI, AllIntraMode) {
aom_codec_iface_t *iface = aom_codec_av1_cx();
aom_codec_ctx_t enc;
aom_codec_enc_cfg_t cfg;
EXPECT_EQ(AOM_CODEC_OK,
aom_codec_enc_config_default(iface, &cfg, AOM_USAGE_ALL_INTRA));
EXPECT_EQ(AOM_CODEC_OK, aom_codec_enc_init(&enc, iface, &cfg, 0));
EXPECT_EQ(AOM_CODEC_OK, aom_codec_destroy(&enc));
EXPECT_EQ(AOM_CODEC_OK,
aom_codec_enc_config_default(iface, &cfg, AOM_USAGE_ALL_INTRA));
cfg.g_lag_in_frames = 1;
EXPECT_EQ(AOM_CODEC_INVALID_PARAM, aom_codec_enc_init(&enc, iface, &cfg, 0));
EXPECT_EQ(AOM_CODEC_OK,
aom_codec_enc_config_default(iface, &cfg, AOM_USAGE_ALL_INTRA));
cfg.kf_max_dist = 1;
EXPECT_EQ(AOM_CODEC_INVALID_PARAM, aom_codec_enc_init(&enc, iface, &cfg, 0));
}
TEST(EncodeAPI, AllIntraAndUsePsnr) {
aom_codec_iface_t *iface = aom_codec_av1_cx();
aom_codec_enc_cfg_t cfg;
ASSERT_EQ(aom_codec_enc_config_default(iface, &cfg, AOM_USAGE_ALL_INTRA),
AOM_CODEC_OK);
aom_codec_ctx_t enc;
ASSERT_EQ(aom_codec_enc_init(&enc, iface, &cfg, AOM_CODEC_USE_PSNR),
AOM_CODEC_OK);
aom_image_t *image = CreateGrayImage(AOM_IMG_FMT_I420, cfg.g_w, cfg.g_h);
ASSERT_NE(image, nullptr);
ASSERT_EQ(aom_codec_encode(&enc, image, 0, 1, 0), AOM_CODEC_OK);
const aom_codec_cx_pkt_t *pkt;
aom_codec_iter_t iter = nullptr;
while ((pkt = aom_codec_get_cx_data(&enc, &iter)) != nullptr) {
if (pkt->kind != AOM_CODEC_CX_FRAME_PKT) {
ASSERT_EQ(pkt->kind, AOM_CODEC_PSNR_PKT);
}
}
aom_img_free(image);
ASSERT_EQ(aom_codec_destroy(&enc), AOM_CODEC_OK);
}
TEST(EncodeAPI, AllIntraAndNoRefLast) {
aom_codec_iface_t *iface = aom_codec_av1_cx();
aom_codec_enc_cfg_t cfg;
ASSERT_EQ(aom_codec_enc_config_default(iface, &cfg, AOM_USAGE_ALL_INTRA),
AOM_CODEC_OK);
aom_codec_ctx_t enc;
ASSERT_EQ(aom_codec_enc_init(&enc, iface, &cfg, 0), AOM_CODEC_OK);
aom_image_t *image = CreateGrayImage(AOM_IMG_FMT_I420, cfg.g_w, cfg.g_h);
ASSERT_NE(image, nullptr);
ASSERT_EQ(aom_codec_encode(&enc, image, 0, 1, AOM_EFLAG_NO_REF_LAST),
AOM_CODEC_OK);
aom_img_free(image);
ASSERT_EQ(aom_codec_destroy(&enc), AOM_CODEC_OK);
}
#endif
}