diff options
author | Clément Bœsch <u@pkh.me> | 2014-11-14 02:00:44 +0300 |
---|---|---|
committer | Clément Bœsch <u@pkh.me> | 2014-11-15 23:01:39 +0300 |
commit | 7e91f77547b887cc6e834d058c237a73b8bbadcf (patch) | |
tree | 0fb76bc4ccd307397a5b91a285e49a9dd298cf91 /libavfilter | |
parent | 18e4bf4f54ca0c4ca9c007bc99e5844dbd195369 (diff) |
avfilter/xbr: refactor src/dst pointers definitions into a macro
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/vf_xbr.c | 105 |
1 files changed, 25 insertions, 80 deletions
diff --git a/libavfilter/vf_xbr.c b/libavfilter/vf_xbr.c index 0a53e2f43c..d795acc6a6 100644 --- a/libavfilter/vf_xbr.c +++ b/libavfilter/vf_xbr.c @@ -96,6 +96,28 @@ 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_SRC_DST_POINTERS(level) \ + uint32_t *E = (uint32_t *)(output->data[0] + y * output->linesize[0] * (level)); \ + const uint32_t *sa2 = (uint32_t *)(input->data[0] + y * input->linesize[0] - 8); /* center */ \ + const uint32_t *sa1 = sa2 - (input->linesize[0]>>2); /* up x1 */ \ + const uint32_t *sa0 = sa1 - (input->linesize[0]>>2); /* up x2 */ \ + const uint32_t *sa3 = sa2 + (input->linesize[0]>>2); /* down x1 */ \ + const uint32_t *sa4 = sa3 + (input->linesize[0]>>2); /* down x2 */ \ + \ + if (y <= 1) { \ + sa0 = sa1; \ + if (y == 0) { \ + sa0 = sa1 = sa2; \ + } \ + } \ + \ + if (y >= input->height - 2) { \ + sa4 = sa3; \ + if (y == input->height - 1) { \ + sa4 = sa3 = sa2; \ + } \ + } + #define INIT_21_PIXELS \ const uint32_t B1 = sa0[2]; \ const uint32_t PB = sa1[2]; \ @@ -167,32 +189,7 @@ static void xbr2x(AVFrame * input, AVFrame * output, const uint32_t * r2y) int next_line = output->linesize[0]>>2; for (y = 0; y < input->height; y++) { - uint32_t * E = (uint32_t *)(output->data[0] + y * output->linesize[0] * 2); - - /* middle. Offset of -8 is given */ - const uint32_t *sa2 = (uint32_t *)(input->data[0] + y * input->linesize[0] - 8); - /* up one */ - const uint32_t *sa1 = sa2 - (input->linesize[0]>>2); - /* up two */ - const uint32_t *sa0 = sa1 - (input->linesize[0]>>2); - /* down one */ - const uint32_t *sa3 = sa2 + (input->linesize[0]>>2); - /* down two */ - const uint32_t *sa4 = sa3 + (input->linesize[0]>>2); - - if (y <= 1) { - sa0 = sa1; - if (y == 0) { - sa0 = sa1 = sa2; - } - } - - if (y >= input->height - 2) { - sa4 = sa3; - if (y == input->height - 1) { - sa4 = sa3 = sa2; - } - } + INIT_SRC_DST_POINTERS(2) for (x = 0; x < input->width; x++) { INIT_21_PIXELS @@ -264,33 +261,7 @@ static void xbr3x(AVFrame *input, AVFrame *output, const uint32_t *r2y) int x,y; for (y = 0; y < input->height; y++) { - - uint32_t * E = (uint32_t *)(output->data[0] + y * output->linesize[0] * 3); - - /* middle. Offset of -8 is given */ - const uint32_t *sa2 = (uint32_t *)(input->data[0] + y * input->linesize[0] - 8); - /* up one */ - const uint32_t *sa1 = sa2 - (input->linesize[0]>>2); - /* up two */ - const uint32_t *sa0 = sa1 - (input->linesize[0]>>2); - /* down one */ - const uint32_t *sa3 = sa2 + (input->linesize[0]>>2); - /* down two */ - const uint32_t *sa4 = sa3 + (input->linesize[0]>>2); - - if (y <= 1){ - sa0 = sa1; - if (y == 0){ - sa0 = sa1 = sa2; - } - } - - if (y >= input->height - 2){ - sa4 = sa3; - if (y == input->height - 1){ - sa4 = sa3 = sa2; - } - } + INIT_SRC_DST_POINTERS(3) for (x = 0; x < input->width; x++){ INIT_21_PIXELS @@ -370,33 +341,7 @@ static void xbr4x(AVFrame *input, AVFrame *output, const uint32_t *r2y) int x, y; for (y = 0; y < input->height; y++) { - - uint32_t * E = (uint32_t *)(output->data[0] + y * output->linesize[0] * 4); - - /* middle. Offset of -8 is given */ - const uint32_t *sa2 = (uint32_t *)(input->data[0] + y * input->linesize[0] - 8); - /* up one */ - const uint32_t *sa1 = sa2 - (input->linesize[0]>>2); - /* up two */ - const uint32_t *sa0 = sa1 - (input->linesize[0]>>2); - /* down one */ - const uint32_t *sa3 = sa2 + (input->linesize[0]>>2); - /* down two */ - const uint32_t *sa4 = sa3 + (input->linesize[0]>>2); - - if (y <= 1) { - sa0 = sa1; - if (y == 0) { - sa0 = sa1 = sa2; - } - } - - if (y >= input->height - 2) { - sa4 = sa3; - if (y == input->height - 1) { - sa4 = sa3 = sa2; - } - } + INIT_SRC_DST_POINTERS(4) for (x = 0; x < input->width; x++) { INIT_21_PIXELS |