// Copyright 2015 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/cast/encoding/vpx_quantizer_parser.h" #include "base/logging.h" #include "base/memory/raw_ptr.h" namespace media { namespace cast { namespace { // VpxBitReader is a re-implementation of a subset of the VP8 entropy decoder. // It is used to decompress the VP8 bitstream for the purposes of quickly // parsing the VP8 frame headers. It is mostly the exact same implementation // found in third_party/libvpx/.../vp8/decoder/dboolhuff.h except that only // the portion of the implementation needed to parse the frame headers is // present. As of this writing, the implementation in libvpx could not be // re-used because of the way that the code is structured, and lack of the // necessary parts being exported. class VpxBitReader { … }; // The number of bits to be left-shifted to make the variable range_ over 128. const uint8_t vpx_shift[128] = …; // Mapping from the q_index(0-127) to the quantizer value(0-63). const uint8_t vpx_quantizer_lookup[128] = …; void VpxBitReader::VpxDecoderReadBytes() { … } unsigned int VpxBitReader::DecodeBit() { … } unsigned int VpxBitReader::DecodeValue(unsigned int num_bits) { … } // Parse the Segment Header part in the first partition. void ParseSegmentHeader(VpxBitReader* bit_reader) { … } // Parse the Filter Header in the first partition. void ParseFilterHeader(VpxBitReader* bit_reader) { … } } // unnamed namespace int ParseVpxHeaderQuantizer(const uint8_t* encoded_data, size_t size) { … } } // namespace cast } // namespace media