// Copyright 2016 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/parsers/vp9_bool_decoder.h" #include <algorithm> #include <memory> #include "base/logging.h" #include "media/base/bit_reader.h" namespace media { namespace { // This is an optimization lookup table for the loop in spec 9.2.2. // while BoolRange <= 128: // read 1 bit // BoolRange *= 2 // This table indicates how many iterations to run for a given BoolRange. So // the loop could be reduced to // read (kCountToShiftTo128[BoolRange]) bits const int kCountToShiftTo128[256] = …; } // namespace Vp9BoolDecoder::Vp9BoolDecoder() = default; Vp9BoolDecoder::~Vp9BoolDecoder() = default; // 9.2.1 Initialization process for Boolean decoder bool Vp9BoolDecoder::Initialize(const uint8_t* data, size_t size) { … } // Fill at least |count_to_fill_| bits and prefill remain bits of |bool_value_| // if data is enough. bool Vp9BoolDecoder::Fill() { … } // 9.2.2 Boolean decoding process bool Vp9BoolDecoder::ReadBool(int prob) { … } // 9.2.4 Parsing process for read_literal uint8_t Vp9BoolDecoder::ReadLiteral(int bits) { … } bool Vp9BoolDecoder::ConsumePaddingBits() { … } } // namespace media