Add ICU message format support
[chromium-blink-merge.git] / third_party / brotli / dec / bit_reader.c
blob8369397e6a927033ef0037217197fdf619a3c0a3
1 /* Copyright 2013 Google Inc. All Rights Reserved.
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
7 http://www.apache.org/licenses/LICENSE-2.0
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
16 /* Bit reading helpers */
18 #include <assert.h>
19 #include <stdlib.h>
21 #include "./bit_reader.h"
23 #if defined(__cplusplus) || defined(c_plusplus)
24 extern "C" {
25 #endif
27 void BrotliInitBitReader(BrotliBitReader* const br,
28 BrotliInput input, int finish) {
29 assert(br != NULL);
31 br->finish_ = finish;
32 br->tmp_bytes_read_ = 0;
34 br->buf_ptr_ = br->buf_;
35 br->input_ = input;
36 br->val_ = 0;
37 br->pos_ = 0;
38 br->bit_pos_ = 0;
39 br->bit_end_pos_ = 0;
40 br->eos_ = 0;
44 int BrotliWarmupBitReader(BrotliBitReader* const br) {
45 size_t i;
47 if (!BrotliReadMoreInput(br)) {
48 return 0;
50 for (i = 0; i < sizeof(br->val_); ++i) {
51 br->val_ |= ((uint64_t)br->buf_[br->pos_]) << (8 * i);
52 ++br->pos_;
54 return (br->bit_end_pos_ > 0);
57 #if defined(__cplusplus) || defined(c_plusplus)
58 } /* extern "C" */
59 #endif