[FFmpeg-cvslog] (e)ac3enc: select a default bit rate based on the channel layout

Justin Ruggles git at videolan.org
Thu Mar 1 03:20:21 CET 2012


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Wed Feb 22 21:45:06 2012 -0500| [4e99501f629f6baebac0414d92d841b64ead30fe] | committer: Justin Ruggles

(e)ac3enc: select a default bit rate based on the channel layout

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4e99501f629f6baebac0414d92d841b64ead30fe
---

 libavcodec/ac3enc.c               |   11 +++++++++++
 libavcodec/ac3enc_fixed.c         |    1 +
 libavcodec/ac3enc_float.c         |    1 +
 libavcodec/ac3enc_opts_template.c |    6 ++++++
 libavcodec/eac3enc.c              |    1 +
 5 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 669be23..967c1bd 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -2141,6 +2141,17 @@ static av_cold int validate_options(AC3EncodeContext *s)
     s->bit_alloc.sr_code  = i % 3;
     s->bitstream_id       = s->eac3 ? 16 : 8 + s->bit_alloc.sr_shift;
 
+    /* select a default bit rate if not set by the user */
+    if (!avctx->bit_rate) {
+        switch (s->fbw_channels) {
+        case 1: avctx->bit_rate =  96000; break;
+        case 2: avctx->bit_rate = 192000; break;
+        case 3: avctx->bit_rate = 320000; break;
+        case 4: avctx->bit_rate = 384000; break;
+        case 5: avctx->bit_rate = 448000; break;
+        }
+    }
+
     /* validate bit rate */
     if (s->eac3) {
         int max_br, min_br, wpf, min_br_dist, min_br_code;
diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c
index 202dfb8..98838f3 100644
--- a/libavcodec/ac3enc_fixed.c
+++ b/libavcodec/ac3enc_fixed.c
@@ -151,4 +151,5 @@ AVCodec ff_ac3_fixed_encoder = {
     .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
     .priv_class = &ac3enc_class,
     .channel_layouts = ff_ac3_channel_layouts,
+    .defaults        = ac3_defaults,
 };
diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c
index a4abd89..64b360f 100644
--- a/libavcodec/ac3enc_float.c
+++ b/libavcodec/ac3enc_float.c
@@ -149,5 +149,6 @@ AVCodec ff_ac3_encoder = {
     .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
     .priv_class = &ac3enc_class,
     .channel_layouts = ff_ac3_channel_layouts,
+    .defaults        = ac3_defaults,
 };
 #endif
diff --git a/libavcodec/ac3enc_opts_template.c b/libavcodec/ac3enc_opts_template.c
index a5f848e..fa89844 100644
--- a/libavcodec/ac3enc_opts_template.c
+++ b/libavcodec/ac3enc_opts_template.c
@@ -20,6 +20,7 @@
  */
 
 #include "libavutil/opt.h"
+#include "internal.h"
 #include "ac3.h"
 
 #if AC3ENC_TYPE == AC3ENC_TYPE_AC3_FIXED
@@ -78,3 +79,8 @@ static const AVOption eac3_options[] = {
     {"auto", "Selected by the Encoder", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_AUTO }, INT_MIN, INT_MAX, AC3ENC_PARAM, "cpl_start_band"},
 {NULL}
 };
+
+static const AVCodecDefault ac3_defaults[] = {
+    { "b",  "0" },
+    { NULL }
+};
diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c
index f3b4418..459fb90 100644
--- a/libavcodec/eac3enc.c
+++ b/libavcodec/eac3enc.c
@@ -258,5 +258,6 @@ AVCodec ff_eac3_encoder = {
     .long_name       = NULL_IF_CONFIG_SMALL("ATSC A/52 E-AC-3"),
     .priv_class      = &eac3enc_class,
     .channel_layouts = ff_ac3_channel_layouts,
+    .defaults        = ac3_defaults,
 };
 #endif



More information about the ffmpeg-cvslog mailing list