From: James Almer via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: James Almer <jamrial@gmail.com>
Subject: [FFmpeg-devel] Re: [PATCH] Fix WAV bitrate calculation when bits_per_coded_sample != 8
Date: Mon, 24 Nov 2025 23:15:50 -0300
Message-ID: <280d83bd-c827-4762-a3c4-5ce053610265@gmail.com> (raw)
In-Reply-To: <bddc8a79-8fde-4296-b916-450bef6d7f41@veed.io>
[-- Attachment #1.1.1: Type: text/plain, Size: 1432 bytes --]
On 11/17/2025 10:01 AM, Erdinc Kaya via ffmpeg-devel wrote:
> - Correctly scale bitrate by bits_per_coded_sample instead of assuming 8
> bits per byte.
When is a byte not 8 bits?
> - Prevents wrong bitrate reports for 16-bit PCM WAV files.
Do you have a sample that gets the wrong bitrate? I generated one just
now, a 1 second 44100Hz 16bit stereo pcm wav file, and it gave me the
correct bitrate of 1411 kb/s.
This function reads bitrate from a coded value in the container,
BytePerSec, which is converted to bits. So not sure why you think it
needs to be altered.
>
> 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;
bits_per_coded_sample is going to be 16 for a 16 bit pcm sample,
clearly, so this here will halve the value in bitrate.
> +
> if (id == 0xFFFE) {
> par->codec_tag = 0;
> } else {
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
[-- Attachment #2: Type: text/plain, Size: 163 bytes --]
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
prev parent reply other threads:[~2025-11-25 2:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-17 13:01 [FFmpeg-devel] " 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 [this message]
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=280d83bd-c827-4762-a3c4-5ce053610265@gmail.com \
--to=ffmpeg-devel@ffmpeg.org \
--cc=jamrial@gmail.com \
/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