summaryrefslogtreecommitdiff
path: root/libavfilter/vf_yadif.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2017-11-11 10:09:41 -0300
committerJames Almer <jamrial@gmail.com>2017-11-11 10:09:41 -0300
commit672e704e4a409f5174f253f7a463653dd7e9cb7c (patch)
tree3dc65f89f5e41e85de8d8dfca334ccd05ee8d55e /libavfilter/vf_yadif.c
parent28bb96c408e3d5d1da7f2788dfbdbfd25a3cff76 (diff)
parentfeed239021bad89743d5e7989b426ae594322eb7 (diff)
downloadffmpeg-672e704e4a409f5174f253f7a463653dd7e9cb7c.tar.gz
Merge commit 'feed239021bad89743d5e7989b426ae594322eb7'
* commit 'feed239021bad89743d5e7989b426ae594322eb7': yadif: Account for the buffer alignment while processing the frame edges See 221f902f1dc167bdc0bfdff6b6af3214ae3cc1f4 Merged-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavfilter/vf_yadif.c')
-rw-r--r--libavfilter/vf_yadif.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c
index 694ac44999..f58d8ac2bc 100644
--- a/libavfilter/vf_yadif.c
+++ b/libavfilter/vf_yadif.c
@@ -123,18 +123,20 @@ static void filter_edges(void *dst1, void *prev1, void *cur1, void *next1,
uint8_t *prev2 = parity ? prev : cur ;
uint8_t *next2 = parity ? cur : next;
+ const int edge = MAX_ALIGN - 1;
+
/* Only edge pixels need to be processed here. A constant value of false
* for is_not_edge should let the compiler ignore the whole branch. */
FILTER(0, 3, 0)
- dst = (uint8_t*)dst1 + w - (MAX_ALIGN-1);
- prev = (uint8_t*)prev1 + w - (MAX_ALIGN-1);
- cur = (uint8_t*)cur1 + w - (MAX_ALIGN-1);
- next = (uint8_t*)next1 + w - (MAX_ALIGN-1);
+ dst = (uint8_t*)dst1 + w - edge;
+ prev = (uint8_t*)prev1 + w - edge;
+ cur = (uint8_t*)cur1 + w - edge;
+ next = (uint8_t*)next1 + w - edge;
prev2 = (uint8_t*)(parity ? prev : cur);
next2 = (uint8_t*)(parity ? cur : next);
- FILTER(w - (MAX_ALIGN-1), w - 3, 1)
+ FILTER(w - edge, w - 3, 1)
FILTER(w - 3, w, 0)
}
@@ -167,19 +169,22 @@ static void filter_edges_16bit(void *dst1, void *prev1, void *cur1, void *next1,
int x;
uint16_t *prev2 = parity ? prev : cur ;
uint16_t *next2 = parity ? cur : next;
+
+ const int edge = MAX_ALIGN / 2 - 1;
+
mrefs /= 2;
prefs /= 2;
FILTER(0, 3, 0)
- dst = (uint16_t*)dst1 + w - (MAX_ALIGN/2-1);
- prev = (uint16_t*)prev1 + w - (MAX_ALIGN/2-1);
- cur = (uint16_t*)cur1 + w - (MAX_ALIGN/2-1);
- next = (uint16_t*)next1 + w - (MAX_ALIGN/2-1);
+ dst = (uint16_t*)dst1 + w - edge;
+ prev = (uint16_t*)prev1 + w - edge;
+ cur = (uint16_t*)cur1 + w - edge;
+ next = (uint16_t*)next1 + w - edge;
prev2 = (uint16_t*)(parity ? prev : cur);
next2 = (uint16_t*)(parity ? cur : next);
- FILTER(w - (MAX_ALIGN/2-1), w - 3, 1)
+ FILTER(w - edge, w - 3, 1)
FILTER(w - 3, w, 0)
}
@@ -193,6 +198,7 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
int slice_start = (td->h * jobnr ) / nb_jobs;
int slice_end = (td->h * (jobnr+1)) / nb_jobs;
int y;
+ int edge = 3 + MAX_ALIGN / df - 1;
/* filtering reads 3 pixels to the left/right; to avoid invalid reads,
* we need to call the c variant which avoids this for border pixels
@@ -205,7 +211,7 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
uint8_t *dst = &td->frame->data[td->plane][y * td->frame->linesize[td->plane]];
int mode = y == 1 || y + 2 == td->h ? 2 : s->mode;
s->filter_line(dst + pix_3, prev + pix_3, cur + pix_3,
- next + pix_3, td->w - (3 + MAX_ALIGN/df-1),
+ next + pix_3, td->w - edge,
y + 1 < td->h ? refs : -refs,
y ? -refs : refs,
td->parity ^ td->tff, mode);