HuffYUV RGB->YUY2 conversion: TV/PC scale?

This forum is for questions and discussion of all the aspects of handling your footage. If you have questions about capturing/ripping footage, AviSynth, or compression/encoding/converting, look here.

HuffYUV RGB->YUY2 conversion: TV/PC scale?

Postby Scintilla » Sat Jun 26, 2010 8:42 pm

Does anybody know whether, when using HuffYUV's "Convert to YUY2" option for RGB input, the conversion that occurs produces PC scale or TV scale luma?

I just realized this working on my last video, when I was informed that I had (incorrectly) encoded my MPEG-2 with PC-scale luma.
My typical workflow's RGB<->YUV conversions are as follows:

- YV12 off the VOB, served straight through AVISynth, then somehow converted to RGB for use in Premiere Pro (I do not explicitly call ConvertToRGB32() in my scripts). I'm assuming that this conversion assumes TV-scale YUV input, as this is the default behaviour in AVISynth.

- RGB video in Premiere Pro, saved as YUY2 HuffYUV. If I would just save my exports in RGB mode, I could spare myself this trouble, but it would results in significantly bigger files.

TMPGEnc has an option for "Output YUV data as Basic YCbCr not CCIR601" (PC-scale luma), and I had originally had this checked; I only unchecked it after being informed that I was doing it wrong. But, if it turns out that HuffYUV's RGB->YUV conversion maps it to TV scale already, wouldn't it be better to check this option so as not to shrink the luma range twice?

That's why I'm hoping somebody knows the answer here. As far as I can see, it's not in the HuffYUV documentation.
ImageImage
:pizza: :pizza: Image :pizza: :pizza:
User avatar
Scintilla
(for EXTREME)
 
Joined: 31 Mar 2003
Location: New Jersey
Status: Quo

Re: HuffYUV RGB->YUY2 conversion: TV/PC scale?

Postby Mister Hatt » Mon Jun 28, 2010 2:42 am

Why are you using YUY2? Which huffyuv encoder are you using? Why are you letting the encoder do colourspace conversions instead of doing them with the correct matrix in avisynth?
Mister Hatt
 
Joined: 25 Dec 2007
Status: better than you

Re: HuffYUV RGB->YUY2 conversion: TV/PC scale?

Postby Scintilla » Mon Jun 28, 2010 6:29 am

I'm using YUY2 because it saves disk space vs the RGB modes available, I'm using HuffYUV 2.1.1, and see answer #1.
And even if it turns out that HuffYUV uses the PC scale matrix, I can just let TMPGEnc do the mapping to CCIR601 for my convention encodes and keep all my other (distribution) encodes at PC scale.

Incidentally, once I get this figured out, I guess I'll be able to stop using white mattes in Premiere that are really (235, 235, 235), like I've been doing for years, instead of FFFFFF.
ImageImage
:pizza: :pizza: Image :pizza: :pizza:
User avatar
Scintilla
(for EXTREME)
 
Joined: 31 Mar 2003
Location: New Jersey
Status: Quo

Re: HuffYUV RGB->YUY2 conversion: TV/PC scale?

Postby Mister Hatt » Mon Jun 28, 2010 9:43 am

May as well use YV12, it's easier to work with. Use avisynth for correct colour coefficients. As far as whether it uses PC or TV, I would stick to using ffmpeg for exact and confirmed accuracy but it seems HuffYUV 2.1.1 uses whatever your source is, and when it cannot tell it uses PC scale. Still best to use ffmpeg's implementation for confirmed accuracy. I don't understand why people use other encoders when lavc is the best for most things anyway, or otherwise links with the best like in the case of x264. All your anime sources uses TV scale so I don't see why you'd corrupt it by changing to PC for distribution encodes. Seems like this is another case of amvers doing things the dumb/incorrect way.
Mister Hatt
 
Joined: 25 Dec 2007
Status: better than you

Re: HuffYUV RGB->YUY2 conversion: TV/PC scale?

Postby mirkosp » Mon Jun 28, 2010 9:50 am

Mister Hatt wrote:Seems like this is another case of amvers doing things the dumb/incorrect way.

Blame it on most NLEs available, really. I don't think there even is an option to pick between TV and PC scale in Premiere/After Effects/Vegas/Magix/Avid/What-have-you. This is why we need a proper GUI for avs-based editing... so we can get things right. And for free. >_>
Image
User avatar
mirkosp
MODkip
 
Joined: 24 Apr 2006
Location: Gallarate (VA), Italy
Status: (」・ワ・)」(⊃・ワ・)⊃

Re: HuffYUV RGB->YUY2 conversion: TV/PC scale?

Postby Mister Hatt » Mon Jun 28, 2010 9:59 am

A GUI for avs is a really dumb idea, would be hideously slow, and eat insane amounts of memory. What you need is to clip your shit to lossless and leave it as is. If you don't have HDD space, then do it in smaller bits or something. Otherwise, maybe use low quality vid and then apply the process you've setup in your NLE to lossless vid later on or something. Not sure how many low-end NLEs do that though. Point is, there is no need to pick between PC and TV when all the source material is TV anyway.
Mister Hatt
 
Joined: 25 Dec 2007
Status: better than you

Re: HuffYUV RGB->YUY2 conversion: TV/PC scale?

Postby mirkosp » Mon Jun 28, 2010 10:07 am

Mister Hatt wrote:Point is, there is no need to pick between PC and TV when all the source material is TV anyway.

The problems kick in when you produce effects like particles or start to also use fanarts or stuff like those. Fanarts are PC levels, and of course you can't tell after effects or premiere to make something tv levels (closest you can do is if you're doing a solid like Scintilla was explaining, but with the more complex stuff it's not quite as simple ─ if possible at all).
Image
User avatar
mirkosp
MODkip
 
Joined: 24 Apr 2006
Location: Gallarate (VA), Italy
Status: (」・ワ・)」(⊃・ワ・)⊃

Re: HuffYUV RGB->YUY2 conversion: TV/PC scale?

Postby Scintilla » Mon Jun 28, 2010 5:35 pm

My build of HuffYUV doesn't have a YV12 mode, it doesn't bother me.

If we can assume that most viewers will watch distro encodes on their computer monitors and not on TV sets or projectors, then wouldn't PC scale luma make more sense for such encodes, for to take advantage of the full range possible on a monitor?

You mentioned ffmpeg; I do have ffdshow, the 6/6/2009 build to be exact, and it does offer HuffYUV encoding in YV12. No option for luma scale though as far as I can see.
ImageImage
:pizza: :pizza: Image :pizza: :pizza:
User avatar
Scintilla
(for EXTREME)
 
Joined: 31 Mar 2003
Location: New Jersey
Status: Quo

Re: HuffYUV RGB->YUY2 conversion: TV/PC scale?

Postby Qyot27 » Tue Jun 29, 2010 1:17 am

Scintilla wrote:My build of HuffYUV doesn't have a YV12 mode, it doesn't bother me.

The original HuffYUV branch never did have a YV12 mode, as far as I know. Only ffvhuff does (and it also added adaptive huffman tables, which greatly improves compression). ffvhuff is what ffdshow has the capability to encode, and some configurations of it (YUY2 with adaptive tables off, for example) are compatible with the original branch. RGB-mode isn't accessible for ffvhuff through ffdshow, although it might be for standard ffmpeg or mencoder. I can't seem to get it (ffmpeg itself) to do so if it can, though.

You mentioned ffmpeg; I do have ffdshow, the 6/6/2009 build to be exact, and it does offer HuffYUV encoding in YV12. No option for luma scale though as far as I can see.

I don't know how closely ffdshow's VFW Decoder and Encoder work together, but the color scale options are on the Decoder tab under 'RGB conversion', which is the very last one in the list.

I would also recommend making sure ffdshow is no more than about three or four months old, as decoder efficiency in libavcodec and features march on. DXVA for H.264 and VC-1 was added a couple months ago, but my graphics card is too old to use it (although it could use MPEG-2 if that got added). I can't even remember if the mid-2009 ffdshow builds had ffmpeg-mt for H.264.
My profile on MyAnimeList | Quasistatic Regret: yeah, yeah, I finally got a blog
User avatar
Qyot27
Surreptitious fluffy bunny
 
Joined: 30 Aug 2002
Location: St. Pete, FL
Status: Creepin' between the bullfrogs

Re: HuffYUV RGB->YUY2 conversion: TV/PC scale?

Postby Mister Hatt » Tue Jun 29, 2010 11:28 am

PC scale is silly if your content is TV scale already. Just leave it alone. Adobe and whatnot are generally made for Industry use so I would suggest that it's safe to assume they use TV levels regardless. I don't think it's important enough for you to have to worry about given you're already doing it wrong by using RGB at any stage to begin with. When it's wrong in one place, who cares if it's wrong in others. Nobody will notice.
Mister Hatt
 
Joined: 25 Dec 2007
Status: better than you

Re: HuffYUV RGB->YUY2 conversion: TV/PC scale?

Postby Scintilla » Tue Jun 29, 2010 4:46 pm

Mister Hatt wrote:PC scale is silly if your content is TV scale already. Just leave it alone.

Okay, maybe I'm misunderstanding things here, but my impression was that when AVISynth converts YV12 (DVD) to RGB (in the NLE), it defaults to using the TV scale matrix -- so that, say, white pixel with a Y of 235 becomes (255, 255, 255) in RGB, and black with a Y of 16 becomes (0, 0, 0).

And then, once it's RGB (assuming the conversion was done using the right matrix), it's full scale -- and you can't tell what scale it was originally. In that case, there would be no harm in keeping it full scale when converting back to YV12 for playback on a computer monitor. Was I wrong in my understanding of this?

Mister Hatt wrote:I don't think it's important enough for you to have to worry about given you're already doing it wrong by using RGB at any stage to begin with. When it's wrong in one place, who cares if it's wrong in others. Nobody will notice.

Hey, it's not my fault that a major prosumer NLE only works in RGB colorspace. I was given to understand that there still weren't any NLEs out there that handled YUY2 or YV12 natively. That's the only reason I need to worry about all this in the first place.

And this whole thread was kicked off precisely because a contest coordinator *did* notice, when I converted my YUY2 HuffYUV file to MPEG-2 with TMPGEnc without realizing I had the "Basic YCbCr" (full scale) option checked.
ImageImage
:pizza: :pizza: Image :pizza: :pizza:
User avatar
Scintilla
(for EXTREME)
 
Joined: 31 Mar 2003
Location: New Jersey
Status: Quo

Re: HuffYUV RGB->YUY2 conversion: TV/PC scale?

Postby Mister Hatt » Wed Jun 30, 2010 11:24 am

You are most definitely misunderstanding it then. It uses what you tell it to when you convert to RGB<resolution>. You can define whether it uses PC or TV luma models along with which chroma matrix. Using Rec{whatever} makes it use TV levels. PC.709 f.e. will use PC levels. Also you seem to think that it's rescaling your video when it isn't. If your source vid uses TV levels and you convert to PC levels, it will NOT change a black defined as 16 to 0 for you. It will still be 16 on the PC scale. That statement may in fact be wrong for the values of 16 and 235 only, but all values in between WILL stay the same. Best thing to do is use avisynth to do your convertions so you have full control over them.

Use a better NLE. Almost every professional NLE I have seen uses YV12, YUY2, and RGB40 (er yeaaaah) quite well, although the user being able to do so is another question. Professional video is mostly YUY2, at least in my industry experience.

I am very surprised a contest coordinator can notice anything that small given that they are also asking for MPEG-2 and therefore have no right to talk about video whatsoever.
Mister Hatt
 
Joined: 25 Dec 2007
Status: better than you

Re: HuffYUV RGB->YUY2 conversion: TV/PC scale?

Postby Scintilla » Wed Jun 30, 2010 6:43 pm

Mister Hatt wrote:It uses what you tell it to when you convert to RGB<resolution>. You can define whether it uses PC or TV luma models along with which chroma matrix. Using Rec{whatever} makes it use TV levels. PC.709 f.e. will use PC levels.

I get that part; and according to the documentation, it defaults to Rec601.

Mister Hatt wrote:Also you seem to think that it's rescaling your video when it isn't. If your source vid uses TV levels and you convert to PC levels, it will NOT change a black defined as 16 to 0 for you. It will still be 16 on the PC scale. That statement may in fact be wrong for the values of 16 and 235 only, but all values in between WILL stay the same.

The idea that it rescaled the video came to me straight out of the AVISynth documentation (emphasis mine):

The AVISynth documentation wrote:In v2.56, matrix="pc.601" (and matrix="pc.709") enables you to do the RGB <-> YUV conversion while keeping the luma range, thus RGB [0,255] <-> YUV [0,255] (instead of the usual/default RGB [0,255] <-> YUV [16,235]).

If that line doesn't say that (for example) black with Y of 16 in YUV becomes (0,0,0) in RGB under the usual/default behaviour (= Rec601), then what is it saying?
(Setting aside PC-levels YUV for the moment. I'm only concerned right now with converting TV-levels YUV to RGB; I'd like to get that cleared up first.)
ImageImage
:pizza: :pizza: Image :pizza: :pizza:
User avatar
Scintilla
(for EXTREME)
 
Joined: 31 Mar 2003
Location: New Jersey
Status: Quo

Re: HuffYUV RGB->YUY2 conversion: TV/PC scale?

Postby mirkosp » Thu Jul 01, 2010 2:42 am

Why are you still using v2.5.6? At least get 2.5.8... Hatt will say to get 2.6a, though. :P
Image
User avatar
mirkosp
MODkip
 
Joined: 24 Apr 2006
Location: Gallarate (VA), Italy
Status: (」・ワ・)」(⊃・ワ・)⊃

Re: HuffYUV RGB->YUY2 conversion: TV/PC scale?

Postby Scintilla » Thu Jul 01, 2010 6:15 am

According to the Version script I just ran, I *am* using 2.5.8, built 12/22/2008. :P
ImageImage
:pizza: :pizza: Image :pizza: :pizza:
User avatar
Scintilla
(for EXTREME)
 
Joined: 31 Mar 2003
Location: New Jersey
Status: Quo

Next

Return to Footage Help

Who is online

Users browsing this forum: No registered users and 2 guests