|
|
|
@ -56,7 +56,7 @@ |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct AVResampleContext{ |
|
|
|
|
typedef struct ResampleContext { |
|
|
|
|
const AVClass *av_class; |
|
|
|
|
FELEM *filter_bank; |
|
|
|
|
int filter_length; |
|
|
|
@ -70,7 +70,7 @@ typedef struct AVResampleContext{ |
|
|
|
|
int phase_mask; |
|
|
|
|
int linear; |
|
|
|
|
double factor; |
|
|
|
|
}AVResampleContext; |
|
|
|
|
} ResampleContext; |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 0th order modified bessel function of the first kind. |
|
|
|
@ -199,13 +199,13 @@ static int build_filter(FELEM *filter, double factor, int tap_count, int phase_c |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
AVResampleContext *swr_resample_init(AVResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff){ |
|
|
|
|
ResampleContext *swr_resample_init(ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff){ |
|
|
|
|
double factor= FFMIN(out_rate * cutoff / in_rate, 1.0); |
|
|
|
|
int phase_count= 1<<phase_shift; |
|
|
|
|
|
|
|
|
|
if (!c || c->phase_shift != phase_shift || c->linear!=linear || c->factor != factor |
|
|
|
|
|| c->filter_length != FFMAX((int)ceil(filter_size/factor), 1)) { |
|
|
|
|
c = av_mallocz(sizeof(AVResampleContext)); |
|
|
|
|
c = av_mallocz(sizeof(*c)); |
|
|
|
|
if (!c) |
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
@ -238,7 +238,7 @@ error: |
|
|
|
|
return NULL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void swr_resample_free(AVResampleContext **c){ |
|
|
|
|
void swr_resample_free(ResampleContext **c){ |
|
|
|
|
if(!*c) |
|
|
|
|
return; |
|
|
|
|
av_freep(&(*c)->filter_bank); |
|
|
|
@ -246,13 +246,13 @@ void swr_resample_free(AVResampleContext **c){ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void swr_compensate(struct SwrContext *s, int sample_delta, int compensation_distance){ |
|
|
|
|
AVResampleContext *c= s->resample; |
|
|
|
|
ResampleContext *c= s->resample; |
|
|
|
|
// sample_delta += (c->ideal_dst_incr - c->dst_incr)*(int64_t)c->compensation_distance / c->ideal_dst_incr;
|
|
|
|
|
c->compensation_distance= compensation_distance; |
|
|
|
|
c->dst_incr = c->ideal_dst_incr - c->ideal_dst_incr * (int64_t)sample_delta / compensation_distance; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int swr_resample(AVResampleContext *c, short *dst, const short *src, int *consumed, int src_size, int dst_size, int update_ctx){ |
|
|
|
|
int swr_resample(ResampleContext *c, short *dst, const short *src, int *consumed, int src_size, int dst_size, int update_ctx){ |
|
|
|
|
int dst_index, i; |
|
|
|
|
int index= c->index; |
|
|
|
|
int frac= c->frac; |
|
|
|
@ -341,7 +341,7 @@ av_log(NULL, AV_LOG_DEBUG, "%d %d %d\n", c->dst_incr, c->ideal_dst_incr, c->comp |
|
|
|
|
return dst_index; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int swr_multiple_resample(AVResampleContext *c, AudioData *dst, int dst_size, AudioData *src, int src_size, int *consumed){ |
|
|
|
|
int swr_multiple_resample(ResampleContext *c, AudioData *dst, int dst_size, AudioData *src, int src_size, int *consumed){ |
|
|
|
|
int i, ret= -1; |
|
|
|
|
|
|
|
|
|
for(i=0; i<dst->ch_count; i++){ |
|
|
|
|