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

Side by Side Diff: source/libvpx/vp9/encoder/vp9_writer.h

Issue 478033002: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 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
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 #ifndef VP9_ENCODER_VP9_WRITER_H_ 11 #ifndef VP9_ENCODER_VP9_WRITER_H_
12 #define VP9_ENCODER_VP9_WRITER_H_ 12 #define VP9_ENCODER_VP9_WRITER_H_
13 13
14 #include "vpx_ports/mem.h" 14 #include "vpx_ports/mem.h"
15 15
16 #include "vp9/common/vp9_prob.h" 16 #include "vp9/common/vp9_prob.h"
17 17
18 #ifdef __cplusplus 18 #ifdef __cplusplus
19 extern "C" { 19 extern "C" {
20 #endif 20 #endif
21 21
22 typedef struct { 22 typedef struct {
23 unsigned int lowvalue; 23 unsigned int lowvalue;
24 unsigned int range; 24 unsigned int range;
25 unsigned int value;
26 int count; 25 int count;
27 unsigned int pos; 26 unsigned int pos;
28 uint8_t *buffer; 27 uint8_t *buffer;
29
30 // Variables used to track bit costs without outputing to the bitstream
31 unsigned int measure_cost;
32 uint64_t bit_counter;
33 } vp9_writer; 28 } vp9_writer;
34 29
35 void vp9_start_encode(vp9_writer *bc, uint8_t *buffer); 30 void vp9_start_encode(vp9_writer *bc, uint8_t *buffer);
36 void vp9_stop_encode(vp9_writer *bc); 31 void vp9_stop_encode(vp9_writer *bc);
37 32
38 static void vp9_write(vp9_writer *br, int bit, int probability) { 33 static INLINE void vp9_write(vp9_writer *br, int bit, int probability) {
39 unsigned int split; 34 unsigned int split;
40 int count = br->count; 35 int count = br->count;
41 unsigned int range = br->range; 36 unsigned int range = br->range;
42 unsigned int lowvalue = br->lowvalue; 37 unsigned int lowvalue = br->lowvalue;
43 register unsigned int shift; 38 register unsigned int shift;
44 39
45 split = 1 + (((range - 1) * probability) >> 8); 40 split = 1 + (((range - 1) * probability) >> 8);
46 41
47 range = split; 42 range = split;
48 43
(...skipping 27 matching lines...) Expand all
76 lowvalue &= 0xffffff; 71 lowvalue &= 0xffffff;
77 count -= 8; 72 count -= 8;
78 } 73 }
79 74
80 lowvalue <<= shift; 75 lowvalue <<= shift;
81 br->count = count; 76 br->count = count;
82 br->lowvalue = lowvalue; 77 br->lowvalue = lowvalue;
83 br->range = range; 78 br->range = range;
84 } 79 }
85 80
86 static void vp9_write_bit(vp9_writer *w, int bit) { 81 static INLINE void vp9_write_bit(vp9_writer *w, int bit) {
87 vp9_write(w, bit, 128); // vp9_prob_half 82 vp9_write(w, bit, 128); // vp9_prob_half
88 } 83 }
89 84
90 static void vp9_write_literal(vp9_writer *w, int data, int bits) { 85 static INLINE void vp9_write_literal(vp9_writer *w, int data, int bits) {
91 int bit; 86 int bit;
92 87
93 for (bit = bits - 1; bit >= 0; bit--) 88 for (bit = bits - 1; bit >= 0; bit--)
94 vp9_write_bit(w, 1 & (data >> bit)); 89 vp9_write_bit(w, 1 & (data >> bit));
95 } 90 }
96 91
97 #define vp9_write_prob(w, v) vp9_write_literal((w), (v), 8) 92 #define vp9_write_prob(w, v) vp9_write_literal((w), (v), 8)
98 93
99 #ifdef __cplusplus 94 #ifdef __cplusplus
100 } // extern "C" 95 } // extern "C"
101 #endif 96 #endif
102 97
103 #endif // VP9_ENCODER_VP9_WRITER_H_ 98 #endif // VP9_ENCODER_VP9_WRITER_H_
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_write_bit_buffer.c ('k') | source/libvpx/vp9/encoder/vp9_writer.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698