[MPlayer-dev-eng] Colorspace conversion and image buffer format

Roberto Togni rtogni at bresciaonline.it
Mon Mar 4 21:36:55 CET 2002


On 2002.03.04 14:52 Arpi wrote:
> 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'm writing it for the new API, but I'll do both if needed: new 
interface and decoding functions are in two files at the moment.

> 
> > 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 don't know. Original source code offers this method. I'll ignore 
alpha and print a warning.

[...]

> > - what's the best way to output YV12 using YUY2 as source? should I
> [...]
> 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).
Ok.

> 
> > 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.
Sorry. Bad wording on my side. Frames are independent. I need to read 
data from the buffer I'm writing to, not from the previous frame. It's 
something like this:

Row  n : .........abcdef.........
Row n+1: .........ghiP

To decode pixel P I need to access pixels c, d and i of current frame.
Can I read them back from image buffer, or should I keep them in a 
private buffer? If I can read them from image buffer, do I have to 
request a readable buffer with MP_IMGFLAG_READABLE ? Are MP_TEMP 
buffers write only (or readable, but very slow)?


> 
> > 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()
Now I'm starting to understand how it works. So, to request a YUV or 
RGB buffer I'll have to call mpcodecs_config_vo(), it will set 
sh_video->outfmtidx (I guess, it's notimplemented yet) and them 
mp_image_setfmt will choose the right buffer format. Is it right?

> 
> 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.
Ok. I'll do.


> 
> A'rpi / Astral & ESP-team
> 
Ciao,
  Roberto



More information about the MPlayer-dev-eng mailing list