赞
踩
目录
FFMPEG中结构体很多。最关键的结构体可以分成以下几类:
a) 解协议(http,rtsp,rtmp,mms)
AVIOContext,URLProtocol,URLContext主要存储视音频使用的协议的类型以及状态。URLProtocol存储输入视音频使用的封装格式。每种协议都对应一个URLProtocol结构。(注意:FFMPEG中文件也被当做一种协议“file”)
b) 解封装(flv,avi,rmvb,mp4)
AVFormatContext主要存储视音频封装格式中包含的信息;AVInputFormat存储输入视音频使用的封装格式。每种视音频封装格式都对应一个AVInputFormat 结构。
c) 解码(h264,mpeg2,aac,mp3)
每个AVStream存储一个视频/音频流的相关数据;每个AVStream对应一个AVCodecContext,存储该视频/音频流使用解码方式的相关数据;每个AVCodecContext中对应一个AVCodec,包含该视频/音频对应的解码器。每种解码器都对应一个AVCodec结构。
d) 存数据
视频的话,每个结构一般是存一帧;音频可能有好几帧
解码前数据:AVPacket
解码后数据:AVFrame
- /*
- *雷霄骅
- *leixiaohua1020@126.com
- *中国传媒大学/数字电视技术
- */
- /**
- * Audio Video Frame.
- * New fields can be added to the end of AVFRAME with minor version
- * bumps. Similarly fields that are marked as to be only accessed by
- * av_opt_ptr() can be reordered. This allows 2 forks to add fields
- * without breaking compatibility with each other.
- * Removal, reordering and changes in the remaining cases require
- * a major version bump.
- * sizeof(AVFrame) must not be used outside libavcodec.
- */
- typedef struct AVFrame {
- #define AV_NUM_DATA_POINTERS 8
- /**图像数据
- * pointer to the picture/channel planes.
- * This might be different from the first allocated byte
- * - encoding: Set by user
- * - decoding: set by AVCodecContext.get_buffer()
- */
- //解码后原始数据,针对视频可能是(YUV,RGB),音频的数据为(PCM)
- uint8_t *data[AV_NUM_DATA_POINTERS];
-
- /**
- * Size, in bytes, of the data for each picture/channel plane.
- *
- * For audio, only linesize[0] may be set. For planar audio, each channel
- * plane must be the same size.
- *
- * - encoding: Set by user
- * - decoding: set by AVCodecContext.get_buffer()
- */
- // data中每行数据的大小
- int linesize[AV_NUM_DATA_POINTERS];
-
- /**
- * pointers to the data planes/channels.
- *
- * For video, this should simply point to data[].
- *
- * For planar audio, each channel has a separate data pointer, and
- * linesize[0] contains the size of each channel buffer.
- * For packed audio, there is just one data pointer, and linesize[0]
- * contains the total size of the buffer for all channels.
- *
- * Note: Both data and extended_data will always be set by get_buffer(),
- * but for planar audio with more channels that can fit in data,
- * extended_data must be used by the decoder in order to access all
- * channels.
- *
- * encoding: unused
- * decoding: set by AVCodecContext.get_buffer()
- */
- //扩展数据,指向数据平面/通道指针,对于音频的舒缓每个通道一个但对于的数据指针
- //对于视频数据应该指向data[]
- uint8_t **extended_data;
-
- /**宽高
- * width and height of the video frame
- * - encoding: unused
- * - decoding: Read by user.
- */
- //视频数据的宽度和高度
- int width, height;
-
- /**
- * number of audio samples (per channel) described by this frame
- * - encoding: Set by user
- * - decoding: Set by libavcodec
- */
- //音频的一个AVframe中的包含多个视频帧
- int nb_samples;
-
- /**
- * format of the frame, -1 if unknown or unset
- * Values correspond to enum AVPixelFormat for video frames,
- * enum AVSampleFormat for audio)
- * - encoding: unused
- * - decoding: Read by user.
- */
- // 解码后原始数据的类型(YUV420,yuv422,RBG24)
- int format;
-
- /**
- * 1 -> keyframe, 0-> not
- * - encoding: Set by libavcodec.
- * - decoding: Set by libavcodec.
- */
-
- //是否是关键帧
- int key_frame;
-
- /**帧类型(I,B,P)
- * Picture type of the frame, see ?_TYPE below.
- * - encoding: Set by libavcodec. for coded_picture (and set by user for input).
- * - decoding: Set by libavcodec.
- */
- // 视频数据帧的类型
- enum AVPictureType pict_type;
-
- /**
- * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.
- * This isn't used by libavcodec unless the default get/release_buffer() is used.
- * - encoding:
- * - decoding:
- */
- uint8_t *base[AV_NUM_DATA_POINTERS];
-
- /**
- * sample aspect ratio for the video frame, 0/1 if unknown/unspecified
- * - encoding: unused
- * - decoding: Read by user.
- */
- //视频数据宽高的比率
- AVRational sample_aspect_ratio;
-
- /**
- * presentation timestamp in time_base units (time when frame should be shown to user)
- * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed.
- * - encoding: MUST be set by user.
- * - decoding: Set by libavcodec.
- */
- // 显示事件戳
- int64_t pts;
-
- /**
- * reordered pts from the last AVPacket that has been input into the decoder
- * - encoding: unused
- * - decoding: Read by user.
- */
- //
- int64_t pkt_pts;
-
- /**
- * dts from the last AVPacket that has been input into the decoder
- * - encoding: unused
- * - decoding: Read by user.
- */
- int64_t pkt_dts;
-
- /**
- * picture number in bitstream order
- * - encoding: set by
- * - decoding: Set by libavcodec.
- */
- int coded_picture_number;
- /**
- * picture number in display order
- * - encoding: set by
- * - decoding: Set by libavcodec.
- */
- int display_picture_number;
-
- /**
- * quality (between 1 (good) and FF_LAMBDA_MAX (bad))
- * - encoding: Set by libavcodec. for coded_picture (and set by user for input).
- * - decoding: Set by libavcodec.
- */
- int quality;
-
- /**
- * is this picture used as reference
- * The values for this are the same as the MpegEncContext.picture_structure
- * variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
- * Set to 4 for delayed, non-reference frames.
- * - encoding: unused
- * - decoding: Set by libavcodec. (before get_buffer() call)).
- */
- int reference;
-
- /**QP表
- * QP table
- * - encoding: unused
- * - decoding: Set by libavcodec.
- */
- int8_t *qscale_table;
- /**
- * QP store stride
- * - encoding: unused
- * - decoding: Set by libavcodec.
- */
- int qstride;
-
- /**
- *
- */
- int qscale_type;
-
- /**跳过宏块表
- * mbskip_table[mb]>=1 if MB didn't change
- * stride= mb_width = (width+15)>>4
- * - encoding: unused
- * - decoding: Set by libavcodec.
- */
- uint8_t *mbskip_table;
-
- /**运动矢量表
- * motion vector table
- * @code
- * example:
- * int mv_sample_log2= 4 - motion_subsample_log2;
- * int mb_width= (width+15)>>4;
- * int mv_stride= (mb_width << mv_sample_log2) + 1;
- * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];
- * @endcode
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- int16_t (*motion_val[2])[2];
-
- /**宏块类型表
- * macroblock type table
- * mb_type_base + mb_width + 2
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- uint32_t *mb_type;
-
- /**DCT系数
- * DCT coefficients
- * - encoding: unused
- * - decoding: Set by libavcodec.
- */
- short *dct_coeff;
-
- /**参考帧列表
- * motion reference frame index
- * the order in which these are stored can depend on the codec.
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- int8_t *ref_index[2];
-
- /**
- * for some private data of the user
- * - encoding: unused
- * - decoding: Set by user.
- */
- void *opaque;
-
- /**
- * error
- * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.
- * - decoding: unused
- */
- uint64_t error[AV_NUM_DATA_POINTERS];
-
- /**
- * type of the buffer (to keep track of who has to deallocate data[*])
- * - encoding: Set by the one who allocates it.
- * - decoding: Set by the one who allocates it.
- * Note: User allocated (direct rendering) & internal buffers cannot coexist currently.
- */
- int type;
-
- /**
- * When decoding, this signals how much the picture must be delayed.
- * extra_delay = repeat_pict / (2*fps)
- * - encoding: unused
- * - decoding: Set by libavcodec.
- */
- int repeat_pict;
-
- /**
- * The content of the picture is interlaced.
- * - encoding: Set by user.
- * - decoding: Set by libavcodec. (default 0)
- */
- int interlaced_frame;
-
- /**
- * If the content is interlaced, is top field displayed first.
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- int top_field_first;
-
- /**
- * Tell user application that palette has changed from previous frame.
- * - encoding: ??? (no palette-enabled encoder yet)
- * - decoding: Set by libavcodec. (default 0).
- */
- int palette_has_changed;
-
- /**
- * codec suggestion on buffer type if != 0
- * - encoding: unused
- * - decoding: Set by libavcodec. (before get_buffer() call)).
- */
- int buffer_hints;
-
- /**
- * Pan scan.
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- AVPanScan *pan_scan;
-
- /**
- * reordered opaque 64bit (generally an integer or a double precision float
- * PTS but can be anything).
- * The user sets AVCodecContext.reordered_opaque to represent the input at
- * that time,
- * the decoder reorders values as needed and sets AVFrame.reordered_opaque
- * to exactly one of the values provided by the user through AVCodecContext.reordered_opaque
- * @deprecated in favor of pkt_pts
- * - encoding: unused
- * - decoding: Read by user.
- */
- int64_t reordered_opaque;
-
- /**
- * hardware accelerator private data (FFmpeg-allocated)
- * - encoding: unused
- * - decoding: Set by libavcodec
- */
- void *hwaccel_picture_private;
-
- /**
- * the AVCodecContext which ff_thread_get_buffer() was last called on
- * - encoding: Set by libavcodec.
- * - decoding: Set by libavcodec.
- */
- struct AVCodecContext *owner;
-
- /**
- * used by multithreading to store frame-specific info
- * - encoding: Set by libavcodec.
- * - decoding: Set by libavcodec.
- */
- void *thread_opaque;
-
- /**
- * log2 of the size of the block which a single vector in motion_val represents:
- * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)
- * - encoding: unused
- * - decoding: Set by libavcodec.
- */
- uint8_t motion_subsample_log2;
-
- /**(音频)采样率
- * Sample rate of the audio data.
- *
- * - encoding: unused
- * - decoding: read by user
- */
- int sample_rate;
-
- /**
- * Channel layout of the audio data.
- *
- * - encoding: unused
- * - decoding: read by user.
- */
- uint64_t channel_layout;
-
- /**
- * frame timestamp estimated using various heuristics, in stream time base
- * Code outside libavcodec should access this field using:
- * av_frame_get_best_effort_timestamp(frame)
- * - encoding: unused
- * - decoding: set by libavcodec, read by user.
- */
- int64_t best_effort_timestamp;
-
- /**
- * reordered pos from the last AVPacket that has been input into the decoder
- * Code outside libavcodec should access this field using:
- * av_frame_get_pkt_pos(frame)
- * - encoding: unused
- * - decoding: Read by user.
- */
- int64_t pkt_pos;
-
- /**
- * duration of the corresponding packet, expressed in
- * AVStream->time_base units, 0 if unknown.
- * Code outside libavcodec should access this field using:
- * av_frame_get_pkt_duration(frame)
- * - encoding: unused
- * - decoding: Read by user.
- */
- int64_t pkt_duration;
-
- /**
- * metadata.
- * Code outside libavcodec should access this field using:
- * av_frame_get_metadata(frame)
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- AVDictionary *metadata;
-
- /**
- * decode error flags of the frame, set to a combination of
- * FF_DECODE_ERROR_xxx flags if the decoder produced a frame, but there
- * were errors during the decoding.
- * Code outside libavcodec should access this field using:
- * av_frame_get_decode_error_flags(frame)
- * - encoding: unused
- * - decoding: set by libavcodec, read by user.
- */
- int decode_error_flags;
- #define FF_DECODE_ERROR_INVALID_BITSTREAM 1
- #define FF_DECODE_ERROR_MISSING_REFERENCE 2
-
- /**
- * number of audio channels, only used for audio.
- * Code outside libavcodec should access this field using:
- * av_frame_get_channels(frame)
- * - encoding: unused
- * - decoding: Read by user.
- */
- int64_t channels;
- } AVFrame;
- typedef struct AVPacket {
- //对数据包数据所在数缓冲区的引用
- AVBufferRef *buf;
- /**
- * Presentation timestamp in AVStream->time_base units; the time at which
- * the decompressed packet will be presented to the user.
- * Can be AV_NOPTS_VALUE if it is not stored in the file.
- * pts MUST be larger or equal to dts as presentation cannot happen before
- * decompression, unless one wants to view hex dumps. Some formats misuse
- * the terms dts and pts/cts to mean something different. Such timestamps
- * must be converted to true pts/dts before they are stored in AVPacket.
- */
- // 显示时间戳
- int64_t pts;
- /**
- * Decompression timestamp in AVStream->time_base units; the time at which
- * the packet is decompressed.
- * Can be AV_NOPTS_VALUE if it is not stored in the file.
- */
- // 解码事件戳
- int64_t dts;
- //保存压缩数据的指针
- uint8_t *data;
- //压缩收据的大小
- int size;
- // 包存在数据的的数据流的ID
- int stream_index;
- /**
- * A combination of AV_PKT_FLAG values
- */
- // 数据为最低为1表示该数据为的关键帧率
- int flags;
- /**
- * Additional packet data that can be provided by the container.
- * Packet can contain several types of side information.
- */
- AVPacketSideData *side_data;
- int side_data_elems;
-
-
- //单位数据包的持续时间
- int64_t duration;
- //在数据流中的具体位置
- int64_t pos; ///< byte position in stream, -1 if unknown
-
- //保存用户的私有数据
- void *opaque;
-
- /**
- * AVBufferRef for free use by the API user. FFmpeg will never check the
- * contents of the buffer ref. FFmpeg calls av_buffer_unref() on it when
- * the packet is unreferenced. av_packet_copy_props() calls create a new
- * reference with av_buffer_ref() for the target packet's opaque_ref field.
- *
- * This is unrelated to the opaque field, although it serves a similar
- * purpose.
- */
- AVBufferRef *opaque_ref;
-
- /**
- * Time base of the packet's timestamps.
- * In the future, this field may be set on packets output by encoders or
- * demuxers, but its value will be by default ignored on input to decoders
- * or muxers.
- */
- // 数据包的时间基
- AVRational time_base;
- } AVPacket;
- typedef struct AVBufferRef {
- AVBuffer *buffer;
-
- /**
- * The data buffer. It is considered writable if and only if
- * this is the only reference to the buffer, in which case
- * av_buffer_is_writable() returns 1.
- */
- uint8_t *data;
- /**
- * Size of data in bytes.
- */
- size_t size;
- } AVBufferRef;
AVBuffer:数据缓冲区
- struct AVBuffer {
- //指向一段长度为size的neicun
- uint8_t *data; /**< data described by this buffer */
- size_t size; /**< size of data in bytes */
-
- // 引用计数,表示有多山个AVBufferRef对象引用了自己
- atomic_uint refcount;
-
- /**
- * a callback for freeing the data
- */
- void (*free)(void *opaque, uint8_t *data);
-
- //一个指针,指向一个用户自定义类型的对象,也可为空,FFmpeg 不关心。
-
- void *opaque;
-
- //一些辅助自身状态的标志变量
- int flags;
- int flags_internal;
- };
此结构包含了一个视频流的格式内容。其中AVInputFormat或者AVOutputFormat,但是同一时间AVFormatContext内只能存在其中一个),AVStream,AVPacket这几个重要的结构以及一些其他信息,比如title,author,copyright等,后还有一些可能在编解码中会用到的信息,比如 duration、file_size、 bit_rate等。
- typedef struct AVFormatContext
- {
- /**
- * A class for logging and @ref avoptions. Set by avformat_alloc_context().
- * Exports (de)muxer private options if they exist.
- */
- const AVClass *av_class;
-
- // 输入容器的格式
- // avformat_open_input() 设置
- ff_const59 struct AVInputFormat *iformat;
-
- // 输出容器的个数
- // avformat_write_header()设置
- ff_const59 struct AVOutputFormat *oformat;
-
- // * - muxing: set by avformat_write_header()
- // * - demuxing: set by avformat_open_input()
- // 格式私有数据
- void *priv_data;
-
- // I/O context. 在解复用时候,在avformat_open_input()调用之前设置
- AVIOContext *pb;
-
- // 流信息
- int ctx_flags;
-
- // 流的数量
- unsigned int nb_streams;
-
- // 文件流的链表
- AVStream **streams;
-
- #if FF_API_FORMAT_FILENAME
- // 流所属的文件名
- char filename[1024];
- #endif
-
- // 流的url地址
- char *url;
-
- // 开始帧的位置,只有在解复用的时候用到
- int64_t start_time;
-
- // 流的时长
- int64_t duration;
-
- // 整个流的比特率
- int64_t bit_rate;
- // 整个packet的大小
- unsigned int packet_size;
- // 最大的延迟
- int max_delay;
-
- // 解码器的状态
- int flags;
- #define AVFMT_FLAG_GENPTS 0x0001 ///< Generate missing pts even if it requires parsing future frames.
- #define AVFMT_FLAG_IGNIDX 0x0002 ///< Ignore index.
- #define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets from input.
- #define AVFMT_FLAG_IGNDTS 0x0008 ///< Ignore DTS on frames that contain both DTS & PTS
- #define AVFMT_FLAG_NOFILLIN 0x0010 ///< Do not infer any values from other values, just return what is stored in the container
- #define AVFMT_FLAG_NOPARSE 0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the fillin code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled
- #define AVFMT_FLAG_NOBUFFER 0x0040 ///< Do not buffer frames when possible
- #define AVFMT_FLAG_CUSTOM_IO 0x0080 ///< The caller has supplied a custom AVIOContext, don't avio_close() it.
- #define AVFMT_FLAG_DISCARD_CORRUPT 0x0100 ///< Discard frames marked corrupted
- #define AVFMT_FLAG_FLUSH_PACKETS 0x0200 ///< Flush the AVIOContext every packet.
- /**
- * When muxing, try to avoid writing any random/volatile data to the output.
- * This includes any random IDs, real-time timestamps/dates, muxer version, etc.
- *
- * This flag is mainly intended for testing.
- */
- #define AVFMT_FLAG_BITEXACT 0x0400
- #if FF_API_LAVF_MP4A_LATM
- #define AVFMT_FLAG_MP4A_LATM 0x8000 ///< Deprecated, does nothing.
- #endif
- #define AVFMT_FLAG_SORT_DTS 0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down)
- #if FF_API_LAVF_PRIV_OPT
- #define AVFMT_FLAG_PRIV_OPT 0x20000 ///< Enable use of private options by delaying codec open (deprecated, will do nothing once av_demuxer_open() is removed)
- #endif
- #if FF_API_LAVF_KEEPSIDE_FLAG
- #define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Deprecated, does nothing.
- #endif
- #define AVFMT_FLAG_FAST_SEEK 0x80000 ///< Enable fast, but inaccurate seeks for some formats
- #define AVFMT_FLAG_SHORTEST 0x100000 ///< Stop muxing when the shortest stream stops.
- #define AVFMT_FLAG_AUTO_BSF 0x200000 ///< Add bitstream filters as requested by the muxer
-
- // 从输入中读取最大字节数用来确定流的属性
- int64_t probesize;
-
- // 读取数据的最大持续时间
- int64_t max_analyze_duration;
-
- const uint8_t *key;
- int keylen;
-
- unsigned int nb_programs;
- AVProgram **programs;
-
- // 视屏编码数据编码器类型 Id
- enum AVCodecID video_codec_id;
-
- // 音频编码器的类型 Id
- enum AVCodecID audio_codec_id;
-
- // 字幕类型编码器的 ID
- enum AVCodecID subtitle_codec_id;
-
- // 每条流中最大内存字节数
- unsigned int max_index_size;
-
- // Buffering frames的最大内存字节数
- unsigned int max_picture_buffer;
-
- // AVChapters array的chapters的数量
- unsigned int nb_chapters;
- AVChapter **chapters;
-
- /**
- * Metadata that applies to the whole file.
- *
- * - demuxing: set by libavformat in avformat_open_input()
- * - muxing: may be set by the caller before avformat_write_header()
- *
- * Freed by libavformat in avformat_free_context().
- */
- // 元数据,应用整个数据过程
- AVDictionary *metadata;
-
- // 起始时间,从PTS=0开始
- int64_t start_time_realtime;
-
- // 帧率
- int fps_probe_size;
-
- // 错误检测
- int error_recognition;
-
- /**
- * Custom interrupt callbacks for the I/O layer.
- *
- * demuxing: set by the user before avformat_open_input().
- * muxing: set by the user before avformat_write_header()
- * (mainly useful for AVFMT_NOFILE formats). The callback
- * should also be passed to avio_open2() if it's used to
- * open the file.
- */
- AVIOInterruptCB interrupt_callback;
-
- /**
- * Flags to enable debugging.
- */
- int debug;
- #define FF_FDEBUG_TS 0x0001
-
- /**
- * Maximum buffering duration for interleaving.
- *
- * To ensure all the streams are interleaved correctly,
- * av_interleaved_write_frame() will wait until it has at least one packet
- * for each stream before actually writing any packets to the output file.
- * When some streams are "sparse" (i.e. there are large gaps between
- * successive packets), this can result in excessive buffering.
- *
- * This field specifies the maximum difference between the timestamps of the
- * first and the last packet in the muxing queue, above which libavformat
- * will output a packet regardless of whether it has queued a packet for all
- * the streams.
- *
- * Muxing only, set by the caller before avformat_write_header().
- */
- int64_t max_interleave_delta;
-
- /**
- * Allow non-standard and experimental extension
- * @see AVCodecContext.strict_std_compliance
- */
- int strict_std_compliance;
-
- /**
- * Flags indicating events happening on the file, a combination of
- * AVFMT_EVENT_FLAG_*.
- *
- * - demuxing: may be set by the demuxer in avformat_open_input(),
- * avformat_find_stream_info() and av_read_frame(). Flags must be cleared
- * by the user once the event has been handled.
- * - muxing: may be set by the user after avformat_write_header() to
- * indicate a user-triggered event. The muxer will clear the flags for
- * events it has handled in av_[interleaved]_write_frame().
- */
- int event_flags;
- /**
- * - demuxing: the demuxer read new metadata from the file and updated
- * AVFormatContext.metadata accordingly
- * - muxing: the user updated AVFormatContext.metadata and wishes the muxer to
- * write it into the file
- */
- #define AVFMT_EVENT_FLAG_METADATA_UPDATED 0x0001
-
- /**
- * Maximum number of packets to read while waiting for the first timestamp.
- * Decoding only.
- */
- int max_ts_probe;
-
- /**
- * Avoid negative timestamps during muxing.
- * Any value of the AVFMT_AVOID_NEG_TS_* constants.
- * Note, this only works when using av_interleaved_write_frame. (interleave_packet_per_dts is in use)
- * - muxing: Set by user
- * - demuxing: unused
- */
- int avoid_negative_ts;
- #define AVFMT_AVOID_NEG_TS_AUTO -1 ///< Enabled when required by target format
- #define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE 1 ///< Shift timestamps so they are non negative
- #define AVFMT_AVOID_NEG_TS_MAKE_ZERO 2 ///< Shift timestamps so that they start at 0
-
- // 数据传输过程中的流ID
- int ts_id;
-
- // 音视频提前加载,不是所有格式都支持
- int audio_preload;
-
- // 最大chunk时长,不是所有格式都支持
- int max_chunk_duration;
-
- // 最大chunk以字节为单位
- int max_chunk_size;
-
- // 强制使用wallclock时间戳作为数据包的pts/dts
- int use_wallclock_as_timestamps;
-
- /**
- * avio flags, used to force AVIO_FLAG_DIRECT.
- * - encoding: unused
- * - decoding: Set by user
- */
- int avio_flags;
-
- // 可以通过不同的方式估计持续时间字段
- enum AVDurationEstimationMethod duration_estimation_method;
-
- // 当字节流打开流的时候,跳过初始化字节
- int64_t skip_initial_bytes;
-
- // 纠正单个时间戳的溢出
- unsigned int correct_ts_overflow;
-
- // 强制seek到任意一帧
- int seek2any;
-
- // 在每个packet之后
- int flush_packets;
-
- // 格式探测评分
- int probe_score;
-
- // 读取最大的字节数来确定格式
- int format_probesize;
-
- // 由','分隔的所有可用的decoder(解码器)
- char *codec_whitelist;
-
- // 由‘,’分隔的所有可用的demuxers(解复用器)
- char *format_whitelist;
-
- // libavformat内部私有成员
- AVFormatInternal *internal;
-
- // I/O 更改的标志
- int io_repositioned;
-
- // 特殊解码器或者相同codec_id的视频Codec
- AVCodec *video_codec;
-
- // 特殊解码器或者相同codec_id的音频Codec
- AVCodec *audio_codec;
-
- // 特殊解码器或者相同codec_id的字幕Codec
- AVCodec *subtitle_codec;
-
- // 特殊解码器或者相同codec_id的数据Codec
- AVCodec *data_codec;
-
- /**
- * Number of bytes to be written as padding in a metadata header.
- * Demuxing: Unused.
- * Muxing: Set by user via av_format_set_metadata_header_padding.
- */
- int metadata_header_padding;
-
- // 用户私有数据
- void *opaque;
-
- /**
- * Callback used by devices to communicate with application.
- */
- av_format_control_message control_message_cb;
-
- /**
- * Output timestamp offset, in microseconds.
- * Muxing: set by user
- */
- int64_t output_ts_offset;
-
- /**
- * dump format separator.
- * can be ", " or "\n " or anything else
- * - muxing: Set by user.
- * - demuxing: Set by user.
- */
- uint8_t *dump_separator;
-
- /**
- * Forced Data codec_id.
- * Demuxing: Set by user.
- */
- enum AVCodecID data_codec_id;
-
- #if FF_API_OLD_OPEN_CALLBACKS
- /**
- * Called to open further IO contexts when needed for demuxing.
- *
- * This can be set by the user application to perform security checks on
- * the URLs before opening them.
- * The function should behave like avio_open2(), AVFormatContext is provided
- * as contextual information and to reach AVFormatContext.opaque.
- *
- * If NULL then some simple checks are used together with avio_open2().
- *
- * Must not be accessed directly from outside avformat.
- * @See av_format_set_open_cb()
- *
- * Demuxing: Set by user.
- *
- * @deprecated Use io_open and io_close.
- */
- attribute_deprecated int (*open_cb)(struct AVFormatContext *s, AVIOContext **p, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options);
- #endif
-
- /**
- * ',' separated list of allowed protocols.
- * - encoding: unused
- * - decoding: set by user
- */
- // 协议白名单
- char *protocol_whitelist;
-
- /**
- * A callback for opening new IO streams.
- *
- * Whenever a muxer or a demuxer needs to open an IO stream (typically from
- * avformat_open_input() for demuxers, but for certain formats can happen at
- * other times as well), it will call this callback to obtain an IO context.
- *
- * @param s the format context
- * @param pb on success, the newly opened IO context should be returned here
- * @param url the url to open
- * @param flags a combination of AVIO_FLAG_*
- * @param options a dictionary of additional options, with the same
- * semantics as in avio_open2()
- * @return 0 on success, a negative AVERROR code on failure
- *
- * @note Certain muxers and demuxers do nesting, i.e. they open one or more
- * additional internal format contexts. Thus the AVFormatContext pointer
- * passed to this callback may be different from the one facing the caller.
- * It will, however, have the same 'opaque' field.
- */
- int (*io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url,
- int flags, AVDictionary **options);
-
- /**
- * A callback for closing the streams opened with AVFormatContext.io_open().
- */
- void (*io_close)(struct AVFormatContext *s, AVIOContext *pb);
-
- // 协议的黑名单
- char *protocol_blacklist;
-
- // 流的最大数量
- int max_streams;
-
- /**
- * Skip duration calcuation in estimate_timings_from_pts.
- * - encoding: unused
- * - decoding: set by user
- */
- int skip_estimate_duration_from_pts;
-
- // 多少个packet用于检测
- int max_probe_packets;
- } AVFormatContext;
VInputFormat
是解复用器(解封装)作用时读取媒体文件并将其拆分为数据块(数据包)。每个数据包,包含一个或者多个编码帧
- typedef struct AVInputFormat
- {
- // 封装格式的短名
- const char *name;
-
- // 封装格式的长名字
- const char *long_name;
-
- /**
- * Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS,
- * AVFMT_NOTIMESTAMPS, AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH,
- * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK, AVFMT_SEEK_TO_PTS.
- */
- int flags;
-
- // 如果扩展被定义就不会进行类型格式的探查
- const char *extensions;
- // 编码器标签
- const struct AVCodecTag *const *codec_tag;
- // 私有数据
- const AVClass *priv_class; ///< AVClass for the private context
-
- // mime类型,比如video/avc,在probing(探测)时候需要检查
- const char *mime_type;
-
- /*****************************************************************
- * No fields below this line are part of the public API. They
- * may not be used outside of libavformat and can be changed and
- * removed at will.
- * New public fields should be added right above.
- *****************************************************************
- */
- #if FF_API_NEXT
- ff_const59 struct AVInputFormat *next;
- #endif
-
- // 原始Demuxer存储的codec i
- int raw_codec_id;
-
- // 魔种格式文件的数据大小
- int priv_data_size;
-
- /**
- * Tell if a given file has a chance of being parsed as this format.
- * The buffer provided is guaranteed to be AVPROBE_PADDING_SIZE bytes
- * big so you do not have to check for that unless you need more.
- */
- int (*read_probe)(const AVProbeData *);
-
- /**
- * Read the format header and initialize the AVFormatContext
- * structure. Return 0 if OK. 'avformat_new_stream' should be
- * called to create new streams.
- */
- int (*read_header)(struct AVFormatContext *);
-
- /**
- * Read one packet and put it in 'pkt'. pts and flags are also
- * set. 'avformat_new_stream' can be called only if the flag
- * AVFMTCTX_NOHEADER is used and only in the calling thread (not in a
- * background thread).
- * @return 0 on success, < 0 on error.
- * Upon returning an error, pkt must be unreferenced by the caller.
- */
- int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
-
- /**
- * Close the stream. The AVFormatContext and AVStreams are not
- * freed by this function
- */
- int (*read_close)(struct AVFormatContext *);
-
- /**
- * Seek to a given timestamp relative to the frames in
- * stream component stream_index.
- * @param stream_index Must not be -1.
- * @param flags Selects which direction should be preferred if no exact
- * match is available.
- * @return >= 0 on success (but not necessarily the new offset)
- */
- int (*read_seek)(struct AVFormatContext *,
- int stream_index, int64_t timestamp, int flags);
-
- /**
- * Get the next timestamp in stream[stream_index].time_base units.
- * @return the timestamp or AV_NOPTS_VALUE if an error occurred
- */
- int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
- int64_t *pos, int64_t pos_limit);
-
- /**
- * Start/resume playing - only meaningful if using a network-based format
- * (RTSP).
- */
- int (*read_play)(struct AVFormatContext *);
-
- /**
- * Pause playing - only meaningful if using a network-based format
- * (RTSP).
- */
- int (*read_pause)(struct AVFormatContext *);
-
- /**
- * Seek to timestamp ts.
- * Seeking will be done so that the point from which all active streams
- * can be presented successfully will be closest to ts and within min/max_ts.
- * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.
- */
- int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
-
- /**
- * Returns device list with it properties.
- * @see avdevice_list_devices() for more details.
- */
- int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list);
-
- #if LIBAVFORMAT_VERSION_MAJOR < 59
- /**
- * Initialize device capabilities submodule.
- * @see avdevice_capabilities_create() for more details.
- */
- int (*create_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps);
-
- /**
- * Free device capabilities submodule.
- * @see avdevice_capabilities_free() for more details.
- */
- int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps);
- #endif
- } AVInputFormat;
- typedef struct AVOutputFormat
- {
- // 封装格式名称
- const char *name;
- // 封装格式的长名称
- const char *long_name;
-
- const char *mime_type;
- const char *extensions; /**< comma-separated filename extensions */
- /* output support */
- enum AVCodecID audio_codec; /**< default audio codec */
- enum AVCodecID video_codec; /**< default video codec */
- enum AVCodecID subtitle_codec; /**< default subtitle codec */
- /**
- * can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER,
- * AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS,
- * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH,
- * AVFMT_TS_NONSTRICT, AVFMT_TS_NEGATIVE
- */
- int flags;
-
- /**
- * List of supported codec_id-codec_tag pairs, ordered by "better
- * choice first". The arrays are all terminated by AV_CODEC_ID_NONE.
- */
- const struct AVCodecTag *const *codec_tag;
-
- const AVClass *priv_class; ///< AVClass for the private context
-
- /*****************************************************************
- * No fields below this line are part of the public API. They
- * may not be used outside of libavformat and can be changed and
- * removed at will.
- * New public fields should be added right above.
- *****************************************************************
- */
- /**
- * The ff_const59 define is not part of the public API and will
- * be removed without further warning.
- */
- #if FF_API_AVIOFORMAT
- #define ff_const59
- #else
- #define ff_const59 const
- #endif
- #if FF_API_NEXT
- ff_const59 struct AVOutputFormat *next;
- #endif
- /**
- * size of private data so that it can be allocated in the wrapper
- */
- int priv_data_size;
-
- int (*write_header)(struct AVFormatContext *);
- /**
- * Write a packet. If AVFMT_ALLOW_FLUSH is set in flags,
- * pkt can be NULL in order to flush data buffered in the muxer.
- * When flushing, return 0 if there still is more data to flush,
- * or 1 if everything was flushed and there is no more buffered
- * data.
- */
- int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
- int (*write_trailer)(struct AVFormatContext *);
- /**
- * A format-specific function for interleavement.
- * If unset, packets will be interleaved by dts.
- */
- int (*interleave_packet)(struct AVFormatContext *, AVPacket *out,
- AVPacket *in, int flush);
- /**
- * Test if the given codec can be stored in this container.
- *
- * @return 1 if the codec is supported, 0 if it is not.
- * A negative number if unknown.
- * MKTAG('A', 'P', 'I', 'C') if the codec is only supported as AV_DISPOSITION_ATTACHED_PIC
- */
- int (*query_codec)(enum AVCodecID id, int std_compliance);
-
- void (*get_output_timestamp)(struct AVFormatContext *s, int stream,
- int64_t *dts, int64_t *wall);
- /**
- * Allows sending messages from application to device.
- */
- int (*control_message)(struct AVFormatContext *s, int type,
- void *data, size_t data_size);
-
- /**
- * Write an uncoded AVFrame.
- *
- * See av_write_uncoded_frame() for details.
- *
- * The library will free *frame afterwards, but the muxer can prevent it
- * by setting the pointer to NULL.
- */
- int (*write_uncoded_frame)(struct AVFormatContext *, int stream_index,
- AVFrame **frame, unsigned flags);
- /**
- * Returns device list with it properties.
- * @see avdevice_list_devices() for more details.
- */
- int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list);
- #if LIBAVFORMAT_VERSION_MAJOR < 59
- /**
- * Initialize device capabilities submodule.
- * @see avdevice_capabilities_create() for more details.
- */
- int (*create_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps);
- /**
- * Free device capabilities submodule.
- * @see avdevice_capabilities_free() for more details.
- */
- int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps);
- #endif
- enum AVCodecID data_codec; /**< default data codec */
- /**
- * Initialize format. May allocate data here, and set any AVFormatContext or
- * AVStream parameters that need to be set before packets are sent.
- * This method must not write output.
- *
- * Return 0 if streams were fully configured, 1 if not, negative AVERROR on failure
- *
- * Any allocations made here must be freed in deinit().
- */
- int (*init)(struct AVFormatContext *);
- /**
- * Deinitialize format. If present, this is called whenever the muxer is being
- * destroyed, regardless of whether or not the header has been written.
- *
- * If a trailer is being written, this is called after write_trailer().
- *
- * This is called if init() fails as well.
- */
- void (*deinit)(struct AVFormatContext *);
- /**
- * Set up any necessary bitstream filtering and extract any extra data needed
- * for the global header.
- * Return 0 if more packets from this stream must be checked; 1 if not.
- */
- int (*check_bitstream)(struct AVFormatContext *, const AVPacket *pkt);
- } AVOutputFormat;
- typedef struct AVCodecContext
- {
- // 一个用来记录和指向avoptions的类。由avformat_all_context()设置。如果(de)muxer存在私有option也会输出
- const AVClass *av_class;
- int log_level_offset;
- // 解码器的类型(视频,音频...)
- enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
- // 采用编码器的AVcodec
- const struct AVCodec *codec;
- // 编码器的id
- enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */
-
- /**
- * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
- * This is used to work around some encoder bugs.
- * A demuxer should set this to what is stored in the field used to identify the codec.
- * If there are multiple such fields in a container then the demuxer should choose the one
- * which maximizes the information about the used codec.
- * If the codec tag field in a container is larger than 32 bits then the demuxer should
- * remap the longer ID to 32 bits with a table or other structure. Alternatively a new
- * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
- * first.
- * - encoding: Set by user, if not then the default based on codec_id will be used.
- * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
- */
- unsigned int codec_tag;
-
- // 私有数据
- void *priv_data;
-
- /**
- * Private context used for internal data.
- *
- * Unlike priv_data, this is not codec-specific. It is used in general
- * libavcodec functions.
- */
- struct AVCodecInternal *internal;
-
- /**
- * Private data of the user, can be used to carry app specific stuff.
- * - encoding: Set by user.
- * - decoding: Set by user.
- */
- void *opaque;
-
- // 平均比特率
- int64_t bit_rate;
-
- // 比特流允许偏离参考的比特数
- int bit_rate_tolerance;
-
- /**
- * Global quality for codecs which cannot change it per frame.
- * This should be proportional to MPEG-1/2/4 qscale.
- * - encoding: Set by user.
- * - decoding: unused
- */
- int global_quality;
-
- /**
- * - encoding: Set by user.
- * - decoding: unused
- */
- int compression_level;
- #define FF_COMPRESSION_DEFAULT -1
-
- /**
- * AV_CODEC_FLAG_*.
- * - encoding: Set by user.
- * - decoding: Set by user.
- */
- int flags;
-
- /**
- * AV_CODEC_FLAG2_*
- * - encoding: Set by user.
- * - decoding: Set by user.
- */
- int flags2;
-
- /**
- * some codecs need / can use extradata like Huffman tables.
- * MJPEG: Huffman tables
- * rv10: additional flags
- * MPEG-4: global headers (they can be in the bitstream or here)
- * The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger
- * than extradata_size to avoid problems if it is read with the bitstream reader.
- * The bytewise contents of extradata must not depend on the architecture or CPU endianness.
- * Must be allocated with the av_malloc() family of functions.
- * - encoding: Set/allocated/freed by libavcodec.
- * - decoding: Set/allocated/freed by user.
- */
- uint8_t *extradata;
- int extradata_size;
-
- /**
- * This is the fundamental unit of time (in seconds) in terms
- * of which frame timestamps are represented. For fixed-fps content,
- * timebase should be 1/framerate and timestamp increments should be
- * identically 1.
- * This often, but not always is the inverse of the frame rate or field rate
- * for video. 1/time_base is not the average frame rate if the frame rate is not
- * constant.
- *
- * Like containers, elementary streams also can store timestamps, 1/time_base
- * is the unit in which these timestamps are specified.
- * As example of such codec time base see ISO/IEC 14496-2:2001(E)
- * vop_time_increment_resolution and fixed_vop_rate
- * (fixed_vop_rate == 0 implies that it is different from the framerate)
- *
- * - encoding: MUST be set by user.
- * - decoding: the use of this field for decoding is deprecated.
- * Use framerate instead.
- */
- AVRational time_base;
-
- /**
- * For some codecs, the time base is closer to the field rate than the frame rate.
- * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
- * if no telecine is used ...
- *
- * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
- */
- int ticks_per_frame;
-
- /**
- * Codec delay.
- *
- * Encoding: Number of frames delay there will be from the encoder input to
- * the decoder output. (we assume the decoder matches the spec)
- * Decoding: Number of frames delay in addition to what a standard decoder
- * as specified in the spec would produce.
- *
- * Video:
- * Number of frames the decoded output will be delayed relative to the
- * encoded input.
- *
- * Audio:
- * For encoding, this field is unused (see initial_padding).
- *
- * For decoding, this is the number of samples the decoder needs to
- * output before the decoder's output is valid. When seeking, you should
- * start decoding this many samples prior to your desired seek point.
- *
- * - encoding: Set by libavcodec.
- * - decoding: Set by libavcodec.
- */
- int delay;
-
- // 视屏图像的尺寸
- int width, height;
-
- //比特流的宽高,当解码帧裁剪之后输出,所以可能与width, height值不一样
- int coded_width, coded_height;
-
- // 在一组gop中图像中的数量
- int gop_size;
-
- // 图像的格式
- enum AVPixelFormat pix_fmt;
-
- /**
- * If non NULL, 'draw_horiz_band' is called by the libavcodec
- * decoder to draw a horizontal band. It improves cache usage. Not
- * all codecs can do that. You must check the codec capabilities
- * beforehand.
- * When multithreading is used, it may be called from multiple threads
- * at the same time; threads might draw different parts of the same AVFrame,
- * or multiple AVFrames, and there is no guarantee that slices will be drawn
- * in order.
- * The function is also used by hardware acceleration APIs.
- * It is called at least once during frame decoding to pass
- * the data needed for hardware render.
- * In that mode instead of pixel data, AVFrame points to
- * a structure specific to the acceleration API. The application
- * reads the structure and can change some fields to indicate progress
- * or mark state.
- * - encoding: unused
- * - decoding: Set by user.
- * @param height the height of the slice
- * @param y the y position of the slice
- * @param type 1->top field, 2->bottom field, 3->frame
- * @param offset offset into the AVFrame.data from which the slice should be read
- */
- void (*draw_horiz_band)(struct AVCodecContext *s,
- const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],
- int y, int type, int height);
-
- /**
- * callback to negotiate the pixelFormat
- * @param fmt is the list of formats which are supported by the codec,
- * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality.
- * The first is always the native one.
- * @note The callback may be called again immediately if initialization for
- * the selected (hardware-accelerated) pixel format failed.
- * @warning Behavior is undefined if the callback returns a value not
- * in the fmt list of formats.
- * @return the chosen format
- * - encoding: unused
- * - decoding: Set by user, if not set the native format will be chosen.
- */
- enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat *fmt);
-
- // 非 B 帧之间的最大 B 帧数
- int max_b_frames;
-
- // IP 和 B 帧之间的 qscale 因子 如果 > 0,则将使用最后一个 P 帧量化器
- float b_quant_factor;
-
- #if FF_API_PRIVATE_OPT
- /** @deprecated use encoder private options instead */
- attribute_deprecated int b_frame_strategy;
- #endif
-
- // qscale offset between IP and B-frames
- float b_quant_offset;
-
- // 解码器中帧重新排序缓冲区的大小
- int has_b_frames;
-
- #if FF_API_PRIVATE_OPT
- /** @deprecated use encoder private options instead */
- attribute_deprecated int mpeg_quant;
- #endif
-
- /**
- * qscale factor between P- and I-frames
- * If > 0 then the last P-frame quantizer will be used (q = lastp_q * factor + offset).
- * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
- * - encoding: Set by user.
- * - decoding: unused
- */
- float i_quant_factor;
-
- /**
- * qscale offset between P and I-frames
- * - encoding: Set by user.
- * - decoding: unused
- */
- float i_quant_offset;
-
- /**
- * luminance masking (0-> disabled)
- * - encoding: Set by user.
- * - decoding: unused
- */
- float lumi_masking;
-
- /**
- * temporary complexity masking (0-> disabled)
- * - encoding: Set by user.
- * - decoding: unused
- */
- float temporal_cplx_masking;
-
- /**
- * spatial complexity masking (0-> disabled)
- * - encoding: Set by user.
- * - decoding: unused
- */
- float spatial_cplx_masking;
-
- /**
- * p block masking (0-> disabled)
- * - encoding: Set by user.
- * - decoding: unused
- */
- float p_masking;
-
- /**
- * darkness masking (0-> disabled)
- * - encoding: Set by user.
- * - decoding: unused
- */
- float dark_masking;
-
- /**
- * slice count
- * - encoding: Set by libavcodec.
- * - decoding: Set by user (or 0).
- */
- int slice_count;
-
- #if FF_API_PRIVATE_OPT
- /** @deprecated use encoder private options instead */
- attribute_deprecated int prediction_method;
- #define FF_PRED_LEFT 0
- #define FF_PRED_PLANE 1
- #define FF_PRED_MEDIAN 2
- #endif
-
- /**
- * slice offsets in the frame in bytes
- * - encoding: Set/allocated by libavcodec.
- * - decoding: Set/allocated by user (or NULL).
- */
- int *slice_offset;
-
- /**
- * sample aspect ratio (0 if unknown)
- * That is the width of a pixel divided by the height of the pixel.
- * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- AVRational sample_aspect_ratio;
-
- /**
- * motion estimation comparison function
- * - encoding: Set by user.
- * - decoding: unused
- */
- int me_cmp;
- /**
- * subpixel motion estimation comparison function
- * - encoding: Set by user.
- * - decoding: unused
- */
- int me_sub_cmp;
- /**
- * macroblock comparison function (not supported yet)
- * - encoding: Set by user.
- * - decoding: unused
- */
- int mb_cmp;
- /**
- * interlaced DCT comparison function
- * - encoding: Set by user.
- * - decoding: unused
- */
- int ildct_cmp;
- #define FF_CMP_SAD 0
- #define FF_CMP_SSE 1
- #define FF_CMP_SATD 2
- #define FF_CMP_DCT 3
- #define FF_CMP_PSNR 4
- #define FF_CMP_BIT 5
- #define FF_CMP_RD 6
- #define FF_CMP_ZERO 7
- #define FF_CMP_VSAD 8
- #define FF_CMP_VSSE 9
- #define FF_CMP_NSSE 10
- #define FF_CMP_W53 11
- #define FF_CMP_W97 12
- #define FF_CMP_DCTMAX 13
- #define FF_CMP_DCT264 14
- #define FF_CMP_MEDIAN_SAD 15
- #define FF_CMP_CHROMA 256
-
- /**
- * ME diamond size & shape
- * - encoding: Set by user.
- * - decoding: unused
- */
- int dia_size;
-
- /**
- * amount of previous MV predictors (2a+1 x 2a+1 square)
- * - encoding: Set by user.
- * - decoding: unused
- */
- int last_predictor_count;
-
- #if FF_API_PRIVATE_OPT
- /** @deprecated use encoder private options instead */
- attribute_deprecated int pre_me;
- #endif
-
- /**
- * motion estimation prepass comparison function
- * - encoding: Set by user.
- * - decoding: unused
- */
- int me_pre_cmp;
-
- /**
- * ME prepass diamond size & shape
- * - encoding: Set by user.
- * - decoding: unused
- */
- int pre_dia_size;
-
- /**
- * subpel ME quality
- * - encoding: Set by user.
- * - decoding: unused
- */
- int me_subpel_quality;
-
- /**
- * maximum motion estimation search range in subpel units
- * If 0 then no limit.
- *
- * - encoding: Set by user.
- * - decoding: unused
- */
- int me_range;
-
- /**
- * slice flags
- * - encoding: unused
- * - decoding: Set by user.
- */
- int slice_flags;
- #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
- #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG-2 field pics)
- #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
-
- /**
- * macroblock decision mode
- * - encoding: Set by user.
- * - decoding: unused
- */
- int mb_decision;
- #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
- #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
- #define FF_MB_DECISION_RD 2 ///< rate distortion
-
- /**
- * custom intra quantization matrix
- * Must be allocated with the av_malloc() family of functions, and will be freed in
- * avcodec_free_context().
- * - encoding: Set/allocated by user, freed by libavcodec. Can be NULL.
- * - decoding: Set/allocated/freed by libavcodec.
- */
- uint16_t *intra_matrix;
-
- /**
- * custom inter quantization matrix
- * Must be allocated with the av_malloc() family of functions, and will be freed in
- * avcodec_free_context().
- * - encoding: Set/allocated by user, freed by libavcodec. Can be NULL.
- * - decoding: Set/allocated/freed by libavcodec.
- */
- uint16_t *inter_matrix;
-
- #if FF_API_PRIVATE_OPT
- /** @deprecated use encoder private options instead */
- attribute_deprecated int scenechange_threshold;
-
- /** @deprecated use encoder private options instead */
- attribute_deprecated int noise_reduction;
- #endif
-
- /**
- * precision of the intra DC coefficient - 8
- * - encoding: Set by user.
- * - decoding: Set by libavcodec
- */
- int intra_dc_precision;
-
- /**
- * Number of macroblock rows at the top which are skipped.
- * - encoding: unused
- * - decoding: Set by user.
- */
- int skip_top;
-
- /**
- * Number of macroblock rows at the bottom which are skipped.
- * - encoding: unused
- * - decoding: Set by user.
- */
- int skip_bottom;
-
- /**
- * minimum MB Lagrange multiplier
- * - encoding: Set by user.
- * - decoding: unused
- */
- int mb_lmin;
-
- /**
- * maximum MB Lagrange multiplier
- * - encoding: Set by user.
- * - decoding: unused
- */
- int mb_lmax;
-
- #if FF_API_PRIVATE_OPT
- /**
- * @deprecated use encoder private options instead
- */
- attribute_deprecated int me_penalty_compensation;
- #endif
-
- /**
- * - encoding: Set by user.
- * - decoding: unused
- */
- int bidir_refine;
-
- #if FF_API_PRIVATE_OPT
- /** @deprecated use encoder private options instead */
- attribute_deprecated int brd_scale;
- #endif
-
- /**
- * minimum GOP size
- * - encoding: Set by user.
- * - decoding: unused
- */
- int keyint_min;
-
- /**
- * number of reference frames
- * - encoding: Set by user.
- * - decoding: Set by lavc.
- */
- int refs;
-
- #if FF_API_PRIVATE_OPT
- /** @deprecated use encoder private options instead */
- attribute_deprecated int chromaoffset;
- #endif
-
- /**
- * Note: Value depends upon the compare function used for fullpel ME.
- * - encoding: Set by user.
- * - decoding: unused
- */
- int mv0_threshold;
-
- #if FF_API_PRIVATE_OPT
- /** @deprecated use encoder private options instead */
- attribute_deprecated int b_sensitivity;
- #endif
-
- /**
- * Chromaticity coordinates of the source primaries.
- * - encoding: Set by user
- * - decoding: Set by libavcodec
- */
- enum AVColorPrimaries color_primaries;
-
- /**
- * Color Transfer Characteristic.
- * - encoding: Set by user
- * - decoding: Set by libavcodec
- */
- enum AVColorTransferCharacteristic color_trc;
-
- /**
- * YUV colorspace type.
- * - encoding: Set by user
- * - decoding: Set by libavcodec
- */
- enum AVColorSpace colorspace;
-
- /**
- * MPEG vs JPEG YUV range.
- * - encoding: Set by user
- * - decoding: Set by libavcodec
- */
- enum AVColorRange color_range;
-
- /**
- * This defines the location of chroma samples.
- * - encoding: Set by user
- * - decoding: Set by libavcodec
- */
- enum AVChromaLocation chroma_sample_location;
-
- /**
- * Number of slices.
- * Indicates number of picture subdivisions. Used for parallelized
- * decoding.
- * - encoding: Set by user
- * - decoding: unused
- */
- int slices;
-
- /** Field order
- * - encoding: set by libavcodec
- * - decoding: Set by user.
- */
- enum AVFieldOrder field_order;
-
- /* audio only */
- int sample_rate; ///< samples per second
- int channels; ///< number of audio channels
-
- /**
- * audio sample format
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- enum AVSampleFormat sample_fmt; ///< sample format
-
- /* The following data should not be initialized. */
- /**
- * Number of samples per channel in an audio frame.
- *
- * - encoding: set by libavcodec in avcodec_open2(). Each submitted frame
- * except the last must contain exactly frame_size samples per channel.
- * May be 0 when the codec has AV_CODEC_CAP_VARIABLE_FRAME_SIZE set, then the
- * frame size is not restricted.
- * - decoding: may be set by some decoders to indicate constant frame size
- */
- int frame_size;
-
- /**
- * Frame counter, set by libavcodec.
- *
- * - decoding: total number of frames returned from the decoder so far.
- * - encoding: total number of frames passed to the encoder so far.
- *
- * @note the counter is not incremented if encoding/decoding resulted in
- * an error.
- */
- int frame_number;
-
- /**
- * number of bytes per packet if constant and known or 0
- * Used by some WAV based audio codecs.
- */
- int block_align;
-
- /**
- * Audio cutoff bandwidth (0 means "automatic")
- * - encoding: Set by user.
- * - decoding: unused
- */
- int cutoff;
-
- /**
- * Audio channel layout.
- * - encoding: set by user.
- * - decoding: set by user, may be overwritten by libavcodec.
- */
- uint64_t channel_layout;
-
- /**
- * Request decoder to use this channel layout if it can (0 for default)
- * - encoding: unused
- * - decoding: Set by user.
- */
- uint64_t request_channel_layout;
-
- /**
- * Type of service that the audio stream conveys.
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- enum AVAudioServiceType audio_service_type;
-
- /**
- * desired sample format
- * - encoding: Not used.
- * - decoding: Set by user.
- * Decoder will decode to this format if it can.
- */
- enum AVSampleFormat request_sample_fmt;
-
- /**
- * This callback is called at the beginning of each frame to get data
- * buffer(s) for it. There may be one contiguous buffer for all the data or
- * there may be a buffer per each data plane or anything in between. What
- * this means is, you may set however many entries in buf[] you feel necessary.
- * Each buffer must be reference-counted using the AVBuffer API (see description
- * of buf[] below).
- *
- * The following fields will be set in the frame before this callback is
- * called:
- * - format
- * - width, height (video only)
- * - sample_rate, channel_layout, nb_samples (audio only)
- * Their values may differ from the corresponding values in
- * AVCodecContext. This callback must use the frame values, not the codec
- * context values, to calculate the required buffer size.
- *
- * This callback must fill the following fields in the frame:
- * - data[]
- * - linesize[]
- * - extended_data:
- * * if the data is planar audio with more than 8 channels, then this
- * callback must allocate and fill extended_data to contain all pointers
- * to all data planes. data[] must hold as many pointers as it can.
- * extended_data must be allocated with av_malloc() and will be freed in
- * av_frame_unref().
- * * otherwise extended_data must point to data
- * - buf[] must contain one or more pointers to AVBufferRef structures. Each of
- * the frame's data and extended_data pointers must be contained in these. That
- * is, one AVBufferRef for each allocated chunk of memory, not necessarily one
- * AVBufferRef per data[] entry. See: av_buffer_create(), av_buffer_alloc(),
- * and av_buffer_ref().
- * - extended_buf and nb_extended_buf must be allocated with av_malloc() by
- * this callback and filled with the extra buffers if there are more
- * buffers than buf[] can hold. extended_buf will be freed in
- * av_frame_unref().
- *
- * If AV_CODEC_CAP_DR1 is not set then get_buffer2() must call
- * avcodec_default_get_buffer2() instead of providing buffers allocated by
- * some other means.
- *
- * Each data plane must be aligned to the maximum required by the target
- * CPU.
- *
- * @see avcodec_default_get_buffer2()
- *
- * Video:
- *
- * If AV_GET_BUFFER_FLAG_REF is set in flags then the frame may be reused
- * (read and/or written to if it is writable) later by libavcodec.
- *
- * avcodec_align_dimensions2() should be used to find the required width and
- * height, as they normally need to be rounded up to the next multiple of 16.
- *
- * Some decoders do not support linesizes changing between frames.
- *
- * If frame multithreading is used, this callback may be called from a
- * different thread, but not from more than one at once. Does not need to be
- * reentrant.
- *
- * @see avcodec_align_dimensions2()
- *
- * Audio:
- *
- * Decoders request a buffer of a particular size by setting
- * AVFrame.nb_samples prior to calling get_buffer2(). The decoder may,
- * however, utilize only part of the buffer by setting AVFrame.nb_samples
- * to a smaller value in the output frame.
- *
- * As a convenience, av_samples_get_buffer_size() and
- * av_samples_fill_arrays() in libavutil may be used by custom get_buffer2()
- * functions to find the required data size and to fill data pointers and
- * linesize. In AVFrame.linesize, only linesize[0] may be set for audio
- * since all planes must be the same size.
- *
- * @see av_samples_get_buffer_size(), av_samples_fill_arrays()
- *
- * - encoding: unused
- * - decoding: Set by libavcodec, user can override.
- */
- int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags);
-
- #if FF_API_OLD_ENCDEC
- /**
- * If non-zero, the decoded audio and video frames returned from
- * avcodec_decode_video2() and avcodec_decode_audio4() are reference-counted
- * and are valid indefinitely. The caller must free them with
- * av_frame_unref() when they are not needed anymore.
- * Otherwise, the decoded frames must not be freed by the caller and are
- * only valid until the next decode call.
- *
- * This is always automatically enabled if avcodec_receive_frame() is used.
- *
- * - encoding: unused
- * - decoding: set by the caller before avcodec_open2().
- */
- attribute_deprecated int refcounted_frames;
- #endif
-
- /* - encoding parameters */
- float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
- float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
-
- /**
- * minimum quantizer
- * - encoding: Set by user.
- * - decoding: unused
- */
- int qmin;
-
- /**
- * maximum quantizer
- * - encoding: Set by user.
- * - decoding: unused
- */
- int qmax;
-
- /**
- * maximum quantizer difference between frames
- * - encoding: Set by user.
- * - decoding: unused
- */
- int max_qdiff;
-
- /**
- * decoder bitstream buffer size
- * - encoding: Set by user.
- * - decoding: unused
- */
- int rc_buffer_size;
-
- /**
- * ratecontrol override, see RcOverride
- * - encoding: Allocated/set/freed by user.
- * - decoding: unused
- */
- int rc_override_count;
- RcOverride *rc_override;
-
- /**
- * maximum bitrate
- * - encoding: Set by user.
- * - decoding: Set by user, may be overwritten by libavcodec.
- */
- int64_t rc_max_rate;
-
- /**
- * minimum bitrate
- * - encoding: Set by user.
- * - decoding: unused
- */
- int64_t rc_min_rate;
-
- /**
- * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.
- * - encoding: Set by user.
- * - decoding: unused.
- */
- float rc_max_available_vbv_use;
-
- /**
- * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow.
- * - encoding: Set by user.
- * - decoding: unused.
- */
- float rc_min_vbv_overflow_use;
-
- /**
- * Number of bits which should be loaded into the rc buffer before decoding starts.
- * - encoding: Set by user.
- * - decoding: unused
- */
- int rc_initial_buffer_occupancy;
-
- #if FF_API_CODER_TYPE
- #define FF_CODER_TYPE_VLC 0
- #define FF_CODER_TYPE_AC 1
- #define FF_CODER_TYPE_RAW 2
- #define FF_CODER_TYPE_RLE 3
- /**
- * @deprecated use encoder private options instead
- */
- attribute_deprecated int coder_type;
- #endif /* FF_API_CODER_TYPE */
-
- #if FF_API_PRIVATE_OPT
- /** @deprecated use encoder private options instead */
- attribute_deprecated int context_model;
- #endif
-
- #if FF_API_PRIVATE_OPT
- /** @deprecated use encoder private options instead */
- attribute_deprecated int frame_skip_threshold;
-
- /** @deprecated use encoder private options instead */
- attribute_deprecated int frame_skip_factor;
-
- /** @deprecated use encoder private options instead */
- attribute_deprecated int frame_skip_exp;
-
- /** @deprecated use encoder private options instead */
- attribute_deprecated int frame_skip_cmp;
- #endif /* FF_API_PRIVATE_OPT */
-
- /**
- * trellis RD quantization
- * - encoding: Set by user.
- * - decoding: unused
- */
- int trellis;
-
- #if FF_API_PRIVATE_OPT
- /** @deprecated use encoder private options instead */
- attribute_deprecated int min_prediction_order;
-
- /** @deprecated use encoder private options instead */
- attribute_deprecated int max_prediction_order;
-
- /** @deprecated use encoder private options instead */
- attribute_deprecated
- int64_t timecode_frame_start;
- #endif
-
- #if FF_API_RTP_CALLBACK
- /**
- * @deprecated unused
- */
- /* The RTP callback: This function is called */
- /* every time the encoder has a packet to send. */
- /* It depends on the encoder if the data starts */
- /* with a Start Code (it should). H.263 does. */
- /* mb_nb contains the number of macroblocks */
- /* encoded in the RTP payload. */
- attribute_deprecated void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
- #endif
-
- #if FF_API_PRIVATE_OPT
- /** @deprecated use encoder private options instead */
- attribute_deprecated int rtp_payload_size; /* The size of the RTP payload: the coder will */
- /* do its best to deliver a chunk with size */
- /* below rtp_payload_size, the chunk will start */
- /* with a start code on some codecs like H.263. */
- /* This doesn't take account of any particular */
- /* headers inside the transmitted RTP payload. */
- #endif
-
- #if FF_API_STAT_BITS
- /* statistics, used for 2-pass encoding */
- attribute_deprecated int mv_bits;
- attribute_deprecated int header_bits;
- attribute_deprecated int i_tex_bits;
- attribute_deprecated int p_tex_bits;
- attribute_deprecated int i_count;
- attribute_deprecated int p_count;
- attribute_deprecated int skip_count;
- attribute_deprecated int misc_bits;
-
- /** @deprecated this field is unused */
- attribute_deprecated int frame_bits;
- #endif
-
- /**
- * pass1 encoding statistics output buffer
- * - encoding: Set by libavcodec.
- * - decoding: unused
- */
- char *stats_out;
-
- /**
- * pass2 encoding statistics input buffer
- * Concatenated stuff from stats_out of pass1 should be placed here.
- * - encoding: Allocated/set/freed by user.
- * - decoding: unused
- */
- char *stats_in;
-
- /**
- * Work around bugs in encoders which sometimes cannot be detected automatically.
- * - encoding: Set by user
- * - decoding: Set by user
- */
- int workaround_bugs;
- #define FF_BUG_AUTODETECT 1 ///< autodetection
- #define FF_BUG_XVID_ILACE 4
- #define FF_BUG_UMP4 8
- #define FF_BUG_NO_PADDING 16
- #define FF_BUG_AMV 32
- #define FF_BUG_QPEL_CHROMA 64
- #define FF_BUG_STD_QPEL 128
- #define FF_BUG_QPEL_CHROMA2 256
- #define FF_BUG_DIRECT_BLOCKSIZE 512
- #define FF_BUG_EDGE 1024
- #define FF_BUG_HPEL_CHROMA 2048
- #define FF_BUG_DC_CLIP 4096
- #define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
- #define FF_BUG_TRUNCATED 16384
- #define FF_BUG_IEDGE 32768
-
- /**
- * strictly follow the standard (MPEG-4, ...).
- * - encoding: Set by user.
- * - decoding: Set by user.
- * Setting this to STRICT or higher means the encoder and decoder will
- * generally do stupid things, whereas setting it to unofficial or lower
- * will mean the encoder might produce output that is not supported by all
- * spec-compliant decoders. Decoders don't differentiate between normal,
- * unofficial and experimental (that is, they always try to decode things
- * when they can) unless they are explicitly asked to behave stupidly
- * (=strictly conform to the specs)
- */
- int strict_std_compliance;
- #define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software.
- #define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences.
- #define FF_COMPLIANCE_NORMAL 0
- #define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions
- #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
-
- /**
- * error concealment flags
- * - encoding: unused
- * - decoding: Set by user.
- */
- int error_concealment;
- #define FF_EC_GUESS_MVS 1
- #define FF_EC_DEBLOCK 2
- #define FF_EC_FAVOR_INTER 256
-
- /**
- * debug
- * - encoding: Set by user.
- * - decoding: Set by user.
- */
- int debug;
- #define FF_DEBUG_PICT_INFO 1
- #define FF_DEBUG_RC 2
- #define FF_DEBUG_BITSTREAM 4
- #define FF_DEBUG_MB_TYPE 8
- #define FF_DEBUG_QP 16
- #define FF_DEBUG_DCT_COEFF 0x00000040
- #define FF_DEBUG_SKIP 0x00000080
- #define FF_DEBUG_STARTCODE 0x00000100
- #define FF_DEBUG_ER 0x00000400
- #define FF_DEBUG_MMCO 0x00000800
- #define FF_DEBUG_BUGS 0x00001000
- #define FF_DEBUG_BUFFERS 0x00008000
- #define FF_DEBUG_THREADS 0x00010000
- #define FF_DEBUG_GREEN_MD 0x00800000
- #define FF_DEBUG_NOMC 0x01000000
-
- /**
- * Error recognition; may misdetect some more or less valid parts as errors.
- * - encoding: Set by user.
- * - decoding: Set by user.
- */
- int err_recognition;
-
- /**
- * Verify checksums embedded in the bitstream (could be of either encoded or
- * decoded data, depending on the codec) and print an error message on mismatch.
- * If AV_EF_EXPLODE is also set, a mismatching checksum will result in the
- * decoder returning an error.
- */
- #define AV_EF_CRCCHECK (1 << 0)
- #define AV_EF_BITSTREAM (1 << 1) ///< detect bitstream specification deviations
- #define AV_EF_BUFFER (1 << 2) ///< detect improper bitstream length
- #define AV_EF_EXPLODE (1 << 3) ///< abort decoding on minor error detection
-
- #define AV_EF_IGNORE_ERR (1 << 15) ///< ignore errors and continue
- #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
- #define AV_EF_COMPLIANT (1 << 17) ///< consider all spec non compliances as errors
- #define AV_EF_AGGRESSIVE (1 << 18) ///< consider things that a sane encoder should not do as an error
-
- /**
- * opaque 64-bit number (generally a PTS) that will be reordered and
- * output in AVFrame.reordered_opaque
- * - encoding: Set by libavcodec to the reordered_opaque of the input
- * frame corresponding to the last returned packet. Only
- * supported by encoders with the
- * AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE capability.
- * - decoding: Set by user.
- */
-
- int64_t reordered_opaque;
-
- /**
- * Hardware accelerator in use
- * - encoding: unused.
- * - decoding: Set by libavcodec
- */
- // 硬件加速的器正在使用的
- const struct AVHWAccel *hwaccel;
-
- /**
- * Hardware accelerator context.
- * For some hardware accelerators, a global context needs to be
- * provided by the user. In that case, this holds display-dependent
- * data FFmpeg cannot instantiate itself. Please refer to the
- * FFmpeg HW accelerator documentation to know how to fill this
- * is. e.g. for VA API, this is a struct vaapi_context.
- * - encoding: unused
- * - decoding: Set by user
- */
- // 加速器上下文
- void *hwaccel_context;
-
- /**
- * error
- * - encoding: Set by libavcodec if flags & AV_CODEC_FLAG_PSNR.
- * - decoding: unused
- */
- uint64_t error[AV_NUM_DATA_POINTERS];
-
- /**
- * DCT algorithm, see FF_DCT_* below
- * - encoding: Set by user.
- * - decoding: unused
- */
- int dct_algo;
- #define FF_DCT_AUTO 0
- #define FF_DCT_FASTINT 1
- #define FF_DCT_INT 2
- #define FF_DCT_MMX 3
- #define FF_DCT_ALTIVEC 5
- #define FF_DCT_FAAN 6
-
- /**
- * IDCT algorithm, see FF_IDCT_* below.
- * - encoding: Set by user.
- * - decoding: Set by user.
- */
- int idct_algo;
- #define FF_IDCT_AUTO 0
- #define FF_IDCT_INT 1
- #define FF_IDCT_SIMPLE 2
- #define FF_IDCT_SIMPLEMMX 3
- #define FF_IDCT_ARM 7
- #define FF_IDCT_ALTIVEC 8
- #define FF_IDCT_SIMPLEARM 10
- #define FF_IDCT_XVID
- typedef struct AVStream
- {
- // 流的索引在
- int index; /**< stream index in AVFormatContext */
- /**
- * Format-specific stream ID.
- * decoding: set by libavformat
- * encoding: set by the user, replaced by libavformat if left unset
- */
- // 流的id
- int id;
- #if FF_API_LAVF_AVCTX
- /**
- * @deprecated use the codecpar struct instead
- */
- attribute_deprecated
- // 封装和解码器耦合在一起
- AVCodecContext *codec;
- #endif
- // 私有数据
- void *priv_data;
-
- // 时间基
- AVRational time_base;
-
- // 第一帧的显示时间
- int64_t start_time;
-
- // 该视频或者音频的数据长度
- int64_t duration;
- // 数据帧的多长
- int64_t nb_frames; ///< number of frames in this stream if known or 0
- // 去除的数据帧的位置
- int disposition; /**< AV_DISPOSITION_* bit field */
- // 哪一个数据帧被抛弃
- enum AVDiscard discard; ///< Selects which packets can be discarded at will and do not need to be demuxed.
-
- /**
- * sample aspect ratio (0 if unknown)
- * - encoding: Set by user.
- * - decoding: Set by libavformat.
- */
- // 样本比特率
- AVRational sample_aspect_ratio;
- // 元数据
- AVDictionary *metadata;
-
- /**
- * Average framerate
- *
- * - demuxing: May be set by libavformat when creating the stream or in
- * avformat_find_stream_info().
- * - muxing: May be set by the caller before avformat_write_header().
- */
- AVRational avg_frame_rate;
-
- /**
- * For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet
- * will contain the attached picture.
- *
- * decoding: set by libavformat, must not be modified by the caller.
- * encoding: unused
- */
- AVPacket attached_pic;
-
- /**
- * An array of side data that applies to the whole stream (i.e. the
- * container does not allow it to change between packets).
- *
- * There may be no overlap between the side data in this array and side data
- * in the packets. I.e. a given side data is either exported by the muxer
- * (demuxing) / set by the caller (muxing) in this array, then it never
- * appears in the packets, or the side data is exported / sent through
- * the packets (always in the first packet where the value becomes known or
- * changes), then it does not appear in this array.
- *
- * - demuxing: Set by libavformat when the stream is created.
- * - muxing: May be set by the caller before avformat_write_header().
- *
- * Freed by libavformat in avformat_free_context().
- *
- * @see av_format_inject_global_side_data()
- */
- AVPacketSideData *side_data;
- /**
- * The number of elements in the AVStream.side_data array.
- */
- int nb_side_data;
-
- /**
- * Flags indicating events happening on the stream, a combination of
- * AVSTREAM_EVENT_FLAG_*.
- *
- * - demuxing: may be set by the demuxer in avformat_open_input(),
- * avformat_find_stream_info() and av_read_frame(). Flags must be cleared
- * by the user once the event has been handled.
- * - muxing: may be set by the user after avformat_write_header(). to
- * indicate a user-triggered event. The muxer will clear the flags for
- * events it has handled in av_[interleaved]_write_frame().
- */
- int event_flags;
- /**
- * - demuxing: the demuxer read new metadata from the file and updated
- * AVStream.metadata accordingly
- * - muxing: the user updated AVStream.metadata and wishes the muxer to write
- * it into the file
- */
- #define AVSTREAM_EVENT_FLAG_METADATA_UPDATED 0x0001
- /**
- * - demuxing: new packets for this stream were read from the file. This
- * event is informational only and does not guarantee that new packets
- * for this stream will necessarily be returned from av_read_frame().
- */
- #define AVSTREAM_EVENT_FLAG_NEW_PACKETS (1 << 1)
-
- /**
- * Real base framerate of the stream.
- * This is the lowest framerate with which all timestamps can be
- * represented accurately (it is the least common multiple of all
- * framerates in the stream). Note, this value is just a guess!
- * For example, if the time base is 1/90000 and all frames have either
- * approximately 3600 or 1800 timer ticks, then r_frame_rate will be 50/1.
- */
- AVRational r_frame_rate;
-
- #if FF_API_LAVF_FFSERVER
- /**
- * String containing pairs of key and values describing recommended encoder configuration.
- * Pairs are separated by ','.
- * Keys are separated from values by '='.
- *
- * @deprecated unused
- */
- attribute_deprecated char *recommended_encoder_configuration;
- #endif
-
- /**
- * Codec parameters associated with this stream. Allocated and freed by
- * libavformat in avformat_new_stream() and avformat_free_context()
- * respectively.
- *
- * - demuxing: filled by libavformat on stream creation or in
- * avformat_find_stream_info()
- * - muxing: filled by the caller before avformat_write_header()
- */
- AVCodecParameters *codecpar;
-
- /*****************************************************************
- * All fields below this line are not part of the public API. They
- * may not be used outside of libavformat and can be changed and
- * removed at will.
- * Internal note: be aware that physically removing these fields
- * will break ABI. Replace removed fields with dummy fields, and
- * add new fields to AVStreamInternal.
- *****************************************************************
- */
-
- #if LIBAVFORMAT_VERSION_MAJOR < 59
- // kept for ABI compatibility only, do not access in any way
- void *unused;
- #endif
-
- int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */
-
- // Timestamp generation support:
- /**
- * Timestamp corresponding to the last dts sync point.
- *
- * Initialized when AVCodecParserContext.dts_sync_point >= 0 and
- * a DTS is received from the underlying container. Otherwise set to
- * AV_NOPTS_VALUE by default.
- */
- int64_t first_dts;
- int64_t cur_dts;
- int64_t last_IP_pts;
- int last_IP_duration;
-
- /**
- * Number of packets to buffer for codec probing
- */
- int probe_packets;
-
- /**
- * Number of frames that have been demuxed during avformat_find_stream_info()
- */
- int codec_info_nb_frames;
-
- /* av_read_frame() support */
- enum AVStreamParseType need_parsing;
- struct AVCodecParserContext *parser;
-
- #if LIBAVFORMAT_VERSION_MAJOR < 59
- // kept for ABI compatibility only, do not access in any way
- void *unused7;
- AVProbeData unused6;
- int64_t unused5[16 + 1];
- #endif
- AVIndexEntry *index_entries; /**< Only used if the format does not
- support seeking natively. */
- int nb_index_entries;
- unsigned int index_entries_allocated_size;
-
- /**
- * Stream Identifier
- * This is the MPEG-TS stream identifier +1
- * 0 means unknown
- */
- int stream_identifier;
-
- #if LIBAVFORMAT_VERSION_MAJOR < 59
- // kept for ABI compatibility only, do not access in any way
- int unused8;
- int unused9;
- int unused10;
- #endif
-
- /**
- * An opaque field for libavformat internal usage.
- * Must not be accessed in any way by callers.
- */
- AVStreamInternal *internal;
- } AVStream;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。