diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2012-05-27 21:44:55 -0400 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2012-07-08 15:22:11 -0400 |
commit | 6410397600eae3bd447c0ec2667cc53722ab84ee (patch) | |
tree | fb27812ab145c6a7e6bacc24d813e3676e332d45 /libavresample/utils.c | |
parent | 372647aed04b89def4e73ae29df0fef60a2f1930 (diff) | |
download | ffmpeg-6410397600eae3bd447c0ec2667cc53722ab84ee.tar.gz |
lavr: resampling: add support for s32p, fltp, and dblp internal sample formats
Based partially on implementation by Michael Niedermayer <michaelni@gmx.at> in
libswresample in FFmpeg. See commits:
7f1ae79d38c4edba9dbd31d7bf797e525298ac55
24ab1abfb6d55bf330022df4b10d7aec80b3f116
Diffstat (limited to 'libavresample/utils.c')
-rw-r--r-- | libavresample/utils.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/libavresample/utils.c b/libavresample/utils.c index ac1c36e17c..1aca566282 100644 --- a/libavresample/utils.c +++ b/libavresample/utils.c @@ -64,10 +64,30 @@ int avresample_open(AVAudioResampleContext *avr) enum AVSampleFormat out_fmt = av_get_planar_sample_fmt(avr->out_sample_fmt); int max_bps = FFMAX(av_get_bytes_per_sample(in_fmt), av_get_bytes_per_sample(out_fmt)); - if (avr->resample_needed || max_bps <= 2) { + if (max_bps <= 2) { avr->internal_sample_fmt = AV_SAMPLE_FMT_S16P; } else if (avr->mixing_needed) { avr->internal_sample_fmt = AV_SAMPLE_FMT_FLTP; + } else { + if (max_bps <= 4) { + if (in_fmt == AV_SAMPLE_FMT_S32P || + out_fmt == AV_SAMPLE_FMT_S32P) { + if (in_fmt == AV_SAMPLE_FMT_FLTP || + out_fmt == AV_SAMPLE_FMT_FLTP) { + /* if one is s32 and the other is flt, use dbl */ + avr->internal_sample_fmt = AV_SAMPLE_FMT_DBLP; + } else { + /* if one is s32 and the other is s32, s16, or u8, use s32 */ + avr->internal_sample_fmt = AV_SAMPLE_FMT_S32P; + } + } else { + /* if one is flt and the other is flt, s16 or u8, use flt */ + avr->internal_sample_fmt = AV_SAMPLE_FMT_FLTP; + } + } else { + /* if either is dbl, use dbl */ + avr->internal_sample_fmt = AV_SAMPLE_FMT_DBLP; + } } av_log(avr, AV_LOG_DEBUG, "Using %s as internal sample format\n", av_get_sample_fmt_name(avr->internal_sample_fmt)); |