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 04/18] fftools/ffmpeg_dec: move scheduler registration from dec_open() to dec_alloc()
Date: Wed,  6 Mar 2024 12:03:05 +0100
Message-ID: <20240306110319.17339-4-anton@khirnov.net> (raw)
In-Reply-To: <20240306110319.17339-1-anton@khirnov.net>

Will be useful in following commits where we will want to create a
decoder before having enough information to open it.
---
 fftools/ffmpeg_dec.c | 51 +++++++++++++++++++++++---------------------
 1 file changed, 27 insertions(+), 24 deletions(-)

diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index 8c92b27cc1..98c4a0c83c 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -110,9 +110,26 @@ void dec_free(Decoder **pdec)
     av_freep(pdec);
 }
 
-static int dec_alloc(DecoderPriv **pdec)
+static const char *dec_item_name(void *obj)
+{
+    const DecoderPriv *dp = obj;
+
+    return dp->log_name;
+}
+
+static const AVClass dec_class = {
+    .class_name                = "Decoder",
+    .version                   = LIBAVUTIL_VERSION_INT,
+    .parent_log_context_offset = offsetof(DecoderPriv, log_parent),
+    .item_name                 = dec_item_name,
+};
+
+static void *decoder_thread(void *arg);
+
+static int dec_alloc(DecoderPriv **pdec, Scheduler *sch, int send_end_ts)
 {
     DecoderPriv *dp;
+    int ret = 0;
 
     *pdec = NULL;
 
@@ -128,17 +145,24 @@ static int dec_alloc(DecoderPriv **pdec)
     if (!dp->pkt)
         goto fail;
 
+    dp->dec.class                    = &dec_class;
     dp->last_filter_in_rescale_delta = AV_NOPTS_VALUE;
     dp->last_frame_pts               = AV_NOPTS_VALUE;
     dp->last_frame_tb                = (AVRational){ 1, 1 };
     dp->hwaccel_pix_fmt              = AV_PIX_FMT_NONE;
 
+    ret = sch_add_dec(sch, decoder_thread, dp, send_end_ts);
+    if (ret < 0)
+        goto fail;
+    dp->sch     = sch;
+    dp->sch_idx = ret;
+
     *pdec = dp;
 
     return 0;
 fail:
     dec_free((Decoder**)&dp);
-    return AVERROR(ENOMEM);
+    return ret >= 0 ? AVERROR(ENOMEM) : ret;
 }
 
 static AVRational audio_samplerate_update(DecoderPriv *dp,
@@ -1042,20 +1066,6 @@ static int hw_device_setup_for_decode(DecoderPriv *dp,
     return 0;
 }
 
-static const char *dec_item_name(void *obj)
-{
-    const DecoderPriv *dp = obj;
-
-    return dp->log_name;
-}
-
-static const AVClass dec_class = {
-    .class_name                = "Decoder",
-    .version                   = LIBAVUTIL_VERSION_INT,
-    .parent_log_context_offset = offsetof(DecoderPriv, log_parent),
-    .item_name                 = dec_item_name,
-};
-
 int dec_open(Decoder **pdec, Scheduler *sch,
              AVDictionary **dec_opts, const DecoderOpts *o)
 {
@@ -1065,18 +1075,11 @@ int dec_open(Decoder **pdec, Scheduler *sch,
 
     *pdec = NULL;
 
-    ret = dec_alloc(&dp);
+    ret = dec_alloc(&dp, sch, !!(o->flags & DECODER_FLAG_SEND_END_TS));
     if (ret < 0)
         return ret;
 
-    ret = sch_add_dec(sch, decoder_thread, dp, o->flags & DECODER_FLAG_SEND_END_TS);
-    if (ret < 0)
-        return ret;
-    dp->sch     = sch;
-    dp->sch_idx = ret;
-
     dp->flags      = o->flags;
-    dp->dec.class  = &dec_class;
     dp->log_parent = o->log_parent;
 
     dp->framerate_in            = o->framerate;
-- 
2.43.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-03-06 11:05 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-06 11:03 [FFmpeg-devel] [PATCH 01/18] fftools/cmdutils: fix printing group name in split_commandline() Anton Khirnov
2024-03-06 11:03 ` [FFmpeg-devel] [PATCH 02/18] fftools/ffmpeg_filter: refactor setting input timebase Anton Khirnov
2024-03-07 20:37   ` Michael Niedermayer
2024-03-08  5:34     ` Anton Khirnov
2024-03-10  3:36       ` Michael Niedermayer
2024-03-10  6:13         ` Anton Khirnov
2024-03-10 19:21           ` Michael Niedermayer
2024-03-10 22:24             ` Anton Khirnov
2024-03-10 22:29               ` James Almer
2024-03-10 22:49                 ` Anton Khirnov
2024-03-10 23:37                   ` Michael Niedermayer
2024-03-11  6:03                     ` Anton Khirnov
2024-03-11 10:12                   ` Tobias Rapp
2024-03-11 12:23                     ` Anton Khirnov
2024-03-11 12:29                       ` Martin Storsjö
2024-03-11 13:28                         ` Anton Khirnov
2024-03-11 14:03                           ` Martin Storsjö via ffmpeg-devel
2024-03-11 14:32                             ` Anton Khirnov
2024-03-11 14:37                               ` Martin Storsjö
2024-03-11 14:31                           ` Tobias Rapp
2024-03-06 11:03 ` [FFmpeg-devel] [PATCH 03/18] fftools/ffmpeg_filter: drop unused InputFilterPriv.ist Anton Khirnov
2024-03-06 11:03 ` Anton Khirnov [this message]
2024-03-06 11:03 ` [FFmpeg-devel] [PATCH 05/18] fftools/ffmpeg_dec: factor opening the decoder out of dec_open() Anton Khirnov
2024-03-06 11:03 ` [FFmpeg-devel] [PATCH 06/18] fftools/ffmpeg_opt: merge init_complex_filters() and check_filter_outputs() Anton Khirnov
2024-03-06 11:03 ` [FFmpeg-devel] [PATCH 07/18] fftools/ffmpeg_filter: move filtergraph input type check to a better place Anton Khirnov
2024-03-06 11:03 ` [FFmpeg-devel] [PATCH 08/18] fftools/ffmpeg_filter: add logging for binding inputs to demuxer streams Anton Khirnov
2024-03-06 11:03 ` [FFmpeg-devel] [PATCH 09/18] fftools/ffmpeg: simplify propagating fallback parameters from decoders to filters Anton Khirnov
2024-03-06 11:03 ` [FFmpeg-devel] [PATCH 10/18] fftools/ffmpeg: remove unncessary casts for *_thread() return values Anton Khirnov
2024-03-06 11:03 ` [FFmpeg-devel] [PATCH 11/18] fftools/ffmpeg_enc: drop unnecessary parameter from forced_kf_apply() Anton Khirnov
2024-03-06 11:03 ` [FFmpeg-devel] [PATCH 12/18] fftools/ffmpeg_enc: merge do_{audio, video}_out into frame_encode() Anton Khirnov
2024-03-06 11:03 ` [FFmpeg-devel] [PATCH 13/18] fftools/ffmpeg_sched: allow encoders to send to multiple destinations Anton Khirnov
2024-03-06 11:03 ` [FFmpeg-devel] [PATCH 14/18] fftools/ffmpeg_sched: factor initializing nodes into separate function Anton Khirnov
2024-03-06 11:03 ` [FFmpeg-devel] [PATCH 15/18] fftools/ffmpeg_sched: allow connecting encoder output to decoders Anton Khirnov
2024-03-06 11:03 ` [FFmpeg-devel] [PATCH 16/18] fftools/ffmpeg: prepare FrameData for having allocated fields Anton Khirnov
2024-03-06 11:03 ` [FFmpeg-devel] [PATCH 17/18] fftools/ffmpeg: add loopback decoding Anton Khirnov
2024-03-07 14:42   ` [FFmpeg-devel] [PATCH v2 " Anton Khirnov
2024-03-06 11:03 ` [FFmpeg-devel] [PATCH 18/18] fftools/ffmpeg_enc: set AV_PKT_FLAG_TRUSTED on encoded packets Anton Khirnov
2024-03-09 19:08 ` [FFmpeg-devel] [PATCH 01/18] fftools/cmdutils: fix printing group name in split_commandline() 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=20240306110319.17339-4-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