FFmpeg  4.1.11
golomb.h
Go to the documentation of this file.
1 /*
2  * exp golomb vlc 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 stuff
27  * @author Michael Niedermayer <michaelni@gmx.at> and Alex Beregszaszi
28  */
29 
30 #ifndef AVCODEC_GOLOMB_H
31 #define AVCODEC_GOLOMB_H
32 
33 #include <stdint.h>
34 
35 #include "get_bits.h"
36 #include "put_bits.h"
37 
38 #define INVALID_VLC 0x80000000
39 
40 extern const uint8_t ff_golomb_vlc_len[512];
41 extern const uint8_t ff_ue_golomb_vlc_code[512];
42 extern const int8_t ff_se_golomb_vlc_code[512];
43 extern const uint8_t ff_ue_golomb_len[256];
44 
45 extern const uint8_t ff_interleaved_golomb_vlc_len[256];
47 extern const int8_t ff_interleaved_se_golomb_vlc_code[256];
49 
50 /**
51  * Read an unsigned Exp-Golomb code in the range 0 to 8190.
52  *
53  * @returns the read value or a negative error code.
54  */
55 static inline int get_ue_golomb(GetBitContext *gb)
56 {
57  unsigned int buf;
58 
59 #if CACHED_BITSTREAM_READER
60  buf = show_bits_long(gb, 32);
61 
62  if (buf >= (1 << 27)) {
63  buf >>= 32 - 9;
65 
66  return ff_ue_golomb_vlc_code[buf];
67  } else {
68  int log = 2 * av_log2(buf) - 31;
69  buf >>= log;
70  buf--;
71  skip_bits_long(gb, 32 - log);
72 
73  return buf;
74  }
75 #else
76  OPEN_READER(re, gb);
77  UPDATE_CACHE(re, gb);
78  buf = GET_CACHE(re, gb);
79 
80  if (buf >= (1 << 27)) {
81  buf >>= 32 - 9;
83  CLOSE_READER(re, gb);
84 
85  return ff_ue_golomb_vlc_code[buf];
86  } else {
87  int log = 2 * av_log2(buf) - 31;
88  LAST_SKIP_BITS(re, gb, 32 - log);
89  CLOSE_READER(re, gb);
90  if (log < 7) {
91  av_log(NULL, AV_LOG_ERROR, "Invalid UE golomb code\n");
92  return AVERROR_INVALIDDATA;
93  }
94  buf >>= log;
95  buf--;
96 
97  return buf;
98  }
99 #endif
100 }
101 
102 /**
103  * Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
104  */
105 static inline unsigned get_ue_golomb_long(GetBitContext *gb)
106 {
107  unsigned buf, log;
108 
109  buf = show_bits_long(gb, 32);
110  log = 31 - av_log2(buf);
111  skip_bits_long(gb, log);
112 
113  return get_bits_long(gb, log + 1) - 1;
114 }
115 
116 /**
117  * read unsigned exp golomb code, constraint to a max of 31.
118  * the return value is undefined if the stored value exceeds 31.
119  */
120 static inline int get_ue_golomb_31(GetBitContext *gb)
121 {
122  unsigned int buf;
123 
124 #if CACHED_BITSTREAM_READER
125  buf = show_bits_long(gb, 32);
126 
127  buf >>= 32 - 9;
129 #else
130 
131  OPEN_READER(re, gb);
132  UPDATE_CACHE(re, gb);
133  buf = GET_CACHE(re, gb);
134 
135  buf >>= 32 - 9;
137  CLOSE_READER(re, gb);
138 #endif
139 
140  return ff_ue_golomb_vlc_code[buf];
141 }
142 
143 static inline unsigned get_interleaved_ue_golomb(GetBitContext *gb)
144 {
145  uint32_t buf;
146 
147 #if CACHED_BITSTREAM_READER
148  buf = show_bits_long(gb, 32);
149 
150  if (buf & 0xAA800000) {
151  buf >>= 32 - 8;
153 
155  } else {
156  unsigned ret = 1;
157 
158  do {
159  buf >>= 32 - 8;
161 
162  if (ff_interleaved_golomb_vlc_len[buf] != 9) {
163  ret <<= (ff_interleaved_golomb_vlc_len[buf] - 1) >> 1;
165  break;
166  }
167  ret = (ret << 4) | ff_interleaved_dirac_golomb_vlc_code[buf];
168  buf = show_bits_long(gb, 32);
169  } while (get_bits_left(gb) > 0);
170 
171  return ret - 1;
172  }
173 #else
174  OPEN_READER(re, gb);
175  UPDATE_CACHE(re, gb);
176  buf = GET_CACHE(re, gb);
177 
178  if (buf & 0xAA800000) {
179  buf >>= 32 - 8;
181  CLOSE_READER(re, gb);
182 
184  } else {
185  unsigned ret = 1;
186 
187  do {
188  buf >>= 32 - 8;
189  LAST_SKIP_BITS(re, gb,
191 
192  if (ff_interleaved_golomb_vlc_len[buf] != 9) {
193  ret <<= (ff_interleaved_golomb_vlc_len[buf] - 1) >> 1;
195  break;
196  }
197  ret = (ret << 4) | ff_interleaved_dirac_golomb_vlc_code[buf];
198  UPDATE_CACHE(re, gb);
199  buf = GET_CACHE(re, gb);
200  } while (ret<0x8000000U && BITS_AVAILABLE(re, gb));
201 
202  CLOSE_READER(re, gb);
203  return ret - 1;
204  }
205 #endif
206 }
207 
208 /**
209  * read unsigned truncated exp golomb code.
210  */
211 static inline int get_te0_golomb(GetBitContext *gb, int range)
212 {
213  av_assert2(range >= 1);
214 
215  if (range == 1)
216  return 0;
217  else if (range == 2)
218  return get_bits1(gb) ^ 1;
219  else
220  return get_ue_golomb(gb);
221 }
222 
223 /**
224  * read unsigned truncated exp golomb code.
225  */
226 static inline int get_te_golomb(GetBitContext *gb, int range)
227 {
228  av_assert2(range >= 1);
229 
230  if (range == 2)
231  return get_bits1(gb) ^ 1;
232  else
233  return get_ue_golomb(gb);
234 }
235 
236 /**
237  * read signed exp golomb code.
238  */
239 static inline int get_se_golomb(GetBitContext *gb)
240 {
241  unsigned int buf;
242 
243 #if CACHED_BITSTREAM_READER
244  buf = show_bits_long(gb, 32);
245 
246  if (buf >= (1 << 27)) {
247  buf >>= 32 - 9;
249 
250  return ff_se_golomb_vlc_code[buf];
251  } else {
252  int log = 2 * av_log2(buf) - 31;
253  buf >>= log;
254 
255  skip_bits_long(gb, 32 - log);
256 
257  if (buf & 1)
258  buf = -(buf >> 1);
259  else
260  buf = (buf >> 1);
261 
262  return buf;
263  }
264 #else
265  OPEN_READER(re, gb);
266  UPDATE_CACHE(re, gb);
267  buf = GET_CACHE(re, gb);
268 
269  if (buf >= (1 << 27)) {
270  buf >>= 32 - 9;
272  CLOSE_READER(re, gb);
273 
274  return ff_se_golomb_vlc_code[buf];
275  } else {
276  int log = av_log2(buf), sign;
277  LAST_SKIP_BITS(re, gb, 31 - log);
278  UPDATE_CACHE(re, gb);
279  buf = GET_CACHE(re, gb);
280 
281  buf >>= log;
282 
283  LAST_SKIP_BITS(re, gb, 32 - log);
284  CLOSE_READER(re, gb);
285 
286  sign = -(buf & 1);
287  buf = ((buf >> 1) ^ sign) - sign;
288 
289  return buf;
290  }
291 #endif
292 }
293 
294 static inline int get_se_golomb_long(GetBitContext *gb)
295 {
296  unsigned int buf = get_ue_golomb_long(gb);
297  int sign = (buf & 1) - 1;
298  return ((buf >> 1) ^ sign) + 1;
299 }
300 
302 {
303  unsigned int buf;
304 
305 #if CACHED_BITSTREAM_READER
306  buf = show_bits_long(gb, 32);
307 
308  if (buf & 0xAA800000) {
309  buf >>= 32 - 8;
311 
313  } else {
314  int log;
315  skip_bits(gb, 8);
316  buf |= 1 | show_bits_long(gb, 24);
317 
318  if ((buf & 0xAAAAAAAA) == 0)
319  return INVALID_VLC;
320 
321  for (log = 31; (buf & 0x80000000) == 0; log--)
322  buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30);
323 
324  skip_bits_long(gb, 63 - 2 * log - 8);
325 
326  return (signed) (((((buf << log) >> log) - 1) ^ -(buf & 0x1)) + 1) >> 1;
327  }
328 #else
329  OPEN_READER(re, gb);
330  UPDATE_CACHE(re, gb);
331  buf = GET_CACHE(re, gb);
332 
333  if (buf & 0xAA800000) {
334  buf >>= 32 - 8;
336  CLOSE_READER(re, gb);
337 
339  } else {
340  int log;
341  LAST_SKIP_BITS(re, gb, 8);
342  UPDATE_CACHE(re, gb);
343  buf |= 1 | (GET_CACHE(re, gb) >> 8);
344 
345  if ((buf & 0xAAAAAAAA) == 0)
346  return INVALID_VLC;
347 
348  for (log = 31; (buf & 0x80000000) == 0; log--)
349  buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30);
350 
351  LAST_SKIP_BITS(re, gb, 63 - 2 * log - 8);
352  CLOSE_READER(re, gb);
353 
354  return (signed) (((((buf << log) >> log) - 1) ^ -(buf & 0x1)) + 1) >> 1;
355  }
356 #endif
357 }
358 
359 static inline int dirac_get_se_golomb(GetBitContext *gb)
360 {
361  uint32_t ret = get_interleaved_ue_golomb(gb);
362 
363  if (ret) {
364  int sign = -get_bits1(gb);
365  ret = (ret ^ sign) - sign;
366  }
367 
368  return ret;
369 }
370 
371 /**
372  * read unsigned golomb rice code (ffv1).
373  */
374 static inline int get_ur_golomb(GetBitContext *gb, int k, int limit,
375  int esc_len)
376 {
377  unsigned int buf;
378  int log;
379 
380 #if CACHED_BITSTREAM_READER
381  buf = show_bits_long(gb, 32);
382 
383  log = av_log2(buf);
384 
385  if (log > 31 - limit) {
386  buf >>= log - k;
387  buf += (30 - log) << k;
388  skip_bits_long(gb, 32 + k - log);
389 
390  return buf;
391  } else {
392  skip_bits_long(gb, limit);
393  buf = get_bits_long(gb, esc_len);
394 
395  return buf + limit - 1;
396  }
397 #else
398  OPEN_READER(re, gb);
399  UPDATE_CACHE(re, gb);
400  buf = GET_CACHE(re, gb);
401 
402  log = av_log2(buf);
403 
404  if (log > 31 - limit) {
405  buf >>= log - k;
406  buf += (30U - log) << k;
407  LAST_SKIP_BITS(re, gb, 32 + k - log);
408  CLOSE_READER(re, gb);
409 
410  return buf;
411  } else {
412  LAST_SKIP_BITS(re, gb, limit);
413  UPDATE_CACHE(re, gb);
414 
415  buf = SHOW_UBITS(re, gb, esc_len);
416 
417  LAST_SKIP_BITS(re, gb, esc_len);
418  CLOSE_READER(re, gb);
419 
420  return buf + limit - 1;
421  }
422 #endif
423 }
424 
425 /**
426  * read unsigned golomb rice code (jpegls).
427  */
428 static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit,
429  int esc_len)
430 {
431  unsigned int buf;
432  int log;
433 
434 #if CACHED_BITSTREAM_READER
435  buf = show_bits_long(gb, 32);
436 
437  log = av_log2(buf);
438 
439  if (log - k >= 1 && 32 - log < limit) {
440  buf >>= log - k;
441  buf += (30 - log) << k;
442  skip_bits_long(gb, 32 + k - log);
443 
444  return buf;
445  } else {
446  int i;
447  for (i = 0;
448  i < limit && get_bits1(gb) == 0 && get_bits_left(gb) > 0;
449  i++);
450 
451  if (i < limit - 1) {
452  buf = get_bits_long(gb, k);
453 
454  return buf + (i << k);
455  } else if (i == limit - 1) {
456  buf = get_bits_long(gb, esc_len);
457 
458  return buf + 1;
459  } else
460  return -1;
461  }
462 #else
463  OPEN_READER(re, gb);
464  UPDATE_CACHE(re, gb);
465  buf = GET_CACHE(re, gb);
466 
467  log = av_log2(buf);
468 
469  av_assert2(k <= 31);
470 
471  if (log - k >= 32 - MIN_CACHE_BITS + (MIN_CACHE_BITS == 32) &&
472  32 - log < limit) {
473  buf >>= log - k;
474  buf += (30U - log) << k;
475  LAST_SKIP_BITS(re, gb, 32 + k - log);
476  CLOSE_READER(re, gb);
477 
478  return buf;
479  } else {
480  int i;
481  for (i = 0; i < limit && SHOW_UBITS(re, gb, 1) == 0; i++) {
482  if (gb->size_in_bits <= re_index) {
483  CLOSE_READER(re, gb);
484  return -1;
485  }
486  LAST_SKIP_BITS(re, gb, 1);
487  UPDATE_CACHE(re, gb);
488  }
489  SKIP_BITS(re, gb, 1);
490 
491  if (i < limit - 1) {
492  if (k) {
493  if (k > MIN_CACHE_BITS - 1) {
494  buf = SHOW_UBITS(re, gb, 16) << (k-16);
495  LAST_SKIP_BITS(re, gb, 16);
496  UPDATE_CACHE(re, gb);
497  buf |= SHOW_UBITS(re, gb, k-16);
498  LAST_SKIP_BITS(re, gb, k-16);
499  } else {
500  buf = SHOW_UBITS(re, gb, k);
501  LAST_SKIP_BITS(re, gb, k);
502  }
503  } else {
504  buf = 0;
505  }
506 
507  buf += ((SUINT)i << k);
508  } else if (i == limit - 1) {
509  buf = SHOW_UBITS(re, gb, esc_len);
510  LAST_SKIP_BITS(re, gb, esc_len);
511 
512  buf ++;
513  } else {
514  buf = -1;
515  }
516  CLOSE_READER(re, gb);
517  return buf;
518  }
519 #endif
520 }
521 
522 /**
523  * read signed golomb rice code (ffv1).
524  */
525 static inline int get_sr_golomb(GetBitContext *gb, int k, int limit,
526  int esc_len)
527 {
528  unsigned v = get_ur_golomb(gb, k, limit, esc_len);
529  return (v >> 1) ^ -(v & 1);
530 }
531 
532 /**
533  * read signed golomb rice code (flac).
534  */
535 static inline int get_sr_golomb_flac(GetBitContext *gb, int k, int limit,
536  int esc_len)
537 {
538  unsigned v = get_ur_golomb_jpegls(gb, k, limit, esc_len);
539  return (v >> 1) ^ -(v & 1);
540 }
541 
542 /**
543  * read unsigned golomb rice code (shorten).
544  */
545 static inline unsigned int get_ur_golomb_shorten(GetBitContext *gb, int k)
546 {
547  return get_ur_golomb_jpegls(gb, k, INT_MAX, 0);
548 }
549 
550 /**
551  * read signed golomb rice code (shorten).
552  */
553 static inline int get_sr_golomb_shorten(GetBitContext *gb, int k)
554 {
555  int uvar = get_ur_golomb_jpegls(gb, k + 1, INT_MAX, 0);
556  return (uvar >> 1) ^ -(uvar & 1);
557 }
558 
559 #ifdef TRACE
560 
561 static inline int get_ue(GetBitContext *s, const char *file, const char *func,
562  int line)
563 {
564  int show = show_bits(s, 24);
565  int pos = get_bits_count(s);
566  int i = get_ue_golomb(s);
567  int len = get_bits_count(s) - pos;
568  int bits = show >> (24 - len);
569 
570  av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d ue @%5d in %s %s:%d\n",
571  bits, len, i, pos, file, func, line);
572 
573  return i;
574 }
575 
576 static inline int get_se(GetBitContext *s, const char *file, const char *func,
577  int line)
578 {
579  int show = show_bits(s, 24);
580  int pos = get_bits_count(s);
581  int i = get_se_golomb(s);
582  int len = get_bits_count(s) - pos;
583  int bits = show >> (24 - len);
584 
585  av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d se @%5d in %s %s:%d\n",
586  bits, len, i, pos, file, func, line);
587 
588  return i;
589 }
590 
591 static inline int get_te(GetBitContext *s, int r, char *file, const char *func,
592  int line)
593 {
594  int show = show_bits(s, 24);
595  int pos = get_bits_count(s);
596  int i = get_te0_golomb(s, r);
597  int len = get_bits_count(s) - pos;
598  int bits = show >> (24 - len);
599 
600  av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d te @%5d in %s %s:%d\n",
601  bits, len, i, pos, file, func, line);
602 
603  return i;
604 }
605 
606 #define get_ue_golomb(a) get_ue(a, __FILE__, __func__, __LINE__)
607 #define get_se_golomb(a) get_se(a, __FILE__, __func__, __LINE__)
608 #define get_te_golomb(a, r) get_te(a, r, __FILE__, __func__, __LINE__)
609 #define get_te0_golomb(a, r) get_te(a, r, __FILE__, __func__, __LINE__)
610 
611 #endif /* TRACE */
612 
613 /**
614  * write unsigned exp golomb code. 2^16 - 2 at most
615  */
616 static inline void set_ue_golomb(PutBitContext *pb, int i)
617 {
618  av_assert2(i >= 0);
619  av_assert2(i <= 0xFFFE);
620 
621  if (i < 256)
622  put_bits(pb, ff_ue_golomb_len[i], i + 1);
623  else {
624  int e = av_log2(i + 1);
625  put_bits(pb, 2 * e + 1, i + 1);
626  }
627 }
628 
629 /**
630  * write unsigned exp golomb code. 2^32-2 at most.
631  */
632 static inline void set_ue_golomb_long(PutBitContext *pb, uint32_t i)
633 {
634  av_assert2(i <= (UINT32_MAX - 1));
635 
636  if (i < 256)
637  put_bits(pb, ff_ue_golomb_len[i], i + 1);
638  else {
639  int e = av_log2(i + 1);
640  put_bits64(pb, 2 * e + 1, i + 1);
641  }
642 }
643 
644 /**
645  * write truncated unsigned exp golomb code.
646  */
647 static inline void set_te_golomb(PutBitContext *pb, int i, int range)
648 {
649  av_assert2(range >= 1);
650  av_assert2(i <= range);
651 
652  if (range == 2)
653  put_bits(pb, 1, i ^ 1);
654  else
655  set_ue_golomb(pb, i);
656 }
657 
658 /**
659  * write signed exp golomb code. 16 bits at most.
660  */
661 static inline void set_se_golomb(PutBitContext *pb, int i)
662 {
663  i = 2 * i - 1;
664  if (i < 0)
665  i ^= -1; //FIXME check if gcc does the right thing
666  set_ue_golomb(pb, i);
667 }
668 
669 /**
670  * write unsigned golomb rice code (ffv1).
671  */
672 static inline void set_ur_golomb(PutBitContext *pb, int i, int k, int limit,
673  int esc_len)
674 {
675  int e;
676 
677  av_assert2(i >= 0);
678 
679  e = i >> k;
680  if (e < limit)
681  put_bits(pb, e + k + 1, (1 << k) + av_mod_uintp2(i, k));
682  else
683  put_bits(pb, limit + esc_len, i - limit + 1);
684 }
685 
686 /**
687  * write unsigned golomb rice code (jpegls).
688  */
689 static inline void set_ur_golomb_jpegls(PutBitContext *pb, int i, int k,
690  int limit, int esc_len)
691 {
692  int e;
693 
694  av_assert2(i >= 0);
695 
696  e = (i >> k) + 1;
697  if (e < limit) {
698  while (e > 31) {
699  put_bits(pb, 31, 0);
700  e -= 31;
701  }
702  put_bits(pb, e, 1);
703  if (k)
704  put_sbits(pb, k, i);
705  } else {
706  while (limit > 31) {
707  put_bits(pb, 31, 0);
708  limit -= 31;
709  }
710  put_bits(pb, limit, 1);
711  put_bits(pb, esc_len, i - 1);
712  }
713 }
714 
715 /**
716  * write signed golomb rice code (ffv1).
717  */
718 static inline void set_sr_golomb(PutBitContext *pb, int i, int k, int limit,
719  int esc_len)
720 {
721  int v;
722 
723  v = -2 * i - 1;
724  v ^= (v >> 31);
725 
726  set_ur_golomb(pb, v, k, limit, esc_len);
727 }
728 
729 /**
730  * write signed golomb rice code (flac).
731  */
732 static inline void set_sr_golomb_flac(PutBitContext *pb, int i, int k,
733  int limit, int esc_len)
734 {
735  int v;
736 
737  v = -2 * i - 1;
738  v ^= (v >> 31);
739 
740  set_ur_golomb_jpegls(pb, v, k, limit, esc_len);
741 }
742 
743 #endif /* AVCODEC_GOLOMB_H */
static unsigned int show_bits_long(GetBitContext *s, int n)
Show 0-32 bits.
Definition: get_bits.h:587
static int get_sr_golomb_flac(GetBitContext *gb, int k, int limit, int esc_len)
read signed golomb rice code (flac).
Definition: golomb.h:535
static void set_ur_golomb(PutBitContext *pb, int i, int k, int limit, int esc_len)
write unsigned golomb rice code (ffv1).
Definition: golomb.h:672
#define NULL
Definition: coverity.c:32
#define BITS_AVAILABLE(name, gb)
Definition: get_bits.h:140
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
static int get_se_golomb(GetBitContext *gb)
read signed exp golomb code.
Definition: golomb.h:239
const uint8_t ff_ue_golomb_vlc_code[512]
Definition: golomb.c:50
float re
Definition: fft.c:82
static void put_sbits(PutBitContext *pb, int n, int32_t value)
Definition: put_bits.h:240
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:208
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
Definition: get_bits.h:293
static void set_ue_golomb(PutBitContext *pb, int i)
write unsigned exp golomb code.
Definition: golomb.h:616
const int8_t ff_interleaved_se_golomb_vlc_code[256]
Definition: golomb.c:138
const uint8_t ff_interleaved_golomb_vlc_len[256]
Definition: golomb.c:100
#define INVALID_VLC
Definition: golomb.h:38
static int get_te0_golomb(GetBitContext *gb, int range)
read unsigned truncated exp golomb code.
Definition: golomb.h:211
static int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, int esc_len)
read unsigned golomb rice code (jpegls).
Definition: golomb.h:428
#define SUINT
const uint8_t ff_interleaved_dirac_golomb_vlc_code[256]
Definition: golomb.c:157
uint8_t
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Definition: avassert.h:64
static void set_te_golomb(PutBitContext *pb, int i, int range)
write truncated unsigned exp golomb code.
Definition: golomb.h:647
static int dirac_get_se_golomb(GetBitContext *gb)
Definition: golomb.h:359
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:219
bitstream reader API header.
const uint8_t ff_golomb_vlc_len[512]
Definition: golomb.c:31
static int get_ur_golomb(GetBitContext *gb, int k, int limit, int esc_len)
read unsigned golomb rice code (ffv1).
Definition: golomb.h:374
#define av_log(a,...)
#define U(x)
Definition: vp56_arith.h:37
static void put_bits64(PutBitContext *s, int n, uint64_t value)
Write up to 64 bits into a bitstream.
Definition: put_bits.h:288
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:814
#define UPDATE_CACHE(name, gb)
Definition: get_bits.h:178
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:258
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
static int get_ue_golomb(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to 8190.
Definition: golomb.h:55
const char * r
Definition: vf_curves.c:114
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
Definition: graph2dot.c:48
static int get_interleaved_se_golomb(GetBitContext *gb)
Definition: golomb.h:301
const int8_t ff_se_golomb_vlc_code[512]
Definition: golomb.c:69
#define CLOSE_READER(name, gb)
Definition: get_bits.h:149
#define SKIP_BITS(name, gb, num)
Definition: get_bits.h:193
#define FFMIN(a, b)
Definition: common.h:96
int size_in_bits
Definition: get_bits.h:68
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
Definition: get_bits.h:443
#define s(width, name)
Definition: cbs_vp9.c:257
#define LAST_SKIP_BITS(name, gb, num)
Definition: get_bits.h:199
static void set_ur_golomb_jpegls(PutBitContext *pb, int i, int k, int limit, int esc_len)
write unsigned golomb rice code (jpegls).
Definition: golomb.h:689
#define SHOW_UBITS(name, gb, num)
Definition: get_bits.h:211
#define av_log2
Definition: intmath.h:83
static void set_sr_golomb_flac(PutBitContext *pb, int i, int k, int limit, int esc_len)
write signed golomb rice code (flac).
Definition: golomb.h:732
static unsigned get_ue_golomb_long(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
Definition: golomb.h:105
static int get_se_golomb_long(GetBitContext *gb)
Definition: golomb.h:294
static void set_se_golomb(PutBitContext *pb, int i)
write signed exp golomb code.
Definition: golomb.h:661
static int get_ue_golomb_31(GetBitContext *gb)
read unsigned exp golomb code, constraint to a max of 31.
Definition: golomb.h:120
static void set_ue_golomb_long(PutBitContext *pb, uint32_t i)
write unsigned exp golomb code.
Definition: golomb.h:632
#define OPEN_READER(name, gb)
Definition: get_bits.h:138
void * buf
Definition: avisynth_c.h:690
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:487
const uint8_t ff_interleaved_ue_golomb_vlc_code[256]
Definition: golomb.c:119
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition: jacosubdec.c:67
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:460
static void set_sr_golomb(PutBitContext *pb, int i, int k, int limit, int esc_len)
write signed golomb rice code (ffv1).
Definition: golomb.h:718
#define GET_CACHE(name, gb)
Definition: get_bits.h:215
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition: get_bits.h:531
#define MIN_CACHE_BITS
Definition: get_bits.h:128
static int get_te_golomb(GetBitContext *gb, int range)
read unsigned truncated exp golomb code.
Definition: golomb.h:226
const uint8_t ff_ue_golomb_len[256]
Definition: golomb.c:89
int len
static unsigned get_interleaved_ue_golomb(GetBitContext *gb)
Definition: golomb.h:143
static unsigned int get_ur_golomb_shorten(GetBitContext *gb, int k)
read unsigned golomb rice code (shorten).
Definition: golomb.h:545
static int get_sr_golomb(GetBitContext *gb, int k, int limit, int esc_len)
read signed golomb rice code (ffv1).
Definition: golomb.h:525
static int get_sr_golomb_shorten(GetBitContext *gb, int k)
read signed golomb rice code (shorten).
Definition: golomb.h:553
bitstream writer API