Hi, On Sun, Jan 29, 2012 at 9:24 AM, Anton Khirnov <[email protected]> wrote: > This way, if the AVCodecContext is allocated for a specific codec, the > caller doesn't need to store this codec separately and then pass it > again to avcodec_open2(). > > It also allows to set codec private options using av_opt_set_* before > opening the codec. > --- > libavcodec/avcodec.h | 5 +++++ > libavcodec/options.c | 1 + > libavcodec/utils.c | 11 ++++++----- > libavformat/utils.c | 8 +++++--- > 4 files changed, 17 insertions(+), 8 deletions(-) [..] > * @param avctx The context to initialize. > + * @param codec The codec to open this context for. If a non-NULL codec has > been > + * previously passed to avcodec_alloc_context3() or > + * avcodec_get_context_defaults3() for this context, then this > + * parameter MUST be either NULL or equal to the previously > passed > + * codec.
Why NULL? Seems like additional complexity with no real gain. > + if ((!codec && !avctx->codec) || > + (codec && avctx->codec && codec != avctx->codec)) > + return AVERROR(EINVAL); I'd say that if codec != avctx->codec, you probably want to log a very loud AV_LOG_ERROR somewhere. Ronald _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
