From patchwork Fri Feb 24 10:21:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 2670 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.65.149 with SMTP id x21csp625006vsf; Fri, 24 Feb 2017 02:22:17 -0800 (PST) X-Received: by 10.28.23.66 with SMTP id 63mr2060984wmx.46.1487931737078; Fri, 24 Feb 2017 02:22:17 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k197si1837080wmg.97.2017.02.24.02.22.16; Fri, 24 Feb 2017 02:22:17 -0800 (PST) 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 E6C4D687ED5; Fri, 24 Feb 2017 12:22:04 +0200 (EET) 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 925EF681866 for ; Fri, 24 Feb 2017 12:21:58 +0200 (EET) Received: from [172.31.218.40] (helo=vie01a-dmta-pe04-1.mx.upcmail.net) by vie01a-pqmta-pe01.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1chD0o-0001H3-Qx for ffmpeg-devel@ffmpeg.org; Fri, 24 Feb 2017 11:22:06 +0100 Received: from [172.31.216.44] (helo=vie01a-pemc-psmtp-pe02) by vie01a-dmta-pe04.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1chD0i-0007pw-La for ffmpeg-devel@ffmpeg.org; Fri, 24 Feb 2017 11:22:00 +0100 Received: from [192.168.1.3] ([80.110.118.15]) by vie01a-pemc-psmtp-pe02 with SMTP @ mailcloud.upcmail.net id oaMu1u01T0L112801aMv7R; Fri, 24 Feb 2017 11:21:55 +0100 X-SourceIP: 80.110.118.15 From: Carl Eugen Hoyos To: FFmpeg development discussions and patches Date: Fri, 24 Feb 2017 11:21:54 +0100 User-Agent: KMail/1.9.10 MIME-Version: 1.0 Message-Id: <201702241121.54387.cehoyos@ag.or.at> Subject: [FFmpeg-devel] [PATCH]lswr/rematrix: Remove an aggressive loop optimization / undefined behaviour 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" Hi! Attached patch fixes a gcc warning (tested 6.3.0). Please comment, Carl Eugen From 422e4b2fba6f3c9fbf930908474029cb8088bc46 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Fri, 24 Feb 2017 11:16:26 +0100 Subject: [PATCH] lswr/rematrix: Remove an aggressive loop optimization. Fixes undefined behaviour and a gcc warning: libswresample/rematrix.c:376:47: warning: iteration 64 invokes undefined behavior --- libswresample/rematrix.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c index 4721063..03b9b20 100644 --- a/libswresample/rematrix.c +++ b/libswresample/rematrix.c @@ -371,9 +371,10 @@ av_cold static int auto_matrix(SwrContext *s) s->matrix[1] - s->matrix[0], s->matrix_encoding, s); if (ret >= 0 && s->int_sample_fmt == AV_SAMPLE_FMT_FLTP) { - int i; - for (i = 0; i < FF_ARRAY_ELEMS(s->matrix[0])*FF_ARRAY_ELEMS(s->matrix[0]); i++) - s->matrix_flt[0][i] = s->matrix[0][i]; + int i, j; + for (i = 0; i < FF_ARRAY_ELEMS(s->matrix[0]); i++) + for (j = 0; j < FF_ARRAY_ELEMS(s->matrix[0]); j++) + s->matrix_flt[i][j] = s->matrix[i][j]; } return ret;