Differential D9642 Diff 31337 extern/draco/draco/src/draco/compression/bit_coders/rans_bit_decoder.cc
Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/compression/bit_coders/rans_bit_decoder.cc
- This file was moved from extern/draco/dracoenc/src/draco/compression/bit_coders/rans_bit_decoder.cc.
| Show All 21 Lines | |||||
| RAnsBitDecoder::RAnsBitDecoder() : prob_zero_(0) {} | RAnsBitDecoder::RAnsBitDecoder() : prob_zero_(0) {} | ||||
| RAnsBitDecoder::~RAnsBitDecoder() { Clear(); } | RAnsBitDecoder::~RAnsBitDecoder() { Clear(); } | ||||
| bool RAnsBitDecoder::StartDecoding(DecoderBuffer *source_buffer) { | bool RAnsBitDecoder::StartDecoding(DecoderBuffer *source_buffer) { | ||||
| Clear(); | Clear(); | ||||
| if (!source_buffer->Decode(&prob_zero_)) | if (!source_buffer->Decode(&prob_zero_)) { | ||||
| return false; | return false; | ||||
| } | |||||
| uint32_t size_in_bytes; | uint32_t size_in_bytes; | ||||
| #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED | #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED | ||||
| if (source_buffer->bitstream_version() < DRACO_BITSTREAM_VERSION(2, 2)) { | if (source_buffer->bitstream_version() < DRACO_BITSTREAM_VERSION(2, 2)) { | ||||
| if (!source_buffer->Decode(&size_in_bytes)) | if (!source_buffer->Decode(&size_in_bytes)) { | ||||
| return false; | return false; | ||||
| } | |||||
| } else | } else | ||||
| #endif | #endif | ||||
| { | { | ||||
| if (!DecodeVarint(&size_in_bytes, source_buffer)) | if (!DecodeVarint(&size_in_bytes, source_buffer)) { | ||||
| 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 RAnsBitDecoder::DecodeNextBit() { | bool RAnsBitDecoder::DecodeNextBit() { | ||||
| const uint8_t bit = rabs_read(&ans_decoder_, prob_zero_); | const uint8_t bit = rabs_read(&ans_decoder_, prob_zero_); | ||||
| return bit > 0; | return bit > 0; | ||||
| } | } | ||||
| Show All 16 Lines | |||||