swr: automatically choose s16/flt/dbl to preserve input precision unless user overrides.
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 1 May 2012 22:51:06 +0000 (00:51 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 1 May 2012 23:12:16 +0000 (01:12 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libswresample/swresample.c

index 87a885b..6566199 100644 (file)
@@ -208,11 +208,16 @@ int swr_init(struct SwrContext *s){
         return AVERROR(EINVAL);
     }
 
-    //FIXME should we allow/support using FLT on material that doesnt need it ?
-    if(av_get_planar_sample_fmt(s->in_sample_fmt) <= AV_SAMPLE_FMT_S16P || s->int_sample_fmt==AV_SAMPLE_FMT_S16P){
-        s->int_sample_fmt= AV_SAMPLE_FMT_S16P;
-    }else
-        s->int_sample_fmt= AV_SAMPLE_FMT_FLTP;
+    if(s->int_sample_fmt == AV_SAMPLE_FMT_NONE){
+        if(av_get_planar_sample_fmt(s->in_sample_fmt) <= AV_SAMPLE_FMT_S16P){
+            s->int_sample_fmt= AV_SAMPLE_FMT_S16P;
+        }else if(av_get_planar_sample_fmt(s->in_sample_fmt) <= AV_SAMPLE_FMT_FLTP){
+            s->int_sample_fmt= AV_SAMPLE_FMT_FLTP;
+        }else{
+            av_log(s, AV_LOG_DEBUG, "Using double precission mode\n");
+            s->int_sample_fmt= AV_SAMPLE_FMT_DBLP;
+        }
+    }
 
     if(   s->int_sample_fmt != AV_SAMPLE_FMT_S16P
         &&s->int_sample_fmt != AV_SAMPLE_FMT_S32P