From patchwork Mon Oct 3 22:44:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 38544 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp1575222pzh; Mon, 3 Oct 2022 15:45:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM75E86Ocv7GdmhZze01L3ARgow5pt1xzKMQkx5Eh7wiIK/FEEsiPBwq8eY7YGN/8eY1U8ts X-Received: by 2002:a17:907:160d:b0:782:9631:c198 with SMTP id hb13-20020a170907160d00b007829631c198mr16626254ejc.520.1664837126736; Mon, 03 Oct 2022 15:45:26 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hh4-20020a170906a94400b0073d710fec77si9092948ejb.251.2022.10.03.15.45.26; Mon, 03 Oct 2022 15:45:26 -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; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=G7nJEAra; arc=fail (body hash mismatch); 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 131DA68BBFE; Tue, 4 Oct 2022 01:45:21 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03olkn2035.outbound.protection.outlook.com [40.92.58.35]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3B7F968BB4E for ; Tue, 4 Oct 2022 01:45:14 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nvfBUmo2v092j3A8zCGV9nFSvE+xz5Gnfl+MLRtzJuqqsVWqQxjISxswn1wFVe6bNH2Q/fyivriWNRwTuknXFeDSh0aGgBS4elme/PasahOD6wPax1ZadD04HKRGMhiugeL/olcwnNaEPwkYy18O3L4Fe/us70MTWxlYTaHXh4SGBYqFyMaVhtmnw9XzWhpNc1WYqq2AbXzGA1MkrXXl+WiGlXBeLSHJ62QMHumccfZkjeQ44m6bCwE2NdAv2ApTY2t0zqUPF4s5/2lFKjU7CkoIE6v8Gnt9cnLqSHiEexmaTN0O+7eL/p22YFIu7er3kxO2puc02xdgow0x7adUiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qhgJxHcAs9hUyMc/8DNrthRxTXayahTbrhIrigZFbXE=; b=H2SlhFJ+4JsbNi0/LSdeLk/qVPP8u8U1j9X196UOUoegDMTLOeWTqceqRUvRipOkYDYOXGCHOumPeCMj5bP8nlJLDLRVzmS0ZKaSSGltNWUQzOOkSvoeDB1Mp99fn6s5Lk59C9YKKKO1l0NGFjHSR/+Dt2YHRBrFiUuYFp/qt7jikPB5VZWy+udVew9jNyaqP2mnQ+I7+pDHPGCDDTbFk4N7NpwgizxynQyJ4OUjk4g1CIiiNEINqVBXJ8eJZDfnMP9NK5QFuw6BzL6beSYGDGde6BlQNiBkRKsk99Ie6sCWnPVpW/r4gIWs9iM7o5ekfcxLXBk8pKXGkN1XuFtsvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qhgJxHcAs9hUyMc/8DNrthRxTXayahTbrhIrigZFbXE=; b=G7nJEAraNWp/xOr6YrSogBihV+dTZaryrGRI72veKGwHPFSJvVcxW4jd1nEQyt1g5SaK8a4l57lvijFnltPjTqJOUtiZh75IcrvYOGOau90G/LISsqZuLM+N1ZM5AkC3L/dvvutxHeROZprvVdRy18hYeInltGUkiruqpLt3uGbCugPLAb8MFQzJf1nQUKtkJeyIePOFdAJoTut6XJ1RaM6c/RSKiCo7uNms4jY2EaQIANGL0JkhQlJ5G+NUT9pjTggOQ5Jj8RyAyAop0yIFVLH3L9wnwkUKpOMhe485xynGdD/P2vfLv1kQ5l+r4PELrHvls9ooeFb32fLix60/ug== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by PAXP250MB0470.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:283::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.23; Mon, 3 Oct 2022 22:45:11 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8%9]) with mapi id 15.20.5676.023; Mon, 3 Oct 2022 22:45:11 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 4 Oct 2022 00:44:59 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [xkZJH+i9NGcqswaZwv7T2Xf0NDiSFEVVzNVyzqLqlA8=] X-ClientProxiedBy: ZR0P278CA0056.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:21::7) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20221003224505.1846824-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|PAXP250MB0470:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d1069d5-04b1-4cc3-04f8-08daa590edd7 X-MS-Exchange-SLBlob-MailProps: ZILSnhm0P3lA05FefvWS45JiO4vgSAs16MqCQq99TBZHNqt6FpMv3Prirw94xb6fp+Q4xdwlTXP8awJyo4+mIq+Hi1E3HpBLaeZfUBAKQCNnh69x7zAxW4vy/EyH5yLy9ywQBQ2RrfTrhMY56shgvYJxvO+UcSNoflDS+1b7ZAgbhtPE4fz1PyKeJcMrFLA0IOrtm4GaMqBUYtzZ517gm9kmSIRxE+wAdEnjsT9q5VPh4mePOQtBuVLYRi/2kG1B8O6BKGwyQBHJurQ1/h0nVtLnKQ+O+26P//QmbmjYnh6I4s5T9Y4btxGMLLkuY8JiB9QLAPr531OmS9Rb72wfcvs/usBI47xltd/lhTDveJ7oJS3uvT+TuCUreAB6/QgYHNfLkX1OjMrUGYENnZfN3jG6beoS6AKJA3Bt6oKPPIhDYYFvwjHB16TEUKGaAHhLPX919sp1ykGIahiYQECAcLbOVBlm2ZpZzonUN1MXjxbDwMW95oh4RfEvYSgkR31opfeiECfVto0fdk4tGF/lGralCX3helCd/wELGKar+jY0MJta46rFsE/bdfktR2+LwkcTrmNMXSAeeW++sF1iNgdSeFeDuB19MUSn7RMEIKaPhzud+ERJw0hMBTUKJAPY1Rlkm1PYKmMr/OLoJeYcxzjy7BusWed0NQeIU6W6Dyn95Cmd0Adz3XgIpMEAII2PbEElDiO04wsZ9nuCVJ9hxloZ3/NJ47i9GCLF/4xVoG8ygAWVYCatt6/+cOxxK2eJA1V7LHOjEQcsNUbtOaFmIwM/jE9PiNaQ X-Microsoft-Antispam: B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id: 0d1069d5-04b1-4cc3-04f8-08daa590edd7 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2022 22:45:11.2385 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXP250MB0470 Subject: [FFmpeg-devel] [PATCH 3/9] avcodec/opus: Move OpusStreamContext to its only user 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: E6slmbQ6jncb Namely opusdec.c. Signed-off-by: Andreas Rheinhardt --- libavcodec/opus.h | 52 +------------------------------------------- libavcodec/opusdec.c | 47 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 51 deletions(-) diff --git a/libavcodec/opus.h b/libavcodec/opus.h index b73949a811..264128f09e 100644 --- a/libavcodec/opus.h +++ b/libavcodec/opus.h @@ -25,12 +25,7 @@ #include -#include "libavutil/audio_fifo.h" #include "libavutil/float_dsp.h" -#include "libavutil/frame.h" -#include "libavutil/mem_internal.h" - -#include "libswresample/swresample.h" #include "avcodec.h" #include "opus_rc.h" @@ -98,51 +93,6 @@ typedef struct OpusPacket { enum OpusBandwidth bandwidth; /**< bandwidth */ } OpusPacket; -typedef struct OpusStreamContext { - AVCodecContext *avctx; - int output_channels; - - /* number of decoded samples for this stream */ - int decoded_samples; - /* current output buffers for this stream */ - float *out[2]; - int out_size; - /* Buffer with samples from this stream for synchronizing - * the streams when they have different resampling delays */ - AVAudioFifo *sync_buffer; - - OpusRangeCoder rc; - OpusRangeCoder redundancy_rc; - SilkContext *silk; - CeltFrame *celt; - AVFloatDSPContext *fdsp; - - float silk_buf[2][960]; - float *silk_output[2]; - DECLARE_ALIGNED(32, float, celt_buf)[2][960]; - float *celt_output[2]; - - DECLARE_ALIGNED(32, float, redundancy_buf)[2][960]; - float *redundancy_output[2]; - - /* buffers for the next samples to be decoded */ - float *cur_out[2]; - int remaining_out_size; - - float *out_dummy; - int out_dummy_allocated_size; - - SwrContext *swr; - AVAudioFifo *celt_delay; - int silk_samplerate; - /* number of samples we still want to get from the resampler */ - int delayed_samples; - - OpusPacket packet; - - int redundancy_idx; -} OpusStreamContext; - // a mapping between an opus stream and an output channel typedef struct ChannelMap { int stream_idx; @@ -161,7 +111,7 @@ typedef struct ChannelMap { typedef struct OpusContext { AVClass *av_class; - OpusStreamContext *streams; + struct OpusStreamContext *streams; int apply_phase_inv; int nb_streams; diff --git a/libavcodec/opusdec.c b/libavcodec/opusdec.c index d255486d06..87a86b6b47 100644 --- a/libavcodec/opusdec.c +++ b/libavcodec/opusdec.c @@ -38,6 +38,8 @@ #include "libavutil/attributes.h" #include "libavutil/audio_fifo.h" #include "libavutil/channel_layout.h" +#include "libavutil/frame.h" +#include "libavutil/mem_internal.h" #include "libavutil/opt.h" #include "libswresample/swresample.h" @@ -63,6 +65,51 @@ static const int silk_resample_delay[] = { 4, 8, 11, 11, 11 }; +typedef struct OpusStreamContext { + AVCodecContext *avctx; + int output_channels; + + /* number of decoded samples for this stream */ + int decoded_samples; + /* current output buffers for this stream */ + float *out[2]; + int out_size; + /* Buffer with samples from this stream for synchronizing + * the streams when they have different resampling delays */ + AVAudioFifo *sync_buffer; + + OpusRangeCoder rc; + OpusRangeCoder redundancy_rc; + SilkContext *silk; + CeltFrame *celt; + AVFloatDSPContext *fdsp; + + float silk_buf[2][960]; + float *silk_output[2]; + DECLARE_ALIGNED(32, float, celt_buf)[2][960]; + float *celt_output[2]; + + DECLARE_ALIGNED(32, float, redundancy_buf)[2][960]; + float *redundancy_output[2]; + + /* buffers for the next samples to be decoded */ + float *cur_out[2]; + int remaining_out_size; + + float *out_dummy; + int out_dummy_allocated_size; + + SwrContext *swr; + AVAudioFifo *celt_delay; + int silk_samplerate; + /* number of samples we still want to get from the resampler */ + int delayed_samples; + + OpusPacket packet; + + int redundancy_idx; +} OpusStreamContext; + static int get_silk_samplerate(int config) { if (config < 4)