PDA

View Full Version : Reversing blend deinterlacing


thewebchat
3rd September 2009, 18:11
In the case that a 60i video source is converted to 30p by blend deinterlacing and the transform used is known, can the transform used by reversed, restoring the original 60i source?

Case: A 60i video is converted to 30p via AviSynth Blur(0,1). Is there an inverse to this transform that can be applied to restore the 60i?

Note: This is a question - asking for any sources or whatever is completely beside the point.

neuron2
3rd September 2009, 22:01
Start with variables A and B and define the transformation A + B -> C. Now you have just C. How can you go backwards knowing just C?

thewebchat
3rd September 2009, 23:26
In this case, since we average pairs of lines together, wouldn't it be more like A + B -> C + D since no pixels were removed? In this case, knowing the transform, shouldn't it be possible to turn C + D back into A + B if we know how C/D are related to A/B?

neuron2
4th September 2009, 00:03
It depends on how the blending is done.

In a simple blend deinterlacing we have:

A
C
B

where A and B are from one field and C from another.

We replace C by C' with:

C' = 0.5 C + 0.25 A + 0.25 B

Now, given C' and A and B, we can calculate C. But this only works if the blending was performed only on the field that contains C. If it is performed on all lines of both fields, we no longer have A and B.

Gavino
4th September 2009, 00:45
If it is performed on all lines of both fields, we no longer have A and B.
That's true, but we have A' and B' instead.
Given that the number of output pixels is the same as the number of input ones, we have n equations in n unknowns, which in principle should be solvable. In deriving the equations, you would have to take into account how the original convolution treated the edges, of course, but let's assume that is known.

In practice though, even if you could mathematically solve the equations, you could never losslessly recreate the original pixel values due to rounding errors.

thewebchat
4th September 2009, 01:29
Well, rounding aside, how would we approach the problem? My linear algebra is poor (non-existent), so could you describe it to me? You seem to know a lot about the inner-workings of AviSynth, Gavino, so perhaps we could use the Blur(0,1) vertical kernel as an example?

neuron2
4th September 2009, 03:31
OK, theoretically possible. But it's going to be near O(n^3) and that only does one column of the frame. So likely quite impractical for video, but I'll keep an open mind.

thewebchat
4th September 2009, 04:49
Oh, I see. For a 1x4 image, the problem is something like this:

A B C D
0.50 0.25 0.00 0.00 = A'
0.25 0.50 0.25 0.00 = B'
0.00 0.25 0.50 0.25 = C'
0.00 0.00 0.25 0.50 = D'

And the length of this problem only grows as the number of pixels increases. I see, so there is no fast way to solve this problem (and the rounding error will compound really fast anyway).

Then again, the transform for each column should be the same, so perhaps if the equation could be solved once per video and the results cached.

neuron2
4th September 2009, 05:08
Then again, the transform for each column should be the same, so perhaps if the equation could be solved once per video and the results cached. No, it has to be solved for every frame because the data is different and hence the system of equations is different. You could re-use a column's solution if the column's pixels don't change from one frame to the next.

thewebchat
4th September 2009, 07:16
Ah, I see. So, a general case reverse blend deinterlace is not practical. In that case, how about the special case where we reverse the (adaptive) blend deinterlacing of telecined content. I know SRestore has such a mode (though it doesn't work that well). In this case, the values for A and B can be found from the neighboring progressive frames, so if we know which frames are blend deinterlaced, it should be possible to reverse the blend trivially, correct?