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

Side by Side Diff: source/libvpx/vp8/encoder/boolhuff.h

Issue 7671004: Update libvpx snapshot to v0.9.7-p1 (Cayuga). (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: '' Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp8/encoder/block.h ('k') | source/libvpx/vp8/encoder/boolhuff.c » ('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 /**************************************************************************** 12 /****************************************************************************
13 * 13 *
14 * Module Title : boolhuff.h 14 * Module Title : boolhuff.h
15 * 15 *
16 * Description : Bool Coder header file. 16 * Description : Bool Coder header file.
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19 #ifndef __INC_BOOLHUFF_H 19 #ifndef __INC_BOOLHUFF_H
20 #define __INC_BOOLHUFF_H 20 #define __INC_BOOLHUFF_H
21 21
22 #include "vpx_ports/mem.h"
22 23
23 typedef struct 24 typedef struct
24 { 25 {
25 unsigned int lowvalue; 26 unsigned int lowvalue;
26 unsigned int range; 27 unsigned int range;
27 unsigned int value; 28 unsigned int value;
28 int count; 29 int count;
29 unsigned int pos; 30 unsigned int pos;
30 unsigned char *buffer; 31 unsigned char *buffer;
31 32
32 // Variables used to track bit costs without outputing to the bitstream 33 // Variables used to track bit costs without outputing to the bitstream
33 unsigned int measure_cost; 34 unsigned int measure_cost;
34 unsigned long bit_counter; 35 unsigned long bit_counter;
35 } BOOL_CODER; 36 } BOOL_CODER;
36 37
37 extern void vp8_start_encode(BOOL_CODER *bc, unsigned char *buffer); 38 extern void vp8_start_encode(BOOL_CODER *bc, unsigned char *buffer);
38 extern void vp8_encode_bool(BOOL_CODER *bc, int x, int context); 39
39 extern void vp8_encode_value(BOOL_CODER *br, int data, int bits); 40 extern void vp8_encode_value(BOOL_CODER *br, int data, int bits);
40 extern void vp8_stop_encode(BOOL_CODER *bc); 41 extern void vp8_stop_encode(BOOL_CODER *bc);
41 extern const unsigned int vp8_prob_cost[256]; 42 extern const unsigned int vp8_prob_cost[256];
42 43
44
45 DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]);
46
47
48 static void vp8_encode_bool(BOOL_CODER *br, int bit, int probability)
49 {
50 unsigned int split;
51 int count = br->count;
52 unsigned int range = br->range;
53 unsigned int lowvalue = br->lowvalue;
54 register unsigned int shift;
55
56 #ifdef ENTROPY_STATS
57 #if defined(SECTIONBITS_OUTPUT)
58
59 if (bit)
60 Sectionbits[active_section] += vp8_prob_cost[255-probability];
61 else
62 Sectionbits[active_section] += vp8_prob_cost[probability];
63
43 #endif 64 #endif
65 #endif
66
67 split = 1 + (((range - 1) * probability) >> 8);
68
69 range = split;
70
71 if (bit)
72 {
73 lowvalue += split;
74 range = br->range - split;
75 }
76
77 shift = vp8_norm[range];
78
79 range <<= shift;
80 count += shift;
81
82 if (count >= 0)
83 {
84 int offset = shift - count;
85
86 if ((lowvalue << (offset - 1)) & 0x80000000)
87 {
88 int x = br->pos - 1;
89
90 while (x >= 0 && br->buffer[x] == 0xff)
91 {
92 br->buffer[x] = (unsigned char)0;
93 x--;
94 }
95
96 br->buffer[x] += 1;
97 }
98
99 br->buffer[br->pos++] = (lowvalue >> (24 - offset));
100 lowvalue <<= offset;
101 shift = count;
102 lowvalue &= 0xffffff;
103 count -= 8 ;
104 }
105
106 lowvalue <<= shift;
107 br->count = count;
108 br->lowvalue = lowvalue;
109 br->range = range;
110 }
111
112 #endif
OLDNEW
« no previous file with comments | « source/libvpx/vp8/encoder/block.h ('k') | source/libvpx/vp8/encoder/boolhuff.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698