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.

693 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. * BITS_LEFT(name, gb)
  107. * Return the number of bits left
  108. *
  109. * For examples see get_bits, show_bits, skip_bits, get_vlc.
  110. */
  111. #ifdef LONG_BITSTREAM_READER
  112. # define MIN_CACHE_BITS 32
  113. #else
  114. # define MIN_CACHE_BITS 25
  115. #endif
  116. #define OPEN_READER_NOSIZE(name, gb) \
  117. unsigned int name ## _index = (gb)->index; \
  118. unsigned int av_unused name ## _cache
  119. #if UNCHECKED_BITSTREAM_READER
  120. #define OPEN_READER(name, gb) OPEN_READER_NOSIZE(name, gb)
  121. #define BITS_AVAILABLE(name, gb) 1
  122. #else
  123. #define OPEN_READER(name, gb) \
  124. OPEN_READER_NOSIZE(name, gb); \
  125. unsigned int name ## _size_plus8 = (gb)->size_in_bits_plus8
  126. #define BITS_AVAILABLE(name, gb) name ## _index < name ## _size_plus8
  127. #endif
  128. #define CLOSE_READER(name, gb) (gb)->index = name ## _index
  129. # ifdef LONG_BITSTREAM_READER
  130. # define UPDATE_CACHE_LE(name, gb) name ## _cache = \
  131. AV_RL64((gb)->buffer + (name ## _index >> 3)) >> (name ## _index & 7)
  132. # define UPDATE_CACHE_BE(name, gb) name ## _cache = \
  133. AV_RB64((gb)->buffer + (name ## _index >> 3)) >> (32 - (name ## _index & 7))
  134. #else
  135. # define UPDATE_CACHE_LE(name, gb) name ## _cache = \
  136. AV_RL32((gb)->buffer + (name ## _index >> 3)) >> (name ## _index & 7)
  137. # define UPDATE_CACHE_BE(name, gb) name ## _cache = \
  138. AV_RB32((gb)->buffer + (name ## _index >> 3)) << (name ## _index & 7)
  139. #endif
  140. #ifdef BITSTREAM_READER_LE
  141. # define UPDATE_CACHE(name, gb) UPDATE_CACHE_LE(name, gb)
  142. # define SKIP_CACHE(name, gb, num) name ## _cache >>= (num)
  143. #else
  144. # define UPDATE_CACHE(name, gb) UPDATE_CACHE_BE(name, gb)
  145. # define SKIP_CACHE(name, gb, num) name ## _cache <<= (num)
  146. #endif
  147. #if UNCHECKED_BITSTREAM_READER
  148. # define SKIP_COUNTER(name, gb, num) name ## _index += (num)
  149. #else
  150. # define SKIP_COUNTER(name, gb, num) \
  151. name ## _index = FFMIN(name ## _size_plus8, name ## _index + (num))
  152. #endif
  153. #define BITS_LEFT(name, gb) ((int)((gb)->size_in_bits - name ## _index))
  154. #define SKIP_BITS(name, gb, num) \
  155. do { \
  156. SKIP_CACHE(name, gb, num); \
  157. SKIP_COUNTER(name, gb, num); \
  158. } while (0)
  159. #define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num)
  160. #define SHOW_UBITS_LE(name, gb, num) zero_extend(name ## _cache, num)
  161. #define SHOW_SBITS_LE(name, gb, num) sign_extend(name ## _cache, num)
  162. #define SHOW_UBITS_BE(name, gb, num) NEG_USR32(name ## _cache, num)
  163. #define SHOW_SBITS_BE(name, gb, num) NEG_SSR32(name ## _cache, num)
  164. #ifdef BITSTREAM_READER_LE
  165. # define SHOW_UBITS(name, gb, num) SHOW_UBITS_LE(name, gb, num)
  166. # define SHOW_SBITS(name, gb, num) SHOW_SBITS_LE(name, gb, num)
  167. #else
  168. # define SHOW_UBITS(name, gb, num) SHOW_UBITS_BE(name, gb, num)
  169. # define SHOW_SBITS(name, gb, num) SHOW_SBITS_BE(name, gb, num)
  170. #endif
  171. #define GET_CACHE(name, gb) ((uint32_t) name ## _cache)
  172. static inline int get_bits_count(const GetBitContext *s)
  173. {
  174. return s->index;
  175. }
  176. static inline void skip_bits_long(GetBitContext *s, int n)
  177. {
  178. #if UNCHECKED_BITSTREAM_READER
  179. s->index += n;
  180. #else
  181. s->index += av_clip(n, -s->index, s->size_in_bits_plus8 - s->index);
  182. #endif
  183. }
  184. /**
  185. * read mpeg1 dc style vlc (sign bit + mantissa with no MSB).
  186. * if MSB not set it is negative
  187. * @param n length in bits
  188. */
  189. static inline int get_xbits(GetBitContext *s, int n)
  190. {
  191. register int sign;
  192. register int32_t cache;
  193. OPEN_READER(re, s);
  194. av_assert2(n>0 && n<=25);
  195. UPDATE_CACHE(re, s);
  196. cache = GET_CACHE(re, s);
  197. sign = ~cache >> 31;
  198. LAST_SKIP_BITS(re, s, n);
  199. CLOSE_READER(re, s);
  200. return (NEG_USR32(sign ^ cache, n) ^ sign) - sign;
  201. }
  202. static inline int get_sbits(GetBitContext *s, int n)
  203. {
  204. register int tmp;
  205. OPEN_READER(re, s);
  206. av_assert2(n>0 && n<=25);
  207. UPDATE_CACHE(re, s);
  208. tmp = SHOW_SBITS(re, s, n);
  209. LAST_SKIP_BITS(re, s, n);
  210. CLOSE_READER(re, s);
  211. return tmp;
  212. }
  213. /**
  214. * Read 1-25 bits.
  215. */
  216. static inline unsigned int get_bits(GetBitContext *s, int n)
  217. {
  218. register int tmp;
  219. OPEN_READER(re, s);
  220. av_assert2(n>0 && n<=25);
  221. UPDATE_CACHE(re, s);
  222. tmp = SHOW_UBITS(re, s, n);
  223. LAST_SKIP_BITS(re, s, n);
  224. CLOSE_READER(re, s);
  225. return tmp;
  226. }
  227. static inline unsigned int get_bits_le(GetBitContext *s, int n)
  228. {
  229. register int tmp;
  230. OPEN_READER(re, s);
  231. av_assert2(n>0 && n<=25);
  232. UPDATE_CACHE_LE(re, s);
  233. tmp = SHOW_UBITS_LE(re, s, n);
  234. LAST_SKIP_BITS(re, s, n);
  235. CLOSE_READER(re, s);
  236. return tmp;
  237. }
  238. /**
  239. * Show 1-25 bits.
  240. */
  241. static inline unsigned int show_bits(GetBitContext *s, int n)
  242. {
  243. register int tmp;
  244. OPEN_READER_NOSIZE(re, s);
  245. av_assert2(n>0 && n<=25);
  246. UPDATE_CACHE(re, s);
  247. tmp = SHOW_UBITS(re, s, n);
  248. return tmp;
  249. }
  250. static inline void skip_bits(GetBitContext *s, int n)
  251. {
  252. OPEN_READER(re, s);
  253. LAST_SKIP_BITS(re, s, n);
  254. CLOSE_READER(re, s);
  255. }
  256. static inline unsigned int get_bits1(GetBitContext *s)
  257. {
  258. unsigned int index = s->index;
  259. uint8_t result = s->buffer[index >> 3];
  260. #ifdef BITSTREAM_READER_LE
  261. result >>= index & 7;
  262. result &= 1;
  263. #else
  264. result <<= index & 7;
  265. result >>= 8 - 1;
  266. #endif
  267. #if !UNCHECKED_BITSTREAM_READER
  268. if (s->index < s->size_in_bits_plus8)
  269. #endif
  270. index++;
  271. s->index = index;
  272. return result;
  273. }
  274. static inline unsigned int show_bits1(GetBitContext *s)
  275. {
  276. return show_bits(s, 1);
  277. }
  278. static inline void skip_bits1(GetBitContext *s)
  279. {
  280. skip_bits(s, 1);
  281. }
  282. /**
  283. * Read 0-32 bits.
  284. */
  285. static inline unsigned int get_bits_long(GetBitContext *s, int n)
  286. {
  287. if (!n) {
  288. return 0;
  289. } else if (n <= MIN_CACHE_BITS) {
  290. return get_bits(s, n);
  291. } else {
  292. #ifdef BITSTREAM_READER_LE
  293. unsigned ret = get_bits(s, 16);
  294. return ret | (get_bits(s, n - 16) << 16);
  295. #else
  296. unsigned ret = get_bits(s, 16) << (n - 16);
  297. return ret | get_bits(s, n - 16);
  298. #endif
  299. }
  300. }
  301. /**
  302. * Read 0-64 bits.
  303. */
  304. static inline uint64_t get_bits64(GetBitContext *s, int n)
  305. {
  306. if (n <= 32) {
  307. return get_bits_long(s, n);
  308. } else {
  309. #ifdef BITSTREAM_READER_LE
  310. uint64_t ret = get_bits_long(s, 32);
  311. return ret | (uint64_t) get_bits_long(s, n - 32) << 32;
  312. #else
  313. uint64_t ret = (uint64_t) get_bits_long(s, n - 32) << 32;
  314. return ret | get_bits_long(s, 32);
  315. #endif
  316. }
  317. }
  318. /**
  319. * Read 0-32 bits as a signed integer.
  320. */
  321. static inline int get_sbits_long(GetBitContext *s, int n)
  322. {
  323. return sign_extend(get_bits_long(s, n), n);
  324. }
  325. /**
  326. * Show 0-32 bits.
  327. */
  328. static inline unsigned int show_bits_long(GetBitContext *s, int n)
  329. {
  330. if (n <= MIN_CACHE_BITS) {
  331. return show_bits(s, n);
  332. } else {
  333. GetBitContext gb = *s;
  334. return get_bits_long(&gb, n);
  335. }
  336. }
  337. static inline int check_marker(GetBitContext *s, const char *msg)
  338. {
  339. int bit = get_bits1(s);
  340. if (!bit)
  341. av_log(NULL, AV_LOG_INFO, "Marker bit missing at %d of %d %s\n", get_bits_count(s) - 1, s->size_in_bits, msg);
  342. return bit;
  343. }
  344. /**
  345. * Initialize GetBitContext.
  346. * @param buffer bitstream buffer, must be AV_INPUT_BUFFER_PADDING_SIZE bytes
  347. * larger than the actual read bits because some optimized bitstream
  348. * readers read 32 or 64 bit at once and could read over the end
  349. * @param bit_size the size of the buffer in bits
  350. * @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow.
  351. */
  352. static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,
  353. int bit_size)
  354. {
  355. int buffer_size;
  356. int ret = 0;
  357. if (bit_size >= INT_MAX - 7 || bit_size < 0 || !buffer) {
  358. bit_size = 0;
  359. buffer = NULL;
  360. ret = AVERROR_INVALIDDATA;
  361. }
  362. buffer_size = (bit_size + 7) >> 3;
  363. s->buffer = buffer;
  364. s->size_in_bits = bit_size;
  365. s->size_in_bits_plus8 = bit_size + 8;
  366. s->buffer_end = buffer + buffer_size;
  367. s->index = 0;
  368. return ret;
  369. }
  370. /**
  371. * Initialize GetBitContext.
  372. * @param buffer bitstream buffer, must be AV_INPUT_BUFFER_PADDING_SIZE bytes
  373. * larger than the actual read bits because some optimized bitstream
  374. * readers read 32 or 64 bit at once and could read over the end
  375. * @param byte_size the size of the buffer in bytes
  376. * @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow.
  377. */
  378. static inline int init_get_bits8(GetBitContext *s, const uint8_t *buffer,
  379. int byte_size)
  380. {
  381. if (byte_size > INT_MAX / 8 || byte_size < 0)
  382. byte_size = -1;
  383. return init_get_bits(s, buffer, byte_size * 8);
  384. }
  385. static inline const uint8_t *align_get_bits(GetBitContext *s)
  386. {
  387. int n = -get_bits_count(s) & 7;
  388. if (n)
  389. skip_bits(s, n);
  390. return s->buffer + (s->index >> 3);
  391. }
  392. #define init_vlc(vlc, nb_bits, nb_codes, \
  393. bits, bits_wrap, bits_size, \
  394. codes, codes_wrap, codes_size, \
  395. flags) \
  396. ff_init_vlc_sparse(vlc, nb_bits, nb_codes, \
  397. bits, bits_wrap, bits_size, \
  398. codes, codes_wrap, codes_size, \
  399. NULL, 0, 0, flags)
  400. int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
  401. const void *bits, int bits_wrap, int bits_size,
  402. const void *codes, int codes_wrap, int codes_size,
  403. const void *symbols, int symbols_wrap, int symbols_size,
  404. int flags);
  405. void ff_free_vlc(VLC *vlc);
  406. #define INIT_VLC_LE 2
  407. #define INIT_VLC_USE_NEW_STATIC 4
  408. #define INIT_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size) \
  409. do { \
  410. static VLC_TYPE table[static_size][2]; \
  411. (vlc)->table = table; \
  412. (vlc)->table_allocated = static_size; \
  413. init_vlc(vlc, bits, a, b, c, d, e, f, g, INIT_VLC_USE_NEW_STATIC); \
  414. } while (0)
  415. /**
  416. * If the vlc code is invalid and max_depth=1, then no bits will be removed.
  417. * If the vlc code is invalid and max_depth>1, then the number of bits removed
  418. * is undefined.
  419. */
  420. #define GET_VLC(code, name, gb, table, bits, max_depth) \
  421. do { \
  422. int n, nb_bits; \
  423. unsigned int index; \
  424. \
  425. index = SHOW_UBITS(name, gb, bits); \
  426. code = table[index][0]; \
  427. n = table[index][1]; \
  428. \
  429. if (max_depth > 1 && n < 0) { \
  430. LAST_SKIP_BITS(name, gb, bits); \
  431. UPDATE_CACHE(name, gb); \
  432. \
  433. nb_bits = -n; \
  434. \
  435. index = SHOW_UBITS(name, gb, nb_bits) + code; \
  436. code = table[index][0]; \
  437. n = table[index][1]; \
  438. if (max_depth > 2 && n < 0) { \
  439. LAST_SKIP_BITS(name, gb, nb_bits); \
  440. UPDATE_CACHE(name, gb); \
  441. \
  442. nb_bits = -n; \
  443. \
  444. index = SHOW_UBITS(name, gb, nb_bits) + code; \
  445. code = table[index][0]; \
  446. n = table[index][1]; \
  447. } \
  448. } \
  449. SKIP_BITS(name, gb, n); \
  450. } while (0)
  451. #define GET_RL_VLC_INTERNAL(level, run, name, gb, table, bits, \
  452. max_depth, need_update) \
  453. do { \
  454. int n, nb_bits; \
  455. unsigned int index; \
  456. \
  457. index = SHOW_UBITS(name, gb, bits); \
  458. level = table[index].level; \
  459. n = table[index].len; \
  460. \
  461. if (max_depth > 1 && n < 0) { \
  462. SKIP_BITS(name, gb, bits); \
  463. if (need_update) { \
  464. UPDATE_CACHE(name, gb); \
  465. } \
  466. \
  467. nb_bits = -n; \
  468. \
  469. index = SHOW_UBITS(name, gb, nb_bits) + level; \
  470. level = table[index].level; \
  471. n = table[index].len; \
  472. } \
  473. run = table[index].run; \
  474. SKIP_BITS(name, gb, n); \
  475. } while (0)
  476. /**
  477. * Parse a vlc code.
  478. * @param bits is the number of bits which will be read at once, must be
  479. * identical to nb_bits in init_vlc()
  480. * @param max_depth is the number of times bits bits must be read to completely
  481. * read the longest vlc code
  482. * = (max_vlc_length + bits - 1) / bits
  483. */
  484. static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2],
  485. int bits, int max_depth)
  486. {
  487. int code;
  488. OPEN_READER(re, s);
  489. UPDATE_CACHE(re, s);
  490. GET_VLC(code, re, s, table, bits, max_depth);
  491. CLOSE_READER(re, s);
  492. return code;
  493. }
  494. static inline int decode012(GetBitContext *gb)
  495. {
  496. int n;
  497. n = get_bits1(gb);
  498. if (n == 0)
  499. return 0;
  500. else
  501. return get_bits1(gb) + 1;
  502. }
  503. static inline int decode210(GetBitContext *gb)
  504. {
  505. if (get_bits1(gb))
  506. return 0;
  507. else
  508. return 2 - get_bits1(gb);
  509. }
  510. static inline int get_bits_left(GetBitContext *gb)
  511. {
  512. return gb->size_in_bits - get_bits_count(gb);
  513. }
  514. static inline int skip_1stop_8data_bits(GetBitContext *gb)
  515. {
  516. if (get_bits_left(gb) <= 0)
  517. return AVERROR_INVALIDDATA;
  518. while (get_bits1(gb)) {
  519. skip_bits(gb, 8);
  520. if (get_bits_left(gb) <= 0)
  521. return AVERROR_INVALIDDATA;
  522. }
  523. return 0;
  524. }
  525. //#define TRACE
  526. #ifdef TRACE
  527. static inline void print_bin(int bits, int n)
  528. {
  529. int i;
  530. for (i = n - 1; i >= 0; i--)
  531. av_log(NULL, AV_LOG_DEBUG, "%d", (bits >> i) & 1);
  532. for (i = n; i < 24; i++)
  533. av_log(NULL, AV_LOG_DEBUG, " ");
  534. }
  535. static inline int get_bits_trace(GetBitContext *s, int n, const char *file,
  536. const char *func, int line)
  537. {
  538. int r = get_bits(s, n);
  539. print_bin(r, n);
  540. av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d bit @%5d in %s %s:%d\n",
  541. r, n, r, get_bits_count(s) - n, file, func, line);
  542. return r;
  543. }
  544. static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2],
  545. int bits, int max_depth, const char *file,
  546. const char *func, int line)
  547. {
  548. int show = show_bits(s, 24);
  549. int pos = get_bits_count(s);
  550. int r = get_vlc2(s, table, bits, max_depth);
  551. int len = get_bits_count(s) - pos;
  552. int bits2 = show >> (24 - len);
  553. print_bin(bits2, len);
  554. av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d vlc @%5d in %s %s:%d\n",
  555. bits2, len, r, pos, file, func, line);
  556. return r;
  557. }
  558. #define GET_RL_VLC(level, run, name, gb, table, bits, \
  559. max_depth, need_update) \
  560. do { \
  561. int show = SHOW_UBITS(name, gb, 24); \
  562. int len; \
  563. int pos = name ## _index; \
  564. \
  565. GET_RL_VLC_INTERNAL(level, run, name, gb, table, bits,max_depth, need_update); \
  566. \
  567. len = name ## _index - pos + 1; \
  568. show = show >> (24 - len); \
  569. \
  570. print_bin(show, len); \
  571. \
  572. av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d/%-3d rlv @%5d in %s %s:%d\n",\
  573. show, len, run-1, level, pos, __FILE__, __PRETTY_FUNCTION__, __LINE__);\
  574. } while (0) \
  575. static inline int get_xbits_trace(GetBitContext *s, int n, const char *file,
  576. const char *func, int line)
  577. {
  578. int show = show_bits(s, n);
  579. int r = get_xbits(s, n);
  580. print_bin(show, n);
  581. av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d xbt @%5d in %s %s:%d\n",
  582. show, n, r, get_bits_count(s) - n, file, func, line);
  583. return r;
  584. }
  585. #define get_bits(s, n) get_bits_trace(s , n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
  586. #define get_bits1(s) get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__)
  587. #define get_xbits(s, n) get_xbits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
  588. #define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__)
  589. #define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__)
  590. #else //TRACE
  591. #define GET_RL_VLC GET_RL_VLC_INTERNAL
  592. #endif
  593. #endif /* AVCODEC_GET_BITS_H */