Changeset 34c71967f9b0e4533ba8343062282029f39e7089
- Timestamp:
- 03/09/02 01:17:06 (6 years ago)
- git-parent:
- Files:
-
- Makefile.opts.in (modified) (2 diffs)
- configure.in (modified) (5 diffs)
- include/aout_internal.h (modified) (2 diffs)
- include/audio_output.h (modified) (2 diffs)
- include/vlc_symbols.h (modified) (2 diffs)
- include/vlc_threads.h (modified) (2 diffs)
- modules/audio_filter/converter/Makefile (modified) (1 diff)
- modules/audio_filter/converter/a52tofloat32.c (added)
- modules/audio_filter/converter/a52tospdif.c (modified) (3 diffs)
- modules/audio_output/oss.c (modified) (2 diffs)
- modules/audio_output/sdl.c (modified) (3 diffs)
- modules/codec/Makefile (modified) (1 diff)
- modules/codec/a52.c (modified) (16 diffs)
- modules/codec/spdif.c (deleted)
- modules/gui/macosx/aout.m (modified) (2 diffs)
- po/Makefile.in.in (modified) (1 diff)
- src/audio_output/audio_output.c (modified) (3 diffs)
- src/audio_output/filters.c (modified) (6 diffs)
- src/misc/modules_plugin.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Makefile.opts.in
r6038883 r34c7196 59 59 mozilla_CFLAGS = @mozilla_CFLAGS@ 60 60 61 a52 _CFLAGS = @a52_CFLAGS@61 a52tofloat32_CFLAGS = @a52tofloat32_CFLAGS@ 62 62 arts_CFLAGS = @arts_CFLAGS@ 63 63 i420_yuy2_mmx_CFLAGS = @i420_yuy2_mmx_CFLAGS@ … … 95 95 mozilla_LDFLAGS = @mozilla_LDFLAGS@ 96 96 97 a52 _LDFLAGS = @a52_LDFLAGS@97 a52tofloat32_LDFLAGS = @a52tofloat32_LDFLAGS@ 98 98 aa_LDFLAGS = @aa_LDFLAGS@ 99 99 alsa_LDFLAGS = @alsa_LDFLAGS@ configure.in
r16f2ff8 r34c7196 447 447 PLUGINS="${PLUGINS} control/rc/rc misc/logger/logger access/file misc/memcpy/memcpy" 448 448 PLUGINS="${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 "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/mpeg_audio/mpeg_audio" 450 PLUGINS="${PLUGINS} codec/a52old/imdct/imdct codec/a52old/downmix/downmix codec/a52old/a52old codec/a52" 451 451 #PLUGINS="${PLUGINS} codec/lpcm/lpcm" 452 452 PLUGINS="${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" … … 1186 1186 then 1187 1187 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}" 1191 1191 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" 1195 1195 ],[ 1196 1196 if test -f ${real_a52_tree}/liba52/.libs/liba52.a 1197 1197 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]) 1199 1199 else 1200 1200 AC_MSG_ERROR([the specified tree hasn't been compiled]) … … 1221 1221 AC_CHECK_HEADERS(a52dec/a52.h, [ 1222 1222 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}" 1226 1226 ],[ 1227 1227 if test "x${enable_dvbpsi}" != "x" … … 2082 2082 AC_SUBST(mozilla_CFLAGS) 2083 2083 2084 AC_SUBST(a52 _CFLAGS)2084 AC_SUBST(a52tofloat32_CFLAGS) 2085 2085 AC_SUBST(arts_CFLAGS) 2086 2086 AC_SUBST(i420_yuy2_mmx_CFLAGS) … … 2116 2116 AC_SUBST(mozilla_LDFLAGS) 2117 2117 2118 AC_SUBST(a52 _LDFLAGS)2118 AC_SUBST(a52tofloat32_LDFLAGS) 2119 2119 AC_SUBST(aa_LDFLAGS) 2120 2120 AC_SUBST(alsa_LDFLAGS) include/aout_internal.h
r0699631 r34c7196 3 3 ***************************************************************************** 4 4 * Copyright (C) 2002 VideoLAN 5 * $Id: aout_internal.h,v 1.1 4 2002/08/30 23:27:05 massiot Exp $5 * $Id: aout_internal.h,v 1.15 2002/09/02 23:17:05 massiot Exp $ 6 6 * 7 7 * Authors: Christophe Massiot <massiot@via.ecp.fr> … … 227 227 VLC_EXPORT( aout_buffer_t *, aout_OutputNextBuffer, ( aout_instance_t *, mtime_t, vlc_bool_t ) ); 228 228 229 VLC_EXPORT( int, aout_FormatNbChannels, ( audio_sample_format_t * p_format ) ); 229 230 void aout_FormatPrepare( audio_sample_format_t * p_format ); 230 231 void aout_FifoInit( aout_instance_t *, aout_fifo_t *, u32 ); include/audio_output.h
r1c13a98 r34c7196 3 3 ***************************************************************************** 4 4 * Copyright (C) 2002 VideoLAN 5 * $Id: audio_output.h,v 1.6 1 2002/08/21 22:41:59massiot Exp $5 * $Id: audio_output.h,v 1.62 2002/09/02 23:17:05 massiot Exp $ 6 6 * 7 7 * Authors: Christophe Massiot <massiot@via.ecp.fr> … … 108 108 109 109 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 110 139 /***************************************************************************** 111 140 * aout_buffer_t : audio output buffer include/vlc_symbols.h
r7d2f6de r34c7196 38 38 int (* __vlc_threads_end_inner) ( vlc_object_t * ) ; 39 39 int (* __vlc_threads_init_inner) ( vlc_object_t * ) ; 40 int (* aout_FormatNbChannels_inner) ( audio_sample_format_t * p_format ) ; 40 41 int (* input_AccessInit_inner) ( input_thread_t * ) ; 41 42 int (* input_AddInfo_inner) ( input_info_category_t *, char *, char *, ... ) ; … … 225 226 # define aout_DeleteInstance p_symbols->aout_DeleteInstance_inner 226 227 # define aout_FifoPop p_symbols->aout_FifoPop_inner 228 # define aout_FormatNbChannels p_symbols->aout_FormatNbChannels_inner 227 229 # define aout_InputDelete p_symbols->aout_InputDelete_inner 228 230 # define aout_OutputNextBuffer p_symbols->aout_OutputNextBuffer_inner include/vlc_threads.h
r1e666bc r34c7196 4 4 ***************************************************************************** 5 5 * Copyright (C) 1999, 2002 VideoLAN 6 * $Id: vlc_threads.h,v 1.1 2 2002/09/01 21:20:29massiot Exp $6 * $Id: vlc_threads.h,v 1.13 2002/09/02 23:17:05 massiot Exp $ 7 7 * 8 8 * Authors: Jean-Marc Dressler <polux@via.ecp.fr> … … 72 72 # define VLC_THREAD_PRIORITY_INPUT 37 73 73 # define VLC_THREAD_PRIORITY_AUDIO 38 74 # define VLC_THREAD_PRIORITY_VIDEO 3 674 # define VLC_THREAD_PRIORITY_VIDEO 31 75 75 # define VLC_THREAD_PRIORITY_OUTPUT 38 76 76 modules/audio_filter/converter/Makefile
rafa6c92 r34c7196 4 4 float32tou8_SOURCES = float32tou8.c 5 5 a52tospdif_SOURCES = a52tospdif.c 6 a52tofloat32_SOURCES = a52tofloat32.c 6 7 fixed32tos16_SOURCES = fixed32tos16.c 7 8 fixed32tofloat32_SOURCES = fixed32tofloat32.c modules/audio_filter/converter/a52tospdif.c
r15f3b0f r34c7196 3 3 ***************************************************************************** 4 4 * Copyright (C) 2002 VideoLAN 5 * $Id: a52tospdif.c,v 1.1 0 2002/08/26 23:00:22massiot Exp $5 * $Id: a52tospdif.c,v 1.11 2002/09/02 23:17:05 massiot Exp $ 6 6 * 7 7 * Authors: Christophe Massiot <massiot@via.ecp.fr> … … 43 43 *****************************************************************************/ 44 44 static int Create ( vlc_object_t * ); 45 46 45 static void DoWork ( aout_instance_t *, aout_filter_t *, aout_buffer_t *, 47 46 aout_buffer_t * ); … … 57 56 58 57 /***************************************************************************** 59 * Create: allocate trivial mixer 60 ***************************************************************************** 61 * This function allocates and initializes a Crop vout method. 58 * Create: 62 59 *****************************************************************************/ 63 60 static int Create( vlc_object_t *p_this ) modules/audio_output/oss.c
r13f4593 r34c7196 3 3 ***************************************************************************** 4 4 * Copyright (C) 2000-2002 VideoLAN 5 * $Id: oss.c,v 1.2 2 2002/08/31 22:10:25 stefExp $5 * $Id: oss.c,v 1.23 2002/09/02 23:17:05 massiot Exp $ 6 6 * 7 7 * Authors: Michel Kaempf <maxx@via.ecp.fr> … … 175 175 || i_format != p_aout->output.output.i_format ) 176 176 { 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 } 179 196 } 180 197 modules/audio_output/sdl.c
r4d51273 r34c7196 3 3 ***************************************************************************** 4 4 * Copyright (C) 2000-2002 VideoLAN 5 * $Id: sdl.c,v 1.1 0 2002/08/31 19:58:04 stefExp $5 * $Id: sdl.c,v 1.11 2002/09/02 23:17:05 massiot Exp $ 6 6 * 7 7 * Authors: Michel Kaempf <maxx@via.ecp.fr> … … 104 104 } 105 105 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 106 111 /* TODO: finish and clean this */ 107 112 … … 118 123 return VLC_EGENERIC; 119 124 } 120 121 p_aout->output.output.i_format = AOUT_FMT_S16_NE;122 p_aout->output.i_nb_samples = FRAME_SIZE;123 125 124 126 SDL_PauseAudio( 0 ); modules/codec/Makefile
r9a9f8a1 r34c7196 1 1 a52_SOURCES = a52.c 2 spdif_SOURCES = spdif.cmodules/codec/a52.c
r0b88e77 r34c7196 1 1 /***************************************************************************** 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 5 3 ***************************************************************************** 6 * Copyright (C) 2001 ,2002 VideoLAN7 * $Id: a52.c,v 1. 8 2002/08/30 22:22:24massiot Exp $4 * Copyright (C) 2001-2002 VideoLAN 5 * $Id: a52.c,v 1.9 2002/09/02 23:17:05 massiot Exp $ 8 6 * 9 * Authors: Gildas Bazin <gbazin@netcourrier.com>7 * Authors: St�ane Borel <stef@via.ecp.fr> 10 8 * Christophe Massiot <massiot@via.ecp.fr> 11 * 9 * Michel Lespinasse <walken@zoy.org> 10 * Aaron Holtzman <aholtzma@ess.engr.uvic.ca> 11 * 12 12 * This program is free software; you can redistribute it and/or modify 13 13 * it under the terms of the GNU General Public License as published by … … 28 28 * Preamble 29 29 *****************************************************************************/ 30 #include <stdio.h> 31 #include <stdlib.h> 32 #include <string.h> /* memcpy() */ 33 #include <fcntl.h> 34 30 35 #include <vlc/vlc.h> 36 #include <vlc/decoder.h> 31 37 #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_H37 # include <stdint.h> /* int16_t .. */38 #elif HAVE_INTTYPES_H39 # include <inttypes.h> /* int16_t .. */40 #endif41 38 42 39 #ifdef HAVE_UNISTD_H … … 44 41 #endif 45 42 46 #ifdef USE_A52DEC_TREE /* liba52 header file */47 # include "include/a52.h"48 #else49 # include "a52dec/a52.h"50 #endif51 52 43 #define A52_FRAME_NB 1536 53 44 54 45 /***************************************************************************** 55 * a52_thread_t : a52 decoderthread descriptor56 *****************************************************************************/ 57 typedef struct a52_thread_s46 * spdif_thread_t : A52 pass-through thread descriptor 47 *****************************************************************************/ 48 typedef struct spdif_thread_s 58 49 { 59 50 /* 60 * liba52properties51 * Thread properties 61 52 */ 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 */ 67 54 68 55 /* … … 70 57 */ 71 58 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; 73 62 74 63 /* … … 78 67 aout_input_t * p_aout_input; /* opaque */ 79 68 audio_sample_format_t output_format; 80 audio_date_t end_date; 81 } a52_thread_t; 82 83 /***************************************************************************** 69 } spdif_thread_t; 70 71 /**************************************************************************** 84 72 * Local prototypes 85 **************************************************************************** */73 ****************************************************************************/ 86 74 static int OpenDecoder ( vlc_object_t * ); 87 75 static 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 77 static int InitThread ( spdif_thread_t *, decoder_fifo_t * ); 78 static void EndThread ( spdif_thread_t * ); 79 80 static int SyncInfo ( const byte_t *, int *, int *, int * ); 91 81 92 82 /***************************************************************************** 93 83 * Module descriptor 94 84 *****************************************************************************/ 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 103 85 vlc_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 ); 108 88 set_callbacks( OpenDecoder, NULL ); 89 add_shortcut( "pass_through" ); 90 add_shortcut( "pass" ); 109 91 vlc_module_end(); 110 92 … … 112 94 * OpenDecoder: probe the decoder and return score 113 95 ***************************************************************************** 114 * Tries to launch a decoder and return score so that the interface is able 115 * to cho ose.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 *****************************************************************************/ 99 static int OpenDecoder( vlc_object_t *p_this ) 100 { 119 101 decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this; 120 102 121 103 if( p_fifo->i_fourcc != VLC_FOURCC('a','5','2',' ') 122 104 && p_fifo->i_fourcc != VLC_FOURCC('a','5','2','b') ) 123 105 { 124 return VLC_EGENERIC; 106 return VLC_EGENERIC; 125 107 } 126 108 … … 129 111 } 130 112 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 ****************************************************************************/ 134 118 static int RunDecoder( decoder_fifo_t *p_fifo ) 135 119 { 136 a52_thread_t *p_dec; 137 120 spdif_thread_t * p_dec; 121 audio_date_t end_date; 122 138 123 /* 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) ); 140 125 if( p_dec == NULL ) 141 126 { … … 144 129 return -1; 145 130 } 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" ); 150 136 DecoderError( p_fifo ); 151 137 free( p_dec ); … … 153 139 } 154 140 155 /* liba52decoder 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; 159 145 mtime_t pts; 160 146 /* 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; 162 149 163 150 /* Look for sync word - should be 0x0b77 */ 164 151 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)) 167 154 { 168 155 RemoveBits( &p_dec->bit_stream, 8 ); … … 171 158 /* Set the Presentation Time Stamp */ 172 159 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 ); 176 163 } 177 164 178 165 /* Get A/52 frame header */ 179 GetChunk( &p_dec->bit_stream, p_ frame_buffer, 7 );166 GetChunk( &p_dec->bit_stream, p_header, 7 ); 180 167 if( p_dec->p_fifo->b_die ) break; 181 168 182 169 /* 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 ); 185 172 186 173 if( !i_frame_size ) … … 192 179 if( (p_dec->p_aout_input != NULL) && 193 180 ( (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) ) ) 195 183 { 196 184 /* Parameters changed - this should not happen. */ … … 203 191 { 204 192 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 ); 207 197 p_dec->p_aout_input = aout_InputNew( p_dec->p_fifo, 208 198 &p_dec->p_aout, … … 216 206 } 217 207 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, 220 227 i_frame_size - 7 ); 221 228 if( p_dec->p_fifo->b_die ) break; 222 229 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 */ 231 235 if( p_dec->p_fifo->b_error ) 232 236 { … … 234 238 } 235 239 236 /* End of the a52decoder thread */240 /* End of the spdif decoder thread */ 237 241 EndThread( p_dec ); 238 242 239 243 return 0; 240 244 } 241 245 242 /**************************************************************************** *243 * InitThread: initialize data before entering main loop244 **************************************************************************** */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 ****************************************************************************/ 249 static int InitThread( spdif_thread_t * p_dec, decoder_fifo_t * p_fifo ) 246 250 { 247 251 /* Initialize the thread properties */ … … 249 253 p_dec->p_aout_input = NULL; 250 254 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; 263 256 264 257 /* Init the Bitstream */ … … 270 263 271 264 /***************************************************************************** 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 *****************************************************************************/ 267 static 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 ****************************************************************************/ 284 int 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 */ 301 298 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 3 3 ***************************************************************************** 4 4 * Copyright (C) 2002 VideoLAN 5 * $Id: aout.m,v 1. 8 2002/08/30 23:27:06massiot Exp $5 * $Id: aout.m,v 1.9 2002/09/02 23:17:05 massiot Exp $ 6 6 * 7 7 * Authors: Colin Delacroix <colin@zoy.org> … … 119 119 } 120 120 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; 128 123 129 124 /* Set sample rate and channels per frame */ 130 125 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; 132 128 133 129 /* Get the buffer size that the device uses for IO */ po/Makefile.in.in
rb7d33a0 r34c7196 3 3 # 4 4 # This file file be copied and used freely without restrictions. It can 5 # be used in projects which are not available under the GNU GeneralPublic License5 # be used in projects which are not available under the GNU Public License 6 6 # but which still want to provide support for the GNU gettext functionality. 7 7 # Please note that the actual code is *not* freely available. src/audio_output/audio_output.c
r0b88e77 r34c7196 3 3 ***************************************************************************** 4 4 * Copyright (C) 2002 VideoLAN 5 * $Id: audio_output.c,v 1.10 0 2002/08/30 22:22:24massiot Exp $5 * $Id: audio_output.c,v 1.101 2002/09/02 23:17:06 massiot Exp $ 6 6 * 7 7 * Authors: Christophe Massiot <massiot@via.ecp.fr> … … 151 151 152 152 /* 153 * Formats management (internal)153 * Formats management 154 154 */ 155 156 /***************************************************************************** 157 * aout_FormatNbChannels : return the number of channels 158 *****************************************************************************/ 159 int 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 } 155 200 156 201
