1 /* 2 * Codec parameters public API 3 * 4 * This file is part of FFmpeg. 5 * 6 * FFmpeg is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * FFmpeg is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with FFmpeg; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 module ffmpeg.libavcodec.codec_par; 21 22 import ffmpeg.libavcodec; 23 import ffmpeg.libavutil; 24 25 extern (C) @nogc nothrow: 26 27 /** 28 * @addtogroup lavc_core 29 */ 30 31 enum AVFieldOrder 32 { 33 AV_FIELD_UNKNOWN = 0, 34 AV_FIELD_PROGRESSIVE = 1, 35 AV_FIELD_TT = 2, //< Top coded_first, top displayed first 36 AV_FIELD_BB = 3, //< Bottom coded first, bottom displayed first 37 AV_FIELD_TB = 4, //< Top coded first, bottom displayed first 38 AV_FIELD_BT = 5 //< Bottom coded first, top displayed first 39 } 40 41 /** 42 * This struct describes the properties of an encoded stream. 43 * 44 * sizeof(AVCodecParameters) is not a part of the public ABI, this struct must 45 * be allocated with avcodec_parameters_alloc() and freed with 46 * avcodec_parameters_free(). 47 */ 48 struct AVCodecParameters 49 { 50 /** 51 * General type of the encoded data. 52 */ 53 AVMediaType codec_type; 54 /** 55 * Specific type of the encoded data (the codec used). 56 */ 57 AVCodecID codec_id; 58 /** 59 * Additional information about the codec (corresponds to the AVI FOURCC). 60 */ 61 uint codec_tag; 62 63 /** 64 * Extra binary data needed for initializing the decoder, codec-dependent. 65 * 66 * Must be allocated with av_malloc() and will be freed by 67 * avcodec_parameters_free(). The allocated size of extradata must be at 68 * least extradata_size + AV_INPUT_BUFFER_PADDING_SIZE, with the padding 69 * bytes zeroed. 70 */ 71 ubyte* extradata; 72 /** 73 * Size of the extradata content in bytes. 74 */ 75 int extradata_size; 76 77 /** 78 * - video: the pixel format, the value corresponds to enum AVPixelFormat. 79 * - audio: the sample format, the value corresponds to enum AVSampleFormat. 80 */ 81 int format; 82 83 /** 84 * The average bitrate of the encoded data (in bits per second). 85 */ 86 long bit_rate; 87 88 /** 89 * The number of bits per sample in the codedwords. 90 * 91 * This is basically the bitrate per sample. It is mandatory for a bunch of 92 * formats to actually decode them. It's the number of bits for one sample in 93 * the actual coded bitstream. 94 * 95 * This could be for example 4 for ADPCM 96 * For PCM formats this matches bits_per_raw_sample 97 * Can be 0 98 */ 99 int bits_per_coded_sample; 100 101 /** 102 * This is the number of valid bits in each output sample. If the 103 * sample format has more bits, the least significant bits are additional 104 * padding bits, which are always 0. Use right shifts to reduce the sample 105 * to its actual size. For example, audio formats with 24 bit samples will 106 * have bits_per_raw_sample set to 24, and format set to AV_SAMPLE_FMT_S32. 107 * To get the original sample use "(int32_t)sample >> 8"." 108 * 109 * For ADPCM this might be 12 or 16 or similar 110 * Can be 0 111 */ 112 int bits_per_raw_sample; 113 114 /** 115 * Codec-specific bitstream restrictions that the stream conforms to. 116 */ 117 int profile; 118 int level; 119 120 /** 121 * Video only. The dimensions of the video frame in pixels. 122 */ 123 int width; 124 int height; 125 126 /** 127 * Video only. The aspect ratio (width / height) which a single pixel 128 * should have when displayed. 129 * 130 * When the aspect ratio is unknown / undefined, the numerator should be 131 * set to 0 (the denominator may have any value). 132 */ 133 AVRational sample_aspect_ratio; 134 135 /** 136 * Video only. The order of the fields in interlaced video. 137 */ 138 AVFieldOrder field_order; 139 140 /** 141 * Video only. Additional colorspace characteristics. 142 */ 143 AVColorRange color_range; 144 AVColorPrimaries color_primaries; 145 AVColorTransferCharacteristic color_trc; 146 AVColorSpace color_space; 147 AVChromaLocation chroma_location; 148 149 /** 150 * Video only. Number of delayed frames. 151 */ 152 int video_delay; 153 154 /** 155 * Audio only. The channel layout bitmask. May be 0 if the channel layout is 156 * unknown or unspecified, otherwise the number of bits set must be equal to 157 * the channels field. 158 */ 159 ulong channel_layout; 160 /** 161 * Audio only. The number of audio channels. 162 */ 163 int channels; 164 /** 165 * Audio only. The number of audio samples per second. 166 */ 167 int sample_rate; 168 /** 169 * Audio only. The number of bytes per coded audio frame, required by some 170 * formats. 171 * 172 * Corresponds to nBlockAlign in WAVEFORMATEX. 173 */ 174 int block_align; 175 /** 176 * Audio only. Audio frame size, if known. Required by some formats to be static. 177 */ 178 int frame_size; 179 180 /** 181 * Audio only. The amount of padding (in samples) inserted by the encoder at 182 * the beginning of the audio. I.e. this number of leading decoded samples 183 * must be discarded by the caller to get the original audio without leading 184 * padding. 185 */ 186 int initial_padding; 187 /** 188 * Audio only. The amount of padding (in samples) appended by the encoder to 189 * the end of the audio. I.e. this number of decoded samples must be 190 * discarded by the caller from the end of the stream to get the original 191 * audio without any trailing padding. 192 */ 193 int trailing_padding; 194 /** 195 * Audio only. Number of samples to skip after a discontinuity. 196 */ 197 int seek_preroll; 198 } 199 200 /** 201 * Allocate a new AVCodecParameters and set its fields to default values 202 * (unknown/invalid/0). The returned struct must be freed with 203 * avcodec_parameters_free(). 204 */ 205 AVCodecParameters* avcodec_parameters_alloc (); 206 207 /** 208 * Free an AVCodecParameters instance and everything associated with it and 209 * write NULL to the supplied pointer. 210 */ 211 void avcodec_parameters_free (AVCodecParameters** par); 212 213 /** 214 * Copy the contents of src to dst. Any allocated fields in dst are freed and 215 * replaced with newly allocated duplicates of the corresponding fields in src. 216 * 217 * @return >= 0 on success, a negative AVERROR code on failure. 218 */ 219 int avcodec_parameters_copy (AVCodecParameters* dst, const(AVCodecParameters)* src); 220 221 /** 222 * @} 223 */ 224 225 // AVCODEC_CODEC_PAR_H