From 19342bc725025a572c3e0bf1a3f27ba310d50d5c Mon Sep 17 00:00:00 2001 From: Michael Niedermayer <michaelni@gmx.at> Date: Sun, 25 Mar 2012 05:37:26 +0200 Subject: [PATCH] swr: test partial flushing Signed-off-by: Michael Niedermayer <michaelni@gmx.at> --- libswresample/swresample_test.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/libswresample/swresample_test.c b/libswresample/swresample_test.c index d41b964ba4c..9dd9f44607c 100644 --- a/libswresample/swresample_test.c +++ b/libswresample/swresample_test.c @@ -67,6 +67,18 @@ static void set(uint8_t *a[], int ch, int index, int ch_count, enum AVSampleFor } } +static void shift(uint8_t *a[], int index, int ch_count, enum AVSampleFormat f){ + int i, ch; + + if(av_sample_fmt_is_planar(f)){ + f= av_get_alt_sample_fmt(f, 0); + for(ch= 0; ch<ch_count; ch++) + a[ch] += index*av_get_bytes_per_sample(f); + }else{ + a[0] += index*ch_count*av_get_bytes_per_sample(f); + } +} + uint64_t layouts[]={ AV_CH_LAYOUT_MONO , AV_CH_LAYOUT_STEREO , @@ -109,10 +121,16 @@ int main(int argc, char **argv){ uint8_t *ain[SWR_CH_MAX]; uint8_t *aout[SWR_CH_MAX]; uint8_t *amid[SWR_CH_MAX]; + int flush_i=0; struct SwrContext * forw_ctx= NULL; struct SwrContext *backw_ctx= NULL; + in_sample_rate=16000; + for(osr=0; osr<5; osr++){ + out_sample_rate= sample_rates[osr]; + } + in_sample_rate=16000; for(osr=0; osr<5; osr++){ out_sample_rate= sample_rates[osr]; @@ -178,7 +196,12 @@ int main(int argc, char **argv){ fprintf(stderr, "[%f %f %f] len:%5d\n", sqrt(sse/out_count), x, maxdiff, out_count); } - flush_count=swr_convert(backw_ctx,aout, SAMPLES, 0, 0); + flush_i++; + flush_i%=21; + flush_count = swr_convert(backw_ctx,aout, flush_i, 0, 0); + shift(aout, flush_i, in_ch_count, in_sample_fmt); + flush_count+= swr_convert(backw_ctx,aout, SAMPLES-flush_i, 0, 0); + shift(aout, -flush_i, in_ch_count, in_sample_fmt); if(flush_count){ for(ch=0; ch<in_ch_count; ch++){ double sse, x, maxdiff=0; @@ -200,7 +223,7 @@ int main(int argc, char **argv){ x = sum_ab/sum_bb; sse= sum_aa + sum_bb*x*x - 2*x*sum_ab; - fprintf(stderr, "[%f %f %f] len:%5d\n", sqrt(sse/flush_count), x, maxdiff, flush_count); + fprintf(stderr, "[%f %f %f] len:%5d F:%3d\n", sqrt(sse/flush_count), x, maxdiff, flush_count, flush_i); } } -- GitLab