You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

691 lines
21KB

  1. /*
  2. * copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. /**
  21. * @file
  22. * bitstream reader API header.
  23. */
  24. #ifndef AVCODEC_GET_BITS_H
  25. #define AVCODEC_GET_BITS_H
  26. #include <stdint.h>
  27. #include "libavutil/common.h"
  28. #include "libavutil/intreadwrite.h"
  29. #include "libavutil/log.h"
  30. #include "libavutil/avassert.h"
  31. #include "mathops.h"
  32. /*
  33. * Safe bitstream reading:
  34. * optionally, the get_bits API can check to ensure that we
  35. * don't read past input buffer boundaries. This is protected
  36. * with CONFIG_SAFE_BITSTREAM_READER at the global level, and
  37. * then below that with UNCHECKED_BITSTREAM_READER at the per-
  38. * decoder level. This means that decoders that check internally
  39. * can "#define UNCHECKED_BITSTREAM_READER 1" to disable
  40. * overread checks.
  41. * Boundary checking causes a minor performance penalty so for
  42. * applications that won't want/need this, it can be disabled
  43. * globally using "#define CONFIG_SAFE_BITSTREAM_READER 0".
  44. */
  45. #ifndef UNCHECKED_BITSTREAM_READER
  46. #define UNCHECKED_BITSTREAM_READER !CONFIG_SAFE_BITSTREAM_READER
  47. #endif
  48. typedef struct GetBitContext {
  49. const uint8_t *buffer, *buffer_end;
  50. int index;
  51. int size_in_bits;
  52. int size_in_bits_plus8;
  53. } GetBitContext;
  54. #define VLC_TYPE int16_t
  55. typedef struct VLC {
  56. int bits;
  57. VLC_TYPE (*table)[2]; ///< code, bits
  58. int table_size, table_allocated;
  59. } VLC;
  60. typedef struct RL_VLC_ELEM {
  61. int16_t level;
  62. int8_t len;
  63. uint8_t run;
  64. } RL_VLC_ELEM;
  65. /* Bitstream reader API docs:
  66. * name
  67. * arbitrary name which is used as prefix for the internal variables
  68. *
  69. * gb
  70. * getbitcontext
  71. *
  72. * OPEN_READER(name, gb)
  73. * load gb into local variables
  74. *
  75. * CLOSE_READER(name, gb)
  76. * store local vars in gb
  77. *
  78. * UPDATE_CACHE(name, gb)
  79. * Refill the internal cache from the bitstream.
  80. * After this call at least MIN_CACHE_BITS will be available.
  81. *
  82. * GET_CACHE(name, gb)
  83. * Will output the contents of the internal cache,
  84. * next bit is MSB of 32 or 64 bit (FIXME 64bit).
  85. *
  86. * SHOW_UBITS(name, gb, num)
  87. * Will return the next num bits.
  88. *
  89. * SHOW_SBITS(name, gb, num)
  90. * Will return the next num bits and do sign extension.
  91. *
  92. * SKIP_BITS(name, gb, num)
  93. * Will skip over the next num bits.
  94. * Note, this is equivalent to SKIP_CACHE; SKIP_COUNTER.
  95. *
  96. * SKIP_CACHE(name, gb, num)
  97. * Will remove the next num bits from the cache (note SKIP_COUNTER
  98. * MUST be called before UPDATE_CACHE / CLOSE_READER).
  99. *
  100. * SKIP_COUNTER(name, gb, num)
  101. * Will increment the internal bit counter (see SKIP_CACHE & SKIP_BITS).
  102. *
  103. * LAST_SKIP_BITS(name, gb, num)
  104. * Like SKIP_BITS, to be used if next call is UPDATE_CACHE or CLOSE_READER.
  105. *
  106. * For examples see get_bits, show_bits, skip_bits, get_vlc.
  107. */
  108. #ifdef LONG_BITSTREAM_READER
  109. # define MIN_CACHE_BITS 32
  110. #else
  111. # define MIN_CACHE_BITS 25
  112. #endif
  113. #if UNCHECKED_BITSTREAM_READER
  114. #define OPEN_READER(name, gb) \
  115. unsigned int name ## _index = (gb)->index; \
  116. unsigned int av_unused name ## _cache
  117. #define HAVE_BITS_REMAINING(name, gb) 1
  118. #else
  119. #define OPEN_READER(name, gb) \
  120. unsigned int name ## _index = (gb)->index; \
  121. unsigned int av_unused name ## _cache = 0; \
  122. unsigned int av_unused name ## _size_plus8 = (gb)->size_in_bits_plus8
  123. #define HAVE_BITS_REMAINING(name, gb) name ## _index < name ## _size_plus8
  124. #endif
  125. #define CLOSE_READER(name, gb) (gb)->index = name ## _index
  126. # ifdef LONG_BITSTREAM_READER
  127. # define UPDATE_CACHE_LE(name, gb) name ## _cache = \
  128. AV_RL64((gb)->buffer + (name ## _index >> 3)) >> (name ## _index & 7)
  129. # define UPDATE_CACHE_BE(name, gb) name ## _cache = \
  130. AV_RB64((gb)->buffer + (name ## _index >> 3)) >> (32 - (name ## _index & 7))
  131. #else
  132. # define UPDATE_CACHE_LE(name, gb) name ## _cache = \
  133. AV_RL32((gb)->buffer + (name ## _index >> 3)) >> (name ## _index & 7)
  134. # define UPDATE_CACHE_BE(name, gb) name ## _cache = \
  135. AV_RB32((gb)->buffer + (name ## _index >> 3)) << (name ## _index & 7)
  136. #endif
  137. #ifdef BITSTREAM_READER_LE
  138. # define UPDATE_CACHE(name, gb) UPDATE_CACHE_LE(name, gb)
  139. # define SKIP_CACHE(name, gb, num) name ## _cache >>= (num)
  140. #else
  141. # define UPDATE_CACHE(name, gb) UPDATE_CACHE_BE(name, gb)
  142. # define SKIP_CACHE(name, gb, num) name ## _cache <<= (num)
  143. #endif
  144. #if UNCHECKED_BITSTREAM_READER
  145. # define SKIP_COUNTER(name, gb, num) name ## _index += (num)
  146. #else
  147. # define SKIP_COUNTER(name, gb, num) \
  148. name ## _index = FFMIN(name ## _size_plus8, name ## _index + (num))
  149. #endif
  150. #define SKIP_BITS(name, gb, num) \
  151. do { \
  152. SKIP_CACHE(name, gb, num); \
  153. SKIP_COUNTER(name, gb, num); \
  154. } while (0)
  155. #define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num)
  156. #define SHOW_UBITS_LE(name, gb, num) zero_extend(name ## _cache, num)
  157. #define SHOW_SBITS_LE(name, gb, num) sign_extend(name ## _cache, num)
  158. #define SHOW_UBITS_BE(name, gb, num) NEG_USR32(name ## _cache, num)
  159. #define SHOW_SBITS_BE(name, gb, num) NEG_SSR32(name ## _cache, num)
  160. #ifdef BITSTREAM_READER_LE
  161. # define SHOW_UBITS(name, gb, num) SHOW_UBITS_LE(name, gb, num)
  162. # define SHOW_SBITS(name, gb, num) SHOW_SBITS_LE(name, gb, num)
  163. #else
  164. # define SHOW_UBITS(name, gb, num) SHOW_UBITS_BE(name, gb, num)
  165. # define SHOW_SBITS(name, gb, num) SHOW_SBITS_BE(name, gb, num)
  166. #endif
  167. #define GET_CACHE(name, gb) ((uint32_t) name ## _cache)
  168. static inline int get_bits_count(const GetBitContext *s)
  169. {
  170. return s->index;
  171. }
  172. static inline void skip_bits_long(GetBitContext *s, int n)
  173. {
  174. #if UNCHECKED_BITSTREAM_READER
  175. s->index += n;
  176. #else
  177. s->index += av_clip(n, -s->index, s->size_in_bits_plus8 - s->index);
  178. #endif
  179. }
  180. /**
  181. * read mpeg1 dc style vlc (sign bit + mantissa with no MSB).
  182. * if MSB not set it is negative
  183. * @param n length in bits
  184. */
  185. static inline int get_xbits(GetBitContext *s, int n)
  186. {
  187. register int sign;
  188. register int32_t cache;
  189. OPEN_READER(re, s);
  190. av_assert2(n>0 && n<=25);
  191. UPDATE_CACHE(re, s);
  192. cache = GET_CACHE(re, s);
  193. sign = ~cache >> 31;
  194. LAST_SKIP_BITS(re, s, n);
  195. CLOSE_READER(re, s);
  196. return (NEG_USR32(sign ^ cache, n) ^ sign) - sign;
  197. }
  198. static inline int get_sbits(GetBitContext *s, int n)
  199. {
  200. register int tmp;
  201. OPEN_READER(re, s);
  202. av_assert2(n>0 && n<=25);
  203. UPDATE_CACHE(re, s);
  204. tmp = SHOW_SBITS(re, s, n);
  205. LAST_SKIP_BITS(re, s, n);
  206. CLOSE_READER(re, s);
  207. return tmp;
  208. }
  209. /**
  210. * Read 1-25 bits.
  211. */
  212. static inline unsigned int get_bits(GetBitContext *s, int n)
  213. {
  214. register int tmp;
  215. OPEN_READER(re, s);
  216. av_assert2(n>0 && n<=25);
  217. UPDATE_CACHE(re, s);
  218. tmp = SHOW_UBITS(re, s, n);
  219. LAST_SKIP_BITS(re, s, n);
  220. CLOSE_READER(re, s);
  221. return tmp;
  222. }
  223. static inline unsigned int get_bits_le(GetBitContext *s, int n)
  224. {
  225. register int tmp;
  226. OPEN_READER(re, s);
  227. av_assert2(n>0 && n<=25);
  228. UPDATE_CACHE_LE(re, s);
  229. tmp = SHOW_UBITS_LE(re, s, n);
  230. LAST_SKIP_BITS(re, s, n);
  231. CLOSE_READER(re, s);
  232. return tmp;
  233. }
  234. /**
  235. * Show 1-25 bits.
  236. */
  237. static inline unsigned int show_bits(GetBitContext *s, int n)
  238. {
  239. register int tmp;
  240. OPEN_READER(re, s);
  241. av_assert2(n>0 && n<=25);
  242. UPDATE_CACHE(re, s);
  243. tmp = SHOW_UBITS(re, s, n);
  244. return tmp;
  245. }
  246. static inline void skip_bits(GetBitContext *s, int n)
  247. {
  248. OPEN_READER(re, s);
  249. LAST_SKIP_BITS(re, s, n);
  250. CLOSE_READER(re, s);
  251. }
  252. static inline unsigned int get_bits1(GetBitContext *s)
  253. {
  254. unsigned int index = s->index;
  255. uint8_t result = s->buffer[index >> 3];
  256. #ifdef BITSTREAM_READER_LE
  257. result >>= index & 7;
  258. result &= 1;
  259. #else
  260. result <<= index & 7;
  261. result >>= 8 - 1;
  262. #endif
  263. #if !UNCHECKED_BITSTREAM_READER
  264. if (s->index < s->size_in_bits_plus8)
  265. #endif
  266. index++;
  267. s->index = index;
  268. return result;
  269. }
  270. static inline unsigned int show_bits1(GetBitContext *s)
  271. {
  272. return show_bits(s, 1);
  273. }
  274. static inline void skip_bits1(GetBitContext *s)
  275. {
  276. skip_bits(s, 1);
  277. }
  278. /**
  279. * Read 0-32 bits.
  280. */
  281. static inline unsigned int get_bits_long(GetBitContext *s, int n)
  282. {
  283. if (!n) {
  284. return 0;
  285. } else if (n <= MIN_CACHE_BITS) {
  286. return get_bits(s, n);
  287. } else {
  288. #ifdef BITSTREAM_READER_LE
  289. unsigned ret = get_bits(s, 16);
  290. return ret | (get_bits(s, n - 16) << 16);
  291. #else
  292. unsigned ret = get_bits(s, 16) << (n - 16);
  293. return ret | get_bits(s, n - 16);
  294. #endif
  295. }
  296. }
  297. /**
  298. * Read 0-64 bits.
  299. */
  300. static inline uint64_t get_bits64(GetBitContext *s, int n)
  301. {
  302. if (n <= 32) {
  303. return get_bits_long(s, n);
  304. } else {
  305. #ifdef BITSTREAM_READER_LE
  306. uint64_t ret = get_bits_long(s, 32);
  307. return ret | (uint64_t) get_bits_long(s, n - 32) << 32;
  308. #else
  309. uint64_t ret = (uint64_t) get_bits_long(s, n - 32) << 32;
  310. return ret | get_bits_long(s, 32);
  311. #endif
  312. }
  313. }
  314. /**
  315. * Read 0-32 bits as a signed integer.
  316. */
  317. static inline int get_sbits_long(GetBitContext *s, int n)
  318. {
  319. return sign_extend(get_bits_long(s, n), n);
  320. }
  321. /**
  322. * Show 0-32 bits.
  323. */
  324. static inline unsigned int show_bits_long(GetBitContext *s, int n)
  325. {
  326. if (n <= MIN_CACHE_BITS) {
  327. return show_bits(s, n);
  328. } else {
  329. GetBitContext gb = *s;
  330. return get_bits_long(&gb, n);
  331. }
  332. }
  333. static inline int check_marker(GetBitContext *s, const char *msg)
  334. {
  335. int bit = get_bits1(s);
  336. if (!bit)
  337. av_log(NULL, AV_LOG_INFO, "Marker bit missing %s\n", msg);
  338. return bit;
  339. }
  340. /**
  341. * Initialize GetBitContext.
  342. * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes
  343. * larger than the actual read bits because some optimized bitstream
  344. * readers read 32 or 64 bit at once and could read over the end
  345. * @param bit_size the size of the buffer in bits
  346. * @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow.
  347. */
  348. static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,
  349. int bit_size)
  350. {
  351. int buffer_size;
  352. int ret = 0;
  353. if (bit_size >= INT_MAX - 7 || bit_size < 0 || !buffer) {
  354. bit_size = 0;
  355. buffer = NULL;
  356. ret = AVERROR_INVALIDDATA;
  357. }
  358. buffer_size = (bit_size + 7) >> 3;
  359. s->buffer = buffer;
  360. s->size_in_bits = bit_size;
  361. s->size_in_bits_plus8 = bit_size + 8;
  362. s->buffer_end = buffer + buffer_size;
  363. s->index = 0;
  364. return ret;
  365. }
  366. /**
  367. * Initialize GetBitContext.
  368. * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes
  369. * larger than the actual read bits because some optimized bitstream
  370. * readers read 32 or 64 bit at once and could read over the end
  371. * @param byte_size the size of the buffer in bytes
  372. * @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow.
  373. */
  374. static inline int init_get_bits8(GetBitContext *s, const uint8_t *buffer,
  375. int byte_size)
  376. {
  377. if (byte_size > INT_MAX / 8 || byte_size < 0)
  378. byte_size = -1;
  379. return init_get_bits(s, buffer, byte_size * 8);
  380. }
  381. static inline const uint8_t *align_get_bits(GetBitContext *s)
  382. {
  383. int n = -get_bits_count(s) & 7;
  384. if (n)
  385. skip_bits(s, n);
  386. return s->buffer + (s->index >> 3);
  387. }
  388. #define init_vlc(vlc, nb_bits, nb_codes, \
  389. bits, bits_wrap, bits_size, \
  390. codes, codes_wrap, codes_size, \
  391. flags) \
  392. ff_init_vlc_sparse(vlc, nb_bits, nb_codes, \
  393. bits, bits_wrap, bits_size, \
  394. codes, codes_wrap, codes_size, \
  395. NULL, 0, 0, flags)
  396. int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
  397. const void *bits, int bits_wrap, int bits_size,
  398. const void *codes, int codes_wrap, int codes_size,
  399. const void *symbols, int symbols_wrap, int symbols_size,
  400. int flags);
  401. void ff_free_vlc(VLC *vlc);
  402. #define INIT_VLC_LE 2
  403. #define INIT_VLC_USE_NEW_STATIC 4
  404. #define INIT_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size) \
  405. do { \
  406. static VLC_TYPE table[static_size][2]; \
  407. (vlc)->table = table; \
  408. (vlc)->table_allocated = static_size; \
  409. init_vlc(vlc, bits, a, b, c, d, e, f, g, INIT_VLC_USE_NEW_STATIC); \
  410. } while (0)
  411. /**
  412. * If the vlc code is invalid and max_depth=1, then no bits will be removed.
  413. * If the vlc code is invalid and max_depth>1, then the number of bits removed
  414. * is undefined.
  415. */
  416. #define GET_VLC(code, name, gb, table, bits, max_depth) \
  417. do { \
  418. int n, nb_bits; \
  419. unsigned int index; \
  420. \
  421. index = SHOW_UBITS(name, gb, bits); \
  422. code = table[index][0]; \
  423. n = table[index][1]; \
  424. \
  425. if (max_depth > 1 && n < 0) { \
  426. LAST_SKIP_BITS(name, gb, bits); \
  427. UPDATE_CACHE(name, gb); \
  428. \
  429. nb_bits = -n; \
  430. \
  431. index = SHOW_UBITS(name, gb, nb_bits) + code; \
  432. code = table[index][0]; \
  433. n = table[index][1]; \
  434. if (max_depth > 2 && n < 0) { \
  435. LAST_SKIP_BITS(name, gb, nb_bits); \
  436. UPDATE_CACHE(name, gb); \
  437. \
  438. nb_bits = -n; \
  439. \
  440. index = SHOW_UBITS(name, gb, nb_bits) + code; \
  441. code = table[index][0]; \
  442. n = table[index][1]; \
  443. } \
  444. } \
  445. SKIP_BITS(name, gb, n); \
  446. } while (0)
  447. #define GET_RL_VLC_INTERNAL(level, run, name, gb, table, bits, \
  448. max_depth, need_update) \
  449. do { \
  450. int n, nb_bits; \
  451. unsigned int index; \
  452. \
  453. index = SHOW_UBITS(name, gb, bits); \
  454. level = table[index].level; \
  455. n = table[index].len; \
  456. \
  457. if (max_depth > 1 && n < 0) { \
  458. SKIP_BITS(name, gb, bits); \
  459. if (need_update) { \
  460. UPDATE_CACHE(name, gb); \
  461. } \
  462. \
  463. nb_bits = -n; \
  464. \
  465. index = SHOW_UBITS(name, gb, nb_bits) + level; \
  466. level = table[index].level; \
  467. n = table[index].len; \
  468. } \
  469. run = table[index].run; \
  470. SKIP_BITS(name, gb, n); \
  471. } while (0)
  472. /**
  473. * Parse a vlc code.
  474. * @param bits is the number of bits which will be read at once, must be
  475. * identical to nb_bits in init_vlc()
  476. * @param max_depth is the number of times bits bits must be read to completely
  477. * read the longest vlc code
  478. * = (max_vlc_length + bits - 1) / bits
  479. */
  480. static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2],
  481. int bits, int max_depth)
  482. {
  483. int code;
  484. OPEN_READER(re, s);
  485. UPDATE_CACHE(re, s);
  486. GET_VLC(code, re, s, table, bits, max_depth);
  487. CLOSE_READER(re, s);
  488. return code;
  489. }
  490. static inline int decode012(GetBitContext *gb)
  491. {
  492. int n;
  493. n = get_bits1(gb);
  494. if (n == 0)
  495. return 0;
  496. else
  497. return get_bits1(gb) + 1;
  498. }
  499. static inline int decode210(GetBitContext *gb)
  500. {
  501. if (get_bits1(gb))
  502. return 0;
  503. else
  504. return 2 - get_bits1(gb);
  505. }
  506. static inline int get_bits_left(GetBitContext *gb)
  507. {
  508. return gb->size_in_bits - get_bits_count(gb);
  509. }
  510. static inline int skip_1stop_8data_bits(GetBitContext *gb)
  511. {
  512. if (get_bits_left(gb) <= 0)
  513. return AVERROR_INVALIDDATA;
  514. while (get_bits1(gb)) {
  515. skip_bits(gb, 8);
  516. if (get_bits_left(gb) <= 0)
  517. return AVERROR_INVALIDDATA;
  518. }
  519. return 0;
  520. }
  521. //#define TRACE
  522. #ifdef TRACE
  523. static inline void print_bin(int bits, int n)
  524. {
  525. int i;
  526. for (i = n - 1; i >= 0; i--)
  527. av_log(NULL, AV_LOG_DEBUG, "%d", (bits >> i) & 1);
  528. for (i = n; i < 24; i++)
  529. av_log(NULL, AV_LOG_DEBUG, " ");
  530. }
  531. static inline int get_bits_trace(GetBitContext *s, int n, const char *file,
  532. const char *func, int line)
  533. {
  534. int r = get_bits(s, n);
  535. print_bin(r, n);
  536. av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d bit @%5d in %s %s:%d\n",
  537. r, n, r, get_bits_count(s) - n, file, func, line);
  538. return r;
  539. }
  540. static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2],
  541. int bits, int max_depth, const char *file,
  542. const char *func, int line)
  543. {
  544. int show = show_bits(s, 24);
  545. int pos = get_bits_count(s);
  546. int r = get_vlc2(s, table, bits, max_depth);
  547. int len = get_bits_count(s) - pos;
  548. int bits2 = show >> (24 - len);
  549. print_bin(bits2, len);
  550. av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d vlc @%5d in %s %s:%d\n",
  551. bits2, len, r, pos, file, func, line);
  552. return r;
  553. }
  554. #define GET_RL_VLC(level, run, name, gb, table, bits, \
  555. max_depth, need_update) \
  556. do { \
  557. int show = SHOW_UBITS(name, gb, 24); \
  558. int len; \
  559. int pos = name ## _index; \
  560. \
  561. GET_RL_VLC_INTERNAL(level, run, name, gb, table, bits,max_depth, need_update); \
  562. \
  563. len = name ## _index - pos + 1; \
  564. show = show >> (24 - len); \
  565. \
  566. print_bin(show, len); \
  567. \
  568. av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d/%-3d rlv @%5d in %s %s:%d\n",\
  569. show, len, run-1, level, pos, __FILE__, __PRETTY_FUNCTION__, __LINE__);\
  570. } while (0) \
  571. static inline int get_xbits_trace(GetBitContext *s, int n, const char *file,
  572. const char *func, int line)
  573. {
  574. int show = show_bits(s, n);
  575. int r = get_xbits(s, n);
  576. print_bin(show, n);
  577. av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d xbt @%5d in %s %s:%d\n",
  578. show, n, r, get_bits_count(s) - n, file, func, line);
  579. return r;
  580. }
  581. #define get_bits(s, n) get_bits_trace(s , n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
  582. #define get_bits1(s) get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__)
  583. #define get_xbits(s, n) get_xbits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
  584. #define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__)
  585. #define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__)
  586. #define tprintf(p, ...) av_log(p, AV_LOG_DEBUG, __VA_ARGS__)
  587. #else //TRACE
  588. #define tprintf(p, ...) { }
  589. #define GET_RL_VLC GET_RL_VLC_INTERNAL
  590. #endif
  591. #endif /* AVCODEC_GET_BITS_H */