From patchwork Fri Oct 14 10:15:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 38737 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4a86:b0:9d:28a3:170e with SMTP id fn6csp244545pzb; Fri, 14 Oct 2022 03:19:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5LZ6kI8hwwowAfsCsFv6/taKPI8CgEVY3DpwEIxRwDEwlWHw7k5wYJyxSo1SQuEZ/1Fl5+ X-Received: by 2002:a17:907:a047:b0:78d:9b73:79bb with SMTP id gz7-20020a170907a04700b0078d9b7379bbmr2945375ejc.657.1665742769558; Fri, 14 Oct 2022 03:19:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665742769; cv=none; d=google.com; s=arc-20160816; b=JGPSZgnHwKBeNwkMyZf4O30XHHZ+f4MTtkp7ZFqUFVDGSvOnkX7zRaZc2YM1KWA5Co DmwL6af2q7cZb5VvHLyjqN12fZM0aSnybhJyEgkXkfVQpFteXKsHY+3Sv51P5OW8Z8Ky pTymt1gvyKFM7SBSyx+SP+8We1VzDKizNcvA7OKiokChYg6Lp/AXwmLdb3xKs7+YsFpr nSPOXcB/CyqPGsvIWQT0I27Ie2pdUCrP9IXnd+xXF/eOmMIIOsI4YqFoyPTUo0y5KrNz WqpBE4LBuQ4zT0NBckC69e94gaPPGCQyK554hRqbxT83lcahY5pObe15AX+PavWnJesj 3WYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=vlPNksXyXlUTg+xuYnxtFY8MKDeL8u0LePImOboZfOw=; b=OuLzBY9iQJmh2e5KVc7wHoSeqRq3yC0IeIOwN06VXKsWt4BpI3flLjhzp7d3y4nXOQ cJKGK/VGbcwYwvL9EbtkFfJru3MiO12aNL3VardEVfD/eehwzg3ml+ulEzbQL4Mw3Yzz zVIss4lyywMoA1rx7cz5w5gjUGaDWnRnAGRn957djMrJdRYItf0l1slW+DFNL5Uk7b9p VLAEVaX64Bu9RUxx4p0OoIGXHNLwYzrFEHxAZz7QdfnypWL3Xusdem49v7mpWQ0hDdWF fMf31fyxaKpVME9yCpDjcSttbYSrrnRA4+t0h4vO/D0JWAtRKku2JNMWwCD9xIBJlv1T 8N1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id dt18-20020a170907729200b0078de51e1c21si2014441ejc.845.2022.10.14.03.19.29; Fri, 14 Oct 2022 03:19:29 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5774D68BDD4; Fri, 14 Oct 2022 13:18:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F1F7668BDA1 for ; Fri, 14 Oct 2022 13:18:30 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 5340A240591 for ; Fri, 14 Oct 2022 12:18:29 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id hiCJdMn-j1hS for ; Fri, 14 Oct 2022 12:18:28 +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 F20992405EC for ; Fri, 14 Oct 2022 12:18:24 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 2E1043A17F4 for ; Fri, 14 Oct 2022 12:18:24 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 14 Oct 2022 12:15:47 +0200 Message-Id: <20221014101548.3486-8-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221014101548.3486-1-anton@khirnov.net> References: <20221013134904.10104-1-anton@khirnov.net> <20221014101548.3486-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 21/22] fftools/ffmpeg_mux: move bsf_ctx from OutputStream to MuxStream 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Ie9Na/q/IIYt It is private to the muxer and does not need to be visible outside of it. --- fftools/ffmpeg.h | 2 -- fftools/ffmpeg_mux.c | 17 ++++++++++------- fftools/ffmpeg_mux.h | 2 ++ fftools/ffmpeg_mux_init.c | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 0af824b9b9..b98bb45331 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -510,8 +510,6 @@ typedef struct OutputStream { AVRational mux_timebase; AVRational enc_timebase; - AVBSFContext *bsf_ctx; - AVCodecContext *enc_ctx; int64_t max_frames; AVFrame *filtered_frame; diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 4ad69a149a..525c15b4ae 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -318,6 +318,7 @@ static int submit_packet(Muxer *mux, AVPacket *pkt, OutputStream *ost) void of_output_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int eof) { Muxer *mux = mux_from_of(of); + MuxStream *ms = ms_from_ost(ost); const char *err_msg; int ret = 0; @@ -325,17 +326,17 @@ void of_output_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int eof) ost->last_mux_dts = av_rescale_q(pkt->dts, ost->mux_timebase, AV_TIME_BASE_Q); /* apply the output bitstream filters */ - if (ost->bsf_ctx) { + if (ms->bsf_ctx) { int bsf_eof = 0; - ret = av_bsf_send_packet(ost->bsf_ctx, eof ? NULL : pkt); + ret = av_bsf_send_packet(ms->bsf_ctx, eof ? NULL : pkt); if (ret < 0) { err_msg = "submitting a packet for bitstream filtering"; goto fail; } while (!bsf_eof) { - ret = av_bsf_receive_packet(ost->bsf_ctx, pkt); + ret = av_bsf_receive_packet(ms->bsf_ctx, pkt); if (ret == AVERROR(EAGAIN)) return; else if (ret == AVERROR_EOF) @@ -541,9 +542,10 @@ int mux_check_init(Muxer *mux) return 0; } -static int bsf_init(OutputStream *ost) +static int bsf_init(MuxStream *ms) { - AVBSFContext *ctx = ost->bsf_ctx; + OutputStream *ost = &ms->ost; + AVBSFContext *ctx = ms->bsf_ctx; int ret; if (!ctx) @@ -573,6 +575,7 @@ static int bsf_init(OutputStream *ost) int of_stream_init(OutputFile *of, OutputStream *ost) { Muxer *mux = mux_from_of(of); + MuxStream *ms = ms_from_ost(ost); int ret; if (ost->sq_idx_mux >= 0) @@ -581,7 +584,7 @@ int of_stream_init(OutputFile *of, OutputStream *ost) /* initialize bitstream filters for the output stream * needs to be done here, because the codec id for streamcopy is not * known until now */ - ret = bsf_init(ost); + ret = bsf_init(ms); if (ret < 0) return ret; @@ -652,7 +655,7 @@ static void ost_free(OutputStream **post) av_fifo_freep2(&ms->muxing_queue); } - av_bsf_free(&ost->bsf_ctx); + av_bsf_free(&ms->bsf_ctx); av_frame_free(&ost->filtered_frame); av_frame_free(&ost->sq_frame); diff --git a/fftools/ffmpeg_mux.h b/fftools/ffmpeg_mux.h index 45daeb3591..8470f971cc 100644 --- a/fftools/ffmpeg_mux.h +++ b/fftools/ffmpeg_mux.h @@ -40,6 +40,8 @@ typedef struct MuxStream { /* the packets are buffered here until the muxer is ready to be initialized */ AVFifo *muxing_queue; + AVBSFContext *bsf_ctx; + /* * The size of the AVPackets' buffers in queue. * Updated when a packet is either pushed or pulled from the queue. diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index d6bae92513..3f2db04f52 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -304,7 +304,7 @@ static OutputStream *new_output_stream(Muxer *mux, OptionsContext *o, MATCH_PER_STREAM_OPT(bitstream_filters, str, bsfs, oc, st); if (bsfs && *bsfs) { - ret = av_bsf_list_parse_str(bsfs, &ost->bsf_ctx); + ret = av_bsf_list_parse_str(bsfs, &ms->bsf_ctx); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error parsing bitstream filter sequence '%s': %s\n", bsfs, av_err2str(ret)); exit_program(1);