# MPEGDecoder.dll YV12 Version for AviSynth 2.5 Only!
(Version 2.03 Alpha)

### By Nic

#### Introduction

This DLL lets you load VOB/MPEG-2 ES,PS,TS/MPEG-1 files to be loaded directly into Avisynth.
A Sample AVISynth Script looks like this:
LoadPlugin("MPEGDecoder.dll")
MPEGSource("d:\kiss\kiss.vob")
This avs file can now be loaded into VDub/etc.

#### The Way it works

Unlike the previous version, this MPEGDecoder.dll is primarily based on the DVD2AVI d2v file format.
However, if no D2V file is supplied, it creates one itself

#### Main Parameters

The parameters for 'MPEGSource' are as follows:
For normal use:
MPEGSource("e:\rip\spiderman.d2v")
Which will load a d2v as normal
or:
MPEGSource("e:\rip\VTs_01_1.vob+e:\rip\VTs_01_2.vob+e:\rip\VTs_01_3.vob)
Here the first thing that MPEGDecoder.dll will do is to check for a e:\rip\VTs_01_1.d2v file.
if a file with that name exists it will load that and assume that the d2v is for the three files.
if e:\rip\VTs_01_1.d2v does not exist, it will be created and then loaded automatically.
For D2V files created automatically by MPEGDecoder.dll it does not know if force film should be turned on.
If it should then put "ff" as the third parameter
i.e.
MPEGSource("e:\rip\big.vob", 0, "ff")

#### Detailed Parameter Description

Usage:
MPEGSource(file names, number of frames, commands)
file names
This can be a sequence of MPEG files combined with a '+' or a d2v file.
number of frames
This should always be 0 as a default. But can be used to force the decoder to return a certain number of frames. MPEGSource can not correctly create d2v files for MPEG-1 yet, so use this to input the correct number of frames.
A value of -2 can also be written here. This means no d2v can be used and therefore only files can be inputed in the first parameter. From the files specified Directshow is asked to get the correct number of frames.
commands
The only two commands at present are "ff" which forces film. (as described above) and "nod2v".
"nod2v" is similar to the -2 command in that you can only specify files and nod2v is used or created. But it allows you to specify a number of frames in the "number of frames" parameter.

#### Misc/Notes

- Pro's/Con's
BUG: The MPEG2 Repeat Field flag is not taken into consideration. So when decoding NTSC films its like Force Film is already turned on.
PRO: Its fast, faster decoding than normal MPEG2DEC.DLL(MPEG2Source). This speeds up encoding :)
- Info
Read this document carefully!
Transport streams can be used the same as Program Streams, the MPEGDecoder should detect that they are transport streams and determine the PIDs automatically.
- Bugs
When creating d2v files for MPEG-1 files the, number of frames determined is wrong. either use -2, or enter the correct number of frames. (if you want to find to find the correct number of frames exactly, load the mpeg-1 into VirtualDub and it will tell you the number of frames through File->File Information)
When seeking, sometimes the video looks corrupt, ignore this as it will not look corrupt when encoding

#### Credits

The MPEG2 decoding library is based on libmpeg2.sf.net (Michel Lespinasse , Aaron Holtzman )
ColorSpace code comes from the XviD MPEG-4 project (www.xvid.org) (Michael Militzer, Peter Ross, edgomez, skal)
Ive pinched the way this doc looks from Decomb 3.8's documentation (by Donald Graft - http://shelob.mordor.net/dgraft/ )

#### Changelog as of 2.0 alpha

2.03 alpha
Added automatic Transport Stream support
-2 dshow framecount guess support and frame count overiding
2.02 alpha
Fixed frame counting bug (did not take into consideration trf 0)
2.01 alpha
Fixed a bug in ForceFilm mode
2.0 alpha
Due to lack of time, Im releasing a test version. As I dont have time to test myself :(
All code is GPL!
email: nic@nic.dnsalias.com