~ppsspp/ppsspp/ffmpeg-upstream

« back to all changes in this revision

Viewing changes to libswresample/soxr_resample.c

  • Committer: Sérgio Benjamim
  • Date: 2015-07-20 03:55:05 UTC
  • Revision ID: sergio_br2@yahoo.com.br-20150720035505-i1jj1zcjcnd0mc7w
Updated to 2.7.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
}
68
68
 
69
69
static int flush(struct SwrContext *s){
 
70
    s->delayed_samples_fixup = soxr_delay((soxr_t)s->resample);
 
71
 
70
72
    soxr_process((soxr_t)s->resample, NULL, 0, NULL, NULL, 0, NULL);
 
73
 
 
74
    {
 
75
        float f;
 
76
        size_t idone, odone;
 
77
        soxr_process((soxr_t)s->resample, &f, 0, &idone, &f, 0, &odone);
 
78
        s->delayed_samples_fixup -= soxr_delay((soxr_t)s->resample);
 
79
    }
 
80
 
71
81
    return 0;
72
82
}
73
83
 
87
97
}
88
98
 
89
99
static int64_t get_delay(struct SwrContext *s, int64_t base){
90
 
    double delay_s = soxr_delay((soxr_t)s->resample) / s->out_sample_rate;
 
100
    double delayed_samples = soxr_delay((soxr_t)s->resample);
 
101
    double delay_s;
 
102
 
 
103
    if (s->flushed)
 
104
        delayed_samples += s->delayed_samples_fixup;
 
105
 
 
106
    delay_s = delayed_samples / s->out_sample_rate;
 
107
 
91
108
    return (int64_t)(delay_s * base + .5);
92
109
}
93
110
 
94
111
static int invert_initial_buffer(struct ResampleContext *c, AudioData *dst, const AudioData *src,
95
 
                                 int in_count, int *out_idx, int *out_sz)
96
 
{
 
112
                                 int in_count, int *out_idx, int *out_sz){
97
113
    return 0;
98
114
}
99
115
 
 
116
static int64_t get_out_samples(struct SwrContext *s, int in_samples){
 
117
    double out_samples = (double)s->out_sample_rate / s->in_sample_rate * in_samples;
 
118
    double delayed_samples = soxr_delay((soxr_t)s->resample);
 
119
 
 
120
    if (s->flushed)
 
121
        delayed_samples += s->delayed_samples_fixup;
 
122
 
 
123
    return (int64_t)(out_samples + delayed_samples + 1 + .5);
 
124
}
 
125
 
100
126
struct Resampler const swri_soxr_resampler={
101
127
    create, destroy, process, flush, NULL /* set_compensation */, get_delay,
102
 
    invert_initial_buffer,
 
128
    invert_initial_buffer, get_out_samples
103
129
};
104
130