Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: source/libvpx/vp8/decoder/dboolhuff.c

Issue 13042014: Description: (Closed) Base URL: https://src.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: libvpx: Pull from upstream Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/libvpx/vp8/decoder/dboolhuff.h ('k') | source/libvpx/vp8/decoder/decodemv.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 11
12 #include "dboolhuff.h" 12 #include "dboolhuff.h"
13 #include "vpx_ports/mem.h"
14 #include "vpx_mem/vpx_mem.h"
15 13
16 int vp8dx_start_decode(BOOL_DECODER *br, 14 int vp8dx_start_decode(BOOL_DECODER *br,
17 const unsigned char *source, 15 const unsigned char *source,
18 unsigned int source_sz) 16 unsigned int source_sz)
19 { 17 {
20 br->user_buffer_end = source+source_sz; 18 br->user_buffer_end = source+source_sz;
21 br->user_buffer = source; 19 br->user_buffer = source;
22 br->value = 0; 20 br->value = 0;
23 br->count = -8; 21 br->count = -8;
24 br->range = 255; 22 br->range = 255;
25 23
26 if (source_sz && !source) 24 if (source_sz && !source)
27 return 1; 25 return 1;
28 26
29 /* Populate the buffer */ 27 /* Populate the buffer */
30 vp8dx_bool_decoder_fill(br); 28 vp8dx_bool_decoder_fill(br);
31 29
32 return 0; 30 return 0;
33 } 31 }
34 32
35
36 void vp8dx_bool_decoder_fill(BOOL_DECODER *br) 33 void vp8dx_bool_decoder_fill(BOOL_DECODER *br)
37 { 34 {
38 const unsigned char *bufptr; 35 const unsigned char *bufptr = br->user_buffer;
39 const unsigned char *bufend; 36 const unsigned char *bufend = br->user_buffer_end;
40 VP8_BD_VALUE value; 37 VP8_BD_VALUE value = br->value;
41 int count; 38 int count = br->count;
42 bufend = br->user_buffer_end; 39 int shift = VP8_BD_VALUE_SIZE - 8 - (count + 8);
43 bufptr = br->user_buffer; 40 size_t bits_left = (bufend - bufptr)*CHAR_BIT;
44 value = br->value; 41 int x = (int)(shift + CHAR_BIT - bits_left);
45 count = br->count; 42 int loop_end = 0;
46 43
47 VP8DX_BOOL_DECODER_FILL(count, value, bufptr, bufend); 44 if(x >= 0)
45 {
46 count += VP8_LOTS_OF_BITS;
47 loop_end = x;
48 }
49
50 if (x < 0 || bits_left)
51 {
52 while(shift >= loop_end)
53 {
54 count += CHAR_BIT;
55 value |= (VP8_BD_VALUE)*bufptr++ << shift;
56 shift -= CHAR_BIT;
57 }
58 }
48 59
49 br->user_buffer = bufptr; 60 br->user_buffer = bufptr;
50 br->value = value; 61 br->value = value;
51 br->count = count; 62 br->count = count;
52 } 63 }
OLDNEW
« no previous file with comments | « source/libvpx/vp8/decoder/dboolhuff.h ('k') | source/libvpx/vp8/decoder/decodemv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698