Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Shiqi Zhu <hiccupzhu@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Shiqi Zhu <hiccupzhu@gmail.com>
Subject: [FFmpeg-devel] [PATCH] avfilter/af_amix: fix amix decreased sound output
Date: Wed, 12 Jun 2024 18:10:16 +0800
Message-ID: <20240612101016.2023960-1-hiccupzhu@gmail.com> (raw)

fix he issue of decreased sound output when one or more input of the amix settings is set to EOF.

Signed-off-by: Shiqi Zhu <hiccupzhu@gmail.com>
---
 libavfilter/af_amix.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c
index ade4ef76a8..3ff85650a7 100644
--- a/libavfilter/af_amix.c
+++ b/libavfilter/af_amix.c
@@ -216,11 +216,11 @@ static void calculate_scales(MixContext *s, int nb_samples)
     int i;
 
     for (i = 0; i < s->nb_inputs; i++)
-        if (s->input_state[i] & INPUT_ON)
+        if ((s->input_state[i] & INPUT_ON) && av_audio_fifo_size(s->fifos[i]) > 0)
             weight_sum += FFABS(s->weights[i]);
 
     for (i = 0; i < s->nb_inputs; i++) {
-        if (s->input_state[i] & INPUT_ON) {
+        if ((s->input_state[i] & INPUT_ON) && av_audio_fifo_size(s->fifos[i]) > 0) {
             if (s->scale_norm[i] > weight_sum / FFABS(s->weights[i])) {
                 s->scale_norm[i] -= ((s->weight_sum / FFABS(s->weights[i])) / s->nb_inputs) *
                                     nb_samples / (s->dropout_transition * s->sample_rate);
@@ -230,7 +230,7 @@ static void calculate_scales(MixContext *s, int nb_samples)
     }
 
     for (i = 0; i < s->nb_inputs; i++) {
-        if (s->input_state[i] & INPUT_ON) {
+        if ((s->input_state[i] & INPUT_ON) && av_audio_fifo_size(s->fifos[i]) > 0) {
             if (!s->normalize)
                 s->input_scale[i] = FFABS(s->weights[i]);
             else
-- 
2.34.1

_______________________________________________
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".

                 reply	other threads:[~2024-06-12 10:10 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=20240612101016.2023960-1-hiccupzhu@gmail.com \
    --to=hiccupzhu@gmail.com \
    --cc=ffmpeg-devel@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