#

DGDecodeNV 2048

What is DGDecodeNV?
Filter Syntax
DGSource()
Usage Examples
LoadPlugin() Example
DGSource() Examples

##

What is DGDecodeNV? | Table of Contents

DGDecodeNV is an Avisynth source filter (AviSynth v2.5 or higher) that decodes and frame-serves AVC (H.264), VC1, and MPEG2 video. It works in conjunction with the indexing tool DGIndexNV.

Note that DGDecodeNV automatically generates hinting data for the Avisynth filter ColorMatrix().

The "NV" in the name "DGDecodeNV" indicates that this version of the program is designed for use with the VP2 (or greater) GPU decoder on some Nvidia video cards. See here to check whether your video card has a VP2 or greater engine:

Table of Nvidia Graphics Cards Specifications

You can get the latest binaries of DGDecodeNV at http://rationalqm.us/dgdecnv/dgdecnv.html.

##

Filter Syntax | Table of Contents

###

DGSource() | Table of Contents

`DGSource(str "dgi", bool i420, int deinterlace, bool use_top_field, bool use_pf, bool use_D3D, int crop_t, int crop_b, int crop_l, int crop_r, int resize_w, int resize_h, int fieldop, bool debug)`
dgi: "[PATH\]project.dgi"

DGIndexNV Project File.
Required parameter!
Note 1: PATH\ can be omitted if "project.dgi" is in the same directory as your AviSynth (*.avs) script.

i420: true/false (default: false)

Deliver i420 instead of YV12.

deinterlace: 0/1/2 (default: 0)

Nvidia PureVideo Deinterlacer
0: no deinterlacing
1: single rate deinterlacing
2: double rate deinterlacing (bobbing)
Note that double rate deinterlacing requires Windows XP SP3!
Also note that setting deinterlace to 1 or 2 forces the field operation to be "Ignore Pulldown", regardless of the project setting.

use_top_field: true/false (default: true)

Use the top field for single rate deinterlacing.
When this parameter is true, the top field is used for single rate deinterlacing; when false the bottom field is used. When deinterlace=0 or deinterlace=2, this parameter is ignored.

use_pf: true/false (default: false)

Use the progressive_frame indication from NVCUVID. If deinterlace=1 or deinterlace=2, and use_pf=true, then only frames marked as interlaced by NVCUVID will be deinterlaced. If deinterlace=1 or deinterlace=2, and use_pf=false, then all frames will be deinterlaced.

use_D3D: true/false (default: false)

Use D3D operation. This should be set only if you receive a decoder creation error when it is not set. Some versions of the Nvidia driver require D3D operation. Always first try with use_D3D set to false and set it to true only if a decoder creation error is encountered.

crop_t, crop_b, crop_l, crop_r: integer (default: 0)

Use the GPU to crop the video. Any non-zero value for one of these parameters overrides any cropping that may have been defined in DGIndexNV for that value. These options give you the flexibility to define GPU cropping either in DGIndexNV or in the DGSource() parameters.

resize_w, resize_h: integer (default: 0)

Use the GPU to resize the video. The resizing is applied after deinterlacing. If either resize_w or resize_h is 0, no resizing is performed. If you need to crop before resizing, use the cropping filter in DGIndexNV, or the crop_t/b/l/r parameters described above.

fieldop: 0/1/2 (default: 0)

0: Honor Pulldown Flags
1: Force Film
2: Ignore Pulldown Flags

AVC, MPG, and VC1 video each provide syntax elements that enable a single field of any frame to be repeated automatically during display ("pulled down"). The extra fields do not occupy space in the video stream but are simply created by copying when the stream is decoded and displayed. This facility is most often used to display film rate clips (23.976 fps) at the NTSC rate (29.97 fps), a process called 3:2 pulldown. In practice, however, pulldown in various different patterns is commonly encountered. It can be used, for example, to display 25 fps PAL at the NTSC rate. One way to learn about "telecining" and "3:2 pulldown" is to perform a search for those terms using our friend Google.

Understanding the theory and practice required to properly set this option for a given application is nontrivial. Here we can only define the operations and give some general guidance. There is ample additional material available in existing guides.

The fieldop setting allows the user to specify how the pulldown flags are to be handled.

- Honor Pulldown Flags (fieldop=0) - The pulldown flags (if any) are obeyed and the fields are repeated. This means that the frame-served video will appear exactly as it is intended to appear on the final display device. Therefore, if you have a 3:2 pulled-down clip, you'll get the standard repeating pattern of 3 progressive frames followed by 2 interlaced frames. If you have PAL, you'll just get the encoded pictures with no repeated fields (because PAL has no pulldown flags to honor). The frame rate will always be the same as the display frame rate of the source.
- Ignore Pulldown Flags (fieldop=2) - The pulldown flags are ignored. This allows one to obtain the raw encoded pictures, with no repeated fields. However, because repeated fields intended for display are ignored and not displayed, the resulting frame rate may differ from the source frame rate. It may even vary throughout the clip, due to irregular patterns of pulldown flags. If the pulldown is irregular, use of this option will cause the audio-video sync to change at different parts of the clip, and most likely sync will not be acceptable. This option is mostly intended for power users, who would use it as a diagnostic aid for inspecting the encoded pictures. Although this option ignores the flags, they are still stored in the DGI file although DGDecodeNV will ignore them.
- Force Film (fieldop=1) - This option is intended for the special case of film content encoded at 23.976 fps but pulled down for display at 29.97 fps, i.e., 3:2 pulldown. This option will restore the 23.976 fps film rate while keeping audio and video in sync throughout the clip. This option works by ignoring pulldown flags and adjusting the frame rate back to the film rate. Do not use this option on non-3:2 pulled-down material, and, therefore, never use it on PAL.

The fieldop is perhaps the most important option to understand when using DGDecNV. Most users should first preview the project and inspect the DGIndexNV Information Panel. If the clip is 29.976fps, and the Field Repeats box in the Information Panel indicates field repeats consistent with 3:2 pulldown, then it is likely that the clip can be treated as 3:2 pulldown material, and so Force Film (fieldop=1) should be selected. Force Film can also be used on hybrid material and will decimate frames as required in video sections to maintain the film rate.

Otherwise, then you should leave fieldop=0 (Honor Pulldown Flags) for generation of the DGI file. If the result is combed (because the source is interlaced, hybrid interlaced/3:2, field blended, etc.), you may want to apply a deinterlacer or inverse telecine (IVTC) filter in your Avisynth script.

Almost invariably, if you know the source is not all 3:2 pulled-down NTSC, you will want to select Honor Pulldown Flags and then post-process as required. Keep in mind that if there are no pulldown flags, there is nothing to honor, so this option just delivers the encoded frames.

fieldop=2 (Ignore Pulldown Flags) should be necessary only for advanced users who want to see just the exact coded pictures in the video stream.

debug: true/false (default: false)

Enable textual debug overlay on the output video frames. Currently the information displayed is the DGDecodeNV version number, the GOP number, the display and coded frame numbers, and the frame coding type. Note that if leading orphaned B frames exist at the beginning of the stream, they are replaced with copies of the first I frame, and so the overlay will show data for the first I frame for each of the leading orphaned B frames. Also note that the frame numbers appropriately reflect the setting of the fieldop option.

##

Usage Examples | Table of Contents

###

AviSynth LoadPlugin() Example | Table of Contents

AviSynth's LoadPlugin() must be called before any DGDecodeNV functions can be used.
To accomplish this, add a line like the following one to the beginning of your AviSynth (*.avs) script:

    LoadPlugin("C:\My Files\DGDecodeNV.dll")

Note: This load plugin line can be omitted if DGDecodeNV.dll is in the default AviSynth plug-ins directory, because Avisynth will load it automatically.

###

DGSource() Examples | Table of Contents

To decode:

    DGSource("C:\My Files\project.dgi")

Note: The path can be omitted if "project.dgi" is in the same directory as your AviSynth (*.avs) script.
Nvidia PureVideo deinterlacing:

    DGSource("project.dgi", deinterlace=1)

Resizing:

    DGSource("project.dgi", deinterlace=2, resize_w=1280, resize_h=720)

Copyright (C) 2007-2011 Donald A. Graft, All Rights Reserved.