Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
|
|
Thread Tools | Search this Thread | Display Modes |
26th July 2004, 00:15 | #1 | Link |
ffdshow/AviSynth wrangler
Join Date: Feb 2003
Location: Austria
Posts: 2,441
|
BlendBob 1.2: smartbobbed-field matching and de-rainbowing filter
Okay, some here may actually remember my BlendBob script that I've posted a bit about here - even though not a single person posted in that thread; was everybody totally stunned by it's greatness?
Well, to make a long story short: I've made a new and improved version of it, but this time as an AviSynth plugin (currently at version 1.2). It does approximately the same job that Telecide has, but instead of trying to directly match fields and then deinterlace what slipped through it does it the other way around by using a smart bobber (well, I've only tested it with KernelDeint, but you could probably use anything a bit smarter than Bob()) to produce a frame from each field and then blends every other frame with the neighbouring frame that closer matches it (and which also brings the framerate back to what it started at); if the smart bobber did it's job right then no combs should be able to slip through (except for a special case I'll explain further down...). It's advantage over Telecide is that you really needn't worry about finding a threshold for comb elimination; the smart bobber takes care of that. The blending of 2 smart bobbed frames means you'll get full resolution in still areas and damn close to full resolution in moving areas. The derainbowing code I've added takes the chroma from the 2 frames it's chosen for blending, subtracts them and builds a mask of all pixels where the chroma difference exceeds a threshold. This mask is then used to replace the rainbowed chroma in the blended frame with a blurred version that has less to no rainbows. Of course, you'll still need to use Decimate() on the result (unless I start working on my own plugin for that... ). Here's the readme that comes with it: Code:
BlendBob 1.2 by Kurt Bernhard Pruenner ====================================== This filter takes a bobbed video stream and halves it's framerate by blending every other frame with the adjacent frame that matches it best. Additionally, it tries to fix badly telecined frames, and offers derainbowing options for 24 and 30FPS material. Parameters ========== c ............... Clip to blend show ............ If true show the following framematching metrics: * The first line shows the current frame number and the action that is used for this frame * The next line shows the following metrics: - Difference between previous & current frame - Difference between current & next frame - Difference between previous & next frame - The difference used for determining the action - The average used metric for the last 7 frames - The frame's brightness (used to normalize differences) * The last line shows two metrics that measure the similarity of the current resulting frame and the previous and next one. If a badly telecined frame is found that has a small enough difference to one of these neighbours it is replaced with it, otherwise a blend of the previous and next source frame is passed through, which has somewhat less vertical resolution depending on the bobber that was used. (default false) pnThresh ........ Threshold for bad telecine detection; the smaller one of the prev/curr and curr/next differences minus the averaged used values must be pnThresh times larger than the prev/next difference for the frame to be detected as badly telecined. Set to 0.0 or very high to turn this off. (default 2.5) diffBias ........ Weight bias for difference weights: 0.0 gives a sine curve from -pi to pi 0.0 to -1.0 moves the end value towards 0 0.0 to 1.0 moves the start value towards 0 Set this to below zero if your source is noisy. (default 0.0) diffScale ....... The weights calculated using diffBias are values between 0.0 and 1.0, which are then multiplied by this value - adjust this if your setting for diffBias produces too small results (default 16.0) forceMatch ...... Force a match in case you want to derainbow progressive material 0 - automatic matching 1 - force curr/next matches 2 - force prev/curr matches (default 0) derainbow ....... 0 - Turn rainbow elimination off 1 - Turn rainbow elimination on 2 - Mark rainbows red 3 - Replace luma with gray and only show rainbows in chroma 4 - Show rainbow mask NOTE: derainbowing will only work on 24 or 30FPS material where the rainbows change with every new field. (default 0) rainbowThresh ... Color difference threshold for detecting rainbows, higher values detect less rainbows (default 32) rainbowRadius ... Blur radius in pixels (1-8) that is used for nuking rainbows (a (2*r-1)^2 pixel area with the current pixel in the center is being averaged, so 1 really doesn't do anything) (default 4) badFrames ....... 0 - Replace bad frames 1 - Pass bad frames through 2 - Pass bad frames through with their frame number in the top right corner, skip up to 100 good frames per requested frame (default 0) dupeThresh ...... Threshold for duplicate detection; if a bad frame is detected and the dupe difference of either the next or previous frame is lower than this vale then the bad frame is replaced with it. (default 500) dupeBias ........ Weight bias for duplicate detection difference weights 0.0 gives a sine curve from -pi to pi 0.0 to -1.0 moves the end value towards 0 0.0 to 1.0 moves the start value towards 0 Set this to below zero if your source is noisy. (default 0.0) dupeScale ....... The weights calculated using dupeBias are values between 0.0 and 1.0, which are then multiplied by this value - adjust this if your setting for dupeBias produces too small results (default 16.0) coring .......... Set to true if input luma range is TV range (16-235); used for frame brightness calculation (default true) forceCPU ........ Force the filter to only use specific optimizations 0 ... autodetect 1 ... C++ code only 2 ... Use MMX code where available 3 ... Use MMX & Integer SSE code where available 4 ... Use MMX & SSE code where available 5 ... Use MMX & SSE & SSE2 code where available (default 0) Version history =============== 25.07.2004 Version 1.0 * First Release - still missing de-rainbowing 28.07.2004 Version 1.1 * First implementation of de-rainbowing using spatial nuking (pure C only, though) 28.07.2004 Version 1.1a * D'oh - SSE frameblending code was disabled 31.07.2004 Version 1.2 * Main part of de-rainbowing now also implemented with MMX * Fixed memory allocation bug where I used rainbowThresh instead of rainbowRadius; this could crash if rainbowThresh wasn't at least 2 times as big as rainbowRadius - and it wasted memory as well Code:
MPEG2Source("test.d2v",cpu=4,moderate_h=30,moderate_v=60,iPP=true,idct=6) KernelBob(1,8,false) BlendBob(show=true,badFrames=0) Example 1: Bad frame passed through (badFrames=1): vs. Bad frame fixed (badFrames=0): Example 2: Bad frame passed through (badFrames=1): vs. Bad frame fixed (badFrames=0): (notice that this time the frame wasn't replaced with one of it's neighbours as the background is moving slowly in this scene; if it had been replaced there would have been a stutter in the video) To better illustrate the problem, here's the original frames around the first example: (as you can see, the second and third frame are identical and can't be matched, but using a neighbouring frame instead works nicely) Download BlendBob 1.2 (including the source) np: A Grape Dope - Am Nasty (Immediate Action comp.) Last edited by Leak; 6th November 2006 at 12:40. |
26th July 2004, 05:29 | #2 | Link |
Almost Silent Member
Join Date: Jun 2002
Location: Purgatory
Posts: 273
|
Glad to see that script is being made into a plugin. I didn't post into the other thread because I didn't have any problems with it when I used it.
I'll gladly run some tests once I have an empty job queue again. Is there anything in particular you want testers to look for, or are concerned with?
__________________
Rethinking the "Why?" chromosome. |
26th July 2004, 11:11 | #3 | Link | |
ffdshow/AviSynth wrangler
Join Date: Feb 2003
Location: Austria
Posts: 2,441
|
Quote:
And I'd of course like to know if there are bugs in it, or if people find it useful, or if they have ideas for enhancements... the usual things... np: Bigg Jus - NYC Color Designer (Black Mamba Serums v2.0) |
|
26th July 2004, 12:12 | #4 | Link | |
Registered User
Join Date: May 2003
Location: Germany
Posts: 502
|
Quote:
|
|
26th July 2004, 12:56 | #5 | Link | |||||
ffdshow/AviSynth wrangler
Join Date: Feb 2003
Location: Austria
Posts: 2,441
|
Quote:
Quote:
Of course you'll get motion blending on full framerate material (i.e. sport broadcasts), but on movies or TV series or anime you shouldn't get blurred motion. Quote:
Quote:
If you meant to say that the output is inferior to when a field matcher can find a match - yes, it's a bit smoother, but not as much as if you'd simply deinterlace everything. Quote:
To be honest, I'm not looking for the sharpest picture possible (but I do think the output of my filter still looks quite sharp), but for the smoothest motion possible without the jaggies you get when suddenly a deinterlacer kicks in with Decomb and without the possibility of there being stray combs because there's this one scene that needs a lower vThresh in Telecide... (this is not against Decomb, as it does what it does great, but I like to be able to do things in more ways than one... ) np: Alter Ego - Satanic Circus (Transphormer) Last edited by Leak; 9th March 2007 at 23:58. |
|||||
26th July 2004, 13:48 | #6 | Link | ||||
Registered User
Join Date: May 2003
Location: Germany
Posts: 502
|
Quote:
[/B][/QUOTE] Quote:
Quote:
Quote:
|
||||
26th July 2004, 14:14 | #7 | Link |
Registered User
Join Date: Jun 2004
Posts: 75
|
hi i have just finish similat plugin based on dup thresold :P and now i seen this thread.... DOH
i have got confusion where is Kernelbob function?? in blendbob script? or in dll?? to work i have past into my script kernelbob function from blendbob.avsi and loaded dll is corrent? |
26th July 2004, 16:01 | #8 | Link | ||
ffdshow/AviSynth wrangler
Join Date: Feb 2003
Location: Austria
Posts: 2,441
|
Quote:
Quote:
np: Bigg Jus - Dedication 2 Pray (Black Mamba Serums v1.0) |
||
27th July 2004, 11:42 | #10 | Link | |
Dismembered
Join Date: Nov 2003
Location: Craggy Island
Posts: 873
|
Ok, I've tried your filter on a telecined PAL series I have last night. I know, hardly challenging, PAL field shifts are pretty straighforward, but that's all I have, and if it can't do the basics, what else can it do hey?
Result: You've sold it to me Excellent results. No shimmering, or anything untowards(I have former episodes to check against).Considering the crappy state of the source(obviously remastered VHS to a DVD),I'm pretty happy to have it look as good as it can, even slightly nicer to me(in this case) than telecide(guide=2) ! THX leak.... now if I get my hands on a hybrid, I will be sure to give it a go, and please keep working on it I have a question about this: Quote:
I got it running as kernelbob(1,8) |
|
27th July 2004, 12:14 | #11 | Link | ||
ffdshow/AviSynth wrangler
Join Date: Feb 2003
Location: Austria
Posts: 2,441
|
Quote:
Code:
# # Kernel Bob - uses KernelDeint to bob-deinterlace video # (maybe not the newest version, but it gets the job done) # # c ...................... clip to bob # topFieldFirst .......... 0 for bottom field first, 1 for top field first # kernelDeintThreshold ... threshold used for KernelDeint, 8 works for me # sharp .................. use sharpening, higher resolution kernel # # Needs KernelDeint(), tested with version 1.4.0 # Function KernelBob(clip c, int "topFieldFirst", int "kernelDeintThreshold", bool "sharp") { Assert(Defined(topFieldFirst),"topFieldFirst must be specified!") kernelDeintThreshold=Default(kernelDeintThreshold,3) sharp=Default(sharp,false) a=((topFieldFirst == 1) ? c.AssumeTFF() : c.AssumeBFF()) b=separatefields(a).trim(1,0).weave() a=a.kerneldeint(order=topFieldFirst, \ sharp=false, \ threshold=kernelDeintThreshold) b=b.kerneldeint(order=(1-topFieldFirst), \ sharp=false, \ threshold=kernelDeintThreshold) return interleave(a,b) } Quote:
And yes, I'll keep working on it considering I'm using it myself... Next stop will be implementing the de-rainbowing I have in my BlendBob script (so I'll finally be able to get a good encode out of my Armitage III RC2 DVD). Then I'll probably have a look if it makes sense to add a second mode that'll match the unbobbed fields using data gained from the bobbed ones, which would get this plugin quite a bit closer to being an actual fieldmatcher... In this case, integrating KernelBob into the filter might be a good idea so you can directly feed it your source, without the need of bobbing it first (although leaving an option to use any bobber might be a good idea). Also, looking at KernelDeint's source I see it's all C++, so I guess converting the main loop to assembler using MMX or rather floating point SSE/SSE2 might speed it up a great deal (not that it's slow to begin with... ). np: Alter Ego - Rocker (Transphormer) |
||
27th July 2004, 12:27 | #12 | Link | |||
Dismembered
Join Date: Nov 2003
Location: Craggy Island
Posts: 873
|
Thx for the clarification, though I was on my way to edit my post to say I'd figured it out
Quote:
btw i have a P4 too, so I can prove nothing . Quote:
Quote:
and will there be an option to use the de-rainbower on its own as well? |
|||
27th July 2004, 13:14 | #13 | Link | |||
ffdshow/AviSynth wrangler
Join Date: Feb 2003
Location: Austria
Posts: 2,441
|
Quote:
Quote:
Quote:
I just have the nagging feeling that a bad edit in the video can screw that up, so probably changing the matching direction if enough frames seem to be wrong might be a good idea. (If you're suddenly matching the wrong frames, all movement in the chroma will be detected as rainbows, which won't be pretty...) Of course, you'll still need to bob your material then, but if the fieldmatching part I've talked about above works out the derainbowing should also work on the raw input. np: Bigg Jus - Athena (Black Mamba Serums v1.0) |
|||
27th July 2004, 21:49 | #14 | Link |
Hates all his encodes
Join Date: Sep 2003
Posts: 166
|
I have to say Leak, I've tested it on Hybrid material.... And while it does blur a tad bit, it definitely conquers stray frames/poorly telecined frames in a manner that any other deinterlacer I used could not. Great filter!
__________________
http://thevideophile.blogspot.com/ Watch and be amazed by my frustration over the video world! |
28th July 2004, 07:12 | #15 | Link |
Brazilian Anime Ripper
Join Date: Nov 2001
Location: Brazil
Posts: 237
|
This filter is a very good surprise for me. I try in two different anime series (Yu-Gi-Oh and Captain Tsubasa) both I have better IVTC/deinterlace results than Telecide, TomsMoComp and KernelDeint.
Tanks for this great filter.
__________________
Capture cards: Compro VideoMate Gold+ (Philips SAA7134 based) (not active) Hauppauge PVR 150MCE (not active) ATI TV Wonder Elite (active) |
28th July 2004, 12:50 | #16 | Link |
Registered User
Join Date: Jun 2004
Location: Netherlands
Posts: 129
|
Wouldn't it be better if you check for similarity between bobbed frames and then weave the fields, thus retaining the fps? So in moving scenes you simply bob, but in still scenes you get some sort of enhanced bob, just like you have now, but you also retain fluidity of motion.
That was at least what I was thinking about a few days ago. Gotta do something when you can't sleep . |
28th July 2004, 16:02 | #17 | Link |
interlace this!
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
|
yes - a parameter like "blend=false" or something of the kind would be good. even a "mode=1" style param would be useful for choosing whether to weave, blend or use a combination with some kind of thresholding.
hmmm... have you considered having a look at scharfi's intellibob? there's something that could use it's own plugin, even if it is a simplified version that could be built on in scripts, like a generic per-pixel field matcher plugin that could be called from script functions.
__________________
sucking the life out of your videos since 2004 |
28th July 2004, 17:11 | #18 | Link | ||
ffdshow/AviSynth wrangler
Join Date: Feb 2003
Location: Austria
Posts: 2,441
|
Quote:
Quote:
Also, before I do anything like that I'll probably take a shot at optimizing KernelDeint; currently it's pure C++ code which could use some floating point SSE code - dunno if an Integer MMX version is practicable. np: El-P - Truancy (Fantastic Damage) |
||
28th July 2004, 17:11 | #19 | Link | |
ffdshow/AviSynth wrangler
Join Date: Feb 2003
Location: Austria
Posts: 2,441
|
Quote:
If you mean to apply my filter on 60 FPS interlaced material it'll probably work quite poorly, it's mainly meant for telecined material. But yes, I've thought about using the bobbed frames for calculating the metrics and then weaving the original fields instead of blending the bobbed frame; it's just that I'm currently working on the derainbowing part I myself could use very much... np: Radiohead - The National Anthem (Kid A) |
|
28th July 2004, 17:26 | #20 | Link |
ffdshow/AviSynth wrangler
Join Date: Feb 2003
Location: Austria
Posts: 2,441
|
Version 1.1 released
Okay, so you've probably already noticed that I've updated the first post...
Version 1.1 adds de-rainbowing (look in the readme or the first post for info on how to use it), but currently it's implemented in C++ only so you'll get a noticeable speed drop for using it (my test script went from 28 FPS to 17 FPS using a blur radius of 6, so I think that it's not too bad - after all, it took most of the rainbowing down with it... ). Adding MMX and SSE versions of the performance critical functions is up next. Also, I've fixed a bug in the MMX frame blender that was not really blending well - since nobody noticed it I guess everybody is using SSE capable CPUs nowadays... np: Gold Chains - Young Miss America (Young Miss America) |
Thread Tools | Search this Thread |
Display Modes | |
|
|