ffmpeg: Allocate (In|Out)putStream.filter_frame early
Based on a commit by Andreas Rheinhardt. Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
@@ -1533,9 +1533,6 @@ static int reap_filters(int flush)
|
|||||||
if (av_buffersink_get_type(filter) == AVMEDIA_TYPE_AUDIO)
|
if (av_buffersink_get_type(filter) == AVMEDIA_TYPE_AUDIO)
|
||||||
init_output_stream_wrapper(ost, NULL, 1);
|
init_output_stream_wrapper(ost, NULL, 1);
|
||||||
|
|
||||||
if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc())) {
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
|
||||||
filtered_frame = ost->filtered_frame;
|
filtered_frame = ost->filtered_frame;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
@@ -2342,8 +2339,6 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output,
|
|||||||
|
|
||||||
if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc()))
|
if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc()))
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
if (!ist->filter_frame && !(ist->filter_frame = av_frame_alloc()))
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
decoded_frame = ist->decoded_frame;
|
decoded_frame = ist->decoded_frame;
|
||||||
|
|
||||||
update_benchmark(NULL);
|
update_benchmark(NULL);
|
||||||
@@ -2415,8 +2410,6 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_
|
|||||||
|
|
||||||
if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc()))
|
if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc()))
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
if (!ist->filter_frame && !(ist->filter_frame = av_frame_alloc()))
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
decoded_frame = ist->decoded_frame;
|
decoded_frame = ist->decoded_frame;
|
||||||
if (ist->dts != AV_NOPTS_VALUE)
|
if (ist->dts != AV_NOPTS_VALUE)
|
||||||
dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ist->st->time_base);
|
dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ist->st->time_base);
|
||||||
|
|||||||
@@ -889,6 +889,10 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
|
|||||||
exit_program(1);
|
exit_program(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ist->filter_frame = av_frame_alloc();
|
||||||
|
if (!ist->filter_frame)
|
||||||
|
exit_program(1);
|
||||||
|
|
||||||
ist->pkt = av_packet_alloc();
|
ist->pkt = av_packet_alloc();
|
||||||
if (!ist->pkt)
|
if (!ist->pkt)
|
||||||
exit_program(1);
|
exit_program(1);
|
||||||
@@ -1521,6 +1525,10 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
|
|||||||
exit_program(1);
|
exit_program(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ost->filtered_frame = av_frame_alloc();
|
||||||
|
if (!ost->filtered_frame)
|
||||||
|
exit_program(1);
|
||||||
|
|
||||||
ost->pkt = av_packet_alloc();
|
ost->pkt = av_packet_alloc();
|
||||||
if (!ost->pkt)
|
if (!ost->pkt)
|
||||||
exit_program(1);
|
exit_program(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user