chromium/media/gpu/av1_decoder_unittest.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "media/gpu/av1_decoder.h"

#include <string.h>

#include <string>
#include <vector>

#include "base/compiler_specific.h"
#include "base/containers/span.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/numerics/safe_conversions.h"
#include "base/ranges/algorithm.h"
#include "media/base/decoder_buffer.h"
#include "media/base/test_data_util.h"
#include "media/ffmpeg/ffmpeg_common.h"
#include "media/ffmpeg/scoped_av_packet.h"
#include "media/filters/ffmpeg_demuxer.h"
#include "media/filters/in_memory_url_protocol.h"
#include "media/gpu/av1_picture.h"
#include "media/media_buildflags.h"
#include "media/parsers/ivf_parser.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/libgav1/src/src/obu_parser.h"
#include "third_party/libgav1/src/src/utils/constants.h"
#include "third_party/libgav1/src/src/utils/types.h"

_;
DoAll;
Return;
SaveArg;

namespace media {
namespace {

class FakeAV1Picture : public AV1Picture {};

bool IsYUV420(int8_t subsampling_x, int8_t subsampling_y, bool is_monochrome) {}

MATCHER_P(SameAV1PictureInstance, av1_picture, "") {}

MATCHER_P2(MatchesFrameSizeAndRenderSize, frame_size, render_size, "") {}

MATCHER_P4(MatchesFrameHeader,
           frame_size,
           render_size,
           show_existing_frame,
           show_frame,
           "") {}

MATCHER_P4(MatchesYUV420SequenceHeader,
           profile,
           bitdepth,
           max_frame_size,
           film_grain_params_present,
           "") {}

MATCHER(NonEmptyTileBuffers, "") {}

MATCHER_P(MatchesFrameData, decoder_buffer, "") {}

class MockAV1Accelerator : public AV1Decoder::AV1Accelerator {};

}  // namespace

class AV1DecoderTest : public ::testing::Test {};

void AV1DecoderTest::SetUp() {}

std::vector<AcceleratedVideoDecoder::DecodeResult> AV1DecoderTest::Decode(
    scoped_refptr<DecoderBuffer> buffer) {}

const libgav1::DecoderState* AV1DecoderTest::GetDecoderState() const {}

AV1ReferenceFrameVector& AV1DecoderTest::GetReferenceFrames() const {}

void AV1DecoderTest::Reset() {}

scoped_refptr<DecoderBuffer> AV1DecoderTest::ReadDecoderBuffer(
    const std::string& fname) {}

std::vector<scoped_refptr<DecoderBuffer>> AV1DecoderTest::ReadIVF(
    const std::string& fname) {}

std::vector<scoped_refptr<DecoderBuffer>> AV1DecoderTest::ReadWebm(
    const std::string& fname) {}

TEST_F(AV1DecoderTest, DecodeInvalidOBU) {}

TEST_F(AV1DecoderTest, DecodeEmptyOBU) {}

TEST_F(AV1DecoderTest, DecodeOneIFrame) {}

TEST_F(AV1DecoderTest, DecodeSimpleStream) {}

TEST_F(AV1DecoderTest, DecodeShowExistingPictureStream) {}

TEST_F(AV1DecoderTest, Decode10bitStream) {}

TEST_F(AV1DecoderTest, DecodeTemporalLayerStream) {}

TEST_F(AV1DecoderTest, DecodeSVCStream) {}

TEST_F(AV1DecoderTest, DenyDecodeNonYUV420) {}

TEST_F(AV1DecoderTest, DecodeFilmGrain) {}

// TODO(b/175895249): Test in isolation each of the conditions that trigger a
// kConfigChange event.
TEST_F(AV1DecoderTest, ConfigChange) {}

TEST_F(AV1DecoderTest, Reset) {}

TEST_F(AV1DecoderTest, ResetAndConfigChange) {}

// This test ensures that the AV1Decoder fails gracefully if for some reason,
// the reference frame state tracked by AV1Decoder becomes inconsistent with the
// state tracked by libgav1.
TEST_F(AV1DecoderTest, InconsistentReferenceFrameState) {}

TEST_F(AV1DecoderTest, TryAgainSubmitDecode) {}

// This test verifies that AV1 videos which are encoded using reference frame
// scaling can be decoded completely. Reference frame scaling allows resolution
// changes in a video stream without requiring a key frame. Please refer to
// the chromium bug https://issues.chromium.org/issues/338251332 for details.
TEST_F(AV1DecoderTest, DecodeWithFrameSizeChange) {}

// TODO(hiroh): Add more tests: reference frame tracking, render size change,
// profile change, bit depth change, render size different than the frame size,
// visible rectangle change in the middle of video sequence, reset while waiting
// for buffers, flushing.
}  // namespace media