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 26/31] fftools/ffmpeg_dec: remove unnecessary InputStream arguments
Date: Wed, 24 Jan 2024 09:16:56 +0100
Message-ID: <20240124081702.4759-26-anton@khirnov.net> (raw)
In-Reply-To: <20240124081702.4759-1-anton@khirnov.net>

---
 fftools/ffmpeg_dec.c | 35 ++++++++++++++---------------------
 1 file changed, 14 insertions(+), 21 deletions(-)

diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index fd1c9ca609..98cde0a040 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -221,9 +221,8 @@ static void audio_ts_process(DecoderPriv *dp, AVFrame *frame)
     frame->time_base = tb_filter;
 }
 
-static int64_t video_duration_estimate(const InputStream *ist, const AVFrame *frame)
+static int64_t video_duration_estimate(const DecoderPriv *dp, const AVFrame *frame)
 {
-    const DecoderPriv    *dp = dp_from_dec(ist->decoder);
     const int  ts_unreliable = dp->flags & DECODER_FLAG_TS_UNRELIABLE;
     const int      fr_forced = dp->flags & DECODER_FLAG_FRAMERATE_FORCED;
     int64_t codec_duration = 0;
@@ -316,10 +315,8 @@ fail:
     return err;
 }
 
-static int video_frame_process(InputStream *ist, AVFrame *frame)
+static int video_frame_process(DecoderPriv *dp, AVFrame *frame)
 {
-    DecoderPriv *dp = dp_from_dec(ist->decoder);
-
 #if FFMPEG_OPT_TOP
     if (dp->flags & DECODER_FLAG_TOP_FIELD_FIRST) {
         av_log(dp, AV_LOG_WARNING, "-top is deprecated, use the setfield filter instead\n");
@@ -348,7 +345,7 @@ static int video_frame_process(InputStream *ist, AVFrame *frame)
                      dp->last_frame_pts + dp->last_frame_duration_est;
 
     // update timestamp history
-    dp->last_frame_duration_est = video_duration_estimate(ist, frame);
+    dp->last_frame_duration_est = video_duration_estimate(dp, frame);
     dp->last_frame_pts          = frame->pts;
     dp->last_frame_tb           = frame->time_base;
 
@@ -374,9 +371,8 @@ static int video_frame_process(InputStream *ist, AVFrame *frame)
     return 0;
 }
 
-static int process_subtitle(InputStream *ist, AVFrame *frame)
+static int process_subtitle(DecoderPriv *dp, AVFrame *frame)
 {
-    DecoderPriv *dp = dp_from_dec(ist->decoder);
     const AVSubtitle *subtitle = (AVSubtitle*)frame->buf[0]->data;
     int ret = 0;
 
@@ -418,9 +414,8 @@ static int process_subtitle(InputStream *ist, AVFrame *frame)
     return ret == AVERROR_EOF ? AVERROR_EXIT : ret;
 }
 
-static int fix_sub_duration_heartbeat(InputStream *ist, int64_t signal_pts)
+static int fix_sub_duration_heartbeat(DecoderPriv *dp, int64_t signal_pts)
 {
-    DecoderPriv *dp = dp_from_dec(ist->decoder);
     int ret = AVERROR_BUG;
     AVSubtitle *prev_subtitle = dp->sub_prev[0]->buf[0] ?
         (AVSubtitle*)dp->sub_prev[0]->buf[0]->data : NULL;
@@ -438,13 +433,12 @@ static int fix_sub_duration_heartbeat(InputStream *ist, int64_t signal_pts)
     subtitle = (AVSubtitle*)dp->sub_heartbeat->buf[0]->data;
     subtitle->pts = signal_pts;
 
-    return process_subtitle(ist, dp->sub_heartbeat);
+    return process_subtitle(dp, dp->sub_heartbeat);
 }
 
-static int transcode_subtitles(InputStream *ist, const AVPacket *pkt,
+static int transcode_subtitles(DecoderPriv *dp, const AVPacket *pkt,
                                AVFrame *frame)
 {
-    DecoderPriv *dp = dp_from_dec(ist->decoder);
     AVPacket *flush_pkt = NULL;
     AVSubtitle subtitle;
     int got_output;
@@ -458,8 +452,8 @@ static int transcode_subtitles(InputStream *ist, const AVPacket *pkt,
         ret = sch_dec_send(dp->sch, dp->sch_idx, frame);
         return ret == AVERROR_EOF ? AVERROR_EXIT : ret;
     } else if (pkt && (intptr_t)pkt->opaque == PKT_OPAQUE_FIX_SUB_DURATION) {
-        return fix_sub_duration_heartbeat(ist, av_rescale_q(pkt->pts, pkt->time_base,
-                                                            AV_TIME_BASE_Q));
+        return fix_sub_duration_heartbeat(dp, av_rescale_q(pkt->pts, pkt->time_base,
+                                                           AV_TIME_BASE_Q));
     }
 
     if (!pkt) {
@@ -497,18 +491,17 @@ static int transcode_subtitles(InputStream *ist, const AVPacket *pkt,
     frame->width  = dp->dec_ctx->width;
     frame->height = dp->dec_ctx->height;
 
-    return process_subtitle(ist, frame);
+    return process_subtitle(dp, frame);
 }
 
-static int packet_decode(InputStream *ist, AVPacket *pkt, AVFrame *frame)
+static int packet_decode(DecoderPriv *dp, AVPacket *pkt, AVFrame *frame)
 {
-    DecoderPriv *dp = dp_from_dec(ist->decoder);
     AVCodecContext *dec = dp->dec_ctx;
     const char *type_desc = av_get_media_type_string(dec->codec_type);
     int ret;
 
     if (dec->codec_type == AVMEDIA_TYPE_SUBTITLE)
-        return transcode_subtitles(ist, pkt, frame);
+        return transcode_subtitles(dp, pkt, frame);
 
     // With fate-indeo3-2, we're getting 0-sized packets before EOF for some
     // reason. This seems like a semi-critical bug. Don't trigger EOF, and
@@ -599,7 +592,7 @@ static int packet_decode(InputStream *ist, AVPacket *pkt, AVFrame *frame)
 
             audio_ts_process(dp, frame);
         } else {
-            ret = video_frame_process(ist, frame);
+            ret = video_frame_process(dp, frame);
             if (ret < 0) {
                 av_log(dp, AV_LOG_FATAL,
                        "Error while processing the decoded data\n");
@@ -678,7 +671,7 @@ void *decoder_thread(void *arg)
             av_log(dp, AV_LOG_VERBOSE, "Decoder thread received %s packet\n",
                    flush_buffers ? "flush" : "EOF");
 
-        ret = packet_decode(ist, have_data ? dt.pkt : NULL, dt.frame);
+        ret = packet_decode(dp, have_data ? dt.pkt : NULL, dt.frame);
 
         av_packet_unref(dt.pkt);
         av_frame_unref(dt.frame);
-- 
2.42.0

_______________________________________________
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:[~2024-01-24  8:20 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-24  8:16 [FFmpeg-devel] [PATCH 01/31] fftools/ffmpeg_dec: split Decoder into a private and public part Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 02/31] fftools/ffmpeg_dec: export subtitle_header in Decoder Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 03/31] fftools/ffmpeg_filter: consolidate decoder/filter type checks Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 04/31] fftools/ffmpeg: make decoding AVCodecContext private to the decoder Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 05/31] fftools/ffmpeg_dec: add an AVClass to Decoder Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 06/31] fftools/ffmpeg_dec: pass decoder options as an argument to dec_open() Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 07/31] fftools/ffmpeg_dec: move decoding counters from InputStream to Decoder Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 08/31] fftools/ffmpeg_dec: drop useless and racy code Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 09/31] fftools/ffmpeg_dec: drop a useless log message Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 10/31] fftools/ffmpeg: move decoder existence check to a more appropriate place Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 11/31] fftools/ffmpeg_dec: override video SAR with AVCodecParameters value Anton Khirnov
2024-03-24 22:09   ` Michael Niedermayer
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 12/31] fftools/ffmpeg_dec: stop accesing InputStream.fix_sub_duration Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 13/31] fftools/ffmpeg: refactor disabling decoder threading for attached pictures Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 14/31] fftools/ffmpeg_dec: replace InputFile.format_nots with a decoder flag Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 15/31] fftools/ffmpeg: move hwaccel_retrieve_data() from ffmpeg_hw to ffmpeg_dec Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 16/31] fftools/ffmpeg_dec: pass hwaccel options to the decoder in a separate struct Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 17/31] fftools/ffmpeg_dec: move flags to DecoderOpts Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 18/31] fftools/ffmpeg_dec: pass forced/estimated framerate though DecoderOpts Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 19/31] fftools/ffmpeg_dec: move setting compute_edt to demuxer Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 20/31] fftools/ffmpeg_dec: pass input timebase through DecoderOpts Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 21/31] fftools/ffmpeg_dec: pass top_field_first " Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 22/31] fftools/ffmpeg_dec: pass decoder name " Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 23/31] fftools/ffmpeg_dec: eliminate InputStream use in hw_device_setup_for_decode() Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 24/31] fftools/ffmpeg_dec: pass AVCodec through DecoderOpts Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 25/31] fftools/ffmpeg_dec: pass AVCodecParameters " Anton Khirnov
2024-01-24  8:16 ` Anton Khirnov [this message]
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 27/31] fftools/ffmpeg_dec: stop passing InputStream to dec_open() Anton Khirnov
2024-01-25  1:19   ` Michael Niedermayer
2024-01-28  9:40     ` [FFmpeg-devel] [PATCH v2 " Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 28/31] fftools/ffmpeg_dec: eliminate all remaining InputStream uses Anton Khirnov
2024-01-24  8:16 ` [FFmpeg-devel] [PATCH 29/31] fftools/ffmpeg: make InputStream.decoding_needed private to demuxer Anton Khirnov
2024-01-24  8:17 ` [FFmpeg-devel] [PATCH 30/31] fftools/ffmpeg: make InputStream.decoder_opts " Anton Khirnov
2024-01-24  8:17 ` [FFmpeg-devel] [PATCH 31/31] fftools/ffmpeg: cosmetics, vertically align Input{File, Stream} 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=20240124081702.4759-26-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