Revision 6c7165c7 ffplay.c

View differences:

ffplay.c
810 810

  
811 811
        i_start= x = compute_mod(s->sample_array_index - delay * channels, SAMPLE_ARRAY_SIZE);
812 812
        if(s->show_audio==1){
813
        h= INT_MIN;
814
        for(i=0; i<1000; i+=channels){
815
            int idx= (SAMPLE_ARRAY_SIZE + x - i) % SAMPLE_ARRAY_SIZE;
816
            int a= s->sample_array[idx];
817
            int b= s->sample_array[(idx + 4*channels)%SAMPLE_ARRAY_SIZE];
818
            int c= s->sample_array[(idx + 5*channels)%SAMPLE_ARRAY_SIZE];
819
            int d= s->sample_array[(idx + 9*channels)%SAMPLE_ARRAY_SIZE];
820
            int score= a-d;
821
            if(h<score && (b^c)<0){
822
                h= score;
823
                i_start= idx;
813
            h= INT_MIN;
814
            for(i=0; i<1000; i+=channels){
815
                int idx= (SAMPLE_ARRAY_SIZE + x - i) % SAMPLE_ARRAY_SIZE;
816
                int a= s->sample_array[idx];
817
                int b= s->sample_array[(idx + 4*channels)%SAMPLE_ARRAY_SIZE];
818
                int c= s->sample_array[(idx + 5*channels)%SAMPLE_ARRAY_SIZE];
819
                int d= s->sample_array[(idx + 9*channels)%SAMPLE_ARRAY_SIZE];
820
                int score= a-d;
821
                if(h<score && (b^c)<0){
822
                    h= score;
823
                    i_start= idx;
824
                }
824 825
            }
825 826
        }
826
        }
827 827

  
828 828
        s->last_i_start = i_start;
829 829
    } else {
......
832 832

  
833 833
    bgcolor = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00);
834 834
    if(s->show_audio==1){
835
    fill_rectangle(screen,
836
                   s->xleft, s->ytop, s->width, s->height,
837
                   bgcolor);
838

  
839
    fgcolor = SDL_MapRGB(screen->format, 0xff, 0xff, 0xff);
840

  
841
    /* total height for one channel */
842
    h = s->height / nb_display_channels;
843
    /* graph height / 2 */
844
    h2 = (h * 9) / 20;
845
    for(ch = 0;ch < nb_display_channels; ch++) {
846
        i = i_start + ch;
847
        y1 = s->ytop + ch * h + (h / 2); /* position of center line */
848
        for(x = 0; x < s->width; x++) {
849
            y = (s->sample_array[i] * h2) >> 15;
850
            if (y < 0) {
851
                y = -y;
852
                ys = y1 - y;
853
            } else {
854
                ys = y1;
835
        fill_rectangle(screen,
836
                       s->xleft, s->ytop, s->width, s->height,
837
                       bgcolor);
838

  
839
        fgcolor = SDL_MapRGB(screen->format, 0xff, 0xff, 0xff);
840

  
841
        /* total height for one channel */
842
        h = s->height / nb_display_channels;
843
        /* graph height / 2 */
844
        h2 = (h * 9) / 20;
845
        for(ch = 0;ch < nb_display_channels; ch++) {
846
            i = i_start + ch;
847
            y1 = s->ytop + ch * h + (h / 2); /* position of center line */
848
            for(x = 0; x < s->width; x++) {
849
                y = (s->sample_array[i] * h2) >> 15;
850
                if (y < 0) {
851
                    y = -y;
852
                    ys = y1 - y;
853
                } else {
854
                    ys = y1;
855
                }
856
                fill_rectangle(screen,
857
                               s->xleft + x, ys, 1, y,
858
                               fgcolor);
859
                i += channels;
860
                if (i >= SAMPLE_ARRAY_SIZE)
861
                    i -= SAMPLE_ARRAY_SIZE;
855 862
            }
856
            fill_rectangle(screen,
857
                           s->xleft + x, ys, 1, y,
858
                           fgcolor);
859
            i += channels;
860
            if (i >= SAMPLE_ARRAY_SIZE)
861
                i -= SAMPLE_ARRAY_SIZE;
862 863
        }
863
    }
864 864

  
865
    fgcolor = SDL_MapRGB(screen->format, 0x00, 0x00, 0xff);
865
        fgcolor = SDL_MapRGB(screen->format, 0x00, 0x00, 0xff);
866 866

  
867
    for(ch = 1;ch < nb_display_channels; ch++) {
868
        y = s->ytop + ch * h;
869
        fill_rectangle(screen,
870
                       s->xleft, y, s->width, 1,
871
                       fgcolor);
872
    }
873
    SDL_UpdateRect(screen, s->xleft, s->ytop, s->width, s->height);
867
        for(ch = 1;ch < nb_display_channels; ch++) {
868
            y = s->ytop + ch * h;
869
            fill_rectangle(screen,
870
                           s->xleft, y, s->width, 1,
871
                           fgcolor);
872
        }
873
        SDL_UpdateRect(screen, s->xleft, s->ytop, s->width, s->height);
874 874
    }else{
875 875
        nb_display_channels= FFMIN(nb_display_channels, 2);
876 876
        if(rdft_bits != s->rdft_bits){

Also available in: Unified diff