changeset 34523:0481efcf5489

Use AVDictionary to set some special options.
author reimar
date Sat, 28 Jan 2012 10:40:55 +0000
parents d40c46fad187
children 5392905aa13c
files libmpcodecs/ad_ffmpeg.c libmpcodecs/vd_ffmpeg.c
diffstat 2 files changed, 12 insertions(+), 4 deletions(-) [+]
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);
--- a/libmpcodecs/vd_ffmpeg.c	Sat Jan 28 10:32:49 2012 +0000
+++ b/libmpcodecs/vd_ffmpeg.c	Sat Jan 28 10:40:55 2012 +0000
@@ -28,6 +28,7 @@
 #include "av_helpers.h"
 
 #include "libavutil/common.h"
+#include "libavutil/dict.h"
 #include "libavutil/intreadwrite.h"
 #include "mpbswap.h"
 #include "fmt-conversion.h"
@@ -223,6 +224,7 @@
     // slice is rather broken with threads, so disable that combination unless
     // explicitly requested
     int use_slices = vd_use_slices > 0 || (vd_use_slices <  0 && lavc_param_threads <= 1);
+    AVDictionary *opts = NULL;
 
     init_avcodec();
 
@@ -325,7 +327,7 @@
        MJPG fourcc :( */
         if (!sh->bih || sh->bih->biSize <= sizeof(*sh->bih))
             break;
-        avctx->flags |= CODEC_FLAG_EXTERN_HUFF;
+        av_dict_set(&opts, "extern_huff", "1", 0);
         avctx->extradata_size = sh->bih->biSize-sizeof(*sh->bih);
         avctx->extradata = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
         memcpy(avctx->extradata, sh->bih+1, avctx->extradata_size);
@@ -384,11 +386,12 @@
         set_format_params(avctx, PIX_FMT_XVMC_MPEG2_IDCT);
 
     /* open it */
-    if (avcodec_open2(avctx, lavc_codec, NULL) < 0) {
+    if (avcodec_open2(avctx, lavc_codec, &opts) < 0) {
         mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_CantOpenCodec);
         uninit(sh);
         return 0;
     }
+    av_dict_free(&opts);
     // this is necessary in case get_format was never called and init_vo is
     // too late e.g. for H.264 VDPAU
     set_format_params(avctx, avctx->pix_fmt);