diff libmpcodecs/ad_ffmpeg.c @ 34523:0481efcf5489

Use AVDictionary to set some special options.
author reimar
date Sat, 28 Jan 2012 10:40:55 +0000
parents 14a1ae73b01d
children c897dbc5f1de
line wrap: on
line diff
--- a/libmpcodecs/ad_ffmpeg.c	Sat Jan 28 10:32:49 2012 +0000
+++ b/libmpcodecs/ad_ffmpeg.c	Sat Jan 28 10:40:55 2012 +0000
@@ -44,6 +44,7 @@
 #define assert(x)
 
 #include "libavcodec/avcodec.h"
+#include "libavutil/dict.h"
 
 
 static int preinit(sh_audio_t *sh)
@@ -90,6 +91,8 @@
     int x;
     AVCodecContext *lavc_context;
     AVCodec *lavc_codec;
+    AVDictionary *opts = NULL;
+    char tmpstr[50];
 
     mp_msg(MSGT_DECAUDIO,MSGL_V,"FFmpeg's libavcodec audio codec\n");
     init_avcodec();
@@ -103,7 +106,8 @@
     lavc_context = avcodec_alloc_context3(lavc_codec);
     sh_audio->context=lavc_context;
 
-    lavc_context->drc_scale = drc_level;
+    snprintf(tmpstr, sizeof(tmpstr), "%i", drc_level);
+    av_dict_set(&opts, "drc_scale", tmpstr, 0);
     lavc_context->sample_rate = sh_audio->samplerate;
     lavc_context->bit_rate = sh_audio->i_bps * 8;
     if(sh_audio->wf){
@@ -135,10 +139,11 @@
     }
 
     /* open it */
-    if (avcodec_open2(lavc_context, lavc_codec, NULL) < 0) {
+    if (avcodec_open2(lavc_context, lavc_codec, opts) < 0) {
         mp_msg(MSGT_DECAUDIO,MSGL_ERR, MSGTR_CantOpenCodec);
         return 0;
     }
+    av_dict_free(&opts);
    mp_msg(MSGT_DECAUDIO,MSGL_V,"INFO: libavcodec \"%s\" init OK!\n", lavc_codec->name);
 
 //   printf("\nFOURCC: 0x%X\n",sh_audio->format);