Changeset 34c71967f9b0e4533ba8343062282029f39e7089

Show
Ignore:
Timestamp:
03/09/02 01:17:06 (6 years ago)
Author:
Christophe Massiot <massiot@videolan.org>
git-committer:
Christophe Massiot <massiot@videolan.org> 1031008626 +0000
git-parent:

[1e666bc25b9479cc3c07d18cc7d3ad93e7567066]

git-author:
Christophe Massiot <massiot@videolan.org> 1031008626 +0000
Message:

The liba52 "codec" is now an audio filter. It means we are now able to
autodetect S/PDIF hardware support and the audio output plug-in chooses
the best one. Of course it probably breaks existing output modules, see
oss.c for hints :).

Also include minor tweaks which will entitle us to decode and output 5.1
audio. It may break existing plug-ins, too. See
audio_output.c:aout_FormatNbChannels for hints.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Makefile.opts.in

    r6038883 r34c7196  
    5959mozilla_CFLAGS = @mozilla_CFLAGS@ 
    6060 
    61 a52_CFLAGS = @a52_CFLAGS@ 
     61a52tofloat32_CFLAGS = @a52tofloat32_CFLAGS@ 
    6262arts_CFLAGS = @arts_CFLAGS@ 
    6363i420_yuy2_mmx_CFLAGS = @i420_yuy2_mmx_CFLAGS@ 
     
    9595mozilla_LDFLAGS = @mozilla_LDFLAGS@ 
    9696 
    97 a52_LDFLAGS = @a52_LDFLAGS@ 
     97a52tofloat32_LDFLAGS = @a52tofloat32_LDFLAGS@ 
    9898aa_LDFLAGS = @aa_LDFLAGS@ 
    9999alsa_LDFLAGS = @alsa_LDFLAGS@ 
  • configure.in

    r16f2ff8 r34c7196  
    447447PLUGINS="${PLUGINS} control/rc/rc misc/logger/logger access/file misc/memcpy/memcpy" 
    448448PLUGINS="${PLUGINS} demux/mpeg/es demux/mpeg/audio demux/mpeg/mpeg_system demux/mpeg/ps demux/mpeg/ts demux/a52sys" 
    449 PLUGINS="${PLUGINS} codec/mpeg_video/idct/idct codec/mpeg_video/idct/idctclassic codec/mpeg_video/motion/motion codec/mpeg_video/mpeg_video codec/spudec/spudec codec/spdif codec/mpeg_audio/mpeg_audio" 
    450 PLUGINS="${PLUGINS} codec/a52old/imdct/imdct codec/a52old/downmix/downmix codec/a52old/a52old
     449PLUGINS="${PLUGINS} codec/mpeg_video/idct/idct codec/mpeg_video/idct/idctclassic codec/mpeg_video/motion/motion codec/mpeg_video/mpeg_video codec/spudec/spudec codec/mpeg_audio/mpeg_audio" 
     450PLUGINS="${PLUGINS} codec/a52old/imdct/imdct codec/a52old/downmix/downmix codec/a52old/a52old codec/a52
    451451#PLUGINS="${PLUGINS} codec/lpcm/lpcm" 
    452452PLUGINS="${PLUGINS} video_filter/deinterlace/deinterlace video_filter/invert video_filter/wall video_filter/transform video_filter/distort video_filter/clone video_filter/crop video_filter/motionblur" 
     
    11861186    then 
    11871187      AC_MSG_RESULT(yes) 
    1188       a52_CFLAGS="${a52_CFLAGS} -I${real_a52_tree}" 
    1189       a52_LDFLAGS="${a52_LDFLAGS} -L${real_a52_tree}/liba52/.libs" 
    1190       LDFLAGS="${save_LDFLAGS} ${a52_LDFLAGS}" 
     1188      a52tofloat32_CFLAGS="${a52tofloat32_CFLAGS} -I${real_a52_tree}" 
     1189      a52tofloat32_LDFLAGS="${a52tofloat32_LDFLAGS} -L${real_a52_tree}/liba52/.libs" 
     1190      LDFLAGS="${save_LDFLAGS} ${a52tofloat32_LDFLAGS}" 
    11911191      AC_CHECK_LIB(a52, a52_free, [ 
    1192         BUILTINS="${BUILTINS} codec/a52" 
    1193         a52_LDFLAGS="${a52_LDFLAGS} -la52 -lm" 
    1194         a52_CFLAGS="${a52_CFLAGS} -DUSE_A52DEC_TREE" 
     1192        BUILTINS="${BUILTINS} audio_filter/converter/a52tofloat32" 
     1193        a52tofloat32_LDFLAGS="${a52tofloat32_LDFLAGS} -la52 -lm" 
     1194        a52tofloat32_CFLAGS="${a52tofloat32_CFLAGS} -DUSE_A52DEC_TREE" 
    11951195        ],[ 
    11961196        if test -f ${real_a52_tree}/liba52/.libs/liba52.a 
    11971197        then 
    1198           AC_MSG_ERROR([make sure you have at least a52dec-0.7.3]) 
     1198          AC_MSG_ERROR([make sure you have at least a52dec-0.7.4]) 
    11991199        else 
    12001200          AC_MSG_ERROR([the specified tree hasn't been compiled]) 
     
    12211221    AC_CHECK_HEADERS(a52dec/a52.h, [ 
    12221222      AC_CHECK_LIB(a52, a52_free, [ 
    1223         BUILTINS="${BUILTINS} codec/a52" 
    1224         a52_LDFLAGS="${a52_LDFLAGS} ${test_LDFLAGS} -la52 -lm" 
    1225         a52_CFLAGS="${a52_CFLAGS} ${test_CFLAGS}" 
     1223        BUILTINS="${BUILTINS} audio_filter/converter/a52tofloat32" 
     1224        a52tofloat32_LDFLAGS="${a52tofloat32_LDFLAGS} ${test_LDFLAGS} -la52 -lm" 
     1225        a52tofloat32_CFLAGS="${a52tofloat32_CFLAGS} ${test_CFLAGS}" 
    12261226      ],[ 
    12271227        if test "x${enable_dvbpsi}" != "x" 
     
    20822082AC_SUBST(mozilla_CFLAGS) 
    20832083 
    2084 AC_SUBST(a52_CFLAGS) 
     2084AC_SUBST(a52tofloat32_CFLAGS) 
    20852085AC_SUBST(arts_CFLAGS) 
    20862086AC_SUBST(i420_yuy2_mmx_CFLAGS) 
     
    21162116AC_SUBST(mozilla_LDFLAGS) 
    21172117 
    2118 AC_SUBST(a52_LDFLAGS) 
     2118AC_SUBST(a52tofloat32_LDFLAGS) 
    21192119AC_SUBST(aa_LDFLAGS) 
    21202120AC_SUBST(alsa_LDFLAGS) 
  • include/aout_internal.h

    r0699631 r34c7196  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: aout_internal.h,v 1.14 2002/08/30 23:27:05 massiot Exp $ 
     5 * $Id: aout_internal.h,v 1.15 2002/09/02 23:17:05 massiot Exp $ 
    66 * 
    77 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    227227VLC_EXPORT( aout_buffer_t *, aout_OutputNextBuffer, ( aout_instance_t *, mtime_t, vlc_bool_t ) ); 
    228228 
     229VLC_EXPORT( int, aout_FormatNbChannels, ( audio_sample_format_t * p_format ) ); 
    229230void aout_FormatPrepare( audio_sample_format_t * p_format ); 
    230231void aout_FifoInit( aout_instance_t *, aout_fifo_t *, u32 ); 
  • include/audio_output.h

    r1c13a98 r34c7196  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: audio_output.h,v 1.61 2002/08/21 22:41:59 massiot Exp $ 
     5 * $Id: audio_output.h,v 1.62 2002/09/02 23:17:05 massiot Exp $ 
    66 * 
    77 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    108108 
    109109 
     110/* Dual mono. Two independant mono channels */ 
     111#define AOUT_CHAN_CHANNEL   0x0000000B 
     112#define AOUT_CHAN_MONO      0x00000001 
     113#define AOUT_CHAN_STEREO    0x00000002 
     114/* 3 front channels (left, center, right) */ 
     115#define AOUT_CHAN_3F        0x00000003 
     116/* 2 front, 1 rear surround channels (L, R, S) */ 
     117#define AOUT_CHAN_2F1R      0x00000004 
     118/* 3 front, 1 rear surround channels (L, C, R, S) */ 
     119#define AOUT_CHAN_3F1R      0x00000005 
     120/* 2 front, 2 rear surround channels (L, R, LS, RS) */ 
     121#define AOUT_CHAN_2F2R      0x00000006 
     122/* 3 front, 2 rear surround channels (L, C, R, LS, RS) */ 
     123#define AOUT_CHAN_3F2R      0x00000007 
     124/* First of two mono channels */ 
     125#define AOUT_CHAN_CHANNEL1  0x00000008 
     126/* Second of two mono channels */ 
     127#define AOUT_CHAN_CHANNEL2  0x00000009 
     128/* Dolby surround compatible stereo */ 
     129#define AOUT_CHAN_DOLBY     0x0000000A 
     130 
     131#define AOUT_CHAN_MASK      0x0000000F 
     132 
     133/* Low frequency effects channel. Normally used to connect a subwoofer. 
     134 * Can be combined with any of the above channels. For example : 
     135 * AOUT_CHAN_3F2R | AOUT_CHAN_LFE -> 3 front, 2 rear, 1 LFE (5.1) */ 
     136#define AOUT_CHAN_LFE       0x00000010 
     137 
     138 
    110139/***************************************************************************** 
    111140 * aout_buffer_t : audio output buffer 
  • include/vlc_symbols.h

    r7d2f6de r34c7196  
    3838    int (* __vlc_threads_end_inner) ( vlc_object_t * ) ; 
    3939    int (* __vlc_threads_init_inner) ( vlc_object_t * ) ; 
     40    int (* aout_FormatNbChannels_inner) ( audio_sample_format_t * p_format ) ; 
    4041    int (* input_AccessInit_inner) ( input_thread_t * ) ; 
    4142    int (* input_AddInfo_inner) ( input_info_category_t *, char *, char *, ... ) ; 
     
    225226#   define aout_DeleteInstance p_symbols->aout_DeleteInstance_inner 
    226227#   define aout_FifoPop p_symbols->aout_FifoPop_inner 
     228#   define aout_FormatNbChannels p_symbols->aout_FormatNbChannels_inner 
    227229#   define aout_InputDelete p_symbols->aout_InputDelete_inner 
    228230#   define aout_OutputNextBuffer p_symbols->aout_OutputNextBuffer_inner 
  • include/vlc_threads.h

    r1e666bc r34c7196  
    44 ***************************************************************************** 
    55 * Copyright (C) 1999, 2002 VideoLAN 
    6  * $Id: vlc_threads.h,v 1.12 2002/09/01 21:20:29 massiot Exp $ 
     6 * $Id: vlc_threads.h,v 1.13 2002/09/02 23:17:05 massiot Exp $ 
    77 * 
    88 * Authors: Jean-Marc Dressler <polux@via.ecp.fr> 
     
    7272#   define VLC_THREAD_PRIORITY_INPUT 37 
    7373#   define VLC_THREAD_PRIORITY_AUDIO 38 
    74 #   define VLC_THREAD_PRIORITY_VIDEO 36 
     74#   define VLC_THREAD_PRIORITY_VIDEO 31 
    7575#   define VLC_THREAD_PRIORITY_OUTPUT 38 
    7676 
  • modules/audio_filter/converter/Makefile

    rafa6c92 r34c7196  
    44float32tou8_SOURCES = float32tou8.c 
    55a52tospdif_SOURCES = a52tospdif.c 
     6a52tofloat32_SOURCES = a52tofloat32.c 
    67fixed32tos16_SOURCES = fixed32tos16.c 
    78fixed32tofloat32_SOURCES = fixed32tofloat32.c 
  • modules/audio_filter/converter/a52tospdif.c

    r15f3b0f r34c7196  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: a52tospdif.c,v 1.10 2002/08/26 23:00:22 massiot Exp $ 
     5 * $Id: a52tospdif.c,v 1.11 2002/09/02 23:17:05 massiot Exp $ 
    66 * 
    77 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    4343 *****************************************************************************/ 
    4444static int  Create    ( vlc_object_t * ); 
    45  
    4645static void DoWork    ( aout_instance_t *, aout_filter_t *, aout_buffer_t *, 
    4746                        aout_buffer_t * ); 
     
    5756 
    5857/***************************************************************************** 
    59  * Create: allocate trivial mixer 
    60  ***************************************************************************** 
    61  * This function allocates and initializes a Crop vout method. 
     58 * Create: 
    6259 *****************************************************************************/ 
    6360static int Create( vlc_object_t *p_this ) 
  • modules/audio_output/oss.c

    r13f4593 r34c7196  
    33 ***************************************************************************** 
    44 * Copyright (C) 2000-2002 VideoLAN 
    5  * $Id: oss.c,v 1.22 2002/08/31 22:10:25 stef Exp $ 
     5 * $Id: oss.c,v 1.23 2002/09/02 23:17:05 massiot Exp $ 
    66 * 
    77 * Authors: Michel Kaempf <maxx@via.ecp.fr> 
     
    175175         || i_format != p_aout->output.output.i_format ) 
    176176    { 
    177         msg_Err( p_aout, "cannot set audio output format (%i)", i_format ); 
    178         return VLC_EGENERIC; 
     177        if ( i_format == AOUT_FMT_SPDIF ) 
     178        { 
     179            /* Retry with S16 */ 
     180            msg_Warn( p_aout, "cannot set audio output format (%i)", i_format ); 
     181            p_aout->output.output.i_format = i_format = AOUT_FMT_S16_NE; 
     182            p_aout->output.i_nb_samples = FRAME_SIZE; 
     183            if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0 
     184                 || i_format != p_aout->output.output.i_format ) 
     185            { 
     186                msg_Err( p_aout, "cannot set audio output format (%i)", 
     187                         i_format ); 
     188                return VLC_EGENERIC; 
     189            } 
     190        } 
     191        else 
     192        { 
     193            msg_Err( p_aout, "cannot set audio output format (%i)", i_format ); 
     194            return VLC_EGENERIC; 
     195        } 
    179196    } 
    180197 
  • modules/audio_output/sdl.c

    r4d51273 r34c7196  
    33 ***************************************************************************** 
    44 * Copyright (C) 2000-2002 VideoLAN 
    5  * $Id: sdl.c,v 1.10 2002/08/31 19:58:04 stef Exp $ 
     5 * $Id: sdl.c,v 1.11 2002/09/02 23:17:05 massiot Exp $ 
    66 * 
    77 * Authors: Michel Kaempf <maxx@via.ecp.fr> 
     
    104104    } 
    105105 
     106    if ( p_aout->output.output.i_channels > 2 ) 
     107        p_aout->output.output.i_channels = 2; 
     108    p_aout->output.output.i_format = AOUT_FMT_S16_NE; 
     109    p_aout->output.i_nb_samples = FRAME_SIZE; 
     110 
    106111    /* TODO: finish and clean this */ 
    107112 
     
    118123        return VLC_EGENERIC; 
    119124    } 
    120  
    121     p_aout->output.output.i_format = AOUT_FMT_S16_NE; 
    122     p_aout->output.i_nb_samples = FRAME_SIZE; 
    123125 
    124126    SDL_PauseAudio( 0 ); 
  • modules/codec/Makefile

    r9a9f8a1 r34c7196  
    11a52_SOURCES = a52.c 
    2 spdif_SOURCES = spdif.c 
  • modules/codec/a52.c

    r0b88e77 r34c7196  
    11/***************************************************************************** 
    2  * a52.c: ATSC A/52 aka AC-3 decoder plugin for vlc. 
    3  *   This plugin makes use of liba52 to decode A/52 audio 
    4  *   (http://liba52.sf.net/). 
     2 * a52.c: A/52 basic parser 
    53 ***************************************************************************** 
    6  * Copyright (C) 2001, 2002 VideoLAN 
    7  * $Id: a52.c,v 1.8 2002/08/30 22:22:24 massiot Exp $ 
     4 * Copyright (C) 2001-2002 VideoLAN 
     5 * $Id: a52.c,v 1.9 2002/09/02 23:17:05 massiot Exp $ 
    86 * 
    9  * Authors: Gildas Bazin <gbazin@netcourrier.com
     7 * Authors: St�ane Borel <stef@via.ecp.fr
    108 *          Christophe Massiot <massiot@via.ecp.fr> 
    11  *       
     9 *          Michel Lespinasse <walken@zoy.org> 
     10 *          Aaron Holtzman <aholtzma@ess.engr.uvic.ca> 
     11 * 
    1212 * This program is free software; you can redistribute it and/or modify 
    1313 * it under the terms of the GNU General Public License as published by 
     
    2828 * Preamble 
    2929 *****************************************************************************/ 
     30#include <stdio.h> 
     31#include <stdlib.h> 
     32#include <string.h>                                              /* memcpy() */ 
     33#include <fcntl.h> 
     34 
    3035#include <vlc/vlc.h> 
     36#include <vlc/decoder.h> 
    3137#include <vlc/aout.h> 
    32 #include <vlc/decoder.h> 
    33  
    34 #include <stdlib.h>                                      /* malloc(), free() */ 
    35 #include <string.h>                                              /* strdup() */ 
    36 #ifdef HAVE_STDINT_H 
    37 #   include <stdint.h>                                         /* int16_t .. */ 
    38 #elif HAVE_INTTYPES_H 
    39 #   include <inttypes.h>                                       /* int16_t .. */ 
    40 #endif 
    4138 
    4239#ifdef HAVE_UNISTD_H 
     
    4441#endif 
    4542 
    46 #ifdef USE_A52DEC_TREE                                 /* liba52 header file */ 
    47 #   include "include/a52.h" 
    48 #else 
    49 #   include "a52dec/a52.h" 
    50 #endif 
    51  
    5243#define A52_FRAME_NB 1536  
    5344 
    5445/***************************************************************************** 
    55  * a52_thread_t : a52 decoder thread descriptor 
    56  *****************************************************************************/ 
    57 typedef struct a52_thread_s 
     46 * spdif_thread_t : A52 pass-through thread descriptor 
     47 *****************************************************************************/ 
     48typedef struct spdif_thread_s 
    5849{ 
    5950    /* 
    60      * liba52 properties 
     51     * Thread properties 
    6152     */ 
    62     a52_state_t *       p_a52_state; 
    63     vlc_bool_t          b_dynrng; 
    64  
    65     /* The bit stream structure handles the PES stream at the bit level */ 
    66     bit_stream_t        bit_stream; 
     53    vlc_thread_t        thread_id;                /* id for thread functions */ 
    6754 
    6855    /* 
     
    7057     */ 
    7158    decoder_fifo_t *    p_fifo;                /* stores the PES stream data */ 
    72     data_packet_t *     p_data; 
     59 
     60    /* The bit stream structure handles the PES stream at the bit level */ 
     61    bit_stream_t        bit_stream; 
    7362 
    7463    /* 
     
    7867    aout_input_t *      p_aout_input; /* opaque */ 
    7968    audio_sample_format_t output_format; 
    80     audio_date_t        end_date; 
    81 } a52_thread_t; 
    82  
    83 /***************************************************************************** 
     69} spdif_thread_t; 
     70 
     71/**************************************************************************** 
    8472 * Local prototypes 
    85  *****************************************************************************
     73 ****************************************************************************
    8674static int  OpenDecoder    ( vlc_object_t * ); 
    8775static int  RunDecoder     ( decoder_fifo_t * ); 
    88 static int  DecodeFrame    ( a52_thread_t *, byte_t * ); 
    89 static int  InitThread     ( a52_thread_t *, decoder_fifo_t * ); 
    90 static void EndThread      ( a52_thread_t * ); 
     76 
     77static int  InitThread     ( spdif_thread_t *, decoder_fifo_t * ); 
     78static void EndThread      ( spdif_thread_t * ); 
     79 
     80static int  SyncInfo       ( const byte_t *, int *, int *, int * ); 
    9181 
    9282/***************************************************************************** 
    9383 * Module descriptor 
    9484 *****************************************************************************/ 
    95 #define DYNRNG_TEXT N_("A/52 dynamic range compression") 
    96 #define DYNRNG_LONGTEXT N_( \ 
    97     "Dynamic range compression makes the loud sounds softer, and the soft " \ 
    98     "sounds louder, so you can more easily listen to the stream in a noisy " \ 
    99     "environment without disturbing anyone. If you disable the dynamic range "\ 
    100     "compression the playback will be more adapted to a movie theater or a " \ 
    101     "listening room.") 
    102  
    10385vlc_module_begin(); 
    104     add_category_hint( N_("Miscellaneous"), NULL ); 
    105     add_bool( "a52-dynrng", 1, NULL, DYNRNG_TEXT, DYNRNG_LONGTEXT ); 
    106     set_description( _("a52 ATSC A/52 aka AC-3 audio decoder module") ); 
    107     set_capability( "decoder", 60 ); 
     86    set_description( _("A/52 parser") ); 
     87    set_capability( "decoder", 0 ); 
    10888    set_callbacks( OpenDecoder, NULL ); 
     89    add_shortcut( "pass_through" ); 
     90    add_shortcut( "pass" ); 
    10991vlc_module_end(); 
    11092 
     
    11294 * OpenDecoder: probe the decoder and return score 
    11395 ***************************************************************************** 
    114  * Tries to launch a decoder and return score so that the interface is able 
    115  * to choose. 
    116  *****************************************************************************/ 
    117 static int OpenDecoder( vlc_object_t *p_this ) 
    118 { 
     96 * Tries to launch a decoder and return score so that the interface is able  
     97 * to chose. 
     98 *****************************************************************************/ 
     99static int OpenDecoder( vlc_object_t *p_this )  
     100{    
    119101    decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this; 
    120      
     102 
    121103    if( p_fifo->i_fourcc != VLC_FOURCC('a','5','2',' ') 
    122104         && p_fifo->i_fourcc != VLC_FOURCC('a','5','2','b') ) 
    123105    {    
    124         return VLC_EGENERIC; 
     106        return VLC_EGENERIC;  
    125107    } 
    126108 
     
    129111} 
    130112 
    131 /***************************************************************************** 
    132  * RunDecoder: this function is called just after the thread is created 
    133  *****************************************************************************/ 
     113/**************************************************************************** 
     114 * RunDecoder: the whole thing 
     115 **************************************************************************** 
     116 * This function is called just after the thread is launched. 
     117 ****************************************************************************/ 
    134118static int RunDecoder( decoder_fifo_t *p_fifo ) 
    135119{ 
    136     a52_thread_t *p_dec; 
    137  
     120    spdif_thread_t * p_dec; 
     121    audio_date_t end_date; 
     122     
    138123    /* Allocate the memory needed to store the thread's structure */ 
    139     p_dec = (a52_thread_t *)malloc( sizeof(a52_thread_t) ); 
     124    p_dec = malloc( sizeof(spdif_thread_t) ); 
    140125    if( p_dec == NULL ) 
    141126    { 
     
    144129        return -1; 
    145130    } 
    146  
    147     if( InitThread( p_dec, p_fifo ) ) 
    148     { 
    149         msg_Err( p_dec->p_fifo, "could not initialize thread" ); 
     131   
     132    if ( InitThread( p_dec, p_fifo ) ) 
     133    { 
     134         
     135        msg_Err( p_fifo, "could not initialize thread" ); 
    150136        DecoderError( p_fifo ); 
    151137        free( p_dec ); 
     
    153139    } 
    154140 
    155     /* liba52 decoder thread's main loop */ 
    156     while( !p_dec->p_fifo->b_die && !p_dec->p_fifo->b_error ) 
    157     { 
    158         int i_frame_size, i_flags, i_rate, i_bit_rate; 
     141    /* decoder thread's main loop */ 
     142    while ( !p_dec->p_fifo->b_die && !p_dec->p_fifo->b_error ) 
     143    { 
     144        int i_frame_size, i_channels, i_rate, i_bit_rate; 
    159145        mtime_t pts; 
    160146        /* Temporary buffer to store the raw frame to be decoded */ 
    161         byte_t p_frame_buffer[3840]; 
     147        byte_t p_header[7]; 
     148        aout_buffer_t * p_buffer; 
    162149 
    163150        /* Look for sync word - should be 0x0b77 */ 
    164151        RealignBits( &p_dec->bit_stream ); 
    165         while( (ShowBits( &p_dec->bit_stream, 16 ) ) != 0x0b77 &&  
    166                (!p_dec->p_fifo->b_die) && (!p_dec->p_fifo->b_error)) 
     152        while ( (ShowBits( &p_dec->bit_stream, 16 ) ) != 0x0b77 &&  
     153                (!p_dec->p_fifo->b_die) && (!p_dec->p_fifo->b_error)) 
    167154        { 
    168155            RemoveBits( &p_dec->bit_stream, 8 ); 
     
    171158        /* Set the Presentation Time Stamp */ 
    172159        NextPTS( &p_dec->bit_stream, &pts, NULL ); 
    173         if ( pts != 0 && pts != aout_DateGet( &p_dec->end_date ) ) 
    174         { 
    175             aout_DateSet( &p_dec->end_date, pts ); 
     160        if ( pts != 0 && pts != aout_DateGet( &end_date ) ) 
     161        { 
     162            aout_DateSet( &end_date, pts ); 
    176163        } 
    177164 
    178165        /* Get A/52 frame header */ 
    179         GetChunk( &p_dec->bit_stream, p_frame_buffer, 7 ); 
     166        GetChunk( &p_dec->bit_stream, p_header, 7 ); 
    180167        if( p_dec->p_fifo->b_die ) break; 
    181168 
    182169        /* Check if frame is valid and get frame info */ 
    183         i_frame_size = a52_syncinfo( p_frame_buffer, &i_flags, &i_rate, 
    184                                      &i_bit_rate ); 
     170        i_frame_size = SyncInfo( p_header, &i_channels, &i_rate, 
     171                                 &i_bit_rate ); 
    185172 
    186173        if( !i_frame_size ) 
     
    192179        if( (p_dec->p_aout_input != NULL) && 
    193180            ( (p_dec->output_format.i_rate != i_rate) 
    194                /* || (p_dec->output_format.i_channels != i_channels) */ ) ) 
     181                || (p_dec->output_format.i_channels != i_channels) 
     182                || (p_dec->output_format.i_bytes_per_frame != i_frame_size) ) ) 
    195183        { 
    196184            /* Parameters changed - this should not happen. */ 
     
    203191        { 
    204192            p_dec->output_format.i_rate = i_rate; 
    205             /* p_dec->output_format.i_channels = i_channels; */ 
    206             aout_DateInit( &p_dec->end_date, i_rate ); 
     193            p_dec->output_format.i_channels = i_channels; 
     194            p_dec->output_format.i_bytes_per_frame = i_frame_size; 
     195            p_dec->output_format.i_frame_length = A52_FRAME_NB; 
     196            aout_DateInit( &end_date, i_rate ); 
    207197            p_dec->p_aout_input = aout_InputNew( p_dec->p_fifo, 
    208198                                                 &p_dec->p_aout, 
     
    216206        } 
    217207 
    218         /* Get the complete frame */ 
    219         GetChunk( &p_dec->bit_stream, p_frame_buffer + 7, 
     208        if ( !aout_DateGet( &end_date ) ) 
     209        { 
     210            byte_t p_junk[3840]; 
     211 
     212            /* We've just started the stream, wait for the first PTS. */ 
     213            GetChunk( &p_dec->bit_stream, p_junk, i_frame_size - 7 ); 
     214            continue; 
     215        } 
     216 
     217        p_buffer = aout_BufferNew( p_dec->p_aout, p_dec->p_aout_input, 
     218                                   A52_FRAME_NB ); 
     219        if ( p_buffer == NULL ) return -1; 
     220        p_buffer->start_date = aout_DateGet( &end_date ); 
     221        p_buffer->end_date = aout_DateIncrement( &end_date, 
     222                                                 A52_FRAME_NB ); 
     223 
     224        /* Get the whole frame. */ 
     225        memcpy( p_buffer->p_buffer, p_header, 7 ); 
     226        GetChunk( &p_dec->bit_stream, p_buffer->p_buffer + 7, 
    220227                  i_frame_size - 7 ); 
    221228        if( p_dec->p_fifo->b_die ) break; 
    222229 
    223         if( DecodeFrame( p_dec, p_frame_buffer ) ) 
    224         { 
    225             p_dec->p_fifo->b_error = 1; 
    226             break; 
    227         } 
    228     } 
    229  
    230     /* If b_error is set, the decoder thread enters the error loop */ 
     230        /* Send the buffer to the mixer. */ 
     231        aout_BufferPlay( p_dec->p_aout, p_dec->p_aout_input, p_buffer ); 
     232    } 
     233 
     234    /* If b_error is set, the spdif thread enters the error loop */ 
    231235    if( p_dec->p_fifo->b_error ) 
    232236    { 
     
    234238    } 
    235239 
    236     /* End of the a52 decoder thread */ 
     240    /* End of the spdif decoder thread */ 
    237241    EndThread( p_dec ); 
    238  
     242     
    239243    return 0; 
    240244} 
    241245 
    242 /***************************************************************************** 
    243  * InitThread: initialize data before entering main loop 
    244  *****************************************************************************
    245 static int InitThread( a52_thread_t * p_dec, decoder_fifo_t * p_fifo ) 
     246/**************************************************************************** 
     247 * InitThread: initialize thread data and create output fifo 
     248 ****************************************************************************
     249static int InitThread( spdif_thread_t * p_dec, decoder_fifo_t * p_fifo ) 
    246250{ 
    247251    /* Initialize the thread properties */ 
     
    249253    p_dec->p_aout_input = NULL; 
    250254    p_dec->p_fifo = p_fifo; 
    251     p_dec->output_format.i_format = AOUT_FMT_FLOAT32; 
    252     p_dec->output_format.i_channels = 2; /* FIXME ! */ 
    253  
    254     /* Initialize liba52 */ 
    255     p_dec->p_a52_state = a52_init( 0 ); 
    256     if( p_dec->p_a52_state == NULL ) 
    257     { 
    258         msg_Err( p_dec->p_fifo, "unable to initialize liba52" ); 
    259         return -1; 
    260     } 
    261  
    262     p_dec->b_dynrng = config_GetInt( p_dec->p_fifo, "a52-dynrng" ); 
     255    p_dec->output_format.i_format = AOUT_FMT_A52; 
    263256 
    264257    /* Init the Bitstream */ 
     
    270263 
    271264/***************************************************************************** 
    272  * Interleave: helper function to interleave channels 
    273  *****************************************************************************/ 
    274 static void Interleave( float * p_out, const float * p_in, int i_channels ) 
    275 
    276     int i, j; 
    277  
    278     for ( j = 0; j < i_channels; j++ ) 
    279     { 
    280         for ( i = 0; i < 256; i++ ) 
    281         { 
    282             p_out[i * i_channels + j] = p_in[j * 256 + i]; 
    283         } 
    284     } 
    285 
    286  
    287 /***************************************************************************** 
    288  * DecodeFrame: decode an ATSC A/52 frame. 
    289  *****************************************************************************/ 
    290 static int DecodeFrame( a52_thread_t * p_dec, byte_t * p_frame_buffer ) 
    291 
    292     sample_t        i_sample_level = 1; 
    293     aout_buffer_t * p_buffer; 
    294     int             i, i_flags; 
    295     int             i_bytes_per_block = 256 * p_dec->output_format.i_channels 
    296                       * sizeof(float); 
    297  
    298     if( !aout_DateGet( &p_dec->end_date ) ) 
    299     { 
    300         /* We've just started the stream, wait for the first PTS. */ 
     265 * EndThread : spdif thread destruction 
     266 *****************************************************************************/ 
     267static void EndThread( spdif_thread_t * p_dec ) 
     268
     269    if ( p_dec->p_aout_input != NULL ) 
     270    { 
     271        aout_InputDelete( p_dec->p_aout, p_dec->p_aout_input ); 
     272    } 
     273 
     274    free( p_dec ); 
     275
     276 
     277/**************************************************************************** 
     278 * SyncInfo: parse A52 sync info 
     279 **************************************************************************** 
     280 * This code is borrowed from liba52 by Aaron Holtzman & Michel Lespinasse, 
     281 * since we don't want to oblige S/PDIF people to use liba52 just to get 
     282 * their SyncInfo... 
     283 ****************************************************************************/ 
     284int SyncInfo( const byte_t * p_buf, int * pi_channels, int * pi_sample_rate, 
     285              int * pi_bit_rate) 
     286
     287    static const u8 halfrate[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3}; 
     288    static const int rate[] = { 32,  40,  48,  56,  64,  80,  96, 112, 
     289                                128, 160, 192, 224, 256, 320, 384, 448, 
     290                                512, 576, 640}; 
     291    static const u8 lfeon[8] = {0x10, 0x10, 0x04, 0x04, 0x04, 0x01, 0x04, 0x01}; 
     292    int frmsizecod; 
     293    int bitrate; 
     294    int half; 
     295    int acmod; 
     296 
     297    if ((p_buf[0] != 0x0b) || (p_buf[1] != 0x77))        /* syncword */ 
    301298        return 0; 
    302     } 
    303  
    304     p_buffer = aout_BufferNew( p_dec->p_aout, p_dec->p_aout_input, 
    305                                A52_FRAME_NB ); 
    306     if ( p_buffer == NULL ) return -1; 
    307     p_buffer->start_date = aout_DateGet( &p_dec->end_date ); 
    308     p_buffer->end_date = aout_DateIncrement( &p_dec->end_date, 
    309                                              A52_FRAME_NB ); 
    310  
    311     /* FIXME */ 
    312     i_flags = A52_STEREO | A52_ADJUST_LEVEL; 
    313  
    314     /* Do the actual decoding now */ 
    315     a52_frame( p_dec->p_a52_state, p_frame_buffer, 
    316                &i_flags, &i_sample_level, 0 ); 
    317  
    318     if( !p_dec->b_dynrng ) 
    319     { 
    320         a52_dynrng( p_dec->p_a52_state, NULL, NULL ); 
    321     } 
    322  
    323     for ( i = 0; i < 6; i++ ) 
    324     { 
    325         sample_t * p_samples; 
    326  
    327         if( a52_block( p_dec->p_a52_state ) ) 
    328         { 
    329             msg_Warn( p_dec->p_fifo, "a52_block failed for block %i", i ); 
    330         } 
    331  
    332         p_samples = a52_samples( p_dec->p_a52_state ); 
    333  
    334         /* Interleave the *$�%�ples */ 
    335         Interleave( (float *)(p_buffer->p_buffer + i * i_bytes_per_block), 
    336                     p_samples, p_dec->output_format.i_channels ); 
    337     } 
    338  
    339     aout_BufferPlay( p_dec->p_aout, p_dec->p_aout_input, p_buffer ); 
    340  
    341     return 0; 
    342 
    343  
    344 /***************************************************************************** 
    345  * EndThread : liba52 decoder thread destruction 
    346  *****************************************************************************/ 
    347 static void EndThread( a52_thread_t * p_dec ) 
    348 
    349     if ( p_dec->p_aout_input != NULL ) 
    350     { 
    351         aout_InputDelete( p_dec->p_aout, p_dec->p_aout_input ); 
    352     } 
    353  
    354     a52_free( p_dec->p_a52_state ); 
    355     free( p_dec ); 
    356 
    357  
     299 
     300    if (p_buf[5] >= 0x60)                /* bsid >= 12 */ 
     301        return 0; 
     302    half = halfrate[p_buf[5] >> 3]; 
     303 
     304    /* acmod, dsurmod and lfeon */ 
     305    acmod = p_buf[6] >> 5; 
     306    if ( p_buf[6] & 0xf8 ) 
     307    { 
     308        *pi_channels = AOUT_CHAN_DOLBY; 
     309    } 
     310    else switch ( acmod ) 
     311    { 
     312    case 0x0: *pi_channels = AOUT_CHAN_CHANNEL; break; 
     313    case 0x1: *pi_channels = AOUT_CHAN_MONO; break; 
     314    case 0x2: *pi_channels = AOUT_CHAN_STEREO; break; 
     315    case 0x3: *pi_channels = AOUT_CHAN_3F; break; 
     316    case 0x4: *pi_channels = AOUT_CHAN_2F1R; break; 
     317    case 0x5: *pi_channels = AOUT_CHAN_3F1R; break; 
     318    case 0x6: *pi_channels = AOUT_CHAN_2F2R; break; 
     319    case 0x7: *pi_channels = AOUT_CHAN_3F2R; break; 
     320    case 0x8: *pi_channels = AOUT_CHAN_CHANNEL1; break; 
     321    case 0x9: *pi_channels = AOUT_CHAN_CHANNEL2; break; 
     322    } 
     323    
     324    if ( p_buf[6] & lfeon[acmod] ) *pi_channels |= AOUT_CHAN_LFE; 
     325 
     326    frmsizecod = p_buf[4] & 63; 
     327    if (frmsizecod >= 38) 
     328        return 0; 
     329    bitrate = rate [frmsizecod >> 1]; 
     330    *pi_bit_rate = (bitrate * 1000) >> half; 
     331 
     332    switch (p_buf[4] & 0xc0) { 
     333    case 0: 
     334        *pi_sample_rate = 48000 >> half; 
     335        return 4 * bitrate; 
     336    case 0x40: 
     337        *pi_sample_rate = 44100 >> half; 
     338        return 2 * (320 * bitrate / 147 + (frmsizecod & 1)); 
     339    case 0x80: 
     340        *pi_sample_rate = 32000 >> half; 
     341        return 6 * bitrate; 
     342    default: 
     343        return 0; 
     344    } 
     345
     346 
  • modules/gui/macosx/aout.m

    r0699631 r34c7196  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: aout.m,v 1.8 2002/08/30 23:27:06 massiot Exp $ 
     5 * $Id: aout.m,v 1.9 2002/09/02 23:17:05 massiot Exp $ 
    66 * 
    77 * Authors: Colin Delacroix <colin@zoy.org> 
     
    119119    } 
    120120 
    121     /* We only deal with floats */ 
    122     if ( p_aout->output.output.i_format != AOUT_FMT_FLOAT32 ) 
    123     { 
    124         msg_Err( p_aout, "cannot set format 0x%x", 
    125                  p_aout->output.output.i_format ); 
    126         return -1; 
    127     } 
     121    /* We only deal with floats. FIXME : this is where we should do S/PDIF. */ 
     122    p_aout->output.output.i_format = AOUT_FMT_FLOAT32; 
    128123 
    129124    /* Set sample rate and channels per frame */ 
    130125    p_aout->output.output.i_rate = p_sys->stream_format.mSampleRate; 
    131     p_aout->output.output.i_channels = p_sys->stream_format.mChannelsPerFrame; 
     126    /* FIXME : this is where we should ask for downmixing. */ 
     127    p_aout->output.output.i_channels = 2; //p_sys->stream_format.mChannelsPerFrame; 
    132128 
    133129    /* Get the buffer size that the device uses for IO */ 
  • po/Makefile.in.in

    rb7d33a0 r34c7196  
    33# 
    44# This file file be copied and used freely without restrictions.  It can 
    5 # be used in projects which are not available under the GNU General Public License 
     5# be used in projects which are not available under the GNU Public License 
    66# but which still want to provide support for the GNU gettext functionality. 
    77# Please note that the actual code is *not* freely available. 
  • src/audio_output/audio_output.c

    r0b88e77 r34c7196  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: audio_output.c,v 1.100 2002/08/30 22:22:24 massiot Exp $ 
     5 * $Id: audio_output.c,v 1.101 2002/09/02 23:17:06 massiot Exp $ 
    66 * 
    77 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    151151 
    152152/* 
    153  * Formats management (internal) 
     153 * Formats management 
    154154 */ 
     155 
     156/***************************************************************************** 
     157 * aout_FormatNbChannels : return the number of channels 
     158 *****************************************************************************/ 
     159int aout_FormatNbChannels( audio_sample_format_t * p_format ) 
     160{ 
     161    int i_nb; 
     162 
     163    switch ( p_format->i_channels & AOUT_CHAN_MASK ) 
     164    { 
     165    case AOUT_CHAN_CHANNEL1: 
     166    case AOUT_CHAN_CHANNEL2: 
     167    case AOUT_CHAN_MONO: 
     168        i_nb = 1; 
     169        break; 
     170 
     171    case AOUT_CHAN_CHANNEL: 
     172    case AOUT_CHAN_STEREO: 
     173    case AOUT_CHAN_DOLBY: 
     174        i_nb = 2; 
     175        break; 
     176 
     177    case AOUT_CHAN_3F: 
     178    case AOUT_CHAN_2F1R: 
     179        i_nb = 3; 
     180        break; 
     181 
     182    case AOUT_CHAN_3F1R: 
     183    case AOUT_CHAN_2F2R: 
     184        i_nb = 4; 
     185        break; 
     186 
     187    case AOUT_CHAN_3F2R: 
     188        i_nb = 5; 
     189        break; 
     190 
     191    default: 
     192        i_nb = 0; 
     193    } 
     194 
     195    if ( p_format->i_channels & AOUT_CHAN_LFE ) 
     196        return i_nb + 1; 
     197    else 
     198        return i_nb; 
     199} 
    155200 
    156201