Browse Source

bitmapinfoheader: don't read/write the reserved RGBQUAD field in palette

The palette is appended as RGBQUAD after the BITMAPINFO [1] [2].
The RGBQUAD 4th value is reserved and should be 0 [3].

So we write it as 0 and read it as 0xFF (fully opaque RGBA). If the
palette had alpha information it will be lost on writing.

[1] https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapinfoheader
[2] https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapinfo
[3] https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-rgbquad
pull/162/head
Steve Lhomme 3 years ago
parent
commit
0a4bb395ff
  1. 9
      modules/demux/avi/bitmapinfoheader.h

9
modules/demux/avi/bitmapinfoheader.h

@ -200,8 +200,9 @@ static inline int ParseBitmapInfoHeader( const VLC_BITMAPINFOHEADER *p_bih, size
fmt->video.p_palette->i_entries = __MIN(i_bihextra/4, 256);
for( int k = 0; k < fmt->video.p_palette->i_entries; k++ )
{
for( int j = 0; j < 4; j++ )
for( int j = 0; j < 3; j++ )
fmt->video.p_palette->palette[k][j] = p_bihextra[4*k+j];
fmt->video.p_palette->palette[k][3] = 0xFF;
}
}
}
@ -350,7 +351,11 @@ static inline int CreateBitmapInfoHeader( const es_format_t *fmt,
else if( fmt->i_codec == VLC_CODEC_RGBP )
{
for( int i = 0; i < fmt->video.p_palette->i_entries; i++ )
memcpy( &p_bmiColors[i * 4], fmt->video.p_palette->palette[i], 4 );
{
for( int j = 0; i < 3; i++ )
p_bmiColors[i * 4 + j] = fmt->video.p_palette->palette[i][j];
p_bmiColors[i * 4 + 3] = 0;
}
p_bih->biClrUsed = fmt->video.p_palette->i_entries;
}
else if( fmt->i_extra )

Loading…
Cancel
Save