[Libav-user] Copying pixels directly from AVFrame->data, possible alignment error.
Peter Steinbach
steinbach at scionics.de
Thu Jun 9 20:53:59 CEST 2016
Hi Jepser,
I am not an expert on this (@all please correct what I err upon), but
AFAIK the data is padded per line! that's why you also have a linesize
data member of AVFrame:
https://ffmpeg.org/doxygen/3.0/structAVFrame.html
So in other words, say you have a 6x6 frame in GRAY8, this would mean
that AVFrame->data[0] would show for the first 2 lines of the frame:
item0 item1 item2 item3 item4 item5 unused0 unused1
item6 item7 item8 item9 item10 item11 unused2 unused3
...
assuming that AVFrame->linesize[0] = 8!
Also, a frame in AV_PIX_FMT_BGR24 encoding would map to
AVFrame->data[0] being the B channel
AVFrame->data[1] being the G channel
AVFrame->data[2] being the R channel
Translating this to your code example, this would give:
uint64_t src_i = (xx+(yy*src_camera_width))*3;
r = f->pAVFrame->data[2][yy*f->pAVFrame->linesize[2]+xx];
g = f->pAVFrame->data[1][yy*f->pAVFrame->linesize[1]+xx];
b = f->pAVFrame->data[0][yy*f->pAVFrame->linesize[0]+xx];
assuming that you f->pAVFrame was already filled by some other function.
Crossing fingers that I got everything right.
Best,
P
On 09.06.2016 20:32, Jesper Taxbøl wrote:
> Sorry about the toppost . Im afraid my phone and me had a slight accident.
>
> What I was trying to add was how I index the the source pixels, hoping
> it can shed light on the offset error im experiencing.
>
> uint64_t src_i = (xx+(yy*src_camera_width))*3;
> r = f->pAVFrame->data[0][src_i+0];
> g = f->pAVFrame->data[0][src_i+1];
> b = f->pAVFrame->data[0][src_i+2];
>
> Kind regards
>
> Jesper
>
>
>
>
> _______________________________________________
> 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/20160609/667220c6/attachment.html>
More information about the Libav-user
mailing list