]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/libfdk-aacdec.c
lavc: support extracting audio service type from side data
[ffmpeg] / libavcodec / libfdk-aacdec.c
index 2c2abae9e75e9e84c71478fd44bda49ff71a6920..f789b75bfe64f9dd0b05ab080f2a48178a8bac51 100644 (file)
@@ -49,6 +49,7 @@ typedef struct FDKAACDecContext {
     int drc_boost;
     int drc_heavy;
     int drc_cut;
+    int level_limit;
 } FDKAACDecContext;
 
 
@@ -71,6 +72,9 @@ static const AVOption fdk_aac_dec_options[] = {
                      OFFSET(drc_level),      AV_OPT_TYPE_INT,   { .i64 = -1},  -1, 127, AD, NULL    },
     { "drc_heavy", "Dynamic Range Control: heavy compression, where [1] is on (RF mode) and [0] is off",
                      OFFSET(drc_heavy),      AV_OPT_TYPE_INT,   { .i64 = -1},  -1, 1,   AD, NULL    },
+#ifdef AACDECODER_LIB_VL0
+    { "level_limit", "Signal level limiting", OFFSET(level_limit), AV_OPT_TYPE_INT, { .i64 = 0 }, -1, 1, AD },
+#endif
     { NULL }
 };
 
@@ -100,7 +104,7 @@ static int get_stream_info(AVCodecContext *avctx)
 
     for (i = 0; i < info->numChannels; i++) {
         AUDIO_CHANNEL_TYPE ctype = info->pChannelType[i];
-        if (ctype <= ACT_NONE || ctype > FF_ARRAY_ELEMS(channel_counts)) {
+        if (ctype <= ACT_NONE || ctype >= FF_ARRAY_ELEMS(channel_counts)) {
             av_log(avctx, AV_LOG_WARNING, "unknown channel type\n");
             break;
         }
@@ -292,6 +296,13 @@ static av_cold int fdk_aac_decode_init(AVCodecContext *avctx)
         }
     }
 
+#ifdef AACDECODER_LIB_VL0
+    if (aacDecoder_SetParam(s->handle, AAC_PCM_LIMITER_ENABLE, s->level_limit) != AAC_DEC_OK) {
+        av_log(avctx, AV_LOG_ERROR, "Unable to set in signal level limiting in the decoder\n");
+        return AVERROR_UNKNOWN;
+    }
+#endif
+
     avctx->sample_fmt = AV_SAMPLE_FMT_S16;
 
     return 0;