MCPcopy Create free account
hub / github.com/AOMediaCodec/libavif / TEST_P

Function TEST_P

tests/gtest/avifcodectest.cc:15–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13 /*decoding_codec=*/avifCodecChoice>> {};
14
15TEST_P(CodecTest, EncodeDecode) {
16 const avifCodecChoice encoding_codec = std::get<0>(GetParam());
17 const avifCodecChoice decoding_codec = std::get<1>(GetParam());
18
19 if (avifCodecName(encoding_codec, AVIF_CODEC_FLAG_CAN_ENCODE) == nullptr ||
20 avifCodecName(decoding_codec, AVIF_CODEC_FLAG_CAN_DECODE) == nullptr) {
21 GTEST_SKIP() << "Codec unavailable, skip test.";
22 }
23
24 // AVIF_CODEC_CHOICE_SVT requires dimensions to be at least 64 pixels.
25 ImagePtr image =
26 testutil::CreateImage(/*width=*/64, /*height=*/64, /*depth=*/8,
27 AVIF_PIXEL_FORMAT_YUV420, AVIF_PLANES_ALL);
28 ASSERT_NE(image, nullptr);
29 testutil::FillImageGradient(image.get());
30
31 EncoderPtr encoder(avifEncoderCreate());
32 ASSERT_NE(encoder, nullptr);
33 encoder->codecChoice = encoding_codec;
34 encoder->quality = encoder->qualityAlpha = 90; // Small loss.
35 testutil::AvifRwData encoded;
36 ASSERT_EQ(avifEncoderWrite(encoder.get(), image.get(), &encoded),
37 AVIF_RESULT_OK);
38
39 DecoderPtr decoder(avifDecoderCreate());
40 ASSERT_NE(decoder, nullptr);
41 decoder->codecChoice = decoding_codec;
42 ImagePtr decoded(avifImageCreateEmpty());
43 ASSERT_NE(decoded, nullptr);
44 ASSERT_EQ(avifDecoderReadMemory(decoder.get(), decoded.get(), encoded.data,
45 encoded.size),
46 AVIF_RESULT_OK);
47
48 ASSERT_GT(testutil::GetPsnr(*image, *decoded), 32.0);
49}
50
51INSTANTIATE_TEST_SUITE_P(
52 All, CodecTest,

Callers

nothing calls this directly

Calls 9

avifCodecNameFunction · 0.85
CreateImageFunction · 0.85
FillImageGradientFunction · 0.85
avifEncoderCreateFunction · 0.85
avifEncoderWriteFunction · 0.85
avifDecoderCreateFunction · 0.85
avifImageCreateEmptyFunction · 0.85
avifDecoderReadMemoryFunction · 0.85
GetPsnrFunction · 0.70

Tested by

no test coverage detected