Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Renjianguang-mi via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Renjianguang-mi <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] swresample: Delete matrix_flt to optimize memory (PR #20502)
Date: Fri, 12 Sep 2025 10:17:07 -0000
Message-ID: <175767222859.25.5466479572598387289@463a07221176> (raw)

PR #20502 opened by Renjianguang-mi
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20502
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20502.patch

float occupies 4 bytes, which can reduce 64K memory usage

Signed-off-by: renjianguang <renjianguang@xiaomi.com>


>From 5cd5775ad832551fc470a4f4255df8a9777f9e9d Mon Sep 17 00:00:00 2001
From: renjianguang <renjianguang@xiaomi.com>
Date: Fri, 12 Sep 2025 18:12:26 +0800
Subject: [PATCH] swresample: Delete matrix_flt to optimize memory

float occupies 4 bytes, which can reduce 64K memory usage

Signed-off-by: renjianguang <renjianguang@xiaomi.com>
---
 libswresample/rematrix.c            | 12 ++----------
 libswresample/swresample_internal.h |  1 -
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c
index f55b85a52d..cb57927108 100644
--- a/libswresample/rematrix.c
+++ b/libswresample/rematrix.c
@@ -69,13 +69,12 @@ int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride)
     if (!s || s->in_convert) // s needs to be allocated but not initialized
         return AVERROR(EINVAL);
     memset(s->matrix, 0, sizeof(s->matrix));
-    memset(s->matrix_flt, 0, sizeof(s->matrix_flt));
 
     nb_in = s->user_in_chlayout.nb_channels;
     nb_out = s->user_out_chlayout.nb_channels;
     for (out = 0; out < nb_out; out++) {
         for (in = 0; in < nb_in; in++)
-            s->matrix_flt[out][in] = s->matrix[out][in] = matrix[in];
+            s->matrix[out][in] = matrix[in];
         matrix += stride;
     }
     s->rematrix_custom = 1;
@@ -452,13 +451,6 @@ av_cold static int auto_matrix(SwrContext *s)
                            maxval, s->rematrix_volume, (double*)s->matrix,
                            s->matrix[1] - s->matrix[0], s->matrix_encoding, s);
 
-    if (ret >= 0 && s->int_sample_fmt == AV_SAMPLE_FMT_FLTP) {
-        int i, j;
-        for (i = 0; i < FF_ARRAY_ELEMS(s->matrix[0]); i++)
-            for (j = 0; j < FF_ARRAY_ELEMS(s->matrix[0]); j++)
-                s->matrix_flt[i][j] = s->matrix[i][j];
-    }
-
     return ret;
 }
 
@@ -628,7 +620,7 @@ int swri_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mus
                     float v=0;
                     for(j=0; j<s->matrix_ch[out_i][0]; j++){
                         in_i= s->matrix_ch[out_i][1+j];
-                        v+= ((float*)in->ch[in_i])[i] * s->matrix_flt[out_i][in_i];
+                        v+= ((float*)in->ch[in_i])[i] * (float)s->matrix[out_i][in_i];
                     }
                     ((float*)out->ch[out_i])[i]= v;
                 }
diff --git a/libswresample/swresample_internal.h b/libswresample/swresample_internal.h
index 21c9e33fa1..161adcdd8b 100644
--- a/libswresample/swresample_internal.h
+++ b/libswresample/swresample_internal.h
@@ -167,7 +167,6 @@ struct SwrContext {
     struct Resampler const *resampler;              ///< resampler virtual function table
 
     double matrix[SWR_CH_MAX][SWR_CH_MAX];          ///< floating point rematrixing coefficients
-    float matrix_flt[SWR_CH_MAX][SWR_CH_MAX];       ///< single precision floating point rematrixing coefficients
     uint8_t *native_matrix;
     uint8_t *native_one;
     uint8_t *native_simd_one;
-- 
2.49.1

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

                 reply	other threads:[~2025-09-12 10:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=175767222859.25.5466479572598387289@463a07221176 \
    --to=ffmpeg-devel@ffmpeg.org \
    --cc=code@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git