defs.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. /*
  2. *
  3. * This file is part of FFmpeg.
  4. *
  5. * FFmpeg is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * FFmpeg is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with FFmpeg; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. #ifndef AVCODEC_DEFS_H
  20. #define AVCODEC_DEFS_H
  21. /**
  22. * @file
  23. * @ingroup libavc
  24. * Misc types and constants that do not belong anywhere else.
  25. */
  26. #include <stdint.h>
  27. #include <stdlib.h>
  28. /**
  29. * @ingroup lavc_decoding
  30. * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
  31. * This is mainly needed because some optimized bitstream readers read
  32. * 32 or 64 bit at once and could read over the end.<br>
  33. * Note: If the first 23 bits of the additional bytes are not 0, then damaged
  34. * MPEG bitstreams could cause overread and segfault.
  35. */
  36. #define AV_INPUT_BUFFER_PADDING_SIZE 64
  37. /**
  38. * Verify checksums embedded in the bitstream (could be of either encoded or
  39. * decoded data, depending on the format) and print an error message on mismatch.
  40. * If AV_EF_EXPLODE is also set, a mismatching checksum will result in the
  41. * decoder/demuxer returning an error.
  42. */
  43. #define AV_EF_CRCCHECK (1<<0)
  44. #define AV_EF_BITSTREAM (1<<1) ///< detect bitstream specification deviations
  45. #define AV_EF_BUFFER (1<<2) ///< detect improper bitstream length
  46. #define AV_EF_EXPLODE (1<<3) ///< abort decoding on minor error detection
  47. #define AV_EF_IGNORE_ERR (1<<15) ///< ignore errors and continue
  48. #define AV_EF_CAREFUL (1<<16) ///< consider things that violate the spec, are fast to calculate and have not been seen in the wild as errors
  49. #define AV_EF_COMPLIANT (1<<17) ///< consider all spec non compliances as errors
  50. #define AV_EF_AGGRESSIVE (1<<18) ///< consider things that a sane encoder/muxer should not do as an error
  51. #define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software.
  52. #define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences.
  53. #define FF_COMPLIANCE_NORMAL 0
  54. #define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions
  55. #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
  56. #define AV_PROFILE_UNKNOWN -99
  57. #define AV_PROFILE_RESERVED -100
  58. #define AV_PROFILE_AAC_MAIN 0
  59. #define AV_PROFILE_AAC_LOW 1
  60. #define AV_PROFILE_AAC_SSR 2
  61. #define AV_PROFILE_AAC_LTP 3
  62. #define AV_PROFILE_AAC_HE 4
  63. #define AV_PROFILE_AAC_HE_V2 28
  64. #define AV_PROFILE_AAC_LD 22
  65. #define AV_PROFILE_AAC_ELD 38
  66. #define AV_PROFILE_MPEG2_AAC_LOW 128
  67. #define AV_PROFILE_MPEG2_AAC_HE 131
  68. #define AV_PROFILE_DNXHD 0
  69. #define AV_PROFILE_DNXHR_LB 1
  70. #define AV_PROFILE_DNXHR_SQ 2
  71. #define AV_PROFILE_DNXHR_HQ 3
  72. #define AV_PROFILE_DNXHR_HQX 4
  73. #define AV_PROFILE_DNXHR_444 5
  74. #define AV_PROFILE_DTS 20
  75. #define AV_PROFILE_DTS_ES 30
  76. #define AV_PROFILE_DTS_96_24 40
  77. #define AV_PROFILE_DTS_HD_HRA 50
  78. #define AV_PROFILE_DTS_HD_MA 60
  79. #define AV_PROFILE_DTS_EXPRESS 70
  80. #define AV_PROFILE_DTS_HD_MA_X 61
  81. #define AV_PROFILE_DTS_HD_MA_X_IMAX 62
  82. #define AV_PROFILE_EAC3_DDP_ATMOS 30
  83. #define AV_PROFILE_TRUEHD_ATMOS 30
  84. #define AV_PROFILE_MPEG2_422 0
  85. #define AV_PROFILE_MPEG2_HIGH 1
  86. #define AV_PROFILE_MPEG2_SS 2
  87. #define AV_PROFILE_MPEG2_SNR_SCALABLE 3
  88. #define AV_PROFILE_MPEG2_MAIN 4
  89. #define AV_PROFILE_MPEG2_SIMPLE 5
  90. #define AV_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag
  91. #define AV_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag
  92. #define AV_PROFILE_H264_BASELINE 66
  93. #define AV_PROFILE_H264_CONSTRAINED_BASELINE (66|AV_PROFILE_H264_CONSTRAINED)
  94. #define AV_PROFILE_H264_MAIN 77
  95. #define AV_PROFILE_H264_EXTENDED 88
  96. #define AV_PROFILE_H264_HIGH 100
  97. #define AV_PROFILE_H264_HIGH_10 110
  98. #define AV_PROFILE_H264_HIGH_10_INTRA (110|AV_PROFILE_H264_INTRA)
  99. #define AV_PROFILE_H264_MULTIVIEW_HIGH 118
  100. #define AV_PROFILE_H264_HIGH_422 122
  101. #define AV_PROFILE_H264_HIGH_422_INTRA (122|AV_PROFILE_H264_INTRA)
  102. #define AV_PROFILE_H264_STEREO_HIGH 128
  103. #define AV_PROFILE_H264_HIGH_444 144
  104. #define AV_PROFILE_H264_HIGH_444_PREDICTIVE 244
  105. #define AV_PROFILE_H264_HIGH_444_INTRA (244|AV_PROFILE_H264_INTRA)
  106. #define AV_PROFILE_H264_CAVLC_444 44
  107. #define AV_PROFILE_VC1_SIMPLE 0
  108. #define AV_PROFILE_VC1_MAIN 1
  109. #define AV_PROFILE_VC1_COMPLEX 2
  110. #define AV_PROFILE_VC1_ADVANCED 3
  111. #define AV_PROFILE_MPEG4_SIMPLE 0
  112. #define AV_PROFILE_MPEG4_SIMPLE_SCALABLE 1
  113. #define AV_PROFILE_MPEG4_CORE 2
  114. #define AV_PROFILE_MPEG4_MAIN 3
  115. #define AV_PROFILE_MPEG4_N_BIT 4
  116. #define AV_PROFILE_MPEG4_SCALABLE_TEXTURE 5
  117. #define AV_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6
  118. #define AV_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7
  119. #define AV_PROFILE_MPEG4_HYBRID 8
  120. #define AV_PROFILE_MPEG4_ADVANCED_REAL_TIME 9
  121. #define AV_PROFILE_MPEG4_CORE_SCALABLE 10
  122. #define AV_PROFILE_MPEG4_ADVANCED_CODING 11
  123. #define AV_PROFILE_MPEG4_ADVANCED_CORE 12
  124. #define AV_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13
  125. #define AV_PROFILE_MPEG4_SIMPLE_STUDIO 14
  126. #define AV_PROFILE_MPEG4_ADVANCED_SIMPLE 15
  127. #define AV_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 1
  128. #define AV_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 2
  129. #define AV_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION 32768
  130. #define AV_PROFILE_JPEG2000_DCINEMA_2K 3
  131. #define AV_PROFILE_JPEG2000_DCINEMA_4K 4
  132. #define AV_PROFILE_VP9_0 0
  133. #define AV_PROFILE_VP9_1 1
  134. #define AV_PROFILE_VP9_2 2
  135. #define AV_PROFILE_VP9_3 3
  136. #define AV_PROFILE_HEVC_MAIN 1
  137. #define AV_PROFILE_HEVC_MAIN_10 2
  138. #define AV_PROFILE_HEVC_MAIN_STILL_PICTURE 3
  139. #define AV_PROFILE_HEVC_REXT 4
  140. #define AV_PROFILE_HEVC_SCC 9
  141. #define AV_PROFILE_VVC_MAIN_10 1
  142. #define AV_PROFILE_VVC_MAIN_10_444 33
  143. #define AV_PROFILE_AV1_MAIN 0
  144. #define AV_PROFILE_AV1_HIGH 1
  145. #define AV_PROFILE_AV1_PROFESSIONAL 2
  146. #define AV_PROFILE_MJPEG_HUFFMAN_BASELINE_DCT 0xc0
  147. #define AV_PROFILE_MJPEG_HUFFMAN_EXTENDED_SEQUENTIAL_DCT 0xc1
  148. #define AV_PROFILE_MJPEG_HUFFMAN_PROGRESSIVE_DCT 0xc2
  149. #define AV_PROFILE_MJPEG_HUFFMAN_LOSSLESS 0xc3
  150. #define AV_PROFILE_MJPEG_JPEG_LS 0xf7
  151. #define AV_PROFILE_SBC_MSBC 1
  152. #define AV_PROFILE_PRORES_PROXY 0
  153. #define AV_PROFILE_PRORES_LT 1
  154. #define AV_PROFILE_PRORES_STANDARD 2
  155. #define AV_PROFILE_PRORES_HQ 3
  156. #define AV_PROFILE_PRORES_4444 4
  157. #define AV_PROFILE_PRORES_XQ 5
  158. #define AV_PROFILE_ARIB_PROFILE_A 0
  159. #define AV_PROFILE_ARIB_PROFILE_C 1
  160. #define AV_PROFILE_KLVA_SYNC 0
  161. #define AV_PROFILE_KLVA_ASYNC 1
  162. #define AV_PROFILE_EVC_BASELINE 0
  163. #define AV_PROFILE_EVC_MAIN 1
  164. #define AV_LEVEL_UNKNOWN -99
  165. enum AVFieldOrder {
  166. AV_FIELD_UNKNOWN,
  167. AV_FIELD_PROGRESSIVE,
  168. AV_FIELD_TT, ///< Top coded_first, top displayed first
  169. AV_FIELD_BB, ///< Bottom coded first, bottom displayed first
  170. AV_FIELD_TB, ///< Top coded first, bottom displayed first
  171. AV_FIELD_BT, ///< Bottom coded first, top displayed first
  172. };
  173. /**
  174. * @ingroup lavc_decoding
  175. */
  176. enum AVDiscard{
  177. /* We leave some space between them for extensions (drop some
  178. * keyframes for intra-only or drop just some bidir frames). */
  179. AVDISCARD_NONE =-16, ///< discard nothing
  180. AVDISCARD_DEFAULT = 0, ///< discard useless packets like 0 size packets in avi
  181. AVDISCARD_NONREF = 8, ///< discard all non reference
  182. AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
  183. AVDISCARD_NONINTRA= 24, ///< discard all non intra frames
  184. AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
  185. AVDISCARD_ALL = 48, ///< discard all
  186. };
  187. enum AVAudioServiceType {
  188. AV_AUDIO_SERVICE_TYPE_MAIN = 0,
  189. AV_AUDIO_SERVICE_TYPE_EFFECTS = 1,
  190. AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2,
  191. AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = 3,
  192. AV_AUDIO_SERVICE_TYPE_DIALOGUE = 4,
  193. AV_AUDIO_SERVICE_TYPE_COMMENTARY = 5,
  194. AV_AUDIO_SERVICE_TYPE_EMERGENCY = 6,
  195. AV_AUDIO_SERVICE_TYPE_VOICE_OVER = 7,
  196. AV_AUDIO_SERVICE_TYPE_KARAOKE = 8,
  197. AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI
  198. };
  199. /**
  200. * Pan Scan area.
  201. * This specifies the area which should be displayed.
  202. * Note there may be multiple such areas for one frame.
  203. */
  204. typedef struct AVPanScan {
  205. /**
  206. * id
  207. * - encoding: Set by user.
  208. * - decoding: Set by libavcodec.
  209. */
  210. int id;
  211. /**
  212. * width and height in 1/16 pel
  213. * - encoding: Set by user.
  214. * - decoding: Set by libavcodec.
  215. */
  216. int width;
  217. int height;
  218. /**
  219. * position of the top left corner in 1/16 pel for up to 3 fields/frames
  220. * - encoding: Set by user.
  221. * - decoding: Set by libavcodec.
  222. */
  223. int16_t position[3][2];
  224. } AVPanScan;
  225. /**
  226. * This structure describes the bitrate properties of an encoded bitstream. It
  227. * roughly corresponds to a subset the VBV parameters for MPEG-2 or HRD
  228. * parameters for H.264/HEVC.
  229. */
  230. typedef struct AVCPBProperties {
  231. /**
  232. * Maximum bitrate of the stream, in bits per second.
  233. * Zero if unknown or unspecified.
  234. */
  235. int64_t max_bitrate;
  236. /**
  237. * Minimum bitrate of the stream, in bits per second.
  238. * Zero if unknown or unspecified.
  239. */
  240. int64_t min_bitrate;
  241. /**
  242. * Average bitrate of the stream, in bits per second.
  243. * Zero if unknown or unspecified.
  244. */
  245. int64_t avg_bitrate;
  246. /**
  247. * The size of the buffer to which the ratecontrol is applied, in bits.
  248. * Zero if unknown or unspecified.
  249. */
  250. int64_t buffer_size;
  251. /**
  252. * The delay between the time the packet this structure is associated with
  253. * is received and the time when it should be decoded, in periods of a 27MHz
  254. * clock.
  255. *
  256. * UINT64_MAX when unknown or unspecified.
  257. */
  258. uint64_t vbv_delay;
  259. } AVCPBProperties;
  260. /**
  261. * Allocate a CPB properties structure and initialize its fields to default
  262. * values.
  263. *
  264. * @param size if non-NULL, the size of the allocated struct will be written
  265. * here. This is useful for embedding it in side data.
  266. *
  267. * @return the newly allocated struct or NULL on failure
  268. */
  269. AVCPBProperties *av_cpb_properties_alloc(size_t *size);
  270. /**
  271. * This structure supplies correlation between a packet timestamp and a wall clock
  272. * production time. The definition follows the Producer Reference Time ('prft')
  273. * as defined in ISO/IEC 14496-12
  274. */
  275. typedef struct AVProducerReferenceTime {
  276. /**
  277. * A UTC timestamp, in microseconds, since Unix epoch (e.g, av_gettime()).
  278. */
  279. int64_t wallclock;
  280. int flags;
  281. } AVProducerReferenceTime;
  282. /**
  283. * Encode extradata length to a buffer. Used by xiph codecs.
  284. *
  285. * @param s buffer to write to; must be at least (v/255+1) bytes long
  286. * @param v size of extradata in bytes
  287. * @return number of bytes written to the buffer.
  288. */
  289. unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
  290. #endif // AVCODEC_DEFS_H