#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/platform/image-decoders/avif/crabbyavif_image_decoder.h"
#include <cmath>
#include <memory>
#include <ostream>
#include <utility>
#include <vector>
#include "base/barrier_closure.h"
#include "base/bit_cast.h"
#include "base/functional/bind.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/thread_pool.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/platform/image-decoders/image_decoder_test_helpers.h"
#include "third_party/blink/renderer/platform/wtf/shared_buffer.h"
#include "ui/gfx/color_space.h"
#include "ui/gfx/color_transform.h"
#define FIXME_SUPPORT_ICC_PROFILE_NO_TRANSFORM …
#define FIXME_SUPPORT_ICC_PROFILE_TRANSFORM …
#define FIXME_DISTINGUISH_LOSSY_OR_LOSSLESS …
namespace blink {
namespace {
std::unique_ptr<ImageDecoder> CreateAVIFDecoderWithOptions(
ImageDecoder::AlphaOption alpha_option,
ImageDecoder::HighBitDepthDecodingOption high_bit_depth_option,
ColorBehavior color_behavior,
ImageDecoder::AnimationOption animation_option) { … }
std::unique_ptr<ImageDecoder> CreateAVIFDecoder() { … }
struct ExpectedColor { … };
enum class ColorType { … };
struct StaticColorCheckParam { … };
std::ostream& operator<<(std::ostream& os, const StaticColorCheckParam& param) { … }
StaticColorCheckParam kTestParams[] = …;
enum class ErrorPhase { … };
void TestInvalidStaticImage(const char* avif_file, ErrorPhase error_phase) { … }
float HalfFloatToUnorm(uint16_t h) { … }
void ReadYUV(const char* file_name,
const gfx::Size& expected_y_size,
const gfx::Size& expected_uv_size,
SkColorType color_type,
int bit_depth,
gfx::Point3F* rgb_pixel = nullptr) { … }
void TestYUVRed(const char* file_name,
const gfx::Size& expected_uv_size,
SkColorType color_type = kGray_8_SkColorType,
int bit_depth = 8) { … }
void DecodeTask(const Vector<char>* data, base::RepeatingClosure* done) { … }
void InspectImage(
const StaticColorCheckParam& param,
ImageDecoder::HighBitDepthDecodingOption high_bit_depth_option) { … }
void TestAvifBppHistogram(const char* image_name,
const char* histogram_name = nullptr,
base::HistogramBase::Sample sample = 0) { … }
struct AVIFImageParam { … };
constexpr AVIFImageParam kAnimatedTestParams[] = …;
constexpr AVIFImageParam kStaticTestParams[] = …;
CrabbyAVIFValidImagesTest;
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(CrabbyAVIFValidImagesTest, ByteByByteDecode) { … }
TEST(CrabbyAnimatedAVIFTests, HasMultipleSubImages) { … }
TEST(CrabbyStaticAVIFTests, DoesNotHaveMultipleSubImages) { … }
TEST(CrabbyStaticAVIFTests, HasTimingInformation) { … }
TEST(CrabbyAnimatedAVIFTests, HasTimingInformation) { … }
TEST(CrabbyStaticAVIFTests, NoCrashWhenCheckingForMultipleSubImages) { … }
TEST(CrabbyStaticAVIFTests, invalidImages) { … }
TEST(CrabbyStaticAVIFTests, GetAdobeGainmapInfoAndData) { … }
TEST(CrabbyStaticAVIFTests, GetIsoGainmapInfoAndData) { … }
TEST(CrabbyStaticAVIFTests, GetIsoGainmapInfoAndDataHdrToSdr) { … }
TEST(CrabbyStaticAVIFTests, GetIsoGainmapColorSpaceSameICC) { … }
void ExpectMatrixNear(const skcms_Matrix3x3& lhs,
const skcms_Matrix3x3& rhs,
float epsilon) { … }
TEST(CrabbyStaticAVIFTests, GetIsoGainmapColorSpaceDifferentICC) { … }
TEST(CrabbyStaticAVIFTests, GetIsoGainmapColorSpaceDifferentCICP) { … }
TEST(CrabbyStaticAVIFTests, GetGainmapInfoAndDataWithFeatureDisabled) { … }
TEST(CrabbyStaticAVIFTests, GetGainmapInfoAndDataWithTruncatedData) { … }
TEST(CrabbyStaticAVIFTests, YUV) { … }
TEST(CrabbyStaticAVIFTests, SizeAvailableBeforeAllDataReceived) { … }
TEST(CrabbyStaticAVIFTests, ProgressiveDecoding) { … }
TEST(CrabbyStaticAVIFTests, IncrementalDecoding) { … }
TEST(CrabbyStaticAVIFTests, ParallelDecoding) { … }
TEST(CrabbyStaticAVIFTests, AlphaHasNoIspeProperty) { … }
TEST(CrabbyStaticAVIFTests, UnsupportedTransferFunctionInColrProperty) { … }
TEST(CrabbyStaticAVIFTests, ClapPropertyZeroOrigin) { … }
TEST(CrabbyStaticAVIFTests, InvalidClapPropertyHandling) { … }
TEST(CrabbyStaticAVIFTests, BppHistogramSmall) { … }
TEST(CrabbyStaticAVIFTests, BppHistogramSmall3x3) { … }
TEST(CrabbyStaticAVIFTests, BppHistogramSmall900000) { … }
TEST(CrabbyStaticAVIFTests, BppHistogramBig) { … }
TEST(CrabbyStaticAVIFTests, BppHistogramBig13000000) { … }
TEST(CrabbyStaticAVIFTests, BppHistogramHuge) { … }
TEST(CrabbyStaticAVIFTests, BppHistogramHuge13000002) { … }
TEST(CrabbyStaticAVIFTests, BppHistogramInvalid) { … }
TEST(CrabbyStaticAVIFTests, BppHistogram10bit) { … }
TEST(CrabbyStaticAVIFTests, BppHistogramMonochrome) { … }
TEST(CrabbyStaticAVIFTests, BppHistogramAlpha) { … }
TEST(CrabbyStaticAVIFTests, BppHistogramAnimated) { … }
CrabbyStaticAVIFColorTests;
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(CrabbyStaticAVIFColorTests, InspectImage) { … }
TEST_P(CrabbyStaticAVIFColorTests, InspectImageHalfFloat) { … }
}
}