]> git.sesse.net Git - ffmpeg/commitdiff
libopencore-amr: set channel layout for amr-nb or if not set by the user
authorJustin Ruggles <justin.ruggles@gmail.com>
Mon, 22 Oct 2012 21:49:59 +0000 (17:49 -0400)
committerJustin Ruggles <justin.ruggles@gmail.com>
Thu, 1 Nov 2012 15:29:17 +0000 (11:29 -0400)
libavcodec/libopencore-amr.c

index 9a543b48b2f6a3eca29a0a52307d9265ea793332..a754d521a607e8653d5c4df3a05c9a256d84c68a 100644 (file)
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/audioconvert.h"
 #include "avcodec.h"
 #include "libavutil/avstring.h"
 #include "libavutil/common.h"
@@ -30,13 +31,16 @@ static void amr_decode_fix_avctx(AVCodecContext *avctx)
 {
     const int is_amr_wb = 1 + (avctx->codec_id == AV_CODEC_ID_AMR_WB);
 
-    if (!avctx->sample_rate)
-        avctx->sample_rate = 8000 * is_amr_wb;
+    avctx->sample_rate = 8000 * is_amr_wb;
 
-    if (!avctx->channels)
-        avctx->channels = 1;
+    if (avctx->channels > 1) {
+        av_log_missing_feature(avctx, "multi-channel AMR", 0);
+        return AVERROR_PATCHWELCOME;
+    }
 
-    avctx->sample_fmt = AV_SAMPLE_FMT_S16;
+    avctx->channels       = 1;
+    avctx->channel_layout = AV_CH_LAYOUT_MONO;
+    avctx->sample_fmt     = AV_SAMPLE_FMT_S16;
 }
 
 #if CONFIG_LIBOPENCORE_AMRNB