mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-05 23:34:35 +08:00
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
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user