Changeset 295


Ignore:
Timestamp:
04/23/07 21:30:30 (17 years ago)
Author:
r2d
Message:

removed aliasing warnings

Location:
libmpc/trunk/libwavformat
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libmpc/trunk/libwavformat/input.c

    r68 r295  
    1616        for(n=0;n<p_sample_count;n++)
    1717        {
    18                 t_wav_uint32 temp;
    19                
    20                 temp = (t_wav_uint32) (
    21                         ( (t_wav_uint32)p_input[0] ) | 
    22                         ( (t_wav_uint32)p_input[1] << 8) | 
    23                         ( (t_wav_uint32)p_input[2] << 16) | 
    24                         ( (t_wav_uint32)p_input[3] << 24) 
     18                t_wav_conv temp;
     19
     20                temp.n = (t_wav_uint32) (
     21                        ( (t_wav_uint32)p_input[0] ) |
     22                        ( (t_wav_uint32)p_input[1] << 8) |
     23                        ( (t_wav_uint32)p_input[2] << 16) |
     24                        ( (t_wav_uint32)p_input[3] << 24)
    2525                        );
    2626
    2727                p_input += 4;
    2828
    29                 p_sample_buffer[n] = *(t_wav_float32*)&temp;
     29                p_sample_buffer[n] = temp.f;
    3030        }
    3131}
     
    3636        for(n=0;n<p_sample_count;n++)
    3737        {
    38                 t_wav_uint32 temp;
     38                t_wav_conv temp;
    3939                t_wav_int32 tempi;
    40                 temp = (t_wav_uint32) (
    41                         ( (t_wav_uint32)p_input[0] ) | 
    42                         ( (t_wav_uint32)p_input[1] << 8) | 
    43                         ( (t_wav_uint32)p_input[2] << 16) | 
    44                         ( (t_wav_uint32)p_input[3] << 24) 
     40                temp.n = (t_wav_uint32) (
     41                        ( (t_wav_uint32)p_input[0] ) |
     42                        ( (t_wav_uint32)p_input[1] << 8) |
     43                        ( (t_wav_uint32)p_input[2] << 16) |
     44                        ( (t_wav_uint32)p_input[3] << 24)
    4545                        );
    4646
    4747                p_input += 4;
    4848
    49                 tempi = (t_wav_int32)(*(t_wav_float32*)&temp * 0x8000);
     49                tempi = (t_wav_int32)(temp.f * 0x8000);
    5050                if (tempi < -0x8000) tempi = -0x8000;
    5151                else if (tempi > 0x7FFF) tempi = 0x7FFF;
     
    6161        {
    6262                t_wav_int32 temp = (t_wav_int32) (
    63                         ( (t_wav_uint32)p_input[0] ) | 
    64                         ( (t_wav_uint32)p_input[1] << 8) | 
    65                         ( (t_wav_uint32)p_input[2] << 16) | 
    66                         ( (t_wav_uint32)p_input[3] << 24) 
     63                        ( (t_wav_uint32)p_input[0] ) |
     64                        ( (t_wav_uint32)p_input[1] << 8) |
     65                        ( (t_wav_uint32)p_input[2] << 16) |
     66                        ( (t_wav_uint32)p_input[3] << 24)
    6767                        );
    6868
     
    7979        {
    8080                t_wav_int32 temp = (t_wav_int32) (
    81                         ( (t_wav_uint32)p_input[0] ) | 
    82                         ( (t_wav_uint32)p_input[1] << 8) | 
    83                         ( (t_wav_uint32)p_input[2] << 16) | 
     81                        ( (t_wav_uint32)p_input[0] ) |
     82                        ( (t_wav_uint32)p_input[1] << 8) |
     83                        ( (t_wav_uint32)p_input[2] << 16) |
    8484                        ( (t_wav_uint32)p_input[3] << 24)
    8585                        );
     
    9797        {
    9898                t_wav_int32 temp = (t_wav_int32) (
    99                         ( (t_wav_uint32)p_input[0] ) | 
    100                         ( (t_wav_uint32)p_input[1] << 8) | 
     99                        ( (t_wav_uint32)p_input[0] ) |
     100                        ( (t_wav_uint32)p_input[1] << 8) |
    101101                        ( (t_wav_int32)(t_wav_int8)p_input[2] << 16)
    102102                        );
     
    114114        {
    115115                t_wav_int32 temp = (t_wav_int32) (
    116                         ( (t_wav_uint32)p_input[0] ) | 
    117                         ( (t_wav_uint32)p_input[1] << 8) | 
     116                        ( (t_wav_uint32)p_input[0] ) |
     117                        ( (t_wav_uint32)p_input[1] << 8) |
    118118                        ( (t_wav_int32)(t_wav_int8)p_input[2] << 16)
    119119                        );
     
    131131        {
    132132                t_wav_int16 temp = (t_wav_int16)
    133                         ( 
     133                        (
    134134                                (t_wav_uint16)p_input[0] |
    135135                                ( (t_wav_uint16)p_input[1] << 8 )
     
    148148        {
    149149                t_wav_int16 temp = (t_wav_int16)
    150                         ( 
     150                        (
    151151                                (t_wav_uint16)p_input[0] |
    152152                                ( (t_wav_uint16)p_input[1] << 8 )
     
    201201                delta = p_bytes - done;
    202202                if (delta > sizeof(dummy)) delta = sizeof(dummy);
    203                
     203
    204204                delta_done = waveformat_read(p_file,dummy,delta);
    205205
     
    222222        t_wav_uint8 temp[4];
    223223        if (waveformat_read(p_file,&temp,sizeof(temp)) != sizeof(temp)) return 0;
    224         * p_value = 
     224        * p_value =
    225225                ((t_wav_uint32)temp[0]) |
    226226                ((t_wav_uint32)temp[1] << 8) |
     
    234234        t_wav_uint8 temp[2];
    235235        if (waveformat_read(p_file,&temp,sizeof(temp)) != sizeof(temp)) return 0;
    236         * p_value = 
     236        * p_value =
    237237                ((t_wav_uint16)temp[0]) |
    238238                ((t_wav_uint16)temp[1] << 8);
     
    295295
    296296                        p_file->m_bytes_per_sample = p_file->m_bits_per_sample / 8;
    297                        
     297
    298298                        if (p_file->m_bytes_per_sample == 0) return 0;
    299299
     
    351351                                if (waveformat_skip(p_file,fmt_remaining) != fmt_remaining) return 0;
    352352                        }
    353                        
     353
    354354                        main_offset += chunk_size;
    355355                        if (chunk_size & 1) main_offset++;
     
    372372
    373373                        if (waveformat_skip(p_file,toskip) != toskip) return 0;
    374                        
     374
    375375                        main_offset += toskip;
    376376                }
     
    392392        {
    393393                t_wav_uint32 delta, deltaread;
    394                
     394
    395395                delta = p_sample_count - samples_read;
    396396                if (delta > p_file->m_buffer_size) delta = p_file->m_buffer_size;
    397                
     397
    398398                deltaread = waveformat_read(p_file,p_file->m_workbuffer,delta * p_file->m_bytes_per_sample) / p_file->m_bytes_per_sample;
    399                
     399
    400400                if (deltaread > 0)
    401401                {
    402402                        p_file->m_input_handler.m_convert_float32(p_file->m_workbuffer,p_sample_buffer + samples_read,deltaread);
    403                        
     403
    404404                        samples_read += deltaread;
    405405                }
     
    425425        {
    426426                t_wav_uint32 delta, deltaread;
    427                
     427
    428428                delta = p_sample_count - samples_read;
    429429                if (delta > p_file->m_buffer_size) delta = p_file->m_buffer_size;
    430                
     430
    431431                deltaread = waveformat_read(p_file,p_file->m_workbuffer,delta * p_file->m_bytes_per_sample) / p_file->m_bytes_per_sample;
    432                
     432
    433433                if (deltaread > 0)
    434434                {
    435435                        p_file->m_input_handler.m_convert_int16(p_file->m_workbuffer,p_sample_buffer + samples_read,deltaread);
    436                        
     436
    437437                        samples_read += deltaread;
    438438                }
  • libmpc/trunk/libwavformat/libwaveformat.h

    r204 r295  
    3535typedef double t_wav_float64;
    3636#endif
     37
     38typedef union
     39{
     40        t_wav_float32 f;
     41        t_wav_uint32 n;
     42} t_wav_conv;
    3743
    3844#define waveformat_tag_int 1
  • libmpc/trunk/libwavformat/output.c

    r137 r295  
    1818__inline static void write_float(t_wav_uint8 * p_output,t_wav_float32 p_value)
    1919{
    20         t_wav_uint32 bah = *(const t_wav_uint32*)&p_value;
    21         p_output[0] = (t_wav_uint8)bah;
    22         p_output[1] = (t_wav_uint8)(bah >> 8);
    23         p_output[2] = (t_wav_uint8)(bah >> 16);
    24         p_output[3] = (t_wav_uint8)(bah >> 24);
     20        t_wav_conv bah;
     21        bah.f = p_value;
     22        p_output[0] = (t_wav_uint8)bah.n;
     23        p_output[1] = (t_wav_uint8)(bah.n >> 8);
     24        p_output[2] = (t_wav_uint8)(bah.n >> 16);
     25        p_output[3] = (t_wav_uint8)(bah.n >> 24);
    2526}
    2627
Note: See TracChangeset for help on using the changeset viewer.