ffmpeg basic data structures and objects: AVPacket, AVPicture, AVFrame

1. AVPacket

[cpp] view plain copy  
  1. /** 
  2.  * AVPacket as the input of the decoder or the output of the encoder. 
  3.  * When used as input to the decoder, it is generated by the demuxer and then passed to the decoder 
  4.  * When used as the output of the encoder, it is generated by the encoder and then passed to the muxer 
  5.  * 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 
  6.  *  
  7.  * 
  8.  * AVPacket is one of the few public ABIs in ffmpeg, it can only be allocated on the stack by libavcodec and libformat 
  9.  * 
  10.  * The side data is always allocated with av_malloc() and is freed in 
  11.  * av_free_packet (). 
  12.  */  
  13. typedef struct AVPacket {  
  14. /** 
  15.      * The memory space of packet comes from a place called "reference count buffer", which points to a reference count buffer 
  16.      */  
  17.     AVBufferRef *buf;  
  18. /** 
  19.      * Display timestamp units are AVStream->time_base units 
  20.      */  
  21.     int64_t pts;  
  22. /** 
  23.      * Decompression timestamp, at which point the packet needs to be decoded 
  24.      */  
  25.     int64_t dts;  
  26.     uint8_t *data;  
  27. int   size;  
  28. int   stream_index;  
  29. /** 
  30.      * A combination of AV_PKT_FLAG values 
  31.      */  
  32. int   flags;  
  33. /** 
  34.      * Store additional package information 
  35.      */  
  36. struct {  
  37.         uint8_t *data;  
  38. int      size;  
  39. enum AVPacketSideDataType type;  
  40.     } *side_data;  
  41. int side_data_elems;  
  42. /** 
  43.      * The time length of this packet in AVStream->time_base units, setting 0 means unknown. 
  44.      * duration = next_pts - this_pts i. 
  45.      */  
  46. int   duration;  
  47.     int64_t pos;                             ///< byte offset in data stream, -1 if unknown  
  48.     int64_t convergence_duration;  
  49. } AVPacket;  


二、AVPicture

[cpp] view plain copy  
  1. typedef struct AVPicture {  
  2.     uint8_t *data[AV_NUM_DATA_POINTERS];    ///< pointers to the image data planes  
  3. int linesize[AV_NUM_DATA_POINTERS];     ///< number of bytes per line  
  4. }  


3. AVFrame

[cpp] view plain copy  
  1. /** 
  2.  * AVFrame represents a decoded data frame 
  3.  * 
  4.  * AVFrame is created by using av_frame_alloc(). This function just creates the AVFrame structure itself, in the structure 
  5.  * The buffer pointers to other memory blocks defined in must be allocated by other methods 
  6.  * Use av_frame_free() to free AVFrame. 
  7.  * 
  8.  */  
  9. typedef struct AVFrame {  
  10. #define AV_NUM_DATA_POINTERS 8  
  11. /** 
  12.      * pointer to the picture/channel planes. 
  13.      */  
  14.     uint8_t * data [AV_NUM_DATA_POINTERS];  
  15. /** 
  16.      * For video, size in bytes of each picture line. 
  17.      * For audio, size in bytes of each plane. 
  18.      */  
  19. int linesize[AV_NUM_DATA_POINTERS];  
  20. /** 
  21.      * pointers to the data planes/channels. 
  22.      */  
  23.     uint8_t **extended_data;  
  24. /** 
  25.      * width and height of the video frame 
  26.      */  
  27. int width, height;  
  28. /** 
  29.      * number of audio samples (per channel) described by this frame 
  30.      */  
  31. int nb_samples;  
  32. /** 
  33.      * format of the frame, -1 if unknown or unset 
  34.      */  
  35. int format;  
  36. /** 
  37.      * 1 -> keyframe, 0-> not 
  38.      */  
  39. int key_frame;  
  40. /** 
  41.      * Picture type of the frame. 
  42.      */  
  43. enum AVPictureType pict_type;  
  44. /** 
  45.      * Sample aspect ratio for the video frame, 0/1 if unknown/unspecified. 
  46.      */  
  47.     AVRational sample_aspect_ratio;  
  48. /** 
  49.      * Presentation timestamp in time_base units (time when frame should be shown to user). 
  50.      */  
  51.     int64_t pts;  
  52. /** 
  53.      * PTS copied from the AVPacket that was decoded to produce this frame. 
  54.      */  
  55.     int64_t pkt_pts;  
  56. /** 
  57.      * DTS copied from the AVPacket that triggered returning this frame. (if frame threading isnt used) 
  58.      * This is also the Presentation time of this AVFrame calculated from 
  59.      * only AVPacket.dts values without pts values. 
  60.      */  
  61.     int64_t pkt_dts;  
  62. /** 
  63.      * picture number in bitstream order 
  64.      */  
  65. int coded_picture_number;  
  66. /** 
  67.      * picture number in display order 
  68.      */  
  69. int display_picture_number;  
  70. /** 
  71.      * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) 
  72.      */  
  73. int quality;  
  74. /** 
  75.      * for some private data of the user 
  76.      */  
  77. void *opaque;  
  78. /** 
  79.      * error 
  80.      */  
  81.     uint64_t error [AV_NUM_DATA_POINTERS];  
  82. /** 
  83.      * When decoding, this signals how much the picture must be delayed. 
  84.      * extra_delay = repeat_pict / (2*fps) 
  85.      */  
  86. int repeat_pict;  
  87. /** 
  88.      * The content of the picture is interlaced. 
  89.      */  
  90. int interlaced_frame;  
  91. /** 
  92.      * If the content is interlaced, is top field displayed first. 
  93.      */  
  94. int top_field_first;  
  95. /** 
  96.      * Tell user application that palette has changed from previous frame. 
  97.      */  
  98. int palette_has_changed;  
  99. /** 
  100.      * Sample rate of the audio data. 
  101.      */  
  102. int sample_rate;  
  103. /** 
  104.      * Channel layout of the audio data. 
  105.      */  
  106.     uint64_t channel_layout;  
  107. /** 
  108.      * Point to the data buffer in the AVBuffer to be used by this frame. 
  109.      * 
  110.      * Generally, each image bit plane (data[0], data[1] data[2]) has only one buffer pointing to AVBuffer, so for video this array 
  111.      * always contains all the references. For planar audio with more than 
  112.      * AV_NUM_DATA_POINTERS channels, there may be more buffers than can fit in 
  113.      * this array. Then the extra AVBufferRef pointers are stored in the 
  114.      * extended_buf array. 
  115.      */  
  116.     AVBufferRef * buf [AV_NUM_DATA_POINTERS];  
  117. /** 
  118.      * For planar audio which requires more than AV_NUM_DATA_POINTERS 
  119.      * AVBufferRef pointers, this array will hold all the references which 
  120.      * cannot fit into AVFrame.buf. 
  121.      */  
  122.     AVBufferRef **extended_buf;  
  123. /** 
  124.      * Number of elements in extended_buf. 
  125.      */  
  126. int        nb_extended_buf;  
  127.     AVFrameSideData **side_data;  
  128. int            nb_side_data;  
  129. /** 
  130.  * 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 
  131.  */  
  132. #define AV_FRAME_FLAG_CORRUPT       (1 << 0)  
  133. /** 
  134.      * Frame flags, a combination of AV_FRAME_FLAG_* 
  135.      */  
  136. int flags;  
  137.     int64_t best_effort_timestamp;  
  138.     int64_t point_pos;  
  139.     int64_t pkt_duration;  
  140.     AVDictionary *metadata;  
  141. int decode_error_flags;  
  142. #define FF_DECODE_ERROR_INVALID_BITSTREAM   1  
  143. #define FF_DECODE_ERROR_MISSING_REFERENCE   2  
  144. int channels;  
  145. int pkt_size;  
  146. enum AVColorSpace colorspace;  
  147. enum AVColorRange color_range;  
  148. /** 
  149.      * Not to be accessed directly from outside libavutil 
  150.      */  
  151.     AVBufferRef *qp_table_buf;  
  152. } AVFrame;  

from:http://blog.csdn.net/chance_yin/article/details/16817957

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326135432&siteId=291194637