#

DGDecodeNV 255

What is DGDecodeNV?
Filter Syntax
DGSource() Basic Operation
DGSource() Integrated Filters
DGDenoise()
DGSharpen()
DGTweak()
DGLevels()
DGTelecide()
DGDecimate()
DGBob()
PVBob()
Usage Examples
LoadPlugin() Example
DGSource() Examples

##

What is DGDecodeNV? | Table of Contents

DGDecodeNV is an Avisynth/Vapoursynth source filter that decodes and frame-serves AVC (H.264), HEVC (H.265), VC1, and MPEG2 video. It works in conjunction with the indexing tool DGIndexNV. If Avisynth is used, Avisynth+ is required for high-bit-depth work. For this reason, this document recommends and assumes you are using Avisynth+.

The "NV" in the name "DGDecodeNV" indicates that this version of the program is designed for use with the GPU decoder on most Nvidia video cards.

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

The DGDecodeNV DLL is provided in two variants for SSE4.1 and AVX2. For best performance, use the variant appropriate to your machine's available instruction sets.

##

Filter Syntax | Table of Contents

###

DGSource() Basic Operation | Table of Contents

`DGSource(str "dgi", bool i420, int deinterlace, bool use_top_field, bool use_pf, int ct, int cb, int cl, int cr, int rw, int rh, int fieldop, bool show, string show2)`
DGSource() is a source filter that delivers decoded video in YV12/i420/YUV420P16 format. DGSource() exports appropriate Avisynth+/Vapoursynth environment variables.
If the source video has 10-bit depth, the decoded video is delivered as 16-bit and is reported to Avisynth+ as pixel format P016. If the source video has 8-bit depth, the decoded video is delivered as 8-bit and is reported to Avisynth+ as pixel format YV12. If you need a reduced color depth (less than 16 bits) for your high-bit-depth processing, you can use ConvertBits() as needed after your DGSource() call.
dgi: "[PATH\]project.dgi"

DGIndexNV Project File. Required parameter!
PATH\ can be omitted if "project.dgi" is in the same directory as your Avisynth+/Vapoursynth script.
Instead of a path to a DGI (index) file, you may give a path to a supported media file. Then, if a DGI file does not already exist, the source file will be automatically indexed and the resulting DGI file opened transparently. For this mechanism to work, the invoked DGDecodeNV.dll must be in the same folder as DGIndexNV.exe. This is usually the case for a basic installation of DGDecNV. However, if you have moved DGDecodeNV to (say) the Avisynth+ plugins folder, you should also place a copy of DGIndexNV.exe in the same folder.
When the DGI file is automatically created, by default none of the streams is demuxed and a simple index is generated. If you want demuxing of all streams to also occur, you can force that by appending the @ sign to the path, for example: DGSource("file.ts@"). Note that indexing and demuxing occur only when the DGI file does not exist.

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 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 NVDec. If deinterlace=1 or deinterlace=2, and use_pf=true, then only frames marked as interlaced by NVDec will be deinterlaced. If deinterlace=1 or deinterlace=2, and use_pf=false, then all frames will be deinterlaced.

strict_avc: true/false (default: false)

For AVC video, when strict_avc=false both IDR and I pictures are treated as seekable; when strict_avc=true only IDR pictures are treated as seekable. Often, I pictures are seekable but this is not universally true. Setting strict_avc=true when the I pictures are in fact seekable may reduce random access performance. Also, if a stream has only I frames and no IDR frames, decoding may fail. So try setting strict_avc=true only when you encounter seek errors.

ct, cb, cl, cr: integer (default: 0)

Use the GPU to crop the video. The letter c in the parameter stands for "crop" and the letters t/b/l/r stand for top/bottom/left/right, so "cb" specifies the amount to crop off the bottom of the frame. You can use the cropping tool in DGIndexNV to help in determining good values for these parameters and for optionally exporting them to the Avisynth script via the template __crop__ macro (refer to the DGIndexNV user manual for details).

rw, rh: integer (default: 0)

Use the GPU to resize the video. The resizing is applied after deinterlacing. If either rw or rh is 0, no resizing is performed. If you need to crop before resizing, use the ct/cb/cl/cr parameters described above.

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

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

Video sometimes includes 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 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.

show: true/false (default: false)

Enable textual information 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.

show2: string (default: "")

Modifies the display of the show parameter (show must be set to true for this to have any effect). The control string has this format: "x,y,custom", where x and y give the offset in the frame for display of the show information, and custom is a string that will be displayed as the last line of the displayed information. If no custom string is needed, leave that field blank. It is the users responsibility to ensure that the displayed information is not pushed off the frame as that will cause a crash (error checking for this may be added in a future version).

indexing_path: string (default: "")

Indexing path. When a media file is opened directly, this option specifies the folder to be used for the index/demux files. If this option is missing or is given as "" then the folder containing the source file will be used. The path string should not include a trailing '\' character.

###

DGSource() Integrated Filters | Table of Contents

In addition to the basic decoding operation described above, DGDecodeNV.dll provides some filtering functionality. Currently, that includes denoising, sharpening, HDR-to-SDR functionality, tweaking (brightness/contrast/hue/saturation), and levels adjustment. The filtering is provided in both integrated and standalone forms. The standalone filters can be used independently of DGSource(), i.e., with other source filters. The integrated filters are part of DGSource(), such that filter chains defined by the DGSource() line are executed completely on the GPU, without transferring intermediate frames to the CPU. This can significantly improve performance, especially for large frame sizes.
Currently, the order of filter execution is 1) basic decoding, 2) HDR-to-SDR, 3) denoising, 4) sharpening, 5) tweaking, 6) levels adjustment, regardless of the order of the parameters given to DGSource(). As more filters are added, a mechanism for specifying the order may be implemented. The filters may be individually enabled/disabled.
4:4:4 video is not yet supported for integrated or standalone filtering.
All of the integrated filters support Vapoursynth, but the standalone versions currently do not support Vapoursynth.
HDR-to-SDR: The integrated HDR-to-SDR functionality is the same as for the separately available DG Tools filter DGHDRtoSDR. For integrated filtering, the operation is controlled by parameters beginning with 'h2s_'. For descriptions of the parameters refer to the user manual for DGHDRtoSDR(). Following are the available options:
h2s_enable=0/1 (default 0)
h2s_white
h2s_black
h2s_gamma
h2s_hue
h2s_r
h2s_g
h2s_b
h2s_tm
h2s_roll
h2s_mode
Denoising: The integrated denoising functionality is the same as for the standalone DGDenoise filter documented later in this document. For integrated filtering, the operation is controlled by parameters beginning with 'dn_'. Refer to the 'DGDenoise()' section of the document for details. Following are the available options:
dn_enable=0/1/2/3 (int default 0)
dn_strength
dn_cstrength
dn_quality
dn_tthresh
dn_show
Sharpening: The integrated sharpening functionality is the same as for the standalone DGSharpen filter documented later in this document. For integrated filtering, the operation is controlled by parameters beginning with 'sh_'. Refer to the 'DGSharpen()' section of the document for details. Following are the available options:
sh_enable=0/1 (default 0)
sh_strength
sh_os
sh_us
sh_top
sh_bottom
sh_left
sh_right
Tweaking: The integrated tweaking functionality is the same as for the standalone DGTweak filter documented later in this document. For integrated filtering, the operation is controlled by parameters beginning with 'tw_'. Refer to the 'DGTweak()' section of the document for details. Following are the available options:
tw_enable=0/1 (default 0)
tw_hue
tw_sat
tw_bright
tw_cont
tw_coring
tw_startHue
tw_endHue
tw_maxSat
tw_minSat
tw_interp
Levels adjustment: The integrated levels functionality is the same as for the standalone DGLevels filter documented later in this document. For integrated filtering, the operation is controlled by parameters beginning with 'lv_'. Refer to the 'DGLevels()' section of the document for details. Following are the available options:
lv_enable=0/1 (default 0)
lv_input_low
lv_gamma
lv_input_high
lv_output_low
lv_output_high
lv_chroma
lv_coring
lv_dither

###

DGDenoise() | Table of Contents

`DGDenoise(clip c, int enable, float strength, float cstrength, int quality, int tthresh, int show, int device)`
DGDenoise() is a fast stand-alone CUDA filter that implements NLM denoising spatially together with optional temporal denoising. The input clip must be in the YV12 or YUV420P16 format. DGSource() delivers YUV420P16 when the source stream has a 10/12/16-bit depth.
c: Avisynth clip (default: last)
enable: int (default: 0)

0: no denoising
1: spatial denoising only
2: temporal denoising only
3: spatial and temporal denoising

strength: float value (default: 0.15)

Strength of the Non-Local Means (NLM) denoising for the luma plane. Typical values for strength are in the range 0.1-1.0. If you specify 0.0 then luma denoising is disabled. Note that if you have interlaced source you should deinterlace with deinterlace=1 or deinterlace=2. If you have hard pulldown, or you have soft pulldown that is being honored, then invoke it through DGDenoise() after performing external IVTC. The essential point to remember is that denoising should be applied to progressive frames. If you must retain interlacing, then separate the fields, apply DGDenoise(), and then re-weave the fields.

cstrength: float value (default: 0.0)

Strength of the Non-Local Means (NLM) denoising for the chroma planes. Typical values for cstrength are in the range 0.1-1.0. If you specify 0.0 then chroma denoising is disabled. Note that if you have interlaced source you should deinterlace with deinterlace=1 or deinterlace=2. If you have hard pulldown, or you have soft pulldown that is being honored, then invoke it through DGDenoise() after performing external IVTC. The essential point to remember is that denoising should be applied to progressive frames. If you must retain interlacing, then separate the fields, apply DGDenoise(), and then re-weave the fields.

quality: "good"/"better"/"best" (default: "good")

Determines the width of the search window for the NLM denoising. Note that "good" is already of high quality [corresponds to width 9 in previous versions of DGDenoise()]. The "better" and "best" settings are for provided for users wanting enlarged search radiuses while being willing to accept the substantial performance penalties. For most sources, "good" should be fine. Note that "better" and "best" correspond to larger radiuses not available in previous versions of DGDenoise().

tthresh: float (default: 0.75)

The temporal denoising can average the current pixel with one or two previous pixels when the pixel is in an area considered to be not moving. The choice of one or two previous pixels is determined automatically. This parameter determines the motion detection threshold for the temporal denoiser. Decrease it to consider more areas to be moving, and thereby be excluded from temporal averaging. Use the 'show' option below to visualize the areas considered to be moving, and thereby allow prop setting of this parameter.

show: int (default: 0)

Set this to 1 to visualize the areas filtered by the temporal denoiser. Areas subject to filtering are shown in white. Areas not filtered are passed through from the source frame. Increasing dn_tthresh produces more white areas.

device: int (default: 255)

When set to 255, the first GPU found is used. When set to any other value the GPU with that ordinal value is used.

###

DGSharpen() | Table of Contents

`DGSharpen(clip c, float strength, int os, int us, int top, int bottom, int left, int right, int device)`
DGSharpen() is a fast stand-alone CUDA filter that implements limited sharpening like the well-known filter LimitedSharpenFaster(). The input clip must be in the YV12 or YUV420P16 format. DGSource() delivers YUV420P16 when the source stream has a 10/12/16-bit depth.
c: Avisynth clip (default: last)
strength: float value (default: 6.0)

Strength of the sharpening. A typical value for medium strength is 6.0. Note that if you have interlaced source you should deinterlace with deinterlace=1 or deinterlace=2. If you have hard pulldown, or you have soft pulldown that is being honored, then invoke it through DGSharpen() after performing external IVTC. The essential point to remember is that sharpening should be applied to progressive frames. If you must retain interlacing, then separate the fields, apply DGSharpen(), and then re-weave the fields.

os: int (default: 0)

This option allows the sharpened pixels to overshoot the local limit. Set it to the amount of overshoot to be allowed.

us: int (default: 0)

This option allows the sharpened pixels to undershoot the local limit. Set it to the amount of undershoot to be allowed.

top: int (default: 0)

The number of rows at the top to be excluded from sharpening. Good for addressing artifacts at the edge of letterboxing, etc.

bottom: int (default: 0)

The number of rows at the bottom to be excluded from sharpening.

left: int (default: 0)

The number of columns at the left to be excluded from sharpening.

right: int (default: 0)

The number of columns at the right to be excluded from sharpening.

device: int (default: 255)

When set to 255, the first GPU found is used. When set to any other value the GPU with that ordinal value is used.

###

DGTweak() | Table of Contents

`DGTweak(clip c, float hue, float sat, float bright, float cont, int coring, int startHue, int endHue, int maxSat, int minSat, int interp, int device)`
DGTweak() is a fast stand-alone CUDA filter that implements color tweaking (brightness/contrast/hue/saturation) modeled on the Avisynth+ internal filter Tweak(). The input clip must be in the YV12 or YUV420P16 format. DGSource() delivers YUV420P16 when the source stream has a 10/12/16-bit depth.
c: Avisynth clip (default: last)
hue: float value (-180.0 to +180.0, default: 0.0)

Adjust the color hue of the image. Setting hue greater than 0.0 shifts the image towards red. Setting hue less than 0.0 shifts the image towards green.

sat: float (0.0 to 10.0, default: 1.0)

Adjust the color saturation of the image by controlling gain of the color channels. Setting sat greater than 1.0 increases the saturation. Setting sat less than 1.0 reduces the saturation. Use sat=0 to convert to grey scale.

bright: float (-255.0 to 255.0, default: 0.0)

Change the brightness of the image by applying a constant bias to the luma channel. Setting bright greater than 0.0 increases the brightness. Setting bright less than 0.0 decreases the brightness. Note that bright is autoscaled for 16-bit, so you will use the range -255.0 to 255.0 for both 8-bit and 16-bit.

cont: float (0.0 to 10.0, default: 1.0)

Change the contrast of the image by multiplying the luma values by a constant. Setting cont greater than 1.0 increases the contrast (the luma range is stretched). Setting cont less than 1.0 decreases the contrast (the luma range is contracted).

coring: int (default: 1)

When set to 1, the luma (Y) and chroma are clipped to TV-range. When set to 0, the luma and chroma are unconstrained.

startHue/endHue: int (0 to 360 degrees, default: 0/360)

The hue and saturation will be adjusted for image hue values in the range [startHue, endHue] when startHue is less than endHue. If endHue is less than startHue, then the range [endHue, 360] and [0, startHue] will be selected (thus anti-clockwise). Note that the hue is periodic, thus a hue of 360 degrees corresponds to a hue of zero degrees. When using the default values, all pixels will be processed.
The following gives some arbitrary startHue and endHue values for the basic colors:
Red: 75-115
Yellow: 150-180
Green: 191-258
Cyan: 279-300
Blue: 316-4
Magenta: 28-52
A useful technique to properly choose your startHue/endHue values is to temporarily set sat = 0. Then the parts of the image that are selected will show up as gray.

maxSat/minSat: int (0 to 150, default: 150/0)

The hue and saturation will be adjusted for image saturation values in the range [minSat, maxSat]. Practically speaking, the percentage saturation of a pixel will be in the range [0, 100], since these correspond to valid 8-bit RGB pixels (100% corresponds to R = 255, G = B = 0, which has a saturation of 119 in units of chroma). An overshoot (up to 150%) is allowed for non-valid RGB pixels (150% corresponds to U = V = 255, which has a saturation of sqrt(1272 + 1272) = 180). Thus when using the default values all pixels will be processed.
A useful technique to properly choose your maxSat/minSat values is to temporarily set sat = 0. Then the parts of the image that are selected will show up as gray.

interp: int (0 to 64 in chroma units, default: 16)

Interpolate the saturation adjustment at the edges of the chosen range to prevent banding. The adjustment is interpolated between 1.0 and sat in the range [minS - interp, minS] and between sat and 1.0 in [maxS, maxS + interp], where minS and maxS are the equivalents of minSat and maxSat in chroma units (100% = 119 units). There is no interpolation for interp = 0, which can be useful when a clip consists of uniform colors and you want a hard cutoff. The interpolation is linear.

device: int (default: 255)

When set to 255, the first GPU found is used. When set to any other value the GPU with that ordinal value is used.

###

DGLevels() | Table of Contents

`DGLevels(clip c, float input_low, float gamma, float input_high, float output_low, float output_high, int chroma, int coring, int device)`
DGLevels() is a fast stand-alone CUDA filter that implements levels adjustment modeled on the Avisynth+ internal filter Levels(). The input clip must be in the YV12 or YUV420P16 format. DGSource() delivers YUV420P16 when the source stream has a 10/12/16-bit depth.
c: Avisynth clip (default: last)
input_low: float value (default: 0.0)

Input values at input_low or lower are treated as black, and lighter colors are darkened proportionally. Therefore raising input_low darkens the output. This value takes the range 0.0-255.0 for 8-bit, and 0.0-65535.0 for 16-bit.

gamma: float (1.0)

Higher gamma brightens the output; lower gamma darkens the output.

input_high: float (default: 255.0 for 8-bit, 65535.0 for 16-bit)

Input values at input_high or higher are treated as white, and darker colors are brightened proportionally. Therefore lowering input_high brightens the output. This value takes the range 0.0-255.0 for 8-bit, and 0.0-65535.0 for 16-bit.

output_low: float (default: 0.0)

Dark values brighten to gray as output_low becomes larger. This value takes the range 0.0-255.0 for 8-bit, and 0.0-65535.0 for 16-bit.

output_high: float (default: 0.0)

Light values darken to gray as output_high becomes smaller. This value takes the range 0.0-255.0 for 8-bit, and 0.0-65535.0 for 16-bit.

chroma: int (0/1, default: 1)

When set to 1, the chroma is asjusted. When set to 0, the chroma is not adjusted.

coring: int (0/1, default: 0)

When true, for 8-bit, input luma is clamped to the range 16-235 and the chroma to 16-240; this clamped input is scaled from 16-235 to 0-255, the conversion takes place and then output is scaled back to 16-235. Behavior is the same but with constants multiplied by 256 for 16-bit. When false, the conversion takes place without any scaling. coring was created for VirtualDub compatibility; set it to 1 when needed for compatibility with older scripts. In the opinion of some, you should always use coring=0 if you are working directly with luma values (whether or not your input is 16-235).
Note TV-range video can be correctly processed with coring=0; for example,
Levels(0, 1.6, 255, 0, 255, coring=1)
produces the same result as
Levels(16, 1.6, 235, 16, 235, coring=0)
except that the output is not clipped to TV-range. Black and white levels are preserved while adjusting gamma, unlike
Levels(0, 1.6, 255, 0, 255, coring=0)

dither: int (0/1, default: 0)

This option is currently not implemented.

device: int (default: 255)

When set to 255, the first GPU found is used. When set to any other value the GPU with that ordinal value is used.

###

DGTelecide() | Table of Contents

`DGTelecide(clip c, int mode, float pthresh, float dthresh, bool blend, bool map, bool show, int device)`
DGTelecide() is a fast stand-alone CUDA filter that implements field matching and adaptive deinterlacing. The input clip must be in the YV12 format. Note that DGTelecide() requires the field order to be properly specified. The safest policy is to always set the correct order using AssumeTFF()/AssumeBFF(). AVISource() is dangerous without doing so because it always sets BFF. Note that DGSource() sets the correct field order, so when it is used as the source filter it is not necessary to manually set the field order.
DGTelecide() reconstructs the original progressive frames by properly matching fields. Sometimes, due for example to bad edits, a good match cannot be found and a progressive frame cannot be reconstructed. In that case, if postprocessing is enabled (mode = 1), the frame will be deinterlaced so that a bad frame is not delivered. DGTelecide() also provides modes for pure adaptive deinterlacing without field matching. Refer to the description for the mode parameter for details.
c: Avisynth clip (default: last)
mode: int value (default: 0)

Mode of operation:
Mode 0: Field matching without adaptive deinterlacing of frames with a bad match (no postprocessing).
Mode 1: Field matching with adaptive deinterlacing of frames with a bad match (postprocessing).
Mode 2: Adaptive deinterlacing of all frames (unconditional deinterlacing).
Mode 3: Adaptive deinterlacing of frames determined to be combed (conditional deinterlacing).

pthresh: float value (default: 0.0)

Threshold for postprocessing. If the metric for a matched frame exceeds pthresh, the frame will be deinterlaced. Use the show option to see the metrics and thereby set an appropriate pthresh value. Postprocessing applies only to frames with no good match and it allows DGTelecide() to deliver reasonable looking frames in such instances.

dthresh: float value (default: 10.0)

Threshold for adaptive deinterlacing. This threshold is used to detect interlaced lines. Lower values deinterlace more of the frame, while higher values deinterlace less. Use the map option to visualize the lines detected as interlaced and thereby set an appropriate dthresh value.

blend: bool (default: false)

When blend=true deinterlaced frames are deinterlaced using field blending. When blend=false deinterlaced frames are deinterlaced using field interpolation.

map: bool (default: false)

When set to true, then for deinterlced frames, lines detected as interlaced are shown in white. Use this option to appropriately set your deinterlacing threshold dthresh.

show: bool (default: false)

When set to true, metrics information is overlaid onto the frame.

device: int (default: 255)

When set to 255, the first GPU found is used. When set to any other value the GPU with that ordinal value is used.

###

DGDecimate() | Table of Contents

`DGDecimate(clip c, int cycle, int keep, int device, bool show)`
DGDecimate() is a fast stand-alone CUDA filter that implements N-in-M frame decimation. The input clip must be in the YV12 format.
c: Avisynth clip (default: last)
cycle: int value (default: 5, max 40)

Decimation cycle size M. For every cycle of M frames, N frames will be retained, where N is given by the keep parameter. The M - N frames that differ least from their predecessors are discarded.

keep: int value (default: 4)

Decimation keep number N. For every cycle of M frames, N frames will be retained, where N is given by the keep parameter. The M - N frames that differ least from their predecessors are discarded.

device: int (default: 255)

When set to 255, the first GPU found is used. When set to any other value the GPU with that ordinal value is used.

show: bool (default: false)

When set to true, metrics information is overlaid onto the frame. Note that if the cycle size is greater than 10, only the first 10 frame metrics are shown.

###

DGBob() | Table of Contents

`DGBob(clip c, int order, int mode, int device)`
DGBob() is a fast stand-alone CUDA filter that implements the YADIF deinterlacing algorithm (original concept by Michael Niedermayer). The input clip must be in the YV12 format. Note that DGBob() requires the field order to be properly specified. DGBob can take the order from Avisynth but the safest policy is to set the correct order using the 'order' parameter. For example, AVISource() is dangerous without doing so because it always sets BFF. Note that DGSource() sets the correct field order, so when it is used as the source filter it is safe to omit the 'order' parameter or set it to -1.
c: Avisynth clip (default: last)
order: int value (default: -1)

Field order: -1: take order from Avisynth, 0: BFF, 1: TFF.

mode: int value (default: 1)

Rendering mode: 0: single-rate deinterlacing, 1: double-rate deinterlacing, 2: double-rate deinterlacing but retain the original frame rate (for slow motion).

device: int (default: 255)

When set to 255, the first GPU found is used. When set to any other value the GPU with that ordinal value is used.

###

PVBob() | Table of Contents

`PVBob(clip c, int order, int mode, int device)`
PVBob() is a stand-alone version of the PureVideo deinterlacer. This is the same functionality that you get using the deinterlace parameter of DGSource(). If you are sourcing your video using DGSource(), it is always preferable to invoke the deinterlacer using DGSource() rather than PVBob(). PVBob() is intended for use when a different source filter is used. The input clip must be in the YV12 format. Note that PVBob() requires the field order to be properly specified. PVBob can take the order from Avisynth but the safest policy is to set the correct order using the 'order' parameter. For example, AVISource() is dangerous without doing so because it always sets BFF.
c: Avisynth clip (default: last)
order: int value (default: -1)

Field order: -1: take order from Avisynth, 0: BFF, 1: TFF.

mode: int value (default: 1)

Rendering mode: 0: single-rate deinterlacing, 1: double-rate deinterlacing.

device: int (default: 255)

When set to 255, the first GPU found is used. When set to any other value the GPU with that ordinal value is used.

##

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+/Vapoursynth script.
nVidia PureVideo deinterlacing:

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

Resizing:

    DGSource("project.dgi", rw=1280, rh=720)

Standalone denoising:

    DGSource("project.dgi")
    DGDenoise(strength=0.15)

Standalone sharpening:

    DGSource("project.dgi")
    DGSharpen(strength=0.75)

Inverse telecine (IVTC) (for hard 3:2 pulldown):

    DGSource("project.dgi")
    DGTelecide(mode=1, pthresh=3.5)
    DGDecimate()

Deinterlacing (without using nVidia PureVideo):

    DGSource("project.dgi")
    DGTelecide(mode=2, dthresh=7.5)

Use of integrated filtering:

    dgsource("project.dgi",dn_enable=3,dn_strength=0.08,dn_cstrength=0.08,dn_tthresh=75,sh_enable=1)

Use of Vapoursynth:

    import vapoursynth as vs
    from vapoursynth import core
    core.std.LoadPlugin(r"...\dgdecodenv_avx2.dll")
    video = core.dgdecodenv.DGSource(r"Nature.ts",dn_enable=3,dn_strength=0.1,deinterlace=1)
    # video = vs.core.text.ClipInfo(video)
    video.set_output()

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