mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-27 17:21:05 +00:00
avfilter/vf_sab: fix filtering tiny images
Fixes out of array reads
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 9bff052b51
)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
5bb31e856d
commit
252ba4a925
@ -220,6 +220,19 @@ static int config_props(AVFilterLink *inlink)
|
|||||||
|
|
||||||
#define NB_PLANES 4
|
#define NB_PLANES 4
|
||||||
|
|
||||||
|
static inline int mirror(int x, int w)
|
||||||
|
{
|
||||||
|
if (!w)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
while ((unsigned)x > (unsigned)w) {
|
||||||
|
x = -x;
|
||||||
|
if (x < 0)
|
||||||
|
x += 2 * w;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
static void blur(uint8_t *dst, const int dst_linesize,
|
static void blur(uint8_t *dst, const int dst_linesize,
|
||||||
const uint8_t *src, const int src_linesize,
|
const uint8_t *src, const int src_linesize,
|
||||||
const int w, const int h, FilterParam *fp)
|
const int w, const int h, FilterParam *fp)
|
||||||
@ -253,8 +266,7 @@ static void blur(uint8_t *dst, const int dst_linesize,
|
|||||||
for (dy = 0; dy < radius*2 + 1; dy++) {
|
for (dy = 0; dy < radius*2 + 1; dy++) {
|
||||||
int dx;
|
int dx;
|
||||||
int iy = y+dy - radius;
|
int iy = y+dy - radius;
|
||||||
if (iy < 0) iy = -iy;
|
iy = mirror(iy, h-1);
|
||||||
else if (iy >= h) iy = h+h-iy-1;
|
|
||||||
|
|
||||||
for (dx = 0; dx < radius*2 + 1; dx++) {
|
for (dx = 0; dx < radius*2 + 1; dx++) {
|
||||||
const int ix = x+dx - radius;
|
const int ix = x+dx - radius;
|
||||||
@ -265,13 +277,11 @@ static void blur(uint8_t *dst, const int dst_linesize,
|
|||||||
for (dy = 0; dy < radius*2+1; dy++) {
|
for (dy = 0; dy < radius*2+1; dy++) {
|
||||||
int dx;
|
int dx;
|
||||||
int iy = y+dy - radius;
|
int iy = y+dy - radius;
|
||||||
if (iy < 0) iy = -iy;
|
iy = mirror(iy, h-1);
|
||||||
else if (iy >= h) iy = h+h-iy-1;
|
|
||||||
|
|
||||||
for (dx = 0; dx < radius*2 + 1; dx++) {
|
for (dx = 0; dx < radius*2 + 1; dx++) {
|
||||||
int ix = x+dx - radius;
|
int ix = x+dx - radius;
|
||||||
if (ix < 0) ix = -ix;
|
ix = mirror(ix, w-1);
|
||||||
else if (ix >= w) ix = w+w-ix-1;
|
|
||||||
UPDATE_FACTOR;
|
UPDATE_FACTOR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user