]> git.sesse.net Git - ffmpeg/commitdiff
fftools/ffplay: do not write out of rdft visualization texture
authorMarton Balint <cus@passwd.hu>
Wed, 3 Mar 2021 22:23:10 +0000 (23:23 +0100)
committerMarton Balint <cus@passwd.hu>
Wed, 10 Mar 2021 19:01:03 +0000 (20:01 +0100)
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 <cus@passwd.hu>
fftools/ffplay.c

index 471d4a2ac9b1ad23d69b4dc158d9a21dd237217f..e14c800b8ff4b1f1bbf537ae76e1799d54eea953 100644 (file)
@@ -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;
     }
 }