Thought I might include this, its in the source folder for coders, but might assist a little for those trying to figure out what it does.
Findblend_Method.txt
[EDIT: Below MD_??_?? is the difference between two potentially unblended 'component' pixels when merged together for final unblended pixel.
eg MD_10_23 and FD_12 etc are the names of actual variables in the source code. FD_12 etc are the actual differences between adjacent frame pixels in blended clip.]
We use the same names pre-prended with "W_" as per frame weighted [0.0 -> 100.0%] variable names.
Code:
|-----------------------------------------------|
ExBlend [ FindBlend() ]
Rough description of ExBlend() blend detection
|-----------------------------------------------|
-------- -------- -------- --------
|MD_10_23| |MD_21_34| |MD_32_45| |MD_43_56|
| | | | | | | |
| | | | | | | |
|--------| |--------| |--------| |--------|
| | | | | | | |
_| |\ _| |____ | |____ | |
| \ | \ /| |\ | | | /| |
| \ \ \ / | | \ /| | | / | |
| \ \ \ / | | \/ | / | / | |
| \ \ \_ /__ |_________ | /\/________/_____|____/ __| /|
| \ \__ /_ | ___\___|_/ // / ____|_____/ ________/ |
-------- \ --------/ \--|-----/ -\--|--// \-----/--/ -|------/ --------/
|Frame_0 | |Frame_1 | |Frame_2 | |Frame_3 | |Frame_4 | |Frame_5 | |Frame_6 |
| | | | | | | Current| | | | | | |
| in_n-3 | | in_n-2 | | in_n-1 | | in_n | | in_n+1 | | in_n+2 | | in_n+3 |
| p0 | | p1 | | p2 | | p3 | | p4 | | p5 | | p6 |
-------- -------- -------- -------- -------- -------- --------
| | | | | | | |
| | | | | | | |
-------- -------- -------- --------
Metrics display->| FD_12 | | FD_23 | | FD_34 | | FD_45 |<-Metrics display
ONLY | | | | | | | | ONLY
| | | | | | | |
-------- -------- -------- --------
-------------------------------------------------------------------------------
PER PIXEL VARIABLES:- (at current x,y postion in frame)
----
px = Pixel Luma from Frame_x (x = 0 to 6).
----
FD_ab = abs(pa - pb) Delta between adj frames[a & b] pixels
----
UP_ab = (pa * 2) - pb;
Pixel, unblended from 2 frames, two of these are later merged to recover
original frame. These are the inputs to MD_ab_cd and are not shown above
as it just makes it look confusing (I tried it), but each pair of lines
into MD_ab_cd can be thought of as UP_ab.
The ordering of the frame numbers (a,b) IS IMPORTANT and can be gotten from
the description of MD_ab_cd
----
MD_ab_cd = abs(UP_ab - UP_cd)
Merge Delta, between component pixels of the potentially recovered
(unblended) pixel. If we find a blended pair of frames and at the current
frame position we have the first blended frame, then current frame in_n
(frame_3) will be replaced with a recovered frame the equivalent unblended
pixels of MD_32_45 and the second blended frame in_n+1 (frame_4) also will
be filled with the same content when the next frame is requested,
(after doing all this again), however, next time around, in_n will be the
second blended frame as the contents of everything would have shifted left
by 1 frame, and so, MD_32_45 will NO LONGER be the recovered frame, it will
now be MD_21_34. When the recovered frame is finally rendered it will go
sort of like:-
RecoveredPixel = (UP_ab + UP_cd + 1) / 2; (for luma)
-------------------------------------------------------------------------------
PER FRAME VARIABLES
---
WEIGHTINGS:- (float)
Accumulated weighting for pixels; Obviously clear to zero at beginning.
----
W_MD_ab_cd += MD_ab_cd;
W_FD_ab += FD_ab;
----
METRIC:-
Final scaling of measurements for whole frames before deciding if blended.
----
float mx = (vi.width * vi.height) * 255.0;
For scaling weighting into more managable & meaningful numbers.
W_MD_ab_cd = W_MD_ab_cd * 100.0 / mx;
W_UP_ab = W_UP_ab * 100.0 / mx;
W_FD_ab = W_FD_ab * 100.0 / mx;
If ((W_MD_32_45 < W_MD_21_34) && (W_MD_32_45 < W_MD_43_56))
{
// then, is possible 1st of pair of blends
if (W_MD_32_45 < W_FD_34)
{
// then IS 1st blend index
}
}
else If ((W_MD_21_34 < W_MD_10_23) && (W_MD_21_34 < W_MD_32_45))
{
// then is possible 2nd of pair of blends
if (W_MD_21_34 < W_FD_23)
{
// then IS 2nd blend index
}
}
else
{
// Is NOT a blend
}
Also this in there too (identities.txt).
EDIT: After staring at below gobble-de-gook for a while, added the stuff in blue [will be modded as below in next release].
Code:
Below written to assist understanding of how the screwed up clip was created, and is from point of view of the pre-blended clip.
The 'IN' (ie W,X,Y,Z) are frames before the bad blends were created, and 'OUT' is the resultant bad blending sequence that need be fixed,
C and D are the blended pair, and Y is the missing frame that is partially present in both C and D blended pair.
[Missing Y frame is the one that needs recovering].
IN W X Y Z # Pre blended frames.
| | \ /\ /|
OUT A B C D E # Bad frames that we have to deal with.
A = W
B = X
C = (X + Y) / 2 : X = 2C - Y : B = 2C - Y : Y = 2C - X : Y = 2C - B
D = (Y + Z) / 2 : Y = 2D - Z : Y = 2D - E : Z = 2D - Y : E = 2D - Y
E = Z
FD_CD = | ((X + Y) / 2) - ((Y + Z) / 2) | == | ((X + Y - Y - Z) / 2) | == | (X - Z) / 2 |
== | (B - E) / 2 |
== | B - E | / 2
FD_BC = | X - ((X + Y) / 2) | == | (2X - (X + Y)) /2 | == |(2X - X - Y)/2| == | (X - Y) / 2 |
== | (B - Y) / 2 |
== | B - Y | / 2
FD_DE = | ((Y + Z) / 2) - Z | == | (Y + Z - 2Z) / 2 | == | (Y - Z) / 2 |
== | (Y - E) / 2 |
== | Y - E | / 2
# Above FD_nm is expected Frame Difference between frames n and m.