You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
fftools/ffmpeg, ffmpeg_opt: Allocate (In|Out)putStream.pkt early
Avoids checks lateron in the hot path. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.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->pkt && !(ost->pkt = av_packet_alloc())) {
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
|
||||||
if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc())) {
|
if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc())) {
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
@@ -1979,9 +1976,6 @@ static void flush_encoders(void)
|
|||||||
AVPacket *pkt = ost->pkt;
|
AVPacket *pkt = ost->pkt;
|
||||||
int pkt_size;
|
int pkt_size;
|
||||||
|
|
||||||
if (!pkt)
|
|
||||||
break;
|
|
||||||
|
|
||||||
switch (enc->codec_type) {
|
switch (enc->codec_type) {
|
||||||
case AVMEDIA_TYPE_AUDIO:
|
case AVMEDIA_TYPE_AUDIO:
|
||||||
desc = "audio";
|
desc = "audio";
|
||||||
@@ -2597,8 +2591,6 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output,
|
|||||||
for (i = 0; i < nb_output_streams; i++) {
|
for (i = 0; i < nb_output_streams; i++) {
|
||||||
OutputStream *ost = output_streams[i];
|
OutputStream *ost = output_streams[i];
|
||||||
|
|
||||||
if (!ost->pkt && !(ost->pkt = av_packet_alloc()))
|
|
||||||
exit_program(1);
|
|
||||||
if (!check_output_constraints(ist, ost) || !ost->encoding_needed
|
if (!check_output_constraints(ist, ost) || !ost->encoding_needed
|
||||||
|| ost->enc->type != AVMEDIA_TYPE_SUBTITLE)
|
|| ost->enc->type != AVMEDIA_TYPE_SUBTITLE)
|
||||||
continue;
|
continue;
|
||||||
@@ -2634,11 +2626,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo
|
|||||||
int repeating = 0;
|
int repeating = 0;
|
||||||
int eof_reached = 0;
|
int eof_reached = 0;
|
||||||
|
|
||||||
AVPacket *avpkt;
|
AVPacket *avpkt = ist->pkt;
|
||||||
|
|
||||||
if (!ist->pkt && !(ist->pkt = av_packet_alloc()))
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
avpkt = ist->pkt;
|
|
||||||
|
|
||||||
if (!ist->saw_first_ts) {
|
if (!ist->saw_first_ts) {
|
||||||
ist->first_dts =
|
ist->first_dts =
|
||||||
@@ -2809,8 +2797,6 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo
|
|||||||
for (i = 0; i < nb_output_streams; i++) {
|
for (i = 0; i < nb_output_streams; i++) {
|
||||||
OutputStream *ost = output_streams[i];
|
OutputStream *ost = output_streams[i];
|
||||||
|
|
||||||
if (!ost->pkt && !(ost->pkt = av_packet_alloc()))
|
|
||||||
exit_program(1);
|
|
||||||
if (!check_output_constraints(ist, ost) || ost->encoding_needed)
|
if (!check_output_constraints(ist, ost) || ost->encoding_needed)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@@ -888,6 +888,10 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
|
|||||||
exit_program(1);
|
exit_program(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ist->pkt = av_packet_alloc();
|
||||||
|
if (!ist->pkt)
|
||||||
|
exit_program(1);
|
||||||
|
|
||||||
if (o->bitexact)
|
if (o->bitexact)
|
||||||
ist->dec_ctx->flags |= AV_CODEC_FLAG_BITEXACT;
|
ist->dec_ctx->flags |= AV_CODEC_FLAG_BITEXACT;
|
||||||
|
|
||||||
@@ -1516,6 +1520,10 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
|
|||||||
exit_program(1);
|
exit_program(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ost->pkt = av_packet_alloc();
|
||||||
|
if (!ost->pkt)
|
||||||
|
exit_program(1);
|
||||||
|
|
||||||
if (ost->enc) {
|
if (ost->enc) {
|
||||||
AVIOContext *s = NULL;
|
AVIOContext *s = NULL;
|
||||||
char *buf = NULL, *arg = NULL, *preset = NULL;
|
char *buf = NULL, *arg = NULL, *preset = NULL;
|
||||||
|
Reference in New Issue
Block a user