X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffmpeg.c;h=fa907b4c45d309debdb19159e20794d518776759;hb=0744daa887cab007404388da9cba34149781c605;hp=8dd9c08452f765542efd6ce9c3c4a3f3481c3c69;hpb=3787495e1f2c2e2de333cf452021822c2655c8d0;p=ffmpeg diff --git a/ffmpeg.c b/ffmpeg.c index 8dd9c08452f..fa907b4c45d 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -483,6 +483,9 @@ static void ffmpeg_cleanup(int ret) av_freep(&ost->avfilter); av_freep(&ost->logfile_prefix); + av_freep(&ost->audio_channels_map); + ost->audio_channels_mapped = 0; + avcodec_free_context(&ost->enc_ctx); av_freep(&output_streams[i]); @@ -627,6 +630,8 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) a = AVERROR(ENOMEM); } if (a > 0) { + pkt->side_data = NULL; + pkt->side_data_elems = 0; av_free_packet(pkt); new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size, av_buffer_default_free, NULL, 0); @@ -2057,7 +2062,7 @@ out: } /* pkt = NULL means EOF (needed to flush decoder buffers) */ -static int output_packet(InputStream *ist, const AVPacket *pkt) +static int process_input_packet(InputStream *ist, const AVPacket *pkt) { int ret = 0, i; int got_output = 0; @@ -2066,7 +2071,7 @@ static int output_packet(InputStream *ist, const AVPacket *pkt) if (!ist->saw_first_ts) { ist->dts = ist->st->avg_frame_rate.num ? - ist->dec_ctx->has_b_frames * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0; ist->pts = 0; - if (pkt != NULL && pkt->pts != AV_NOPTS_VALUE && !ist->decoding_needed) { + if (pkt && pkt->pts != AV_NOPTS_VALUE && !ist->decoding_needed) { ist->dts += av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q); ist->pts = ist->dts; //unused but better to set it to a value thats not totally wrong } @@ -2078,7 +2083,7 @@ static int output_packet(InputStream *ist, const AVPacket *pkt) if (ist->next_pts == AV_NOPTS_VALUE) ist->next_pts = ist->pts; - if (pkt == NULL) { + if (!pkt) { /* EOF handling */ av_init_packet(&avpkt); avpkt.data = NULL; @@ -3340,7 +3345,7 @@ static int process_input(int file_index) for (i = 0; i < ifile->nb_streams; i++) { ist = input_streams[ifile->ist_index + i]; if (ist->decoding_needed) { - ret = output_packet(ist, NULL); + ret = process_input_packet(ist, NULL); if (ret>0) return 0; } @@ -3521,7 +3526,7 @@ static int process_input(int file_index) sub2video_heartbeat(ist, pkt.pts); - ret = output_packet(ist, &pkt); + ret = process_input_packet(ist, &pkt); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d: %s\n", ist->file_index, ist->st->index, av_err2str(ret)); @@ -3687,7 +3692,7 @@ static int transcode(void) for (i = 0; i < nb_input_streams; i++) { ist = input_streams[i]; if (!input_files[ist->file_index]->eof_reached && ist->decoding_needed) { - output_packet(ist, NULL); + process_input_packet(ist, NULL); } } flush_encoders();