Hello there,
I've never done any coding for transcode, or any other video software
for that matter, so I'm a bit new to the whole idea... but what I want
to know is, how do I take a given RGB colour value, and convert it into
the YUV values as used in the transcode vframe_list structure's
video_buf_Y, video_buf_U, and video_buf_V? (Note that I only need to
convert one or a small number of colours, and then use them over and
over; I am not extracting a whole bunch of colours from the frame itself
and then converting them, or anything like that.)
This might be a stupid question. I don't even know if the Y,U,V values
have the same interpretation for every different codec (do they?), but I
won't find out if I don't ask.
It would be highly convenient if there is already some kind of RGB to
YUV conversion function in the transcode source I could use (I would
have thought there would be one, but I can't find it if it exists), but
it would be just as useful if someone could give me (or tell me where to
find) some info on how to make my own.
For example, although it's not the way I was planning on doing it, it
would solve my problem if I could simply define some pixels in the
video_buf_RGB member array of the vframe_list structure, and then run a
conversion to place the same info in the video_buf_Y, _U, and _V arrays
(in YUV format).
I have already looked at the wikipedia article about YUV (at
http://en.wikipedia.org/wiki/YUV ), which gives a conversion (when
simplified) as:
Y = 0.299*R + 0.587*G + 0.114*B;
U = (B-Y)*0.565;
V = (R-Y)*0.713;
but that isn't working quite right. (Either that or I am still not
applying it correctly; see the next paragraph.)
It would also be very useful to know how the values themselves in the
video_buf_Y, _U, and _V arrays are stored (in fact, this may actually be
my only problem, but I'm not sure). They are specified as char values,
but what is the particular interpretation of the bits inside the char?
For example, what would the maximum Y value look like? (11111111 which
is 0xFF, or something different?) And what would the minimum look like
(00000000 which is 0x00, or something different ?)
Any information (or links to information) that anyone has on the subject
would be much appreciated; I am pretty sure that I almost have my
problem solved - I've been able to display what I want on the screen (in
the right place) - but I just don't have control of what colour it ends
up being (since I can't quite figure out the format of the Y, U, and V
values).
--
James G. Flewelling,
Registered Linux User #327359
Linux From Scratch User #15607