What are the four data streams in AVFrame structure?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

What are the four data streams in AVFrame structure?

Anil Jangam-2

Hi List,

In libavcodec/avcodec.h file, there defined a structure AVFrame, the definition is as below.

   1011 /**
   1012  * Audio Video Frame.
   1013  * New fields can be added to the end of FF_COMMON_FRAME with minor version
   1014  * bumps.
   1015  * Removal, reordering and changes to existing fields require a major
   1016  * version bump. No fields should be added into AVFrame before or after
   1017  * FF_COMMON_FRAME!
   1018  * sizeof(AVFrame) must not be used outside libav*.
   1019  */
   1020 typedef struct AVFrame {
   1021     FF_COMMON_FRAME
   1022 } AVFrame;
   1023

The further macro definition for FF_COMMON_FRAME is given below.

    707 #define FF_COMMON_FRAME \
    708     /**\
    709      * pointer to the picture planes.\
    710      * This might be different from the first allocated byte\
    711      * - encoding: \
    712      * - decoding: \
    713      */\
    714     uint8_t *data[4];\
    715     int linesize[4];\
    716     /**\
    717      * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.\
    718      * This isn't used by libavcodec unless the default get/release_buffer() is used.\
    719      * - encoding: \
    720      * - decoding: \
    721      */\
    722     uint8_t *base[4];\
    723     /**\
    724      * 1 -> keyframe, 0-> not\
    725      * - encoding: Set by libavcodec.\

I want to understand what the 'unit8_t *data[4]' (see line 714 above) field is used for? What they represent in the AVFrame?

I actually dumped all the data in these four data lines into each file, and the fourth data did not have anything.

We are looking for a compressed (i.e. un-decoded) data stream of original video file to be used in the decoder function. Is there any way, we can get the un-decoded compressed data stream inside the Encoder function?

Also can someone explain what 'uint8_t *base[4]' (see line 722 above) used for?

I thank in advance for all the helps on above points.

/anil.



DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: What are the four data streams in AVFrame structure?

Ferenc Deak
Hey,

the uint8_t* data[4] is an array of four pointers which actually point
to the bytes of the frame. How this can be interpreted depends on the
format of the frame. You can find some more explanations in
libavutil/pixfmt.h.

I'll give here two examples:

For an RGBA frame:

The first element of the array is the actual pixel data

data[0][IMG_SIZE]

where IMG_SIZE is and it's usually (Width * Height * 4), the bytes in it
are like:

data[0][x] = R
data[0][x+1] = G
data[0][x+2] = B
data[0][x+2] = A

data[1,2,3] are not used (??? maybe).

For a YUV420 frame:

data[0] - contains the Y values, Width in number (I also think, this is
linesize[0], however I'm not so sure about this)
data[1] - contains the Cb values, Width/2 in number (this might be
linesize[1])
data[2] - contains the Cr values, Width/2 in number (this might be
linesize[2])

Good luck.

f.

(PS: these examples come from real life experiments, you might need more
experiments to get more accurate data for other formats)




On 08/14/2010 06:42 AM, Anil Jangam wrote:

> Hi List,
>
> In libavcodec/avcodec.h file, there defined a structure AVFrame, the definition is as below.
>
>     1011 /**
>     1012  * Audio Video Frame.
>     1013  * New fields can be added to the end of FF_COMMON_FRAME with minor version
>     1014  * bumps.
>     1015  * Removal, reordering and changes to existing fields require a major
>     1016  * version bump. No fields should be added into AVFrame before or after
>     1017  * FF_COMMON_FRAME!
>     1018  * sizeof(AVFrame) must not be used outside libav*.
>     1019  */
>     1020 typedef struct AVFrame {
>     1021     FF_COMMON_FRAME
>     1022 } AVFrame;
>     1023
>
> The further macro definition for FF_COMMON_FRAME is given below.
>
>      707 #define FF_COMMON_FRAME \
>      708     /**\
>      709      * pointer to the picture planes.\
>      710      * This might be different from the first allocated byte\
>      711      * - encoding: \
>      712      * - decoding: \
>      713      */\
>      714     uint8_t *data[4];\
>      715     int linesize[4];\
>      716     /**\
>      717      * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.\
>      718      * This isn't used by libavcodec unless the default get/release_buffer() is used.\
>      719      * - encoding: \
>      720      * - decoding: \
>      721      */\
>      722     uint8_t *base[4];\
>      723     /**\
>      724      * 1 ->  keyframe, 0->  not\
>      725      * - encoding: Set by libavcodec.\
>
> I want to understand what the 'unit8_t *data[4]' (see line 714 above) field is used for? What they represent in the AVFrame?
>
> I actually dumped all the data in these four data lines into each file, and the fourth data did not have anything.
>
> We are looking for a compressed (i.e. un-decoded) data stream of original video file to be used in the decoder function. Is there any way, we can get the un-decoded compressed data stream inside the Encoder function?
>
> Also can someone explain what 'uint8_t *base[4]' (see line 722 above) used for?
>
> I thank in advance for all the helps on above points.
>
> /anil.
>
>
>
> DISCLAIMER
> ==========
> This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
>    
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: What are the four data streams in AVFrame structure?

wl2776
Administrator
In reply to this post by Anil Jangam-2
Anil Jangam-2 wrote
We are looking for a compressed (i.e. un-decoded) data stream of original video file to be used in the decoder function.
You're looking in the wrong place.

Correct one is struct AVPacket.
http://cekirdek.pardus.org.tr/~ismail/ffmpeg-docs/structAVPacket.html
data contains a pointer to the encoded data (which can be fed into avcodec_decode_* functions).

This structure is returned by av_read_frame, which always gives you either one complete video frame, or one or several audio frames.