From patchwork Wed May 17 10:20:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41673 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:ba91:b0:105:feb:71f2 with SMTP id fb17csp1079053pzb; Wed, 17 May 2023 03:23:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6wYWIldzSqGBxq0VEEtedpIRuUejsYwHTT1ADkk6tUJ0efW4w1pTo0qcyi72gP5PxpAjyg X-Received: by 2002:a17:907:940c:b0:960:ddba:e5bb with SMTP id dk12-20020a170907940c00b00960ddbae5bbmr38402642ejc.43.1684319004950; Wed, 17 May 2023 03:23:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684319004; cv=none; d=google.com; s=arc-20160816; b=elkbJ88yNl0LqJIkBdhvNchpOH/nAB33hwefLAHGLLfTmgwPkns8xY4ow+c6DWU8i1 gRUBifmjJxf+/0JveATWz6RNaw5K0OoI/RCMYaO1VGVfmcRyI4Yu4xPUaEAzecapdpJP M/TQiTMzyDu87NMrD1QJlcpVzzAIhMNowd45Yrl6BJ6LfosSeoVebyyi76XlBAFD6plM w6EA1zz30Ar6yvETa5EY6FC2gVetzROnN2EArst77xz5OSFRAvBM6wLZCf7t1/+RlDq3 6HETYzy/KjB1MWEXmexxchKKPzPVXNibnQmlTzOloTqnHrTVb4a60odh712To5foQ2Bq rvjQ== 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:delivered-to; bh=2LqaV9BTtbrTFGQWTcBPV1bpXnsRTNrABakmuPV/44o=; b=tn6VZHU3sq/bX9nYM1FUJMa441Yz9H+ynMJRrWjE/wzwba+iXmSqOPMJeqQEAi51m8 3rek1R54q2+/65rY2mqdbeFErQ8YbqWgXAZAirbzICj8Uyrr5AdgGSNVwFuADwyrQo8/ LldHtP0e7UWObe5HZGjnSVon8DDjwkiE3MJsNIupc4RIJAvevhjtEIM8fFWxWsXjkhao hRAiqKwrjDNwyMBW81wjxqDFsP+iA3BCRn2V6U0IA7sHrb7aMd2n0fARXMCLrMVLUbYf ZxEYdiOUjpp1+gC/u2kamove2qmIGYQ601FnhMweuULwdSgJpzBB2QnI6WsdBoeFoUz4 2F8w== ARC-Authentication-Results: i=1; mx.google.com; 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 h10-20020aa7c60a000000b0050bc6c617a1si15463650edq.113.2023.05.17.03.23.24; Wed, 17 May 2023 03:23:24 -0700 (PDT) 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; 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 C1ABD68C144; Wed, 17 May 2023 13:21:09 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A99CD68C142 for ; Wed, 17 May 2023 13:20:57 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 1A994240D0E for ; Wed, 17 May 2023 12:20:57 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id fExiW33WJwka for ; Wed, 17 May 2023 12:20:55 +0200 (CEST) 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 mail0.khirnov.net (Postfix) with ESMTPS id 48161240D1C for ; Wed, 17 May 2023 12:20:46 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 051C13A228B for ; Wed, 17 May 2023 12:20:41 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 17 May 2023 12:20:28 +0200 Message-Id: <20230517102029.541-35-anton@khirnov.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230517102029.541-1-anton@khirnov.net> References: <20230517102029.541-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 35/36] fftools/ffmpeg_dec: inline decode_audio() into dec_packet() 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: coiJGjbb086p The former function is now trivial - it has 3 lines and cannot fail. --- fftools/ffmpeg_dec.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index 4662d0a265..c8f9ba0f0c 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -128,17 +128,6 @@ static void audio_ts_process(InputStream *ist, AVFrame *frame) frame->time_base = tb_filter; } -static int decode_audio(InputStream *ist, AVFrame *decoded_frame) -{ - ist->samples_decoded += decoded_frame->nb_samples; - - audio_ts_process(ist, decoded_frame); - - ist->nb_samples = decoded_frame->nb_samples; - - return 0; -} - static int64_t video_duration_estimate(const InputStream *ist, const AVFrame *frame) { const InputFile *ifile = input_files[ist->file_index]; @@ -463,14 +452,18 @@ int dec_packet(InputStream *ist, const AVPacket *pkt, int no_eof) frame->time_base = dec->pkt_timebase; - ret = dec->codec_type == AVMEDIA_TYPE_AUDIO ? - decode_audio(ist, frame) : - decode_video(ist, frame); + if (dec->codec_type == AVMEDIA_TYPE_AUDIO) { + ist->samples_decoded += frame->nb_samples; + ist->nb_samples = frame->nb_samples; - 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); - exit_program(1); + audio_ts_process(ist, frame); + } else { + ret = decode_video(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); + exit_program(1); + } } ist->frames_decoded++;