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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 5th September 2018, 08:05   #1  |  Link
Katie Boundary
Registered User
 
Katie Boundary's Avatar
 
Join Date: Jan 2015
Posts: 606
A different approach to truncated sinc filters

AVIsynth's built-in sinc filter is designed to truncate at an integer number of taps. This leaves filter shapes that need to be "normalized" because their integrals don't equal 1. But has anyone looked into truncating the filter at x-values that leave a filter shape with an integral of exactly 1?

So |x| =
0.61320733549
1.55775636508
2.53778369874
3.52784055722

and so on?
__________________
If I ask "How do I do X?" or "what happens if I do X?", and X is a very bad thing that no one would ever normally do, assume that I already know this, and that I have Katie reasons for asking anyway.
Katie Boundary is offline   Reply With Quote
Old 5th September 2018, 09:50   #2  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 1,812
Quote:
AVIsynth's built-in sinc filter is designed to truncate at an integer number of taps.
As opposed to what? A non-integer number?

Sinc is an infinite filter. It will never add up to 1 in all finite cases.

And it's not the integral you want to equal 1, it's the sum of the particular coefficients that get picked, and those depend on your sampling position.

Quote:
So |x| =
0.61320733549
1.55775636508
2.53778369874
3.52784055722

and so on?
The more I read this the more I suspect you don't have any understanding of how interpolation filters work.

Then again maybe I'm still blocked for daring to question your brilliance last time, so if anyone who isn't on the Naughty List wants to quote this...
__________________
My AviSynth filters / I'm the Doctor

Last edited by wonkey_monkey; 5th September 2018 at 13:10.
wonkey_monkey is offline   Reply With Quote
Old 5th September 2018, 17:27   #3  |  Link
Katie Boundary
Registered User
 
Katie Boundary's Avatar
 
Join Date: Jan 2015
Posts: 606
Quote:
Originally Posted by davidhorman
This message is hidden because davidhorman is on your ignore list.
Thank you for your input.
__________________
If I ask "How do I do X?" or "what happens if I do X?", and X is a very bad thing that no one would ever normally do, assume that I already know this, and that I have Katie reasons for asking anyway.
Katie Boundary is offline   Reply With Quote
Old 5th September 2018, 18:11   #4  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,073
I'm a bit confused by your terminology and I'm not a DSP guru, but as far as I understand it, if you want a sinc filter where the coeffs sum to exactly 1, you pretty much want Lanczos, because that's pretty much what Lanczos is. Getting the coeffs to sum to exactly 1 in a real implementation (of any resizer) with all its pesky numerical precision issues requires dithering them though, and even then there might still be a small residual error. See for example zimg's take on it.

Last edited by TheFluff; 5th September 2018 at 18:15.
TheFluff is offline   Reply With Quote
Old 5th September 2018, 19:01   #5  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 1,812
Quote:
Originally Posted by Katie Boundary View Post
Thank you for your input.
If you must be condescending when someone does their best to answer your questions, you should really only do so when you know what you're talking about.

You don't.

Furthermore, most of your "contributions" to this forum seem to consist of little more than insulting other members and spurning their advice, always given in good faith. You're dragging this forum down with your childishness and it's both pathetic and pitiful.
__________________
My AviSynth filters / I'm the Doctor

Last edited by wonkey_monkey; 5th September 2018 at 19:08.
wonkey_monkey is offline   Reply With Quote
Old 5th September 2018, 20:15   #6  |  Link
Katie Boundary
Registered User
 
Katie Boundary's Avatar
 
Join Date: Jan 2015
Posts: 606
Quote:
Originally Posted by TheFluff View Post
I'm a bit confused by your terminology and I'm not a DSP guru, but as far as I understand it, if you want a sinc filter where the coeffs sum to exactly 1, you pretty much want Lanczos, because that's pretty much what Lanczos is.
Lanczos is a windowed sinc filter. I'm referring to truncated sinc, where it just gets cut off abruptly instead of tapering. But you bring up an interesting tangent: In some tests that I ran last night on Desmos, I did notice that Lanczos filters had integrals of pretty damn close to 1 for any number of taps 2 or greater. I expect this to be true of other windowed sinc filters as well. Even at only one tap, the integral was about 0.9

Quote:
Originally Posted by TheFluff View Post
See for example zimg's take on it.
That looks a lot like C code, but isn't C supposed to start with "#include <stdio.h>" and have a "main int" somewhere?
__________________
If I ask "How do I do X?" or "what happens if I do X?", and X is a very bad thing that no one would ever normally do, assume that I already know this, and that I have Katie reasons for asking anyway.
Katie Boundary is offline   Reply With Quote
Old 5th September 2018, 22:42   #7  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,073
As davidhorman mentioned (see below for the record), if you want the coeffs for a sinc filter to sum to exactly 1 then you need an infinitely large filter kernel, so the question in the OP is nonsensical. If you want the coeffs to sum to exactly 1 then you can't just leave some of them out (which is what you do by only considering a fixed number of taps - the mathematically pure sinc filter has an infinite number of taps). So, as I said, the way you solve this is to use a window function because infinitely large filter kernels are obviously not practical, and the best way to do that windowing that anyone has come up with is Lanczos, and that's the only answer I can give you other than "you can't do that".

Quote:
Originally Posted by davidhorman View Post
Quote:
AVIsynth's built-in sinc filter is designed to truncate at an integer number of taps.
As opposed to what? A non-integer number?

Sinc is an infinite filter. It will never add up to 1 in all finite cases.

And it's not the integral you want to equal 1, it's the sum of the particular coefficients that get picked, and those depend on your sampling position.

Quote:
So |x| =
0.61320733549
1.55775636508
2.53778369874
3.52784055722

and so on?
The more I read this the more I suspect you don't have any understanding of how interpolation filters work.

Then again maybe I'm still blocked for daring to question your brilliance last time, so if anyone who isn't on the Naughty List wants to quote this...

Last edited by TheFluff; 5th September 2018 at 22:46.
TheFluff is offline   Reply With Quote
Old 6th September 2018, 17:16   #8  |  Link
Katie Boundary
Registered User
 
Katie Boundary's Avatar
 
Join Date: Jan 2015
Posts: 606
Quote:
Originally Posted by TheFluff View Post
As davidhorman mentioned (see below for the record), if you want the coeffs...
I didn't say anything about coeffs. I said the integral.
__________________
If I ask "How do I do X?" or "what happens if I do X?", and X is a very bad thing that no one would ever normally do, assume that I already know this, and that I have Katie reasons for asking anyway.
Katie Boundary is offline   Reply With Quote
Old 6th September 2018, 19:00   #9  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 1,812
Quote:
I didn't say anything about coeffs. I said the integral.
Why? What significance does the integral have?

Pass this on if you would, Fluff
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 7th September 2018, 00:46   #10  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,073
Quote:
Originally Posted by Katie Boundary View Post
I didn't say anything about coeffs. I said the integral.
I don't understand what you mean. Perhaps you can elaborate on your line of reasoning?

Last edited by TheFluff; 7th September 2018 at 00:48.
TheFluff is offline   Reply With Quote
Old 8th September 2018, 22:52   #11  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Germany
Posts: 660
Quote:
Originally Posted by Katie Boundary View Post
That looks a lot like C code
Almost. It's C++. ^_^

Quote:
Originally Posted by Katie Boundary View Post
but isn't C supposed to start with "#include <stdio.h>"
There's no need to include standard input output unless you need to.
It already includes a bunch of things needed for the calculations it has to do:

Code:
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <stdexcept>
#include <vector>
And... in the code linked by TheFluff, the rounding is done (lines 93-115) using double and then float, trying to minimize the error.
__________________
Broadcast Encoder
Avisynth memes: 1 - 2 - 3
Videotek - Audacity XP
FranceBB is offline   Reply With Quote
Old 10th September 2018, 17:31   #12  |  Link
Katie Boundary
Registered User
 
Katie Boundary's Avatar
 
Join Date: Jan 2015
Posts: 606
Quote:
Originally Posted by TheFluff View Post
I don't understand what you mean. Perhaps you can elaborate on your line of reasoning?
Just wondering if there's anything particularly magical about filter shapes with an integral of exactly 1, and if so, what the implications are for truncated (NOT windowed) sinc filters.
__________________
If I ask "How do I do X?" or "what happens if I do X?", and X is a very bad thing that no one would ever normally do, assume that I already know this, and that I have Katie reasons for asking anyway.
Katie Boundary is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 19:27.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.