1 : /*
2 : * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 : *
4 : * Use of this source code is governed by a BSD-style license
5 : * that can be found in the LICENSE file in the root of the source
6 : * tree. An additional intellectual property rights grant can be found
7 : * in the file PATENTS. All contributing project authors may
8 : * be found in the AUTHORS file in the root of the source tree.
9 : */
10 :
11 :
12 : #include "dboolhuff.h"
13 : #include "vpx_ports/mem.h"
14 : #include "vpx_mem/vpx_mem.h"
15 :
16 0 : int vp8dx_start_decode(BOOL_DECODER *br,
17 : const unsigned char *source,
18 : unsigned int source_sz)
19 : {
20 0 : br->user_buffer_end = source+source_sz;
21 0 : br->user_buffer = source;
22 0 : br->value = 0;
23 0 : br->count = -8;
24 0 : br->range = 255;
25 :
26 0 : if (source_sz && !source)
27 0 : return 1;
28 :
29 : /* Populate the buffer */
30 0 : vp8dx_bool_decoder_fill(br);
31 :
32 0 : return 0;
33 : }
34 :
35 :
36 0 : void vp8dx_bool_decoder_fill(BOOL_DECODER *br)
37 : {
38 : const unsigned char *bufptr;
39 : const unsigned char *bufend;
40 : VP8_BD_VALUE value;
41 : int count;
42 0 : bufend = br->user_buffer_end;
43 0 : bufptr = br->user_buffer;
44 0 : value = br->value;
45 0 : count = br->count;
46 :
47 0 : VP8DX_BOOL_DECODER_FILL(count, value, bufptr, bufend);
48 :
49 0 : br->user_buffer = bufptr;
50 0 : br->value = value;
51 0 : br->count = count;
52 0 : }
|