mirror of
https://github.com/nyanmisaka/ffmpeg-rockchip.git
synced 2025-10-19 23:26:14 +08:00
fftools/ffmpeg: free output streams in of_close()
Output streams are now children of OutputFile, so it makes more sense to free them there.
This commit is contained in:
@@ -502,52 +502,6 @@ static int decode_interrupt_cb(void *ctx)
|
|||||||
|
|
||||||
const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL };
|
const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL };
|
||||||
|
|
||||||
static void ost_free(OutputStream **post)
|
|
||||||
{
|
|
||||||
OutputStream *ost = *post;
|
|
||||||
|
|
||||||
if (!ost)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (ost->logfile) {
|
|
||||||
if (fclose(ost->logfile))
|
|
||||||
av_log(NULL, AV_LOG_ERROR,
|
|
||||||
"Error closing logfile, loss of information possible: %s\n",
|
|
||||||
av_err2str(AVERROR(errno)));
|
|
||||||
ost->logfile = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
av_bsf_free(&ost->bsf_ctx);
|
|
||||||
|
|
||||||
av_frame_free(&ost->filtered_frame);
|
|
||||||
av_frame_free(&ost->sq_frame);
|
|
||||||
av_frame_free(&ost->last_frame);
|
|
||||||
av_packet_free(&ost->pkt);
|
|
||||||
av_dict_free(&ost->encoder_opts);
|
|
||||||
|
|
||||||
av_freep(&ost->forced_keyframes);
|
|
||||||
av_expr_free(ost->forced_keyframes_pexpr);
|
|
||||||
av_freep(&ost->avfilter);
|
|
||||||
av_freep(&ost->logfile_prefix);
|
|
||||||
av_freep(&ost->forced_kf_pts);
|
|
||||||
av_freep(&ost->apad);
|
|
||||||
av_freep(&ost->disposition);
|
|
||||||
|
|
||||||
#if FFMPEG_OPT_MAP_CHANNEL
|
|
||||||
av_freep(&ost->audio_channels_map);
|
|
||||||
ost->audio_channels_mapped = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
av_dict_free(&ost->sws_dict);
|
|
||||||
av_dict_free(&ost->swr_opts);
|
|
||||||
|
|
||||||
if (ost->enc_ctx)
|
|
||||||
av_freep(&ost->enc_ctx->stats_in);
|
|
||||||
avcodec_free_context(&ost->enc_ctx);
|
|
||||||
|
|
||||||
av_freep(post);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ffmpeg_cleanup(int ret)
|
static void ffmpeg_cleanup(int ret)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
@@ -598,15 +552,8 @@ static void ffmpeg_cleanup(int ret)
|
|||||||
av_freep(&filtergraphs);
|
av_freep(&filtergraphs);
|
||||||
|
|
||||||
/* close files */
|
/* close files */
|
||||||
for (i = 0; i < nb_output_files; i++) {
|
for (i = 0; i < nb_output_files; i++)
|
||||||
OutputFile *of = output_files[i];
|
|
||||||
|
|
||||||
for (int j = 0; j < of->nb_streams; j++)
|
|
||||||
ost_free(&of->streams[j]);
|
|
||||||
av_freep(&of->streams);
|
|
||||||
|
|
||||||
of_close(&output_files[i]);
|
of_close(&output_files[i]);
|
||||||
}
|
|
||||||
|
|
||||||
free_input_threads();
|
free_input_threads();
|
||||||
for (i = 0; i < nb_input_files; i++) {
|
for (i = 0; i < nb_input_files; i++) {
|
||||||
|
@@ -623,6 +623,52 @@ int of_write_trailer(OutputFile *of)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ost_free(OutputStream **post)
|
||||||
|
{
|
||||||
|
OutputStream *ost = *post;
|
||||||
|
|
||||||
|
if (!ost)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (ost->logfile) {
|
||||||
|
if (fclose(ost->logfile))
|
||||||
|
av_log(NULL, AV_LOG_ERROR,
|
||||||
|
"Error closing logfile, loss of information possible: %s\n",
|
||||||
|
av_err2str(AVERROR(errno)));
|
||||||
|
ost->logfile = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
av_bsf_free(&ost->bsf_ctx);
|
||||||
|
|
||||||
|
av_frame_free(&ost->filtered_frame);
|
||||||
|
av_frame_free(&ost->sq_frame);
|
||||||
|
av_frame_free(&ost->last_frame);
|
||||||
|
av_packet_free(&ost->pkt);
|
||||||
|
av_dict_free(&ost->encoder_opts);
|
||||||
|
|
||||||
|
av_freep(&ost->forced_keyframes);
|
||||||
|
av_expr_free(ost->forced_keyframes_pexpr);
|
||||||
|
av_freep(&ost->avfilter);
|
||||||
|
av_freep(&ost->logfile_prefix);
|
||||||
|
av_freep(&ost->forced_kf_pts);
|
||||||
|
av_freep(&ost->apad);
|
||||||
|
av_freep(&ost->disposition);
|
||||||
|
|
||||||
|
#if FFMPEG_OPT_MAP_CHANNEL
|
||||||
|
av_freep(&ost->audio_channels_map);
|
||||||
|
ost->audio_channels_mapped = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
av_dict_free(&ost->sws_dict);
|
||||||
|
av_dict_free(&ost->swr_opts);
|
||||||
|
|
||||||
|
if (ost->enc_ctx)
|
||||||
|
av_freep(&ost->enc_ctx->stats_in);
|
||||||
|
avcodec_free_context(&ost->enc_ctx);
|
||||||
|
|
||||||
|
av_freep(post);
|
||||||
|
}
|
||||||
|
|
||||||
static void fc_close(AVFormatContext **pfc)
|
static void fc_close(AVFormatContext **pfc)
|
||||||
{
|
{
|
||||||
AVFormatContext *fc = *pfc;
|
AVFormatContext *fc = *pfc;
|
||||||
@@ -663,6 +709,11 @@ void of_close(OutputFile **pof)
|
|||||||
av_fifo_freep2(&ms->muxing_queue);
|
av_fifo_freep2(&ms->muxing_queue);
|
||||||
}
|
}
|
||||||
av_freep(&mux->streams);
|
av_freep(&mux->streams);
|
||||||
|
|
||||||
|
for (int i = 0; i < of->nb_streams; i++)
|
||||||
|
ost_free(&of->streams[i]);
|
||||||
|
av_freep(&of->streams);
|
||||||
|
|
||||||
av_dict_free(&mux->opts);
|
av_dict_free(&mux->opts);
|
||||||
|
|
||||||
av_packet_free(&mux->sq_pkt);
|
av_packet_free(&mux->sq_pkt);
|
||||||
|
Reference in New Issue
Block a user