chromium/media/gpu/h264_decoder.cc

// Copyright 2012 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/h264_decoder.h"

#include <limits>
#include <memory>
#include <optional>

#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "base/ranges/algorithm.h"
#include "media/base/media_switches.h"
#include "media/parsers/h264_level_limits.h"

namespace media {
namespace {

bool ParseBitDepth(const H264SPS& sps, uint8_t& bit_depth) {}

bool IsValidBitDepth(uint8_t bit_depth, VideoCodecProfile profile) {}
}  // namespace

H264Decoder::H264Accelerator::H264Accelerator() = default;

H264Decoder::H264Accelerator::~H264Accelerator() = default;

scoped_refptr<H264Picture>
H264Decoder::H264Accelerator::CreateH264PictureSecure(uint64_t secure_handle) {}

void H264Decoder::H264Accelerator::ProcessSPS(
    const H264SPS* sps,
    base::span<const uint8_t> sps_nalu_data) {}

void H264Decoder::H264Accelerator::ProcessPPS(
    const H264PPS* pps,
    base::span<const uint8_t> pps_nalu_data) {}

H264Decoder::H264Accelerator::Status
H264Decoder::H264Accelerator::ParseEncryptedSliceHeader(
    const std::vector<base::span<const uint8_t>>& data,
    const std::vector<SubsampleEntry>& subsamples,
    uint64_t secure_handle,
    H264SliceHeader* slice_header_out) {}

H264Decoder::H264Accelerator::Status H264Decoder::H264Accelerator::SetStream(
    base::span<const uint8_t> stream,
    const DecryptConfig* decrypt_config) {}

bool H264Decoder::H264Accelerator::RequiresRefLists() {}

H264Decoder::H264Decoder(std::unique_ptr<H264Accelerator> accelerator,
                         VideoCodecProfile profile,
                         const VideoColorSpace& container_color_space)
    :{}

H264Decoder::~H264Decoder() = default;

void H264Decoder::Reset() {}

void H264Decoder::PrepareRefPicLists() {}

bool H264Decoder::ModifyReferencePicLists(const H264SliceHeader* slice_hdr,
                                          H264Picture::Vector* ref_pic_list0,
                                          H264Picture::Vector* ref_pic_list1) {}

H264Decoder::H264Accelerator::Status H264Decoder::DecodePicture() {}

bool H264Decoder::InitNonexistingPicture(scoped_refptr<H264Picture> pic,
                                         int frame_num) {}

bool H264Decoder::InitCurrPicture(const H264SliceHeader* slice_hdr) {}

bool H264Decoder::CalculatePicOrderCounts(scoped_refptr<H264Picture> pic) {}

void H264Decoder::UpdatePicNums(int frame_num) {}

struct PicNumDescCompare {};

struct LongTermPicNumAscCompare {};

void H264Decoder::ConstructReferencePicListsP() {}

struct POCAscCompare {};

struct POCDescCompare {};

void H264Decoder::ConstructReferencePicListsB() {}

// See 8.2.4
int H264Decoder::PicNumF(const H264Picture& pic) {}

// See 8.2.4
int H264Decoder::LongTermPicNumF(const H264Picture& pic) {}

// Shift elements on the |v| starting from |from| to |to|, inclusive,
// one position to the right and insert pic at |from|.
static void ShiftRightAndInsert(H264Picture::Vector* v,
                                int from,
                                int to,
                                scoped_refptr<H264Picture> pic) {}

bool H264Decoder::ModifyReferencePicList(const H264SliceHeader* slice_hdr,
                                         int list,
                                         H264Picture::Vector* ref_pic_listx) {}

bool H264Decoder::OutputPic(scoped_refptr<H264Picture> pic) {}

void H264Decoder::ClearDPB() {}

bool H264Decoder::OutputAllRemainingPics() {}

bool H264Decoder::Flush() {}

H264Decoder::H264Accelerator::Status H264Decoder::StartNewFrame(
    const H264SliceHeader* slice_hdr) {}

bool H264Decoder::HandleMemoryManagementOps(scoped_refptr<H264Picture> pic) {}

// This method ensures that DPB does not overflow, either by removing
// reference pictures as specified in the stream, or using a sliding window
// procedure to remove the oldest one.
// It also performs marking and unmarking pictures as reference.
// See spac 8.2.5.1.
bool H264Decoder::ReferencePictureMarking(scoped_refptr<H264Picture> pic) {}

bool H264Decoder::SlidingWindowPictureMarking() {}

bool H264Decoder::FinishPicture(scoped_refptr<H264Picture> pic) {}

bool H264Decoder::UpdateMaxNumReorderFrames(const H264SPS* sps) {}

bool H264Decoder::ProcessSPS(int sps_id, bool* need_new_buffers) {}

H264Decoder::H264Accelerator::Status H264Decoder::FinishPrevFrameIfPresent() {}

bool H264Decoder::HandleFrameNumGap(int frame_num) {}

H264Decoder::H264Accelerator::Status H264Decoder::ProcessEncryptedSliceHeader(
    const std::vector<SubsampleEntry>& subsamples) {}

H264Decoder::H264Accelerator::Status H264Decoder::PreprocessCurrentSlice() {}

H264Decoder::H264Accelerator::Status H264Decoder::ProcessCurrentSlice() {}

#define SET_ERROR_AND_RETURN()

#define CHECK_ACCELERATOR_RESULT(func)

void H264Decoder::SetStream(int32_t id, const DecoderBuffer& decoder_buffer) {}

H264Decoder::DecodeResult H264Decoder::Decode() {}

gfx::Size H264Decoder::GetPicSize() const {}

gfx::Rect H264Decoder::GetVisibleRect() const {}

VideoCodecProfile H264Decoder::GetProfile() const {}

uint8_t H264Decoder::GetBitDepth() const {}

VideoChromaSampling H264Decoder::GetChromaSampling() const {}

VideoColorSpace H264Decoder::GetVideoColorSpace() const {}

std::optional<gfx::HDRMetadata> H264Decoder::GetHDRMetadata() const {}

size_t H264Decoder::GetRequiredNumOfPictures() const {}

size_t H264Decoder::GetNumReferenceFrames() const {}

// static
bool H264Decoder::FillH264PictureFromSliceHeader(
    const H264SPS* sps,
    const H264SliceHeader& slice_hdr,
    H264Picture* pic) {}

// static
bool H264Decoder::IsNewPrimaryCodedPicture(const H264Picture* curr_pic,
                                           int curr_pps_id,
                                           const H264SPS* sps,
                                           const H264SliceHeader& slice_hdr) {}

}  // namespace media