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.

82 lines
3.0KB

  1. /*
  2. * Helpers for generating hard-coded VLC tables
  3. *
  4. * Copyright (c) 2014 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
  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. #ifndef AVCODEC_TABLEPRINT_VLC_H
  23. #define AVCODEC_TABLEPRINT_VLC_H
  24. #define FFMPEG_CONFIG_H
  25. #define AVUTIL_LOG_H
  26. #define av_log(a, ...)
  27. #define ff_dlog(a, ...)
  28. #define AVUTIL_MEM_H
  29. #define av_malloc(s) NULL
  30. #define av_malloc_array(a, b) NULL
  31. #define av_realloc_f(p, o, n) NULL
  32. #define av_free(p)
  33. #define av_freep(p)
  34. #define AVCODEC_AVCODEC_H
  35. #define AVCODEC_INTERNAL_H
  36. #include "tableprint.h"
  37. #include "get_bits.h"
  38. #include "mathtables.c"
  39. #include "bitstream.c"
  40. #define REPLACE_DEFINE2(type) write_##type##_array
  41. #define REPLACE_DEFINE(type) REPLACE_DEFINE2(type)
  42. static void write_VLC_TYPE_array(const VLC_TYPE *p, int s) {
  43. REPLACE_DEFINE(VLC_TYPE)(p, s);
  44. }
  45. WRITE_2D_FUNC(VLC_TYPE)
  46. static void write_vlc_type(const VLC *vlc, VLC_TYPE (*base_table)[2], const char *base_table_name)
  47. {
  48. printf(" .bits = %i,\n", vlc->bits);
  49. // Unfortunately need to cast away const currently
  50. printf(" .table = (VLC_TYPE (*)[2])(%s + 0x%x),\n", base_table_name, (int)(vlc->table - base_table));
  51. printf(" .table_size = 0x%x,\n", vlc->table_size);
  52. printf(" .table_allocated = 0x%x,\n", vlc->table_allocated);
  53. }
  54. #define WRITE_VLC_TYPE(prefix, name, base_table) \
  55. do { \
  56. printf(prefix" VLC "#name" = {\n"); \
  57. write_vlc_type(&name, base_table, #base_table); \
  58. printf("};\n"); \
  59. } while(0)
  60. #define WRITE_VLC_ARRAY(prefix, name, base_table) \
  61. do { \
  62. int i; \
  63. const size_t array_size = FF_ARRAY_ELEMS(name); \
  64. printf(prefix" VLC "#name"[%"FMT"] = {{\n", \
  65. array_size); \
  66. for (i = 0; i < array_size; i++) { \
  67. write_vlc_type(name + i, \
  68. base_table, #base_table); \
  69. if (i != array_size - 1) printf("}, {\n"); \
  70. } \
  71. printf("}};\n"); \
  72. } while(0)
  73. #endif /* AVCODEC_TABLEPRINT_VLC_H */