Changeset 3300

Show
Ignore:
Timestamp:
08/17/04 21:42:45 (10 years ago)
Author:
robert
Message:

From Bruce Clay, fixes for VS6.0 build.

Location:
OpenSceneGraph/trunk/src/osg
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osg/dxtctool.cpp

    r3286 r3300  
    1212namespace dxtc_tool { 
    1313 
    14  
    15  
     14    const size_t dxtc_pixels::BSIZE_DXT1 = 8; 
     15    const size_t dxtc_pixels::BSIZE_DXT3 = 16; 
     16    const size_t dxtc_pixels::BSIZE_DXT5 = 16; 
     17    const size_t dxtc_pixels::BSIZE_ALPHA_DXT3 = 8; 
     18    const size_t dxtc_pixels::BSIZE_ALPHA_DXT5 = 8; 
    1619 
    1720////////////////////////////////////////////////////////////////////// 
     
    2730bool dxtc_pixels::OpenGLSize() const 
    2831{ 
    29         size_t Width = m_Width; 
    30         size_t Height = m_Height; 
    31         // size_t TotalTrueBits = 0; 
     32    size_t Width = m_Width; 
     33    size_t Height = m_Height; 
     34    // size_t TotalTrueBits = 0; 
    3235 
    33         if ((Width == 0) || (Height == 0)) 
    34                 return false; 
     36    if ((Width == 0) || (Height == 0)) 
     37        return false; 
    3538 
    36         for (; (Width % 2) == 0; Width /= 2); 
    37         for (; (Height % 2) == 0; Height /= 2); 
     39    for (; (Width % 2) == 0; Width /= 2); 
     40    for (; (Height % 2) == 0; Height /= 2); 
    3841 
    39         if ((Width != 1) || (Height != 1)) 
    40                 return false; 
    41         else 
    42                 return true; 
     42    if ((Width != 1) || (Height != 1)) 
     43        return false; 
     44    else 
     45        return true; 
    4346} 
    4447 
     
    4750bool dxtc_pixels::VFlip() const 
    4851{ 
    49         // Check that the given dimentions are 2^x, 2^y 
    50         if (! OpenGLSize()) 
    51                 return false; 
     52    // Check that the given dimentions are 2^x, 2^y 
     53    if (! OpenGLSize()) 
     54        return false; 
    5255 
    53         // Check that the given format are supported 
    54         if (! SupportedFormat()) 
    55                 return false; 
     56    // Check that the given format are supported 
     57    if (! SupportedFormat()) 
     58        return false; 
    5659 
    57         // Nothing to do if Height == 1 
    58         if (m_Height == 1) 
    59                 return true; 
    60                  
    61         if (DXT1()) 
    62                 VFlip_DXT1(); 
    63         else if (DXT3()) 
    64                 VFlip_DXT3(); 
    65         else if (DXT5()) 
    66                 VFlip_DXT5(); 
    67         else 
    68                 return false; // We should never get there 
     60    // Nothing to do if Height == 1 
     61    if (m_Height == 1) 
     62        return true; 
     63         
     64    if (DXT1()) 
     65        VFlip_DXT1(); 
     66    else if (DXT3()) 
     67        VFlip_DXT3(); 
     68    else if (DXT5()) 
     69        VFlip_DXT5(); 
     70    else 
     71        return false; // We should never get there 
    6972 
    70         return true; 
     73    return true; 
    7174} 
    7275 
     
    7578void dxtc_pixels::VFlip_DXT1() const 
    7679{ 
    77         // const size_t Size = ((m_Width + 3) / 4) * ((m_Height + 3) / 4) * BSIZE_DXT1; 
    78         __int8 * const pPixels = (__int8 * const) m_pPixels; 
     80    // const size_t Size = ((m_Width + 3) / 4) * ((m_Height + 3) / 4) * BSIZE_DXT1; 
     81    __int8 * const pPixels = (__int8 * const) m_pPixels; 
    7982 
    80         if (m_Height == 2) 
    81                 for (size_t j = 0; j < (m_Width + 3) / 4; ++j) 
    82                         BVF_Color_H2(pPixels + j * BSIZE_DXT1); 
     83    if (m_Height == 2) 
     84        for (size_t j = 0; j < (m_Width + 3) / 4; ++j) 
     85            BVF_Color_H2(pPixels + j * BSIZE_DXT1); 
    8386 
    84         if (m_Height == 4) 
    85                 for (size_t j = 0; j < (m_Width + 3) / 4; ++j) 
    86                         BVF_Color_H4(pPixels + j * BSIZE_DXT1); 
     87    if (m_Height == 4) 
     88        for (size_t j = 0; j < (m_Width + 3) / 4; ++j) 
     89            BVF_Color_H4(pPixels + j * BSIZE_DXT1); 
    8790 
    88         if (m_Height > 4) 
    89                 for (size_t i = 0; i < ((m_Height + 7) / 8); ++i) 
    90                         for (size_t j = 0; j < (m_Width + 3) / 4; ++j) { 
    91                                 const size_t TargetRow = ((m_Height + 3) / 4) - (i + 1); 
    92                                 BVF_Color(GetBlock(i, j, BSIZE_DXT1), GetBlock(TargetRow, j, BSIZE_DXT1)); 
    93                         } 
     91    if (m_Height > 4) 
     92        for (size_t i = 0; i < ((m_Height + 7) / 8); ++i) 
     93            for (size_t j = 0; j < (m_Width + 3) / 4; ++j) { 
     94                const size_t TargetRow = ((m_Height + 3) / 4) - (i + 1); 
     95                BVF_Color(GetBlock(i, j, BSIZE_DXT1), GetBlock(TargetRow, j, BSIZE_DXT1)); 
     96            } 
    9497} 
    9598 
     
    98101void dxtc_pixels::VFlip_DXT3() const 
    99102{ 
    100         // const size_t Size = ((m_Width + 3) / 4) * ((m_Height + 3) / 4) * BSIZE_DXT3; 
    101         // __int8 * const pPixels = (__int8 * const) m_pPixels; 
     103    // const size_t Size = ((m_Width + 3) / 4) * ((m_Height + 3) / 4) * BSIZE_DXT3; 
     104    // __int8 * const pPixels = (__int8 * const) m_pPixels; 
    102105 
    103         if (m_Height == 2) 
    104                 for (size_t j = 0; j < (m_Width + 3) / 4; ++j) { 
    105                         BVF_Alpha_DXT3_H2(((__int8 * const) m_pPixels) + (j * BSIZE_DXT3)); 
    106                         BVF_Color_H2(((__int8 * const) m_pPixels) + (j * BSIZE_DXT3 + BSIZE_ALPHA_DXT3)); 
    107                 } 
     106    if (m_Height == 2) 
     107        for (size_t j = 0; j < (m_Width + 3) / 4; ++j) { 
     108            BVF_Alpha_DXT3_H2(((__int8 * const) m_pPixels) + (j * BSIZE_DXT3)); 
     109            BVF_Color_H2(((__int8 * const) m_pPixels) + (j * BSIZE_DXT3 + BSIZE_ALPHA_DXT3)); 
     110        } 
    108111 
    109         if (m_Height == 4) 
    110                 for (size_t j = 0; j < (m_Width + 3) / 4; ++j) { 
    111                         BVF_Alpha_DXT3_H4(((__int8 * const) m_pPixels) + (j * BSIZE_DXT3)); 
    112                         BVF_Color_H4(((__int8 * const) m_pPixels) + (j * BSIZE_DXT3 + BSIZE_ALPHA_DXT3)); 
    113                 } 
     112    if (m_Height == 4) 
     113        for (size_t j = 0; j < (m_Width + 3) / 4; ++j) { 
     114            BVF_Alpha_DXT3_H4(((__int8 * const) m_pPixels) + (j * BSIZE_DXT3)); 
     115            BVF_Color_H4(((__int8 * const) m_pPixels) + (j * BSIZE_DXT3 + BSIZE_ALPHA_DXT3)); 
     116        } 
    114117 
    115         if (m_Height > 4) 
    116                 for (size_t i = 0; i < ((m_Height + 7) / 8); ++i) 
    117                         for (size_t j = 0; j < (m_Width + 3) / 4; ++j) { 
    118                                 const size_t TargetRow = ((m_Height + 3) / 4) - (i + 1); 
    119                                 BVF_Alpha_DXT3(GetBlock(i, j, BSIZE_DXT3), GetBlock(TargetRow, j, BSIZE_DXT3)); 
    120                                 BVF_Color(((__int8 * const) GetBlock(i, j, BSIZE_DXT3)) + BSIZE_ALPHA_DXT3,  
    121                                                   ((__int8 * const) GetBlock(TargetRow, j, BSIZE_DXT3)) + BSIZE_ALPHA_DXT3); 
    122                         } 
     118    if (m_Height > 4) 
     119        for (size_t i = 0; i < ((m_Height + 7) / 8); ++i) 
     120            for (size_t j = 0; j < (m_Width + 3) / 4; ++j) { 
     121                const size_t TargetRow = ((m_Height + 3) / 4) - (i + 1); 
     122                BVF_Alpha_DXT3(GetBlock(i, j, BSIZE_DXT3), GetBlock(TargetRow, j, BSIZE_DXT3)); 
     123                BVF_Color(((__int8 * const) GetBlock(i, j, BSIZE_DXT3)) + BSIZE_ALPHA_DXT3,  
     124                          ((__int8 * const) GetBlock(TargetRow, j, BSIZE_DXT3)) + BSIZE_ALPHA_DXT3); 
     125            } 
    123126} 
    124127 
     
    127130void dxtc_pixels::VFlip_DXT5() const 
    128131{ 
    129         // const size_t Size = ((m_Width + 3) / 4) * ((m_Height + 3) / 4) * BSIZE_DXT5; 
    130         // __int8 * const pPixels = (__int8 * const) m_pPixels; 
     132    // const size_t Size = ((m_Width + 3) / 4) * ((m_Height + 3) / 4) * BSIZE_DXT5; 
     133    // __int8 * const pPixels = (__int8 * const) m_pPixels; 
    131134 
    132         if (m_Height == 2) 
    133                 for (size_t j = 0; j < (m_Width + 3) / 4; ++j) { 
    134                         BVF_Alpha_DXT5_H2(((__int8 * const) m_pPixels) + (j * BSIZE_DXT5)); 
    135                         BVF_Color_H2(((__int8 * const) m_pPixels) + (j * BSIZE_DXT5 + BSIZE_ALPHA_DXT5)); 
    136                 } 
     135    if (m_Height == 2) 
     136        for (size_t j = 0; j < (m_Width + 3) / 4; ++j) { 
     137            BVF_Alpha_DXT5_H2(((__int8 * const) m_pPixels) + (j * BSIZE_DXT5)); 
     138            BVF_Color_H2(((__int8 * const) m_pPixels) + (j * BSIZE_DXT5 + BSIZE_ALPHA_DXT5)); 
     139        } 
    137140 
    138         if (m_Height == 4) 
    139                 for (size_t j = 0; j < (m_Width + 3) / 4; ++j) { 
    140                         BVF_Alpha_DXT5_H4(((__int8 * const) m_pPixels) + (j * BSIZE_DXT5)); 
    141                         BVF_Color_H4(((__int8 * const) m_pPixels) + (j * BSIZE_DXT5 + BSIZE_ALPHA_DXT5)); 
    142                 } 
     141    if (m_Height == 4) 
     142        for (size_t j = 0; j < (m_Width + 3) / 4; ++j) { 
     143            BVF_Alpha_DXT5_H4(((__int8 * const) m_pPixels) + (j * BSIZE_DXT5)); 
     144            BVF_Color_H4(((__int8 * const) m_pPixels) + (j * BSIZE_DXT5 + BSIZE_ALPHA_DXT5)); 
     145        } 
    143146 
    144         if (m_Height > 4) 
    145                 for (size_t i = 0; i < ((m_Height + 7) / 8); ++i) 
    146                         for (size_t j = 0; j < (m_Width + 3) / 4; ++j) { 
    147                                 const size_t TargetRow = ((m_Height + 3) / 4) - (i + 1); 
    148                                 BVF_Alpha_DXT5(GetBlock(i, j, BSIZE_DXT5), GetBlock(TargetRow, j, BSIZE_DXT5)); 
    149                                 BVF_Color(((__int8 * const) GetBlock(i, j, BSIZE_DXT5)) + BSIZE_ALPHA_DXT5,  
    150                                                   ((__int8 * const) GetBlock(TargetRow, j, BSIZE_DXT5)) + BSIZE_ALPHA_DXT5); 
    151                         } 
     147    if (m_Height > 4) 
     148        for (size_t i = 0; i < ((m_Height + 7) / 8); ++i) 
     149            for (size_t j = 0; j < (m_Width + 3) / 4; ++j) { 
     150                const size_t TargetRow = ((m_Height + 3) / 4) - (i + 1); 
     151                BVF_Alpha_DXT5(GetBlock(i, j, BSIZE_DXT5), GetBlock(TargetRow, j, BSIZE_DXT5)); 
     152                BVF_Color(((__int8 * const) GetBlock(i, j, BSIZE_DXT5)) + BSIZE_ALPHA_DXT5,  
     153                          ((__int8 * const) GetBlock(TargetRow, j, BSIZE_DXT5)) + BSIZE_ALPHA_DXT5); 
     154            } 
    152155} 
    153156 
  • OpenSceneGraph/trunk/src/osg/dxtctool.h

    r3290 r3300  
    2626////////////////////////////////////////////////////////////////////// 
    2727// 
    28 //                                              DXTC Tools: Vertical Flip. 
    29 //                                              ************************* 
     28//                        DXTC Tools: Vertical Flip. 
     29//                        ************************* 
    3030// 
    3131// Current version: 1.00 BETA 1 (27/08/2002) 
     
    8181{ 
    8282public: 
    83         dxtc_pixels(size_t Width, size_t Height, GLenum Format, void * pPixels); 
    84  
    85         // Vertically flip the whole picture 
    86         bool VFlip() const; 
     83    dxtc_pixels(size_t Width, size_t Height, GLenum Format, void * pPixels); 
     84 
     85    // Vertically flip the whole picture 
     86    bool VFlip() const; 
    8787 
    8888protected: 
    8989 
    90         // Limitation check functions 
    91         bool DXT1() const; 
    92         bool DXT3() const; 
    93         bool DXT5() const; 
    94         bool OpenGLSize() const; 
    95         bool SupportedFormat() const; 
    96  
    97         // Vertical flipping functions 
    98         void VFlip_DXT1() const;         
    99         void VFlip_DXT3() const; 
    100         void VFlip_DXT5() const; 
    101  
    102         // Block vertical flipping functions 
    103         void BVF_Color_H2(void * const pBlock) const;                                                   // V. flip one color block with its virtual height == 2 
    104         void BVF_Color_H4(void * const pBlock) const;                                                   // V. flip one color block with its virtual height == 4 
    105         void BVF_Color(void * const pBlock1, void * const pBlock2) const;               // V. flip and swap two color blocks, with their virtual height == 4 
    106         void BVF_Alpha_DXT3_H2(void * const pBlock) const;                                              // V. flip one alpha (DXT3) block with its virtual height == 2 
    107         void BVF_Alpha_DXT3_H4(void * const pBlock) const;                                              // V. flip one alpha (DXT3) block with its virtual height == 4 
    108         void BVF_Alpha_DXT3(void * const pBlock1, void * const pBlock2) const;  // V. flip and swap two alpha (DXT3) blocks, with their virtual height == 4 
    109         void BVF_Alpha_DXT5_H2(void * const pBlock) const;                                              // V. flip one alpha (DXT5) block with its virtual height == 2 
    110         void BVF_Alpha_DXT5_H4(void * const pBlock) const;                                              // V. flip one alpha (DXT5) block with its virtual height == 4 
    111         void BVF_Alpha_DXT5(void * const pBlock1, void * const pBlock2) const;  // V. flip and swap two alpha (DXT5) blocks, with their virtual height == 4 
    112          
    113         // Block localization functions 
    114         void * GetBlock(size_t i, size_t j, size_t BlockSize) const; 
    115  
    116         // mighty const and var 
    117         static const size_t BSIZE_DXT1 = 8; 
    118         static const size_t BSIZE_DXT3 = 16; 
    119         static const size_t BSIZE_DXT5 = 16; 
    120         static const size_t BSIZE_ALPHA_DXT3 = 8; 
    121         static const size_t BSIZE_ALPHA_DXT5 = 8; 
    122  
    123         const size_t    m_Width; 
    124         const size_t    m_Height; 
    125         const GLenum    m_Format; 
    126         void * const    m_pPixels; 
     90    // Limitation check functions 
     91    bool DXT1() const; 
     92    bool DXT3() const; 
     93    bool DXT5() const; 
     94    bool OpenGLSize() const; 
     95    bool SupportedFormat() const; 
     96 
     97    // Vertical flipping functions 
     98    void VFlip_DXT1() const;     
     99    void VFlip_DXT3() const; 
     100    void VFlip_DXT5() const; 
     101 
     102    // Block vertical flipping functions 
     103    void BVF_Color_H2(void * const pBlock) const;                            // V. flip one color block with its virtual height == 2 
     104    void BVF_Color_H4(void * const pBlock) const;                            // V. flip one color block with its virtual height == 4 
     105    void BVF_Color(void * const pBlock1, void * const pBlock2) const;        // V. flip and swap two color blocks, with their virtual height == 4 
     106    void BVF_Alpha_DXT3_H2(void * const pBlock) const;                        // V. flip one alpha (DXT3) block with its virtual height == 2 
     107    void BVF_Alpha_DXT3_H4(void * const pBlock) const;                        // V. flip one alpha (DXT3) block with its virtual height == 4 
     108    void BVF_Alpha_DXT3(void * const pBlock1, void * const pBlock2) const;    // V. flip and swap two alpha (DXT3) blocks, with their virtual height == 4 
     109    void BVF_Alpha_DXT5_H2(void * const pBlock) const;                        // V. flip one alpha (DXT5) block with its virtual height == 2 
     110    void BVF_Alpha_DXT5_H4(void * const pBlock) const;                        // V. flip one alpha (DXT5) block with its virtual height == 4 
     111    void BVF_Alpha_DXT5(void * const pBlock1, void * const pBlock2) const;    // V. flip and swap two alpha (DXT5) blocks, with their virtual height == 4 
     112     
     113    // Block localization functions 
     114    void * GetBlock(size_t i, size_t j, size_t BlockSize) const; 
     115 
     116    // mighty const and var 
     117    static const size_t BSIZE_DXT1; 
     118    static const size_t BSIZE_DXT3; 
     119    static const size_t BSIZE_DXT5; 
     120    static const size_t BSIZE_ALPHA_DXT3; 
     121    static const size_t BSIZE_ALPHA_DXT5; 
     122 
     123    const size_t    m_Width; 
     124    const size_t    m_Height; 
     125    const GLenum    m_Format; 
     126    void * const    m_pPixels; 
    127127}; 
    128128 
     
    135135 
    136136inline bool VerticalFlip(size_t Width, size_t Height, GLenum Format, void * pPixels) { 
    137         return (dxtc_pixels(Width, Height, Format, pPixels)).VFlip();  
     137    return (dxtc_pixels(Width, Height, Format, pPixels)).VFlip();  
    138138} 
    139139 
     
    145145 
    146146inline dxtc_pixels::dxtc_pixels(size_t Width, size_t Height, GLenum Format, void * pPixels) : 
    147         m_Width(Width), m_Height(Height), m_Format(Format), m_pPixels(pPixels) { } 
     147    m_Width(Width), m_Height(Height), m_Format(Format), m_pPixels(pPixels) { } 
    148148 
    149149 
    150150inline bool dxtc_pixels::DXT1() const { 
    151         return ((m_Format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) || (m_Format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT)); 
     151    return ((m_Format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) || (m_Format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT)); 
    152152} 
    153153 
    154154 
    155155inline bool dxtc_pixels::DXT3() const { 
    156         return (m_Format == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT); 
     156    return (m_Format == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT); 
    157157} 
    158158 
    159159 
    160160inline bool dxtc_pixels::DXT5() const { 
    161         return (m_Format == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT); 
     161    return (m_Format == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT); 
    162162} 
    163163 
    164164 
    165165inline bool dxtc_pixels::SupportedFormat() const { 
    166         return (DXT1() || DXT3() || DXT5()); 
     166    return (DXT1() || DXT3() || DXT5()); 
    167167} 
    168168 
    169169 
    170170inline void dxtc_pixels::BVF_Color_H2(void * const pBlock) const { 
    171         // Swap the two first row of pixels 
    172         __int8 * const pP = ((__int8 * const) pBlock) + 4; 
    173  
    174         std::swap(pP[0], pP[1]); 
     171    // Swap the two first row of pixels 
     172    __int8 * const pP = ((__int8 * const) pBlock) + 4; 
     173 
     174    std::swap(pP[0], pP[1]); 
    175175} 
    176176 
    177177 
    178178inline void dxtc_pixels::BVF_Color_H4(void * const pBlock) const { 
    179         // Swap the the first row of pixels with the last one, then the 2 middle row of pixels 
    180         __int8 * const pP = ((__int8 * const) pBlock) + 4; 
    181  
    182         std::swap(pP[0], pP[3]); 
    183         std::swap(pP[1], pP[2]); 
     179    // Swap the the first row of pixels with the last one, then the 2 middle row of pixels 
     180    __int8 * const pP = ((__int8 * const) pBlock) + 4; 
     181 
     182    std::swap(pP[0], pP[3]); 
     183    std::swap(pP[1], pP[2]); 
    184184} 
    185185 
    186186 
    187187inline void dxtc_pixels::BVF_Color(void * const pBlock1, void * const pBlock2) const { 
    188         // Swap the "2 colors" header (32bits each header) 
    189         __int32 * const pHdr1 = (__int32 * const) pBlock1; 
    190         __int32 * const pHdr2 = (__int32 * const) pBlock2; 
    191  
    192         std::swap(* pHdr1, * pHdr2); 
    193  
    194         // Now swap the pixel values 
    195         __int8 * const pP1 = ((__int8 * const) pBlock1) + 4; 
    196         __int8 * const pP2 = ((__int8 * const) pBlock2) + 4; 
    197  
    198         std::swap(pP1[0], pP2[3]); 
    199         std::swap(pP1[1], pP2[2]); 
    200         std::swap(pP1[2], pP2[1]); 
    201         std::swap(pP1[3], pP2[0]); 
     188    // Swap the "2 colors" header (32bits each header) 
     189    __int32 * const pHdr1 = (__int32 * const) pBlock1; 
     190    __int32 * const pHdr2 = (__int32 * const) pBlock2; 
     191 
     192    std::swap(* pHdr1, * pHdr2); 
     193 
     194    // Now swap the pixel values 
     195    __int8 * const pP1 = ((__int8 * const) pBlock1) + 4; 
     196    __int8 * const pP2 = ((__int8 * const) pBlock2) + 4; 
     197 
     198    std::swap(pP1[0], pP2[3]); 
     199    std::swap(pP1[1], pP2[2]); 
     200    std::swap(pP1[2], pP2[1]); 
     201    std::swap(pP1[3], pP2[0]); 
    202202} 
    203203 
    204204 
    205205inline void dxtc_pixels::BVF_Alpha_DXT3_H2(void * const pBlock) const { 
    206         // Swap the two first row of pixels 
    207         __int16 * const pP = (__int16 * const) pBlock; 
    208  
    209         std::swap(pP[0], pP[1]); 
     206    // Swap the two first row of pixels 
     207    __int16 * const pP = (__int16 * const) pBlock; 
     208 
     209    std::swap(pP[0], pP[1]); 
    210210} 
    211211 
    212212 
    213213inline void dxtc_pixels::BVF_Alpha_DXT3_H4(void * const pBlock) const { 
    214         // Swap the the first row of pixels with the last one, then the 2 middle row of pixels 
    215         __int16 * const pP = (__int16 * const) pBlock; 
    216  
    217         std::swap(pP[0], pP[3]); 
    218         std::swap(pP[1], pP[2]); 
     214    // Swap the the first row of pixels with the last one, then the 2 middle row of pixels 
     215    __int16 * const pP = (__int16 * const) pBlock; 
     216 
     217    std::swap(pP[0], pP[3]); 
     218    std::swap(pP[1], pP[2]); 
    219219} 
    220220 
    221221 
    222222inline void dxtc_pixels::BVF_Alpha_DXT3(void * const pBlock1, void * const pBlock2) const { 
    223         // Swap all the pixel values 
    224         __int16 * const pP1 = (__int16 * const) pBlock1; 
    225         __int16 * const pP2 = (__int16 * const) pBlock2; 
    226  
    227         std::swap(pP1[0], pP2[3]); 
    228         std::swap(pP1[1], pP2[2]); 
    229         std::swap(pP1[2], pP2[1]); 
    230         std::swap(pP1[3], pP2[0]); 
     223    // Swap all the pixel values 
     224    __int16 * const pP1 = (__int16 * const) pBlock1; 
     225    __int16 * const pP2 = (__int16 * const) pBlock2; 
     226 
     227    std::swap(pP1[0], pP2[3]); 
     228    std::swap(pP1[1], pP2[2]); 
     229    std::swap(pP1[2], pP2[1]); 
     230    std::swap(pP1[3], pP2[0]); 
    231231} 
    232232 
    233233 
    234234inline void dxtc_pixels::BVF_Alpha_DXT5_H2(void * const pBlock) const { 
    235         // Swap the two first row of pixels (kinda tricky with DXT5 unaligned encoding) 
    236         __int32 * const pP = (__int32 * const) (((__int8 * const) pBlock) + 2); 
    237  
    238         __int32 TmpDWord = (pP[0] & 0xFF000000); 
    239         TmpDWord |=     (pP[0] & 0x00000FFF) << 12; 
    240         TmpDWord |= (pP[0] & 0x00FFF000) >> 12; 
    241         pP[0] = TmpDWord; 
     235    // Swap the two first row of pixels (kinda tricky with DXT5 unaligned encoding) 
     236    __int32 * const pP = (__int32 * const) (((__int8 * const) pBlock) + 2); 
     237 
     238    __int32 TmpDWord = (pP[0] & 0xFF000000); 
     239    TmpDWord |=    (pP[0] & 0x00000FFF) << 12; 
     240    TmpDWord |= (pP[0] & 0x00FFF000) >> 12; 
     241    pP[0] = TmpDWord; 
    242242} 
    243243 
     
    248248 
    249249inline void dxtc_pixels::BVF_Alpha_DXT5_H4(void * const pBlock) const { 
    250         // Swap the the first row of pixels with the last one, then the 2 middle row of pixels (tricky again) 
    251         __int64 * const pB = (__int64 * const) pBlock; 
    252  
    253         __int64 TmpQWord = (pB[0] & HEX_0x000000000000FFFF); 
    254         TmpQWord |= (pB[0] & HEX_0x000000000FFF0000) << 36; 
    255         TmpQWord |= (pB[0] & HEX_0x000000FFF0000000) << 12; 
    256         TmpQWord |= (pB[0] & HEX_0x000FFF0000000000) >> 12; 
    257         TmpQWord |= (pB[0] & HEX_0xFFF0000000000000) >> 36; 
    258         pB[0] = TmpQWord; 
     250    // Swap the the first row of pixels with the last one, then the 2 middle row of pixels (tricky again) 
     251    __int64 * const pB = (__int64 * const) pBlock; 
     252 
     253    __int64 TmpQWord = (pB[0] & HEX_0x000000000000FFFF); 
     254    TmpQWord |= (pB[0] & HEX_0x000000000FFF0000) << 36; 
     255    TmpQWord |= (pB[0] & HEX_0x000000FFF0000000) << 12; 
     256    TmpQWord |= (pB[0] & HEX_0x000FFF0000000000) >> 12; 
     257    TmpQWord |= (pB[0] & HEX_0xFFF0000000000000) >> 36; 
     258    pB[0] = TmpQWord; 
    259259} 
    260260 
    261261 
    262262inline void dxtc_pixels::BVF_Alpha_DXT5(void * const pBlock1, void * const pBlock2) const { 
    263         // Swap all the pixel values (same trick for DXT5) 
    264         __int64 * const pB1 = (__int64 * const) pBlock1; 
    265         __int64 * const pB2 = (__int64 * const) pBlock2; 
    266  
    267         __int64 TmpQWord1 = (pB1[0] & HEX_0x000000000000FFFF); 
    268         TmpQWord1 |= (pB1[0] & HEX_0x000000000FFF0000) << 36; 
    269         TmpQWord1 |= (pB1[0] & HEX_0x000000FFF0000000) << 12; 
    270         TmpQWord1 |= (pB1[0] & HEX_0x000FFF0000000000) >> 12; 
    271         TmpQWord1 |= (pB1[0] & HEX_0xFFF0000000000000) >> 36; 
    272  
    273         __int64 TmpQWord2 = (pB2[0] & HEX_0x000000000000FFFF); 
    274         TmpQWord2 |= (pB2[0] & HEX_0x000000000FFF0000) << 36; 
    275         TmpQWord2 |= (pB2[0] & HEX_0x000000FFF0000000) << 12; 
    276         TmpQWord2 |= (pB2[0] & HEX_0x000FFF0000000000) >> 12; 
    277         TmpQWord2 |= (pB2[0] & HEX_0xFFF0000000000000) >> 36; 
    278  
    279         pB1[0] = TmpQWord2; 
    280         pB2[0] = TmpQWord1; 
     263    // Swap all the pixel values (same trick for DXT5) 
     264    __int64 * const pB1 = (__int64 * const) pBlock1; 
     265    __int64 * const pB2 = (__int64 * const) pBlock2; 
     266 
     267    __int64 TmpQWord1 = (pB1[0] & HEX_0x000000000000FFFF); 
     268    TmpQWord1 |= (pB1[0] & HEX_0x000000000FFF0000) << 36; 
     269    TmpQWord1 |= (pB1[0] & HEX_0x000000FFF0000000) << 12; 
     270    TmpQWord1 |= (pB1[0] & HEX_0x000FFF0000000000) >> 12; 
     271    TmpQWord1 |= (pB1[0] & HEX_0xFFF0000000000000) >> 36; 
     272 
     273    __int64 TmpQWord2 = (pB2[0] & HEX_0x000000000000FFFF); 
     274    TmpQWord2 |= (pB2[0] & HEX_0x000000000FFF0000) << 36; 
     275    TmpQWord2 |= (pB2[0] & HEX_0x000000FFF0000000) << 12; 
     276    TmpQWord2 |= (pB2[0] & HEX_0x000FFF0000000000) >> 12; 
     277    TmpQWord2 |= (pB2[0] & HEX_0xFFF0000000000000) >> 36; 
     278 
     279    pB1[0] = TmpQWord2; 
     280    pB2[0] = TmpQWord1; 
    281281} 
    282282 
    283283 
    284284inline void * dxtc_pixels::GetBlock(size_t i, size_t j, size_t BlockSize) const { 
    285         const __int8 * pPixels = (const __int8 *) m_pPixels; 
    286  
    287         return (void *) (pPixels + i * ((m_Width + 3) / 4) * BlockSize + j * BlockSize); 
     285    const __int8 * pPixels = (const __int8 *) m_pPixels; 
     286 
     287    return (void *) (pPixels + i * ((m_Width + 3) / 4) * BlockSize + j * BlockSize); 
    288288} 
    289289