From: Yigithan Yigit <yigithanyigitdevel@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: thilo.borgmann@mail.de, yigithanyigitdevel@gmail.com Subject: [FFmpeg-devel] [PATCH v3 4/5] avfilter/af_volumedetect.c: reindent after last commit Date: Tue, 2 Jul 2024 04:33:53 +0300 Message-ID: <20240702013354.14942-5-yigithanyigitdevel@gmail.com> (raw) In-Reply-To: <20240702013354.14942-1-yigithanyigitdevel@gmail.com> --- libavfilter/af_volumedetect.c | 62 +++++++++++++++++------------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/libavfilter/af_volumedetect.c b/libavfilter/af_volumedetect.c index 778f0cac6c..a53212015d 100644 --- a/libavfilter/af_volumedetect.c +++ b/libavfilter/af_volumedetect.c @@ -160,40 +160,40 @@ static void print_stats(AVFilterContext *ctx) sum += vd->histogram[i]; } } else { - for (i = 0; i < 0x10000; i++) - nb_samples += vd->histogram[i]; - av_log(ctx, AV_LOG_INFO, "n_samples: %"PRId64"\n", nb_samples); - if (!nb_samples) - return; + for (i = 0; i < 0x10000; i++) + nb_samples += vd->histogram[i]; + av_log(ctx, AV_LOG_INFO, "n_samples: %"PRId64"\n", nb_samples); + if (!nb_samples) + return; - /* If nb_samples > 1<<34, there is a risk of overflow in the - multiplication or the sum: shift all histogram values to avoid that. - The total number of samples must be recomputed to avoid rounding - errors. */ - shift = av_log2(nb_samples >> 33); - for (i = 0; i < 0x10000; i++) { - nb_samples_shift += vd->histogram[i] >> shift; - power += (i - 0x8000) * (i - 0x8000) * (vd->histogram[i] >> shift); - } - if (!nb_samples_shift) - return; - power = (power + nb_samples_shift / 2) / nb_samples_shift; - av_assert0(power <= 0x8000 * 0x8000); - av_log(ctx, AV_LOG_INFO, "mean_volume: %.1f dB\n", -logdb((double)power, AV_SAMPLE_FMT_S16)); + /* If nb_samples > 1<<34, there is a risk of overflow in the + multiplication or the sum: shift all histogram values to avoid that. + The total number of samples must be recomputed to avoid rounding + errors. */ + shift = av_log2(nb_samples >> 33); + for (i = 0; i < 0x10000; i++) { + nb_samples_shift += vd->histogram[i] >> shift; + power += (i - 0x8000) * (i - 0x8000) * (vd->histogram[i] >> shift); + } + if (!nb_samples_shift) + return; + power = (power + nb_samples_shift / 2) / nb_samples_shift; + av_assert0(power <= 0x8000 * 0x8000); + av_log(ctx, AV_LOG_INFO, "mean_volume: %.1f dB\n", -logdb((double)power, AV_SAMPLE_FMT_S16)); - max_volume = 0x8000; - while (max_volume > 0 && !vd->histogram[0x8000 + max_volume] && - !vd->histogram[0x8000 - max_volume]) - max_volume--; - av_log(ctx, AV_LOG_INFO, "max_volume: %.1f dB\n", -logdb((double)(max_volume * max_volume), AV_SAMPLE_FMT_S16)); + max_volume = 0x8000; + while (max_volume > 0 && !vd->histogram[0x8000 + max_volume] && + !vd->histogram[0x8000 - max_volume]) + max_volume--; + av_log(ctx, AV_LOG_INFO, "max_volume: %.1f dB\n", -logdb((double)(max_volume * max_volume), AV_SAMPLE_FMT_S16)); - for (i = 0; i < 0x10000; i++) - histdb[(int)logdb((double)(i - 0x8000) * (i - 0x8000), AV_SAMPLE_FMT_S16)] += vd->histogram[i]; - for (i = 0; i <= MAX_DB && !histdb[i]; i++); - for (; i <= MAX_DB && sum < nb_samples / 1000; i++) { - av_log(ctx, AV_LOG_INFO, "histogram_%ddb: %"PRId64"\n", -i, histdb[i]); - sum += histdb[i]; - } + for (i = 0; i < 0x10000; i++) + histdb[(int)logdb((double)(i - 0x8000) * (i - 0x8000), AV_SAMPLE_FMT_S16)] += vd->histogram[i]; + for (i = 0; i <= MAX_DB && !histdb[i]; i++); + for (; i <= MAX_DB && sum < nb_samples / 1000; i++) { + av_log(ctx, AV_LOG_INFO, "histogram_%ddb: %"PRId64"\n", -i, histdb[i]); + sum += histdb[i]; + } } } -- 2.45.2 _______________________________________________ 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".
next prev parent reply other threads:[~2024-07-02 1:34 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-07-02 1:33 [FFmpeg-devel] [PATCH v3 0/5] avfilter/af_volumedetect.c: Add 32bit float audio Yigithan Yigit 2024-07-02 1:33 ` [FFmpeg-devel] [PATCH v3 1/5] avfilter/af_volumedetect.c: Move logdb function Yigithan Yigit 2024-07-02 1:33 ` [FFmpeg-devel] [PATCH v3 2/5] avfilter/af_volumedetect.c: Add 32bit float audio support Yigithan Yigit 2024-07-02 5:46 ` Rémi Denis-Courmont 2024-07-02 5:49 ` Rémi Denis-Courmont 2024-07-02 5:51 ` Rémi Denis-Courmont 2024-07-02 11:46 ` Yigithan Yigit 2024-07-02 1:33 ` [FFmpeg-devel] [PATCH v3 3/5] avfilter/af_volumedetect.c: Added functions for int/float and planar/packed Yigithan Yigit 2024-07-02 7:50 ` Anton Khirnov 2024-07-02 1:33 ` Yigithan Yigit [this message] 2024-07-02 1:33 ` [FFmpeg-devel] [PATCH v3 5/5] Replace division with ldexp Yigithan Yigit
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=20240702013354.14942-5-yigithanyigitdevel@gmail.com \ --to=yigithanyigitdevel@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=thilo.borgmann@mail.de \ /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