diff mbox series

[FFmpeg-devel,1/2] lavc/riffenc: Fix msrle support on Windows 95

Message ID 97f9c4e9b0d09796eecb50419217bed9b97a0d81.camel@haerdin.se
State New
Headers show
Series [FFmpeg-devel,1/2] lavc/riffenc: Fix msrle support on Windows 95 | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Tomas Härdin June 8, 2023, 11:22 a.m. UTC
This is important for the GoldSrc community among others.

/Tomas

Comments

Paul B Mahol June 8, 2023, 11:27 a.m. UTC | #1
But does this break it on other platforms?
Tomas Härdin June 8, 2023, 11:44 a.m. UTC | #2
tor 2023-06-08 klockan 13:27 +0200 skrev Paul B Mahol:
> But does this break it on other platforms?

That is a good question. What other RIFF decoders are there for which
MSRLE support is important and depends on behavior different from VfW?
mpv and vlc work just fine.

/Tomas
Tomas Härdin June 19, 2023, 12:26 p.m. UTC | #3
Will push later today

/Tomas
Leo Izen June 19, 2023, 3:42 p.m. UTC | #4
On 6/8/23 07:44, Tomas Härdin wrote:
> tor 2023-06-08 klockan 13:27 +0200 skrev Paul B Mahol:
>> But does this break it on other platforms?
> 
> That is a good question. What other RIFF decoders are there for which
> MSRLE support is important and depends on behavior different from VfW?
> mpv and vlc work just fine.
> 
> /Tomas
> 

mpv's RIFF decoder is really avformat, so this doesn't say much. VLC has 
its own though, iirc.

- Leo Izen
Tomas Härdin June 19, 2023, 4:57 p.m. UTC | #5
mån 2023-06-19 klockan 11:42 -0400 skrev Leo Izen:
> On 6/8/23 07:44, Tomas Härdin wrote:
> > tor 2023-06-08 klockan 13:27 +0200 skrev Paul B Mahol:
> > > But does this break it on other platforms?
> > 
> > That is a good question. What other RIFF decoders are there for
> > which
> > MSRLE support is important and depends on behavior different from
> > VfW?
> > mpv and vlc work just fine.
> > 
> > /Tomas
> > 
> 
> mpv's RIFF decoder is really avformat, so this doesn't say much. VLC
> has 
> its own though, iirc.

Yeah. Also we'd be hard pressed to find an msrle decoder that isn't
either ffmpeg, vlc or VfW

It might be necessary to do this same thing for more codecs. We only
tested msrle which was painful enough. I wouldn't be surprised if say
msvideo1 requires similar hacks. This patch is conservative until we
learn why VfW needs this.

/Tomas
diff mbox series

Patch

From c5c2d535b3e5dc94b063e13359e475e9ce18e1b6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git@haerdin.se>
Date: Thu, 8 Jun 2023 11:55:28 +0200
Subject: [PATCH 1/2] lavc/riffenc: Fix msrle support on Windows 95

---
 libavformat/riffenc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index 179b0f12cb..3325419b94 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -239,14 +239,16 @@  void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par,
     /* depth */
     avio_wl16(pb, par->bits_per_coded_sample ? par->bits_per_coded_sample : 24);
     /* compression type */
-    avio_wl32(pb, par->codec_tag);
+    // MSRLE compatibility with Media Player 3.1 and Windows 95
+    avio_wl32(pb, par->codec_id == AV_CODEC_ID_MSRLE ? 1 : par->codec_tag);
     avio_wl32(pb, (par->width * par->height * (par->bits_per_coded_sample ? par->bits_per_coded_sample : 24)+7) / 8);
     avio_wl32(pb, 0);
     avio_wl32(pb, 0);
     /* Number of color indices in the color table that are used.
      * A value of 0 means 2^biBitCount indices, but this doesn't work
      * with Windows Media Player and files containing xxpc chunks. */
-    avio_wl32(pb, pal_avi ? 1 << par->bits_per_coded_sample : 0);
+    // MSRLE on Windows 95 requires a zero here
+    avio_wl32(pb, pal_avi && par->codec_id != AV_CODEC_ID_MSRLE ? 1 << par->bits_per_coded_sample : 0);
     avio_wl32(pb, 0);
 
     if (!ignore_extradata) {
-- 
2.30.2