mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-19 05:49:09 +02:00
fftools/ffmpeg_demux: only allocate the decoder when actually decoding
It is not needed otherwise.
This commit is contained in:
parent
2ee1c6ffb2
commit
50448ca290
@ -782,6 +782,16 @@ static int ist_use(InputStream *ist, int decoding_needed)
|
|||||||
if (decoding_needed && ds->sch_idx_dec < 0) {
|
if (decoding_needed && ds->sch_idx_dec < 0) {
|
||||||
int is_audio = ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO;
|
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");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
ret = sch_add_dec(d->sch, decoder_thread, ist, d->loop && is_audio);
|
ret = sch_add_dec(d->sch, decoder_thread, ist, d->loop && is_audio);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
@ -1215,23 +1225,13 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st)
|
|||||||
default: av_assert0(0);
|
default: av_assert0(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ist->dec_ctx = avcodec_alloc_context3(ist->dec);
|
|
||||||
if (!ist->dec_ctx)
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
|
|
||||||
ret = avcodec_parameters_to_context(ist->dec_ctx, par);
|
|
||||||
if (ret < 0) {
|
|
||||||
av_log(ist, AV_LOG_ERROR, "Error initializing the decoder context.\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ist->par = avcodec_parameters_alloc();
|
ist->par = avcodec_parameters_alloc();
|
||||||
if (!ist->par)
|
if (!ist->par)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
ret = avcodec_parameters_from_context(ist->par, ist->dec_ctx);
|
ret = avcodec_parameters_copy(ist->par, par);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(ist, AV_LOG_ERROR, "Error initializing the decoder context.\n");
|
av_log(ist, AV_LOG_ERROR, "Error exporting stream parameters.\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user