FFplay : Fix segfault when playing monoaural streams.
authorJai Menon <jmenon86@gmail.com>
Wed, 7 Jul 2010 18:14:58 +0000 (18:14 +0000)
committerJai Menon <jmenon86@gmail.com>
Wed, 7 Jul 2010 18:14:58 +0000 (18:14 +0000)
Originally committed as revision 24090 to svn://svn.ffmpeg.org/ffmpeg/trunk

ffplay.c

index 67e2437..c32b10a 100644 (file)
--- a/ffplay.c
+++ b/ffplay.c
@@ -943,7 +943,8 @@ static void video_audio_display(VideoState *s)
             for(y=0; y<s->height; y++){
                 double w= 1/sqrt(nb_freq);
                 int a= sqrt(w*sqrt(data[0][2*y+0]*data[0][2*y+0] + data[0][2*y+1]*data[0][2*y+1]));
-                int b= sqrt(w*sqrt(data[1][2*y+0]*data[1][2*y+0] + data[1][2*y+1]*data[1][2*y+1]));
+                int b= (nb_display_channels == 2 ) ? sqrt(w*sqrt(data[1][2*y+0]*data[1][2*y+0]
+                       + data[1][2*y+1]*data[1][2*y+1])) : a;
                 a= FFMIN(a,255);
                 b= FFMIN(b,255);
                 fgcolor = SDL_MapRGB(screen->format, a, b, (a+b)/2);