changeset 33255:54faee206150

Command Line Options: Support FFmpeg per-codec AVOptions. This change extends the existing support for arbitrary FFmpeg options to also include per-codec AVOptions. You can now pass per-codec options in the same way as global options are passed: mplayer -lavdopts o=<option>
author philipl
date Sun, 01 May 2011 15:25:41 +0000
parents 8cfe525f0ec0
children 0ebe0fb46341
files av_opts.c libmpcodecs/vd_ffmpeg.c
diffstat 2 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/av_opts.c	Fri Apr 29 13:05:49 2011 +0000
+++ b/av_opts.c	Sun May 01 15:25:41 2011 +0000
@@ -27,6 +27,10 @@
 
 int parse_avopts(void *v, char *str){
     char *start;
+
+    if (!v)
+        return -1;
+
     start= str= strdup(str);
 
     while(str && *str){
--- a/libmpcodecs/vd_ffmpeg.c	Fri Apr 29 13:05:49 2011 +0000
+++ b/libmpcodecs/vd_ffmpeg.c	Sun May 01 15:25:41 2011 +0000
@@ -304,6 +304,7 @@
     ctx->pic = avcodec_alloc_frame();
     ctx->avctx = avcodec_alloc_context();
     avctx = ctx->avctx;
+    avcodec_get_context_defaults3(avctx, lavc_codec);
     avctx->opaque = sh;
     avctx->codec_type = AVMEDIA_TYPE_VIDEO;
     avctx->codec_id = lavc_codec->id;
@@ -346,7 +347,9 @@
     avctx->skip_frame = str2AVDiscard(lavc_param_skip_frame_str);
 
     if(lavc_avopt){
-        if(parse_avopts(avctx, lavc_avopt) < 0){
+        if (parse_avopts(avctx, lavc_avopt) < 0 &&
+            (!lavc_codec->priv_class ||
+             parse_avopts(avctx->priv_data, lavc_avopt) < 0)) {
             mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Your options /%s/ look like gibberish to me pal\n", lavc_avopt);
             uninit(sh);
             return 0;