[Xorg-driver-geode] How to calculate the video overlay size? (xf86-video-geode & xf86-video-ati)
Cui, Hunk
Hunk.Cui at amd.com
Thu Aug 12 20:52:46 PDT 2010
Hi, Maarten & Alex,
Through communicate with community guys on IRC (#xorg-devel channel), I have got some info about how to calculate the DstPitch size.
I known the color data is split into chroma and luma channels, and the chroma channel is only sampled half as often, the documents are http://en.wikipedia.org/wiki/YUV & http://fourcc.org/, so in common case, only have half as much data in the UV (chroma) plane as in the Y (luma) plane. For the I420 format, the image becomes much more compressible, it belong to the planar formats, all the pixels of a particular channel are grouped into planes. So the color channels are sampled at half the resolution to save space.
The total size of the source image is the size of the Y plane plus the U and V planes. Y plane is full (w * h), U and V planes are half (w/2 * h/2) each, so total is (w * h) + (w/2 * h/2) + (w/2 * h/2), Y+U+V.
Above is my summary.
Many thanks for you help. :)
Thanks,
Hunk Cui
> >> > In xf86-video-geode:
> >> > lx_video.c -> LXCopyPlanar function, some codes make me confuse,
> >> >
> >> > (
> >> > http://cgit.freedesktop.org/xorg/driver/xf86-video-geode/tree/src/lx_vid
> >> > eo.c#n224 )
> >> > YSrcPitch = (width + 3) & ~3;
> >> > YDstPitch = (width + 31) & ~31;
> >> >
> >> > UVSrcPitch = ((width >> 1) + 3) & ~3;
> >> > UVDstPitch = ((width >> 1) + 15) & ~15;
> >> >
> >> > USrcOffset = YSrcPitch * height;
> >> > VSrcOffset = USrcOffset + (UVSrcPitch * (height >> 1));
> >> >
> >> > UDstOffset = YDstPitch * height;
> >> > VDstOffset = UDstOffset + (UVDstPitch * (height >> 1));
> >> >
> >> > size = YDstPitch * height;
> >> > size += UVDstPitch * height;
> >> >
> >> > What is the formula for reference?
> >>
> >> See http://fourcc.org/
> >>
> >> > How to define and calculate the YDstPitch and UVDstPitch?
> >>
> >> Planar formats store the YUV data in separate planes rather than
> >> packed as pixel tuples. Depending on the format the UV portion has
> >> half the resolution as the Y component.
> >
> > Could you give me some more example to explain this? Confuse about
> "UVDstPitch = ((width >> 1) + 15) & ~15;"
> > Why the UV portion need to the half of the resolution as the Y
> portion?
>
> That's because (some) YUV formats have 1 U and 1 V pixel per 4 Y
> pixels, it's a way to save space. The grayscale is the most important
> part, and the colors are lower resolution (this gives an effective 12
> bits per pixel).
More information about the Xorg-driver-geode
mailing list