Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Programming and Hacking > Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 2nd September 2002, 14:44   #1  |  Link
bergi
Registered User
 
bergi's Avatar
 
Join Date: Jun 2002
Posts: 76
best rgb yuv conversation

I'm testing some wavelet transform, using rgb and yuv color format. I've found many different conversation formulars with different loss, and different ranges, but what formular is used in the standart windows codecs?
bergi is offline   Reply With Quote
Old 6th September 2002, 12:45   #2  |  Link
alexnoe
Banned
 
alexnoe's Avatar
 
Join Date: Aug 2002
Location: Germany
Posts: 1,737
When I need that conversion, I used the formula that caused an YUV overlay to look exactly as the RGB-original.

The AVI file format descriptions I have say

Y = 0.299 R + 0.587 G + 0.114 B
U = 0.493 (B - Y)
V = 0.877 (R - Y)

But for my overlay, it definitely didn't work. The colors were somehow "weak". I had to scale the values.

I really don't remember the formula any more, since I did that a year ago or even more, but you can try to extract it from my RGB->YUV source code:

http://www.alexander-noe.de/Video/RGBNYUV/

Last edited by alexnoe; 6th September 2002 at 13:35.
alexnoe is offline   Reply With Quote
Old 8th September 2002, 01:41   #3  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,901
Your formulas are wrong.
Guest is offline   Reply With Quote
Old 8th September 2002, 14:20   #4  |  Link
alexnoe
Banned
 
alexnoe's Avatar
 
Join Date: Aug 2002
Location: Germany
Posts: 1,737
They are not "my" formulas...they are copy+pasted from an AVI file description.

I know that they can't be correct. As I said, the color was somehow weak if I used them for a RGB->YUV conversion and copied it to an overlay.

Would you be so kind to give the correct ones? You seem to know them...would you mind to share your knowledge?
alexnoe is offline   Reply With Quote
Old 8th September 2002, 17:30   #5  |  Link
dividee
Registered User
 
Join Date: Oct 2001
Location: Brussels
Posts: 358
By converting avisynth code to formula I get this (rec601):

scaled_Y = 0.299 R + 0.587 B + 0.114 G
Y = 0.859 scaled_Y + 16
U = 0.496 (B - scaled_Y) + 128 (needs clipping)
V = 0.627 (R - scaled_Y) + 128 (needs clipping)

or if you prefer:

Y = 0.257 R + 0.504 G + 0.098 B + 16
U = -0.148 R - 0.291 G + 0.439 B + 128
V = 0.439 R - 0.368 G - 0.071 B + 128

That's assuming the standard representation of 8 bits/components, of course.
__________________
dividee
dividee is offline   Reply With Quote
Old 9th September 2002, 05:09   #6  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,901
That looks much better.
Guest is offline   Reply With Quote
Old 9th September 2002, 09:06   #7  |  Link
bergi
Registered User
 
bergi's Avatar
 
Join Date: Jun 2002
Posts: 76
Thanks!

An other question, there are many different types yuv color formats like yuv12.

i think standard is yuv12 and looks like this

---------
|yuv|y |
---------
|y |y |
---------


Can anybody tell me a good page about yuv color formats or explain it on the forum?
bergi is offline   Reply With Quote
Old 9th September 2002, 09:12   #8  |  Link
alexnoe
Banned
 
alexnoe's Avatar
 
Join Date: Aug 2002
Location: Germany
Posts: 1,737
yv12 is (at least for DirectDraw overlays)


------------------
|yyyyyyy...
|yyyyyyy...
|yyyyyyy...
|yyyyyyy...
|v v v v...
|
|v v v v...
|
|u u u u...
|
|u u u u...
|


Unfortunately, the page were I found this some time ago is down

EDIT
does anyone have an idea why there are different RGB->YUV formulas? I can promise that the last one won't work with DirectDraw overlays...

Last edited by alexnoe; 9th September 2002 at 10:25.
alexnoe is offline   Reply With Quote
Old 9th September 2002, 13:42   #9  |  Link
mpucoder
Moderator
 
Join Date: Oct 2001
Posts: 3,530
Different standards, and mistakes. Some people confuse YIQ, YCbCr, and YPbPr for YUV.

Edit: btw, DVD uses three different standards (ITU-601, aka SMPTE-170 M, is one), so if you are working with DVD source make sure you check which one was used to encode.
http://mpucoder.kewlhair.com/DVD/dvdmpeg.html

Last edited by mpucoder; 9th September 2002 at 13:50.
mpucoder is offline   Reply With Quote
Old 28th August 2021, 16:29   #10  |  Link
Balling
Registered User
 
Join Date: Feb 2020
Posts: 539
0.493 is just a mistake in BT.470. It is actually 0.492.
Balling is offline   Reply With Quote
Old 24th September 2021, 23:55   #11  |  Link
DTL
Registered User
 
Join Date: Jul 2018
Posts: 1,041
1/1000 error in data is much less error at the full awful idea to use YUV for small 2:1 bitrate compression after subsampling to 4:2:0. Nowdays mpegs can easily reach 1000:1 compression rate but awful 4:2:0 old compression idea still bugs the data today too. I hope someday YUV will be only for processing luma/chroma separately and the awful 4:2:2 and 4:2:0 data-damaging ideas goes to the same grave as interlace scan.
DTL is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:22.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.