diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2010-09-29 15:05:47 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2010-09-29 15:05:47 +0000 |
commit | dc51a72ba45fbefb9f1c6c3ca5a5b2388d69b2da (patch) | |
tree | fb90f0690489553fcefda116b43f866ea9a8ebbe /libavcodec/options.c | |
parent | cd17285e6cecefbeb286adbba881eb26dbabec29 (diff) | |
download | ffmpeg-dc51a72ba45fbefb9f1c6c3ca5a5b2388d69b2da.tar.gz |
Move allocation and init to defaults of the private codec contexts to avcodec_get_context_defaults3().
That way the user app can set codec specific parameters in the private context
before opening it.
Originally committed as revision 25257 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/options.c')
-rw-r--r-- | libavcodec/options.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libavcodec/options.c b/libavcodec/options.c index d55d4fde26..6a6ac78e28 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -467,6 +467,36 @@ void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType codec_typ s->reordered_opaque= AV_NOPTS_VALUE; } +int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec){ + avcodec_get_context_defaults2(s, codec ? codec->type : AVMEDIA_TYPE_UNKNOWN); + if(codec && codec->priv_data_size){ + if(!s->priv_data){ + s->priv_data= av_mallocz(codec->priv_data_size); + if (!s->priv_data) { + return AVERROR(ENOMEM); + } + } + if(codec->priv_class){ + *(AVClass**)s->priv_data= codec->priv_class; + av_opt_set_defaults(s->priv_data); + } + } + return 0; +} + +AVCodecContext *avcodec_alloc_context3(AVCodec *codec){ + AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext)); + + if(avctx==NULL) return NULL; + + if(avcodec_get_context_defaults3(avctx, codec) < 0){ + av_free(avctx); + return NULL; + } + + return avctx; +} + AVCodecContext *avcodec_alloc_context2(enum AVMediaType codec_type){ AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext)); |