chromium/third_party/blink/renderer/platform/image-decoders/avif/crabbyavif_image_decoder_test.cc

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// WARNING: Auto-generated by gen_crabbyavif_wrapper.py.
// Do not modify manually.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#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 {};

// If 'error_phase' is ErrorPhase::kParse, error is expected during parse
// (SetData() call); else error is expected during decode
// (DecodeFrameBufferAtIndex() call).
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) {}

// TODO(ryoh): Add corrupted video tests.

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) {}

// Reproduces crbug.com/1402841. Decodes a large AVIF image 104 times in
// parallel from base::ThreadPool. Should not cause temporary deadlock of
// base::ThreadPool.
TEST(CrabbyStaticAVIFTests, ParallelDecoding) {}

TEST(CrabbyStaticAVIFTests, AlphaHasNoIspeProperty) {}

TEST(CrabbyStaticAVIFTests, UnsupportedTransferFunctionInColrProperty) {}

TEST(CrabbyStaticAVIFTests, ClapPropertyZeroOrigin) {}

// Verifies that an invalid 'clap' (clean aperture) image property is handled by
// ignoring the 'clap' property and showing the full image.
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) {}

}  // namespace

}  // namespace blink