* commit 'feed239021bad89743d5e7989b426ae594322eb7':
yadif: Account for the buffer alignment while processing the frame edges
See 221f902f1dc167bdc0bfdff6b6af3214ae3cc1f4
Merged-by: James Almer <jamrial@gmail.com>
... | ... |
@@ -123,18 +123,20 @@ static void filter_edges(void *dst1, void *prev1, void *cur1, void *next1, |
123 | 123 |
uint8_t *prev2 = parity ? prev : cur ; |
124 | 124 |
uint8_t *next2 = parity ? cur : next; |
125 | 125 |
|
126 |
+ const int edge = MAX_ALIGN - 1; |
|
127 |
+ |
|
126 | 128 |
/* Only edge pixels need to be processed here. A constant value of false |
127 | 129 |
* for is_not_edge should let the compiler ignore the whole branch. */ |
128 | 130 |
FILTER(0, 3, 0) |
129 | 131 |
|
130 |
- dst = (uint8_t*)dst1 + w - (MAX_ALIGN-1); |
|
131 |
- prev = (uint8_t*)prev1 + w - (MAX_ALIGN-1); |
|
132 |
- cur = (uint8_t*)cur1 + w - (MAX_ALIGN-1); |
|
133 |
- next = (uint8_t*)next1 + w - (MAX_ALIGN-1); |
|
132 |
+ dst = (uint8_t*)dst1 + w - edge; |
|
133 |
+ prev = (uint8_t*)prev1 + w - edge; |
|
134 |
+ cur = (uint8_t*)cur1 + w - edge; |
|
135 |
+ next = (uint8_t*)next1 + w - edge; |
|
134 | 136 |
prev2 = (uint8_t*)(parity ? prev : cur); |
135 | 137 |
next2 = (uint8_t*)(parity ? cur : next); |
136 | 138 |
|
137 |
- FILTER(w - (MAX_ALIGN-1), w - 3, 1) |
|
139 |
+ FILTER(w - edge, w - 3, 1) |
|
138 | 140 |
FILTER(w - 3, w, 0) |
139 | 141 |
} |
140 | 142 |
|
... | ... |
@@ -167,19 +169,22 @@ static void filter_edges_16bit(void *dst1, void *prev1, void *cur1, void *next1, |
167 | 167 |
int x; |
168 | 168 |
uint16_t *prev2 = parity ? prev : cur ; |
169 | 169 |
uint16_t *next2 = parity ? cur : next; |
170 |
+ |
|
171 |
+ const int edge = MAX_ALIGN / 2 - 1; |
|
172 |
+ |
|
170 | 173 |
mrefs /= 2; |
171 | 174 |
prefs /= 2; |
172 | 175 |
|
173 | 176 |
FILTER(0, 3, 0) |
174 | 177 |
|
175 |
- dst = (uint16_t*)dst1 + w - (MAX_ALIGN/2-1); |
|
176 |
- prev = (uint16_t*)prev1 + w - (MAX_ALIGN/2-1); |
|
177 |
- cur = (uint16_t*)cur1 + w - (MAX_ALIGN/2-1); |
|
178 |
- next = (uint16_t*)next1 + w - (MAX_ALIGN/2-1); |
|
178 |
+ dst = (uint16_t*)dst1 + w - edge; |
|
179 |
+ prev = (uint16_t*)prev1 + w - edge; |
|
180 |
+ cur = (uint16_t*)cur1 + w - edge; |
|
181 |
+ next = (uint16_t*)next1 + w - edge; |
|
179 | 182 |
prev2 = (uint16_t*)(parity ? prev : cur); |
180 | 183 |
next2 = (uint16_t*)(parity ? cur : next); |
181 | 184 |
|
182 |
- FILTER(w - (MAX_ALIGN/2-1), w - 3, 1) |
|
185 |
+ FILTER(w - edge, w - 3, 1) |
|
183 | 186 |
FILTER(w - 3, w, 0) |
184 | 187 |
} |
185 | 188 |
|
... | ... |
@@ -193,6 +198,7 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) |
193 | 193 |
int slice_start = (td->h * jobnr ) / nb_jobs; |
194 | 194 |
int slice_end = (td->h * (jobnr+1)) / nb_jobs; |
195 | 195 |
int y; |
196 |
+ int edge = 3 + MAX_ALIGN / df - 1; |
|
196 | 197 |
|
197 | 198 |
/* filtering reads 3 pixels to the left/right; to avoid invalid reads, |
198 | 199 |
* 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) |
205 | 205 |
uint8_t *dst = &td->frame->data[td->plane][y * td->frame->linesize[td->plane]]; |
206 | 206 |
int mode = y == 1 || y + 2 == td->h ? 2 : s->mode; |
207 | 207 |
s->filter_line(dst + pix_3, prev + pix_3, cur + pix_3, |
208 |
- next + pix_3, td->w - (3 + MAX_ALIGN/df-1), |
|
208 |
+ next + pix_3, td->w - edge, |
|
209 | 209 |
y + 1 < td->h ? refs : -refs, |
210 | 210 |
y ? -refs : refs, |
211 | 211 |
td->parity ^ td->tff, mode); |