vlc.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef AVCODEC_VLC_H
  19. #define AVCODEC_VLC_H
  20. #include <stdint.h>
  21. #define VLC_TYPE int16_t
  22. typedef struct VLC {
  23. int bits;
  24. VLC_TYPE (*table)[2]; ///< code, bits
  25. int table_size, table_allocated;
  26. } VLC;
  27. typedef struct RL_VLC_ELEM {
  28. int16_t level;
  29. int8_t len;
  30. uint8_t run;
  31. } RL_VLC_ELEM;
  32. #define init_vlc(vlc, nb_bits, nb_codes, \
  33. bits, bits_wrap, bits_size, \
  34. codes, codes_wrap, codes_size, \
  35. flags) \
  36. ff_init_vlc_sparse(vlc, nb_bits, nb_codes, \
  37. bits, bits_wrap, bits_size, \
  38. codes, codes_wrap, codes_size, \
  39. NULL, 0, 0, flags)
  40. int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
  41. const void *bits, int bits_wrap, int bits_size,
  42. const void *codes, int codes_wrap, int codes_size,
  43. const void *symbols, int symbols_wrap, int symbols_size,
  44. int flags);
  45. void ff_free_vlc(VLC *vlc);
  46. #define INIT_VLC_LE 2
  47. #define INIT_VLC_USE_NEW_STATIC 4
  48. #define INIT_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, h, i, j, static_size) \
  49. do { \
  50. static VLC_TYPE table[static_size][2]; \
  51. (vlc)->table = table; \
  52. (vlc)->table_allocated = static_size; \
  53. ff_init_vlc_sparse(vlc, bits, a, b, c, d, e, f, g, h, i, j, \
  54. INIT_VLC_USE_NEW_STATIC); \
  55. } while (0)
  56. #define INIT_LE_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, h, i, j, static_size) \
  57. do { \
  58. static VLC_TYPE table[static_size][2]; \
  59. (vlc)->table = table; \
  60. (vlc)->table_allocated = static_size; \
  61. ff_init_vlc_sparse(vlc, bits, a, b, c, d, e, f, g, h, i, j, \
  62. INIT_VLC_USE_NEW_STATIC | INIT_VLC_LE); \
  63. } while (0)
  64. #define INIT_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size) \
  65. INIT_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, NULL, 0, 0, static_size)
  66. #define INIT_LE_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size) \
  67. INIT_LE_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, NULL, 0, 0, static_size)
  68. #endif /* AVCODEC_VLC_H */