PDA

View Full Version : DirectShowSource & non-mod-4-width YV12 streams


Snowknight26
4th January 2009, 21:24
I noticed that when DirectShowSource() is used, Avisynth spits out an error stating that YV12 must be divisible by 4, even though neuron2's MPEG2Source() works correctly with streams that are only mod 2. Any reason why it's like this?

IanB
4th January 2009, 22:05
I assume you mean this error message :- "YV12 images for output must have a width divisible by 4 (use crop)!"

The restriction is in the AviFile API for YV12 that Avisynth uses to output video to the parent application. It applies equally no matter what input source you use.

Individual input source filters may impose other limits inherent in the particular API's they are using to read the source.

leeperry
4th January 2009, 22:05
2.58 should allow mod2 YV12 through DS I think ? that's the reason why I'm waiting for MT 0.7 to be updated :D

IanB
4th January 2009, 22:23
@leeperry,

No, DirectShowSource() has no implicit restrictions of it's own. Any restrictions are imposed from the DirectShow codecs and other DirectShow components it uses to extract the video data.

2.58 relaxes the mod 4 with restriction to mod 2 for the Resizer core only. The output mod 4 restriction is not Avisynth's.

Snowknight26
4th January 2009, 22:32
The output mod 4 restriction is not Avisynth's.

So whenever MPEG2Source() or anything else thats not DSS() is used, the AVIFile API is bypassed?

neuron2
4th January 2009, 22:36
Not at all.

Please provide an unprocessed source sample.

Snowknight26
4th January 2009, 22:44
Though the same happens to me neuron2, I just had someone do the same with crop set to Crop(12,12,-10,-10) and they could encode the file successfully at 698x458 (encoded with x264 which only supports YV12/YUV4MPEG).

IanB
4th January 2009, 22:44
P.S The Output restriction is colour space dependant.

YV12 :- Mod4 Width, Mod2 Height

YUY2 :- Mod4 Width

RGB24 and RGB32 are NOT restricted!

Any input filters restriction are their own and do not effect the output restrictions.

Snowknight26
4th January 2009, 23:04
http://avisynth.org/DataStorageInAviSynth

YV12
width mod-2 (even values)
height mod-2 (even values) if progressive

Edit: Guess I wasn't entirely aware of the way Avisynth works. Piping the avs with avs2yuv to x264 works correctly, just not having it directly open the avs, which results in something rendering/decoding (?) the video before passing the raw input to x264.

IanB
5th January 2009, 01:33
Yes if you access Avisynth through the Avisynth.h API like avs2yuv does then there will only be the intrinsic data restrictions of the pixel format.

As I said the output restriction is in the AVIFile API used to deliver video data to applications.


:Aside:
X264 like all mpeg4 derived formats only intrinsically works with mod 16 height and width. If they are not such it internally pads to mod 16 and flags the output stream for cropping on playback to the correct size.

This means all the right side and bottom blocks might be encoding sub optimal data.

Dark Shikari
5th January 2009, 01:34
:Aside:
X264 like all mpeg4 derived formats only intrinsically works with mod 16 height and width. If they are not such it internally pads to mod 16 and flags the output stream for cropping on playback to the correct size.

This means all the right side and bottom blocks might be encoding sub optimal data.Of course remember that x264's padding is generally more efficient than anything a user can do...

jase99
5th January 2009, 01:49
...the output restriction is in the AVIFile API used to deliver video data to applications.Out of curiosity, why does the AVIFile API restrict YV12 widths to mod 4 instead of the intrinsic restrictions of the pixel format (mod 2 for YV12) ?

squid_80
5th January 2009, 16:01
I think from memory it's because the AVIFile API requires image scanlines to be a multiple of 4 bytes long. YV12 Luma is 1 byte per pixel, hence width must be a multiple of 4 pixels.

LigH
24th February 2009, 10:35
You can provoke this error already with a simple generated clip, e.g.: ColorBars(702,576,"YV12")

It seems to be rather recent (v2.5.8?) that AviSynth checks for mod-4 widths. I don't remember this from times when I worked with earlier AviSynth versions like 2.5.6.

Looking at the luminance might be misleading, as the chrominance planes have half the dimensions, and will just require a mod-2 width?