diff options
author | Stefano Sabatini <stefasab@gmail.com> | 2013-02-15 14:18:02 +0100 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2013-02-17 11:47:39 +0100 |
commit | ef4c71e8f83a46fb31a11f0a066efb90821c579f (patch) | |
tree | 3e62ef3373e819ddfd7c5cb347b19028eba15c9e /libavfilter/vf_unsharp.c | |
parent | b8bb661dab8ed2eb1ca7e32bde1809741382c7bc (diff) | |
download | ffmpeg-ef4c71e8f83a46fb31a11f0a066efb90821c579f.tar.gz |
lavfi/unsharp: add check on matrix x/y size values oddity
Diffstat (limited to 'libavfilter/vf_unsharp.c')
-rw-r--r-- | libavfilter/vf_unsharp.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/libavfilter/vf_unsharp.c b/libavfilter/vf_unsharp.c index 2170d651e7..53de99f0df 100644 --- a/libavfilter/vf_unsharp.c +++ b/libavfilter/vf_unsharp.c @@ -195,11 +195,18 @@ static int query_formats(AVFilterContext *ctx) return 0; } -static void init_filter_param(AVFilterContext *ctx, FilterParam *fp, const char *effect_type, int width) +static int init_filter_param(AVFilterContext *ctx, FilterParam *fp, const char *effect_type, int width) { int z; const char *effect; + if (!(fp->msize_x & fp->msize_y & 1)) { + av_log(ctx, AV_LOG_ERROR, + "Invalid even size for %s matrix size %dx%d\n", + effect_type, fp->msize_x, fp->msize_y); + return AVERROR(EINVAL); + } + effect = fp->amount == 0 ? "none" : fp->amount < 0 ? "blur" : "sharpen"; av_log(ctx, AV_LOG_VERBOSE, "effect:%s type:%s msize_x:%d msize_y:%d amount:%0.2f\n", @@ -207,18 +214,25 @@ static void init_filter_param(AVFilterContext *ctx, FilterParam *fp, const char for (z = 0; z < 2 * fp->steps_y; z++) fp->sc[z] = av_malloc(sizeof(*(fp->sc[z])) * (width + 2 * fp->steps_x)); + + return 0; } static int config_props(AVFilterLink *link) { UnsharpContext *unsharp = link->dst->priv; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format); + int ret; unsharp->hsub = desc->log2_chroma_w; unsharp->vsub = desc->log2_chroma_h; - init_filter_param(link->dst, &unsharp->luma, "luma", link->w); - init_filter_param(link->dst, &unsharp->chroma, "chroma", SHIFTUP(link->w, unsharp->hsub)); + ret = init_filter_param(link->dst, &unsharp->luma, "luma", link->w); + if (ret < 0) + return ret; + ret = init_filter_param(link->dst, &unsharp->chroma, "chroma", SHIFTUP(link->w, unsharp->hsub)); + if (ret < 0) + return ret; return 0; } |