Commit a67afb66 authored by KO Myung-Hun's avatar KO Myung-Hun Committed by Rafaël Carré

Replace the bitmap structures of Microsoft with ones of VLC

Signed-off-by: default avatarRafaël Carré <funman@videolan.org>
Modified-by: default avatarRafaël Carré <funman@videolan.org>
    ... Replace them in ASF demux as well
parent 066c6231
......@@ -106,8 +106,9 @@ _WAVEHEADER {
} WAVEHEADER;
#endif /* _WAVEHEADER_ */
#if !defined(_BITMAPINFOHEADER_) && !defined(WIN32)
#define _BITMAPINFOHEADER_
#ifndef _VLC_BITMAPINFOHEADER_
#define _VLC_BITMAPINFOHEADER_
typedef struct
ATTR_PACKED
{
......@@ -122,14 +123,14 @@ ATTR_PACKED
uint32_t biYPelsPerMeter;
uint32_t biClrUsed;
uint32_t biClrImportant;
} BITMAPINFOHEADER, *PBITMAPINFOHEADER, *LPBITMAPINFOHEADER;
} VLC_BITMAPINFOHEADER, *VLC_PBITMAPINFOHEADER, *VLC_LPBITMAPINFOHEADER;
typedef struct
ATTR_PACKED
{
BITMAPINFOHEADER bmiHeader;
int bmiColors[1];
} BITMAPINFO, *LPBITMAPINFO;
VLC_BITMAPINFOHEADER bmiHeader;
int bmiColors[1];
} VLC_BITMAPINFO, *VLC_LPBITMAPINFO;
#endif
#ifndef _RECT32_
......@@ -151,12 +152,12 @@ typedef int64_t REFERENCE_TIME;
typedef struct
ATTR_PACKED
{
RECT32 rcSource;
RECT32 rcTarget;
uint32_t dwBitRate;
uint32_t dwBitErrorRate;
REFERENCE_TIME AvgTimePerFrame;
BITMAPINFOHEADER bmiHeader;
RECT32 rcSource;
RECT32 rcTarget;
uint32_t dwBitRate;
uint32_t dwBitErrorRate;
REFERENCE_TIME AvgTimePerFrame;
VLC_BITMAPINFOHEADER bmiHeader;
} VIDEOINFOHEADER;
#endif
......@@ -187,12 +188,12 @@ ATTR_PACKED
typedef struct
ATTR_PACKED
{
RECT32 rcSource;
RECT32 rcTarget;
uint32_t dwBitRate;
uint32_t dwBitErrorRate;
REFERENCE_TIME AvgTimePerFrame;
BITMAPINFOHEADER bmiHeader;
RECT32 rcSource;
RECT32 rcTarget;
uint32_t dwBitRate;
uint32_t dwBitErrorRate;
REFERENCE_TIME AvgTimePerFrame;
VLC_BITMAPINFOHEADER bmiHeader;
union
{
......
......@@ -35,7 +35,7 @@
#include <vlc_meta.h> /* vlc_meta_Set*, vlc_meta_New */
#include <vlc_access.h> /* GET_PRIVATE_ID_STATE */
#include <vlc_codecs.h> /* BITMAPINFOHEADER, WAVEFORMATEX */
#include <vlc_codecs.h> /* VLC_BITMAPINFOHEADER, WAVEFORMATEX */
#include "libasf.h"
......@@ -859,7 +859,7 @@ static int DemuxInit( demux_t *p_demux )
else if( guidcmp( &p_sp->i_stream_type,
&asf_object_stream_type_video ) &&
p_sp->i_type_specific_data_length >= 11 +
sizeof( BITMAPINFOHEADER ) )
sizeof( VLC_BITMAPINFOHEADER ) )
{
uint8_t *p_data = &p_sp->p_type_specific_data[11];
......@@ -883,13 +883,13 @@ static int DemuxInit( demux_t *p_demux )
}
if( p_sp->i_type_specific_data_length > 11 +
sizeof( BITMAPINFOHEADER ) )
sizeof( VLC_BITMAPINFOHEADER ) )
{
fmt.i_extra = __MIN( GetDWLE( p_data ),
p_sp->i_type_specific_data_length - 11 -
sizeof( BITMAPINFOHEADER ) );
sizeof( VLC_BITMAPINFOHEADER ) );
fmt.p_extra = malloc( fmt.i_extra );
memcpy( fmt.p_extra, &p_data[sizeof( BITMAPINFOHEADER )],
memcpy( fmt.p_extra, &p_data[sizeof( VLC_BITMAPINFOHEADER )],
fmt.i_extra );
}
......
......@@ -531,8 +531,8 @@ static int Open( vlc_object_t * p_this )
fmt.video.i_frame_rate = tk->i_rate;
fmt.video.i_frame_rate_base = tk->i_scale;
fmt.i_extra =
__MIN( p_vids->p_bih->biSize - sizeof( BITMAPINFOHEADER ),
p_vids->i_chunk_size - sizeof(BITMAPINFOHEADER) );
__MIN( p_vids->p_bih->biSize - sizeof( VLC_BITMAPINFOHEADER ),
p_vids->i_chunk_size - sizeof(VLC_BITMAPINFOHEADER) );
if( fmt.i_extra > 0 )
{
fmt.p_extra = malloc( fmt.i_extra );
......@@ -560,7 +560,7 @@ static int Open( vlc_object_t * p_this )
if( fmt.video.i_bits_per_pixel > 0 && fmt.video.i_bits_per_pixel <= 8 )
{
/* The palette is not always included in biSize */
fmt.i_extra = p_vids->i_chunk_size - sizeof(BITMAPINFOHEADER);
fmt.i_extra = p_vids->i_chunk_size - sizeof(VLC_BITMAPINFOHEADER);
if( fmt.i_extra > 0 && fmt.p_extra )
{
const uint8_t *p_pal = fmt.p_extra;
......
......@@ -27,7 +27,7 @@
#include <vlc_common.h>
#include <vlc_demux.h>
#include <vlc_codecs.h> /* BITMAPINFOHEADER */
#include <vlc_codecs.h> /* VLC_BITMAPINFOHEADER */
#include "libavi.h"
......@@ -401,11 +401,11 @@ static int AVI_ChunkRead_strf( stream_t *s, avi_chunk_t *p_chk )
{
p_chk->strf.vids.p_bih->biSize = p_chk->common.i_chunk_size;
}
if( p_chk->common.i_chunk_size > sizeof(BITMAPINFOHEADER) )
if( p_chk->common.i_chunk_size > sizeof(VLC_BITMAPINFOHEADER) )
{
memcpy( &p_chk->strf.vids.p_bih[1],
p_buff + 8 + sizeof(BITMAPINFOHEADER), /* 8=fourrc+size */
p_chk->common.i_chunk_size -sizeof(BITMAPINFOHEADER) );
p_buff + 8 + sizeof(VLC_BITMAPINFOHEADER), /* 8=fourrc+size */
p_chk->common.i_chunk_size -sizeof(VLC_BITMAPINFOHEADER) );
}
#ifdef AVI_DEBUG
msg_Dbg( (vlc_object_t*)s,
......
......@@ -124,8 +124,8 @@ typedef struct avi_chunk_strf_auds_s
typedef struct avi_chunk_strf_vids_s
{
AVI_CHUNK_COMMON
int i_cat;
BITMAPINFOHEADER *p_bih;
int i_cat;
VLC_BITMAPINFOHEADER *p_bih;
} avi_chunk_strf_vids_t;
typedef union avi_chunk_strf_u
......
......@@ -919,24 +919,24 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
if( !strcmp( p_tk->psz_codec, "V_MS/VFW/FOURCC" ) )
{
if( p_tk->i_extra_data < (int)sizeof( BITMAPINFOHEADER ) )
if( p_tk->i_extra_data < (int)sizeof( VLC_BITMAPINFOHEADER ) )
{
msg_Err( &sys.demuxer, "missing/invalid BITMAPINFOHEADER" );
msg_Err( &sys.demuxer, "missing/invalid VLC_BITMAPINFOHEADER" );
p_tk->fmt.i_codec = VLC_FOURCC( 'u', 'n', 'd', 'f' );
}
else
{
BITMAPINFOHEADER *p_bih = (BITMAPINFOHEADER*)p_tk->p_extra_data;
VLC_BITMAPINFOHEADER *p_bih = (VLC_BITMAPINFOHEADER*)p_tk->p_extra_data;
p_tk->fmt.video.i_width = GetDWLE( &p_bih->biWidth );
p_tk->fmt.video.i_height= GetDWLE( &p_bih->biHeight );
p_tk->fmt.i_codec = GetFOURCC( &p_bih->biCompression );
p_tk->fmt.i_extra = GetDWLE( &p_bih->biSize ) - sizeof( BITMAPINFOHEADER );
p_tk->fmt.i_extra = GetDWLE( &p_bih->biSize ) - sizeof( VLC_BITMAPINFOHEADER );
if( p_tk->fmt.i_extra > 0 )
{
/* Very unlikely yet possible: bug #5659*/
size_t maxlen = p_tk->i_extra_data - sizeof( BITMAPINFOHEADER );
size_t maxlen = p_tk->i_extra_data - sizeof( VLC_BITMAPINFOHEADER );
p_tk->fmt.i_extra = ( p_tk->fmt.i_extra < maxlen )?
p_tk->fmt.i_extra : maxlen;
......
......@@ -575,7 +575,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
}
}
tk->i_extra = 11 + sizeof( BITMAPINFOHEADER ) + i_codec_extra;
tk->i_extra = 11 + sizeof( VLC_BITMAPINFOHEADER ) + i_codec_extra;
tk->p_extra = malloc( tk->i_extra );
if( !tk->p_extra )
{
......@@ -586,8 +586,8 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
bo_addle_u32( &bo, p_input->p_fmt->video.i_width );
bo_addle_u32( &bo, p_input->p_fmt->video.i_height );
bo_add_u8 ( &bo, 0x02 ); /* flags */
bo_addle_u16( &bo, sizeof( BITMAPINFOHEADER ) + i_codec_extra );
bo_addle_u32( &bo, sizeof( BITMAPINFOHEADER ) + i_codec_extra );
bo_addle_u16( &bo, sizeof( VLC_BITMAPINFOHEADER ) + i_codec_extra );
bo_addle_u32( &bo, sizeof( VLC_BITMAPINFOHEADER ) + i_codec_extra );
bo_addle_u32( &bo, p_input->p_fmt->video.i_width );
bo_addle_u32( &bo, p_input->p_fmt->video.i_height );
bo_addle_u16( &bo, 1 );
......
......@@ -75,8 +75,8 @@ typedef struct avi_stream_s
float f_fps;
int i_bitrate;
BITMAPINFOHEADER *p_bih;
WAVEFORMATEX *p_wf;
VLC_BITMAPINFOHEADER *p_bih;
WAVEFORMATEX *p_wf;
} avi_stream_t;
......@@ -370,7 +370,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
p_sys->i_stream_video = p_sys->i_streams;
}
p_stream->p_wf = NULL;
p_stream->p_bih = malloc( sizeof( BITMAPINFOHEADER ) +
p_stream->p_bih = malloc( sizeof( VLC_BITMAPINFOHEADER ) +
p_input->p_fmt->i_extra );
if( !p_stream->p_bih )
{
......@@ -378,7 +378,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
return VLC_ENOMEM;
}
#define p_bih p_stream->p_bih
p_bih->biSize = sizeof( BITMAPINFOHEADER ) +
p_bih->biSize = sizeof( VLC_BITMAPINFOHEADER ) +
p_input->p_fmt->i_extra;
if( p_input->p_fmt->i_extra > 0 )
{
......@@ -478,7 +478,7 @@ static int Mux ( sout_mux_t *p_mux )
== VLC_FOURCC( 'X', 'V', 'I', 'D' ) )
{
int i_header_length =
p_stream->p_bih->biSize - sizeof(BITMAPINFOHEADER);
p_stream->p_bih->biSize - sizeof(VLC_BITMAPINFOHEADER);
p_data = block_Realloc( p_data,
i_header_length, p_data->i_buffer );
if( !p_data)
......@@ -811,7 +811,7 @@ static int avi_HeaderAdd_strf( buffer_out_t *p_bo, avi_stream_t *p_stream )
bo_AddDWordLE( p_bo, p_stream->p_bih->biClrUsed );
bo_AddDWordLE( p_bo, p_stream->p_bih->biClrImportant );
bo_AddMem( p_bo,
p_stream->p_bih->biSize - sizeof( BITMAPINFOHEADER ),
p_stream->p_bih->biSize - sizeof( VLC_BITMAPINFOHEADER ),
(uint8_t*)&p_stream->p_bih[1] );
break;
}
......
......@@ -59,8 +59,8 @@ typedef unsigned long DWORD;
#define BI_RGB 0L
#if !defined(_BITMAPFILEHEADER_)
#define _BITMAPFILEHEADER_
#if !defined(_VLC_BITMAPFILEHEADER_)
#define _VLC_BITMAPFILEHEADER_
typedef struct
#ifdef HAVE_ATTRIBUTE_PACKED
__attribute__((__packed__))
......@@ -71,7 +71,7 @@ typedef struct
uint16_t bfReserved1;
uint16_t bfReserved2;
uint32_t bfOffBits;
} BITMAPFILEHEADER, *LPBITMAPFILEHEADER, *PBITMAPFILEHEADER;
} VLC_BITMAPFILEHEADER, *VLC_LPBITMAPFILEHEADER, *VLC_PBITMAPFILEHEADER;
#endif
#endif
......
......@@ -88,7 +88,7 @@ ATMO_BOOL CAtmoExternalCaptureInput::Close(void)
5. let the thread wake up and return imediately to the caller
so that the real videoout wouldn't be stop for a too long time
*/
void CAtmoExternalCaptureInput::DeliverNewSourceDataPaket(BITMAPINFOHEADER *bmpInfoHeader,void *pixelData)
void CAtmoExternalCaptureInput::DeliverNewSourceDataPaket(VLC_BITMAPINFOHEADER *bmpInfoHeader,void *pixelData)
{
/*
normaly we should protect this area of code by critical_section or a mutex,
......
......@@ -36,7 +36,7 @@ protected:
CRITICAL_SECTION m_BufferLock;
#endif
BITMAPINFOHEADER m_CurrentFrameHeader;
VLC_BITMAPINFOHEADER m_CurrentFrameHeader;
void *m_pCurrentFramePixels;
virtual DWORD Execute(void);
......@@ -47,7 +47,7 @@ public:
this method is called from the com server AtmoLiveViewControlImpl!
or inside videolan from the filter method to start a new processing
*/
void DeliverNewSourceDataPaket(BITMAPINFOHEADER *bmpInfoHeader,void *pixelData);
void DeliverNewSourceDataPaket(VLC_BITMAPINFOHEADER *bmpInfoHeader,void *pixelData);
public:
CAtmoExternalCaptureInput(CAtmoDynData *pAtmoDynData);
......
......@@ -191,8 +191,8 @@ int CAtmoZoneDefinition::LoadGradientFromBitmap(char *pszBitmap)
// transform 256 color image (gray scale!)
// into m_basicWeight or use the GREEN value of a 24bit image!
// channel of a true color bitmap!
BITMAPINFO bmpInfo;
BITMAPFILEHEADER bmpFileHeader;
VLC_BITMAPINFO bmpInfo;
VLC_BITMAPFILEHEADER bmpFileHeader;
/*
ATMO_LOAD_GRADIENT_FILENOTFOND
......@@ -206,7 +206,7 @@ int CAtmoZoneDefinition::LoadGradientFromBitmap(char *pszBitmap)
if(!bmp)
return ATMO_LOAD_GRADIENT_FILENOTFOND;
if(fread(&bmpFileHeader, sizeof(BITMAPFILEHEADER), 1, bmp) != 1)
if(fread(&bmpFileHeader, sizeof(VLC_BITMAPFILEHEADER), 1, bmp) != 1)
{
fclose(bmp);
return ATMO_LOAD_GRADIENT_FAILED_SIZE;
......@@ -218,7 +218,7 @@ int CAtmoZoneDefinition::LoadGradientFromBitmap(char *pszBitmap)
return ATMO_LOAD_GRADIENT_FAILED_HEADER;
}
if(fread(&bmpInfo, sizeof(BITMAPINFO), 1, bmp) != 1)
if(fread(&bmpInfo, sizeof(VLC_BITMAPINFO), 1, bmp) != 1)
{
fclose(bmp);
return ATMO_LOAD_GRADIENT_FAILED_SIZE;
......
......@@ -774,7 +774,7 @@ struct filter_sys_t
/* storage for temporal settings "volatile" */
CAtmoDynData *p_atmo_dyndata;
/* initialized for buildin driver with AtmoCreateTransferBuffers */
BITMAPINFOHEADER mini_image_format;
VLC_BITMAPINFOHEADER mini_image_format;
/* is only use buildin driver! */
uint8_t *p_atmo_transfer_buffer;
/* end buildin driver */
......@@ -991,9 +991,9 @@ static void AtmoCreateTransferBuffers(filter_t *p_filter,
p_sys->p_atmo_transfer_buffer = (uint8_t *)malloc(bytePerPixel *
width * height);
memset(&p_sys->mini_image_format,0,sizeof(BITMAPINFOHEADER));
memset(&p_sys->mini_image_format,0,sizeof(VLC_BITMAPINFOHEADER));
p_sys->mini_image_format.biSize = sizeof(BITMAPINFOHEADER);
p_sys->mini_image_format.biSize = sizeof(VLC_BITMAPINFOHEADER);
p_sys->mini_image_format.biWidth = width;
p_sys->mini_image_format.biHeight = height;
p_sys->mini_image_format.biBitCount = bytePerPixel*8;
......@@ -2192,12 +2192,12 @@ static void ExtractMiniImage_YUV(filter_sys_t *p_sys,
void SaveBitmap(filter_sys_t *p_sys, uint8_t *p_pixels, char *psz_filename)
{
/* for debug out only used*/
BITMAPINFO bmp_info;
BITMAPFILEHEADER bmp_fileheader;
VLC_BITMAPINFO bmp_info;
VLC_BITMAPFILEHEADER bmp_fileheader;
FILE *fp_bitmap;
memset(&bmp_info, 0, sizeof(BITMAPINFO));
bmp_info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
memset(&bmp_info, 0, sizeof(VLC_BITMAPINFO));
bmp_info.bmiHeader.biSize = sizeof(VLC_BITMAPINFOHEADER);
bmp_info.bmiHeader.biSizeImage = p_sys->i_atmo_height *
p_sys->i_atmo_width * 4;
bmp_info.bmiHeader.biCompression = BI_RGB;
......@@ -2208,18 +2208,18 @@ void SaveBitmap(filter_sys_t *p_sys, uint8_t *p_pixels, char *psz_filename)
bmp_fileheader.bfReserved1 = 0;
bmp_fileheader.bfReserved2 = 0;
bmp_fileheader.bfSize = sizeof(BITMAPFILEHEADER) +
sizeof(BITMAPINFOHEADER) +
bmp_fileheader.bfSize = sizeof(VLC_BITMAPFILEHEADER) +
sizeof(VLC_BITMAPINFOHEADER) +
bmp_info.bmiHeader.biSizeImage;
bmp_fileheader.bfType = VLC_TWOCC('B','M');
bmp_fileheader.bfOffBits = sizeof(BITMAPFILEHEADER) +
sizeof(BITMAPINFOHEADER);
bmp_fileheader.bfOffBits = sizeof(VLC_BITMAPFILEHEADER) +
sizeof(VLC_BITMAPINFOHEADER);
fp_bitmap = fopen(psz_filename,"wb");
if( fp_bitmap != NULL)
{
fwrite(&bmp_fileheader, sizeof(BITMAPFILEHEADER), 1, fp_bitmap);
fwrite(&bmp_info.bmiHeader, sizeof(BITMAPINFOHEADER), 1, fp_bitmap);
fwrite(&bmp_fileheader, sizeof(VLC_BITMAPFILEHEADER), 1, fp_bitmap);
fwrite(&bmp_info.bmiHeader, sizeof(VLC_BITMAPINFOHEADER), 1, fp_bitmap);
fwrite(p_pixels, bmp_info.bmiHeader.biSizeImage, 1, fp_bitmap);
fclose(fp_bitmap);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment