[FFmpeg-devel] [PATCH 5/8] fftools/ffmpeg_demux: only allocate the decoder when actually decoding
Anton Khirnov
anton at khirnov.net
Tue Jan 16 21:50:29 EET 2024
Quoting Stefano Sabatini (2024-01-06 12:34:53)
> On date Friday 2024-01-05 17:42:48 +0100, Anton Khirnov wrote:
> > It is not needed otherwise.
> > ---
> > fftools/ffmpeg_demux.c | 24 ++++++++++++------------
> > 1 file changed, 12 insertions(+), 12 deletions(-)
> >
> > diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
> > index 892094c512..c51140b1c5 100644
> > --- a/fftools/ffmpeg_demux.c
> > +++ b/fftools/ffmpeg_demux.c
> > @@ -782,6 +782,16 @@ static int ist_use(InputStream *ist, int decoding_needed)
> > if (decoding_needed && ds->sch_idx_dec < 0) {
> > int is_audio = ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO;
> >
> > + ist->dec_ctx = avcodec_alloc_context3(ist->dec);
> > + if (!ist->dec_ctx)
> > + return AVERROR(ENOMEM);
> > +
> > + ret = avcodec_parameters_to_context(ist->dec_ctx, ist->par);
> > + if (ret < 0) {
>
> > + av_log(ist, AV_LOG_ERROR, "Error initializing the decoder context.\n");
>
> unrelated, here and below: might be useful to notify the failing
> stream identifier, assuming it is not already shown in the log
It is, logging to ist prints something like
[aist#0:0/pcm_s16le @ 0x563a40304b40] ....
--
Anton Khirnov
More information about the ffmpeg-devel
mailing list