diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-05-31 11:45:13 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-06-05 16:16:12 +0200 |
commit | 96e1325d9152323cb6418df017da7aca99d59f78 (patch) | |
tree | 1038dc77ef01869af5929458f3a32388c3968a08 /fftools/ffmpeg_mux.c | |
parent | c803b36b8f5c8fa73ab2e77490d284d906d4c44b (diff) | |
download | ffmpeg-96e1325d9152323cb6418df017da7aca99d59f78.tar.gz |
fftools/ffmpeg_mux: use a dedicated packet for BSF output
Currently of_output_packet() reuses the input packet, which requires its
callers to submit blank packets even on EOF, which makes the code more
complex.
Diffstat (limited to 'fftools/ffmpeg_mux.c')
-rw-r--r-- | fftools/ffmpeg_mux.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index dc2d189ff0..485f499971 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -351,7 +351,7 @@ void of_output_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int eof) } while (!bsf_eof) { - ret = av_bsf_receive_packet(ms->bsf_ctx, pkt); + ret = av_bsf_receive_packet(ms->bsf_ctx, ms->bsf_pkt); if (ret == AVERROR(EAGAIN)) return; else if (ret == AVERROR_EOF) @@ -361,7 +361,7 @@ void of_output_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int eof) goto fail; } - ret = submit_packet(mux, bsf_eof ? NULL : pkt, ost); + ret = submit_packet(mux, bsf_eof ? NULL : ms->bsf_pkt, ost); if (ret < 0) goto mux_fail; } @@ -656,6 +656,10 @@ static int bsf_init(MuxStream *ms) return ret; ost->st->time_base = ctx->time_base_out; + ms->bsf_pkt = av_packet_alloc(); + if (!ms->bsf_pkt) + return AVERROR(ENOMEM); + return 0; } @@ -856,6 +860,7 @@ static void ost_free(OutputStream **post) avcodec_parameters_free(&ost->par_in); av_bsf_free(&ms->bsf_ctx); + av_packet_free(&ms->bsf_pkt); av_packet_free(&ost->pkt); av_dict_free(&ost->encoder_opts); |