summaryrefslogtreecommitdiff
path: root/libavcodec/utils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2010-09-29 15:05:47 +0000
committerMichael Niedermayer <michaelni@gmx.at>2010-09-29 15:05:47 +0000
commitdc51a72ba45fbefb9f1c6c3ca5a5b2388d69b2da (patch)
treefb90f0690489553fcefda116b43f866ea9a8ebbe /libavcodec/utils.c
parentcd17285e6cecefbeb286adbba881eb26dbabec29 (diff)
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/utils.c')
-rw-r--r--libavcodec/utils.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index ad80f0f4a3..7edff412ec 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -471,11 +471,17 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
goto end;
if (codec->priv_data_size > 0) {
+ if(!avctx->priv_data){
avctx->priv_data = av_mallocz(codec->priv_data_size);
if (!avctx->priv_data) {
ret = AVERROR(ENOMEM);
goto end;
}
+ if(codec->priv_class){ //this can be droped once all user apps use avcodec_get_context_defaults3()
+ *(AVClass**)avctx->priv_data= codec->priv_class;
+ av_opt_set_defaults(avctx->priv_data);
+ }
+ }
} else {
avctx->priv_data = NULL;
}