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.

98 lines
3.3KB

  1. /*
  2. * Header file for hardcoded DV tables
  3. *
  4. * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
  5. *
  6. * This file is part of Libav.
  7. *
  8. * Libav 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. * Libav 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 Libav; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #ifndef AVCODEC_DV_TABLEGEN_H
  23. #define AVCODEC_DV_TABLEGEN_H
  24. #include <stdint.h>
  25. #include "dvdata.h"
  26. #if CONFIG_SMALL
  27. #define DV_VLC_MAP_RUN_SIZE 15
  28. #define DV_VLC_MAP_LEV_SIZE 23
  29. #else
  30. #define DV_VLC_MAP_RUN_SIZE 64
  31. #define DV_VLC_MAP_LEV_SIZE 512 // FIXME sign was removed so this should be /2 but needs check
  32. #endif
  33. /* VLC encoding lookup table */
  34. typedef struct dv_vlc_pair {
  35. uint32_t vlc;
  36. uint32_t size;
  37. } dv_vlc_pair;
  38. #if CONFIG_HARDCODED_TABLES
  39. #define dv_vlc_map_tableinit()
  40. #include "libavcodec/dv_tables.h"
  41. #else
  42. static struct dv_vlc_pair dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE];
  43. static void dv_vlc_map_tableinit(void)
  44. {
  45. int i, j;
  46. for (i = 0; i < NB_DV_VLC - 1; i++) {
  47. if (ff_dv_vlc_run[i] >= DV_VLC_MAP_RUN_SIZE)
  48. continue;
  49. #if CONFIG_SMALL
  50. if (ff_dv_vlc_level[i] >= DV_VLC_MAP_LEV_SIZE)
  51. continue;
  52. #endif
  53. if (dv_vlc_map[ff_dv_vlc_run[i]][ff_dv_vlc_level[i]].size != 0)
  54. continue;
  55. dv_vlc_map[ff_dv_vlc_run[i]][ff_dv_vlc_level[i]].vlc =
  56. ff_dv_vlc_bits[i] << (!!ff_dv_vlc_level[i]);
  57. dv_vlc_map[ff_dv_vlc_run[i]][ff_dv_vlc_level[i]].size =
  58. ff_dv_vlc_len[i] + (!!ff_dv_vlc_level[i]);
  59. }
  60. for (i = 0; i < DV_VLC_MAP_RUN_SIZE; i++) {
  61. #if CONFIG_SMALL
  62. for (j = 1; j < DV_VLC_MAP_LEV_SIZE; j++) {
  63. if (dv_vlc_map[i][j].size == 0) {
  64. dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc |
  65. (dv_vlc_map[i - 1][0].vlc <<
  66. dv_vlc_map[0][j].size);
  67. dv_vlc_map[i][j].size = dv_vlc_map[i - 1][0].size +
  68. dv_vlc_map[0][j].size;
  69. }
  70. }
  71. #else
  72. for (j = 1; j < DV_VLC_MAP_LEV_SIZE / 2; j++) {
  73. if (dv_vlc_map[i][j].size == 0) {
  74. dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc |
  75. (dv_vlc_map[i - 1][0].vlc <<
  76. dv_vlc_map[0][j].size);
  77. dv_vlc_map[i][j].size = dv_vlc_map[i - 1][0].size +
  78. dv_vlc_map[0][j].size;
  79. }
  80. dv_vlc_map[i][((uint16_t) (-j)) & 0x1ff].vlc = dv_vlc_map[i][j].vlc | 1;
  81. dv_vlc_map[i][((uint16_t) (-j)) & 0x1ff].size = dv_vlc_map[i][j].size;
  82. }
  83. #endif
  84. }
  85. }
  86. #endif /* CONFIG_HARDCODED_TABLES */
  87. #endif /* AVCODEC_DV_TABLEGEN_H */