From patchwork Sun Jan 5 13:14:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 17200 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 5B80D44B762 for ; Sun, 5 Jan 2020 15:14:37 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 448ED68AE58; Sun, 5 Jan 2020 15:14:37 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8E5EE68AC2D for ; Sun, 5 Jan 2020 15:14:30 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 57A93E3756; Sun, 5 Jan 2020 14:14:30 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wlCcIXb6wihE; Sun, 5 Jan 2020 14:14:28 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 46412E3769; Sun, 5 Jan 2020 14:14:28 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 5 Jan 2020 14:14:12 +0100 Message-Id: <20200105131413.22707-5-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200105131413.22707-1-cus@passwd.hu> References: <20200105131413.22707-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 5/6] avformat: remove more unneeded avio_flush() calls X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" These instances are simply redundant or present because avio_flush() used to be required before doing a seekback. That is no longer the case, aviobuf code does the flush automatically on seek. This only affects code which is either disabled for streaming IO contexts or does no seekbacks after the flush, so this change should have no adverse effect on streaming. Signed-off-by: Marton Balint --- libavformat/asfenc.c | 1 - libavformat/avienc.c | 1 - libavformat/gxfenc.c | 2 -- libavformat/segafilmenc.c | 2 -- libavformat/wavenc.c | 7 ------- 5 files changed, 13 deletions(-) diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c index d03cff91c0..8eaa9d40ce 100644 --- a/libavformat/asfenc.c +++ b/libavformat/asfenc.c @@ -1130,7 +1130,6 @@ static int asf_write_trailer(AVFormatContext *s) return ret; asf_write_index(s, asf->index_ptr, asf->maximum_packet, asf->next_start_sec); } - avio_flush(s->pb); if (asf->is_streamed || !(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) { put_chunk(s, 0x4524, 0, 0); /* end of stream */ diff --git a/libavformat/avienc.c b/libavformat/avienc.c index 23cc58ea76..d6cfb1b783 100644 --- a/libavformat/avienc.c +++ b/libavformat/avienc.c @@ -591,7 +591,6 @@ static void update_odml_entry(AVFormatContext *s, int stream_index, int64_t ix, int64_t pos; int au_byterate, au_ssize, au_scale; - avio_flush(pb); pos = avio_tell(pb); /* Updating one entry in the AVI OpenDML master index */ diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c index c9fb0dcd91..e09b8d7625 100644 --- a/libavformat/gxfenc.c +++ b/libavformat/gxfenc.c @@ -863,13 +863,11 @@ static int gxf_write_trailer(AVFormatContext *s) return ret; gxf_write_flt_packet(s); gxf_write_umf_packet(s); - avio_flush(pb); /* update duration in all map packets */ for (i = 1; i < gxf->map_offsets_nb; i++) { avio_seek(pb, gxf->map_offsets[i], SEEK_SET); if ((ret = gxf_write_map_packet(s, 1)) < 0) return ret; - avio_flush(pb); } avio_seek(pb, end, SEEK_SET); diff --git a/libavformat/segafilmenc.c b/libavformat/segafilmenc.c index f1048ff808..812d0ad64e 100644 --- a/libavformat/segafilmenc.c +++ b/libavformat/segafilmenc.c @@ -362,8 +362,6 @@ static int film_write_header(AVFormatContext *format_context) avio_wb32(pb, film->packet_count); - avio_flush(pb); - /* Finally, write out each packet's data to the header */ packet = film->start; while (packet != NULL) { diff --git a/libavformat/wavenc.c b/libavformat/wavenc.c index ea7573139c..f6f5710802 100644 --- a/libavformat/wavenc.c +++ b/libavformat/wavenc.c @@ -411,17 +411,13 @@ static int wav_write_trailer(AVFormatContext *s) int rf64 = 0; int ret = 0; - avio_flush(pb); - if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) { if (wav->write_peak != PEAK_ONLY && avio_tell(pb) - wav->data < UINT32_MAX) { ff_end_tag(pb, wav->data); - avio_flush(pb); } if (wav->write_peak && wav->peak_output) { ret = peak_write_chunk(s); - avio_flush(pb); } /* update file size */ @@ -433,8 +429,6 @@ static int wav_write_trailer(AVFormatContext *s) avio_seek(pb, 4, SEEK_SET); avio_wl32(pb, (uint32_t)(file_size - 8)); avio_seek(pb, file_size, SEEK_SET); - - avio_flush(pb); } else { av_log(s, AV_LOG_ERROR, "Filesize %"PRId64" invalid for wav, output file will be broken\n", @@ -454,7 +448,6 @@ static int wav_write_trailer(AVFormatContext *s) } else { avio_wl32(pb, number_of_samples); avio_seek(pb, file_size, SEEK_SET); - avio_flush(pb); } }