h261data.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
  3. * copyright (c) 2004 Maarten Daniels
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  22. * @file libavcodec/h261data.h
  23. * H.261 tables.
  24. */
  25. #ifndef AVCODEC_H261DATA_H
  26. #define AVCODEC_H261DATA_H
  27. #include <stdint.h>
  28. #include "h261.h"
  29. // H.261 VLC table for macroblock addressing
  30. static const uint8_t h261_mba_code[35] = {
  31. 1, 3, 2, 3,
  32. 2, 3, 2, 7,
  33. 6, 11, 10, 9,
  34. 8, 7, 6, 23,
  35. 22, 21, 20, 19,
  36. 18, 35, 34, 33,
  37. 32, 31, 30, 29,
  38. 28, 27, 26, 25,
  39. 24,
  40. 15, //(MBA stuffing)
  41. 1 //(start code)
  42. };
  43. static const uint8_t h261_mba_bits[35] = {
  44. 1, 3, 3, 4,
  45. 4, 5, 5, 7,
  46. 7, 8, 8, 8,
  47. 8, 8, 8, 10,
  48. 10, 10, 10, 10,
  49. 10, 11, 11, 11,
  50. 11, 11, 11, 11,
  51. 11, 11, 11, 11,
  52. 11,
  53. 11, //(MBA stuffing)
  54. 16 //(start code)
  55. };
  56. //H.261 VLC table for macroblock type
  57. static const uint8_t h261_mtype_code[10] = {
  58. 1, 1, 1, 1,
  59. 1, 1, 1, 1,
  60. 1, 1
  61. };
  62. static const uint8_t h261_mtype_bits[10] = {
  63. 4, 7, 1, 5,
  64. 9, 8, 10, 3,
  65. 2, 6
  66. };
  67. static const int h261_mtype_map[10]= {
  68. MB_TYPE_INTRA4x4,
  69. MB_TYPE_INTRA4x4 | MB_TYPE_QUANT,
  70. MB_TYPE_CBP,
  71. MB_TYPE_QUANT | MB_TYPE_CBP,
  72. MB_TYPE_16x16,
  73. MB_TYPE_CBP | MB_TYPE_16x16,
  74. MB_TYPE_QUANT | MB_TYPE_CBP | MB_TYPE_16x16,
  75. MB_TYPE_16x16 | MB_TYPE_H261_FIL,
  76. MB_TYPE_CBP | MB_TYPE_16x16 | MB_TYPE_H261_FIL,
  77. MB_TYPE_QUANT | MB_TYPE_CBP | MB_TYPE_16x16 | MB_TYPE_H261_FIL
  78. };
  79. //H.261 VLC table for motion vectors
  80. static const uint8_t h261_mv_tab[17][2] = {
  81. {1,1}, {1,2}, {1,3}, {1,4}, {3,6}, {5,7}, {4,7}, {3,7},
  82. {11,9}, {10,9}, {9,9}, {17,10}, {16,10}, {15,10}, {14,10}, {13,10}, {12,10}
  83. };
  84. static const int mvmap[17] =
  85. {
  86. 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16
  87. };
  88. //H.261 VLC table for coded block pattern
  89. static const uint8_t h261_cbp_tab[63][2] =
  90. {
  91. {11,5}, {9,5}, {13,6}, {13,4}, {23,7}, {19,7}, {31,8}, {12,4},
  92. {22,7}, {18,7}, {30,8}, {19,5}, {27,8}, {23,8}, {19,8}, {11,4},
  93. {21,7}, {17,7}, {29,8}, {17,5}, {25,8}, {21,8}, {17,8}, {15,6},
  94. {15,8}, {13,8}, {3,9}, {15,5}, {11,8}, {7,8}, {7,9}, {10,4},
  95. {20,7}, {16,7}, {28,8}, {14,6}, {14,8}, {12,8}, {2,9}, {16,5},
  96. {24,8}, {20,8}, {16,8}, {14,5}, {10,8}, {6,8}, {6,9}, {18,5},
  97. {26,8}, {22,8}, {18,8}, {13,5}, {9,8}, {5,8}, {5,9}, {12,5},
  98. {8,8}, {4,8}, {4,9}, {7,3}, {10,5}, {8,5}, {12,6}
  99. };
  100. //H.261 VLC table for transform coefficients
  101. static const uint16_t h261_tcoeff_vlc[65][2] = {
  102. { 0x2, 2 }, { 0x3, 2 },{ 0x4, 4 },{ 0x5, 5 },
  103. { 0x6, 7 },{ 0x26, 8 },{ 0x21, 8 },{ 0xa, 10 },
  104. { 0x1d, 12 },{ 0x18, 12 },{ 0x13, 12 },{ 0x10 , 12 },
  105. { 0x1a, 13},{ 0x19, 13 }, { 0x18, 13 }, { 0x17, 13 },
  106. { 0x3, 3 }, { 0x6, 6 }, { 0x25 , 8 }, { 0xc, 10 },
  107. { 0x1b, 12 }, { 0x16, 13 }, { 0x15, 13 }, { 0x5, 4},
  108. { 0x4, 7}, { 0xb, 10 }, { 0x14, 12 }, { 0x14, 13 },
  109. { 0x7, 5 }, { 0x24, 8 }, { 0x1c, 12 }, { 0x13, 13 },
  110. { 0x6, 5 }, { 0xf, 10 }, { 0x12, 12}, { 0x7, 6},
  111. { 0x9 , 10 }, { 0x12, 13 }, { 0x5, 6 }, { 0x1e, 12 },
  112. { 0x4, 6 }, { 0x15, 12 }, { 0x7, 7 }, { 0x11, 12},
  113. { 0x5, 7 }, { 0x11, 13 }, { 0x27, 8 }, { 0x10, 13 },
  114. { 0x23, 8 }, { 0x22, 8 }, { 0x20, 8 }, { 0xe , 10 },
  115. { 0xd, 10 }, { 0x8, 10 },{ 0x1f, 12 }, { 0x1a, 12 },
  116. { 0x19, 12 }, { 0x17, 12 }, { 0x16, 12}, { 0x1f, 13},
  117. { 0x1e, 13 }, { 0x1d, 13 }, { 0x1c, 13}, { 0x1b, 13},
  118. { 0x1, 6 } //escape
  119. };
  120. static const int8_t h261_tcoeff_level[64] = {
  121. 0, 1, 2, 3, 4, 5, 6, 7,
  122. 8, 9, 10, 11, 12, 13, 14, 15,
  123. 1, 2, 3, 4, 5, 6, 7, 1,
  124. 2, 3, 4, 5, 1, 2, 3, 4,
  125. 1, 2, 3, 1, 2, 3, 1, 2,
  126. 1, 2, 1, 2, 1, 2, 1, 2,
  127. 1, 1, 1, 1, 1, 1, 1, 1,
  128. 1, 1, 1, 1, 1, 1, 1, 1
  129. };
  130. static const int8_t h261_tcoeff_run[64] = {
  131. 0,
  132. 0, 0, 0, 0, 0, 0, 0, 0,
  133. 0, 0, 0, 0, 0, 0, 0, 1,
  134. 1, 1, 1, 1, 1, 1, 2, 2,
  135. 2, 2, 2, 3, 3, 3, 3, 4,
  136. 4, 4, 5, 5, 5, 6, 6, 7,
  137. 7, 8, 8, 9, 9, 10, 10, 11,
  138. 12, 13, 14, 15, 16, 17, 18, 19,
  139. 20, 21, 22, 23, 24, 25, 26
  140. };
  141. static RLTable h261_rl_tcoeff = {
  142. 64,
  143. 64,
  144. h261_tcoeff_vlc,
  145. h261_tcoeff_run,
  146. h261_tcoeff_level,
  147. };
  148. #endif /* AVCODEC_H261DATA_H */