On Wed, 9 Jan 2013, Justin Ruggles wrote:

---
libavcodec/libfaac.c |   27 ++++++++++++++++++++++++++-
1 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/libavcodec/libfaac.c b/libavcodec/libfaac.c
index 745fee2..9239578 100644
--- a/libavcodec/libfaac.c
+++ b/libavcodec/libfaac.c
@@ -28,6 +28,7 @@

#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
+#include "libavutil/opt.h"
#include "avcodec.h"
#include "audio_frame_queue.h"
#include "internal.h"
@@ -37,10 +38,26 @@
#define FAAC_DELAY_SAMPLES 1024

typedef struct FaacAudioContext {
+    AVClass *class;
+    int mpeg_version;
    faacEncHandle faac_handle;
    AudioFrameQueue afq;
} FaacAudioContext;

+#define OFFSET(x) offsetof(FaacAudioContext, x)
+#define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+
+static const AVOption options[] = {
+    { "mpeg_version", "Set the MPEG version (2 or 4)", OFFSET(mpeg_version), 
AV_OPT_TYPE_INT, { .i64 = 4 }, 2, 4, AE },
+    { NULL },
+};
+
+static const AVClass class = {
+    .class_name = "libfaac",
+    .item_name  = av_default_item_name,
+    .option     = options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};

static av_cold int Faac_encode_close(AVCodecContext *avctx)
{
@@ -116,7 +133,14 @@ static av_cold int Faac_encode_init(AVCodecContext *avctx)
            ret = AVERROR(EINVAL);
            goto error;
    }
-    faac_cfg->mpegVersion = MPEG4;
+    switch (s->mpeg_version) {
+    case 2:  faac_cfg->mpegVersion = MPEG2; break;
+    case 4:  faac_cfg->mpegVersion = MPEG4; break;
+    default:
+        av_log(avctx, AV_LOG_ERROR, "invalid MPEG version: %d\n",
+               s->mpeg_version);
+        return AVERROR(EINVAL);
+    }
    faac_cfg->useTns = 0;
    faac_cfg->allowMidside = 1;
    faac_cfg->bitRate = avctx->bit_rate / avctx->channels;
@@ -248,4 +272,5 @@ AVCodec ff_libfaac_encoder = {
    .long_name      = NULL_IF_CONFIG_SMALL("libfaac AAC (Advanced Audio 
Coding)"),
    .profiles       = NULL_IF_CONFIG_SMALL(profiles),
    .channel_layouts = faac_channel_layouts,
+    .priv_class     = &class,
};
--
1.7.1

Looks reasonable to me.

// Martin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to