[MPlayer-dev-eng] Colorspace conversion and image buffer format
Arpi
arpi at thot.banki.hu
Mon Mar 4 14:52:47 CET 2002
Hi,
> I'm writing a native decoder for HuffYUV (fourcc HFYU).
> Image format can be RGB, RGBA (RGB plus alpha channel) and YUY2 (it
> will use new output format selection when it will be available).
Do you plan to do it for new libmpcodecs API, or for old one for now?
> I have some question about colorspaces:
> - what about RGBA? Should I store it as RGB32, using the 4th byte as A,
> or shoud I ignore alpha channel?
Does it really uses alpha channel? For what ?
I haven't seen such codec yet using alpha values.
RGB32 in mplayer means 24 bit color depth (r,g,b bytes) and one byte padding
(unused byte) to get pixels at 4-byte aligned memory.
> - what's the best way to output YV12 using YUY2 as source? should I
> convert it "on the fly" averaging U (and V) every 2 rows or it's better
> to store the image into a temporary buffer and use yuy2toyv12()
> function from rgb2rgb.c? What's the best way to do it if input is
> interlaced?
I don't think you should implement output YV12. It decreases quality and
means conversion. No one should add conversion to codecs, unless they do
direct rendering (later).
> Another question about buffer format:
> image buffer will be MP_TEMP (every frame is independent from others).
> Do I have to use MP_IMGFLAG_READABLE if I need to read from buffer
> during decompression (I need to access previous pixel and top pixel
> from previous row)?
Hmm. then it's predicted frame type, so use MP_IMGTYPE_IP.
MP_TEMP won't preserve content of frame for the decoder, it may do
postprocessing, scaling, conversions, OSD etc on it.
If you need previous frame, then this sentence is no longer valid from you:
"(every frame is independent from others)."
MP_IMGTYPE_IP is the right format for codecs using prediction.
> Other flags used are MP_IMGFLAG_YUV for YUY2 case and also
> MP_IMGFLAG_PLANAR for YV12 case.
You don't need these, they are set by mp_get_image()
But, if possible, make possible to set stride for frame, so add flag
MP_IMGFLAG_ACCEPT_STRIDE and us ethe mpi->stride[] value instead of width
when calculating buffer addresses. Direct rendering usually have limited
stride, so this feature is mostly required. And it also requires for tricks
like crop/expand frame, i think it's usefull for mencoder.
A'rpi / Astral & ESP-team
--
Developer of MPlayer, the Movie Player for Linux - http://www.MPlayerHQ.hu
More information about the MPlayer-dev-eng
mailing list