aboutsummaryrefslogtreecommitdiffstats
path: root/cmdutils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-05-16 21:00:06 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-05-16 21:26:18 +0200
commit5319f48a5753772e5c04c022a0ed903d8ceecbd1 (patch)
tree9db95fcc4969201699718c849f5d1468aa6d932b /cmdutils.c
parent68bed67d2eaabcfa7eaf00442312055f7d953b69 (diff)
downloadffmpeg-5319f48a5753772e5c04c022a0ed903d8ceecbd1.tar.gz
cmdutils: Allocate private decoder context if its not allocated yet.
This fixes and simplifies setting decoder private options. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'cmdutils.c')
-rw-r--r--cmdutils.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/cmdutils.c b/cmdutils.c
index 11391af361..a5363b8176 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -411,13 +411,24 @@ int opt_timelimit(const char *opt, const char *arg)
return 0;
}
+static void *alloc_priv_context(int size, AVClass *class){
+ void *p = av_mallocz(size);
+ if (p) {
+ *(AVClass**)p = class;
+ av_opt_set_defaults(p);
+ }
+ return p;
+}
+
void set_context_opts(void *ctx, void *opts_ctx, int flags, AVCodec *codec)
{
int i;
void *priv_ctx=NULL;
if(!strcmp("AVCodecContext", (*(AVClass**)ctx)->class_name)){
AVCodecContext *avctx= ctx;
- if(codec && codec->priv_class && avctx->priv_data){
+ if(codec && codec->priv_class){
+ if(!avctx->priv_data && codec->priv_data_size)
+ avctx->priv_data= alloc_priv_context(codec->priv_data_size, codec->priv_class);
priv_ctx= avctx->priv_data;
}
} else if (!strcmp("AVFormatContext", (*(AVClass**)ctx)->class_name)) {