>From d872a75ee331c2d3998d055aedf60d2818583f22 Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <komh@chollian.net>
Date: Sat, 28 Jan 2012 22:38:08 +0900
Subject: [PATCH 8/8] Replace the bitmap structures of Microsoft with ones of VLC

---
 include/vlc_codecs.h                               |   37 ++++++++++---------
 modules/demux/avi/avi.c                            |    6 ++--
 modules/demux/avi/libavi.c                         |    8 ++--
 modules/demux/avi/libavi.h                         |    4 +-
 modules/demux/mkv/matroska_segment.cpp             |   10 +++---
 modules/mux/asf.c                                  |    6 ++--
 modules/mux/avi.c                                  |   12 +++---
 modules/video_filter/atmo/AtmoDefs.h               |    6 ++--
 .../video_filter/atmo/AtmoExternalCaptureInput.cpp |    2 +-
 .../video_filter/atmo/AtmoExternalCaptureInput.h   |    4 +-
 modules/video_filter/atmo/AtmoZoneDefinition.cpp   |    8 ++--
 modules/video_filter/atmo/atmo.cpp                 |   26 +++++++-------
 12 files changed, 65 insertions(+), 64 deletions(-)

diff --git a/include/vlc_codecs.h b/include/vlc_codecs.h
index 6963178..8798603 100644
--- a/include/vlc_codecs.h
+++ b/include/vlc_codecs.h
@@ -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
     {
diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c
index 5e86df8..f28a4ed 100644
--- a/modules/demux/avi/avi.c
+++ b/modules/demux/avi/avi.c
@@ -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;
diff --git a/modules/demux/avi/libavi.c b/modules/demux/avi/libavi.c
index d50af46..e289212 100644
--- a/modules/demux/avi/libavi.c
+++ b/modules/demux/avi/libavi.c
@@ -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,
diff --git a/modules/demux/avi/libavi.h b/modules/demux/avi/libavi.h
index 3862cf9..96df03d 100644
--- a/modules/demux/avi/libavi.h
+++ b/modules/demux/avi/libavi.h
@@ -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
diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp
index 455f7d9..04c6146 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -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;
 
diff --git a/modules/mux/asf.c b/modules/mux/asf.c
index ceec09a..9985c3e 100644
--- a/modules/mux/asf.c
+++ b/modules/mux/asf.c
@@ -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 );
diff --git a/modules/mux/avi.c b/modules/mux/avi.c
index d2d1a70..f418914 100644
--- a/modules/mux/avi.c
+++ b/modules/mux/avi.c
@@ -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;
     }
diff --git a/modules/video_filter/atmo/AtmoDefs.h b/modules/video_filter/atmo/AtmoDefs.h
index a7719a0..9e7c5b7 100644
--- a/modules/video_filter/atmo/AtmoDefs.h
+++ b/modules/video_filter/atmo/AtmoDefs.h
@@ -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
diff --git a/modules/video_filter/atmo/AtmoExternalCaptureInput.cpp b/modules/video_filter/atmo/AtmoExternalCaptureInput.cpp
index 7e8d3cf..37c6950 100644
--- a/modules/video_filter/atmo/AtmoExternalCaptureInput.cpp
+++ b/modules/video_filter/atmo/AtmoExternalCaptureInput.cpp
@@ -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,
diff --git a/modules/video_filter/atmo/AtmoExternalCaptureInput.h b/modules/video_filter/atmo/AtmoExternalCaptureInput.h
index 01bab73..a229e9a 100644
--- a/modules/video_filter/atmo/AtmoExternalCaptureInput.h
+++ b/modules/video_filter/atmo/AtmoExternalCaptureInput.h
@@ -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);
diff --git a/modules/video_filter/atmo/AtmoZoneDefinition.cpp b/modules/video_filter/atmo/AtmoZoneDefinition.cpp
index 2ab2fcd..36ffe25 100644
--- a/modules/video_filter/atmo/AtmoZoneDefinition.cpp
+++ b/modules/video_filter/atmo/AtmoZoneDefinition.cpp
@@ -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;
diff --git a/modules/video_filter/atmo/atmo.cpp b/modules/video_filter/atmo/atmo.cpp
index cd32fb2..f1ab6c6 100644
--- a/modules/video_filter/atmo/atmo.cpp
+++ b/modules/video_filter/atmo/atmo.cpp
@@ -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);
     }
-- 
1.7.3.2

