NMM视频技术(旧)

 找回密码
 成为会员
搜索
查看: 28552|回复: 3

[资料]Deinterlace/IVTC插件相关[中/英/日]

[复制链接]
发表于 2004-10-29 13:00 | 显示全部楼层 |阅读模式
本贴介绍Decomb以及IT两个Deinterlace/IVTC插件。

语言:中/英/日

本贴包含以下文章
《Decomb Plugin for Avisynth Frequently Asked Questions (FAQ)》(《Decomb问答》)[英]
《Decomb Plugin for Avisynth Tutorial》(《Decomb使用指南》)[中/英对照]
《Decomb Plugin for Avisynth 2.5 Reference Manual》(《Decomb参考手册》)[英]
《IT使用手册》[日]

其中:Decomb相关内容是针对Decomb5.2.1版本的。
 楼主| 发表于 2004-10-29 13:05 | 显示全部楼层

Decomb Plugin for Avisynth Tutorial

Decomb指南(初译稿,中英对照)

翻译:大虾(dgwxx)
转载请注明作者、出处。

简介
本文档是Decomb的使用指南. 本文将指导你如何正确使用Telecide() 和 Decimate() 来处理影片. 本文将不包括FieldDeinterlace(),因为你能很容易的从Decomb参考手册中找到它的用法。
请参看《Decomb参考手册》来获得关于Decomb更详细的描述及其参数用法。
________________________________________
Telecide()
Telecide() recovers progressive frames (by finding and aligning matching fields). Do not use Telecide() on streams that do not contain telecined progressive frames, such as pure interlaced video.
Telecide()用于恢复progressive frames(通过寻找并校正匹配场)。不要在不包含telecined progressive frames的影片上使用Telecide(),比如纯交错视频。
Step 1. Determine and Set the Field Order
第一步:确定并设定场顺序
It is essential to set the field order properly for correct rendering. The field order is set using the mandatory parameter order. Set order=1 for top field first; set order=0 for bottom field first. Because setting it correctly is so important, you are strongly encouraged not to make assumptions about the field order of a clip, but rather to verify the field order using the following procedure.
对于正确的还原原始影像,设定正确的场顺序非常重要。场顺序通过参数order来设定,本参数为必选参数。设定order=1为奇数场优先,设定order=0为偶数场优先。因为确定正确的场顺序实在太重要了,所以强烈建议你按照下面的方法确认场顺序,而不是猜测场顺序。
To determine the field order, make an Avisynth script that serves the raw clip without any processing. If it were an AVI, then just AviSource() would be used. For our examples, we'll use AviSource(). Add a script line to separate the fields using top field first, as follows:
要确定场顺序,需要建立一个不对片源进行任何处理的AVS脚本。比如,片源是AVI,那么只使用AviSource()来打开片源。首先照下面建立一个AVS脚本来分离顶场:

AviSource("your_clip.avi"
AssumeTFF().SeparateFields()
Now serve the script into VirtualDub and find an area with motion. Single step forward through the motion. Note whether the motion progresses always forward as it should, or whether it jumps back and forth as it proceeds. For example, if the field order is wrong, an object moving steadily from left to right would move right, then jump back left a little, then move right again, etc. If the field order is correct, it moves steadily to the right.
现在,用视频处理软件(比如VirtualDub)打开AVS脚本,然后找到一段包含运动物体的影片并步进向前(一帧一帧地向前),注意运动物体是一直朝它该去的方向运动,还是在运动过程中突然向回运动。比如,如果场顺序错了,本来应该一直朝右侧运动的物体在运动过程中突然向左跳一下,然后继续朝右运动;如果场顺序正确,那么它会平稳的一直向右运动。
If the motion is correct with AssumeTFF().SeparateFields(), then your field order is top field first and you must set order=1. If the motion is incorrect, then your field order is bottom field first and you must set order=0. If you are want to double check things, you can use AssumeBFF.SeparateFields() to check correct operation for bottom field first.
如果使用AssumeTFF().SeparateFields()的时候物体运动正常,则该段影片的场顺序是奇数场优先,需要设定order=1;如果运动不正常,则是偶数场优先,需要设定order=0。如果你想进一步确认是否是偶数场优先,使用AssumeBFF.SeparateFields()。
Let's assume we have a top field first clip in the following steps. You would of course use the correct field order for your clip. So far, then, our script is as follows:
我们假设我们的片源是奇数场优先。到目前为止,我们的AVS脚本是下面的样子:
AviSource("your_clip.avi"
Telecide(order=1)
Step 2. Set up Pattern Guidance If Appropriate
第二步:设定Pattern Guidance
Often you know from the nature of a clip what telecining pattern (if any) is used and therefore what the pattern of field matches should be. Telecide()'s pattern guidance feature uses that information to improve the field matching. Pattern guidance is controlled by the optional guide parameter. It has 4 possible values: guide=0 means disable pattern guidance; guide=1 means use 3:2 pulldown guidance (24fps->30fps); guide=2 means use 2:2 guidance (PAL); and guide=3 means use 3:2:3:2:2 guidance (25fps->30fps).
通常,通过了解片源的过带方式,决定场匹配模式。Telecide()的pattern guidance会通过这些信息来提高场匹配的质量。Pattern guidance通过可选参数guide控制。Guide参数有四个值,设定guide=0关闭pattern guidance;设置guide=1使用3:2 pulldown模式(片源是24fps->30fps的);设置guide=2使用2:2模式(适用于PAL制式);设置guide=3使用3:2:3:2:2模式(片源为25fps->30fps,较少见)
First decide if your source clip is PAL. If it is, and if it has progressive content, you can almost invariably set guide=2 to use PAL pattern guidance. Of course, if your clip does not have progressive content, it will not help you, and you shouldn't be using Telecide() at all! So for PAL, we can skip to Step 3 with our script looking this so far:
首先确定你的片源是否是PAL制式。如果是,并且其内容为progressive,你可以直接设定guide=2来使用PAL模式。当然,如果片源不含progressive(纯交错),你就根本不应该用Telecide()。所以对于PAL,我们可以直接跳到第三步。我们的AVS脚本此时应该是:
AviSource("your_clip.avi"
Telecide(order=1,guide=2)
If we have an NTSC 29.97fps or 30fps source clip, things are trickier. First we have to determine whether the clip contains 3:2 pulldown material. There are several tests we can apply. First, serve the clip raw (no Decomb or other processing) into VirtualDub. Then step through the frames in motion areas. If you see a repeating pattern of 3 clean frames followed by 2 interlaced frames, that is 3:2 pulldown. Typically, movies will use 3:2 pulldown.
如果我们的片源是NTSC 29.97fps或30fps,那么事情就要复杂一些。首先我们要确定片源是否为3:2 pulldown生成的。有很多测试方法可以使用。第一种,直接用VirtualDub打开片源,并且不要进行任何处理。然后找到一处包含运动物体的片段,步进前进。如果你看到3帧非交错画面和2帧交错画面循环出现,那么就可以确定是3:2 pulldown了。大多数电影都是用的3:2 pulldown。
Looking for the 3:2 pattern as described above is not foolproof, because for animations there are duplicate frames that can make it hard to see a clear 3:2 pattern.
像象上面讲的那样寻找3:2循环并不十分简单,因为一些动画包含重复的帧,很难清楚地发现3:2循环。
Second, you can serve the following script into VirtualDub and see what Telecide() reports about it (remember to use the correct field order as you determined it above).
所以我们还有第二种方法,你可以用下面的AVS脚本打开片源,然后看Telecide()怎样返回结果。(注意,一定要正确的设定场顺序。)
AviSource("your_clip.avi")
Telecide(order=1,guide=1,post=0,show=true)
Serve this into VirtualDub and step through several typical sections of your clip. If Telecide() reports "in-pattern", or "in-pattern*", then it is locking onto 3:2 pulldown. If it reports "out-of-pattern" or continuously jumps in and out of pattern lock, then it is not locking onto a consistent 3:2 pattern.
用VirtualDub打开这个AVS脚本,然后多抽取几段影片浏览。如果Telecide()报告"in-pattern"或"in-pattern*",那么这段影片就是3:2 pulldown。如果报告"out-of-pattern"或" in-pattern "、"out-of-pattern"来回跳动,那么片源就不是纯3:2循环。
If you determine that your clip has a lot of 3:2 content, then you should go ahead and set guide=1. If there is not a lot of 3:2 content, or you have any doubts about the nature of the clip, then you should set guide=0. We will assume that we have a lot of 3:2 content for the next steps. Therefore, our script so far looks like this:
如果你确定片源中含有大量3:2内容,那么就应该设定guide=1。如果3:2占的比例不高或者不能确定片源种类,那就设置guide=0。我们假设我们的片源种3:2 pulldown含量很高,我们的脚本到目前为止应该是:
AviSource("your_clip.avi")
Telecide(order=1,guide=1)
Step 3. Set up Postprocessing
第三步:设置Postprocessing
Postprocessing is the process by which frames that come out of the field matching process still combed can be detected and deinterlaced. The postprocessing modes are controlled by the post parameter: post=0 means disable postprocessing; post=1 means calculate the metrics but don't deinterlace; post=2 means calculate the metrics and deinterlace accordingly; and post=3 means calculate the metrics, deinterlace accordingly, and show a deinterlacing motion map for frames that are detected as combed. There are two more advanced modes as well; please refer to the reference manual for details.
有些帧经过场匹配处理后仍然会出现交错,Postprocessing就是一个能将这些帧找出并Deinterlace的过程。Postprocessing由参数post控制,设定Post=0关闭Postprocessing;设置Post=1计算metrics但不进行deinterlace;设置post=2计算metrics并进行deinterlace;设置post=3计算metrics、进行deinterlace,并在经过deinterlace处理的帧上显示deinterlacing动态图。此外,还有两个更加高级的模式,参见《Decomb参考手册》。
We will adopt a standard procedure for setting up postprocessing. First, we will enable the metrics and show them as follows (note we are carrying forward previously determined settings -- you would use the ones you earlier determined for order and guide):
我们采用一个比较标准的程序来设定postprocessing。首先,我们将metrics设为可用,然后照下面显示(注意,其他参数都是按照以前确定的,你应当按照以前确定的order和guide的参数来设定):
AviSource("your_clip.avi")
Telecide(order=1,guide=1,post=3,vthresh=25,show=true)
Serve this into VirtualDub and play through the clip while examining frames and the displayed vmetric values. The value that applies to the frame as matched is the one in brackets that starts with "chosen=", e.g., "[chosen=27]". Let's just call that the vmetric value. Any vmetric value greater than vthresh defines the frame as interlaced. You want to find the vthresh value that correctly distinguishes combed frames from non-combed frames for your clip. You'll easily be able to identify the frames thought to be combed because a) the vmetric value will be greater than vthresh, b) the progressive/interlaced indicator will say interlaced, and c) the frame will have a white deinterlacing motion map overlayed on it. There's no way you'll miss them!
用VirtualDub打开这个脚本然后播放影片,这时Decomb会测试这些帧并在画面上显示vmetric值。实际应用到该帧的vmetric值显示在方括号中的"chosen=",比如"[chosen=27]",我们叫它vmetric值。如果有vmetric值高于参数中指定的vthresh值,就说明该帧为交错帧。现在需要找出一个合适的vthresh值,能够从非交错帧里面辨别出交错帧。你能够很容易的辨别出被认为是交错的帧,因为a) vmetric 会大于 vthresh,) progressive/interlaced 指示器会显示interlaced,c)整个帧会有一个白色的反交错(deinterlacing)动态图覆盖在上面。你绝不会错过它们的。
Your chosen vthresh may not be perfect and if it is not you should err on the side of caution. It's better to catch some progressive frames than to miss some combed ones.
你设定的vehresh也许部好,如果设定的不好,你必须加倍小心谨慎。宁愿捉到progressive frames都比放过交错的好。
Let's suppose that our vthresh value that distinguishes combed from non-combed frames is 30. Now create the following script with post=2 (carry over your determined previous settings, as always):
我们假设我们将vthresh设置成30的时候恰好能将交错、非交错frame区分开。那么现在应当将post设置为2(其他参数应当继续沿用你先前确定的值)
AviSource("your_clip.avi")
Telecide(order=1,guide=1,post=2,vthresh=30,show=true)
Serve this and play it into VirtualDub. As you step through you should see the progressive frames passing through untouched while the combed ones ones are deinterlaced.
If you are not happy with the deinterlacing of the combed frames and want them "hit a little harder", you can reduce the dthresh parameter. Also, if you prefer interpolation to blending for the combed areas, you can change the blend parameter. Refer to the reference manual for the proper use of these parameters.
如果你对反交错的效果不满意,而想让它们"hit a little harder",你可以减少dthresh这个参数的值。同样,如果比起混合你更喜欢内差补点(内差补点比混合速度快),那么调整blend这个参数。参考《手册》获得更多详细信息。
Our script so far then is:
我们的脚本到目前为止是这样的:
AviSource("your_clip.avi")
Telecide(order=1,guide=1,post=2,vthresh=30)
There are two more important things to say about postprocessing before we move on. First, there is a subtle difference between post=2 and post=4 which might affect you. The reference manual describes the differences in detail. Setting post=2 will often avoid making gross frame blends at scene changes, but it can make deinterlaced video sequences jerky. Setting post=4 retains the smoothness of deinterlaced sequences, but may make frame blends at scene changes.
在我们继续下去之前,我们有两点需要注意。第一,在post=2和post=4之间有些微小的区别可能会影响到结果。《参考手册》中有详细的描述。设置成post=2可以避免在场景切换的时候产生“gross frame blends(恶心难看的混合方式去场,通常指鬼影现象)”,但是可能会引起去交错后的视频播放的时候一顿一顿的。设置成post=4可以保持移动最平滑的视频,但是可能在场景切换的地方产生“混合”。
Second, you may find that you need different vthresh values for different parts of your clip. If so, use Telecide's manual override capability to specify values for different frame ranges as needed. Refer to the reference manual for details.
第二,你可能会发现在影片的不同的场景中会需要不同的vthresh值。如果是这样,使用Telecide的手动忽略功能为不同场景制定不同的值。参看《手册》获得更多信息。
Decimate()
俗话:十步杀一人,千里不留行。
As a side effect of performing field matching for 3:2 pulldown, Telecide() emits duplicate frames and leaves the clip at its original frame rate. Decimate() detects and removes these duplicates and sets the frame rate down appropriately.
作为对3:2 pulldown的片源进行场匹配所产生的副作用,Telecide()可能会产生重复帧并保持原有帧率。Decimate()可以找出并删除重复帧,并降低帧率。
Step 4. Set up Decimation
If your clip is PAL, you do not require decimation and you are finished!
如果你的片源是PAL,你便不需要Decimate了,到此为止便可以完成。
If your clip has 3:2 pulldown, you will need to decimate the clip. Simply add a call to Decimate(). Our final script then looks like this:
如果你的片源是3:2 pulldown,便需要进行Decimate。只要简单的添加Decimate()即可。我们最终的脚本便是这样的:
AviSource("your_clip.avi")
Telecide(order=1,guide=1,post=2,vthresh=30)
Decimate()
One thing to be aware of is that you may not always want to decimate 30fps material. For example, if your clip is a hybrid of 3:2 progressive and normal interlaced video, if you decimate it you'll make the video portions jerky. Often with such clips it is better to leave them at their original frame rate by omitting Decimate().
有一点需要指出的是,不是所有的30fps影片都能够进行Decimate。举个例子,你的片子是3:2 progressive和一般交错相混合的,那么就不能进行Decimate,如果做了,就会造成影片播放时一顿一顿的。通常遇到这种片子都不加Decimate()。
Refinements
This manual has described only the basic parameters and procedures required to quickly master Decomb. There are many more parameters that you can use to adapt to unusual and difficult situations. Please refer to the Decomb Reference manual to begin exploring this additional functionality.
本文只包含了最基本的参数和使用方法,适合那些要求快速掌握Decom的人。还有更多的参数来应对不同的情况。请参阅《Decomb参考手册》了解了解这些高级功能。
Here is one example of a refinement so you'll understand what I am talking about: Suppose you have a noisy off-air capture and you are experiencing matching failures. You can add some extra noise tolerance to Telecide() by increasing the value of the nt parameter. You will find many such little gems in the Reference Manual. It makes great bathtub reading.
举个例子你就知道我在说些什么了:假设你有一段噪声严重的影片导致出现了场匹配错误,你可以通过增加nt这个参数的值来增加噪声容差。相类似的“小把戏”在《参考手册》中还有很多。
 楼主| 发表于 2004-10-29 13:06 | 显示全部楼层

Decomb Plugin for Avisynth Frequently Asked Questions (FAQ)

My video sequences come out jerky, even when I don't decimate the clip.
Use post=4 (and post=5) rather than post=2 (and post=3). Also, do not set an unnecessarily low vthresh parameter.



--------------------------------------------------------------------------------

The dthreshold parameter is not working.
The dthreshold parameter was renamed to dthresh in Telecide for Decomb 5.0.0. It is still called dthreshold in FieldDeinterlace.



--------------------------------------------------------------------------------

Why was Decomb 5.0.0 made field-order dependent?
It's faster and less error-prone to do 2 comparisons rather than 3. But Decomb 5.0.0 will still try the third match if a frame is still combed after the 2-way match. So no extra combed frames are emitted compared to Decomb 4. The tutorial provides a really easy way to determine a clip's field order.



--------------------------------------------------------------------------------

Why am I getting some bad field matches?
First, verify that your field order is set correctly using the procedure given in the tutorial!

The field matching process is not perfect. However, it can be improved in some situations. For example, if you have a noisy clip (as you might get from an analog capture), you can often improve the matching by using the nt parameter to add more noise tolerance than the default value of 10. The best value will depend on how noisy your clip is. But be cautious when raising the noise tolerance, because it can degrade matching for clean clips.

You can also improve matching in some cases by enabling pattern guidance. In some uncommon cases you can improve matching by disabling pattern guidance! Try it both ways and see which gives you better results.



--------------------------------------------------------------------------------

Why am I getting combed frames after some scene changes?
These scene changes require a third (backward) match. Decomb will test the third match only if post is set to any value other than 0. Note that you can enable the third match testing without enabling postprocessing: you can set post=1. You can also enable three-way matching on all frames (not just ones that are combed after two-way matching) by using the triple parameter. Setting triple=true, however, can produce jerkiness.



--------------------------------------------------------------------------------

Even after a frame is deinterlaced, I still can see combing on it.
First, use post=3 or post=5 to verify that the frame is actually being deinterlaced. If it is not, then you need to reduce your vthresh parameter until it is. If it is being deinterlaced, then you can decrease the dthresh parameter to attack more areas of the frame, but see the caveat below.

Make sure that what you think is combing is really combing. For example, sometimes the clip has content that is intentional but looks like combing. If you use SeparateFields() (by itself without Decomb) and still see "combing" on the fields, then it is not really combing but intentional content.

If you have a color conversion before Decomb, be sure to use ConvertToXXX(interlaced=true).

Do not resize vertically before Decomb.

Caveat About Residual Combing: People will often freeze on an frame and zoom in closely and see some faint residual combing and agonize over it. But that is a seriously misguided way to assess residual combing. Human perception cannot register contrast when the difference becomes less than a threshold. But the threshold gets lower as the feature size gets larger. That means that when you zoom in, you get an incorrect idea of what can actually be seen at normal size. Also, when things are in motion we see them with reduced resolution; therefore, freezing the frame gives an incorrect idea of what can be perceived. To assess residual combing, play the clip at normal speed and size. If it looks good, then be happy!

Finally, reducing dthresh to low values (such as 0-5) throws away most of the advantages of the area-based adaptive deinterlacing that Decomb performs. You will lose resolution on static areas of the frames, where you want it the most.



--------------------------------------------------------------------------------

I get "marching ants" on some hard horizontal edges when using FieldDeinterlace.
This artifact is a consequence of the field-differencing algorithm employed by FieldDeinterlace. All deinterlacers have characteristic faults like this. There is no perfect solution to deinterlacing. This is usually seen at the edges of letterboxing. You can crop off the letterboxes first and restore them afterwards (if you need them) as a workaround. Alternatively, you can use a frame-differencing deinterlacer, such as TomsMoComp, if you can accept the characteristic artifacts of frame differencing.

I am exploring ways to reduce this artifact and hope for better performance in the future.



--------------------------------------------------------------------------------

I'm confused about the difference between threshold and dthreshold in FieldDeinterlace.
The process goes like this (if full = false): First the frame is tested to see if it is combed. This is done by detecting combed areas and seeing if there is enough combing to reasonably declare the frame as combed. The threshold parameter determines the sensitivity of the combing detection in this step. Second, if the frame is declared as combed, the combed areas of the frame are again detected but this time using the dthreshold parameter. The areas of the frame detected as combed using dthreshold are then deinterlaced.

If full=true, the first step is omitted and all frames are declared as combed.

FieldDeinterlace's map parameter allows you to directly visualize the effect of these parameters.



--------------------------------------------------------------------------------

I get "ghosting" on my deinterlaced frames.
Refer to the question on blending versus interpolation. To get rid of ghosting, set blend=false.



--------------------------------------------------------------------------------

Technically, what is the difference between blending and interpolation?
Suppose you have 3 pixels on successive lines and the same x offset:

a
b
c

If you decide that pixel b is combed, and you replace it with (0.5*a+0.5*c) that is (linear) interpolation. If you replace it with (0.25*a+0.5*b+0.25*c), that is blending. Note that when interpolating, the even lines are passed through and the odd lines are calculated as described. For blending, every line is calculated. Blending thus produces a blend of the two fields while interpolation uses data from one field only. That is why people say that blending causes "ghosting". You can eliminate the ghosting by setting blend=false. Also note that while interpolation can be calculated in place, blending cannot. Interpolation is a little faster.



--------------------------------------------------------------------------------

Different parts of my movie seem to require different vthresh values. What can I do?
The combing detector used by Decomb is quite sensitive but that can sometimes cause you trouble when you have content that has sections that are not combed but have detail that looks like combing. If you set vthresh high to avoid deinterlacing these areas, you may let combs slip through elsewhere. While it's better to err on the side of caution and deinterlace some good frames, some extreme cases make you wish you could set different vthresh values for different parts of the clip. Fortunately, Decomb allows this through its manual override capability. Refer to the reference manual for further details.



--------------------------------------------------------------------------------

How does gthresh affect the field matching when pattern guidance is enabled?
If the pattern guidance thinks that the calculated (blind) field match is not what it predicts based on pattern analysis, it tries to override the blind field match. The override is allowed if the pattern mismatch is less than gthresh. Think of gthresh as a limiter: it limits how large the mismatch can be before a predicted match is overruled by the actual calculated match. If your gthresh is too high, it may cause a new pattern in the clip to be erroneously overridden by the previous pattern. There is a happy medium that allows new patterns to be locked onto quickly while still allowing the pattern guidance to correct mismatches due to noise, etc. The happy medium is usually in the range 5-10%, but it will be clip-specific.
 楼主| 发表于 2004-10-29 13:07 | 显示全部楼层

Decomb Plugin for Avisynth 2.5 Reference Manual

Introduction
This package of plugin functions for Avisynth provides the means for removing combing artifacts from telecined progressive streams, interlaced streams, and mixtures thereof. Functions can be combined to implement inverse telecine (IVTC) for both NTSC and PAL streams.

The term "combing" is used as a general term versus "interlacing" because interlacing is usually associated with nonprogressive streams. What look like interlacing artifacts can be seen on telecined progressive streams, so I use the term combing to refer to all such artifacts, regardless of the type of the stream.

The package automatically adapts to any telecine/capture patterns, and mixtures thereof, although if you want to decimate the recovered progressive stream, you have to specify the desired decimation ratio if it differs from the default 1-in-5 used for NTSC 3:2 telecining. None of the functions introduce a delay in the audio or video streams.

For many applications, there are few parameters to set, but best results are achieved with careful setting of parameters. Decomb allows the user to define his own default parameters if desired (defaults are the values assumed if the parameter is not specified explicitly).

Many of Decomb's decisions can be manually overridden as desired using text override files. This allows meticulous users to achieve the best possible quality for their encodes.

This is the reference manual for Decomb. Refer to the Decomb Tutorial for user-friendly procedures for using Decomb, and to the Decomb FAQ for answers to frequently asked questions.



--------------------------------------------------------------------------------

Functions Overview
The package consists of the following functions:

Telecide(): Recovers progressive frames (by finding and aligning matching fields) but does not remove resulting duplicates and does not change the frame rate or frame count. Do not use Telecide on streams that do not contain telecined progressive frames, such as pure interlaced video. Note that a stream of PAL progressive frames that are shifted by one field will exhibit combing and can be considered a telecined stream for purposes of recovery; Telecide will easily handle this situation.

By default, Telecide runs postprocessing on the recovered frames. This postprocessing checks each frame to see if it is combed (some combed frames may come through the field-matching process [see below]), and if a frame is combed, it is deinterlaced, otherwise it is not touched. The deinterlacing algorithm is a space-adaptive one, that is, only the portions of a frame that are combed are deinterlaced. This means that full detail is retained in static picture areas. The algorithm for distinguishing between combed and progressive frames is effective but not perfect.

To achieve inverse telecine, apply Telecide followed by Decimate. Appendix A explains why this works.

Telecide supports an optional pattern guidance mode. Enabling this option allows Telecide to overrule the calculated field match with its predicted match based on the recent clip history and future. A threshold can be defined so that a large enough discrepancy between the predicted and calculated matches will reset the pattern.

FieldDeinterlace(): This filter provides functionality similar to the postprocessing function of Telecide. You can use it for pure interlaced streams (that is, those not containing telecined progressive frames). (The name refers to the fact that field mode differencing is used.) Do not use FieldDeinterlace after Telecide because the same functionality is built into Telecide.

FieldDeinterlace provides an option that allows you to specify whether all frames are to be deinterlaced or whether just frames detected to be combed are deinterlaced.

Decimate(): Decimate 1 frame in every N, where N is a parameter and can range from 2 to 25. Decimate removes one duplicate frame in every group of N frames. The frame rate and count are adjusted appropriately. Decimate properly supports VirtualDub random access (timeline navigation).

Decimate provides several special modes that are useful when dealing with film/video hybrid material.


IsCombed(): This is a utility filter useful in Avisynth scripting. It enables a script to distinguish progressive versus interlaced frames. It is designed for use within ConditionalFilter().



--------------------------------------------------------------------------------

Input Requirements
Telecide requires that the input width be a multiple of 2. Deviation from this will cause Telecide to throw an exception.

Do not resize vertically before applying Decomb. Decomb needs to see the original line spacing to properly detect combing.

Telecide requires YUY2 or YV12 color format as input. The DLL shipped with this version of Decomb will work only with Avisynth version 2.5 and beyond.

It is preferable not to convert between YV12 and YUY2 (either way) before using Decomb. Apply Decomb in the native color space. Such conversions can cause artifacts due to incorrect chroma upsampling/downsampling.

For YV12 operation, the only supported version of "mpeg2dec" is MarcFD's mpeg2dec3 (version 0.94 and beyond). Other versions may produce incorrect output.


--------------------------------------------------------------------------------

Important Speed Tips
Avoid Converting the Color Space  Be aware that converting to YUY2 from RGB is very time expensive, so don't save your AVIs in RGB. The popular HUFYUV codec has an option to convert RGB to YUY2 and you should enable that when generating AVIs with HUFYUV that are destined for Decomb processing.

Don't Postprocess Unnecessarily  Try Telecide without postprocessing if you think there is a chance that you have a nice clean input stream. If you do have such a stream, you'll find that processing runs faster without postprocessing.

Don't Invoke an Avisynth Strangeness  This one is very important and can easily cost you a 25% speed penalty! It appears that Avisynth has a strangeness that causes it to waste enormous amounts of time when there are no parentheses with the commands. For example, this script:

Telecide
Decimate

…will run much slower than this one:

Telecide()
Decimate()

If you doubt this, try it both ways and see. It is critical, therefore, to always include at least one parameter or the set of empty parentheses. That is why the scenarios below all are coded that way.

Use Fast Recompress If Possible  If you are serving into VirtualDub for transcoding, and you don't need to do any filtering or other processing in VirtualDub, then use VirtualDub's Fast Recompress mode.

Disable Frame Displays  When sending Decomb output to VirtualDub (and similar applications), disable the display of the input and output frames during processing. This will noticeably decrease processing time.


--------------------------------------------------------------------------------

Typical Scenarios
These examples are intended only to illustrate the main features of Decomb. Refer to the User Manual for detailed procedures for determining the correct settings to apply, as best results are achieved with careful tweaking of parameters.

Simple Deinterlacing  If you have some nonfilm (interlaced) source, you simply deinterlace it as follows:

  LoadPlugin("decomb.dll"
  AVISource("nonfilm.avi"
  FieldDeinterlace()

Progressive Frame Recovery  If you have telecined film (progressive) source and want to recover the progressive frames but not change the frame rate by decimating, you proceed as follows:

  LoadPlugin("decomb.dll"
  AVISource("film.avi")
  Telecide(order=1)

The order parameter must be set to correctly specify the field order of the clip. Note that here Telecide does postprocessing of the recovered frames to clean up any combed frames that might have come through the field-matching process (see "Notes on Field Matching" below).

You can use the show option, or the debug option in conjunction with the DebugView utility, to see the metrics and decisions that Telecide generates. This will assist you in tweaking the parameters.

Inverse Telecine (IVTC)  If you want to do the same thing but decimate the result to remove duplicated frames (which amounts to performing an inverse telecine [IVTC] operation), you proceed as follows [NTSC 3:2 uses Decimate(cycle=5)]:

  LoadPlugin("decomb.dll")
  AVISource("film.avi")
  Telecide(order=1)
  Decimate(cycle=5)

Disabling Postprocessing  If your telecined source material is very clean, you may want to disable postprocessing to reduce processing time. Proceed as follows:

  LoadPlugin("decomb.dll")
  AVISource("mixed.avi")
  Telecide(order=1,post=0)
  Decimate(cycle=5)

Here the third parameter, post, is set to 0 to disable postprocessing.

Inverse 3:2 Telecine with Pattern Guidance  If your telecined source material is NTSC 3:2 pulldown, you can enable pattern guidance, which can make the field matching more accurate for some clips. Proceed as follows:

  LoadPlugin("decomb.dll")
  AVISource("mixed.avi")
  Telecide(order=1,guide=1)
  Decimate(cycle=5)

Refer to the syntax description for Telecide() below for more details.

Processing Hybrid Material  If you have a clip that contains both 3:2 pulldown (film) and pure video, you can do a good job with it like this:

  LoadPlugin("decomb.dll")
  AVISource("hybrid.avi")
  Telecide(order=1,guide=1)
  Decimate(mode=3,threshold=2.0)

Refer to APPENDIX B for further details on handling hybrid material.


--------------------------------------------------------------------------------

Notes on Field Matching
Telecide normally does an excellent job at recovering progressive frames by field matching. There are four known source stream conditions that can cause Telecide to output frames with combing:

Missing Fields. If a field is missing due to a bad edit, then its partner field in the source will not have a good field to match with. Use the default postprocessing to clean up the output stream.

Blended Fields. Some streams have fields that are blends of two original film progressive pictures! Some NTSC/PAL conversions can cause this, for example. Usually such a stream has a lot of these and the solution is to run postprocessing with blend=true to clean up the output stream. Using blend=true mode seems to work best and the blended fields appear as blended frames, which lends a kind of motion blur and reflects the "intent" of the input stream.

In cases where there are a lot of blended frames, there is no point in using Telecide at all. Just use FieldDeinterlace() to treat the clip as interlaced video.

Finally, how do you tell if your stream has blended fields? Simply use the Avisynth SeparateFields function to split the fields apart and then serve the result to VirtualDub. Step through the fields and see if there are any fields that are blends of more than one picture.

Nonfilm Frames (Hybrid Clips). Some streams, especially those captured from live broadcasts, have periods of film and periods of nonfilm. For such streams, you can either use Decimate() with mode=1 or mode=3 as described in the scenarios section above. Mode=1 will leave the clip at 30fps while mode=3 will leave it at 24fps. It is your (difficult) decision about whether you want the final stream at 24fps or 30fps.

Hybrid Frames. Sometimes graphics, credits, etc., will be rendered at final frame rate and then overlayed on the telecined content, resulting in frames that have both progressive and nonprogressive content. Or more rarely, one encounters clips that have different layers that are telecined with differnt phases and then composited. For streams with hybrid frames, you usually must rely upon Telecide's postprocessing to clean up the output stream.

By now you should be getting the idea that postprocessing is generally a good thing to do to ensure that no combed frames sneak through.


--------------------------------------------------------------------------------

General Function Syntax
The Decomb functions use named parameters. That means you do not have to worry about the ordering of parameters. You can simply refer to them by name and put them in any order in the list of parameters. If you omit a parameter it takes its default value. For example, if you want to run Telecide with order tff, postprocessing, and with debug enabled, you can simply say:

Telecide(order=1,post=2,debug=true)

Any combination and order of named parameters is allowed. Remember, however, that you should always include empty parentheses if you are not specifying any parameters.


--------------------------------------------------------------------------------

Customizing Default Parameter Values
If you do not like the defaults as documented below, you can set your own standard defaults. To override the defaults, create defaults files as required in the Avisynth plugins directory. For example, to set the default post=4 for Telecide(), make a file called Telecide.def and put this line in it:

post=4

You can list as many parameter assignments as you like, one per line. Those not specified assume the default values documented below. Of course, you can always override the defaults in your scripts when you invoke the functions. NOTE: The lines in the defaults file must not contain any spaces or tabs.


--------------------------------------------------------------------------------

Overriding Decomb Decisions
On occasion you may have close to a perfect encode except for a few frames that Decomb decides wrong about. In such cases you can use Decomb's manual override functionality. This is an advanced feature that should be used only by experts who need the highest possible quality encodes.

Overriding Telecide() For example, suppose we find that frame 100 is not being field-matched correctly. We inspect Telecide()'s debug output and find that it is matching to the previous frame ("[using p]"). We want to try forcing a match to current and next to see if a correct match can be found (refer to APPENDIX A for an explanation of the terminology). First, we make a file in the same directory as the script file called "tango.tel" (you can use any filename). Then we place this line in the file:

100 c

This declares that frame 100 is to be matched to current (use "p" for previous frame and "n" for next).

Now we direct Telecide to use this overrides file:

Telecide(ovr="tango.tel")

Now process the script as usual; the specified override to current will be used. If this match fails we can try replacing "c" with "n" to try next.

A frame range can also be used, such as:

100,500 c

We can add additional lines defining any other overrides as required. Note that the frame numbers must be in ascending order (from lowest to highest).

You can also specify full patterns for your matching in the Telecide overrides file. For example, suppose you wanted to force a pattern of ncccn for frames 100 through 185. Your overrides file line would be:

100,185 ncccn

You can put as many specifiers in the pattern as you like. For example, this would be legal too:

100,185 nc

The specified pattern will be repeated beginning at the starting frame and ending at the ending frame of the range.

This capability allows for flexible and convenient manual control of field matching. You can do your whole film manually if you like!

Telecide()'s postprocessing decisions can also be overridden. To force a frame to be considered combed, use a line with a '+' like one of these:

100 +
100,500 +

To force a frame to be considered NOT combed, use lines like this:

100 -
100,500 -

You can set different vthresh values for different parts of your clip. For example, to set vthresh to 25 for frames 200 through 500, use:

200,500 v 25
Note that the 'v' override requires a frame range. To specify a single frame, set both the starting and ending frames of the range to the desired frame number.

You can specify the matching mode (back=0/1/2) for a frame or range of frames:

100 b 2
200,500 b 1

The first line above enables triple matching for frame 100. The second line enables combing-driven backward matching for frames 200 through 500.

Lines for overriding field matching and for overriding postprocessing can be used together in the same overrides file as long as the ascending frame number requirement is met.

Overriding FieldDeinterlace() FieldDeinterlace() supports the '+' and '-' overrides as described for Telecide(). Of course, field matching overrides do not apply and should not be used. You might want to call the overrides file "tango.fd".

Overriding Decimate() For Decimate(), we do things the same way but we use lines of the following form, where the numbers are frame numbers of the clip entering Decimate() that will be forced to be decimated:

150
175

In the above example, frames 150 and 175 will be force decimated. Again, an appropriate name for the overrides file would be "tango.dec".


--------------------------------------------------------------------------------

Detailed Function Syntax
Following is the syntax for the Decomb functions (replace parameter_list with your comma-separated list of named parameters):



--------------------------------------------------------------------------------

Telecide(parameter_list)
Commonly used parameters

order (0-1, default none!) defines the field order of the clip. It is very important to set this correctly. The User Manual specifies a reliable procedure for doing so. Use order=0 for bottom field first (bff). Use order=1 for top field first (tff). You must specify order; Decomb throws an exception if you omit this parameter.

guide (0-3, default 0) can be used to improve field matching when the source clip is known to be PAL or NTSC telecined material. To disable this option (blind field matching), set guide=0. For NTSC 24fps->30fps telecine guidance, set guide=1. For simple PAL guidance (tries to maintain lock to the field phase), set guide=2. For NTSC 25fps->30fps telecine guidance, set guide=3.

When this option is enabled, Telecide() can overrule a field match decision and use a predicted match based on the recent clip past and future. The gthresh parameter (below) is used to define how small a discrepancy between the predicted and calculated field matches is required to accept and use the prediction. Do not enable this option unless you know that the source clip corresponds to the selected guidance mode. If in doubt, leave guide=0.

Note that this feature uses Avisynth random frame access, so it works fine when the user uses random timeline navigation.

gthresh (0.0-100.0, default 10.0) defines how large a discrepancy (in percent) between the predicted and calculated field matches is required to reset the pattern. Use the show option, if required, to appropriately tweak this threshold. The show and/or debug output will indicate which matches have been overridden. Overridden matches are denoted with an asterisk, e.g., "in-pattern*".

Do not set gthresh too high, as it can create bad matches. Anything over about 10-15 is starting to get dangerous.

post (0-5, default 2) controls whether and how Telecide performs postprocessing to clean up frames that come through the field-matching still combed:

post=0: Use this to totally disable postprocessing.
post=1: Use this to enable the metrics calculation and to display the vmetric values but not perform deinterlacing.
post=2: Use this to enable deinterlacing. Note that in this mode, the field matching occurs normally and the best matched frame is deinterlaced and delivered.
post=3: This is the same as post=2 except that the deinterlacing motion map is displayed in white on the deinterlaced frames.
post=4: This is the same as post=2 except that instead of using the best field match for the frame, the original frame is deinterlaced. You would use this to pass video sequences through when you have a hybrid clip.
post=5: This is the same as post=4 except that the deinterlacing motion map is displayed in white on the deinterlaced frames.
vthresh (0.0-255.0, default 50.0) sets the combed frame detection threshold for the postprocessing. You may want to increase this value if too many good frames are being deinterlaced, or reduce it if some combed frames are not getting caught. The default is a reasonable general purpose value. Note that this threshold determines whether a frame is considered combed and needs to be deinterlaced; it is not the threshold you might be familiar with in Smart Deinterlacer. That threshold is determined by dthresh (below); it is the threshold for deinterlacing the frames detected as combed.

dthresh (0.0-255.0, default 7.0) sets the threshold for deinterlacing frames detected as combed. Note that this threshold is the threshold you might be familiar with in Smart Deinterlacer.

blend (true/false, default false) enables blending instead of interpolating in combed areas. Interpolating is faster.

show (true/false, default false) enables metrics to be displayed on the frame to assist with tweaking of thresholds. Also displays the software version.

Advanced parameters

chroma (true/false, default true) determines whether chroma combing is included in the decision made during postprocessing as to whether a frame is combed or not. If chroma=true, then chroma combing is included, otherwise it is not included. Note that chroma is always deinterlaced; this parameter affects only the decision about whether a frame is combed. It is useful for clips which have a large amount of luma/chroma interference, as might result from a poor comb filter. The interference can cause frames that are not combed to be detected as combed when chroma=true. By setting chroma=false, the effect of the interference can be eliminated.

back (0-2, default 0) selects the matching mode. When back=0, the backward match is never tested. This means that at bad edit cuts, a progressive frame may not be found and the resulting frame must be deinterlaced by postprocessing. When back=1, if a frame is still combed after field matching (according to a test against 'bthresh' -- see below), then the backward match is tried. This requires post > 0 and may allow a good progressive frame to be found at bad edit cuts. When back=2, the backward match is always considered. Some clips, especially those with a lot of blended fields, may be handled better with back=2, which tests for matching with the previous, current, and next frames. But use it with caution, because it can make some clips jerky.

bthresh (0.0-255.0, default 50) sets the combing detection threshold for conditional backward matching (back=1). The backward match will be considered if the candidate match has combing greater than 'bthresh'. Typically you set a high 'vthresh' to catch stray combed frames, together with a lower 'bthresh' to catch bad edits.

nt (integer, default 10) defines the noise tolerance threshold. It should usually not be necessary to adjust this parameter. If you have a noisy capture and are experiencing matching failures, however, you might usefully try increasing it.

y0 and y1 (integer, default 0) define an exclusion band for the field matching. If y0 is not equal to y1 this feature is enabled. Rows in the image between lines y0 and y1 (inclusive) are excluded from consideration when the field matching is decided. This feature is typically used to ignore subtitling, which might otherwise throw off the matching. y0 and y1 must both be positive integers and y0 must be less than or equal to y1; if this is violated an exception will be thrown.

hints (true/false, default true) enables Telecide() to pass hints to Decimate(). Decimate uses these hints to optimize its behavior in modes 1 and 3.

ovr (string, default "") enables specification of an overrides file (see the section above called "Overriding Decomb Decisions"). The file must be in the same directory as the script file (the Avisynth current directory) and the filename must be enclosed in quotation marks, e.g., ovr="tango.tel".

debug (true/false, default false) enables logging/debugging information about the filter's decisions to be printed via OutputDebugString(). A utility called DebugView is available for catching these strings.


--------------------------------------------------------------------------------

FieldDeinterlace(parameter_list)
full (true/false, default true) chooses whether to process all frames or just the frames that are detected as combed. Use full=true to process all frames.

threshold (0-255, default 20) sets the combed frame detection threshold. When running with full=false, you may want to increase this value if too many good frames are being deinterlaced, or reduce it if small combed areas are not getting caught. The default is a good general purpose value. Note that this threshold determines whether a frame is considered combed and needs to be deinterlaced; it is not the threshold you might be familiar with in Smart Deinterlacer. That threshold is determined by dthreshold (below); it is the threshold for deinterlacing the frames detected as combed. When full=true, threshold is ignored, but dthreshold remains functional.

dthreshold (0-255, default 7) sets the threshold for deinterlacing frames detected as combed. Note that this threshold is the threshold you might be familiar with in Smart Deinterlacer.

blend (true/false, default true) enables blending instead of interpolating in combed areas.

map (true/false, default false) enables display of the combing detection map (motion map). If full=true, the map is shown for all frames. If full=false, the map is shown only for frames detected as combed; non-combed frames are displayed normally. The map shows combed areas as bright cyan; non-combed areas are copied from the source frame and blended with gray.

chroma (true/false, default false) determines whether chroma combing is included in the decision made during postprocessing as to whether a frame is combed or not. If chroma=true, then chroma combing is included, otherwise it is not included. Note that chroma is always deinterlaced; this parameter affects only the decision about whether a frame is combed. It is useful for clips which have a large amount of luma/chroma interference, as might result from a poor comb filter. The interference can cause frames that are not combed to be detected as combed when chroma=true. By setting chroma=false, the effect of the interference can be eliminated. This option has no effect when full=true because all frames are considered combed.

ovr (string, default "") enables specification of an overrides file (see the section above called "Overriding Decomb Decisions"). The file must be in the same directory as the script file (the Avisynth current directory) and the filename must be enclosed in quotation marks, e.g., ovr="tango.fd".

show (true/false, default false) enables metrics to be displayed on the frame to assist with tweaking of thresholds. Also displays the software version.

debug is the same as described for Telecide.


--------------------------------------------------------------------------------

Decimate(parameter_list)
cycle (2-25, default 5) selects the decimation ratio, that is, decimate 1 frame in every cycle frames.

mode (0-3, default 0) determines how Decimate() deals with the extra frame in the cycle.

If mode=0, Decimate discards the frame in the cycle determined to be most similar to its predecessor.

If mode=1, instead of discarding the most similar frame, Decimate() will either replace it with a frame interpolated between the current frame (usually a duplicate of the preceding frame) and the following frame, or it will pass the frame through as is. The choice between these two depends on two things: 1) whether the cycle of frames is from 3:2 pulldown material or from pure video, and 2) the threshold parameter setting and on how different the frame is from its preceding frame (see below). The first requires guide=1 for Telecide (to declare the pulldown pattern).

Decimate(mode=1) is useful for hybrid clips having mostly video. It allows you to leave the frame rate at video rates (to get smooth video sequences) but also to ameliorate the effect of duplicate frames that are emitted by Telecide() for film sequences (frames that are normally removed with mode=0).

Refer to APPENDIX B for more details and a guide to processing hybrid material.

If mode=2, Decimate() deletes a frame from the longest run of duplicates. This mode is the most reliable with anime and other material where the motion may occur only in every second, third, or fourth (etc.) frames. If you use mode=0 on such clips, there is a danger that incorrect decimation may occur, causing jerkiness. Clips such as those described usually derive from 8fps or 12fps animation, as well as normal 24fps animation where slow motion results in repeated duplicates. Mode=2 is able to delete the correct duplicates in all these cases.

If mode=3, instead of discarding the most similar frame, Decimate() will apply different decimation strategies for 3:2 pulldown material (film) and for pure video (nonfilm) cycles. Film cycles are decimated in the normal way. Nonfilm cycles are decimated by applying a frame blending decimation of the cycle from 5 frames to 4 frames. The resulting frame rate is the film rate (decimated by 1/5).

There are two factors that affect the decision about how to decimate: 1) whether the cycle of frames is from 3:2 pulldown material or from pure video, and 2) the threshold parameter setting and on the difference metric for the most similar frame. The first requires guide=1 for Telecide (to declare the pulldown pattern).

Decimate(mode=3) is useful for hybrid clips having mostly film. It allows you to decimate the clip to film rates and treat the film normally while doing a blend decimation of video sequences to retain their smoothness.

Refer to APPENDIX B for more details and a guide to processing hybrid material.

threshold (decimal, default 0.0) When mode=1, frames determined to be the most similar to their preceding frame can be treated in two possible ways: 1) they can be blended as described above, or 2) they can be passed through if the threshold parameter is non-zero and the difference metric exceeds the threshold. By setting an appropriate threshold, you can have duplicates get blended while passing through frames that have new content, i.e., which differ significantly from the previous frame. This allows hybrid film/nonfilm clips to be dealt with intelligently: the film portions will have blends and the nonfilm portions will not. The threshold parameter has no effect when mode=0. Use show=true (or debug=true in conjunction with the DebugView utility) to view the difference metrics and thereby determine an appropriate threshold for your clip.

the threshold parameter also affects mode=3 in a similar way. Refere to APPENDIX B for details.

threshold2 (decimal, default 3.0) When mode=2, Decimate() deletes a frame from the longest run of duplicates as described above. The threshold2 parameter controls how close two frames must be to be considered duplicates. If threshold2 is raised, a larger frame difference is tolerated while still declaring them as duplicates. The default setting works well for most clips. Use show=true (or debug=true in conjunction with the DebugView utility) to view the difference metrics and thereby determine an appropriate threshold for your clip.

quality (0-3, default 2) This option allows the user to trade off quality of difference detection against speed. Following are the possibilities:

quality=0: Subsampled for speed and chroma not considered (fastest).
quality=1: Subsampled for speed and chroma considered.
quality=2: Fully sampled and chroma not considered.
quality=3: Fully sampled and chroma considered (slowest).
ovr (string, default "") enables specification of an overrides file (see the section above called "Overriding Decomb Decisions"). The file must be in the same directory as the script file (the Avisynth current directory) and the filename must be enclosed in quotation marks, e.g., ovr="tango.dec".

show (true/false, default false) enables metrics to be displayed on the frame to assist with tweaking of thresholds. Also displays the software version.

debug (true/false, default false) enables logging/debugging information about the filter's decisions to be printed via OutputDebugString(). A utility called DebugView is available for catching these strings. The information displayed is the same as shown by the show option above.



--------------------------------------------------------------------------------

IsCombed(parameter_list)
This utility filter is designed for use within ConditionalFilter(). It returns a boolean to indicate whether a frame is combed (interlaced).
threshold (0-255, default 20) sets the amount of combing required to declare a frame combed. It is analogous to the threshold parameter of FieldDeinterlace(). You may have to tweak this for best performance with your specific material.


--------------------------------------------------------------------------------

APPENDIX A. Telecide() Theory of Operation
Here's what Telecide does by default. When it receives a request for a frame it gets access to the next frame and the requested one (called the current frame). Here is what he sees (where N=next, C=current, t=top field, b=bottom field):

Ct Nt
Cb Nb

Telecide makes 2 combinations of frames from the available fields. Here are the combinations:

Nt
Cb

Ct
Cb

Now both of these frames are checked for combing. The least combed frame is the output frame (assuming no pattern guidance). It is that simple.

If pattern guidance is enabled, the decision described above can be overridden by a predicted match based on the perceived pattern surrounding the current frame. The prediction is ignored if the difference between the matches is too large, as that implies a possible change of phase of the pattern, to which Telecide() should re-sync.

Consider now a cycle of frames from a 3:2 pulldown sequence (top field first):

a a b c d
a b c c d
Telecide will produce matched output frames as follows:

a b c c d
a b c c d

It can be seen that a duplicate frame has been produced. Decimate removes the duplicate frame by finding and removing the frame most similar to its predecessor. It is easy to see now why Telecide followed by Decimate produces an inverse 3:2 telecine (IVTC) function.


--------------------------------------------------------------------------------

APPENDIX B. Dealing with Hybrid Clips
Most real-world clips in NTSC environments are mixtures of 3:2 pulldown material (film) and pure video (nonfilm) material. This presents a difficulty for encoding because our formats require a specification of frame rate as either 29.97fps or 23.976fps. If we choose the video rate, the video sequences will be OK, but the film sequences will not be decimated and will emit duplicates, appearing jumpy.

On the other hand, if we choose the film rate, the film sequences will be OK, but the video sequences will be decimated, appearing jumpy.

Decomb provides two special decimation modes to better handle hybrid clips.

Mostly Film Clips (mode=3)

Let's first consider the case where the clip is mostly film. In this case, we want to decimate the film portions normally so they will be smooth. For the nonfilm portions, we want to reduce their frame rate by blend decimating each cycle of frames from 5 frames to 4 frames. Video sequences so rendered appear smoother than when they are decimated as film.

Here is a typical script to enable this mode of operation:

Telecide(guide=1)
Decimate(mode=3,threshold=1.0)

There are 2 factors that enable Decimate to treat the film and nonfilm portions appropriately. First, when Telecide declares guide=1, it is able to pass information to Decimate about which frames are derived from film and which from video. For this mechanism to work, Decimate must immediately follow Telecide. Clearly, the better job you do with pattern locking in Telecide (by tweaking parameters as required), the better job Decimate can do.

The second factor is the threshold. If a cycle of frames is seen that does not have a duplicate, then the cycle is treated as video. The threshold determines what percentage of frame difference is considered to be a duplicate. Note that threshold=0 disables the second factor.

Mostly Video Clips (mode=1)

Now let's consider the case where the clip is mostly video. In this case, we want avoid decimating the video portions be smooth. For the film portions, we want to leave them at the video rate but change the duplicated frame into a frame blend so it is not so obvious.

Here is a typical script to enable this mode of operation:

Telecide(guide=1)
Decimate(mode=1,threshold=1.0)

There are 2 factors that enable Decimate to treat the film and nonfilm portions appropriately. First, when Telecide declares guide=1, it is able to pass information to Decimate about which frames are derived from film and which from video. For this mechanism to work, Decimate must immediately follow Telecide. Clearly, the better job you do with pattern locking in Telecide (by tweaking parameters as required), the better job Decimate can do.

The second factor is the threshold. If a cycle of frames is seen that does not have a duplicate, then the cycle is treated as video. The threshold determines what percentage of frame difference is considered to be a duplicate. Note that threshold=0 disables the second factor.


--------------------------------------------------------------------------------

Acknowledgements
I'd like to thank Thomas Daniel ('manono') for his valuable assistance during the development of this software. He not only made several valuable suggestions and pointed out useful resources, but he performed torture testing on very difficult streams and ran head-to-head tests against other available decombing software.

Darryl Andrews provided valuable assistance in specifying and testing the new features in Version 4.00.

Klaus Post ('sh0dan') provided some code and ideas for low-level optimization of the YV12 code.

Members of the forum at doom9.org provided much help and encouragement.
您需要登录后才可以回帖 登录 | 成为会员

本版积分规则

小黑屋|手机版|NMM视频技术

GMT+8, 2024-3-29 15:52 , Processed in 0.119816 second(s), 14 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表