From patchwork Tue Sep 15 07:39:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22408 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 1D1EF449636 for ; Tue, 15 Sep 2020 10:44:19 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B1B1068BC9E; Tue, 15 Sep 2020 10:41:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 40AE168BC84 for ; Tue, 15 Sep 2020 10:40:55 +0300 (EEST) Received: by mail-wr1-f65.google.com with SMTP id m6so2212692wrn.0 for ; Tue, 15 Sep 2020 00:40:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2Q/YeInfn5HTSF9IS2nPJga94q1oqIM4LYsnJiEMtzY=; b=ssVRNVZAzY+alZtVLhpp7YDvA9zffZwcC4w+VFifgJlhBOAWinsufiCMuuW0boUjsJ 4Y42pi5I+LEE4J/rd8atxC5BImrYj69Osf8zYL2UXX0baNaLRm73C2Ul+E6RK9UZQLyl /wq5ulD+d8AY5k/pdID+XpsKhVb6T+UnVMk/UjEXUZnOG5unlfree//c13zKvVf9PPGr slqmD0jYOo7XmoKkZdEwwERmX4UDZesmC26bXSf9bEDf3VXlUavmjlwAQMRAL4298GoU LJL853IGKSuU4stYLv3Wp7Chy986UFF5FuOD8zCqKRVw1YRcEZ/WDjoI/2e2dfGfTfe7 DLGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2Q/YeInfn5HTSF9IS2nPJga94q1oqIM4LYsnJiEMtzY=; b=oQdeGdTtS2ILeClJd3qmM3ZFdtkUXAxgzQN9jB4LmnOUwTqKfCBQeWXovye+cQGwqi T+U7w4SYgS3wt1SWApqcSuI9XwtG6i0vxx9rWnQtgQwYHKEGqSpaaPGPgD4hMfa4JMWl qNxoZRhep6AcRxYc9LgLCuCsFBunC2R5qnway+FcR4JAgfhkaRUj45ucolGnxn3sjXAi 4k/55enl3bml7CoTN2RKwMOHijbOkRWd3cY3S4qc9d3KJpDcGVhowaXAIk1WnpCswjxi LiHzKuQp19+Xw/mQhmBFO0lHyxUtXy8Mc6lX6Kzh1aH/N1qlmfdBVNjLOhnQyTNkAPKh CUfQ== X-Gm-Message-State: AOAM53139BJERmyNqQf9qWjdYj/VQ17uKKTib8tVm5fM/Opzw6CFX91M c7MJFvFmzTcWNy56DdFNE357mQ1BQhc= X-Google-Smtp-Source: ABdhPJyoi2wKrELjbzo/dTW5kQpL5/o4q6lH61jzyS9YTd2WKgTKsbj7bwii6YO1bC4VpTPLggHmwA== X-Received: by 2002:a5d:6806:: with SMTP id w6mr19905411wru.395.1600155654453; Tue, 15 Sep 2020 00:40:54 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id d23sm6112125wmb.6.2020.09.15.00.40.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 00:40:54 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Sep 2020 09:39:58 +0200 Message-Id: <20200915074000.102622-28-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200915074000.102622-1-andreas.rheinhardt@gmail.com> References: <20200915074000.102622-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 28/30] avcodec/mpegaudiodec_float: Avoid indirection with float dsp function X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" Do this by only keeping the only function pointer from the AVFloatDSPContext that is needed lateron. This also allows to remove the decoders' close function. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegaudiodec_float.c | 4 ---- libavcodec/mpegaudiodec_template.c | 30 +++++++++++------------------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/libavcodec/mpegaudiodec_float.c b/libavcodec/mpegaudiodec_float.c index ddfa5e0daa..0defdf3af1 100644 --- a/libavcodec/mpegaudiodec_float.c +++ b/libavcodec/mpegaudiodec_float.c @@ -46,7 +46,6 @@ AVCodec ff_mp1float_decoder = { .id = AV_CODEC_ID_MP1, .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, - .close = decode_close, .decode = decode_frame, .capabilities = AV_CODEC_CAP_DR1, .flush = flush, @@ -64,7 +63,6 @@ AVCodec ff_mp2float_decoder = { .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, .decode = decode_frame, - .close = decode_close, .capabilities = AV_CODEC_CAP_DR1, .flush = flush, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, @@ -80,7 +78,6 @@ AVCodec ff_mp3float_decoder = { .id = AV_CODEC_ID_MP3, .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, - .close = decode_close, .decode = decode_frame, .capabilities = AV_CODEC_CAP_DR1, .flush = flush, @@ -97,7 +94,6 @@ AVCodec ff_mp3adufloat_decoder = { .id = AV_CODEC_ID_MP3ADU, .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, - .close = decode_close, .decode = decode_frame_adu, .capabilities = AV_CODEC_CAP_DR1, .flush = flush, diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c index 98759b8e01..d2b72497e1 100644 --- a/libavcodec/mpegaudiodec_template.c +++ b/libavcodec/mpegaudiodec_template.c @@ -87,7 +87,7 @@ typedef struct MPADecodeContext { int err_recognition; AVCodecContext* avctx; MPADSPContext mpadsp; - AVFloatDSPContext *fdsp; + void (*butterflies_float)(float *av_restrict v1, float *av_restrict v2, int len); AVFrame *frame; uint32_t crc; } MPADecodeContext; @@ -410,16 +410,6 @@ static av_cold void decode_init_static(void) } } -#if USE_FLOATS -static av_cold int decode_close(AVCodecContext * avctx) -{ - MPADecodeContext *s = avctx->priv_data; - av_freep(&s->fdsp); - - return 0; -} -#endif - static av_cold int decode_init(AVCodecContext * avctx) { static int initialized_tables = 0; @@ -433,9 +423,14 @@ static av_cold int decode_init(AVCodecContext * avctx) s->avctx = avctx; #if USE_FLOATS - s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); - if (!s->fdsp) - return AVERROR(ENOMEM); + { + AVFloatDSPContext *fdsp; + fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); + if (!fdsp) + return AVERROR(ENOMEM); + s->butterflies_float = fdsp->butterflies_float; + av_free(fdsp); + } #endif ff_mpadsp_init(&s->mpadsp); @@ -1188,7 +1183,7 @@ found2: /* NOTE: the 1/sqrt(2) normalization factor is included in the global gain */ #if USE_FLOATS - s->fdsp->butterflies_float(g0->sb_hybrid, g1->sb_hybrid, 576); + s->butterflies_float(g0->sb_hybrid, g1->sb_hybrid, 576); #else tab0 = g0->sb_hybrid; tab1 = g1->sb_hybrid; @@ -1871,9 +1866,6 @@ static av_cold int decode_close_mp3on4(AVCodecContext * avctx) MP3On4DecodeContext *s = avctx->priv_data; int i; - if (s->mp3decctx[0]) - av_freep(&s->mp3decctx[0]->fdsp); - for (i = 0; i < s->frames; i++) av_freep(&s->mp3decctx[i]); @@ -1938,7 +1930,7 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx) s->mp3decctx[i]->adu_mode = 1; s->mp3decctx[i]->avctx = avctx; s->mp3decctx[i]->mpadsp = s->mp3decctx[0]->mpadsp; - s->mp3decctx[i]->fdsp = s->mp3decctx[0]->fdsp; + s->mp3decctx[i]->butterflies_float = s->mp3decctx[0]->butterflies_float; } return 0;