[Libav-user] BGR24 to YUV pixel conversion
Neil Menne
nhmenne42 at students.tntech.edu
Tue Apr 23 20:59:59 CEST 2013
Nevermind all that previous nonsense. I misunderstood the intended use of
avpicture_fill and that was the source of a great deal of my confusion. Now
I can ask the right question:
*How do I get the raw image buffer (located in a uint8_t array called data)
into the AVFrame? *
*
*
I've looked at the API a great deal today and yesterday, and I don't see a
clear way to accomplish this.
-Neil
On Tue, Apr 23, 2013 at 10:22 AM, Neil Menne <the1evilgenius at gmail.com>wrote:
> //begin relevant code here
> mSwsContext = sws_getContext(input_width,
> input_height,
> input_pixel_format,
> output_width,
> output_height,
> output_pixel_format,
> SWS_BICUBIC,
> NULL,
> NULL,
> NULL);
>
> AVPicture input_picture;
> avpicture_alloc(&input_picture,
> input_pixel_format, //AV_PIX_FMT_BGR24
> input_width, //656
> input_height); //354
>
> ret = avpicture_fill(&input_picture,
> data,
> input_pixel_format,
> input_width,
> input_height);
>
> AVPicture output_picture;
> avpicture_alloc(&output_picture,
> output_pixel_format,
> output_width,
> output_height);
>
> if (mSwsContext != NULL)
> {
> ret = sws_scale(mSwsContext,
> input_picture.data,
> input_picture.linesize,
> 0,
> input_height,
> output_picture.data,
> output_picture.linesize);
>
> //ret here is always 0
> }
>
> //etc....
>
>
> On Tue, Apr 23, 2013 at 10:21 AM, Neil Menne <
> nhmenne42 at students.tntech.edu> wrote:
>
>> I'm trying to convert a raw image that I receive as a unsigned character
>> array. I then create (via avpicture_alloc) two AVPictures (one for the
>> source and one for the destination). I then do an avpicture_fill for the
>> input using the unsigned character array. The value returned by
>> avpicture_fill matches the size of the original image.
>>
>> When I do the sws_scale, I get a printout saying "bad src image pointers"
>> which comes from the check_image_pointers function in sws_scale. My
>> question is this: How is this happening? I'm filling an allocated picture.
>> Where is the disconnect?
>>
>> Thanks in advance, guys.
>>
>> -Neil
>>
>> P.S. here's the relevant snippet of code
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130423/d94a7dea/attachment.html>
More information about the Libav-user
mailing list