Changeset 55f1d3272f61f46068e58c41690111e879082188

Show
Ignore:
Timestamp:
06/22/08 18:07:34 (2 months ago)
Author:
Antoine Cellerier <dionoea@videolan.org>
git-committer:
Antoine Cellerier <dionoea@videolan.org> 1214150854 +0200
git-parent:

[4c8296b58b24175921b37f99dfa7bda5e08f6cdb]

git-author:
Antoine Cellerier <dionoea@videolan.org> 1214150625 +0200
Message:

Set i_bitspersample to correct value when changing an audio codec. (Not
sure if I didn't miss some spots where that was missing). Thanks to
Kevin DuBois? for finding the bug. (This should fix some audio
transcoding crashes)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_aout.h

    rfbb8255 r55f1d32  
    366366 
    367367VLC_EXPORT( unsigned int, aout_FormatNbChannels, ( const audio_sample_format_t * p_format ) ); 
     368VLC_EXPORT( unsigned int, aout_BitsPerSample, ( vlc_fourcc_t i_format ) ); 
    368369VLC_EXPORT( void, aout_FormatPrepare, ( audio_sample_format_t * p_format ) ); 
    369370VLC_EXPORT( void, aout_FormatPrint, ( aout_instance_t * p_aout, const char * psz_text, const audio_sample_format_t * p_format ) ); 
  • modules/audio_filter/converter/a52tofloat32.c

    r3561b9b r55f1d32  
    439439        p_filter->fmt_out.i_codec = VLC_FOURCC('f','l','3','2'); 
    440440#endif 
     441    p_filter->fmt_out.audio.i_bitspersample = 
     442        aout_BitsPerSample( p_filter->fmt_out.i_codec ); 
    441443 
    442444    /* Allocate the memory needed to store the module's structure */ 
  • modules/audio_filter/converter/dtstofloat32.c

    r3561b9b r55f1d32  
    397397    p_filter->fmt_out.audio.i_format = 
    398398        p_filter->fmt_out.i_codec = VLC_FOURCC('f','l','3','2'); 
     399    p_filter->fmt_out.audio.i_bitspersample = 
     400        aout_BitsPerSample( p_filter->fmt_out.i_codec ); 
    399401 
    400402    /* Allocate the memory needed to store the module's structure */ 
  • modules/audio_filter/converter/mpgatofixed32.c

    r3561b9b r55f1d32  
    336336        p_filter->fmt_out.i_codec = VLC_FOURCC('f','i','3','2'); 
    337337    p_filter->fmt_out.audio.i_format = p_filter->fmt_out.i_codec; 
     338    p_filter->fmt_out.audio.i_bitspersample = 
     339        aout_BitsPerSample( p_filter->fmt_out.i_codec ); 
    338340 
    339341    p_filter->fmt_out.audio.i_rate = p_filter->fmt_in.audio.i_rate; 
  • src/audio_output/common.c

    rd666030 r55f1d32  
    110110 
    111111/***************************************************************************** 
    112  * aout_FormatPrepare : compute the number of bytes per frame & frame length 
    113  *****************************************************************************/ 
    114 void aout_FormatPrepare( audio_sample_format_t * p_format ) 
    115 
    116     int i_result; 
    117  
    118     switch ( p_format->i_format ) 
     112 * aout_BitsPerSample : get the number of bits per sample 
     113 *****************************************************************************/ 
     114unsigned int aout_BitsPerSample( vlc_fourcc_t i_format ) 
     115
     116    switch( i_format ) 
    119117    { 
    120118    case VLC_FOURCC('u','8',' ',' '): 
    121119    case VLC_FOURCC('s','8',' ',' '): 
    122         i_result = 1; 
    123         break; 
     120        return 8; 
    124121 
    125122    case VLC_FOURCC('u','1','6','l'): 
     
    127124    case VLC_FOURCC('u','1','6','b'): 
    128125    case VLC_FOURCC('s','1','6','b'): 
    129         i_result = 2; 
    130         break; 
     126        return 16; 
    131127 
    132128    case VLC_FOURCC('u','2','4','l'): 
     
    134130    case VLC_FOURCC('u','2','4','b'): 
    135131    case VLC_FOURCC('s','2','4','b'): 
    136         i_result = 3; 
    137         break; 
     132        return 24; 
    138133 
    139134    case VLC_FOURCC('f','l','3','2'): 
    140135    case VLC_FOURCC('f','i','3','2'): 
    141         i_result = 4; 
    142         break; 
    143  
    144     case VLC_FOURCC('s','p','d','i'): 
    145     case VLC_FOURCC('s','p','d','b'): /* Big endian spdif output */ 
    146     case VLC_FOURCC('a','5','2',' '): 
    147     case VLC_FOURCC('d','t','s',' '): 
    148     case VLC_FOURCC('m','p','g','a'): 
    149     case VLC_FOURCC('m','p','g','3'): 
     136        return 32; 
     137 
     138    case VLC_FOURCC('f','l','6','4'): 
     139        return 64; 
     140 
    150141    default: 
    151142        /* For these formats the caller has to indicate the parameters 
    152143         * by hand. */ 
    153         return; 
    154     } 
    155  
    156     p_format->i_bytes_per_frame = i_result * aout_FormatNbChannels( p_format ); 
    157     p_format->i_frame_length = 1; 
     144        return 0; 
     145    } 
     146
     147 
     148/***************************************************************************** 
     149 * aout_FormatPrepare : compute the number of bytes per frame & frame length 
     150 *****************************************************************************/ 
     151void aout_FormatPrepare( audio_sample_format_t * p_format ) 
     152
     153    p_format->i_bitspersample = aout_BitsPerSample( p_format->i_format ); 
     154    if( p_format->i_bitspersample > 0 ) 
     155    { 
     156        p_format->i_bytes_per_frame = ( p_format->i_bitspersample / 8 ) 
     157                                    * aout_FormatNbChannels( p_format ); 
     158        p_format->i_frame_length = 1; 
     159    } 
    158160} 
    159161