[Libav-user] Copying pixels directly from AVFrame->data, possible alignment error.
steinbach at scionics.de
Thu Jun 9 20:53:59 CEST 2016
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:
So in other words, say you have a 6x6 frame in GRAY8, this would mean
that AVFrame->data 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 = 8!
Also, a frame in AV_PIX_FMT_BGR24 encoding would map to
AVFrame->data being the B channel
AVFrame->data being the G channel
AVFrame->data 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[yy*f->pAVFrame->linesize+xx];
g = f->pAVFrame->data[yy*f->pAVFrame->linesize+xx];
b = f->pAVFrame->data[yy*f->pAVFrame->linesize+xx];
assuming that you f->pAVFrame was already filled by some other function.
Crossing fingers that I got everything right.
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[src_i+0];
> g = f->pAVFrame->data[src_i+1];
> b = f->pAVFrame->data[src_i+2];
> Kind regards
> Libav-user mailing list
> Libav-user at ffmpeg.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libav-user