PDA

View Full Version : MJPEG and DV luma


stickboy
23rd August 2002, 13:35
Is there any way that Avisynth can avoid luma problems with opening MJPEG and DV video? (Well, with the PicVideo MJPEG and Canopus DV codecs, specifically... I don't know how other MJPEG and DV codecs behave.)

I've tried the MJPEGcorrect (http://forum.doom9.org/showthread.php?s=&threadid=28187) filter, but as far as I can tell, although the luma is closer to what it should be, it's still not quite right.

Here are histograms from VirtualDub:

1. DV video, opened directly with VirtualDub
http://www.slimjimmy.com/junk/temp/fora/doom9/dv.virtualdub.gif

2. DV video, opened in Avisynth
http://www.slimjimmy.com/junk/temp/fora/doom9/dv.avisynth.yuy2.gif

3. DV video, opened in Avisynth, followed by ConvertToRGB
http://www.slimjimmy.com/junk/temp/fora/doom9/dv.avisynth.rgb.gif

4. DV video, opened in Avisynth, followed by MJPEGcorrect
http://www.slimjimmy.com/junk/temp/fora/doom9/dv.avisynth.mjpegcorrect.gif

In #2 and #3, it looks the blacks are getting a bit clipped (how does MJPEGcorrect fix the blacks if it gets clipped input?). #4 has the same structure as what I expect (#1), but rescaling the luma (not too surprisingly) generates a bunch of peaks and valleys, which kind of bug me...

According to Blight (http://www.inmatrix.com/articles/ivtcsynth1.shtml), decoding to RGB instead of YUV avoids this problem, and this is what VirtualDub does (AFAIK, VirtualDub does all processing in RGB anyhow).

Would it be possible to get Avisynth to decode MJPEG and DV video to RGB? I don't mind performing an extra RGB->YUY2 conversion after opening the file; the differences between #2 and #3 are slight compared to those between #1 and #4.

(Or are there any other ways to avoid or to correct this problem easily?)

Blight
23rd August 2002, 13:48
There should probably be a "PreferDecode(YUV/RGB)" function. Some decoders can do both and this should be taken advantage of when possible.

hakko504
23rd August 2002, 14:18
My experience with Matrox MJPEG is that a ConvertToYUY2() call right after opening the source solves most problems.

stickboy
23rd August 2002, 20:19
Originally posted by Blight
There should probably be a "PreferDecode(YUV/RGB)" function. Some decoders can do both and this should be taken advantage of when possible. I was thinking of something more like an extra, optional argument to AviSource() (and the other file opening functions). That way seems more functional, but a PreferDecode() function would be okay too.

hakko504:
For PicVideo's MJPEG codec and Canopus' DV codecs, calling ConvertToYUY2() has no effect (results are identical to #2).

vidiot
23rd August 2002, 22:30
one silly question:
How do you open DV Videos

I personally open them with DirectShowSource, because I semm to get bogus colours with Avisource...

Harald

thorazine
24th August 2002, 03:48
Don't know about DV but according to Pegasus (picvideo makers) the codec is clipping luma to 16-235 when compressing from YUY2 sources.
Doesnt that mean you can't fix the luma when decoding no matter what you do?

Also I'm not sure if it's only that: I made a few tests with a gamma ramp:

DV opened with VDub (decoded to RGB):
http://perso.wanadoo.es/thorazine/doom9/dv_vdub_rgb.png
http://perso.wanadoo.es/thorazine/doom9/dv_vdub_rgb_histo.png

DV opened with Avisynth (decoded to YUY2):
http://perso.wanadoo.es/thorazine/doom9/dv_avis_yuy.png
http://perso.wanadoo.es/thorazine/doom9/dv_avis_yuy_histo.png

I'm no expert by any means but the banding and the valleys doesnt look right...

dividee
24th August 2002, 05:03
Originally posted by stickboy
I was thinking of something more like an extra, optional argument to AviSource() Was thinking about that too :) I'll do it for the next version. Should be easy and it would solve that problem.

stickboy
24th August 2002, 06:34
vidiot:
I've been using AviSource. DirectShowsource doesn't seem to work for me (I probably have something misconfigured somewhere; I'm using Avisynth 2.0.5, and I get an "Unrecognized exception!" error for all files).

dividee:
Awesome! Thanks!

ErMaC
24th August 2002, 12:30
On this same subject, I have a Pinnacle DV500 at home and the Pinnacle DV codec that it installs for VFW and DirectShow will only report back RGB video.
Now this is obviously silly as DV stores YUV (or rather, 4:1:1 colorspace, but either way NOT in RGB). When I'm encoding from the DV sources thru AVISynth I have to ConvertToYUY2() after opening them, then decomb, etc, etc...

Is there any way to possibly force alternate codecs for opening files? For instance, forcing using the MSDV codec or the radius DV codec, or maybe forcing using the DivX3.11 decoder instead of the DivX5 VFW decoder (as another example)?

vidiot
24th August 2002, 13:39
stickboy:
Like ErMaC told us there are many codecs on most systems...
You donīt have a DV Codec intalled on your System that Supports DS.

There are codecs that only support VfW.
And others that support both.

I personally think/(have read) that the only codecs that are "blue book" conform are Canopus and MC for DV Video both are not free,
but the main Concept Codec is woth the money (~50$).
(Itīs the fastest one although).

An excellent site on the web regarding to DV 2 SVCD was Ross Mc Leans site...
wait...

http://www.geocities.com/aussie01au/

He mentioned a colour shift in avisynth, too.
Long before I recognized anything like that:

"Color Correction:
In the process of encoding a SVCD you may encounter a color shift or a lack of brightness or reduced contrast in the final file when compared with the original source. This is particularly related to files in MS DV Type 1 or MS Type 2 when used in association with avisynth to frame serve the TMPGEnc encoder. Testing has shown this not to be the case with the Main Concept DV Codec. This subject is noted on the MSP6 related issues page."

Hope this helps

Harald

Defiler
25th August 2002, 00:15
(Tangent) Isn't 16-235 the valid range for NTSC luma anyway?

stickboy
25th August 2002, 04:29
vidiot:
Yeah, I know that some codecs support VfW and others support DirectShow... I thought that PicVideo's MJPEG codec supported DirectShow decoding, but I guess it supports DirectShow only for encoding. (How can I tell for certain?)

thorazine
25th August 2002, 15:28
Picvideo's DirectShow filter supports encoding and decoding.
You can load a MJPEG video on WMP6.4, Zoom Player or any other player that lets you see what filters are being used: you should see a "PICVideo MJPEG Decompressor" there.

DV is different though, you should have a MS DV DirectShow filter (it comes with DirectX 8.1) but I think it only supports DV Type 1 files with DSVD fourCC so it most likely won't open Canopus DV files.