EEDI2 Port

Archive of historical development discussions
Discussions / Development has moved to GitHub
Forum rules
*******************************
Please be aware we are now using GitHub for issue tracking and feature requests.
- This section of the forum is now closed to new topics.

*******************************
jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

EEDI2 Port

Post by jbrjake » Wed Dec 10, 2008 5:27 pm

While yadif's a great filter overall, its spatial interpolation isn't that hot:

- It's very clever and fast, but it doesn't work well on anything other than 90 and 45 degree angles.

- Thin lines get mangled pretty badly.

- It only looks at a 4x3 block of pixels.

- And it only averages together two of those pixels to find its spatial guess.

With decomb I tried to improve things slightly (whether I actually did is arguable) by switching to cubic interpolation, which considers more pixels when it guesses. I still used the same edge detection, with all its flaws, but pushed out a bit further along those vectors to get more samples.

This helped a little, but there are still lots of jaggies.

Yadid has two parts: a spatial filter and a temporal filter.

The spatial filter -- the part that isn't so great -- looks at the current field and tries to guess the missing one. This gives it a spatial prediction for what its output should be.

Then the temporal filter kicks in, and adjusts that spatial prediction if it thinks it's found a better match in the previous or next field. That part's cool. It's like a poor man's motion compensation.

The geniuses in the AviSynth community figure out a solution -- tritical made yadifmod, a version of yadif that cuts out the spatial prediction and lets you insert another one of your liking.

One of the most popular spatial interpolators to use with yadifmod (or any other AviSynth deinterlacer, particularly tritical's TDeint) is EEDI2, also by tritical. See: http://forum.doom9.org/showthread.php?p ... post744308

EEDI2's niftiness comes from its hard-core approach to the problem. It doesn't just look at a 4x3 window, it gets down to some serious filtering.

It runs an edge detector with a much wider search window than yadif's over the whole field, generating a full resolution bitmap of edging. Then it filters that, with erosion and dilatiion and expansion filters until it's removed the noise and enhanced all the distinct areas of edging. It follows this up with a direction map, that encodes basic spatial vectors for all those edges, to know the directions to interpolate along. Then it upscales all these maps, and refilters them until they're smooth again, and only then does it actually decide which pixels to interpolate from when filling in all the missing lines in the actual image.

It is awesome.

I've shoehorned EEDI2 into decomb.c. When decomb detects a combed frame it wants to filter with yadif, it builds the eedi2 interpolation, and then shunts it to yadif_filter_line to replace its internal spatial_pred.

Patch: http://handbrake.fr/pastebin/pastebin.php?show=344

There is still a lot of work to be done.

- Tritical writes his code for himself. That is, he mostly deals with people using his compiled library, and not other developers hacking on his code. So maintainability and comments and descriptive variable names and white space aren't big priorities for him. They are for me, though, so now that I've got it working I'm going to give the code a serious facelift so people (read: I) can grok what it's doing.

- EEDI2 offers a number of options, but for now I'm just hard coding all of them to the default values.

- The plane copy function is just C, and could definitely be sped up with some assembly on SSE chips.

- For some reason it won't work with DV sources, it's like the stride is wrong; I don't understand why since with r1867 van started to convert them to yuv420, before they hit the filters. EDIT: Van has informed me that this is because DV is BFF. Reversing the tff setting in decomb makes it work great.

- There is a second level of post processing I haven't ported yet, since it's off by default.

- And it'd probably be worth investigating a third set of threads for decomb, to run EEDI2 on all planes simulatneously.

I don't have really great example images yet, but here's a very preliminary test shot I did. This don't demonstrate how the filter will work in regular use. Rather, to test how EEDI2 looked, I set decomb to build EEDI2 interpolations for all frames and passed those through as the output, without including the yadif temporal adjustments. This is what EEDI2 can reconstruct from half the fields of a progressive frame, versus what running --deinterlace="slower" (yadif) would do to it. Also, this doesn't include eedi2's post processing, only its raw (pp=0) interpolation.

original:
Image

yadif:
Image

eedi2:
Image
Last edited by jbrjake on Wed Dec 10, 2008 5:41 pm, edited 1 time in total.
Reason: Adds explanation from van for the DV issue

sdm
Bright Spark User
Posts: 194
Joined: Mon Feb 19, 2007 4:53 pm

Re: EEDI2 Port

Post by sdm » Wed Dec 10, 2008 10:29 pm

jbrjake - man I thank you! I can't wait to try on some animated sources I have.

not a developer - so forgive the post.

--sdm.

jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Re: EEDI2 Port

Post by jbrjake » Sat Dec 13, 2008 8:11 pm

Okay, parameters are no longer hard coded, I've added the first level of post-processing, and the DV issue is worked out. I'm not sure how I feel about the post-processing. I find I prefer the sharper unprocessed look, but for now I'm going with tritical's judgement and leaving pp=1 as a default.

New patch: http://handbrake.fr/pastebin/pastebin.php?show=355

I've begun the task of restyling the code, so that I can better understand and maintain it. Personally I find it easier to grok all those SADs when the pointer indices are column-aligned.

Some basic Shark profiling shows that currently the big timesink is calc_directions().

As of now the yadif spatial prediction is still disabled entirely. I'll probably add another mode setting, so it can be used (nice for comparing the interpolations of each filter without keeping multiple copies of HB around).

I've simply tacked the new parameters onto the end of the old set.

Default (--decomb by itself) is equivalent to:
--decomb=1:2:6:9:80:16:16:10:20:20:4:2:50:24:1

The order is:
mode : spatial metric: motion threshold : spatial threshold : block threshold : block width : block height: magnitude threshold : variance threshold : laplacian threshold : dilation threshold : erosion threshold : noise threshold : maximum search distance : post processing

Quite a mouthful, eh? ;)

Here are descriptions of the new ones, taken verbatim from tritical's README.

These all control edge detection used for building the initial edge map:

* magnitude threshold: the edge magnitude threshold... its range is from 0 to 255, lower values will detect weaker edges.

* laplacian threshold: its range is 0 to 510, lower values will detect weaker lines. vthresh is the variance threshold... its range is 0 to a large number, lower values will detect weaker edges.

default - mthresh = 10 (int)
vthresh = 20 (int)
lthresh = 20 (int)

* erosion_threshold, dilation_threshold:

These are used for dilation and erosion of the edge map:

* erostion_threshold: sets the required number of edge pixels (<=) in a 3x3 area, in which the center pixel has been detected as an edge pixel, for the center pixel to be removed from the edge map.

* dilation_threshold: sets the required number of edge pixels (>=) in a 3x3 area, in which the center pixel has not been detected as an edge pixel, for the center pixel to be added to the edge map.

default - estr = 2 (int)
dstr = 4 (int)

Other parameters:

* maximum_search_distance: Sets the maximum pixel search distance for determining the interpolation direction. Larger values will be able to connect edges and lines of smaller slope but can lead to artifacts. Sometimes using a smaller maxd will give better results than a larger setting. The maximum possible value is 29.

default - 24 (int)

* noise_threshold: Defines a noise threshold between pixels in the sliding vectors, this is used to set initial starting values. Lower values should reduce artifacts but sacrifice edge reconstruction... while higher values should improve edge recontruction but lead to more artifacts. The possible range of values is 0 to 256.

default - 50 (int)

* post_processing: Enables two optional post-processing modes aimed at reducing artifacts by identifying problems areas and then using plain vertical linear interpolation in those parts.

The possible settings are:
0 - no post-processing
1 - check for spatial consistency of final interpolation directions
2 - check for junctions and corners (NOT PORTED YET)
3 - do both 1 and 2 (NOT PORTED YET)

Using the pp modes will slow down processing and can cause some loss of edge directedness.

default - 1 (int)

cvk_b
Veteran User
Posts: 527
Joined: Sun Mar 18, 2007 2:11 am

Re: EEDI2 Port

Post by cvk_b » Sat Jan 03, 2009 2:48 am

Well, I like the new threaded decomb v2 the best (only defaults compared). It's a wee bit faster, and the ouput looks better. So far only tested on Seinfeld. If there's any users out there who know how to patch, please do. Jon won't likely commit this until some more testing happens and I can't do it all myself 8)

dynaflash
Veteran User
Posts: 3820
Joined: Thu Nov 02, 2006 8:19 pm

Re: EEDI2 Port

Post by dynaflash » Sat Jan 03, 2009 6:29 am

cvk_b wrote: If there's any users out there who know how to patch, please do.
Okee Dokee ;)

sdm
Bright Spark User
Posts: 194
Joined: Mon Feb 19, 2007 4:53 pm

Re: EEDI2 Port

Post by sdm » Sun Jan 18, 2009 8:28 pm

seems like this patch is no longer available?

I finally have some time to give it a try.
jbrjake, can you make it available again?

thanks
--sdm.

jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Re: EEDI2 Port

Post by jbrjake » Mon Jan 19, 2009 8:32 pm

Weird, I'd have sworn I set it to save permanently...

This is messy, but it's the current state of the patch:
http://handbrake.fr/pastebin/pastebin.php?show=412

Like I said I was going to do earlier in the thread, I made a new mode, 5, for using eedi2 interpolation. I've also made this the default mode. That means you can compare eedi2 versus regular yadif spatial interpolation by doing --decomb versus --decomb=1 .

I've multithreaded the interpolation. It now runs three threads to interpolate all three planes concurrently, which is what provides the speed boost cvk_b alluded to in an earlier post. There are probably ways to speed this up more (example: I haven't tested yet if I'd be better off using 2 threads and feeding one the two color planes).

The real timesink is calc_directions, because it's where the edges are actually searched. For every pixel, there's a loop that's run through 24 times to compare against pixels up to 12 units away to the left and right. On each of those 24 iterations, there are 6-8 (almost always 8 ) sums of absolute differences found for 3 pairs of values. So that's calling abs() 24 * 8 * 3 = 576 times per pixel. If you look at the code, or the compiler warnings, you'll see I began to play around with using the gcc vector extensions to speed this up. Didn't work too well...too much overhead I guess. Anyway, that code's commented out for now, for the most part.

I finished restyling the code that's already present, but still haven't gotten around to adding level 2 postprocessing. It's slow enough as it is ;>

No Doxy comments yet either.

I would like to check this in soon, but I fear that despite it's goodness, it's too slow for regular users. So I might end up switching back to mode 1's yadif interpolation as the default, and make the user choose to use mode 5.

I'm also thinking about redoing the decomb mask checker soon, to use overlapping blocks instead of non-overlapping...got that stashed away to try out after this is committed.

sdm
Bright Spark User
Posts: 194
Joined: Mon Feb 19, 2007 4:53 pm

Re: EEDI2 Port

Post by sdm » Tue Jan 20, 2009 3:54 am

Okay I have a shiny new patched svn! The the picture setting is something I'm definitely curious to experiment with.
In the past, (Dynaflash?) created a preference (at my request I believe) where you could enter the decomb parameters when using the GUI.
I can't see such a preference any longer, nor a place to enter in the gui.
Can I request such a thing a thing again? or have I missed it.

Thanks for the hard work as always guys.
--sdm.

jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Re: EEDI2 Port

Post by jbrjake » Tue Jan 20, 2009 3:12 pm

The MacGui leaves the default decomb values; in this patch EEDI2 is default so it works fine without a custom string. I asked dynaflash to remove the customization because it was ugly and kludgey. I've also asked him to look into adding a separate inspector window for filters, which will allow a nicer display of advanced stuff and better customization. In the mean time, though, you can compare eedi2 to yadif's interpolation in the gui just by compiling one build with the patch and one without.

dynaflash
Veteran User
Posts: 3820
Joined: Thu Nov 02, 2006 8:19 pm

Re: EEDI2 Port

Post by dynaflash » Tue Jan 20, 2009 8:56 pm

jbrjake wrote:I've also asked him to look into adding a separate inspector window for filters, which will allow a nicer display of advanced stuff and better customization.
As soon as I finish up on some full screen scaling stuff for the picture preview window, I will get on it.

jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Re: EEDI2 Port

Post by jbrjake » Mon Mar 09, 2009 2:19 pm

Finally, a pretty much complete patch for eedi2.

http://handbrake.fr/pastebin/pastebin.php?show=492

I've added that second post-processing mode I'd been too lazy to port before, which filters junctions and corners. Right now the default post-processing mode is 1. I am very much not set on this. I'd be very curious to hear what people think of the three PP modes. They can be tested like so:

* No post-processing:
5:2:6:9:80:16:16:10:20:20:4:2:50:24:0

* Post-process edge direction consistency
5:2:6:9:80:16:16:10:20:20:4:2:50:24:1

* Post-process junctions and corners
5:2:6:9:80:16:16:10:20:20:4:2:50:24:2

* Post-process both direction consistency and junctions/corners:
5:2:6:9:80:16:16:10:20:20:4:2:50:24:3

Personally, I think no post-processing looks the cleanest.

I've also down a major structural overhaul on the patch. Instead of cramming everything into decomb.c, I've split the interpolation functions and their helper routines off to a new source file, libhb/eedi2.c and header. Thoughts on this? I feel like there must be a cleaner way to do this than adding another internal header file, but I'm not sure what it is. I want the functions to be independent of decomb.c so that the interpolator can be used in the regular deinterlacing filter or played with for other purposes (eedi2 run twice on a rotating frame is a decent anti-aliaser).

As well, I've done by best to document all the new functions, Doxygen style.

jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Re: EEDI2 Port

Post by jbrjake » Tue Mar 10, 2009 5:13 pm

Fresher diff: http://handbrake.fr/pastebin/pastebin.php?show=494

This cleans up the patch a bit to remove stuff like modifying whitespace and rearrangements caused by cutting and pasting during development.

I've also added a new spatial metric mode to decomb: -1. This forces all frames to detected as combed and sent to yadif/eedi2 or blend depending on mode. This is a lot easier and less invasive than implementing threaded eedi2 in deinterlace.c, but gives the same benefit. So you can do --decomb=5:-1 and it'll eedi2 interpolate every frame, --decomb=1:-1 and it'll yadif interpolate every frame, or --decomb=4:-1 and it'll lowpass5 blend every frame.

I would really appreciate if if testers could give this a spin and developers would review the code, because I've really reached a point where any further work is going to require this getting checked into the repo. I haven't gotten any feedback in months now and that leaves me feeling trepidatious about committing it.

jzietman
Regular User
Posts: 146
Joined: Mon Feb 04, 2008 3:29 pm

Re: EEDI2 Port

Post by jzietman » Tue Mar 10, 2009 6:05 pm

I'll run some tests this afternoon, see how encodes look. I know that the old yadif decomb didn't perfectly work on my interlaced sources (blackadder episodes, mostly), so we'll see how this works.

edit: i'm using the MacGUI and teh latest SVN, and I'm getting very minor results between no decomb, yadif, and eedi2. Maybe I should be using the CLI? I'll also need to look for more intelaced material. The blackadder stuff, while certainly interlaced, doesn't seem to be getting much of a fix out of these methods.

Also, I just looked at my encode logs, and apparently there's no difference between the two decomb methods with my build; both have yadif and blend working ont eh same number of frames, and the same number of frames remain untouched. is there a string i need to add to use eedi2 in the GUI?

jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Re: EEDI2 Port

Post by jbrjake » Tue Mar 10, 2009 10:10 pm

....it's just an interpolator. It does not affect combing detection. You're supposed to get the same number of hits as without the patch. The difference is in how it deinterlaces the frames it does filter.

jzietman
Regular User
Posts: 146
Joined: Mon Feb 04, 2008 3:29 pm

Re: EEDI2 Port

Post by jzietman » Tue Mar 10, 2009 10:30 pm

well, with default settings, I get the following:

yadif:

Image


eedi2:

Image



I'm guessing that I need to find a better source, though. Maybe this image, which still contains combing similar to the original, simply isn't combed enough to be detected.

jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Re: EEDI2 Port

Post by jbrjake » Tue Mar 10, 2009 10:37 pm

jzietman wrote:Maybe this image, which still contains combing similar to the original, simply isn't combed enough to be detected.
That's why I added the new spatial metric to force detection of all frames as combed. Try using the settings 5:-1

jzietman
Regular User
Posts: 146
Joined: Mon Feb 04, 2008 3:29 pm

Re: EEDI2 Port

Post by jzietman » Wed Mar 11, 2009 4:34 am

Ok, running new encodes using the CLI. Just to make sure before I run it, could I turn off decomb in the CLI using --decomb=0:0? I've been looking through the old decomb threads but there's no clear answer that I kind see.

jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Re: EEDI2 Port

Post by jbrjake » Wed Mar 11, 2009 4:48 am

A: You don't need to use the CLI. The GUIs have text fields for custom filter settings.

B: By "turn off decomb" I assume you mean the combing detection, in which case it's like I said above...you do 5:-1 to force eedi2 interpolation or 1:-1 for yadif interpolation.

jzietman
Regular User
Posts: 146
Joined: Mon Feb 04, 2008 3:29 pm

Re: EEDI2 Port

Post by jzietman » Wed Mar 11, 2009 6:53 am

Sorry for the confusion, I'd forgotten that the custom string box had been replaced after it was removed from the Preferences Pane.

Anyway, here are my results so far. I find that eedi2 provides a minor benefit over yadif at a significant hit to encoding speed. The eedi2 encode is slightly smaller than the yadif encode, both of which are smaller than an encode that has had no deinterlacing applied (likely due to compression inefficiency).

Here are my encode logs:

No deinterlacing:

Code: Select all

HandBrake Activity Log for /Users/jzietman/Desktop/no deinterlacing.m4v: 2009-03-11 02:00:55 -0400
Handbrake Version: svn2255 i386 (2009031101)

[02:00:55] macgui: incrementQueueItemDone currentQueueEncodeIndex is incremented to: 2
[02:00:55] macgui: incrementQueueItemDone currentQueueEncodeIndex is incremented to: 2
[02:00:55] macgui: scanning specifically for title: 1
[02:00:55] macgui: performNewQueueScan currentQueueEncodeIndex is: 2
[02:00:55] hb_scan: path=/Users/jzietman/Movies/BLACK_ADDER_3, title_index=1
[02:00:55] scan: trying to open with libdvdread
[02:00:55] scan: DVD has 1 title(s)
[02:00:55] scan: scanning title 1
[02:00:55] scan: opening IFO for VTS 1
[02:00:55] pgc_id: 1, pgn: 1: pgc: 0x176114d0
[02:00:55] scan: vts=1, ttn=1, cells=0->0, blocks=0->96984, 96985 blocks
[02:00:55] scan: duration is 00:06:47 (407053 ms)
[02:00:55] scan: checking audio 1
[02:00:55] scan: id=80bd, lang=English (AC3), 3cc=eng ext=0
[02:00:55] scan: title 1 has 1 chapters
[02:00:55] scan: chap 1 c=0->0, b=0->96984 (96985), 407052 ms
[02:00:55] scan: aspect = 0
[02:00:55] scan: decoding previews for title 1
[02:00:55] scan: audio 0x80bd: AC-3, rate=48000Hz, bitrate=192000 English (AC3) (2.0 ch)
[02:00:55] scan: 20 previews, 720x480, 29.970 fps, autocrop = 0/0/12/0, aspect 4:3, PAR 8:9
[02:00:55] scan: title (0) job->width:624, job->height:480
[02:00:55] libhb: scan thread found 1 valid title(s)
[02:00:55] macgui: currentScanCount received from fQueueEncodeLibhb
[02:00:55] macgui: ScanDone state received from fQueueEncodeLibhb
[02:00:55] macgui: processNewQueueEncode title list is: 1
[02:00:55] macgui: Preset: blackadder test
[02:00:55] macgui: processNewQueueEncode number of passes expected is: 1
[02:00:55] macgui: prepareJob exiting
[02:00:55] 1 job(s) to process
[02:00:55] starting job
[02:00:55] job configuration:
[02:00:55]  * source
[02:00:55]    + /Users/jzietman/Movies/BLACK_ADDER_3
[02:00:55]    + title 1, chapter(s) 1 to 1
[02:00:55]  * destination
[02:00:55]    + /Users/jzietman/Desktop/no deinterlacing.m4v
[02:00:55]    + container: MPEG-4 (.mp4 and .m4v)
[02:00:55]      + 64-bit formatting
[02:00:55]      + chapter markers
[02:00:55]  * video track
[02:00:55]    + decoder: mpeg2
[02:00:55]      + bitrate 7500 kbps
[02:00:55]    + frame rate: 29.970 fps -> variable fps
[02:00:55]    + dimensions: 720 * 480 -> 624 * 480, crop 0/0/12/0
[02:00:55]    + filter
[02:00:55]      + Detelecine (pullup) (default settings)
[02:00:55]    + encoder: x264
[02:00:55]      + options: level=30:cabac=0:ref=2:mixed-refs=1:me=umh:no-fast-pskip=1
[02:00:55]      + quality: 20.00 (RF)
[02:00:55]  * audio track 0
[02:00:55]    + decoder: English (AC3) (2.0 ch) (track 1, id 80bd)
[02:00:55]      + bitrate: 192 kbps, samplerate: 48000 Hz
[02:00:55]    + AC3 passthrough
[02:00:55] encx264: keyint-min: 30, keyint-max: 300
[02:00:55] encx264: Encoding at constant RF 20.000000
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
[02:00:55] reader: first SCR 73995702
x264 [info]: profile Baseline, level 3.0
No accelerated IMDCT transform found
[02:00:55] sync: expecting 12229 video frames
[02:00:55] output track 0: ac3 in sync after skipping 388 bytes
[02:00:55] mpeg2: "Chapter  1" (1) at frame 0 time 3003
[02:00:55] sync: first pts is 3003
[02:10:25] 230.663773s: Video -> Film
[02:18:13] reader: done. 1 scr changes
[02:18:18] sync: got 12227 frames, 12229 expected
[02:18:18] work: average encoding speed for job is 11.729252 fps
[02:18:21] mpeg2 done: 12228 frames
[02:18:21] render: lost time: 375375 (125 frames)
[02:18:21] render: gained time: 375375 (496 frames) (0 not accounted for)
[02:18:21] render: average dropped frame duration: 3003
x264 [info]: slice I:99    Avg QP:14.37  size: 44523  PSNR Mean Y:48.62 U:50.65 V:51.70 Avg:49.30 Global:48.84
x264 [info]: slice P:12000 Avg QP:17.87  size: 15916  PSNR Mean Y:44.16 U:45.85 V:47.39 Avg:44.81 Global:44.60
x264 [info]: mb I  I16..4: 20.0%  0.0% 80.0%
x264 [info]: mb P  I16..4:  2.2%  0.0%  4.2%  P16..4: 49.4% 32.0% 11.7%  0.0%  0.0%    skip: 0.6%
x264 [info]: ref P L0  73.1% 26.9%
x264 [info]: SSIM Mean Y:0.9765238
x264 [info]: PSNR Mean Y:44.194 U:45.893 V:47.422 Avg:44.847 Global:44.619 kb/s:3872.18
[02:18:21] libhb: work result = 0
yadif on all frames:

Code: Select all

HandBrake Activity Log for /Users/jzietman/Desktop/yadif.m4v: 2009-03-11 01:05:21 -0400
Handbrake Version: svn2255 i386 (2009031101)

[01:05:21] macgui: Rip: Pending queue count is 0
[01:05:21] macgui: Rip: No pending jobs, so sending this one to doAddToQueue
[01:05:21] macgui: Rip: Going right to performNewQueueScan
[01:05:21] macgui: scanning specifically for title: 1
[01:05:21] macgui: performNewQueueScan currentQueueEncodeIndex is: 0
[01:05:21] hb_scan: path=/Users/jzietman/Movies/BLACK_ADDER_3, title_index=1
[01:05:21] scan: trying to open with libdvdread
[01:05:21] scan: DVD has 1 title(s)
[01:05:21] scan: scanning title 1
[01:05:21] scan: opening IFO for VTS 1
[01:05:21] pgc_id: 1, pgn: 1: pgc: 0x117e51d0
[01:05:21] scan: vts=1, ttn=1, cells=0->0, blocks=0->96984, 96985 blocks
[01:05:21] scan: duration is 00:06:47 (407053 ms)
[01:05:21] scan: checking audio 1
[01:05:21] scan: id=80bd, lang=English (AC3), 3cc=eng ext=0
[01:05:21] scan: title 1 has 1 chapters
[01:05:21] scan: chap 1 c=0->0, b=0->96984 (96985), 407052 ms
[01:05:21] scan: aspect = 0
[01:05:21] scan: decoding previews for title 1
[01:05:21] scan: audio 0x80bd: AC-3, rate=48000Hz, bitrate=192000 English (AC3) (2.0 ch)
[01:05:22] scan: 20 previews, 720x480, 29.970 fps, autocrop = 0/0/12/0, aspect 4:3, PAR 8:9
[01:05:22] scan: title (0) job->width:624, job->height:480
[01:05:22] libhb: scan thread found 1 valid title(s)
[01:05:22] macgui: ScanDone state received from fQueueEncodeLibhb
[01:05:22] macgui: processNewQueueEncode title list is: 1
[01:05:22] macgui: Preset: blackadder test
[01:05:22] macgui: processNewQueueEncode number of passes expected is: 1
[01:05:22] macgui: prepareJob exiting
[01:05:22] 1 job(s) to process
[01:05:22] starting job
[01:05:22] job configuration:
[01:05:22]  * source
[01:05:22]    + /Users/jzietman/Movies/BLACK_ADDER_3
[01:05:22]    + title 1, chapter(s) 1 to 1
[01:05:22]  * destination
[01:05:22]    + /Users/jzietman/Desktop/yadif.m4v
[01:05:22]    + container: MPEG-4 (.mp4 and .m4v)
[01:05:22]      + 64-bit formatting
[01:05:22]      + chapter markers
[01:05:22]  * video track
[01:05:22]    + decoder: mpeg2
[01:05:22]      + bitrate 7500 kbps
[01:05:22]    + frame rate: 29.970 fps -> variable fps
[01:05:22]    + dimensions: 720 * 480 -> 624 * 480, crop 0/0/12/0
[01:05:22]    + filters
[01:05:22]      + Detelecine (pullup) (default settings)
[01:05:22]      + Decomb (1:-1)
[01:05:22]    + encoder: x264
[01:05:22]      + options: level=30:cabac=0:ref=2:mixed-refs=1:me=umh:no-fast-pskip=1
[01:05:22]      + quality: 20.00 (RF)
[01:05:22]  * audio track 0
[01:05:22]    + decoder: English (AC3) (2.0 ch) (track 1, id 80bd)
[01:05:22]      + bitrate: 192 kbps, samplerate: 48000 Hz
[01:05:22]    + AC3 passthrough
[01:05:22] yadif thread started for segment 0
[01:05:22] decomb thread started for segment 0
[01:05:22] yadif thread started for segment 1
[01:05:22] decomb thread started for segment 1
[01:05:22] encx264: keyint-min: 30, keyint-max: 300
[01:05:22] encx264: Encoding at constant RF 20.000000
[01:05:22] reader: first SCR 73995702
[01:05:22] mpeg2: "Chapter  1" (1) at frame 0 time 3003
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
x264 [info]: profile Baseline, level 3.0
No accelerated IMDCT transform found
[01:05:22] output track 0: ac3 in sync after skipping 388 bytes
[01:05:22] sync: expecting 12229 video frames
[01:05:22] sync: first pts is 3003
[01:16:59] 230.663773s: Video -> Film
[01:26:36] reader: done. 1 scr changes
[01:26:42] sync: got 12227 frames, 12229 expected
[01:26:42] work: average encoding speed for job is 9.555604 fps
[01:26:45] mpeg2 done: 12228 frames
[01:26:45] render: lost time: 375375 (125 frames)
[01:26:45] render: gained time: 375375 (496 frames) (0 not accounted for)
[01:26:45] render: average dropped frame duration: 3003
x264 [info]: slice I:109   Avg QP:14.31  size: 35655  PSNR Mean Y:49.02 U:50.77 V:51.76 Avg:49.63 Global:49.30
x264 [info]: slice P:11989 Avg QP:17.97  size: 14252  PSNR Mean Y:44.60 U:46.37 V:47.69 Avg:45.25 Global:45.05
x264 [info]: mb I  I16..4: 10.8%  0.0% 89.2%
x264 [info]: mb P  I16..4:  1.4%  0.0%  4.7%  P16..4: 50.2% 32.4% 10.9%  0.0%  0.0%    skip: 0.5%
x264 [info]: ref P L0  69.3% 30.7%
x264 [info]: SSIM Mean Y:0.9789544
x264 [info]: PSNR Mean Y:44.641 U:46.412 V:47.728 Avg:45.291 Global:45.079 kb/s:3463.27
[01:26:45] decomb: yadif deinterlaced 12101 | blend deinterlaced 0 | unfiltered 0 | total 12101
[01:26:45] libhb: work result = 0
eedi2 on all frames:

Code: Select all

HandBrake Activity Log for /Users/jzietman/Desktop/eedi2.m4v: 2009-03-11 01:26:46 -0400
Handbrake Version: svn2255 i386 (2009031101)

[01:26:46] macgui: incrementQueueItemDone currentQueueEncodeIndex is incremented to: 1
[01:26:46] macgui: incrementQueueItemDone currentQueueEncodeIndex is incremented to: 1
[01:26:46] macgui: scanning specifically for title: 1
[01:26:46] macgui: performNewQueueScan currentQueueEncodeIndex is: 1
[01:26:46] hb_scan: path=/Users/jzietman/Movies/BLACK_ADDER_3, title_index=1
[01:26:46] scan: trying to open with libdvdread
[01:26:46] scan: DVD has 1 title(s)
[01:26:46] scan: scanning title 1
[01:26:46] scan: opening IFO for VTS 1
[01:26:46] pgc_id: 1, pgn: 1: pgc: 0x176114d0
[01:26:46] scan: vts=1, ttn=1, cells=0->0, blocks=0->96984, 96985 blocks
[01:26:46] scan: duration is 00:06:47 (407053 ms)
[01:26:46] scan: checking audio 1
[01:26:46] scan: id=80bd, lang=English (AC3), 3cc=eng ext=0
[01:26:46] scan: title 1 has 1 chapters
[01:26:46] scan: chap 1 c=0->0, b=0->96984 (96985), 407052 ms
[01:26:46] scan: aspect = 0
[01:26:46] scan: decoding previews for title 1
[01:26:46] scan: audio 0x80bd: AC-3, rate=48000Hz, bitrate=192000 English (AC3) (2.0 ch)
[01:26:46] scan: 20 previews, 720x480, 29.970 fps, autocrop = 0/0/12/0, aspect 4:3, PAR 8:9
[01:26:46] scan: title (0) job->width:624, job->height:480
[01:26:46] libhb: scan thread found 1 valid title(s)
[01:26:46] macgui: currentScanCount received from fQueueEncodeLibhb
[01:26:46] macgui: ScanDone state received from fQueueEncodeLibhb
[01:26:46] macgui: processNewQueueEncode title list is: 1
[01:26:46] macgui: Preset: blackadder test
[01:26:46] macgui: processNewQueueEncode number of passes expected is: 1
[01:26:46] macgui: prepareJob exiting
[01:26:46] 1 job(s) to process
[01:26:46] starting job
[01:26:46] job configuration:
[01:26:46]  * source
[01:26:46]    + /Users/jzietman/Movies/BLACK_ADDER_3
[01:26:46]    + title 1, chapter(s) 1 to 1
[01:26:46]  * destination
[01:26:46]    + /Users/jzietman/Desktop/eedi2.m4v
[01:26:46]    + container: MPEG-4 (.mp4 and .m4v)
[01:26:46]      + 64-bit formatting
[01:26:46]      + chapter markers
[01:26:46]  * video track
[01:26:46]    + decoder: mpeg2
[01:26:46]      + bitrate 7500 kbps
[01:26:46]    + frame rate: 29.970 fps -> variable fps
[01:26:46]    + dimensions: 720 * 480 -> 624 * 480, crop 0/0/12/0
[01:26:46]    + filters
[01:26:46]      + Detelecine (pullup) (default settings)
[01:26:46]      + Decomb (5:-1)
[01:26:46]    + encoder: x264
[01:26:46]      + options: level=30:cabac=0:ref=2:mixed-refs=1:me=umh:no-fast-pskip=1
[01:26:46]      + quality: 20.00 (RF)
[01:26:46]  * audio track 0
[01:26:46]    + decoder: English (AC3) (2.0 ch) (track 1, id 80bd)
[01:26:46]      + bitrate: 192 kbps, samplerate: 48000 Hz
[01:26:46]    + AC3 passthrough
[01:26:46] reader: first SCR 73995702
[01:26:46] yadif thread started for segment 0
[01:26:46] yadif thread started for segment 1
[01:26:46] decomb thread started for segment 0
[01:26:46] decomb thread started for segment 1
[01:26:46] eedi2 thread started for plane 0
[01:26:46] encx264: keyint-min: 30, keyint-max: 300
[01:26:46] encx264: Encoding at constant RF 20.000000
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
[01:26:46] eedi2 thread started for plane 1
[01:26:46] eedi2 thread started for plane 2
x264 [info]: profile Baseline, level 3.0
No accelerated IMDCT transform found
[01:26:46] output track 0: ac3 in sync after skipping 388 bytes
[01:26:46] sync: expecting 12229 video frames
[01:26:46] mpeg2: "Chapter  1" (1) at frame 0 time 3003
[01:26:46] sync: first pts is 3003
[01:47:07] 230.663773s: Video -> Film
[02:00:45] reader: done. 1 scr changes
[02:00:51] sync: got 12227 frames, 12229 expected
[02:00:51] work: average encoding speed for job is 5.979090 fps
[02:00:54] mpeg2 done: 12228 frames
[02:00:54] render: lost time: 375375 (125 frames)
[02:00:54] render: gained time: 375375 (496 frames) (0 not accounted for)
[02:00:54] render: average dropped frame duration: 3003
x264 [info]: slice I:108   Avg QP:14.00  size: 34394  PSNR Mean Y:49.67 U:51.40 V:52.46 Avg:50.29 Global:49.90
x264 [info]: slice P:11990 Avg QP:17.76  size: 13958  PSNR Mean Y:45.02 U:46.77 V:48.11 Avg:45.67 Global:45.46
x264 [info]: mb I  I16..4: 11.0%  0.0% 89.0%
x264 [info]: mb P  I16..4:  1.9%  0.0%  5.8%  P16..4: 49.3% 31.9% 10.5%  0.0%  0.0%    skip: 0.5%
x264 [info]: ref P L0  69.2% 30.8%
x264 [info]: SSIM Mean Y:0.9811139
x264 [info]: PSNR Mean Y:45.062 U:46.811 V:48.153 Avg:45.709 Global:45.484 kb/s:3390.20
[02:00:54] decomb: yadif deinterlaced 12101 | blend deinterlaced 0 | unfiltered 0 | total 12101
[02:00:54] libhb: work result = 0
Here are some snapshots:

No deinterlacing:

Image


yadif:

Image

eedi2:

Image


No deinterlacing:

Image

yadif:

Image

eedi2:

Image



I know the source is low quality. I'm looking through the dvds available to me to find something better.

jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Re: EEDI2 Port

Post by jbrjake » Wed Mar 11, 2009 3:05 pm

That seems pretty much in line with what I've found myself. The difference can be negligible with a lot of low-quality, noisy, live-action stuff. Run it on something with fine detail like animation, though, and the difference can be very significant.

Once the interpolator gets checked in, I can start playing with ways to mix and match the different methods to improve speed. Maybe only run eedi2 on the Y plane, and let yadif handle the color planes internally.

jzietman
Regular User
Posts: 146
Joined: Mon Feb 04, 2008 3:29 pm

Re: EEDI2 Port

Post by jzietman » Wed Mar 11, 2009 4:49 pm

I've got the first season of the Simpsons on DVD, so I'll see if that's interlaced and give it a shot.

RickAns
Posts: 7
Joined: Sat Jan 10, 2009 3:45 am

Re: EEDI2 Port

Post by RickAns » Tue Mar 17, 2009 1:49 am

Greets,

jbrjake - Thank you very much for your work on the EEDI2 port. Been using Handbrake 9.3.0 since it came out and it's enhanced Decomb funtion (yadif + mcdeint + lowpass-5 combo) is what really sold me on Handbrake as my x264 GUI of choice. I have tried over a half dozen or so other GUI's. All the ones on Doom9 plus any others I could find. Along with using another half dozen or so other deinterlacers with AviSynth scripts in CLI form and yours gives me the best looking, smoothest motion picture.

After stumbling around and finally being able to patch EEDI2 and compile Handbrake I have done a few test runs with EEDI2. As noted it is definitely slower, almost by half, than without using it. File size is slightly smaller. The picture quality for me is noticeably better when paying attention.

Tried it out on a few episodes that have given most deinterlacers problems for me, even a little with your Decomb. Diagonal lines of shelves and bookcases, as well as marker writing on a whiteboard, have less of the 'jaggies' effect. Horizontal window blinds look much better and have greatly reduced 'shimmer'. On my quad core with EEDI2 it does not fully max out all the cores. Which is to be expected.

Please, continue the good work. I look forward to continued use of Handbrake well into future encodes. I'm running 64 bit Windows and am pleased to see the x264 devs beginning to work on 64bit versions of it for Windows. Hopefully more filters will continue to be made 64 bit as well so one day we can pipe the full encode chain as 64 bit.


jzietman - Black Adder fan here as well. A thought here on if BA at HD resolutions would be the best test subject. Since BA is originally a standard def video source and your screen caps showing a res of 1440x900. That maybe the resizing would have an adverse affect on EEDI2? I figure you are using a Bluray or something so it has to have been resized from the original standard def res. I'm still stuck in SD world still, so have not delved into HD and how an original SD source would look at those resolutions.

Cheers,
Rick

jzietman
Regular User
Posts: 146
Joined: Mon Feb 04, 2008 3:29 pm

Re: EEDI2 Port

Post by jzietman » Tue Mar 17, 2009 2:42 am

Just to clarify my earlier tests, I used standard DVDs of the tested Black Adder episode, encoded at the same resolution as on the dvd. The screenshots are 1440 x 900 since that's my screen's resolution. To take screenshots, I opened the files in quicktime (to allow for multiple open files at once) and seleted to same frame in all. Then, at full screen (which is how I generally watch my movies), I took a screenshot. So, yes, there is some upscaling, and likely also some compression artifacts due to the png compression algorithm.

The reason the picture quality is so iffy is due not only to the upscaling and the deinterlacing but also to the DVDs themselves; Black Adder was broadcast on TV in the late 80s/early-mid 90s, so picture quality wasn't the greatest.

Elan
Posts: 35
Joined: Wed Jan 30, 2008 6:32 am

Re: EEDI2 Port

Post by Elan » Tue Mar 17, 2009 11:12 pm

I'm using the Mac GUI on SVN2257 x86_64 with the last EEDI2 patch 494.

How can I decomb all the combed frames with eedi2 only? I try using the custom string 5:2:6:9:80:16:16:10:20:20:4:2:50:24:0 but the log show me that it didn't works that way as it blend 194 frames :

decomb: yadif deinterlaced 1 | blend deinterlaced 194 | unfiltered 155425 | total 155620

Code: Select all

[03:47:10] job configuration:
[03:47:10]  * source
[03:47:10]    + /Volumes/DISK2/FIXED/SD/Chasse au Tresor.mpg
[03:47:10]    + title 1, chapter(s) 1 to 1
[03:47:10]  * destination
[03:47:10]    + /Volumes/USERS/Chasse au Trésor.mp4
[03:47:10]    + container: MPEG-4 (.mp4 and .m4v)
[03:47:10]      + 64-bit formatting
[03:47:10]      + optimized for progressive web downloads
[03:47:10]  * video track
[03:47:10]    + decoder: mpeg2
[03:47:10]      + bitrate 15000 kbps
[03:47:10]    + frame rate: 23.976 fps -> variable fps
[03:47:10]    + dimensions: 704 * 480 -> 704 * 480, crop 2/0/0/0
[03:47:10]    + filters
[03:47:10]      + Detelecine (pullup) (default settings)
[03:47:10]      + Decomb (5:2:6:9:80:16:16:10:20:20:4:2:50:24:0)
[03:47:10]    + encoder: x264
[03:47:10]      + options: no-fast-pskip=1:analyse=all:ref=6:mixed-refs=1:subq=9:merange=16:me=umh:bframes=6:direct=auto:weightb=1:8x8dct=1:trellis=2:b-adapt=2:psy-rd=1.0,0.2
[03:47:10]      + quality: 21.00 (RF)
[03:47:10]  * audio track 0
[03:47:10]    + decoder: Unknown (AC3) (Dolby Surround) (track 1, id 80bd)
[03:47:10]      + bitrate: 192 kbps, samplerate: 48000 Hz
[03:47:10]    + mixdown: Stereo
[03:47:10]    + dynamic range compression: 1.000000
[03:47:10]    + encoder: faac
[03:47:10]      + bitrate: 160 kbps, samplerate: 48000 Hz
[03:47:10] thread 1f782000 started ("reader")
[03:47:10] dvd: not a dvd - trying as a stream/file instead
[03:47:10] thread 1fb50000 started ("MPEG-2 decoder (libmpeg2)")
[03:47:10] reader: first SCR 194
[03:47:10] thread 21dfb000 started ("yadif_filter_segment")
[03:47:10] yadif thread started for segment 0
[03:47:10] thread 21e7e000 started ("yadif_filter_segment")
[03:47:10] yadif thread started for segment 1
[03:47:10] thread 21f01000 started ("yadif_filter_segment")
[03:47:10] yadif thread started for segment 2
[03:47:10] thread 21f84000 started ("yadif_filter_segment")
[03:47:10] yadif thread started for segment 3
[03:47:10] thread 22007000 started ("yadif_filter_segment")
[03:47:10] yadif thread started for segment 4
[03:47:10] thread 2208a000 started ("yadif_filter_segment")
[03:47:10] yadif thread started for segment 5
[03:47:10] thread 2210d000 started ("yadif_filter_segment")
[03:47:10] yadif thread started for segment 6
[03:47:10] thread 22190000 started ("yadif_filter_segment")
[03:47:10] yadif thread started for segment 7
[03:47:10] thread 22213000 started ("decomb_filter_segment")
[03:47:10] decomb thread started for segment 0
[03:47:10] thread 22296000 started ("decomb_filter_segment")
[03:47:10] decomb thread started for segment 1
[03:47:10] thread 22319000 started ("decomb_filter_segment")
[03:47:10] decomb thread started for segment 2
[03:47:10] thread 2251c000 started ("decomb_filter_segment")
[03:47:10] decomb thread started for segment 3
[03:47:10] thread 2259f000 started ("decomb_filter_segment")
[03:47:10] decomb thread started for segment 4
[03:47:10] thread 22622000 started ("decomb_filter_segment")
[03:47:10] decomb thread started for segment 5
[03:47:10] thread 226a5000 started ("decomb_filter_segment")
[03:47:10] decomb thread started for segment 6
[03:47:10] thread 22728000 started ("decomb_filter_segment")
[03:47:10] decomb thread started for segment 7
[03:47:10] thread 227ab000 started ("eedi2_filter_segment")
[03:47:10] eedi2 thread started for plane 0
[03:47:10] thread 2282e000 started ("eedi2_filter_segment")
[03:47:10] eedi2 thread started for plane 1
[03:47:10] thread 228b1000 started ("eedi2_filter_segment")
[03:47:10] eedi2 thread started for plane 2
[03:47:10] thread 22934000 started ("Renderer")
[03:47:10] encx264: keyint-min: 24, keyint-max: 240
[03:47:10] encx264: Encoding at constant RF 21.000000
[03:47:10] encx264: opening libx264 (pass 0)
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 PHADD SSE4.1 Cache64
x264 [info]: profile High, level 3.0

jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Re: EEDI2 Port

Post by jbrjake » Wed Mar 18, 2009 3:38 pm

Elan wrote:How can I decomb all the combed frames with eedi2 only?
You don't. You can either force deinterlacing of all frames with yadif+eedi2, or deinterlace only combed frames with either blending or yadif+eedi2 depending on how combed the frame is overall.

It could be added as another mode, though....but it's not really something I want to do inside this patch because it isn't logically connected to eedi2 and would confuse another coder reading through it at a later date. Playing with what interpolator is enabled when is the sort of stuff I've been wanting to get back to for months now, but can't until this code goes into the repo. And I don't feel very comfortable checking in thousands of lines of code no other developer has even glanced at.

Post Reply