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.

147 lines
4.9KB

  1. /*
  2. * This file is part of Libav.
  3. *
  4. * Libav 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. * Libav 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 Libav; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef AVCODEC_H264_SEI_H
  19. #define AVCODEC_H264_SEI_H
  20. #include "get_bits.h"
  21. /**
  22. * SEI message types
  23. */
  24. typedef enum {
  25. H264_SEI_TYPE_BUFFERING_PERIOD = 0, ///< buffering period (H.264, D.1.1)
  26. H264_SEI_TYPE_PIC_TIMING = 1, ///< picture timing
  27. H264_SEI_TYPE_FILLER_PAYLOAD = 3, ///< filler data
  28. H264_SEI_TYPE_USER_DATA_REGISTERED = 4, ///< registered user data as specified by Rec. ITU-T T.35
  29. H264_SEI_TYPE_USER_DATA_UNREGISTERED = 5, ///< unregistered user data
  30. H264_SEI_TYPE_RECOVERY_POINT = 6, ///< recovery point (frame # to decoder sync)
  31. H264_SEI_TYPE_FRAME_PACKING = 45, ///< frame packing arrangement
  32. H264_SEI_TYPE_DISPLAY_ORIENTATION = 47, ///< display orientation
  33. H264_SEI_TYPE_ALTERNATIVE_TRANSFER = 147, ///< alternative transfer
  34. } H264_SEI_Type;
  35. /**
  36. * pic_struct in picture timing SEI message
  37. */
  38. typedef enum {
  39. H264_SEI_PIC_STRUCT_FRAME = 0, ///< 0: %frame
  40. H264_SEI_PIC_STRUCT_TOP_FIELD = 1, ///< 1: top field
  41. H264_SEI_PIC_STRUCT_BOTTOM_FIELD = 2, ///< 2: bottom field
  42. H264_SEI_PIC_STRUCT_TOP_BOTTOM = 3, ///< 3: top field, bottom field, in that order
  43. H264_SEI_PIC_STRUCT_BOTTOM_TOP = 4, ///< 4: bottom field, top field, in that order
  44. H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP = 5, ///< 5: top field, bottom field, top field repeated, in that order
  45. H264_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM = 6, ///< 6: bottom field, top field, bottom field repeated, in that order
  46. H264_SEI_PIC_STRUCT_FRAME_DOUBLING = 7, ///< 7: %frame doubling
  47. H264_SEI_PIC_STRUCT_FRAME_TRIPLING = 8 ///< 8: %frame tripling
  48. } H264_SEI_PicStructType;
  49. typedef struct H264SEIPictureTiming {
  50. int present;
  51. H264_SEI_PicStructType pic_struct;
  52. /**
  53. * Bit set of clock types for fields/frames in picture timing SEI message.
  54. * For each found ct_type, appropriate bit is set (e.g., bit 1 for
  55. * interlaced).
  56. */
  57. int ct_type;
  58. /**
  59. * dpb_output_delay in picture timing SEI message, see H.264 C.2.2
  60. */
  61. int dpb_output_delay;
  62. /**
  63. * cpb_removal_delay in picture timing SEI message, see H.264 C.1.2
  64. */
  65. int cpb_removal_delay;
  66. } H264SEIPictureTiming;
  67. typedef struct H264SEIAFD {
  68. int present;
  69. uint8_t active_format_description;
  70. } H264SEIAFD;
  71. typedef struct H264SEIA53Caption {
  72. int a53_caption_size;
  73. uint8_t *a53_caption;
  74. } H264SEIA53Caption;
  75. typedef struct H264SEIUnregistered {
  76. int x264_build;
  77. } H264SEIUnregistered;
  78. typedef struct H264SEIRecoveryPoint {
  79. /**
  80. * recovery_frame_cnt
  81. *
  82. * Set to -1 if no recovery point SEI message found or to number of frames
  83. * before playback synchronizes. Frames having recovery point are key
  84. * frames.
  85. */
  86. int recovery_frame_cnt;
  87. } H264SEIRecoveryPoint;
  88. typedef struct H264SEIBufferingPeriod {
  89. int present; ///< Buffering period SEI flag
  90. int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs
  91. } H264SEIBufferingPeriod;
  92. typedef struct H264SEIFramePacking {
  93. int present;
  94. int arrangement_type;
  95. int content_interpretation_type;
  96. int quincunx_subsampling;
  97. } H264SEIFramePacking;
  98. typedef struct H264SEIDisplayOrientation {
  99. int present;
  100. int anticlockwise_rotation;
  101. int hflip, vflip;
  102. } H264SEIDisplayOrientation;
  103. typedef struct H264SEIAlternativeTransfer {
  104. int present;
  105. int preferred_transfer_characteristics;
  106. } H264SEIAlternativeTransfer;
  107. typedef struct H264SEIContext {
  108. H264SEIPictureTiming picture_timing;
  109. H264SEIAFD afd;
  110. H264SEIA53Caption a53_caption;
  111. H264SEIUnregistered unregistered;
  112. H264SEIRecoveryPoint recovery_point;
  113. H264SEIBufferingPeriod buffering_period;
  114. H264SEIFramePacking frame_packing;
  115. H264SEIDisplayOrientation display_orientation;
  116. H264SEIAlternativeTransfer alternative_transfer;
  117. } H264SEIContext;
  118. struct H264ParamSets;
  119. int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb,
  120. const struct H264ParamSets *ps, void *logctx);
  121. /**
  122. * Reset SEI values at the beginning of the frame.
  123. */
  124. void ff_h264_sei_uninit(H264SEIContext *h);
  125. #endif /* AVCODEC_H264_SEI_H */