#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/parsers/vp9_parser.h"
#include <algorithm>
#include "base/containers/circular_deque.h"
#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/numerics/byte_conversions.h"
#include "base/numerics/safe_conversions.h"
#include "media/parsers/vp9_compressed_header_parser.h"
#include "media/parsers/vp9_uncompressed_header_parser.h"
namespace media {
namespace {
constexpr size_t kQIndexRange = …;
const int16_t kDcQLookup[][kQIndexRange] = …;
const int16_t kAcQLookup[][kQIndexRange] = …;
static_assert …;
size_t ClampQ(int64_t q) { … }
int ClampLf(int lf) { … }
std::string IncrementIV(std::string_view iv, uint32_t by) { … }
std::unique_ptr<DecryptConfig> SplitSubsamples(
uint32_t frame_size,
size_t* current_subsample_index,
size_t* extra_clear_subsample_bytes,
const DecryptConfig* base_decrypt_config,
const std::vector<SubsampleEntry>& subsamples,
std::string* iv) { … }
bool IsByteNEncrypted(off_t byte,
const std::vector<SubsampleEntry>& subsamples) { … }
}
bool Vp9FrameHeader::IsKeyframe() const { … }
bool Vp9FrameHeader::IsIntra() const { … }
VideoColorSpace Vp9FrameHeader::GetColorSpace() const { … }
Vp9Parser::FrameInfo::FrameInfo() = default;
Vp9Parser::FrameInfo::~FrameInfo() = default;
Vp9Parser::FrameInfo::FrameInfo(const uint8_t* ptr, off_t size)
: … { … }
Vp9Parser::FrameInfo::FrameInfo(const FrameInfo& copy_from)
: … { … }
Vp9Parser::FrameInfo& Vp9Parser::FrameInfo::operator=(
const FrameInfo& copy_from) { … }
bool Vp9FrameContext::IsValid() const { … }
void Vp9Parser::Context::Reset() { … }
const Vp9Parser::ReferenceSlot& Vp9Parser::Context::GetRefSlot(
size_t ref_type) const { … }
void Vp9Parser::Context::UpdateRefSlot(
size_t ref_type,
const Vp9Parser::ReferenceSlot& ref_slot) { … }
Vp9Parser::Vp9Parser(bool parsing_compressed_header)
: … { … }
Vp9Parser::~Vp9Parser() = default;
void Vp9Parser::SetStream(const uint8_t* stream,
off_t stream_size,
const std::vector<uint32_t>& spatial_layer_frame_size,
std::unique_ptr<DecryptConfig> stream_config) { … }
void Vp9Parser::SetStream(const uint8_t* stream,
off_t stream_size,
std::unique_ptr<DecryptConfig> stream_config) { … }
void Vp9Parser::Reset() { … }
bool Vp9Parser::ParseUncompressedHeader(const FrameInfo& frame_info,
Vp9FrameHeader* fhdr,
Result* result,
Vp9Parser::Context* context) { … }
bool Vp9Parser::ParseCompressedHeader(const FrameInfo& frame_info,
Result* result) { … }
Vp9Parser::Result Vp9Parser::ParseNextFrame(
Vp9FrameHeader* fhdr,
gfx::Size* allocate_size,
std::unique_ptr<DecryptConfig>* frame_decrypt_config) { … }
std::unique_ptr<DecryptConfig> Vp9Parser::NextFrameDecryptContextForTesting() { … }
std::string Vp9Parser::IncrementIVForTesting(std::string_view iv, uint32_t by) { … }
bool Vp9Parser::IsSuperframe(const uint8_t* stream,
off_t stream_size,
const DecryptConfig* decrypt_config) { … }
base::circular_deque<Vp9Parser::FrameInfo> Vp9Parser::ExtractFrames(
const uint8_t* stream,
off_t stream_size,
const DecryptConfig* decrypt_config) { … }
base::circular_deque<Vp9Parser::FrameInfo> Vp9Parser::ParseSuperframe() { … }
base::circular_deque<Vp9Parser::FrameInfo> Vp9Parser::ParseSVCFrame() { … }
int64_t Vp9Parser::GetQIndex(const Vp9QuantizationParams& quant,
size_t segid) const { … }
bool Vp9Parser::SetupSegmentationDequant() { … }
void Vp9Parser::SetupLoopFilter() { … }
void Vp9Parser::UpdateSlots(Vp9Parser::Context* context) { … }
}