From patchwork Fri Mar 16 18:55:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 8009 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.70 with SMTP id c67csp1106747jad; Fri, 16 Mar 2018 11:56:08 -0700 (PDT) X-Google-Smtp-Source: AG47ELtH2CzMTyD2ugXbKf9SYAXHBfpyQYSEb6kauGHNdkmJHoVAiWBKZZqxwim/psb2kGnUmzUz X-Received: by 10.223.134.136 with SMTP id 8mr2553163wrx.86.1521226568841; Fri, 16 Mar 2018 11:56:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521226568; cv=none; d=google.com; s=arc-20160816; b=HyrpqB9fhXTXyRZWG1VcP5PjElrFSHWY7lQg+bb5mwMKFYdN8HLDArwq5ig8ZkNQp3 MEhLAcRbkz++dWGrokM75xVwbELptfg1b+OcEJUE0qeOtHf7Y04aHScIHnE/BzfzrK6y VgeNTeoIODR9EGH9AtEjU7JqoDC5FSjhd7a8LkshQ9/v6UdX5T/KiCXst0z8DUUTY0G+ agQnrCWhzvwc5mFeUxVIV3cU4OJ+G0skBENe65aZUqHqqEZMdVxSGNPCVqaV2xOXvU8l pyuL2af/KasOmcyymxvkZvNGKOzhoBiJqQ8aSdzUVPw2zUJDuMo2hSqRg31LR96NMAfG zRPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:delivered-to:arc-authentication-results; bh=ocOzCE4ZLX8JaThhJnoafqiat/uzCGrfI2tyQJJP6o0=; b=Sq7/herlIl6fzdGKqYHonMvnW8/bpsbU1GwG8rxYTEHYsoSJb5CEk6YC6z0Sf9qpJB en/WCaZRzYqKHNqOZuEPTpJZIecNwNnn2lxK7lMvc2MAGAITYfNEUN9BLeFW1ngzBf3Q H9Vbgskbf87IQYYfyeQtljuVCK3Yzg4ElutDMJ4e8TeyC+ctSdkWXgam77N9VnoQrTKB 9XaTyWNC5STLyXsLecCwxuBURsA3oj02ZnA0IWzBUrGpC74mG0NNRfPI3KWkm0hYD90z wMJP3agA65YVbcqRMfsuvB4p0CeMKpDJi/GQWhXdnlTg4Nnj+xAXXfw9t1UXEJZPpD0p VwOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=rAA3+5z9; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q16si388469wra.260.2018.03.16.11.56.07; Fri, 16 Mar 2018 11:56:08 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=rAA3+5z9; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7C76768A042; Fri, 16 Mar 2018 20:55:53 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-it0-f53.google.com (mail-it0-f53.google.com [209.85.214.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CE9DB689AC2 for ; Fri, 16 Mar 2018 20:55:46 +0200 (EET) Received: by mail-it0-f53.google.com with SMTP id k79-v6so3311041ita.2 for ; Fri, 16 Mar 2018 11:55:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=Ifo24RMgfZ1t6gvB7N/3UumJaoba7l/z7403UOt+o5Q=; b=rAA3+5z9m9CxwYoKL5A+aaWNgeZdKGZmpRHn8XnkiKdq6hOor9zl4dW5sPc8214wFp oWuJX2L8WlUmYMCdG+Ui9xYIHx2EcxxYjpRBXgp60JK6pIGlBOjlFMVgrMvYUYopJuG0 Oas6MHZJUD4VuNq15GseX1ac8P9LvKlmfIb7LlLiQajLEUReYbZ6u+g55xkk6FQ9uaCj O7ZWWPsTU3c437NckY5BtC9lSsEYVtsiMJ/ByFEI/VnIIoXC0HJcxZEjKnyCQyqloR1d a2HPxvMjCEK9CG7RFizJpmPkLmHMTFLU+rcFbQDKa9VCzY76zOJWwU1z4owhLXAPfVx2 S7fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=Ifo24RMgfZ1t6gvB7N/3UumJaoba7l/z7403UOt+o5Q=; b=FOoTEi2xRaazLv/Y7/13ShUrm8yMZf/2vCruTHEszy1gULjvFyy/byw02KMg03v1ky VIJY09DwE/ZdFEO0UYqiylc9198xRMpp2h5mxJLqBTGeXyouz1E99Siii27b3cSU965t ppX/AVE2CfCLySDcrlyW0mmMuvbwoaMfOpvSHfOFmvixgAX/CfJ/6YxqfmGrcusSZcEU gjsp55r+xlU+pt7M8q6W1dZ8I0vrcCPMmyKhLhnJBtb5P2gKloEDQIXAd8DHHM2Y0yni RBAScuHxp/ZuW/3v/jo9Aoek/asXJvMSahIR/1mUcGyf1hhp+A5JXVvFbTdFWDaNfqEY OIMg== X-Gm-Message-State: AElRT7GL77PheCTMTSoSuZaq+p/Oj+zU5SlMRyBy3Kslc9P6I8ILPgTc Ez0OEzM0NJ/8kZSFA9dewgkjLyPtIEHAsSnfi74= X-Received: by 2002:a24:c482:: with SMTP id v124-v6mr3579392itf.39.1521226557451; Fri, 16 Mar 2018 11:55:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.2.3.78 with HTTP; Fri, 16 Mar 2018 11:55:56 -0700 (PDT) In-Reply-To: <20180314225055.GT23018@michaelspb> References: <20180314225055.GT23018@michaelspb> From: Carl Eugen Hoyos Date: Fri, 16 Mar 2018 19:55:56 +0100 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH]lavfi/deshake: Check alignment before calling asm init function X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 2018-03-14 23:50 GMT+01:00, Michael Niedermayer : > On Sat, Mar 10, 2018 at 08:50:08PM +0100, Carl Eugen Hoyos wrote: >> Hi! >> >> Attached patch fixes ticket #7078 for me. >> >> Please comment, Carl Eugen > >> vf_deshake.c | 8 ++++---- >> 1 file changed, 4 insertions(+), 4 deletions(-) >> 9f4517eae88416277aeb5bd5b677159914e9c451 >> 0001-lavfi-deshake-Check-alignment-before-calling-asm-ini.patch >> From 75ead282c3aa3c214d37e766690e2edd037307c0 Mon Sep 17 00:00:00 2001 >> From: Carl Eugen Hoyos >> Date: Sat, 10 Mar 2018 20:46:21 +0100 >> Subject: [PATCH] lavfi/deshake: Check alignment before calling asm init >> function. >> >> Do this for every frame to make sure dynamic filters do not >> cause crashes. >> >> Fixes ticket #7078. >> --- >> libavfilter/vf_deshake.c | 8 ++++---- >> 1 file changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c >> index fb4eb35..75e9990 100644 >> --- a/libavfilter/vf_deshake.c >> +++ b/libavfilter/vf_deshake.c >> @@ -342,10 +342,6 @@ static av_cold int init(AVFilterContext *ctx) >> { >> DeshakeContext *deshake = ctx->priv; >> >> - deshake->sad = av_pixelutils_get_sad_fn(4, 4, 1, deshake); // 16x16, >> 2nd source unaligned >> - if (!deshake->sad) >> - return AVERROR(EINVAL); >> - >> deshake->refcount = 20; // XXX: add to options? >> deshake->blocksize /= 2; >> deshake->blocksize = av_clip(deshake->blocksize, 4, 128); >> @@ -432,6 +428,10 @@ static int filter_frame(AVFilterLink *link, AVFrame >> *in) >> } >> av_frame_copy_props(out, in); >> >> + deshake->sad = av_pixelutils_get_sad_fn(4, 4, !((unsigned >> long)in->data[0] & 15), deshake); // 16x16, 2nd source unaligned >> + if (!deshake->sad) >> + return AVERROR(EINVAL); > > does this need to check linesize too ? I think so, new patch attached. Will push if there are no comments, Carl Eugen From 768a2cbcb0536f79fd7590186885c60de039afd5 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Fri, 16 Mar 2018 19:54:03 +0100 Subject: [PATCH] lavfi/deshake: Check alignment before calling asm init function. Do this for every frame to make sure dynamic filters do not cause crashes. Fixes ticket #7078. --- libavfilter/vf_deshake.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c index fb4eb35..aa92cef 100644 --- a/libavfilter/vf_deshake.c +++ b/libavfilter/vf_deshake.c @@ -342,10 +342,6 @@ static av_cold int init(AVFilterContext *ctx) { DeshakeContext *deshake = ctx->priv; - deshake->sad = av_pixelutils_get_sad_fn(4, 4, 1, deshake); // 16x16, 2nd source unaligned - if (!deshake->sad) - return AVERROR(EINVAL); - deshake->refcount = 20; // XXX: add to options? deshake->blocksize /= 2; deshake->blocksize = av_clip(deshake->blocksize, 4, 128); @@ -424,6 +420,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format); const int chroma_width = AV_CEIL_RSHIFT(link->w, desc->log2_chroma_w); const int chroma_height = AV_CEIL_RSHIFT(link->h, desc->log2_chroma_h); + int aligned; out = ff_get_video_buffer(outlink, outlink->w, outlink->h); if (!out) { @@ -432,6 +429,11 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) } av_frame_copy_props(out, in); + aligned = !((unsigned long)in->data[0] & 15 | in->linesize[0] & 15); + deshake->sad = av_pixelutils_get_sad_fn(4, 4, aligned, deshake); // 16x16, 2nd source unaligned + if (!deshake->sad) + return AVERROR(EINVAL); + if (deshake->cx < 0 || deshake->cy < 0 || deshake->cw < 0 || deshake->ch < 0) { // Find the most likely global motion for the current frame find_motion(deshake, (deshake->ref == NULL) ? in->data[0] : deshake->ref->data[0], in->data[0], link->w, link->h, in->linesize[0], &t); -- 1.7.10.4