[MPlayer-cvslog] r34611 - in trunk/libmpcodecs: ad_ffmpeg.c vd_ffmpeg.c
reimar
subversion at mplayerhq.hu
Sat Jan 28 11:40:55 CET 2012
Author: reimar
Date: Sat Jan 28 11:40:55 2012
New Revision: 34611
Log:
Use AVDictionary to set some special options.
Modified:
trunk/libmpcodecs/ad_ffmpeg.c
trunk/libmpcodecs/vd_ffmpeg.c
Modified: trunk/libmpcodecs/ad_ffmpeg.c
==============================================================================
--- trunk/libmpcodecs/ad_ffmpeg.c Sat Jan 28 11:32:49 2012 (r34610)
+++ trunk/libmpcodecs/ad_ffmpeg.c Sat Jan 28 11:40:55 2012 (r34611)
@@ -44,6 +44,7 @@ LIBAD_EXTERN(ffmpeg)
#define assert(x)
#include "libavcodec/avcodec.h"
+#include "libavutil/dict.h"
static int preinit(sh_audio_t *sh)
@@ -90,6 +91,8 @@ static int init(sh_audio_t *sh_audio)
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 @@ static int init(sh_audio_t *sh_audio)
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 @@ static int init(sh_audio_t *sh_audio)
}
/* 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);
Modified: trunk/libmpcodecs/vd_ffmpeg.c
==============================================================================
--- trunk/libmpcodecs/vd_ffmpeg.c Sat Jan 28 11:32:49 2012 (r34610)
+++ trunk/libmpcodecs/vd_ffmpeg.c Sat Jan 28 11:40:55 2012 (r34611)
@@ -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 @@ static int init(sh_video_t *sh){
// 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 @@ static int init(sh_video_t *sh){
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 @@ static int init(sh_video_t *sh){
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);
More information about the MPlayer-cvslog
mailing list