Skip to content

Instantly share code, notes, and snippets.

@philipl
Created July 8, 2020 23:42
Show Gist options
  • Save philipl/64fb6214645fa915bed4f3425b5ded3e to your computer and use it in GitHub Desktop.
Save philipl/64fb6214645fa915bed4f3425b5ded3e to your computer and use it in GitHub Desktop.
Spatial references:
prefs3
prefs
x
mrefs
mrefs3
Temporal references:
prev2 prev cur next next2
prefs4 prefs4
prefs2 prefs2
prefs prefs
0 x 0
mrefs mrefs
mrefs2 mrefs2
mrefs4 mrefs4
Spatial references:
A
B
x
C
D
Temporal references:
a j
b k
f h
c x l
g i
d m
e n
#define FILTER_INTRA() \
for (x = 0; x < w; x++) { \
interpol = (coef_sp[0] * (cur[mrefs] + cur[prefs]) - coef_sp[1] * (cur[mrefs3] + cur[prefs3])) >> 13; \
dst[0] = av_clip(interpol, 0, clip_max); \
\
dst++; \
cur++; \
}
define FILTER1() \
for (x = 0; x < w; x++) { \
int c = cur[mrefs]; \
int d = (prev2[0] + next2[0]) >> 1; \
int e = cur[prefs]; \
int temporal_diff0 = FFABS(prev2[0] - next2[0]); \
int temporal_diff1 =(FFABS(prev[mrefs] - c) + FFABS(prev[prefs] - e)) >> 1; \
int temporal_diff2 =(FFABS(next[mrefs] - c) + FFABS(next[prefs] - e)) >> 1; \
int diff = FFMAX3(temporal_diff0 >> 1, temporal_diff1, temporal_diff2); \
\
if (!diff) { \
dst[0] = d; \
} else {
#define SPAT_CHECK() \
int b = ((prev2[mrefs2] + next2[mrefs2]) >> 1) - c; \
int f = ((prev2[prefs2] + next2[prefs2]) >> 1) - e; \
int dc = d - c; \
int de = d - e; \
int max = FFMAX3(de, dc, FFMIN(b, f)); \
int min = FFMIN3(de, dc, FFMAX(b, f)); \
diff = FFMAX3(diff, min, -max);
#define FILTER_LINE() \
SPAT_CHECK() \
if (FFABS(c - e) > temporal_diff0) { \
interpol = (((coef_hf[0] * (prev2[0] + next2[0]) \
- coef_hf[1] * (prev2[mrefs2] + next2[mrefs2] + prev2[prefs2] + next2[prefs2]) \
+ coef_hf[2] * (prev2[mrefs4] + next2[mrefs4] + prev2[prefs4] + next2[prefs4])) >> 2) \
+ coef_lf[0] * (c + e) - coef_lf[1] * (cur[mrefs3] + cur[prefs3])) >> 13; \
} else { \
interpol = (coef_sp[0] * (c + e) - coef_sp[1] * (cur[mrefs3] + cur[prefs3])) >> 13; \
}
#define FILTER_EDGE() \
if (spat) { \
SPAT_CHECK() \
} \
interpol = (c + e) >> 1;
#define FILTER2() \
if (interpol > d + diff) \
interpol = d + diff; \
else if (interpol < d - diff) \
interpol = d - diff; \
\
dst[0] = av_clip(interpol, 0, clip_max); \
} \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment