From patchwork Fri Sep 8 21:29:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 5059 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.36.26 with SMTP id f26csp671872jaa; Fri, 8 Sep 2017 14:29:56 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCpTDqhHdVgJE4VftkHHrD9BERjrAreQiRi/drQm5Z37U7KIMsVeSrJNzYyKHEhGl8ZolAO X-Received: by 10.28.45.1 with SMTP id t1mr2459212wmt.17.1504906196692; Fri, 08 Sep 2017 14:29:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504906196; cv=none; d=google.com; s=arc-20160816; b=AE0LTfeFfi2pb5YGebnuStK6zBq2YlqgxC7jCxna8kUAXp4IY7SFcTyWu6ZicXxyJw NC+Ofljvgbir6+hRrmLgXDDwxRk+nqQ3PBCMfPSwRUzCgtVPFZSj8Kj+VWkrI9+S6X1i 7uZaT7EuEkX8WDfvSZ7N+aELYNoZpXyg5+qIUIi+0U/tld3+vWs6X5mkgGqcEUHg3/Xl cHiNCFqRbgRFxzFBLQjgEEuJy1qnd0FkfAWWPThzTQLQBRQ+AnefHRVEYOkFf3Wkp5Bz efDYYX+4wjkIr6MXDiME9IN6oAK+TE/puTN6+SezWqK1XIjJ5nZlL/SllzTAqplASMDs X+Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=6EWdsvbzqNTfCR+RriX+v4yucub9hxuG2XLZLerSHqE=; b=gMoJWXI7BWOS6eezhiQ0f+LStX7tICD0YVz8ut6eUBff6M6b+UdJSoElmjMVbETETz I4h7ARtUQyHE8OgZmf3rvSuvj62y7pJ9t0gmjDeNm970BBKeBC6ofHOEEiq90SELB9da NdgabOgzsLw3UrQFKY2TcFKh79ElAVrk1FVzzGvCRhqZx3sXX7nn0v/zIJDzI+tTgUBu o7HTw6yXD9c1WGKE9B2MPrKzDhA6J1tBorHidwGauLSf5YAL7AsYW/pgEt/ufvVHFVYb ac9VfezLfd/iyKpOvl5x1vjom4dhVH1ObD6f3KfFVy8dSorTdJQtJ4hzOQAq0k2JUyzu k2rA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a13si2165949wrg.175.2017.09.08.14.29.56; Fri, 08 Sep 2017 14:29:56 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 34BA4689D83; Sat, 9 Sep 2017 00:29:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe04-3.mx.upcmail.net (vie01a-dmta-pe04-3.mx.upcmail.net [62.179.121.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 97201689735 for ; Sat, 9 Sep 2017 00:29:26 +0300 (EEST) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe04.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1dqQqA-0000ar-SJ for ffmpeg-devel@ffmpeg.org; Fri, 08 Sep 2017 23:29:30 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id 79VG1w00g0S5wYM019VHl4; Fri, 08 Sep 2017 23:29:17 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 8 Sep 2017 23:29:13 +0200 Message-Id: <20170908212913.20478-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170908212913.20478-1-michael@niedermayer.cc> References: <20170908212913.20478-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/scpr: optimize shift loop. 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Speeds code up from 50sec to 15sec Fixes Timeout Fixes: 3242/clusterfuzz-testcase-5811951672229888 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/scpr.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libavcodec/scpr.c b/libavcodec/scpr.c index 37fbe7a106..2ef63a7bf8 100644 --- a/libavcodec/scpr.c +++ b/libavcodec/scpr.c @@ -827,7 +827,16 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, return ret; for (y = 0; y < avctx->height; y++) { - for (x = 0; x < avctx->width * 4; x++) { + if (!(((uintptr_t)dst) & 7)) { + uint64_t *dst64 = (uint64_t *)dst; + int w = avctx->width>>1; + for (x = 0; x < w; x++) { + dst64[x] = (dst64[x] << 3) & 0xFCFCFCFCFCFCFCFCULL; + } + x *= 8; + } else + x = 0; + for (; x < avctx->width * 4; x++) { dst[x] = dst[x] << 3; } dst += frame->linesize[0];