Differential D9642 Diff 31357 extern/draco/draco/src/draco/compression/bit_coders/adaptive_rans_bit_decoder.cc
Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/compression/bit_coders/adaptive_rans_bit_decoder.cc
- This file was moved from extern/draco/dracoenc/src/draco/compression/bit_coders/adaptive_rans_bit_decoder.cc.
| Show All 20 Lines | |||||
| AdaptiveRAnsBitDecoder::AdaptiveRAnsBitDecoder() : p0_f_(0.5) {} | AdaptiveRAnsBitDecoder::AdaptiveRAnsBitDecoder() : p0_f_(0.5) {} | ||||
| AdaptiveRAnsBitDecoder::~AdaptiveRAnsBitDecoder() { Clear(); } | AdaptiveRAnsBitDecoder::~AdaptiveRAnsBitDecoder() { Clear(); } | ||||
| bool AdaptiveRAnsBitDecoder::StartDecoding(DecoderBuffer *source_buffer) { | bool AdaptiveRAnsBitDecoder::StartDecoding(DecoderBuffer *source_buffer) { | ||||
| Clear(); | Clear(); | ||||
| uint32_t size_in_bytes; | uint32_t size_in_bytes; | ||||
| if (!source_buffer->Decode(&size_in_bytes)) | if (!source_buffer->Decode(&size_in_bytes)) { | ||||
| return false; | return false; | ||||
| if (size_in_bytes > source_buffer->remaining_size()) | } | ||||
| if (size_in_bytes > source_buffer->remaining_size()) { | |||||
| return false; | return false; | ||||
| } | |||||
| if (ans_read_init(&ans_decoder_, | if (ans_read_init(&ans_decoder_, | ||||
| reinterpret_cast<uint8_t *>( | reinterpret_cast<uint8_t *>( | ||||
| const_cast<char *>(source_buffer->data_head())), | const_cast<char *>(source_buffer->data_head())), | ||||
| size_in_bytes) != 0) | size_in_bytes) != 0) { | ||||
| return false; | return false; | ||||
| } | |||||
| source_buffer->Advance(size_in_bytes); | source_buffer->Advance(size_in_bytes); | ||||
| return true; | return true; | ||||
| } | } | ||||
| bool AdaptiveRAnsBitDecoder::DecodeNextBit() { | bool AdaptiveRAnsBitDecoder::DecodeNextBit() { | ||||
| const uint8_t p0 = clamp_probability(p0_f_); | const uint8_t p0 = clamp_probability(p0_f_); | ||||
| const bool bit = static_cast<bool>(rabs_read(&ans_decoder_, p0)); | const bool bit = static_cast<bool>(rabs_read(&ans_decoder_, p0)); | ||||
| p0_f_ = update_probability(p0_f_, bit); | p0_f_ = update_probability(p0_f_, bit); | ||||
| Show All 22 Lines | |||||