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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. /**
  57. * @ingroup lavc_decoding
  58. */
  59. enum AVDiscard{
  60. /* We leave some space between them for extensions (drop some
  61. * keyframes for intra-only or drop just some bidir frames). */
  62. AVDISCARD_NONE =-16, ///< discard nothing
  63. AVDISCARD_DEFAULT = 0, ///< discard useless packets like 0 size packets in avi
  64. AVDISCARD_NONREF = 8, ///< discard all non reference
  65. AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
  66. AVDISCARD_NONINTRA= 24, ///< discard all non intra frames
  67. AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
  68. AVDISCARD_ALL = 48, ///< discard all
  69. };
  70. enum AVAudioServiceType {
  71. AV_AUDIO_SERVICE_TYPE_MAIN = 0,
  72. AV_AUDIO_SERVICE_TYPE_EFFECTS = 1,
  73. AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2,
  74. AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = 3,
  75. AV_AUDIO_SERVICE_TYPE_DIALOGUE = 4,
  76. AV_AUDIO_SERVICE_TYPE_COMMENTARY = 5,
  77. AV_AUDIO_SERVICE_TYPE_EMERGENCY = 6,
  78. AV_AUDIO_SERVICE_TYPE_VOICE_OVER = 7,
  79. AV_AUDIO_SERVICE_TYPE_KARAOKE = 8,
  80. AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI
  81. };
  82. /**
  83. * Pan Scan area.
  84. * This specifies the area which should be displayed.
  85. * Note there may be multiple such areas for one frame.
  86. */
  87. typedef struct AVPanScan {
  88. /**
  89. * id
  90. * - encoding: Set by user.
  91. * - decoding: Set by libavcodec.
  92. */
  93. int id;
  94. /**
  95. * width and height in 1/16 pel
  96. * - encoding: Set by user.
  97. * - decoding: Set by libavcodec.
  98. */
  99. int width;
  100. int height;
  101. /**
  102. * position of the top left corner in 1/16 pel for up to 3 fields/frames
  103. * - encoding: Set by user.
  104. * - decoding: Set by libavcodec.
  105. */
  106. int16_t position[3][2];
  107. } AVPanScan;
  108. /**
  109. * This structure describes the bitrate properties of an encoded bitstream. It
  110. * roughly corresponds to a subset the VBV parameters for MPEG-2 or HRD
  111. * parameters for H.264/HEVC.
  112. */
  113. typedef struct AVCPBProperties {
  114. /**
  115. * Maximum bitrate of the stream, in bits per second.
  116. * Zero if unknown or unspecified.
  117. */
  118. int64_t max_bitrate;
  119. /**
  120. * Minimum bitrate of the stream, in bits per second.
  121. * Zero if unknown or unspecified.
  122. */
  123. int64_t min_bitrate;
  124. /**
  125. * Average bitrate of the stream, in bits per second.
  126. * Zero if unknown or unspecified.
  127. */
  128. int64_t avg_bitrate;
  129. /**
  130. * The size of the buffer to which the ratecontrol is applied, in bits.
  131. * Zero if unknown or unspecified.
  132. */
  133. int64_t buffer_size;
  134. /**
  135. * The delay between the time the packet this structure is associated with
  136. * is received and the time when it should be decoded, in periods of a 27MHz
  137. * clock.
  138. *
  139. * UINT64_MAX when unknown or unspecified.
  140. */
  141. uint64_t vbv_delay;
  142. } AVCPBProperties;
  143. /**
  144. * Allocate a CPB properties structure and initialize its fields to default
  145. * values.
  146. *
  147. * @param size if non-NULL, the size of the allocated struct will be written
  148. * here. This is useful for embedding it in side data.
  149. *
  150. * @return the newly allocated struct or NULL on failure
  151. */
  152. AVCPBProperties *av_cpb_properties_alloc(size_t *size);
  153. /**
  154. * This structure supplies correlation between a packet timestamp and a wall clock
  155. * production time. The definition follows the Producer Reference Time ('prft')
  156. * as defined in ISO/IEC 14496-12
  157. */
  158. typedef struct AVProducerReferenceTime {
  159. /**
  160. * A UTC timestamp, in microseconds, since Unix epoch (e.g, av_gettime()).
  161. */
  162. int64_t wallclock;
  163. int flags;
  164. } AVProducerReferenceTime;
  165. /**
  166. * Encode extradata length to a buffer. Used by xiph codecs.
  167. *
  168. * @param s buffer to write to; must be at least (v/255+1) bytes long
  169. * @param v size of extradata in bytes
  170. * @return number of bytes written to the buffer.
  171. */
  172. unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
  173. #endif // AVCODEC_DEFS_H