summaryrefslogtreecommitdiff
path: root/libavfilter/vf_xbr.c
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2014-11-13 23:52:35 +0100
committerClément Bœsch <u@pkh.me>2014-11-15 21:01:39 +0100
commit18e4bf4f54ca0c4ca9c007bc99e5844dbd195369 (patch)
tree1ef0b2acd2cab6d351d63efecaa984002f70dcde /libavfilter/vf_xbr.c
parent6bf9786a9bd0446bde523077a5bf2991f72acb8c (diff)
avfilter/xbr: refactor the 21 pixels definition into a macro
Diffstat (limited to 'libavfilter/vf_xbr.c')
-rw-r--r--libavfilter/vf_xbr.c121
1 files changed, 34 insertions, 87 deletions
diff --git a/libavfilter/vf_xbr.c b/libavfilter/vf_xbr.c
index f6d782bf80..0a53e2f43c 100644
--- a/libavfilter/vf_xbr.c
+++ b/libavfilter/vf_xbr.c
@@ -96,6 +96,37 @@ static uint32_t pixel_diff(uint32_t x, uint32_t y, const uint32_t *r2y)
#define eq(A, B)\
(df(A, B) < 155)\
+#define INIT_21_PIXELS \
+ const uint32_t B1 = sa0[2]; \
+ const uint32_t PB = sa1[2]; \
+ const uint32_t PE = sa2[2]; \
+ const uint32_t PH = sa3[2]; \
+ const uint32_t H5 = sa4[2]; \
+ \
+ const int pprev = 2 - (x > 0); \
+ const uint32_t A1 = sa0[pprev]; \
+ const uint32_t PA = sa1[pprev]; \
+ const uint32_t PD = sa2[pprev]; \
+ const uint32_t PG = sa3[pprev]; \
+ const uint32_t G5 = sa4[pprev]; \
+ \
+ const int pprev2 = pprev - (x > 1); \
+ const uint32_t A0 = sa1[pprev2]; \
+ const uint32_t D0 = sa2[pprev2]; \
+ const uint32_t G0 = sa3[pprev2]; \
+ \
+ const int pnext = 3 - (x == input->width - 1); \
+ const uint32_t C1 = sa0[pnext]; \
+ const uint32_t PC = sa1[pnext]; \
+ const uint32_t PF = sa2[pnext]; \
+ const uint32_t PI = sa3[pnext]; \
+ const uint32_t I5 = sa4[pnext]; \
+ \
+ const int pnext2 = pnext + 1 - (x >= input->width - 2); \
+ const uint32_t C4 = sa1[pnext2]; \
+ const uint32_t F4 = sa2[pnext2]; \
+ const uint32_t I4 = sa3[pnext2];
+
#define FILT2(PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, N0, N1, N2, N3) do { \
unsigned ex = (PE!=PH && PE!=PF); \
if ( ex )\
@@ -164,35 +195,7 @@ static void xbr2x(AVFrame * input, AVFrame * output, const uint32_t * r2y)
}
for (x = 0; x < input->width; x++) {
- uint32_t B1 = sa0[2];
- uint32_t PB = sa1[2];
- uint32_t PE = sa2[2];
- uint32_t PH = sa3[2];
- uint32_t H5 = sa4[2];
-
- const int pprev = 2 - (x > 0);
- uint32_t A1 = sa0[pprev];
- uint32_t PA = sa1[pprev];
- uint32_t PD = sa2[pprev];
- uint32_t PG = sa3[pprev];
- uint32_t G5 = sa4[pprev];
-
- const int pprev2 = pprev - (x > 1);
- uint32_t A0 = sa1[pprev2];
- uint32_t D0 = sa2[pprev2];
- uint32_t G0 = sa3[pprev2];
-
- const int pnext = 3 - (x == input->width - 1);
- uint32_t C1 = sa0[pnext];
- uint32_t PC = sa1[pnext];
- uint32_t PF = sa2[pnext];
- uint32_t PI = sa3[pnext];
- uint32_t I5 = sa4[pnext];
-
- const int pnext2 = pnext + 1 - (x >= input->width - 2);
- uint32_t C4 = sa1[pnext2];
- uint32_t F4 = sa2[pnext2];
- uint32_t I4 = sa3[pnext2];
+ INIT_21_PIXELS
E[0] = E[1] = E[next_line] = E[next_line + 1] = PE; // 0, 1, 2, 3
@@ -290,35 +293,7 @@ static void xbr3x(AVFrame *input, AVFrame *output, const uint32_t *r2y)
}
for (x = 0; x < input->width; x++){
- uint32_t B1 = sa0[2];
- uint32_t PB = sa1[2];
- uint32_t PE = sa2[2];
- uint32_t PH = sa3[2];
- uint32_t H5 = sa4[2];
-
- const int pprev = 2 - (x > 0);
- uint32_t A1 = sa0[pprev];
- uint32_t PA = sa1[pprev];
- uint32_t PD = sa2[pprev];
- uint32_t PG = sa3[pprev];
- uint32_t G5 = sa4[pprev];
-
- const int pprev2 = pprev - (x > 1);
- uint32_t A0 = sa1[pprev2];
- uint32_t D0 = sa2[pprev2];
- uint32_t G0 = sa3[pprev2];
-
- const int pnext = 3 - (x == input->width - 1);
- uint32_t C1 = sa0[pnext];
- uint32_t PC = sa1[pnext];
- uint32_t PF = sa2[pnext];
- uint32_t PI = sa3[pnext];
- uint32_t I5 = sa4[pnext];
-
- const int pnext2 = pnext + 1 - (x >= input->width - 2);
- uint32_t C4 = sa1[pnext2];
- uint32_t F4 = sa2[pnext2];
- uint32_t I4 = sa3[pnext2];
+ INIT_21_PIXELS
E[0] = E[1] = E[2] = PE;
E[nl] = E[nl+1] = E[nl+2] = PE; // 3, 4, 5
@@ -424,35 +399,7 @@ static void xbr4x(AVFrame *input, AVFrame *output, const uint32_t *r2y)
}
for (x = 0; x < input->width; x++) {
- uint32_t B1 = sa0[2];
- uint32_t PB = sa1[2];
- uint32_t PE = sa2[2];
- uint32_t PH = sa3[2];
- uint32_t H5 = sa4[2];
-
- const int pprev = 2 - (x > 0);
- uint32_t A1 = sa0[pprev];
- uint32_t PA = sa1[pprev];
- uint32_t PD = sa2[pprev];
- uint32_t PG = sa3[pprev];
- uint32_t G5 = sa4[pprev];
-
- const int pprev2 = pprev - (x > 1);
- uint32_t A0 = sa1[pprev2];
- uint32_t D0 = sa2[pprev2];
- uint32_t G0 = sa3[pprev2];
-
- const int pnext = 3 - (x == input->width - 1);
- uint32_t C1 = sa0[pnext];
- uint32_t PC = sa1[pnext];
- uint32_t PF = sa2[pnext];
- uint32_t PI = sa3[pnext];
- uint32_t I5 = sa4[pnext];
-
- const int pnext2 = pnext + 1 - (x >= input->width - 2);
- uint32_t C4 = sa1[pnext2];
- uint32_t F4 = sa2[pnext2];
- uint32_t I4 = sa3[pnext2];
+ INIT_21_PIXELS
E[0] = E[1] = E[2] = E[3] = PE;
E[nl] = E[nl+1] = E[nl+2] = E[nl+3] = PE; // 4, 5, 6, 7