From: GXTX via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: GXTX <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] avformat/xmv: Better handling of audio compressions relation to sample blocks (PR #20986)
Date: Thu, 20 Nov 2025 21:32:44 -0000
Message-ID: <176367436518.59.8100985951632538316@2cb04c0e5124> (raw)
PR #20986 opened by GXTX
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20986
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20986.patch
Fixes #20983
I believe this is mostly correct, however, I did run into *another* file that fails to en/decode properly when compression is 1 and bitrate is 44100, specifically the Valve intro XMV found on Half-Life 2.
This is odd because it has the same header info from a different file which is properly handled.
HL2: Valve_Leader.xmv
```
Version: 4
Video Width: 280
Video Height: 1e0
Duration: 44ef
# of audio tracks: 1
0: Compression: 1, Channels: 2, Sample Rate: ac44, BPS: 10, Flags: 0
```
HL2: Demo_Attract.xmv
```
Version: 4
Video Width: 280
Video Height: 1e0
Duration: 1fad9
# of audio tracks: 1
0: Compression: 1, Channels: 2, Sample Rate: ac44, BPS: 10, Flags: 0
```
In either case the changes here make FFmpeg's XMV en/decoder mostly functional.
Let me know if I can provide any samples, etc. and I can obviously remove the `#if 0` block if requested.
>From 86bee2b7118224064b9e4df90956f7148fc45717 Mon Sep 17 00:00:00 2001
From: wutno <aaron@installgentoo.net>
Date: Thu, 20 Nov 2025 16:24:08 -0500
Subject: [PATCH] avformat/xmv: Better handling of audio compressions relation
to sample blocks
---
libavformat/xmv.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/libavformat/xmv.c b/libavformat/xmv.c
index ed59f7b85b..098b0df0f6 100644
--- a/libavformat/xmv.c
+++ b/libavformat/xmv.c
@@ -194,7 +194,10 @@ static int xmv_read_header(AVFormatContext *s)
packet->sample_rate *
packet->channels;
packet->block_align = XMV_BLOCK_ALIGN_SIZE * packet->channels;
- packet->block_samples = 64;
+ if (packet->compression == 1)
+ packet->block_samples = XMV_BLOCK_ALIGN_SIZE / packet->channels;
+ else
+ packet->block_samples = 64;
packet->codec_id = ff_wav_codec_get_id(packet->compression,
packet->bits_per_sample);
@@ -202,6 +205,12 @@ static int xmv_read_header(AVFormatContext *s)
packet->frame_size = 0;
packet->block_count = 0;
+
+#if 0
+ if (packet->compression == 1 && packet->sample_rate == 44100) {
+ av_log(s, AV_LOG_WARNING, "We may not be able to handle this properly...\n");
+ }
+#endif
/* TODO: ADPCM'd 5.1 sound is encoded in three separate streams.
* Those need to be interleaved to a proper 5.1 stream. */
@@ -340,7 +349,7 @@ static int xmv_process_packet_header(AVFormatContext *s)
ast->codecpar->sample_rate = packet->sample_rate;
ast->codecpar->bits_per_coded_sample = packet->bits_per_sample;
ast->codecpar->bit_rate = packet->bit_rate;
- ast->codecpar->block_align = 36 * packet->channels;
+ ast->codecpar->block_align = XMV_BLOCK_ALIGN_SIZE * packet->channels;
avpriv_set_pts_info(ast, 32, packet->block_samples, packet->sample_rate);
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
reply other threads:[~2025-11-20 21:33 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=176367436518.59.8100985951632538316@2cb04c0e5124 \
--to=ffmpeg-devel@ffmpeg.org \
--cc=code@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