From patchwork Fri Apr 12 23:36:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 12715 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 47EF244797A for ; Sat, 13 Apr 2019 02:39:27 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2178B68ACCA; Sat, 13 Apr 2019 02:39:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe05-1.mx.upcmail.net (vie01a-dmta-pe05-1.mx.upcmail.net [84.116.36.11]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1072D68AA15 for ; Sat, 13 Apr 2019 02:39:21 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe05.mx.upcmail.net with esmtp (Exim 4.91) (envelope-from ) id 1hF5lQ-0005a0-4Y for ffmpeg-devel@ffmpeg.org; Sat, 13 Apr 2019 01:39:20 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id F5kShMNSx5D5NF5kShzkpF; Sat, 13 Apr 2019 01:38:20 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.41.20 X-CNFS-Analysis: v=2.3 cv=bu8y+3Si c=1 sm=1 tr=0 a=I1eytVlZLDX1BM2VTtTtSw==:117 a=I1eytVlZLDX1BM2VTtTtSw==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=kZNFXGpazC1T5-UWhdEA:9 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 13 Apr 2019 01:36:46 +0200 Message-Id: <20190412233647.7668-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190412233647.7668-1-michael@niedermayer.cc> References: <20190412233647.7668-1-michael@niedermayer.cc> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfG35E2dQJiV80mMaQjEE7XqwnjecNDuz4tAE+KlTmUrgIFY2LsjFcDkxNuozPark3qW7ZSnidUxqWggtfKir9h0Dp5t8EiNer82qVmyfUu2aJdzqFJuW 5tkjGqbAOY8MuGdOc2B1XKoIz+ima2k5vcQl4yzvouZRIkKLpqQazWha Subject: [FFmpeg-devel] [PATCH 2/3] vcodec/pictordec: avoid pointers in picmemset() 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" Improves overall speed by about 3% Testcase: 14124/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PICTOR_fuzzer-5633887734071296 Signed-off-by: Michael Niedermayer --- libavcodec/pictordec.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/libavcodec/pictordec.c b/libavcodec/pictordec.c index 65d2d49060..af99c486b8 100644 --- a/libavcodec/pictordec.c +++ b/libavcodec/pictordec.c @@ -63,22 +63,25 @@ static void picmemset(PicContext *s, AVFrame *frame, unsigned value, int run, uint8_t *d; int shift = *plane * bits_per_plane; unsigned mask = ((1U << bits_per_plane) - 1) << shift; + int xl = *x; + int yl = *y; + int planel = *plane; value <<= shift; while (run > 0) { int j; for (j = 8-bits_per_plane; j >= 0; j -= bits_per_plane) { - d = frame->data[0] + *y * frame->linesize[0]; - d[*x] |= (value >> j) & mask; - *x += 1; - if (*x == s->width) { - *y -= 1; - *x = 0; - if (*y < 0) { - *y = s->height - 1; - *plane += 1; - if (*plane >= s->nb_planes) - return; + d = frame->data[0] + yl * frame->linesize[0]; + d[xl] |= (value >> j) & mask; + xl += 1; + if (xl == s->width) { + yl -= 1; + xl = 0; + if (yl < 0) { + yl = s->height - 1; + planel += 1; + if (planel >= s->nb_planes) + goto end; value <<= bits_per_plane; mask <<= bits_per_plane; } @@ -86,6 +89,10 @@ static void picmemset(PicContext *s, AVFrame *frame, unsigned value, int run, } run--; } +end: + *x = xl; + *y = yl; + *plane = planel; } static const uint8_t cga_mode45_index[6][4] = {