Revision 12eeda34 ffplay.c

View differences:

ffplay.c
30 30
#include "libavcodec/audioconvert.h"
31 31
#include "libavcodec/colorspace.h"
32 32
#include "libavcodec/opt.h"
33
#include "libavcodec/dsputil.h"
33 34

  
34 35
#include "cmdutils.h"
35 36

  
......
151 152
    int16_t sample_array[SAMPLE_ARRAY_SIZE];
152 153
    int sample_array_index;
153 154
    int last_i_start;
155
    RDFTContext rdft;
156
    int rdft_bits;
157
    int xpos;
154 158

  
155 159
    SDL_Thread *subtitle_tid;
156 160
    int subtitle_stream;
......
799 803
            delay = s->width;
800 804

  
801 805
        i_start= x = compute_mod(s->sample_array_index - delay * channels, SAMPLE_ARRAY_SIZE);
802

  
806
        if(s->show_audio==1){
803 807
        h= INT_MIN;
804 808
        for(i=0; i<1000; i+=channels){
805 809
            int idx= (SAMPLE_ARRAY_SIZE + x - i) % SAMPLE_ARRAY_SIZE;
......
813 817
                i_start= idx;
814 818
            }
815 819
        }
820
        }
816 821

  
817 822
        s->last_i_start = i_start;
818 823
    } else {
......
820 825
    }
821 826

  
822 827
    bgcolor = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00);
828
    if(s->show_audio==1){
823 829
    fill_rectangle(screen,
824 830
                   s->xleft, s->ytop, s->width, s->height,
825 831
                   bgcolor);
......
859 865
                       fgcolor);
860 866
    }
861 867
    SDL_UpdateRect(screen, s->xleft, s->ytop, s->width, s->height);
868
    }else{
869
        int rdft_bits, nb_freq;
870
        nb_display_channels= FFMIN(nb_display_channels, 2);
871
        for(rdft_bits=1; (1<<rdft_bits)<=s->height; rdft_bits++)
872
            ;
873
        if(rdft_bits != s->rdft_bits){
874
            ff_rdft_end(&s->rdft);
875
            ff_rdft_init(&s->rdft, rdft_bits, RDFT);
876
            s->rdft_bits= rdft_bits;
877
        }
878
        nb_freq= 1<<(rdft_bits-1);
879
        {
880
            FFTSample data[2][2*nb_freq];
881
            for(ch = 0;ch < nb_display_channels; ch++) {
882
                i = i_start + ch;
883
                for(x = 0; x < 2*nb_freq; x++) {
884
                    double w= (x-nb_freq)*(1.0/nb_freq);
885
                    data[ch][x]= s->sample_array[i]*(1.0-w*w);
886
                    i += channels;
887
                    if (i >= SAMPLE_ARRAY_SIZE)
888
                        i -= SAMPLE_ARRAY_SIZE;
889
                }
890
                ff_rdft_calc(&s->rdft, data[ch]);
891
            }
892
            //least efficient way to do this, we should of course directly access it but its more than fast enough
893
            for(y=0; y<nb_freq; y++){
894
                double w= 1/sqrt(nb_freq);
895
                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]));
896
                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]));
897
                a= FFMIN(a,255);
898
                b= FFMIN(b,255);
899
                fgcolor = SDL_MapRGB(screen->format, a, b, (a+b)/2);
900

  
901
                fill_rectangle(screen,
902
                            s->xpos, s->height-y, 1, 1,
903
                            fgcolor);
904
            }
905
        }
906
        SDL_UpdateRect(screen, s->xpos, s->ytop, 1, s->height);
907
        s->xpos++;
908
        if(s->xpos >= s->width)
909
            s->xpos= s->xleft;
910
    }
862 911
}
863 912

  
864 913
static int video_open(VideoState *is){
......
2312 2361
{
2313 2362
    if (cur_stream) {
2314 2363
        int bgcolor = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00);
2315
        cur_stream->show_audio = !cur_stream->show_audio;
2364
        cur_stream->show_audio = (cur_stream->show_audio + 1) % 3;
2316 2365
        fill_rectangle(screen,
2317 2366
                    cur_stream->xleft, cur_stream->ytop, cur_stream->width, cur_stream->height,
2318 2367
                    bgcolor);

Also available in: Unified diff