1 /*
2 * exp golomb vlc writing stuff
3 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
4 * Copyright (c) 2004 Alex Beregszaszi
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 /**
24 * @file
25 * @brief
26 * exp golomb vlc writing stuff
27 * @author Michael Niedermayer <michaelni@gmx.at> and Alex Beregszaszi
28 */
29
30 #ifndef AVCODEC_PUT_GOLOMB_H
31 #define AVCODEC_PUT_GOLOMB_H
32
33 #include <stdint.h>
35
37
38 /**
39 * write unsigned exp golomb code. 2^16 - 2 at most
40 */
42 {
45
48 else {
51 }
52 }
53
54 /**
55 * write unsigned exp golomb code. 2^32-2 at most.
56 */
58 {
60
63 else {
66 }
67 }
68
69 /**
70 * write truncated unsigned exp golomb code.
71 */
73 {
76
79 else
81 }
82
83 /**
84 * write signed exp golomb code. 16 bits at most.
85 */
87 {
90 i ^= -1;
//FIXME check if gcc does the right thing
92 }
93
94 /**
95 * write unsigned golomb rice code (ffv1).
96 */
98 int esc_len)
99 {
100 int e;
101
103
107 else
109 }
110
111 /**
112 * write unsigned golomb rice code (jpegls).
113 */
115 int limit,
int esc_len)
116 {
117 int e;
118
120
123 while (e > 31) {
125 e -= 31;
126 }
128 if (k)
130 } else {
134 }
137 }
138 }
139
140 /**
141 * write signed golomb rice code (ffv1).
142 */
144 int esc_len)
145 {
146 int v;
147
149 v ^= (v >> 31);
150
152 }
153
154 #endif /* AVCODEC_PUT_GOLOMB_H */