Based on a commit by Andreas Rheinhardt. Signed-off-by: James Almer <jamr...@gmail.com> --- fftools/ffmpeg.c | 11 ++--------- fftools/ffmpeg_opt.c | 4 ++++ 2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index f6ab33a614..05d197b8af 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2332,15 +2332,11 @@ static int send_frame_to_filters(InputStream *ist, AVFrame *decoded_frame) static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output, int *decode_failed) { - AVFrame *decoded_frame; + AVFrame *decoded_frame = ist->decoded_frame; AVCodecContext *avctx = ist->dec_ctx; int ret, err = 0; AVRational decoded_frame_tb; - if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc())) - return AVERROR(ENOMEM); - decoded_frame = ist->decoded_frame; - update_benchmark(NULL); ret = decode(avctx, decoded_frame, got_output, pkt); update_benchmark("decode_audio %d.%d", ist->file_index, ist->st->index); @@ -2392,7 +2388,7 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output, static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_t *duration_pts, int eof, int *decode_failed) { - AVFrame *decoded_frame; + AVFrame *decoded_frame = ist->decoded_frame; int i, ret = 0, err = 0; int64_t best_effort_timestamp; int64_t dts = AV_NOPTS_VALUE; @@ -2403,9 +2399,6 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_ if (!eof && pkt && pkt->size == 0) return 0; - if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc())) - return AVERROR(ENOMEM); - decoded_frame = ist->decoded_frame; if (ist->dts != AV_NOPTS_VALUE) dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ist->st->time_base); if (pkt) { diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 278cab39bf..2a95c31107 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -888,6 +888,10 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) exit_program(1); } + ist->decoded_frame = av_frame_alloc(); + if (!ist->decoded_frame) + exit_program(1); + ist->filter_frame = av_frame_alloc(); if (!ist->filter_frame) exit_program(1); -- 2.33.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".