Avframe about video and audio data storage

Source: Internet
Author: User
1. Overview

These days with ffmpeg implementation of simple audio transcoding, in the process of writing procedures found in the audio in the Avframe storage and video is very similar to the audio is more complex, I have a bad memory, so here to record down to make memo.2, 2 data membersThere are 2 very important data members in Avframe, one is the database and the other is linesize. Data is stored in the unencrypted source data (regardless of AV), and the Linesize stores the size of each row. The definition of data is as follows:[CPP]   View Plain  copy/**       * pointer to the picture/ channel planes.       * This might be different  from the first allocated byte       *        * some decoders access areas outside 0,0 - width,height,  please       * see avcodec_align_dimensions2 () . some  filters and swscale can read       * up to 16  bytes beyond the planes, if these filters are to be  used,       * then 16 extra bytes must be  allocated.       */       uint8_t *data[av_num_ Data_pointers];   linesize is defined as follows: [CPP]   View Plain  copy/**     * For video, size in bytes  of each picture line.     * For audio, size in  bytes of each plane.     *     * for audio,  only linesize[0] may be set. for planar audio, each channel      * plane must be the same size.     *      * for video the linesizes should be multiplies  of the CPUs alignment     * preference, this is 16  or 32 for modern desktop CPUs.     * some code  requires such alignment other code can be slower without    &nbsP;* correct alignment, for yet other it makes no difference.      *     *  @note  The linesize may be  larger than the size of usable data -- there     *  may be extra padding present for performance reasons.      */     int linesize[AV_NUM_DATA_POINTERS];   Note: When linesize for audio, Only Linesize[0] is a valid value because it is as big as left and right.
3. Storage mode 1. VideoVideo is relatively simple, take yuv420 as an example, the image data stored in the avframe is like this: data[0] storage y data[1] storage u data[2] Storage V and their corresponding size is: linesize[0] is the size of y linesize[1] Size of U linesize[2] V

2. AudioAudio data is more complex, in the audio is divided into planar and non-planar data types, the following is the definition of audio data types:[CPP]   View plain  copy/**   * Audio Sample Formats   *   * @ par   * The data described by the sample format is  always in native-endian order.   * Sample values can be  expressed by native c types, hence the lack of a signed    * 24-bit sample format even though it is a common  raw audio data format.   *   *  @par    * The  Floating-point formats are based on full volume being in the  range   * [-1.0, 1.0]. Any values outside this range  are beyond full volume level.   *   *  @par    * the  data layout&nBsp;as used in av_samples_fill_arrays ()  and elsewhere in FFmpeg    *  (SUCH AS AVFRAME IN LIBAVCODEC)  is as follows:   *   * For planar sample formats, each audio channel is in  a separate data plane,   * and linesize is the buffer  size, in bytes, for a single plane. all data 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.