Changeset 7b0773e690a9c1388f4cfbe7c8fa3fa43a76e54c

Show
Ignore:
Timestamp:
19/05/07 23:43:16 (1 year ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1179610996 +0000
git-parent:

[ce6766b628309d49350ed494fc61e86b11f7acd1]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1179610996 +0000
Message:

Use a vlc_CPU() wrapper instead of (ab)using libvlc_global

Files:

Legend:

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

    raaa92c2 r7b0773e  
    11631163#define CPU_CAPABILITY_ALTIVEC (1<<16) 
    11641164#define CPU_CAPABILITY_FPU     (1<<31) 
     1165VLC_EXPORT( unsigned, vlc_CPU, ( void ) ); 
    11651166 
    11661167/***************************************************************************** 
  • modules/audio_filter/converter/mpgatofixed32.c

    rd3fe7f2 r7b0773e  
    314314    mad_stream_options( &p_sys->mad_stream, MAD_OPTION_IGNORECRC ); 
    315315 
    316     if( p_this->p_libvlc_global->i_cpu & CPU_CAPABILITY_FPU ) 
     316    if( vlc_CPU() & CPU_CAPABILITY_FPU ) 
    317317        p_filter->fmt_out.i_codec = VLC_FOURCC('f','l','3','2'); 
    318318    else 
  • modules/audio_output/alsa.c

    r9025fab r7b0773e  
    358358    /* Choose the linear PCM format (read the comment above about FPU 
    359359       and float32) */ 
    360     if( p_aout->p_libvlc_global->i_cpu & CPU_CAPABILITY_FPU ) 
     360    if( vlc_CPU() & CPU_CAPABILITY_FPU ) 
    361361    { 
    362362        i_vlc_pcm_format = VLC_FOURCC('f','l','3','2'); 
  • modules/codec/faad.c

    r512f81c r7b0773e  
    122122    p_dec->fmt_out.i_cat = AUDIO_ES; 
    123123 
    124     if (p_this->p_libvlc_global->i_cpu & CPU_CAPABILITY_FPU) 
     124    if (vlc_CPU() & CPU_CAPABILITY_FPU) 
    125125        p_dec->fmt_out.i_codec = VLC_FOURCC('f','l','3','2'); 
    126126    else 
     
    157157    /* Set the faad config */ 
    158158    cfg = faacDecGetCurrentConfiguration( p_sys->hfaad ); 
    159     if (p_this->p_libvlc_global->i_cpu & CPU_CAPABILITY_FPU) 
     159    if (vlc_CPU() & CPU_CAPABILITY_FPU) 
    160160        cfg->outputFormat = FAAD_FMT_FLOAT; 
    161161    else 
     
    433433 
    434434    /* Do the actual reordering */ 
    435     if( p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_FPU ) 
     435    if( vlc_CPU() & CPU_CAPABILITY_FPU ) 
    436436        for( i = 0; i < i_samples; i++ ) 
    437437            for( j = 0; j < i_nb_channels; j++ ) 
  • modules/codec/ffmpeg/encoder.c

    r9025fab r7b0773e  
    262262 
    263263    /* Set CPU capabilities */ 
     264    unsigned i_cpu = vlc_CPU(); 
    264265    p_context->dsp_mask = 0; 
    265     if( !(p_enc->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMX) ) 
     266    if( !(i_cpu & CPU_CAPABILITY_MMX) ) 
    266267    { 
    267268        p_context->dsp_mask |= FF_MM_MMX; 
    268269    } 
    269     if( !(p_enc->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT) ) 
     270    if( !(i_cpu & CPU_CAPABILITY_MMXEXT) ) 
    270271    { 
    271272        p_context->dsp_mask |= FF_MM_MMXEXT; 
    272273    } 
    273     if( !(p_enc->p_libvlc_global->i_cpu & CPU_CAPABILITY_3DNOW) ) 
     274    if( !(i_cpu & CPU_CAPABILITY_3DNOW) ) 
    274275    { 
    275276        p_context->dsp_mask |= FF_MM_3DNOW; 
    276277    } 
    277     if( !(p_enc->p_libvlc_global->i_cpu & CPU_CAPABILITY_SSE) ) 
     278    if( !(i_cpu & CPU_CAPABILITY_SSE) ) 
    278279    { 
    279280        p_context->dsp_mask |= FF_MM_SSE; 
  • modules/codec/ffmpeg/ffmpeg.c

    r4fc4b04 r7b0773e  
    235235#endif 
    236236 
    237     var_Create( p_module->p_libvlc_global, "avcodec", VLC_VAR_MUTEX ); 
     237    var_Create( (vlc_object_t *)p_module->p_libvlc_global, "avcodec", 
     238                VLC_VAR_MUTEX ); 
    238239 
    239240vlc_module_end(); 
     
    285286 
    286287    /* Set CPU capabilities */ 
     288    unsigned i_cpu = vlc_CPU(); 
    287289    p_context->dsp_mask = 0; 
    288     if( !(p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMX) ) 
     290    if( !(i_cpu & CPU_CAPABILITY_MMX) ) 
    289291    { 
    290292        p_context->dsp_mask |= FF_MM_MMX; 
    291293    } 
    292     if( !(p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT) ) 
     294    if( !(i_cpu & CPU_CAPABILITY_MMXEXT) ) 
    293295    { 
    294296        p_context->dsp_mask |= FF_MM_MMXEXT; 
    295297    } 
    296     if( !(p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_3DNOW) ) 
     298    if( !(i_cpu & CPU_CAPABILITY_3DNOW) ) 
    297299    { 
    298300        p_context->dsp_mask |= FF_MM_3DNOW; 
    299301    } 
    300     if( !(p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_SSE) ) 
     302    if( !(i_cpu & CPU_CAPABILITY_SSE) ) 
    301303    { 
    302304        p_context->dsp_mask |= FF_MM_SSE; 
    303305    } 
    304     if( !(p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_SSE2) ) 
     306    if( !(i_cpu & CPU_CAPABILITY_SSE2) ) 
    305307    { 
    306308        p_context->dsp_mask |= FF_MM_SSE2; 
     
    338340    vlc_value_t lockval; 
    339341 
    340     var_Get( p_dec->p_libvlc_global, "avcodec", &lockval ); 
     342    var_Get( (vlc_object_t *)p_dec->p_libvlc_global, "avcodec", &lockval ); 
    341343 
    342344    switch( p_sys->i_cat ) 
     
    427429    vlc_value_t lockval; 
    428430 
    429     var_Get( p_object->p_libvlc_global, "avcodec", &lockval ); 
     431    var_Get( (vlc_object_t *)p_object->p_libvlc_global, "avcodec", &lockval ); 
    430432    vlc_mutex_lock( lockval.p_address ); 
    431433 
  • modules/codec/ffmpeg/postprocess.c

    rd3fe7f2 r7b0773e  
    123123{ 
    124124    video_postproc_sys_t *p_sys = (video_postproc_sys_t *)p_data; 
    125     int32_t i_cpu = p_dec->p_libvlc_global->i_cpu
     125    unsigned i_cpu = vlc_CPU()
    126126    int i_flags = 0; 
    127127 
  • modules/codec/ffmpeg/scale.c

    r89daefd r7b0773e  
    116116 
    117117    /* Set CPU capabilities */ 
     118    unsigned i_cpu = vlc_CPU(); 
    118119    p_sys->i_cpu_mask = 0; 
    119     if( p_filter->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMX ) 
     120    if( i_cpu & CPU_CAPABILITY_MMX ) 
    120121    { 
    121122        p_sys->i_cpu_mask |= SWS_CPU_CAPS_MMX; 
    122123    } 
    123     if( p_filter->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT ) 
     124    if( i_cpu & CPU_CAPABILITY_MMXEXT ) 
    124125    { 
    125126        p_sys->i_cpu_mask |= SWS_CPU_CAPS_MMX2; 
    126127    } 
    127     if( p_filter->p_libvlc_global->i_cpu & CPU_CAPABILITY_3DNOW ) 
     128    if( i_cpu & CPU_CAPABILITY_3DNOW ) 
    128129    { 
    129130        p_sys->i_cpu_mask |= SWS_CPU_CAPS_3DNOW; 
    130131    } 
    131     if( p_filter->p_libvlc_global->i_cpu & CPU_CAPABILITY_ALTIVEC ) 
     132    if( i_cpu & CPU_CAPABILITY_ALTIVEC ) 
    132133    { 
    133134        p_sys->i_cpu_mask |= SWS_CPU_CAPS_ALTIVEC; 
  • modules/codec/libmpeg2.c

    r5021c9c r7b0773e  
    149149 
    150150#if defined( __i386__ ) || defined( __x86_64__ ) 
    151     if( p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMX ) 
     151    if( vlc_CPU() & CPU_CAPABILITY_MMX ) 
    152152    { 
    153153        i_accel |= MPEG2_ACCEL_X86_MMX; 
    154154    } 
    155155 
    156     if( p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_3DNOW ) 
     156    if( vlc_CPU() & CPU_CAPABILITY_3DNOW ) 
    157157    { 
    158158        i_accel |= MPEG2_ACCEL_X86_3DNOW; 
    159159    } 
    160160 
    161     if( p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT ) 
     161    if( vlc_CPU() & CPU_CAPABILITY_MMXEXT ) 
    162162    { 
    163163        i_accel |= MPEG2_ACCEL_X86_MMXEXT; 
     
    165165 
    166166#elif defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ ) 
    167     if( p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_ALTIVEC ) 
     167    if( vlc_CPU() & CPU_CAPABILITY_ALTIVEC ) 
    168168    { 
    169169        i_accel |= MPEG2_ACCEL_PPC_ALTIVEC; 
  • modules/codec/x264.c

    r72d1dd3 r7b0773e  
    11151115        p_sys->param.i_fps_den = p_enc->fmt_in.video.i_frame_rate_base; 
    11161116    } 
    1117     if( !(p_enc->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMX) ) 
     1117 
     1118    unsigned i_cpu = vlc_CPU(); 
     1119    if( !(i_cpu & CPU_CAPABILITY_MMX) ) 
    11181120    { 
    11191121        p_sys->param.cpu &= ~X264_CPU_MMX; 
    11201122    } 
    1121     if( !(p_enc->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT) ) 
     1123    if( !(i_cpu & CPU_CAPABILITY_MMXEXT) ) 
    11221124    { 
    11231125        p_sys->param.cpu &= ~X264_CPU_MMXEXT; 
    11241126    } 
    1125     if( !(p_enc->p_libvlc_global->i_cpu & CPU_CAPABILITY_SSE) ) 
     1127    if( !(i_cpu & CPU_CAPABILITY_SSE) ) 
    11261128    { 
    11271129        p_sys->param.cpu &= ~X264_CPU_SSE; 
    11281130    } 
    1129     if( !(p_enc->p_libvlc_global->i_cpu & CPU_CAPABILITY_SSE2) ) 
     1131    if( !(i_cpu & CPU_CAPABILITY_SSE2) ) 
    11301132    { 
    11311133        p_sys->param.cpu &= ~X264_CPU_SSE2; 
  • modules/codec/xvmc/xxmc.c

    r5c0e385 r7b0773e  
    153153 
    154154#if defined( __i386__ ) 
    155     if( p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMX ) 
     155    if( vlc_CPU() & CPU_CAPABILITY_MMX ) 
    156156    { 
    157157        i_accel |= MPEG2_ACCEL_X86_MMX; 
    158158    } 
    159159 
    160     if( p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_3DNOW ) 
     160    if( vlc_CPU() & CPU_CAPABILITY_3DNOW ) 
    161161    { 
    162162        i_accel |= MPEG2_ACCEL_X86_3DNOW; 
    163163    } 
    164164 
    165     if( p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT ) 
     165    if( vlc_CPU() & CPU_CAPABILITY_MMXEXT ) 
    166166    { 
    167167        i_accel |= MPEG2_ACCEL_X86_MMXEXT; 
     
    169169 
    170170#elif defined( __powerpc__ ) || defined( SYS_DARWIN ) 
    171     if( p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_ALTIVEC ) 
     171    if( vlc_CPU() & CPU_CAPABILITY_ALTIVEC ) 
    172172    { 
    173173        i_accel |= MPEG2_ACCEL_PPC_ALTIVEC; 
  • modules/stream_out/switcher.c

    r6f087f5 r7b0773e  
    353353 
    354354        /* Set CPU capabilities */ 
     355        unsigned i_cpu = vlc_CPU(); 
    355356        id->ff_enc_c->dsp_mask = 0; 
    356         if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMX) ) 
     357        if( !(i_cpu & CPU_CAPABILITY_MMX) ) 
    357358        { 
    358359            id->ff_enc_c->dsp_mask |= FF_MM_MMX; 
    359360        } 
    360         if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT) ) 
     361        if( !(i_cpu & CPU_CAPABILITY_MMXEXT) ) 
    361362        { 
    362363            id->ff_enc_c->dsp_mask |= FF_MM_MMXEXT; 
    363364        } 
    364         if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_3DNOW) ) 
     365        if( !(i_cpu & CPU_CAPABILITY_3DNOW) ) 
    365366        { 
    366367            id->ff_enc_c->dsp_mask |= FF_MM_3DNOW; 
    367368        } 
    368         if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_SSE) ) 
     369        if( !(i_cpu & CPU_CAPABILITY_SSE) ) 
    369370        { 
    370371            id->ff_enc_c->dsp_mask |= FF_MM_SSE; 
     
    726727 
    727728        /* Set CPU capabilities */ 
     729        unsigned i_cpu = vlc_CPU(); 
    728730        id->ff_enc_c->dsp_mask = 0; 
    729         if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMX) ) 
     731        if( !(i_cpu & CPU_CAPABILITY_MMX) ) 
    730732        { 
    731733            id->ff_enc_c->dsp_mask |= FF_MM_MMX; 
    732734        } 
    733         if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT) ) 
     735        if( !(i_cpu & CPU_CAPABILITY_MMXEXT) ) 
    734736        { 
    735737            id->ff_enc_c->dsp_mask |= FF_MM_MMXEXT; 
    736738        } 
    737         if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_3DNOW) ) 
     739        if( !(i_cpu & CPU_CAPABILITY_3DNOW) ) 
    738740        { 
    739741            id->ff_enc_c->dsp_mask |= FF_MM_3DNOW; 
    740742        } 
    741         if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_SSE) ) 
     743        if( !(i_cpu & CPU_CAPABILITY_SSE) ) 
    742744        { 
    743745            id->ff_enc_c->dsp_mask |= FF_MM_SSE; 
  • modules/video_filter/deinterlace.c

    r6ec82b0 r7b0773e  
    208208 
    209209#if defined(CAN_COMPILE_C_ALTIVEC) 
    210     if( p_vout->p_libvlc_global->i_cpu & CPU_CAPABILITY_ALTIVEC ) 
     210    if( vlc_CPU() & CPU_CAPABILITY_ALTIVEC ) 
    211211    { 
    212212        p_vout->p_sys->pf_merge = MergeAltivec; 
     
    216216#endif 
    217217#if defined(CAN_COMPILE_SSE) 
    218     if( p_vout->p_libvlc_global->i_cpu & CPU_CAPABILITY_SSE2 ) 
     218    if( vlc_CPU() & CPU_CAPABILITY_SSE2 ) 
    219219    { 
    220220        p_vout->p_sys->pf_merge = MergeSSE2; 
     
    224224#endif 
    225225#if defined(CAN_COMPILE_MMXEXT) 
    226     if( p_vout->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT ) 
     226    if( vlc_CPU() & CPU_CAPABILITY_MMXEXT ) 
    227227    { 
    228228        p_vout->p_sys->pf_merge = MergeMMXEXT; 
     
    232232#endif 
    233233#if defined(CAN_COMPILE_3DNOW) 
    234     if( p_vout->p_libvlc_global->i_cpu & CPU_CAPABILITY_3DNOW ) 
     234    if( vlc_CPU() & CPU_CAPABILITY_3DNOW ) 
    235235    { 
    236236        p_vout->p_sys->pf_merge = Merge3DNow; 
     
    19661966 
    19671967#ifdef CAN_COMPILE_MMXEXT 
    1968             if( p_vout->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT ) 
     1968            if( vlc_CPU & CPU_CAPABILITY_MMXEXT ) 
    19691969                XDeintBand8x8MMXEXT( dst, i_dst, src, i_src, i_mbx, i_modx ); 
    19701970            else 
     
    19931993 
    19941994#ifdef CAN_COMPILE_MMXEXT 
    1995     if( p_vout->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT ) 
     1995    if( vlc_CPU & CPU_CAPABILITY_MMXEXT ) 
    19961996        emms(); 
    19971997#endif 
  • src/libvlc-common.c

    rba04cf9 r7b0773e  
    174174    { 
    175175        /* Guess what CPU we have */ 
    176         libvlc_global.i_cpu = CPUCapabilities(); 
     176        cpu_flags = CPUCapabilities(); 
    177177       /* The module bank will be initialized later */ 
    178178        libvlc_global.p_module_bank = NULL; 
     
    729729 
    730730    if( !config_GetInt( p_libvlc, "fpu" ) ) 
    731         libvlc_global.i_cpu &= ~CPU_CAPABILITY_FPU; 
     731        cpu_flags &= ~CPU_CAPABILITY_FPU; 
    732732 
    733733#if defined( __i386__ ) || defined( __x86_64__ ) 
    734734    if( !config_GetInt( p_libvlc, "mmx" ) ) 
    735         libvlc_global.i_cpu &= ~CPU_CAPABILITY_MMX; 
     735        cpu_flags &= ~CPU_CAPABILITY_MMX; 
    736736    if( !config_GetInt( p_libvlc, "3dn" ) ) 
    737         libvlc_global.i_cpu &= ~CPU_CAPABILITY_3DNOW; 
     737        cpu_flags &= ~CPU_CAPABILITY_3DNOW; 
    738738    if( !config_GetInt( p_libvlc, "mmxext" ) ) 
    739         libvlc_global.i_cpu &= ~CPU_CAPABILITY_MMXEXT; 
     739        cpu_flags &= ~CPU_CAPABILITY_MMXEXT; 
    740740    if( !config_GetInt( p_libvlc, "sse" ) ) 
    741         libvlc_global.i_cpu &= ~CPU_CAPABILITY_SSE; 
     741        cpu_flags &= ~CPU_CAPABILITY_SSE; 
    742742    if( !config_GetInt( p_libvlc, "sse2" ) ) 
    743         libvlc_global.i_cpu &= ~CPU_CAPABILITY_SSE2; 
     743        cpu_flags &= ~CPU_CAPABILITY_SSE2; 
    744744#endif 
    745745#if defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ ) 
    746746    if( !config_GetInt( p_libvlc, "altivec" ) ) 
    747         libvlc_global.i_cpu &= ~CPU_CAPABILITY_ALTIVEC; 
     747        cpu_flags &= ~CPU_CAPABILITY_ALTIVEC; 
    748748#endif 
    749749 
    750750#define PRINT_CAPABILITY( capability, string )                              \ 
    751     if( libvlc_global.i_cpu & capability )                                         \ 
     751    if( vlc_CPU() & capability )                                            \ 
    752752    {                                                                       \ 
    753753        strncat( p_capabilities, string " ",                                \ 
  • src/misc/cpu.c

    rd3fe7f2 r7b0773e  
    5252static int     i_illegal; 
    5353#if defined( __i386__ ) || defined( __x86_64__ ) 
    54 static char  *psz_capability; 
     54static const char *psz_capability; 
    5555#endif 
    5656#endif 
     
    6161 * This function is called to list extensions the CPU may have. 
    6262 *****************************************************************************/ 
    63 uint32_t CPUCapabilities( void ) 
     63static uint32_t CPUCapabilities( void ) 
    6464{ 
    6565    volatile uint32_t i_capabilities = CPU_CAPABILITY_NONE; 
     
    339339#endif 
    340340 
     341 
     342extern uint32_t cpu_flags = 0; 
     343 
     344 
     345/***************************************************************************** 
     346 * vlc_CPU: get pre-computed CPU capability flags 
     347 ****************************************************************************/ 
     348unsigned vlc_CPU (void) 
     349{ 
     350    return cpu_flags; 
     351} 
     352