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.

184 lines
6.2KB

  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. #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_GREEN_METADATA = 56, ///< GreenMPEG information
  34. H264_SEI_TYPE_ALTERNATIVE_TRANSFER = 147, ///< alternative transfer
  35. } H264_SEI_Type;
  36. /**
  37. * pic_struct in picture timing SEI message
  38. */
  39. typedef enum {
  40. H264_SEI_PIC_STRUCT_FRAME = 0, ///< 0: %frame
  41. H264_SEI_PIC_STRUCT_TOP_FIELD = 1, ///< 1: top field
  42. H264_SEI_PIC_STRUCT_BOTTOM_FIELD = 2, ///< 2: bottom field
  43. H264_SEI_PIC_STRUCT_TOP_BOTTOM = 3, ///< 3: top field, bottom field, in that order
  44. H264_SEI_PIC_STRUCT_BOTTOM_TOP = 4, ///< 4: bottom field, top field, in that order
  45. H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP = 5, ///< 5: top field, bottom field, top field repeated, in that order
  46. H264_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM = 6, ///< 6: bottom field, top field, bottom field repeated, in that order
  47. H264_SEI_PIC_STRUCT_FRAME_DOUBLING = 7, ///< 7: %frame doubling
  48. H264_SEI_PIC_STRUCT_FRAME_TRIPLING = 8 ///< 8: %frame tripling
  49. } H264_SEI_PicStructType;
  50. /**
  51. * frame_packing_arrangement types
  52. */
  53. typedef enum {
  54. H264_SEI_FPA_TYPE_CHECKERBOARD = 0,
  55. H264_SEI_FPA_TYPE_INTERLEAVE_COLUMN = 1,
  56. H264_SEI_FPA_TYPE_INTERLEAVE_ROW = 2,
  57. H264_SEI_FPA_TYPE_SIDE_BY_SIDE = 3,
  58. H264_SEI_FPA_TYPE_TOP_BOTTOM = 4,
  59. H264_SEI_FPA_TYPE_INTERLEAVE_TEMPORAL = 5,
  60. H264_SEI_FPA_TYPE_2D = 6,
  61. } H264_SEI_FpaType;
  62. typedef struct H264SEIPictureTiming {
  63. int present;
  64. H264_SEI_PicStructType pic_struct;
  65. /**
  66. * Bit set of clock types for fields/frames in picture timing SEI message.
  67. * For each found ct_type, appropriate bit is set (e.g., bit 1 for
  68. * interlaced).
  69. */
  70. int ct_type;
  71. /**
  72. * dpb_output_delay in picture timing SEI message, see H.264 C.2.2
  73. */
  74. int dpb_output_delay;
  75. /**
  76. * cpb_removal_delay in picture timing SEI message, see H.264 C.1.2
  77. */
  78. int cpb_removal_delay;
  79. } H264SEIPictureTiming;
  80. typedef struct H264SEIAFD {
  81. int present;
  82. uint8_t active_format_description;
  83. } H264SEIAFD;
  84. typedef struct H264SEIA53Caption {
  85. int a53_caption_size;
  86. uint8_t *a53_caption;
  87. } H264SEIA53Caption;
  88. typedef struct H264SEIUnregistered {
  89. int x264_build;
  90. } H264SEIUnregistered;
  91. typedef struct H264SEIRecoveryPoint {
  92. /**
  93. * recovery_frame_cnt
  94. *
  95. * Set to -1 if no recovery point SEI message found or to number of frames
  96. * before playback synchronizes. Frames having recovery point are key
  97. * frames.
  98. */
  99. int recovery_frame_cnt;
  100. } H264SEIRecoveryPoint;
  101. typedef struct H264SEIBufferingPeriod {
  102. int present; ///< Buffering period SEI flag
  103. int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs
  104. } H264SEIBufferingPeriod;
  105. typedef struct H264SEIFramePacking {
  106. int present;
  107. int frame_packing_arrangement_id;
  108. int frame_packing_arrangement_cancel_flag; ///< is previous arrangement canceled, -1 if never received
  109. H264_SEI_FpaType frame_packing_arrangement_type;
  110. int frame_packing_arrangement_repetition_period;
  111. int content_interpretation_type;
  112. int quincunx_sampling_flag;
  113. int current_frame_is_frame0_flag;
  114. } H264SEIFramePacking;
  115. typedef struct H264SEIDisplayOrientation {
  116. int present;
  117. int anticlockwise_rotation;
  118. int hflip, vflip;
  119. } H264SEIDisplayOrientation;
  120. typedef struct H264SEIGreenMetaData {
  121. uint8_t green_metadata_type;
  122. uint8_t period_type;
  123. uint16_t num_seconds;
  124. uint16_t num_pictures;
  125. uint8_t percent_non_zero_macroblocks;
  126. uint8_t percent_intra_coded_macroblocks;
  127. uint8_t percent_six_tap_filtering;
  128. uint8_t percent_alpha_point_deblocking_instance;
  129. uint8_t xsd_metric_type;
  130. uint16_t xsd_metric_value;
  131. } H264SEIGreenMetaData;
  132. typedef struct H264SEIAlternativeTransfer {
  133. int present;
  134. int preferred_transfer_characteristics;
  135. } H264SEIAlternativeTransfer;
  136. typedef struct H264SEIContext {
  137. H264SEIPictureTiming picture_timing;
  138. H264SEIAFD afd;
  139. H264SEIA53Caption a53_caption;
  140. H264SEIUnregistered unregistered;
  141. H264SEIRecoveryPoint recovery_point;
  142. H264SEIBufferingPeriod buffering_period;
  143. H264SEIFramePacking frame_packing;
  144. H264SEIDisplayOrientation display_orientation;
  145. H264SEIGreenMetaData green_metadata;
  146. H264SEIAlternativeTransfer alternative_transfer;
  147. } H264SEIContext;
  148. struct H264ParamSets;
  149. int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb,
  150. const struct H264ParamSets *ps, void *logctx);
  151. /**
  152. * Reset SEI values at the beginning of the frame.
  153. */
  154. void ff_h264_sei_uninit(H264SEIContext *h);
  155. /**
  156. * Get stereo_mode string from the h264 frame_packing_arrangement
  157. */
  158. const char *ff_h264_sei_stereo_mode(const H264SEIFramePacking *h);
  159. #endif /* AVCODEC_H264_SEI_H */