Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Anton Khirnov <anton@khirnov.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 21/22] fftools/ffmpeg_mux: move bsf_ctx from OutputStream to MuxStream
Date: Fri, 14 Oct 2022 12:15:47 +0200
Message-ID: <20221014101548.3486-8-anton@khirnov.net> (raw)
In-Reply-To: <20221014101548.3486-1-anton@khirnov.net>

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);
-- 
2.35.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".

  parent reply	other threads:[~2022-10-14 10:19 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-13 13:48 [FFmpeg-devel] [PATCH 01/13] fftools/ffmpeg_mux: do not unref a NULL packet Anton Khirnov
2022-10-13 13:48 ` [FFmpeg-devel] [PATCH 02/13] fftools/ffmpeg: move output_packet() to ffmpeg_mux Anton Khirnov
2022-10-13 13:48 ` [FFmpeg-devel] [PATCH 03/13] fftools/ffmpeg_mux: rename submit_packet() to thread_submit_packet() Anton Khirnov
2022-10-13 13:48 ` [FFmpeg-devel] [PATCH 04/13] fftools/ffmpeg_mux: drop the of_ prefix from of_submit_packet() Anton Khirnov
2022-10-13 13:48 ` [FFmpeg-devel] [PATCH 05/13] fftools/ffmpeg: move some stream initialization code to ffmpeg_mux Anton Khirnov
2022-10-13 13:48 ` [FFmpeg-devel] [PATCH 06/13] fftools/ffmpeg_opt: move opening output files into a new file Anton Khirnov
2022-10-13 13:48 ` [FFmpeg-devel] [PATCH 07/13] fftools/ffmpeg_mux: move Muxer and MuxStream to a new header Anton Khirnov
2022-10-13 13:48 ` [FFmpeg-devel] [PATCH 08/13] fftools/ffmpeg_mux: embed OutputFile in a Muxer Anton Khirnov
2022-10-13 13:49 ` [FFmpeg-devel] [PATCH 09/13] fftools/ffmpeg_mux: allocate sq_pkt in setup_sync_queues() Anton Khirnov
2022-10-13 13:49 ` [FFmpeg-devel] [PATCH 10/13] fftools/ffmpeg_mux: inline of_muxer_init() into of_open() Anton Khirnov
2022-10-13 13:49 ` [FFmpeg-devel] [PATCH 11/13] fftools/ffmpeg_mux: inline mux_free() into of_close() Anton Khirnov
2022-10-13 13:49 ` [FFmpeg-devel] [PATCH 12/13] fftools/ffmpeg_mux: move sq_mux from OutputFile to Muxer Anton Khirnov
2022-10-13 13:49 ` [FFmpeg-devel] [PATCH 13/13] fftools/ffmpeg: move init_output_bsfs() to ffmpeg_mux Anton Khirnov
2022-10-14 10:15 ` [FFmpeg-devel] [PATCH 14/22] fftools/ffmpeg: move freeing an output stream into a separate function Anton Khirnov
2022-10-14 10:15   ` [FFmpeg-devel] [PATCH 15/22] fftools/ffmpeg: reindent after previous commit Anton Khirnov
2022-10-14 10:15   ` [FFmpeg-devel] [PATCH 16/22] fftools/ffmpeg_mux_init: pass Muxer to new_output_stream() Anton Khirnov
2022-10-14 10:15   ` [FFmpeg-devel] [PATCH 17/22] fftools/ffmpeg: remove the output_streams global Anton Khirnov
2022-10-14 10:15   ` [FFmpeg-devel] [PATCH 18/22] fftools/ffmpeg: remove a cleanup block at the end of transcode() Anton Khirnov
2022-10-14 10:15   ` [FFmpeg-devel] [PATCH 19/22] fftools/ffmpeg: free output streams in of_close() Anton Khirnov
2022-10-14 10:15   ` [FFmpeg-devel] [PATCH 20/22] fftools/ffmpeg_mux: embed OutputStream in a MuxStream Anton Khirnov
2022-10-14 10:15   ` Anton Khirnov [this message]
2022-10-14 10:15   ` [FFmpeg-devel] [PATCH 22/22] fftools/ffmpeg_mux: move muxing queue fields from OutputStream to MuxStream Anton Khirnov
2022-10-17  8:49 ` [FFmpeg-devel] [PATCH 01/13] fftools/ffmpeg_mux: do not unref a NULL packet Anton Khirnov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221014101548.3486-8-anton@khirnov.net \
    --to=anton@khirnov.net \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git