[FFmpeg-devel] [PATCH 11/12] ffplay: remove variable-length array
Mans Rullgard
mans
Wed Jun 23 19:26:49 CEST 2010
---
ffplay.c | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/ffplay.c b/ffplay.c
index 129cd28..2532a74 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -168,6 +168,7 @@ typedef struct VideoState {
int last_i_start;
RDFTContext *rdft;
int rdft_bits;
+ FFTSample *rdft_data;
int xpos;
SDL_Thread *subtitle_tid;
@@ -917,27 +918,31 @@ static void video_audio_display(VideoState *s)
nb_display_channels= FFMIN(nb_display_channels, 2);
if(rdft_bits != s->rdft_bits){
av_rdft_end(s->rdft);
+ av_freep(&s->rdft_data);
s->rdft = av_rdft_init(rdft_bits, DFT_R2C);
s->rdft_bits= rdft_bits;
+ s->rdft_data= av_malloc(4*nb_freq*sizeof(*s->rdft_data));
}
{
- FFTSample data[2][2*nb_freq];
+ FFTSample *data0 = s->rdft_data;
+ FFTSample *data1 = s->rdft_data + 2*nb_freq;
for(ch = 0;ch < nb_display_channels; ch++) {
+ FFTSample *data = s->rdft_data + 2*nb_freq*ch;
i = i_start + ch;
for(x = 0; x < 2*nb_freq; x++) {
double w= (x-nb_freq)*(1.0/nb_freq);
- data[ch][x]= s->sample_array[i]*(1.0-w*w);
+ data[x]= s->sample_array[i]*(1.0-w*w);
i += channels;
if (i >= SAMPLE_ARRAY_SIZE)
i -= SAMPLE_ARRAY_SIZE;
}
- av_rdft_calc(s->rdft, data[ch]);
+ av_rdft_calc(s->rdft, data);
}
//least efficient way to do this, we should of course directly access it but its more than fast enough
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 a= sqrt(w*sqrt(data0[2*y+0]*data0[2*y+0] + data0[2*y+1]*data0[2*y+1]));
+ int b= sqrt(w*sqrt(data1[2*y+0]*data1[2*y+0] + data1[2*y+1]*data1[2*y+1]));
a= FFMIN(a,255);
b= FFMIN(b,255);
fgcolor = SDL_MapRGB(screen->format, a, b, (a+b)/2);
--
1.7.1
More information about the ffmpeg-devel
mailing list