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.

171 lines
7.3KB

  1. /*
  2. * H26L/H264/AVC/JVT/14496-10/... encoder/decoder
  3. * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
  4. *
  5. * This file is part of Libav.
  6. *
  7. * Libav 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. * Libav 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 Libav; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  22. * @file
  23. * @brief
  24. * H264 / AVC / MPEG4 part10 codec data table
  25. * @author Michael Niedermayer <michaelni@gmx.at>
  26. */
  27. #ifndef AVCODEC_H264DATA_H
  28. #define AVCODEC_H264DATA_H
  29. #include <stdint.h>
  30. #include "libavutil/rational.h"
  31. #include "h264.h"
  32. static const uint8_t golomb_to_pict_type[5] = {
  33. AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, AV_PICTURE_TYPE_I,
  34. AV_PICTURE_TYPE_SP, AV_PICTURE_TYPE_SI
  35. };
  36. static const uint8_t golomb_to_intra4x4_cbp[48] = {
  37. 47, 31, 15, 0, 23, 27, 29, 30, 7, 11, 13, 14, 39, 43, 45, 46,
  38. 16, 3, 5, 10, 12, 19, 21, 26, 28, 35, 37, 42, 44, 1, 2, 4,
  39. 8, 17, 18, 20, 24, 6, 9, 22, 25, 32, 33, 34, 36, 40, 38, 41
  40. };
  41. static const uint8_t golomb_to_inter_cbp[48] = {
  42. 0, 16, 1, 2, 4, 8, 32, 3, 5, 10, 12, 15, 47, 7, 11, 13,
  43. 14, 6, 9, 31, 35, 37, 42, 44, 33, 34, 36, 40, 39, 43, 45, 46,
  44. 17, 18, 20, 24, 19, 21, 26, 28, 23, 27, 29, 30, 22, 25, 38, 41
  45. };
  46. static const uint8_t zigzag_scan[16] = {
  47. 0 + 0 * 4, 1 + 0 * 4, 0 + 1 * 4, 0 + 2 * 4,
  48. 1 + 1 * 4, 2 + 0 * 4, 3 + 0 * 4, 2 + 1 * 4,
  49. 1 + 2 * 4, 0 + 3 * 4, 1 + 3 * 4, 2 + 2 * 4,
  50. 3 + 1 * 4, 3 + 2 * 4, 2 + 3 * 4, 3 + 3 * 4,
  51. };
  52. static const uint8_t chroma_dc_scan[4] = {
  53. (0 + 0 * 2) * 16, (1 + 0 * 2) * 16,
  54. (0 + 1 * 2) * 16, (1 + 1 * 2) * 16,
  55. };
  56. static const uint8_t chroma422_dc_scan[8] = {
  57. (0 + 0 * 2) * 16, (0 + 1 * 2) * 16,
  58. (1 + 0 * 2) * 16, (0 + 2 * 2) * 16,
  59. (0 + 3 * 2) * 16, (1 + 1 * 2) * 16,
  60. (1 + 2 * 2) * 16, (1 + 3 * 2) * 16,
  61. };
  62. typedef struct IMbInfo {
  63. uint16_t type;
  64. uint8_t pred_mode;
  65. uint8_t cbp;
  66. } IMbInfo;
  67. static const IMbInfo i_mb_type_info[26] = {
  68. { MB_TYPE_INTRA4x4, -1, -1 },
  69. { MB_TYPE_INTRA16x16, 2, 0 },
  70. { MB_TYPE_INTRA16x16, 1, 0 },
  71. { MB_TYPE_INTRA16x16, 0, 0 },
  72. { MB_TYPE_INTRA16x16, 3, 0 },
  73. { MB_TYPE_INTRA16x16, 2, 16 },
  74. { MB_TYPE_INTRA16x16, 1, 16 },
  75. { MB_TYPE_INTRA16x16, 0, 16 },
  76. { MB_TYPE_INTRA16x16, 3, 16 },
  77. { MB_TYPE_INTRA16x16, 2, 32 },
  78. { MB_TYPE_INTRA16x16, 1, 32 },
  79. { MB_TYPE_INTRA16x16, 0, 32 },
  80. { MB_TYPE_INTRA16x16, 3, 32 },
  81. { MB_TYPE_INTRA16x16, 2, 15 + 0 },
  82. { MB_TYPE_INTRA16x16, 1, 15 + 0 },
  83. { MB_TYPE_INTRA16x16, 0, 15 + 0 },
  84. { MB_TYPE_INTRA16x16, 3, 15 + 0 },
  85. { MB_TYPE_INTRA16x16, 2, 15 + 16 },
  86. { MB_TYPE_INTRA16x16, 1, 15 + 16 },
  87. { MB_TYPE_INTRA16x16, 0, 15 + 16 },
  88. { MB_TYPE_INTRA16x16, 3, 15 + 16 },
  89. { MB_TYPE_INTRA16x16, 2, 15 + 32 },
  90. { MB_TYPE_INTRA16x16, 1, 15 + 32 },
  91. { MB_TYPE_INTRA16x16, 0, 15 + 32 },
  92. { MB_TYPE_INTRA16x16, 3, 15 + 32 },
  93. { MB_TYPE_INTRA_PCM, -1, -1 },
  94. };
  95. typedef struct PMbInfo {
  96. uint16_t type;
  97. uint8_t partition_count;
  98. } PMbInfo;
  99. static const PMbInfo p_mb_type_info[5] = {
  100. { MB_TYPE_16x16 | MB_TYPE_P0L0, 1 },
  101. { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2 },
  102. { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2 },
  103. { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 4 },
  104. { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_REF0, 4 },
  105. };
  106. static const PMbInfo p_sub_mb_type_info[4] = {
  107. { MB_TYPE_16x16 | MB_TYPE_P0L0, 1 },
  108. { MB_TYPE_16x8 | MB_TYPE_P0L0, 2 },
  109. { MB_TYPE_8x16 | MB_TYPE_P0L0, 2 },
  110. { MB_TYPE_8x8 | MB_TYPE_P0L0, 4 },
  111. };
  112. static const PMbInfo b_mb_type_info[23] = {
  113. { MB_TYPE_DIRECT2 | MB_TYPE_L0L1, 1, },
  114. { MB_TYPE_16x16 | MB_TYPE_P0L0, 1, },
  115. { MB_TYPE_16x16 | MB_TYPE_P0L1, 1, },
  116. { MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1, 1, },
  117. { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, },
  118. { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, },
  119. { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
  120. { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
  121. { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L1, 2, },
  122. { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L1, 2, },
  123. { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, },
  124. { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, },
  125. { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
  126. { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
  127. { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
  128. { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
  129. { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, },
  130. { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, },
  131. { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
  132. { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
  133. { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
  134. { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
  135. { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 4, },
  136. };
  137. static const PMbInfo b_sub_mb_type_info[13] = {
  138. { MB_TYPE_DIRECT2, 1, },
  139. { MB_TYPE_16x16 | MB_TYPE_P0L0, 1, },
  140. { MB_TYPE_16x16 | MB_TYPE_P0L1, 1, },
  141. { MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1, 1, },
  142. { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, },
  143. { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, },
  144. { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
  145. { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
  146. { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
  147. { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
  148. { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 4, },
  149. { MB_TYPE_8x8 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 4, },
  150. { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 4, },
  151. };
  152. #endif /* AVCODEC_H264DATA_H */