[Libav-user] Help with unpacking PIX_FMT_YUV4* data types

Ricky Huang rhuang.work at gmail.com
Tue Mar 11 02:32:54 CET 2014


On Mar 10, 2014, at 4:47 PM, wm4 <nfxjfg at googlemail.com> wrote:

> On Mon, 10 Mar 2014 16:18:27 -0700
> Ricky Huang <rhuang.work at gmail.com> wrote:
> 
>> Hello all,
>> 
>> I am writing code that extracts the luminance component of an input video using my own custom filter in libavfilter - specifically I am extracting it from "PIX_FMT_YUV420P" a video and I am wondering how to go about doing so.  According to the pixfmt.h header: 
>>> 
>>> PIX_FMT_YUV420P,   ///< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
>> 
>> I am not sure how to interpret that.  Assuming I am doing this in my draw_slice() function. It has the definition of:
>>> 
>>> static void draw_slice(AVFilterLink *inlink, int y0, int h, int slice_dir)
>> 
>> I know I can get to the input data plane by:
>>> 
>>> AVFilterBufferRef *cur_pic = link->cur_buf;
>>> uint8_t *data = cur_pic->data[0];
> 
> I think this functionality was removed long ago. You're supposed to
> write/read AVFrames from the filters.

Due to internal reasons, we are running ffmpeg 0.7, so the primary arguments to draw_slice() is AVFilterLink*.  Sorry I should have specified that when asked the question.

Or maybe I am missing something obvious here?  Can you help me out with how to use AVFrame to extract the luminance component?


>> But there are multiple "planes" in the data.  Does data[0], data[1], data[2] correspond to each of the Y, U, V channels?
> 
> Yes, for YUV420P.
> 
>> Also, once I am able to point my pointer at the correct coordinate, how should I interpret the extracted result (float, int, etc)?
>> 
>> 
>> Thank you in advance.
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20140310/cd45d076/attachment.html>


More information about the Libav-user mailing list