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 12/15] fftools/ffmpeg: add InputStream.index
Date: Tue, 23 May 2023 15:58:39 +0200
Message-ID: <20230523135842.20388-12-anton@khirnov.net> (raw)
In-Reply-To: <20230523135842.20388-1-anton@khirnov.net>

This allows to avoid access to the underlying AVStream in many places.
---
 fftools/ffmpeg.c          |  6 +++---
 fftools/ffmpeg.h          |  2 ++
 fftools/ffmpeg_dec.c      |  6 +++---
 fftools/ffmpeg_demux.c    |  1 +
 fftools/ffmpeg_filter.c   | 10 +++++-----
 fftools/ffmpeg_mux_init.c |  2 +-
 6 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 1fc13b3e29..0539a45856 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -539,7 +539,7 @@ OutputStream *ost_iter(OutputStream *prev)
 InputStream *ist_iter(InputStream *prev)
 {
     int if_idx  = prev ? prev->file_index : 0;
-    int ist_idx = prev ? prev->st->index + 1  : 0;
+    int ist_idx = prev ? prev->index + 1  : 0;
 
     for (; if_idx < nb_input_files; if_idx++) {
         InputFile *f = input_files[if_idx];
@@ -937,7 +937,7 @@ static void print_stream_maps(void)
         for (int j = 0; j < ist->nb_filters; j++) {
             if (!filtergraph_is_simple(ist->filters[j]->graph)) {
                 av_log(NULL, AV_LOG_INFO, "  Stream #%d:%d (%s) -> %s",
-                       ist->file_index, ist->st->index, ist->dec ? ist->dec->name : "?",
+                       ist->file_index, ist->index, ist->dec ? ist->dec->name : "?",
                        ist->filters[j]->name);
                 if (nb_filtergraphs > 1)
                     av_log(NULL, AV_LOG_INFO, " (graph %d)", ist->filters[j]->graph->index);
@@ -967,7 +967,7 @@ static void print_stream_maps(void)
 
         av_log(NULL, AV_LOG_INFO, "  Stream #%d:%d -> #%d:%d",
                ost->ist->file_index,
-               ost->ist->st->index,
+               ost->ist->index,
                ost->file_index,
                ost->index);
         if (ost->enc_ctx) {
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index d9cac95710..95334825ef 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -330,6 +330,8 @@ typedef struct InputStream {
     const AVClass *class;
 
     int file_index;
+    int index;
+
     AVStream *st;
     int discard;             /* true if stream data should be discarded */
     int user_set_discard;
diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index c952473c16..afb2612ae8 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -470,7 +470,7 @@ int dec_packet(InputStream *ist, const AVPacket *pkt, int no_eof)
         update_benchmark(NULL);
         ret = avcodec_receive_frame(dec, frame);
         update_benchmark("decode_%s %d.%d", type_desc,
-                         ist->file_index, ist->st->index);
+                         ist->file_index, ist->index);
 
         if (ret == AVERROR(EAGAIN)) {
             av_assert0(pkt); // should never happen during flushing
@@ -528,7 +528,7 @@ int dec_packet(InputStream *ist, const AVPacket *pkt, int no_eof)
             ret = video_frame_process(ist, frame);
             if (ret < 0) {
                 av_log(NULL, AV_LOG_FATAL, "Error while processing the decoded "
-                       "data for stream #%d:%d\n", ist->file_index, ist->st->index);
+                       "data for stream #%d:%d\n", ist->file_index, ist->index);
                 exit_program(1);
             }
         }
@@ -577,7 +577,7 @@ static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat
                            "%s hwaccel requested for input stream #%d:%d, "
                            "but cannot be initialized.\n",
                            av_hwdevice_get_type_name(config->device_type),
-                           ist->file_index, ist->st->index);
+                           ist->file_index, ist->index);
                     return AV_PIX_FMT_NONE;
                 }
                 continue;
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index e02bdc3b96..828a1182f0 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -1025,6 +1025,7 @@ static DemuxStream *demux_stream_alloc(Demuxer *d, AVStream *st)
 
     ds->ist.st         = st;
     ds->ist.file_index = f->index;
+    ds->ist.index      = st->index;
     ds->ist.class      = &input_stream_class;
 
     snprintf(ds->log_name, sizeof(ds->log_name), "%cist#%d:%d/%s",
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 640ecec067..f37b867b31 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1073,7 +1073,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
     if (fr.num && fr.den)
         av_bprintf(&args, ":frame_rate=%d/%d", fr.num, fr.den);
     snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index,
-             ist->file_index, ist->st->index);
+             ist->file_index, ist->index);
 
 
     if ((ret = avfilter_graph_create_filter(&ifilter->filter, buffer_filt, name,
@@ -1127,7 +1127,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
     }
 
     snprintf(name, sizeof(name), "trim_in_%d_%d",
-             ist->file_index, ist->st->index);
+             ist->file_index, ist->index);
     if (copy_ts) {
         tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time;
         if (!start_at_zero && f->ctx->start_time != AV_NOPTS_VALUE)
@@ -1180,7 +1180,7 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
     } else
         av_bprintf(&args, ":channels=%d", ifp->ch_layout.nb_channels);
     snprintf(name, sizeof(name), "graph_%d_in_%d_%d", fg->index,
-             ist->file_index, ist->st->index);
+             ist->file_index, ist->index);
 
     if ((ret = avfilter_graph_create_filter(&ifilter->filter, abuffer_filt,
                                             name, args.str, NULL,
@@ -1189,7 +1189,7 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
     last_filter = ifilter->filter;
 
     snprintf(name, sizeof(name), "trim for input stream %d:%d",
-             ist->file_index, ist->st->index);
+             ist->file_index, ist->index);
     if (copy_ts) {
         tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time;
         if (!start_at_zero && f->ctx->start_time != AV_NOPTS_VALUE)
@@ -1574,7 +1574,7 @@ int ifilter_send_eof(InputFilter *ifilter, int64_t pts, AVRational tb)
              ifp->type_src == AVMEDIA_TYPE_VIDEO)) {
             av_log(NULL, AV_LOG_ERROR,
                    "Cannot determine format of input stream %d:%d after EOF\n",
-                   ifp->ist->file_index, ifp->ist->st->index);
+                   ifp->ist->file_index, ifp->ist->index);
             return AVERROR_INVALIDDATA;
         }
     }
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 56f9d1215c..dc33d225df 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -792,7 +792,7 @@ static void new_stream_audio(Muxer *mux, const OptionsContext *o,
                     ist = ost->ist;
                 }
 
-                if (!ist || (ist->file_index == map->file_idx && ist->st->index == map->stream_idx)) {
+                if (!ist || (ist->file_index == map->file_idx && ist->index == map->stream_idx)) {
                     if (av_reallocp_array(&ost->audio_channels_map,
                                           ost->audio_channels_mapped + 1,
                                           sizeof(*ost->audio_channels_map)
-- 
2.39.2

_______________________________________________
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:[~2023-05-23 14:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-23 13:58 [FFmpeg-devel] [PATCH 01/15] fftools/ffmpeg_hw: move hw_device_setup_for_decode() to ffmpeg_dec Anton Khirnov
2023-05-23 13:58 ` [FFmpeg-devel] [PATCH 02/15] fftools/ffmpeg_hw: move hw_device_setup_for_encode() to ffmpeg_enc Anton Khirnov
2023-05-23 13:58 ` [FFmpeg-devel] [PATCH 03/15] fftools/ffmpeg_enc: use AVFrame.hw_frames_ctx for encoder hw setup Anton Khirnov
2023-05-23 13:58 ` [FFmpeg-devel] [PATCH 04/15] fftools/ffmpeg: fail earlier on text/bitmap subtitles mismatch Anton Khirnov
2023-05-23 13:58 ` [FFmpeg-devel] [PATCH 05/15] fftools/ffmpeg: drop outdated comments Anton Khirnov
2023-05-23 13:58 ` [FFmpeg-devel] [PATCH 06/15] fftools/ffmpeg_demux: only print demuxing stats if demuxing actually started Anton Khirnov
2023-05-23 13:58 ` [FFmpeg-devel] [PATCH 07/15] fftools/ffmpeg_demux: initialize nb_streams_warn Anton Khirnov
2023-05-23 13:58 ` [FFmpeg-devel] [PATCH 08/15] fftools/ffmpeg_demux: skip unused/attachment streams in final stats Anton Khirnov
2023-05-23 13:58 ` [FFmpeg-devel] [PATCH 09/15] fftools/ffmpeg_dec: add decoder private data Anton Khirnov
2023-05-23 13:58 ` [FFmpeg-devel] [PATCH 10/15] fftools/ffmpeg_dec: move InputStream.pkt to Decoder Anton Khirnov
2023-05-23 13:58 ` [FFmpeg-devel] [PATCH 11/15] fftools/ffmpeg_dec: move timestamp estimation state " Anton Khirnov
2023-05-23 13:58 ` Anton Khirnov [this message]
2023-05-23 13:58 ` [FFmpeg-devel] [PATCH 13/15] fftools/ffmpeg_demux: log discontinuity warnings to stream context Anton Khirnov
2023-05-23 13:58 ` [FFmpeg-devel] [PATCH 14/15] fftools/sync_queue: add debug logging Anton Khirnov
2023-05-23 13:58 ` [FFmpeg-devel] [PATCH 15/15] fftools/sync_queue: make sure non-limiting streams are not used as queue head Anton Khirnov
2023-05-24 12:01   ` James Almer

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=20230523135842.20388-12-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