Hi,
i'm using libavcodec for decoding mpeg2 and have some questions.
Decoding to YCbCr works fine but when i copy this data (AVFrame) to
BGR24 the picture is stored kind of monochrome planar instead of packed
(aligned). I was using img_convert for that with the older versions of
ffmpeg but this method is gone. I guess av_picture_copy is the way to go
now. The data format seems to be packed (aligned) from api-doc:
PIX_FMT_BGR24 packed RGB 8:8:8, 24bpp, BGRBGR...
when i copy the content of data[0] after applying av_picture_copy i get
more something like
(B+G+R/3) = m or B = m
|mmmm ... mmm WIDTH||mmmm ... mmm WIDTH||mmmm ... mmm WIDTH|
|mmmm ... mmm WIDTH||mmmm ... mmm WIDTH||mmmm ... mmm WIDTH|
..
HEIGHT - 1
|mmmm ... mmm WIDTH||mmmm ... mmm WIDTH||mmmm ... mmm WIDTH|
instead of
|BGR BGR BGR ... BGR WIDTH|
..
..
HEIGHT - 1
|BGR BGR BGR ... BGR WIDTH|
it's more like the Y channel is copied three times into the RGB data by
av_picture_copy.
So i'm a little confused and have three questions:
My code looks something like:
avpicture_alloc (&picture_, PIX_FMT_BGR24, w, h);
av_picture_copy (&picture_, (AVPicture*) frame_from_decoder_, PIX_FMT_BGR24, w,
h);
...
memcpy (dst, picture_.data[0], w*h*3);
1. Am i not supposed to use av_picture_copy after decoding at all ?
Instead use av_picture_fill and decode directly into the proper PIX_FMT
? (I can remember that worked already with 0.4.9pre1) Or maybe use
swscale ?
2. As a user i guess from the doc that the data should be BGRBGR in
AVPicture.data[0] but peeking at the source the method doesn't
distinguish between PLANAR and PACKED data. Is this method still in
development and will be doing PACKED in future or see question (1) ?
from libavcodec/imgconvert.c / av_picture_copy
...
pf = &pix_fmt_info[pix_fmt];
switch(pf->pixel_type) {
case FF_PIXEL_PACKED:
case FF_PIXEL_PLANAR:
for(i = 0; i < pf->nb_channels; i++) {
int h;
..
3. I will use as well RGB planar in data[0] (R), data[1] (G) and data[2]
(B). Is there a way for copying the YUV image from the decoder into that
kind of RGB planar ? I couldn't find 'planar RGB' in the PIX_FMTs.
Best regards,
Lukas
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user