From 14f0c8e28af6f34411d86fa3f965e5be870024e6 Mon Sep 17 00:00:00 2001
From: Luca Abeni <lucabe72@email.it>
Date: Tue, 10 Jan 2006 20:07:29 +0000
Subject: [PATCH] Parameter added for user to set the cutoff frequency when
 encoding with faac. Patch by Luca Abeni - lucabe72 at email dot it.

Originally committed as revision 4837 to svn://svn.ffmpeg.org/ffmpeg/trunk
---
 libavcodec/avcodec.h | 7 +++++++
 libavcodec/faac.c    | 1 +
 libavcodec/utils.c   | 1 +
 3 files changed, 9 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 033cec225fa..a7e504fda4c 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1982,6 +1982,13 @@ typedef struct AVCodecContext {
      * - decoding: unused
      */
     int directpred;
+    
+    /**
+     * audio cutoff bandwidth (0 means "automatic") . Currently used only by FAAC
+     * - encoding: set by user.
+     * - decoding: unused
+     */
+    int cutoff;
 } AVCodecContext;
 
 /**
diff --git a/libavcodec/faac.c b/libavcodec/faac.c
index 99331df1d72..d275f3c71e4 100644
--- a/libavcodec/faac.c
+++ b/libavcodec/faac.c
@@ -57,6 +57,7 @@ static int Faac_encode_init(AVCodecContext *avctx)
     faac_cfg->useTns = 0;
     faac_cfg->allowMidside = 1;
     faac_cfg->bitRate = avctx->bit_rate / avctx->channels;
+    faac_cfg->bandWidth = avctx->cutoff;
     if(avctx->flags & CODEC_FLAG_QSCALE) {
         faac_cfg->bitRate = 0;
         faac_cfg->quantqual = avctx->global_quality / FF_QP2LAMBDA;
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index ede6cc761c2..da74865eb8e 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -494,6 +494,7 @@ static AVOption options[]={
 {"rate_emu", NULL, OFFSET(rate_emu), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
 {"sample_rate", NULL, OFFSET(sample_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
 {"channels", NULL, OFFSET(channels), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
+{"cutoff", "set cutoff bandwidth", OFFSET(cutoff), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, A|E},
 {"frame_size", NULL, OFFSET(frame_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
 {"frame_number", NULL, OFFSET(frame_number), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
 {"real_pict_num", NULL, OFFSET(real_pict_num), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-- 
GitLab