From patchwork Wed Mar 3 22:27:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 26079 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 19E7744A534 for ; Thu, 4 Mar 2021 00:28:05 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E904268A6B5; Thu, 4 Mar 2021 00:28:04 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D48A8689E14 for ; Thu, 4 Mar 2021 00:27:58 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 44E2DE5032; Wed, 3 Mar 2021 23:27:58 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id D1lhXM0lHYdT; Wed, 3 Mar 2021 23:27:28 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 4F915E5044; Wed, 3 Mar 2021 23:27:28 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Wed, 3 Mar 2021 23:27:22 +0100 Message-Id: <20210303222722.14368-1-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] fftools/ffplay: do not write out of rdft visualization texture 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 Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" If the window is resized it was possible that xpos pointed outside the visualization texture. By rearranging the overflow check we make sure this (and a crash) does not happen. We also don't have to use xleft for start position, as that is 0 anyways, and if we ever want to take into account xleft then the texture should be positioned accordingly when rendering. Signed-off-by: Marton Balint --- fftools/ffplay.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index b9a30cdb11..0cdadab293 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -1148,6 +1148,8 @@ static void video_audio_display(VideoState *s) if (realloc_texture(&s->vis_texture, SDL_PIXELFORMAT_ARGB8888, s->width, s->height, SDL_BLENDMODE_NONE, 1) < 0) return; + if (s->xpos >= s->width) + s->xpos = 0; nb_display_channels= FFMIN(nb_display_channels, 2); if (rdft_bits != s->rdft_bits) { av_rdft_end(s->rdft); @@ -1197,8 +1199,6 @@ static void video_audio_display(VideoState *s) } if (!s->paused) s->xpos++; - if (s->xpos >= s->width) - s->xpos= s->xleft; } }