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 B6CD746FCB for ; Mon, 24 Jul 2023 21:58:40 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9434C68C7DA; Tue, 25 Jul 2023 00:58:37 +0300 (EEST) Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 606A268C787 for ; Tue, 25 Jul 2023 00:58:31 +0300 (EEST) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id 80FBC10600E3 for ; Mon, 24 Jul 2023 21:58:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1690235910; s=s1; d=lynne.ee; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:Sender; bh=IyWrHlAPIqPUrOAzhbeKcf4pa7ZVTdZUj3mfbzB7dec=; b=mkMTfwOqdt4LaWZ4jmi6AcZQWbVc7fMsV1j6Irxl6RFxcN5p7sVljsfBVnzY5SwD J7k36QOqv3Maj10EnE/3/8+RZMlMOcxywCaGYb5fVC36p+aal53rGrRkVkmIpsuCHvg wZXTFQpBLBlRI5bOB8R4dBY85ikSZjfPtQgKmchDlynXXIPEv9SNGpAn/tiOT493hra dI6zyvY33foDwen7Dokzvmw6FmZYup2K2YMRbNRwKHGAkqdMSJ4Egnu39bZC1JIkc5z F6Qb6bgNzvgcyH4J6tv5ed+LIg3gl8/QQrGkUpSFt6tVv3vFGvKgy0/g21tS5TAS3YP LA4wt0UnyQ== Date: Mon, 24 Jul 2023 23:58:30 +0200 (CEST) From: Lynne To: Ffmpeg Devel Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_488969_993747633.1690235910798" Subject: [FFmpeg-devel] [PATCH 1/2] ffplay: port to lavu/tx 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" Archived-At: List-Archive: List-Post: ------=_Part_488969_993747633.1690235910798 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Patch attached. ------=_Part_488969_993747633.1690235910798 Content-Type: text/x-diff; charset=us-ascii; name=0001-ffplay-port-to-lavu-tx.patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-ffplay-port-to-lavu-tx.patch >From a3e8ab975d21b3240a63f3f09fe486e05083ab7d Mon Sep 17 00:00:00 2001 From: Lynne Date: Sat, 18 Feb 2023 13:14:31 +0100 Subject: [PATCH 1/2] ffplay: port to lavu/tx --- fftools/ffplay.c | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 5212ad053e..006da7ab57 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -47,7 +47,7 @@ #include "libavdevice/avdevice.h" #include "libswscale/swscale.h" #include "libavutil/opt.h" -#include "libavcodec/avfft.h" +#include "libavutil/tx.h" #include "libswresample/swresample.h" #include "libavfilter/avfilter.h" @@ -262,9 +262,11 @@ typedef struct VideoState { int16_t sample_array[SAMPLE_ARRAY_SIZE]; int sample_array_index; int last_i_start; - RDFTContext *rdft; + AVTXContext *rdft; + av_tx_fn rdft_fn; int rdft_bits; - FFTSample *rdft_data; + float *real_data; + AVComplexFloat *rdft_data; int xpos; double last_vis_time; SDL_Texture *vis_texture; @@ -1120,6 +1122,7 @@ static void video_audio_display(VideoState *s) fill_rectangle(s->xleft, y, s->width, 1); } } else { + int err = 0; if (realloc_texture(&s->vis_texture, SDL_PIXELFORMAT_ARGB8888, s->width, s->height, SDL_BLENDMODE_NONE, 1) < 0) return; @@ -1127,31 +1130,39 @@ static void video_audio_display(VideoState *s) s->xpos = 0; nb_display_channels= FFMIN(nb_display_channels, 2); if (rdft_bits != s->rdft_bits) { - av_rdft_end(s->rdft); - av_free(s->rdft_data); - s->rdft = av_rdft_init(rdft_bits, DFT_R2C); + const float rdft_scale = 1.0; + av_tx_uninit(&s->rdft); + av_freep(&s->real_data); + av_freep(&s->rdft_data); s->rdft_bits = rdft_bits; - s->rdft_data = av_malloc_array(nb_freq, 4 *sizeof(*s->rdft_data)); + s->real_data = av_malloc_array(nb_freq, 4 *sizeof(*s->real_data)); + s->rdft_data = av_malloc_array(nb_freq + 1, 2 *sizeof(*s->rdft_data)); + err = av_tx_init(&s->rdft, &s->rdft_fn, AV_TX_FLOAT_RDFT, + 0, 1 << rdft_bits, &rdft_scale, 0); } - if (!s->rdft || !s->rdft_data){ + if (err < 0 || !s->rdft_data) { av_log(NULL, AV_LOG_ERROR, "Failed to allocate buffers for RDFT, switching to waves display\n"); s->show_mode = SHOW_MODE_WAVES; } else { - FFTSample *data[2]; + float *data_in[2]; + AVComplexFloat *data[2]; SDL_Rect rect = {.x = s->xpos, .y = 0, .w = 1, .h = s->height}; uint32_t *pixels; int pitch; for (ch = 0; ch < nb_display_channels; ch++) { - data[ch] = s->rdft_data + 2 * nb_freq * ch; + data_in[ch] = s->real_data + 2 * nb_freq * ch; + data[ch] = s->rdft_data + nb_freq * ch; i = i_start + ch; for (x = 0; x < 2 * nb_freq; x++) { double w = (x-nb_freq) * (1.0 / nb_freq); - data[ch][x] = s->sample_array[i] * (1.0 - w * w); + data_in[ch][x] = s->sample_array[i] * (1.0 - w * w); i += channels; if (i >= SAMPLE_ARRAY_SIZE) i -= SAMPLE_ARRAY_SIZE; } - av_rdft_calc(s->rdft, data[ch]); + s->rdft_fn(s->rdft, data[ch], data_in[ch], sizeof(float)); + data[ch][0].im = data[ch][nb_freq].re; + data[ch][nb_freq].re = 0; } /* Least efficient way to do this, we should of course * directly access it but it is more than fast enough. */ @@ -1160,8 +1171,8 @@ static void video_audio_display(VideoState *s) pixels += pitch * s->height; for (y = 0; y < s->height; y++) { double w = 1 / sqrt(nb_freq); - int a = sqrt(w * sqrt(data[0][2 * y + 0] * data[0][2 * y + 0] + data[0][2 * y + 1] * data[0][2 * y + 1])); - int b = (nb_display_channels == 2 ) ? sqrt(w * hypot(data[1][2 * y + 0], data[1][2 * y + 1])) + int a = sqrt(w * sqrt(data[0][y].re * data[0][y].re + data[0][y].im * data[0][y].im)); + int b = (nb_display_channels == 2 ) ? sqrt(w * hypot(data[1][y].re, data[1][y].im)) : a; a = FFMIN(a, 255); b = FFMIN(b, 255); @@ -1197,7 +1208,8 @@ static void stream_component_close(VideoState *is, int stream_index) is->audio_buf = NULL; if (is->rdft) { - av_rdft_end(is->rdft); + av_tx_uninit(&is->rdft); + av_freep(&is->real_data); av_freep(&is->rdft_data); is->rdft = NULL; is->rdft_bits = 0; -- 2.40.1 ------=_Part_488969_993747633.1690235910798 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". ------=_Part_488969_993747633.1690235910798--