diff options
author | jstebbins <[email protected]> | 2011-04-08 16:49:24 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2011-04-08 16:49:24 +0000 |
commit | f20621c2d30ad805dfefcab335506f660a133ffe (patch) | |
tree | 5d1a3e9e844b94584790b7f002c3fdec39081326 /libhb/hb.c | |
parent | de122b044e99b0ad1abff0ba51e1a4d9e7d8b020 (diff) |
Change internal audio representation range
...from float [-32768...32767] to float [-1.0...1.0]
Using the range [-1.0..1.0] requires fewer translations of the range for our
various encoders and decoders. This also gets rid of a hacky
translation from float to int to float in decavcodec audio decoding.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3908 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/hb.c')
-rw-r--r-- | libhb/hb.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libhb/hb.c b/libhb/hb.c index 92e743cc6..4c16156c5 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -241,6 +241,29 @@ int hb_ff_layout_xlat(int64_t ff_channel_layout, int channels) return hb_layout; } +// Set sample format to AV_SAMPLE_FMT_FLT if supported. +// If it is not supported, we will have to translate using +// av_audio_convert. +void hb_ff_set_sample_fmt(AVCodecContext *context, AVCodec *codec) +{ + if ( codec && codec->sample_fmts ) + { + if ( codec->type != AVMEDIA_TYPE_AUDIO ) + return; // Not audio + + const enum AVSampleFormat *fmt; + + for ( fmt = codec->sample_fmts; *fmt != -1; fmt++ ) + { + if ( *fmt == AV_SAMPLE_FMT_FLT ) + { + context->sample_fmt = AV_SAMPLE_FMT_FLT; + break; + } + } + } +} + /** * Registers work objects, by adding the work object to a liked list. * @param w Handle to hb_work_object_t to register. |