Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] Fix WAV bitrate calculation when bits_per_coded_sample != 8
@ 2025-11-17 13:01 Erdinc Kaya via ffmpeg-devel
  2025-11-25  1:24 ` [FFmpeg-devel] " Michael Niedermayer via ffmpeg-devel
  2025-11-25  2:15 ` James Almer via ffmpeg-devel
  0 siblings, 2 replies; 3+ messages in thread
From: Erdinc Kaya via ffmpeg-devel @ 2025-11-17 13:01 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Erdinc Kaya

- 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-11-25  2:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-17 13:01 [FFmpeg-devel] [PATCH] Fix WAV bitrate calculation when bits_per_coded_sample != 8 Erdinc Kaya via ffmpeg-devel
2025-11-25  1:24 ` [FFmpeg-devel] " Michael Niedermayer via ffmpeg-devel
2025-11-25  2:15 ` James Almer via ffmpeg-devel

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