From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 0443347F83 for ; Wed, 6 Mar 2024 11:05:34 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E2E5C68CCFE; Wed, 6 Mar 2024 13:05:30 +0200 (EET) Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 31A5F68B5A1 for ; Wed, 6 Mar 2024 13:05:24 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=VK33I+pR; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id BD6B84D58 for ; Wed, 6 Mar 2024 12:05:23 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id OCuQaZMU4TG5 for ; Wed, 6 Mar 2024 12:05:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709723122; bh=Rg4324EfyT/brOQYuc9nInFvUWPkcSBUPMrjEC4Y9sc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=VK33I+pRyo0BjELVWoakqm0InGk8YXxHG6xPuYrhkiVIWvJLdCJLApK72tXB1pH8E o+EjHjz93qNmWZ2RCnTVWhwlWEd3tA4hVrG99uiwKq7OlsDzQVPdV3VKNSWrCf9f+J NG8OPjgg/5/IaTALnBP1S2lWqD0ec7B8ih9TvT0JX87WnJAxAj5IRoFKirN1a8mi1K wGsmjk+JeDfd64hNe+EMyK7CIzarNZac3Go/8xOq8qE9l9sfOWVKlGXj4bXWltDA+4 JL8J9bIwRbdZcSld+ipbVtadu7wj8MujZ865X5i+qP9Ns9ZJh+G+EPbO/i6nrh81Bw 4jJZscOVv7N+A== 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 mail1.khirnov.net (Postfix) with ESMTPS id B96AB4D46 for ; Wed, 6 Mar 2024 12:05:22 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id A459A3A0A6B for ; Wed, 6 Mar 2024 12:05:22 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 6 Mar 2024 12:03:05 +0100 Message-ID: <20240306110319.17339-4-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240306110319.17339-1-anton@khirnov.net> References: <20240306110319.17339-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/18] fftools/ffmpeg_dec: move scheduler registration from dec_open() to dec_alloc() 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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".