From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id A0DCC422EA for ; Fri, 17 Dec 2021 10:54:51 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 62B5A68A569; Fri, 17 Dec 2021 12:54:48 +0200 (EET) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C687E680BA3 for ; Fri, 17 Dec 2021 12:54:41 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 5BF9924017C for ; Fri, 17 Dec 2021 11:54:41 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ClnJaPJeHQdF for ; Fri, 17 Dec 2021 11:54:40 +0100 (CET) Received: from lain.red.khirnov.net (lain.red.khirnov.net [IPv6:2001:67c:1138:4306::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "lain.red.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 013B5240179 for ; Fri, 17 Dec 2021 11:54:39 +0100 (CET) Received: by lain.red.khirnov.net (Postfix, from userid 1000) id 139E716008E; Fri, 17 Dec 2021 11:54:39 +0100 (CET) From: Anton Khirnov To: FFmpeg development discussions and patches In-Reply-To: =?utf-8?q?=3CAM7PR03MB66606198C914F32634746BDE8F779=40AM7PR03MB?= =?utf-8?q?6660=2Eeurprd03=2Eprod=2Eoutlook=2Ecom=3E?= References: <20211213152042.5900-1-anton@khirnov.net> <20211213152042.5900-21-anton@khirnov.net> =?utf-8?q?=3CAM7PR03MB66606198C9?= =?utf-8?q?14F32634746BDE8F779=40AM7PR03MB6660=2Eeurprd03=2Eprod=2Eoutlook?= =?utf-8?q?=2Ecom=3E?= Mail-Followup-To: FFmpeg development discussions and patches Date: Fri, 17 Dec 2021 11:54:39 +0100 Message-ID: <163973847995.13029.3661988046296246615@lain.red.khirnov.net> User-Agent: alot/0.8.1 MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH 21/24] ffmpeg_mux: split of_write_packet() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Quoting Andreas Rheinhardt (2021-12-17 00:42:25) > Anton Khirnov: > > diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c > > index d4b674c9e2..e97ec8ab93 100644 > > --- a/fftools/ffmpeg_mux.c > > +++ b/fftools/ffmpeg_mux.c > > @@ -102,39 +102,12 @@ static int queue_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt) > > return 0; > > } > > > > -void of_write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, > > - int unqueue) > > +static void write_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt) > > { > > AVFormatContext *s = of->ctx; > > AVStream *st = ost->st; > > int ret; > > > > - /* > > - * Audio encoders may split the packets -- #frames in != #packets out. > > - * But there is no reordering, so we can limit the number of output packets > > - * by simply dropping them here. > > - * Counting encoded video frames needs to be done separately because of > > - * reordering, see do_video_out(). > > - * Do not count the packet when unqueued because it has been counted when queued. > > - */ > > - if (!(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->encoding_needed) && !unqueue) { > > - if (ost->frame_number >= ost->max_frames) { > > - av_packet_unref(pkt); > > - return; > > - } > > - ost->frame_number++; > > - } > > Factoring this chunk out of write_packet() (effectively inlining > unqueue) looks good (and I actually pondered it myself), > > > - > > - /* the muxer is not initialized yet, buffer the packet */ > > - if (!of->mux->header_written) { > > - ret = queue_packet(of, ost, pkt); > > - if (ret < 0) { > > - av_packet_unref(pkt); > > - exit_program(1); > > - } > > - return; > > - } > > - > > but I could not prove that the header has already been written in case > unqueue == 0. Can you guarantee this to be so and explain it to me? I don't understand what you mean. unqueue == 0 in the current code tells you nothing about whether the header has been written. How does that relate to the patch? -- Anton Khirnov _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".