Skip to content

Commit ee3d6a2

Browse files
committed
ffmpeg: Allocate (In|Out)putStream.filter_frame early
Based on a commit by Andreas Rheinhardt. Signed-off-by: James Almer <[email protected]>
1 parent 67b92d6 commit ee3d6a2

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

fftools/ffmpeg.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,9 +1533,6 @@ static int reap_filters(int flush)
15331533
if (av_buffersink_get_type(filter) == AVMEDIA_TYPE_AUDIO)
15341534
init_output_stream_wrapper(ost, NULL, 1);
15351535

1536-
if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc())) {
1537-
return AVERROR(ENOMEM);
1538-
}
15391536
filtered_frame = ost->filtered_frame;
15401537

15411538
while (1) {
@@ -2342,8 +2339,6 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output,
23422339

23432340
if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc()))
23442341
return AVERROR(ENOMEM);
2345-
if (!ist->filter_frame && !(ist->filter_frame = av_frame_alloc()))
2346-
return AVERROR(ENOMEM);
23472342
decoded_frame = ist->decoded_frame;
23482343

23492344
update_benchmark(NULL);
@@ -2415,8 +2410,6 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_
24152410

24162411
if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc()))
24172412
return AVERROR(ENOMEM);
2418-
if (!ist->filter_frame && !(ist->filter_frame = av_frame_alloc()))
2419-
return AVERROR(ENOMEM);
24202413
decoded_frame = ist->decoded_frame;
24212414
if (ist->dts != AV_NOPTS_VALUE)
24222415
dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ist->st->time_base);

fftools/ffmpeg_opt.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,10 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
889889
exit_program(1);
890890
}
891891

892+
ist->filter_frame = av_frame_alloc();
893+
if (!ist->filter_frame)
894+
exit_program(1);
895+
892896
ist->pkt = av_packet_alloc();
893897
if (!ist->pkt)
894898
exit_program(1);
@@ -1521,6 +1525,10 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
15211525
exit_program(1);
15221526
}
15231527

1528+
ost->filtered_frame = av_frame_alloc();
1529+
if (!ost->filtered_frame)
1530+
exit_program(1);
1531+
15241532
ost->pkt = av_packet_alloc();
15251533
if (!ost->pkt)
15261534
exit_program(1);

0 commit comments

Comments
 (0)