Log in

View Full Version : YUV & RGB Transformations


amatiman
30th January 2006, 07:10
Hello Everyone,

Please HELP ME OUT !!

I am a very new person in the world of Audio & Video Enoding / Decoding.
The current assignment that I have been given is to develop an engine (in C) that would transform various RAW RGB & RAW YUV files from one form to other, i.e. RGB to YUV & vice-versa. ( RGB888 & below and YUV444 & below)

Being a very new professional in the field of Digital Media, I am really stuck up with certain documents that I managed from the net. I read information as to how to use mathematical formulas to transform these files.

The biggest problem Im facing right now is How to identify the format of these YUV & RGB files.What is the format of the Structure that defines its definition.

I hope you would be kind enough to spare some of your time to help me start up with some proper solution to this problem right from the grass root level. (I have just 2 more days to document my work and define the plan that I shall adapt).

Just give me some idea about the Structure that I can use to Decode these files in my programs, coz once I know the Structure, its just the matter of Parsing which is a relatively very easy task.

It wold be great if you can show me a code segment ( preferably in "C" ) that reads & writes RGB & YUV files

Kindly Help me build up my career in a significant manner.

Desperately looking forward to a quick reply from you....

Thanks & Regards

A Matiman

Richard Berg
30th January 2006, 07:41
This should probably go in the Development forum.

Here's an example in C++:
http://cvs.sourceforge.net/viewcvs.py/avisynth2/avisynth/src/convert/?sortby=date

Does your code need to be optimized? If not, the formulas are very easy. You can read about them on poynton.com and other websites. Convert.h (in the above link) has simple implementations using integer math. The other files have faster versions optimized for streaming CPU architectures & specific colorspaces.

amatiman
30th January 2006, 08:08
Thanks Richard, I shall just try and go through the code that you have suggested in the above link.

If you have any other refences in this regard, please do forward them to me.

Guest
30th January 2006, 14:51
Please HELP ME OUT !! Please stop crossposting, per forum rule 8. Thank you.

Richard Berg
1st February 2006, 17:17
As I wrote in PM:
I'd prefer you keep this conversation on the main forum so others can help and everyone can benefit.

Anyway, there's no good way to tell the difference between RGB & YUV in a raw video stream. You could sample the stream in a few places and see which colorspace "makes more sense" but that's a difficult problem and can never be 100% accurate regardless.
PS: I now see that your PM was a cut-n-paste of the original post, not a followup. That's the same as a crosspost; please stop.

amatiman
2nd February 2006, 06:33
Here is a more precise information about the type of work I want to perform, Take the YUV/RGB file (no information of any sort available inside the file) input with the details mentioned seperately on the basis of the various options available and transform it into any of the desired YUV/RGB format with the maximum possible portability options as possible (444, 422, 421, 420, YUYV or YUY2, YUV12 ...)

Regards

A Matiman

Harlequin
4th February 2006, 05:02
I've been researching the same kinds of things for a project. a good overview of the yuv colorspace is found here: A&E's tech guide (http://www.animemusicvideos.org/guides/avtech/colorspace.html) and a more detailed information is here: CMPT 365 Course (http://www.cs.sfu.ca/CourseCentral/365/li/material/notes/Chap3/Chap3.3/Chap3.3.html)

amatiman
6th February 2006, 06:39
Thanks Harlequin, but I have already been through all the stuff that you referred to me... it did gave me theoratical undersatding, but it was not ver helpfull for practical implementation...

Wilbert
6th February 2006, 10:50
1) I don't think you can autodetect the format. Sure, if you count the number of bytes you know whether it's 4:4:4, 4:2:2, 4:2:0 or 4:1:0. But you don't know whether it's YUV or RGB.

2) To open raw YUV/RGB see the source of the avs RawSource plugin.

3) Sampling: http://www.avisynth.org/Sampling

4) 4:4:4 YUV <-> 4:4:4 RGB. People gave you already links for this.

amatiman
3rd May 2006, 08:20
Hi all,

I have finally completed the engine regarding which I had been bugging you all.
The Engine has been written in "C" language with a GUI in "TCL/TK".

The Engine can handle the following 68 direct transformations :

o RGB-888-PACKED to YUV-444-PACKED
o RGB-888-PACKED to YUV-444-PLANAR
o RGB-888-PACKED to YUV-422-PLANAR
o RGB-888-PACKED to YUV-411-PLANAR
o RGB-888-PACKED to YUV-420-PLANAR-I420/IYUV (MPEG.1)
o RGB-888-PACKED to YUV-420-PLANAR-I420/IYUV (MPEG.2)
o RGB-888-PACKED to YUV-420-PLANAR-I420/IYUV (STANDARD)
o RGB-888-PACKED to YUV-420-PLANAR-YV12 (MPEG.1)
o RGB-888-PACKED to YUV-420-PLANAR-YV12 (MPEG.2)
o RGB-888-PACKED to YUV-420-PLANAR-YV12 (STANDARD)
o RGB-888-PACKED to YUV-400-Y800

o YUV-444-PACKED to YUV-420-PLANAR-YV12 (MPEG.1)
o YUV-444-PACKED to YUV-420-PLANAR-YV12 (MPEG.2)
o YUV-444-PACKED to YUV-420-PLANAR-YV12 (STANDARD)
o YUV-444-PACKED to YUV-422-PLANAR
o YUV-444-PACKED to YUV-411-PLANAR
o YUV-444-PACKED to YUV-420-PLANAR-I420/IYUV (MPEG.1)
o YUV-444-PACKED to YUV-420-PLANAR-I420/IYUV (MPEG.2)
o YUV-444-PACKED to YUV-420-PLANAR-I420/IYUV (STANDARD)
o YUV-444-PACKED to YUV-400-Y800
o YUV-444-PLANAR to YUV-444-PACKED
o YUV-444-PACKED to YUV-444-PLANAR
o RGB-888-PACKED to YUV-422-PACKED UY0VY1
o RGB-888-PACKED to YUV-422-PACKED VY0UY1
o RGB-888-PACKED to YUV-422-PACKED Y0VY1U
o RGB-888-PACKED to YUV-422-PACKED Y1VY0U
o RGB-888-PACKED to YUV-422-PACKED Y1UY0V

o YUV-444-PACKED to YUV-422-PACKED UY0VY1
o YUV-444-PACKED to YUV-422-PACKED VY0UY1
o YUV-444-PACKED to YUV-422-PACKED Y0VY1U
o YUV-444-PACKED to YUV-422-PACKED Y1VY0U
o YUV-444-PACKED to YUV-422-PACKED Y1UY0V

o YUV-422-PLANAR to YUV-444-PLANAR
o YUV-411-PLANAR to YUV-444-PLANAR
o YUV-420-I420(YUV)-PLANAR to YUV-444-PLANAR
o YUV-420-YV12(YVU)-PLANAR to YUV-444-PLANAR
o YUV-422-PLANAR to YUV-444-PACKED
o YUV-411-PLANAR to YUV-444-PACKED
o YUV-420-I420(YUV)-PLANAR to YUV-444-PACKED
o YUV-420-YV12(YVU)-PLANAR to YUV-444-PACKED

o YUV-422-PACKED-UY0VY1 to YUV-444-PLANAR
o YUV-422-PACKED-VY0UY1 to YUV-444-PLANAR
o YUV-422-PACKED-Y0VY1U to YUV-444-PLANAR
o YUV-422-PACKED-Y1VY0U to YUV-444-PLANAR
o YUV-422-PACKED-Y1UY0V to YUV-444-PLANAR
o YUV-422-PACKED-UY0VY1 to YUV-444-PACKED
o YUV-422-PACKED-VY0UY1 to YUV-444-PACKED
o YUV-422-PACKED-Y0VY1U to YUV-444-PACKED
o YUV-422-PACKED-Y1VY0U to YUV-444-PACKED
o YUV-422-PACKED-Y1UY0V to YUV-444-PACKED

o YUV-444-PLANAR-PROGRESSIVE to YUV-444-PLANAR-INTERLACED
o YUV-444-PACKED-PROGRESSIVE to YUV-444-PLANAR-INTERLACED
o YUV-444-PLANAR-PROGRESSIVE to YUV-444-PACKED-INTERLACED
o YUV-444-PACKED-PROGRESSIVE to YUV-444-PACKED-INTERLACED
o YUV-420-PLANAR-PROGRESSIVE-I420 to YUV-420-PLANAR-INTERLACED-I420
o YUV-420-PLANAR-PROGRESSIVE-YV12 to YUV-420-PLANAR-INTERLACED-YV12
o YUV-422-PLANAR-PROGRESSIVE to YUV-422-PLANAR-INTERLACED
o YUV-422-PLANAR-PROGRESSIVE to YUV-422-PACKED-INTERLACED-UY0VY1
o YUV-422-PACKED-PROGRESSIVE-UY0VY1 to YUV-422-PACKED-INTERLACED-UY0VY1
o YUV-422-PACKED-PROGRESSIVE-VY0UY1 to YUV-422-PACKED-INTERLACED-VY0UY1
o YUV-422-PACKED-PROGRESSIVE-Y0VY1U to YUV-422-PACKED-INTERLACED-Y0VY1U
o YUV-422-PACKED-PROGRESSIVE-Y1VY0U to YUV-422-PACKED-INTERLACED-Y1VY0U
o YUV-422-PACKED-PROGRESSIVE-Y1UY0V to YUV-422-PACKED-INTERLACED-Y1UY0V

o RGB-888-PACKED (24 Bit) to RGB-555-PACKED (16 Bit)
o RGB-888-PACKED (24 Bit) to RGB-565-PACKED (16 Bit)
o RGB-888-PACKED (24 Bit) to RGB-888-PACKED (32 Bit)
o YUV-444-PACKED to RGB-888-PACKED (24 Bit)
o YUV-444-PLANAR to RGB-888-PACKED (24 Bit)


Thanks for your help and cooperation.

One more Question... Is it world's first of its kind ??

Shall try to make it Open Source if I get permission from my company.

You all are welcome for any sort of help that you may need in this context.

A Matiman

DanielCardenas
8th June 2007, 18:52
Yes, it would be good if you made it open source. Your company may benefit from other's improvements.