Hi, 2011/6/6 Måns Rullgård <[email protected]>: > "Ronald S. Bultje" <[email protected]> writes: > >> Hi, >> >> 2011/6/6 Måns Rullgård <[email protected]>: >>> "Ronald S. Bultje" <[email protected]> writes: >>> >>>> --- >>>> libavcodec/utils.c | 2 +- >>>> 1 files changed, 1 insertions(+), 1 deletions(-) >>>> >>>> diff --git a/libavcodec/utils.c b/libavcodec/utils.c >>>> index 2b417de..1e58864 100644 >>>> --- a/libavcodec/utils.c >>>> +++ b/libavcodec/utils.c >>>> @@ -783,7 +783,7 @@ av_cold int avcodec_close(AVCodecContext *avctx) >>>> avctx->codec->close(avctx); >>>> avcodec_default_free_buffers(avctx); >>>> avctx->coded_frame = NULL; >>>> - if (avctx->codec->priv_class) >>>> + if (avctx->codec && avctx->codec->priv_class) >>>> av_opt_free(avctx->priv_data); >>>> av_opt_free(avctx); >>>> av_freep(&avctx->priv_data); >>>> -- >>> >>> Why is avctx->codec null when threading is enabled? >> >> It's apparently NULL in a lot of cases, all other access to >> avctx->codec->xyz have a if (avctx->codec) around it in this function, >> except this one. > > That does not answer the question. Why is it null *here* with threading > and not without?
Coding-wise, because frame_thread_free() sets it so. Logic-wise, because what else would it be? The application-level AVCtx has nothing in it, it's a placeholder that is there to synchronize the individual per-thread AVCtxs that run in each worker thread. It has no private context other than the one that syncs between threads. It has no private_data with codec information in it. Therefore, AVCodec == NULL. Ronald _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
