From patchwork Sun Oct 1 16:10:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 5358 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.61.8 with SMTP id n8csp619109jan; Sun, 1 Oct 2017 09:11:00 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAJWosewML08RdeAQvaYjkE/sVmEOEpRfKThN0zpqRh4TS0j5nEj7xZ9YmVW7J4WTEJ1YDU X-Received: by 10.223.134.23 with SMTP id 23mr12249240wrv.93.1506874260331; Sun, 01 Oct 2017 09:11:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506874260; cv=none; d=google.com; s=arc-20160816; b=fvx5mlUn2xQYCP3IDkbdnbDHNUQ1/U5IeCuu3onfNAftvBgpb+Zs8eSj4xYndIQWuh E5phw/lQrh2KPEn0dpKW5AZE/MxfgplYTb9UxGpuHVH8Izn5H9qqqQAHTI2hkccGF4T5 AnubjsoirySerCzycAG0BeeaVWxubrUjRrosvmnydK7jzbD4P0tujSXoAsezqCo5/fSv SZiIbabaYc3jsb1fc5OX6o8jZ8J7zpxDnzW9volAxjbpRzHho6z77G4zhBWVZej/bybR DtWe5FuyJjz5Gi/O3e+x3QIW7zRSs1HLnN3CZlWcv021eio/X5xeby4/yI0wZOP8lA/w jbNw== 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:message-id:date:to:from:delivered-to :arc-authentication-results; bh=fpJ26xkCtgtWwHrZHZJ7JAMCEEsMExonVyKmKmNUMHs=; b=JQzMHC8QN68dQoq0yX/in9Q/g9s0EftnqpjrSEa9SlHw2kCKcM6n6XP6ufdwHjxy3o /WkeHGSTfpg67DtubvfZnefZjJVqCSprPhlwpMnees+hUoqbK1PRTQjY1dqUHeexVBhe isc8ayshmnv5qtsxvIHCl4f83kKPuRuXY6vXMFQbPJ8PXmuqsZVjnn26Hy4Od7b/TSdj Z10Exd+Mj2htS6GWdjIAjDQeousKsGYjVT1geZ6/4yiz9sEyyV2jyGiUbmUkMuGB8x8E acdIc/9MBxkLVUq7rDmQ2BxDKUb7MRrMKrdkfwJHwEUw09KiklQypA0a5fOAztTIdP+9 Nkdg== 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 k23si6967372wre.256.2017.10.01.09.10.59; Sun, 01 Oct 2017 09:11:00 -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 B3057689A46; Sun, 1 Oct 2017 19:10:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe01-2.mx.upcmail.net (vie01a-qmta-pe01-2.mx.upcmail.net [62.179.121.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EFFEF689A46 for ; Sun, 1 Oct 2017 19:10:32 +0300 (EEST) Received: from [172.31.218.37] (helo=vie01a-dmta-pe03-1.mx.upcmail.net) by vie01a-pqmta-pe01.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1dygpK-0003Ll-TN for ffmpeg-devel@ffmpeg.org; Sun, 01 Oct 2017 18:10:46 +0200 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe03.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1dygpD-00033I-Hv for ffmpeg-devel@ffmpeg.org; Sun, 01 Oct 2017 18:10:39 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id GGAd1w00S0S5wYM01GAefE; Sun, 01 Oct 2017 18:10:38 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 1 Oct 2017 18:10:35 +0200 Message-Id: <20171001161036.6133-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.14.2 Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/dvbsubdec: Factor a few expressions out of compute_default_clut() 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" 32% faster loop Signed-off-by: Michael Niedermayer --- libavcodec/dvbsubdec.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index b683109643..6a40f2376f 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -653,8 +653,9 @@ static void compute_default_clut(AVSubtitleRect *rect, int w, int h) uint8_t list_inv[256]; int counttab[256] = {0}; int count, i, x, y; + ptrdiff_t ls = rect->linesize[0]; -#define V(x,y) rect->data[0][(x) + (y)*rect->linesize[0]] +#define V(x,y) rect->data[0][(x) + (y)*ls] for (y = 0; ydata[0][(x) + (y)*rect->linesize[0]] ] +#define L(x,y) list[ d[(x) + (y)*ls] ] for (i = 0; i<256; i++) { int scoretab[256] = {0}; @@ -673,12 +674,13 @@ static void compute_default_clut(AVSubtitleRect *rect, int w, int h) int bestv = 0; for (y = 0; ydata[0][x + y*rect->linesize[0]]; + uint8_t *d = &rect->data[0][x + y*ls]; + int v = *d; int l_m = list[v]; - int l_l = x ? L(x-1, y) : 1; - int l_r = x+1