Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Erdinc Kaya via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Erdinc Kaya <erdinc@veed.io>
Subject: [FFmpeg-devel] [PATCH] Fix WAV bitrate calculation when bits_per_coded_sample != 8
Date: Mon, 17 Nov 2025 14:01:19 +0100
Message-ID: <bddc8a79-8fde-4296-b916-450bef6d7f41@veed.io> (raw)

- Correctly scale bitrate by bits_per_coded_sample instead of assuming 8 
bits per byte.
- Prevents wrong bitrate reports for 16-bit PCM WAV files.

Signed-off-by: Erdinc Kaya <erdinc@veed.io>
---
  libavformat/riffdec.c | 4 ++++
  1 file changed, 4 insertions(+)

diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c
index 30835d5f36..d63edc6377 100644
--- a/libavformat/riffdec.c
+++ b/libavformat/riffdec.c
@@ -130,6 +130,10 @@ int ff_get_wav_header(AVFormatContext *s, 
AVIOContext *pb,
              par->bits_per_coded_sample = avio_rb16(pb);
          }
      }
+
+    if (par->bits_per_coded_sample)
+        bitrate *= 8.0 / par->bits_per_coded_sample;
+
      if (id == 0xFFFE) {
          par->codec_tag = 0;
      } else {
-- 
2.43.0

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

             reply	other threads:[~2025-11-19 18:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-17 13:01 Erdinc Kaya via ffmpeg-devel [this message]
2025-11-25  1:24 ` [FFmpeg-devel] " Michael Niedermayer via ffmpeg-devel
2025-11-25  2:15 ` James Almer via ffmpeg-devel

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=bddc8a79-8fde-4296-b916-450bef6d7f41@veed.io \
    --to=ffmpeg-devel@ffmpeg.org \
    --cc=erdinc@veed.io \
    /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