h264.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. /**
  19. * @file
  20. * H.264 common definitions
  21. */
  22. #ifndef AVCODEC_H264_H
  23. #define AVCODEC_H264_H
  24. #define QP_MAX_NUM (51 + 6*6) // The maximum supported qp
  25. /*
  26. * Table 7-1 – NAL unit type codes, syntax element categories, and NAL unit type classes in
  27. * T-REC-H.264-201704
  28. */
  29. enum {
  30. H264_NAL_UNSPECIFIED = 0,
  31. H264_NAL_SLICE = 1,
  32. H264_NAL_DPA = 2,
  33. H264_NAL_DPB = 3,
  34. H264_NAL_DPC = 4,
  35. H264_NAL_IDR_SLICE = 5,
  36. H264_NAL_SEI = 6,
  37. H264_NAL_SPS = 7,
  38. H264_NAL_PPS = 8,
  39. H264_NAL_AUD = 9,
  40. H264_NAL_END_SEQUENCE = 10,
  41. H264_NAL_END_STREAM = 11,
  42. H264_NAL_FILLER_DATA = 12,
  43. H264_NAL_SPS_EXT = 13,
  44. H264_NAL_PREFIX = 14,
  45. H264_NAL_SUB_SPS = 15,
  46. H264_NAL_DPS = 16,
  47. H264_NAL_RESERVED17 = 17,
  48. H264_NAL_RESERVED18 = 18,
  49. H264_NAL_AUXILIARY_SLICE = 19,
  50. H264_NAL_EXTEN_SLICE = 20,
  51. H264_NAL_DEPTH_EXTEN_SLICE = 21,
  52. H264_NAL_RESERVED22 = 22,
  53. H264_NAL_RESERVED23 = 23,
  54. H264_NAL_UNSPECIFIED24 = 24,
  55. H264_NAL_UNSPECIFIED25 = 25,
  56. H264_NAL_UNSPECIFIED26 = 26,
  57. H264_NAL_UNSPECIFIED27 = 27,
  58. H264_NAL_UNSPECIFIED28 = 28,
  59. H264_NAL_UNSPECIFIED29 = 29,
  60. H264_NAL_UNSPECIFIED30 = 30,
  61. H264_NAL_UNSPECIFIED31 = 31,
  62. };
  63. enum {
  64. // 7.4.2.1.1: seq_parameter_set_id is in [0, 31].
  65. H264_MAX_SPS_COUNT = 32,
  66. // 7.4.2.2: pic_parameter_set_id is in [0, 255].
  67. H264_MAX_PPS_COUNT = 256,
  68. // A.3: MaxDpbFrames is bounded above by 16.
  69. H264_MAX_DPB_FRAMES = 16,
  70. // 7.4.2.1.1: max_num_ref_frames is in [0, MaxDpbFrames], and
  71. // each reference frame can have two fields.
  72. H264_MAX_REFS = 2 * H264_MAX_DPB_FRAMES,
  73. // 7.4.3.1: modification_of_pic_nums_idc is not equal to 3 at most
  74. // num_ref_idx_lN_active_minus1 + 1 times (that is, once for each
  75. // possible reference), then equal to 3 once.
  76. H264_MAX_RPLM_COUNT = H264_MAX_REFS + 1,
  77. // 7.4.3.3: in the worst case, we begin with a full short-term
  78. // reference picture list. Each picture in turn is moved to the
  79. // long-term list (type 3) and then discarded from there (type 2).
  80. // Then, we set the length of the long-term list (type 4), mark
  81. // the current picture as long-term (type 6) and terminate the
  82. // process (type 0).
  83. H264_MAX_MMCO_COUNT = H264_MAX_REFS * 2 + 3,
  84. // A.2.1, A.2.3: profiles supporting FMO constrain
  85. // num_slice_groups_minus1 to be in [0, 7].
  86. H264_MAX_SLICE_GROUPS = 8,
  87. // E.2.2: cpb_cnt_minus1 is in [0, 31].
  88. H264_MAX_CPB_CNT = 32,
  89. // A.3: in table A-1 the highest level allows a MaxFS of 139264.
  90. H264_MAX_MB_PIC_SIZE = 139264,
  91. // A.3.1, A.3.2: PicWidthInMbs and PicHeightInMbs are constrained
  92. // to be not greater than sqrt(MaxFS * 8). Hence height/width are
  93. // bounded above by sqrt(139264 * 8) = 1055.5 macroblocks.
  94. H264_MAX_MB_WIDTH = 1055,
  95. H264_MAX_MB_HEIGHT = 1055,
  96. H264_MAX_WIDTH = H264_MAX_MB_WIDTH * 16,
  97. H264_MAX_HEIGHT = H264_MAX_MB_HEIGHT * 16,
  98. };
  99. #endif /* AVCODEC_H264_H */