1. AVPacket
- /**
- * AVPacket as the input of the decoder or the output of the encoder.
- * When used as input to the decoder, it is generated by the demuxer and then passed to the decoder
- * When used as the output of the encoder, it is generated by the encoder and then passed to the muxer
- * In the video, AVPacket can only contain content no larger than 1 frame, and 1 frame of the video may be included in multiple AVPackets, AVPacket < AVFrame
- *
- *
- * AVPacket is one of the few public ABIs in ffmpeg, it can only be allocated on the stack by libavcodec and libformat
- *
- * The side data is always allocated with av_malloc() and is freed in
- * av_free_packet ().
- */
- typedef struct AVPacket {
- /**
- * The memory space of packet comes from a place called "reference count buffer", which points to a reference count buffer
- */
- AVBufferRef *buf;
- /**
- * Display timestamp units are AVStream->time_base units
- */
- int64_t pts;
- /**
- * Decompression timestamp, at which point the packet needs to be decoded
- */
- int64_t dts;
- uint8_t *data;
- int size;
- int stream_index;
- /**
- * A combination of AV_PKT_FLAG values
- */
- int flags;
- /**
- * Store additional package information
- */
- struct {
- uint8_t *data;
- int size;
- enum AVPacketSideDataType type;
- } *side_data;
- int side_data_elems;
- /**
- * The time length of this packet in AVStream->time_base units, setting 0 means unknown.
- * duration = next_pts - this_pts i.
- */
- int duration;
- int64_t pos; ///< byte offset in data stream, -1 if unknown
- int64_t convergence_duration;
- } AVPacket;
二、AVPicture
- typedef struct AVPicture {
- uint8_t *data[AV_NUM_DATA_POINTERS]; ///< pointers to the image data planes
- int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line
- }
3. AVFrame
- /**
- * AVFrame represents a decoded data frame
- *
- * AVFrame is created by using av_frame_alloc(). This function just creates the AVFrame structure itself, in the structure
- * The buffer pointers to other memory blocks defined in must be allocated by other methods
- * Use av_frame_free() to free AVFrame.
- *
- */
- typedef struct AVFrame {
- #define AV_NUM_DATA_POINTERS 8
- /**
- * pointer to the picture/channel planes.
- */
- uint8_t * data [AV_NUM_DATA_POINTERS];
- /**
- * For video, size in bytes of each picture line.
- * For audio, size in bytes of each plane.
- */
- int linesize[AV_NUM_DATA_POINTERS];
- /**
- * pointers to the data planes/channels.
- */
- uint8_t **extended_data;
- /**
- * width and height of the video frame
- */
- int width, height;
- /**
- * number of audio samples (per channel) described by this frame
- */
- int nb_samples;
- /**
- * format of the frame, -1 if unknown or unset
- */
- int format;
- /**
- * 1 -> keyframe, 0-> not
- */
- int key_frame;
- /**
- * Picture type of the frame.
- */
- enum AVPictureType pict_type;
- /**
- * Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
- */
- AVRational sample_aspect_ratio;
- /**
- * Presentation timestamp in time_base units (time when frame should be shown to user).
- */
- int64_t pts;
- /**
- * PTS copied from the AVPacket that was decoded to produce this frame.
- */
- int64_t pkt_pts;
- /**
- * DTS copied from the AVPacket that triggered returning this frame. (if frame threading isnt used)
- * This is also the Presentation time of this AVFrame calculated from
- * only AVPacket.dts values without pts values.
- */
- int64_t pkt_dts;
- /**
- * picture number in bitstream order
- */
- int coded_picture_number;
- /**
- * picture number in display order
- */
- int display_picture_number;
- /**
- * quality (between 1 (good) and FF_LAMBDA_MAX (bad))
- */
- int quality;
- /**
- * for some private data of the user
- */
- void *opaque;
- /**
- * error
- */
- uint64_t error [AV_NUM_DATA_POINTERS];
- /**
- * When decoding, this signals how much the picture must be delayed.
- * extra_delay = repeat_pict / (2*fps)
- */
- int repeat_pict;
- /**
- * The content of the picture is interlaced.
- */
- int interlaced_frame;
- /**
- * If the content is interlaced, is top field displayed first.
- */
- int top_field_first;
- /**
- * Tell user application that palette has changed from previous frame.
- */
- int palette_has_changed;
- /**
- * Sample rate of the audio data.
- */
- int sample_rate;
- /**
- * Channel layout of the audio data.
- */
- uint64_t channel_layout;
- /**
- * Point to the data buffer in the AVBuffer to be used by this frame.
- *
- * Generally, each image bit plane (data[0], data[1] data[2]) has only one buffer pointing to AVBuffer, so for video this array
- * always contains all the references. For planar audio with more than
- * AV_NUM_DATA_POINTERS channels, there may be more buffers than can fit in
- * this array. Then the extra AVBufferRef pointers are stored in the
- * extended_buf array.
- */
- AVBufferRef * buf [AV_NUM_DATA_POINTERS];
- /**
- * For planar audio which requires more than AV_NUM_DATA_POINTERS
- * AVBufferRef pointers, this array will hold all the references which
- * cannot fit into AVFrame.buf.
- */
- AVBufferRef **extended_buf;
- /**
- * Number of elements in extended_buf.
- */
- int nb_extended_buf;
- AVFrameSideData **side_data;
- int nb_side_data;
- /**
- * May be due to decoding errors, the data frame Frame will become an invalid frame, the following structure is used when the data frame is invalid
- */
- #define AV_FRAME_FLAG_CORRUPT (1 << 0)
- /**
- * Frame flags, a combination of AV_FRAME_FLAG_*
- */
- int flags;
- int64_t best_effort_timestamp;
- int64_t point_pos;
- int64_t pkt_duration;
- AVDictionary *metadata;
- int decode_error_flags;
- #define FF_DECODE_ERROR_INVALID_BITSTREAM 1
- #define FF_DECODE_ERROR_MISSING_REFERENCE 2
- int channels;
- int pkt_size;
- enum AVColorSpace colorspace;
- enum AVColorRange color_range;
- /**
- * Not to be accessed directly from outside libavutil
- */
- AVBufferRef *qp_table_buf;
- } AVFrame;