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 E01BA4669B for ; Wed, 31 May 2023 14:58:32 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 830E368C324; Wed, 31 May 2023 17:55:35 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 85D8068C2B4 for ; Wed, 31 May 2023 17:55:13 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 481BD240177 for ; Wed, 31 May 2023 16:55:13 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ylGoT8BtB10C for ; Wed, 31 May 2023 16:55:12 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (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 "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 35275240D0E for ; Wed, 31 May 2023 16:55:06 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id BBA6D3A0D86 for ; Wed, 31 May 2023 16:55:00 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 31 May 2023 16:54:51 +0200 Message-Id: <20230531145453.20994-21-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230531145453.20994-1-anton@khirnov.net> References: <20230531145453.20994-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 21/23] fftools/ffmpeg_mux: simplify calling of_output_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: Use NULL packets to signal EOF instead of a separate variable. This is made possible by the previous commit. --- fftools/ffmpeg.c | 2 +- fftools/ffmpeg.h | 13 +------------ fftools/ffmpeg_enc.c | 6 +++--- fftools/ffmpeg_mux.c | 14 +++++++------- 4 files changed, 12 insertions(+), 23 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 462365ed02..79baceb1fc 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1104,7 +1104,7 @@ static int process_input(int file_index) for (int oidx = 0; oidx < ist->nb_outputs; oidx++) { OutputStream *ost = ist->outputs[oidx]; OutputFile *of = output_files[ost->file_index]; - of_output_packet(of, ost->pkt, ost, 1); + of_output_packet(of, ost, NULL); } } diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 49c07ede95..890081edb4 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -844,18 +844,7 @@ void of_close(OutputFile **pof); void of_enc_stats_close(void); -/* - * Send a single packet to the output, applying any bitstream filters - * associated with the output stream. This may result in any number - * of packets actually being written, depending on what bitstream - * filters are applied. The supplied packet is consumed and will be - * blank (as if newly-allocated) when this function returns. - * - * If eof is set, instead indicate EOF to all bitstream filters and - * therefore flush any delayed packets to the output. A blank packet - * must be supplied in this case. - */ -void of_output_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int eof); +void of_output_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt); /** * @param dts predicted packet dts in AV_TIME_BASE_Q diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 1515ca971f..8dd8104cea 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -531,7 +531,7 @@ void enc_subtitle(OutputFile *of, OutputStream *ost, AVSubtitle *sub) } pkt->dts = pkt->pts; - of_output_packet(of, pkt, ost, 0); + of_output_packet(of, ost, pkt); } } @@ -718,7 +718,7 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame) av_assert0(frame); // should never happen during flushing return 0; } else if (ret == AVERROR_EOF) { - of_output_packet(of, pkt, ost, 1); + of_output_packet(of, ost, NULL); return ret; } else if (ret < 0) { av_log(ost, AV_LOG_ERROR, "%s encoding failed\n", type_desc); @@ -752,7 +752,7 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame) e->packets_encoded++; - of_output_packet(of, pkt, ost, 0); + of_output_packet(of, ost, pkt); } av_assert0(0); diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 485f499971..879a291ba9 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -324,18 +324,18 @@ static int submit_packet(Muxer *mux, AVPacket *pkt, OutputStream *ost) return 0; } -void of_output_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int eof) +void of_output_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt) { Muxer *mux = mux_from_of(of); MuxStream *ms = ms_from_ost(ost); const char *err_msg; int ret = 0; - if (!eof && pkt->dts != AV_NOPTS_VALUE) + if (pkt && pkt->dts != AV_NOPTS_VALUE) ost->last_mux_dts = av_rescale_q(pkt->dts, pkt->time_base, AV_TIME_BASE_Q); /* rescale timestamps to the muxing timebase */ - if (!eof) { + if (pkt) { av_packet_rescale_ts(pkt, pkt->time_base, ost->mux_timebase); pkt->time_base = ost->mux_timebase; } @@ -344,7 +344,7 @@ void of_output_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int eof) if (ms->bsf_ctx) { int bsf_eof = 0; - ret = av_bsf_send_packet(ms->bsf_ctx, eof ? NULL : pkt); + ret = av_bsf_send_packet(ms->bsf_ctx, pkt); if (ret < 0) { err_msg = "submitting a packet for bitstream filtering"; goto fail; @@ -366,7 +366,7 @@ void of_output_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int eof) goto mux_fail; } } else { - ret = submit_packet(mux, eof ? NULL : pkt, ost); + ret = submit_packet(mux, pkt, ost); if (ret < 0) goto mux_fail; } @@ -399,7 +399,7 @@ void of_streamcopy(OutputStream *ost, const AVPacket *pkt, int64_t dts) // EOF: flush output bitstream filters. if (!pkt) { - of_output_packet(of, opkt, ost, 1); + of_output_packet(of, ost, NULL); return; } @@ -453,7 +453,7 @@ void of_streamcopy(OutputStream *ost, const AVPacket *pkt, int64_t dts) } } - of_output_packet(of, opkt, ost, 0); + of_output_packet(of, ost, opkt); ms->streamcopy_started = 1; } -- 2.40.1 _______________________________________________ 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".