From patchwork Wed Jan 24 08:16:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 45781 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:120f:b0:199:de12:6fa6 with SMTP id v15csp1130397pzf; Wed, 24 Jan 2024 00:20:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IHTkOXiiOrWt3FMfNJyldgYmikh+4LxmKu+h8/ULWWU5F1cTAC/i2br18MwF0e4ZbuLdUvx X-Received: by 2002:aa7:d5cb:0:b0:55c:5f0:953a with SMTP id d11-20020aa7d5cb000000b0055c05f0953amr887324eds.119.1706084456431; Wed, 24 Jan 2024 00:20:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1706084456; cv=none; d=google.com; s=arc-20160816; b=jHcd6bU7flpEpxiRlHUbY5rQ+utRzV2sxiMNkAaTa9nuCHgVisCZWsJZlEpdc5HOEQ Zl1bk01scpXhawOvxEiFX1kCCkfaHr7dutlntsU2658P62BodMUN7iLdvrMvTDKS4XbM dFW1V86Xzu9uaAbfrvROWFv6a3OGacd96YKfy51aLUJBGrsrNFikB/yBIm629jGqdHYI DLlaQX81noqJHAX3FOMAyK5btEWvoFEHV5C8om6MNqpAXaP1ZcdMdDm+NgjOf0PH/R+T 97sqMssb+lPMqVRmKKnPpDmO+t2FSzFYhX02gs8yJjNTzv9I6FUGZz5N4D2FWBznYEI7 DavA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=GNnUOHj+Ukryp/AUOyc49yEF4cVyP85+8RmCSVe7phY=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=rsyzZeS8HJkucD+7H0dwfpD2b651WLiJm0Eb1U7CKGigZ6TvcwjLzk+pDPjEWo+MaZ fJFEq/E3DghoYS4BQzgTDUR+ZJLyPmzL1LPuWUQfA0UGNyk7HppL6S0UcwM6lQMaBuCO oOcPZ1lhWdq7W+vMX+nbyRPynABnrvex2A0OFb+50w3T/S5cOs/w2/QzPeoDCBIewDMS +KO1OljFqrl34aeQZEntFHaO81xWoAppmaMo5I6/w6aKJzKjFapCdKeXjUrFVH3fA+Be jOm19xa5xyZkIIYstp129CeqUUafGAGEvQd2YL3w4GqapvSARpiIAH2mf7DRJmnUCCfL CrcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=Yxve0bkU; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s5-20020a50ab05000000b00553a472e61esi13208611edc.404.2024.01.24.00.20.56; Wed, 24 Jan 2024 00:20:56 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=Yxve0bkU; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D2C5868D1C1; Wed, 24 Jan 2024 10:17:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8D99868D118 for ; Wed, 24 Jan 2024 10:17:27 +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=Yxve0bkU; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 65BA71BB7 for ; Wed, 24 Jan 2024 09:17:25 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 7DJoIy1n6PYt for ; Wed, 24 Jan 2024 09:17:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1706084240; bh=Pf+kf9T/Dd61Kgj3iz6ineUD0zlab4VHf+O6DAL2EbM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Yxve0bkUPCHK4/i2TXBvSR80xS5GL8WxiJIIloxp7pkBHZFqhMhpVEXjXcsRaka7H 8xa1Oda2m0QpwNjqXsSuNN8DMcYDvKFHGxjvb/N9dDsr+Bq/0adufxix59olreMlGp 8FRihMng4JLE+s8PYVhpTMTrHU0mToPwbA20egB0eG6fX8+EaipRcb6y1r0yTvohzs xueNP6woDURQ5pcPMJ0ge5f3EsS1kxdQxfYT9yFP9RF4Ewg74FrrP/DSCYTApj4nOi GuP7+rU+2JhrlpOMR5Wx4qP5LfwFvCjG0z6fTGGQ5WyfHE7MxQq8vkhI9tQAIT0ZMj K+IbTJP0+aAwQ== 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 5F2541C03 for ; Wed, 24 Jan 2024 09:17:20 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 4E9093A0634 for ; Wed, 24 Jan 2024 09:17:20 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Jan 2024 09:16:56 +0100 Message-ID: <20240124081702.4759-26-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240124081702.4759-1-anton@khirnov.net> References: <20240124081702.4759-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 26/31] fftools/ffmpeg_dec: remove unnecessary InputStream arguments 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 3cSUjImxGeLU --- 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);