From patchwork Wed Nov 9 19:52:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Cadhalpun X-Patchwork-Id: 1363 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.90.1 with SMTP id o1csp472703vsb; Wed, 9 Nov 2016 11:53:06 -0800 (PST) X-Received: by 10.194.246.3 with SMTP id xs3mr1404497wjc.87.1478721186461; Wed, 09 Nov 2016 11:53:06 -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 137si1906725wmr.70.2016.11.09.11.53.05; Wed, 09 Nov 2016 11:53:06 -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; dkim=neutral (body hash did not verify) header.i=@googlemail.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; dmarc=fail (p=QUARANTINE dis=NONE) header.from=googlemail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 54355689DFE; Wed, 9 Nov 2016 21:52:59 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1994A689D40 for ; Wed, 9 Nov 2016 21:52:53 +0200 (EET) Received: by mail-wm0-f65.google.com with SMTP id c17so31288081wmc.3 for ; Wed, 09 Nov 2016 11:52:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:subject:to:references:message-id:date:user-agent:mime-version :in-reply-to; bh=kIUKjVP4qdEOt38O8g5P+dp0ZrScidn+IvJGmYvKli8=; b=hNqMbgA2m0EmldCB24HFco9pSaLNMpEv46wvUfHTKcVJyMiM6eEdq5rRY18lsGpfRn d8TcoY6MzUBhOu5FUNM85eQ9gucon1SrblS++mVOSgmmuu7N5GCuteXKZd3quVfSUB5Q DSaNl06mEOZBs2qVRbWt5TC4Lz2SAaWwvXQYC3HwFPrBsSqAEo9iaoGnJlBq13rYKBve QWAxbro9NztRCKuTmMPiuuSw8zpqvts7Jp+NGcgosNbJgL4QO88HcS6cw3ckxBFUxNL/ wWLz5BcX9vwBlhA7/w/rxzSlRfMrckmKWlKKG2CcnF7Ok1g0BI6A5tcnHAf1L71iEJPt DhAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:subject:to:references:message-id:date :user-agent:mime-version:in-reply-to; bh=kIUKjVP4qdEOt38O8g5P+dp0ZrScidn+IvJGmYvKli8=; b=I1VKw+InVVwlzmc6bMFHSxm0DwG6YDS4rcAwcICsQf2V8/1dzmS5JFEURjXpLZDFKe J8BSz/YD35J6spCnneZNKzMPh0exPYd/fOWIDX1HwcYsAtPvoMO3fmvsiBq2OMhtiuJW JtpcuBdSyxxieATp8cIC/PzxWvm2JP+wIbzTyMTRA6jeHYyovRgYRs5RQtKQcCQMYcoN E1zfpYo9ebFIqnQugnGEUMu70Xsb5j1V3ybHobRAG4/95KtGKT4kGqedZWyXKOo65Awx FsI8JTQuVgpjMHN8Om9u3Hlcj8/Gtr8oHl991Uhd67FM2ZVjSE/o3b882YaKUTjzC49M Ul6w== X-Gm-Message-State: ABUngvfMnAdBWQOHxrNGLZ4ZK/GGBkiUbPPERgT3mnuSOSZiRekcoBZSCRie7AxmlxF4Rw== X-Received: by 10.194.231.8 with SMTP id tc8mr1114528wjc.193.1478721175833; Wed, 09 Nov 2016 11:52:55 -0800 (PST) Received: from [192.168.2.21] (p5B072193.dip0.t-ipconnect.de. [91.7.33.147]) by smtp.googlemail.com with ESMTPSA id m194sm2042794wmg.11.2016.11.09.11.52.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Nov 2016 11:52:55 -0800 (PST) From: Andreas Cadhalpun X-Google-Original-From: Andreas Cadhalpun To: ffmpeg-devel@ffmpeg.org References: <6d200416-f02f-370b-3e15-c0bc58792bd1@googlemail.com> <20161109012753.GZ4602@nb4> Message-ID: Date: Wed, 9 Nov 2016 20:52:54 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161109012753.GZ4602@nb4> Subject: Re: [FFmpeg-devel] [PATCH] dvbsubdec: fix division by zero in 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" On 09.11.2016 02:27, Michael Niedermayer wrote: > On Tue, Nov 08, 2016 at 10:36:01PM +0100, Andreas Cadhalpun wrote: >> Since the loop goes down to i = 0 the number of iterations (variable >> count) is the original i, not i - 1. >> In the case of i originally being 1, this miscalculation resulted in >> a division by zero. >> >> This problem was introduced in commit >> 4b90dcb8493552c17a811c8b1e6538dae4061f9d. >> >> Signed-off-by: Andreas Cadhalpun >> --- >> libavcodec/dvbsubdec.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c >> index e9f4765..31898ea 100644 >> --- a/libavcodec/dvbsubdec.c >> +++ b/libavcodec/dvbsubdec.c >> @@ -810,7 +810,7 @@ static void compute_default_clut(AVSubtitleRect *rect, int w, int h) >> list_inv[ i ] = bestv; >> } >> >> - count = i - 1; >> + count = i; >> for (i--; i>=0; i--) { >> int v = i*255/count; >> AV_WN32(rect->data[1] + 4*list_inv[i], RGBA(v/2,v,v/2,v)); > > with this a 2 color text would be 50% and 100% transparent > it should be transparent background and opaque text, > count = FFMAX(i - 1, 1); > seems better to me OK, patch doing that is attached. Best regards, Andreas From 436318575abf482e1ea144f651c47bc2730e41a2 Mon Sep 17 00:00:00 2001 From: Andreas Cadhalpun Date: Tue, 8 Nov 2016 22:32:42 +0100 Subject: [PATCH] dvbsubdec: fix division by zero in compute_default_clut This problem was introduced in commit 4b90dcb8493552c17a811c8b1e6538dae4061f9d. Signed-off-by: Andreas Cadhalpun --- libavcodec/dvbsubdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index e9f4765..bf3b1a1 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -810,7 +810,7 @@ static void compute_default_clut(AVSubtitleRect *rect, int w, int h) list_inv[ i ] = bestv; } - count = i - 1; + count = FFMAX(i - 1, 1); for (i--; i>=0; i--) { int v = i*255/count; AV_WN32(rect->data[1] + 4*list_inv[i], RGBA(v/2,v,v/2,v)); -- 2.10.2