TIVTC is a package of filters intended for performing Inverse Telecine on film stored as interlaced video with a telecine pattern. For more information on telecine and IVTC check out our glossary and Digital Video Fundamentals guide on the subject.
There are essentially three steps to the IVTC process. Field Matching attempts to determine which fields should be paired to re-create the original film frames. Then combing artifacts from putting the fields together need to be cleaned up This is done with the TFM filter. Finally the extra frames need to be removed with TDecimate.
TFM(int "order", int "mode", int "PP", int "field", int "slow",
int "mchroma", int "cthresh", int "chroma", string "D2V", int "flags")
|"order"||Integer||Field order of clip: -1 for AviSynth/D2V value, 0 for BFF, or 1 for TFF. See below for more details|
|"mode"||Integer||The matching strategy to use. See below for more details|
|"PP"||Integer||The method for handling combing artifacts. See below for more details|
|"field"||Integer||Field to match from: -1 for AviSynth/D2V value, 0 for BFF, or 1 for TFF. See below for more details|
|"slow"||Integer||1||Field matching algorithm: 0 for Normal, 1 for Slow, or 2 for Slowest. Higher values are slower but may result in better matches|
|"mchroma"||Boolean||True||Include chroma information to match fields. Set to false if your clip has chroma artifacts that hinder proper field matching|
|"cthresh"||Integer||9||Threshold for detecting a frame as combed. Valid values range from -1 (all pixels automatically combed) to 255 (no pixels combed). Recommended values for most sources are from 8 - 12.|
|"chroma"||Boolean||False||Include chroma information to detect combing artifacts. See below for more details.|
|"d2v"||String||D2V file to get field order and other information to aid field matching.|
|"flags"||Integer||4||Which information to use from D2V project. See below for more details.|
TFM is the field matching filter in the TIVTC filter package (TIVTC.dll). It's primary use is in the field matching portion of an IVTC operation, returning the original film frames (plus duplicates) from a film source that's been telecined for NTSC video. When using it in this way, it's generally followed by TDecimate, a filter that will remove the duplicate frames, restoring the original framerate as well. This video can be encoded to a format for computer or digital TV (DTV) viewing, although if you're final destination is NTSC video you may have to add pulldown flags later on.
In addition to IVTC, TFM's field matching can be used to fix field shifted video where a single field has been added or removed somewhere, shifting one field from each frame so that they're encoded in either the frame before or after their opposite field. For example, a 2:2:2:2:2:2:2:2:2:2:2:3 pulldown pattern (24fps film -> 25fps PAL) would shift half the fields in a clip. If this were done by actually duplicating frames it could cause problems for a standalone player or HDTV's deinterlacer.
orderThe default value for order will depend on the field order set in AviSynth for the clip. You should always make sure your clip has the correct field order before field matching. The default may also come from a D2V project if one is specified. Setting the order to either 0 (BFF) or 1 (TFF) overrides the field order reported by AviSynth or a D2V file.
modeBy default TFM uses mode 4 to find matches for fields. From mode 0 to mode 5 the decisions consider more fields for potential matches as the value increases. Mode 0 will consider only 2 fields for matches, while mode 5 may consider as many as 5 matches. Unless you're experiencing problems getting good matches you should leave this setting alone.
- 0 = 2-way match
- 1 = 2-way match + 3rd match on combed
- 2 = 2-way match + 3rd match (same order) on combed
- 3 = 2-way match + 3rd match on combed + 4th/5th matches if still combed
- 4 = 3-way match
- 5 = 3-way match + 4th/5th matches on combed
PPPP determines what will be done about combing artifacts created by combining fields that don't line up perfectly. A setting of 0 skips this step altogether. Values between 2 and 7 perform various types of deinterlacing. The default setting of 6 for Motion Adaptive Interpolation is generally as low as you should set this. Lower values may be faster but will generally produce lower quality frames.
- 0 = nothing (don't even look for combed frames)
- 1 = find/hint combed frames but don't deinterlace
- 2 = dumb blend deinterlacing
- 3 = dumb cubic interpolation deinterlacing
- 4 = dumb modified-ela deinterlacing
- 5 = motion-adaptive blend deinterlacing
- 6 = motion-adaptive cubic interpolation deinterlacing
- 7 = motion-adaptive modified-ela deinterlacing
fieldBy default TFM uses the dominant field as a starting points, and then finds fields to match from there. As with order this is taken from AviSynth's field order or a D2V project. Setting the order to either 0 (BFF) or 1 (TFF) overrides the field order reported by AviSynth or a D2V file.
chromaAlthough chroma information is useful for field matching, since it typically has a significantly lower resolution than luma it's not as useful for detecting combing artifacts in field matched frames. In most cases you should keep the default setting of False. See our Digital Video Fundamentals guide on Color Formats for a more detailed explanation of color encoding and resolution.
flagsIf you specify a D2V file to get information from you may also want to specify which information is used to help match fields. This is particularly useful for clips that alternate between film with pulldown and actual telecined video since the D2V project will contain detailed information about RFF (pulldown) flags. A value of 0 will only use the D2V file to ensure field order changes (which aren't allowed and can cause field matching problems) are corrected. By default this information will be used by TFM as the field order for all operations. The default value of 4 allows the maximum use of both D2V information and TFM's internal routines.
- 0 = Check the d2v file for illegal transitions and set the order parameter if it is not already manually set. Also, pass on rff flag duplicate info to tdecimate.
- 1 = Same as 0, plus use the trf flags for field matching in film sections (sections where the trf flags follow the 012301... pattern)
- 3 = Same as 0, but don't pass on any info to tdecimate (i.e. only set order and check for illegal transitions)
- 4 = Same as 1, but d2v matches are checked for being combed. If a d2v match is detected as combed then tfm uses its own matching routine for that frame.
- 5 = Same as 4, but d2v matches are only checked for being combed around scenechanges.
Example CodeMatch fields from a D2V project to film frames:
TFM(d2v = "D:\Folder\Filename.d2v")
Match fields from a clip with chroma artifacts:
TFM(d2v = "D:\Folder\Filename.d2v", mchroma = False)
Match fields from a clip using the highest quality field matching algorithm:
TFM(d2v = "D:\Folder\Filename.d2v", slow = 2)
Match fields from a clip with higher than normal sensitivity to combing artifacts:
TFM(d2v = "D:\Folder\Filename.d2v", cthresh = 6):
When To Use ItTIVTC is currently the leading IVTC package for AviSynth, although it's possible you may have a clip that would be handled better by the older Decomb package described in our AVSEdit guide. It can be used to recover film frames from telecined NTSC, as well as some PAL sources.
TDecimate(int "mode", int "cycleR", int "cycle", float "rate", bool "display"
|"mode"||Integer||0||Set this to 0 for standard IVTC decimation, 1 for most animation, or 2 for non-standard decimation. See filter description for more details.|
|"CycleR"||Integer||1||Sets the M for M-in-N decimation. See filter description for more details.|
|"cycle"||Integer||5||Sets the N for M-in-N decimation. See filter description for more details.|
|"rate"||Floating Point Decimal||23.976||Framerate for output clip.|
|"display"||Boolean||False||Display decimation decision information over the frame.|
TDecimate is generally used as the final step in recovering progressive frames from sources with duplicated fields. The first step is generally performed by TFM, and results in duplicate frames. By decimating these extras are removed, resulting in the best possible approximation of the original source. Encoding in the original progressive format will not only give you better image quality on modern progressive HDTV displays, but also improve compression without sacrificing quality.
The primary option to consider is the mode. For most animation sources, especially anime, you have to consider the possibility that some original frames are already duplicates. If the field duplication doesn't exactly match the 2:3 pattern used for standard pulldown it can cause problems determining which frames to decimate. Using Mode 1 for these clips will generall resolve the problem. It's not as fast as Mode 0, and therefore not recommended for standard live action film sources.
Mode 0 is the default M-in-N decimation. This is also referred to as M-in-N decimation because it removes M frames out of each N. The default values of M = 1 and N = 5 will result in the same decimation pattern as Mode 1. By setting N equal to 25 you can remove a single duplicate from PAL clips. For silent movies it's common to encounter lower film framerates like 20fps. You can also decimate to these framerates using M-in-N decimation most of the time.
Example CodeStandard final IVTC step for live action film sources:
TFM(d2v = "D:\Folder\Filename.d2v").TDecimate()
Standard final IVTC step for animated sources:
TFM(d2v = "D:\Folder\Filename.d2v").TDecimate(mode = 1)
Decimate from 30fps to 20fps (or 29.97fps to 19.98fps) :
TFM(d2v = "D:\Folder\Filename.d2v").TDecimate(cycle = 3)
Decimate from 25fps to 24fps:
TFM(d2v = "D:\Folder\Filename.d2v").TDecimate(cycle = 25)
When To Use ItUse TDecimate as the final step in the IVTC process.
previousCropping and Borders | nextBob Deinterlacing
Written by: Rich Fiscus