Commit 34c71967 authored by Christophe Massiot's avatar Christophe Massiot

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.
parent 1e666bc2
......@@ -58,7 +58,7 @@ plugins_CFLAGS = @plugins_CFLAGS@
builtins_CFLAGS = @builtins_CFLAGS@
mozilla_CFLAGS = @mozilla_CFLAGS@
a52_CFLAGS = @a52_CFLAGS@
a52tofloat32_CFLAGS = @a52tofloat32_CFLAGS@
arts_CFLAGS = @arts_CFLAGS@
i420_yuy2_mmx_CFLAGS = @i420_yuy2_mmx_CFLAGS@
directx_CFLAGS = @directx_CFLAGS@
......@@ -94,7 +94,7 @@ plugins_LDFLAGS = @plugins_LDFLAGS@
builtins_LDFLAGS = @builtins_LDFLAGS@
mozilla_LDFLAGS = @mozilla_LDFLAGS@
a52_LDFLAGS = @a52_LDFLAGS@
a52tofloat32_LDFLAGS = @a52tofloat32_LDFLAGS@
aa_LDFLAGS = @aa_LDFLAGS@
alsa_LDFLAGS = @alsa_LDFLAGS@
arts_LDFLAGS = @arts_LDFLAGS@
......
......@@ -446,8 +446,8 @@ BUILTINS="${BUILTINS}"
PLUGINS="${PLUGINS} misc/dummy/dummy misc/null"
PLUGINS="${PLUGINS} control/rc/rc misc/logger/logger access/file misc/memcpy/memcpy"
PLUGINS="${PLUGINS} demux/mpeg/es demux/mpeg/audio demux/mpeg/mpeg_system demux/mpeg/ps demux/mpeg/ts demux/a52sys"
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"
PLUGINS="${PLUGINS} codec/a52old/imdct/imdct codec/a52old/downmix/downmix codec/a52old/a52old"
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"
PLUGINS="${PLUGINS} codec/a52old/imdct/imdct codec/a52old/downmix/downmix codec/a52old/a52old codec/a52"
#PLUGINS="${PLUGINS} codec/lpcm/lpcm"
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"
PLUGINS="${PLUGINS} audio_filter/converter/float32tos16 audio_filter/converter/float32tos8 audio_filter/converter/float32tou16 audio_filter/converter/float32tou8 audio_filter/converter/a52tospdif audio_filter/converter/fixed32tofloat32 audio_filter/converter/fixed32tos16 audio_filter/converter/s16tofloat32"
......@@ -1185,17 +1185,17 @@ then
if test -f ${real_a52_tree}/include/a52.h
then
AC_MSG_RESULT(yes)
a52_CFLAGS="${a52_CFLAGS} -I${real_a52_tree}"
a52_LDFLAGS="${a52_LDFLAGS} -L${real_a52_tree}/liba52/.libs"
LDFLAGS="${save_LDFLAGS} ${a52_LDFLAGS}"
a52tofloat32_CFLAGS="${a52tofloat32_CFLAGS} -I${real_a52_tree}"
a52tofloat32_LDFLAGS="${a52tofloat32_LDFLAGS} -L${real_a52_tree}/liba52/.libs"
LDFLAGS="${save_LDFLAGS} ${a52tofloat32_LDFLAGS}"
AC_CHECK_LIB(a52, a52_free, [
BUILTINS="${BUILTINS} codec/a52"
a52_LDFLAGS="${a52_LDFLAGS} -la52 -lm"
a52_CFLAGS="${a52_CFLAGS} -DUSE_A52DEC_TREE"
BUILTINS="${BUILTINS} audio_filter/converter/a52tofloat32"
a52tofloat32_LDFLAGS="${a52tofloat32_LDFLAGS} -la52 -lm"
a52tofloat32_CFLAGS="${a52tofloat32_CFLAGS} -DUSE_A52DEC_TREE"
],[
if test -f ${real_a52_tree}/liba52/.libs/liba52.a
then
AC_MSG_ERROR([make sure you have at least a52dec-0.7.3])
AC_MSG_ERROR([make sure you have at least a52dec-0.7.4])
else
AC_MSG_ERROR([the specified tree hasn't been compiled])
fi
......@@ -1220,9 +1220,9 @@ then
LDFLAGS="${save_LDFLAGS} ${test_LDFLAGS}"
AC_CHECK_HEADERS(a52dec/a52.h, [
AC_CHECK_LIB(a52, a52_free, [
BUILTINS="${BUILTINS} codec/a52"
a52_LDFLAGS="${a52_LDFLAGS} ${test_LDFLAGS} -la52 -lm"
a52_CFLAGS="${a52_CFLAGS} ${test_CFLAGS}"
BUILTINS="${BUILTINS} audio_filter/converter/a52tofloat32"
a52tofloat32_LDFLAGS="${a52tofloat32_LDFLAGS} ${test_LDFLAGS} -la52 -lm"
a52tofloat32_CFLAGS="${a52tofloat32_CFLAGS} ${test_CFLAGS}"
],[
if test "x${enable_dvbpsi}" != "x"
then
......@@ -2081,7 +2081,7 @@ AC_SUBST(plugins_CFLAGS)
AC_SUBST(builtins_CFLAGS)
AC_SUBST(mozilla_CFLAGS)
AC_SUBST(a52_CFLAGS)
AC_SUBST(a52tofloat32_CFLAGS)
AC_SUBST(arts_CFLAGS)
AC_SUBST(i420_yuy2_mmx_CFLAGS)
AC_SUBST(dvd_CFLAGS)
......@@ -2115,7 +2115,7 @@ AC_SUBST(plugins_LDFLAGS)
AC_SUBST(builtins_LDFLAGS)
AC_SUBST(mozilla_LDFLAGS)
AC_SUBST(a52_LDFLAGS)
AC_SUBST(a52tofloat32_LDFLAGS)
AC_SUBST(aa_LDFLAGS)
AC_SUBST(alsa_LDFLAGS)
AC_SUBST(arts_LDFLAGS)
......
......@@ -2,7 +2,7 @@
* aout_internal.h : internal defines for audio output
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: aout_internal.h,v 1.14 2002/08/30 23:27:05 massiot Exp $
* $Id: aout_internal.h,v 1.15 2002/09/02 23:17:05 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -226,6 +226,7 @@ void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer );
void aout_OutputDelete( aout_instance_t * p_aout );
VLC_EXPORT( aout_buffer_t *, aout_OutputNextBuffer, ( aout_instance_t *, mtime_t, vlc_bool_t ) );
VLC_EXPORT( int, aout_FormatNbChannels, ( audio_sample_format_t * p_format ) );
void aout_FormatPrepare( audio_sample_format_t * p_format );
void aout_FifoInit( aout_instance_t *, aout_fifo_t *, u32 );
mtime_t aout_FifoNextStart( aout_instance_t *, aout_fifo_t * );
......
......@@ -2,7 +2,7 @@
* audio_output.h : audio output interface
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: audio_output.h,v 1.61 2002/08/21 22:41:59 massiot Exp $
* $Id: audio_output.h,v 1.62 2002/09/02 23:17:05 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -107,6 +107,35 @@ typedef s32 vlc_fixed_t;
#define FIXED32_ONE ((vlc_fixed_t) 0x10000000)
/* Dual mono. Two independant mono channels */
#define AOUT_CHAN_CHANNEL 0x0000000B
#define AOUT_CHAN_MONO 0x00000001
#define AOUT_CHAN_STEREO 0x00000002
/* 3 front channels (left, center, right) */
#define AOUT_CHAN_3F 0x00000003
/* 2 front, 1 rear surround channels (L, R, S) */
#define AOUT_CHAN_2F1R 0x00000004
/* 3 front, 1 rear surround channels (L, C, R, S) */
#define AOUT_CHAN_3F1R 0x00000005
/* 2 front, 2 rear surround channels (L, R, LS, RS) */
#define AOUT_CHAN_2F2R 0x00000006
/* 3 front, 2 rear surround channels (L, C, R, LS, RS) */
#define AOUT_CHAN_3F2R 0x00000007
/* First of two mono channels */
#define AOUT_CHAN_CHANNEL1 0x00000008
/* Second of two mono channels */
#define AOUT_CHAN_CHANNEL2 0x00000009
/* Dolby surround compatible stereo */
#define AOUT_CHAN_DOLBY 0x0000000A
#define AOUT_CHAN_MASK 0x0000000F
/* Low frequency effects channel. Normally used to connect a subwoofer.
* Can be combined with any of the above channels. For example :
* AOUT_CHAN_3F2R | AOUT_CHAN_LFE -> 3 front, 2 rear, 1 LFE (5.1) */
#define AOUT_CHAN_LFE 0x00000010
/*****************************************************************************
* aout_buffer_t : audio output buffer
*****************************************************************************/
......
......@@ -37,6 +37,7 @@ struct module_symbols_t
int (* __vlc_thread_create_inner) ( vlc_object_t *, char *, int, char *, void * ( * ) ( void * ), int, vlc_bool_t ) ;
int (* __vlc_threads_end_inner) ( vlc_object_t * ) ;
int (* __vlc_threads_init_inner) ( vlc_object_t * ) ;
int (* aout_FormatNbChannels_inner) ( audio_sample_format_t * p_format ) ;
int (* input_AccessInit_inner) ( input_thread_t * ) ;
int (* input_AddInfo_inner) ( input_info_category_t *, char *, char *, ... ) ;
int (* input_ChangeArea_inner) ( input_thread_t *, input_area_t * ) ;
......@@ -224,6 +225,7 @@ struct module_symbols_t
# define aout_DateSet p_symbols->aout_DateSet_inner
# define aout_DeleteInstance p_symbols->aout_DeleteInstance_inner
# define aout_FifoPop p_symbols->aout_FifoPop_inner
# define aout_FormatNbChannels p_symbols->aout_FormatNbChannels_inner
# define aout_InputDelete p_symbols->aout_InputDelete_inner
# define aout_OutputNextBuffer p_symbols->aout_OutputNextBuffer_inner
# define config_Duplicate p_symbols->config_Duplicate_inner
......
......@@ -3,7 +3,7 @@
* This header provides portable declarations for mutexes & conditions
*****************************************************************************
* Copyright (C) 1999, 2002 VideoLAN
* $Id: vlc_threads.h,v 1.12 2002/09/01 21:20:29 massiot Exp $
* $Id: vlc_threads.h,v 1.13 2002/09/02 23:17:05 massiot Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr>
......@@ -71,7 +71,7 @@
# define VLC_THREAD_PRIORITY_LOW 0
# define VLC_THREAD_PRIORITY_INPUT 37
# define VLC_THREAD_PRIORITY_AUDIO 38
# define VLC_THREAD_PRIORITY_VIDEO 36
# define VLC_THREAD_PRIORITY_VIDEO 31
# define VLC_THREAD_PRIORITY_OUTPUT 38
#elif defined(WIN32)
......
......@@ -3,6 +3,7 @@ float32tos8_SOURCES = float32tos8.c
float32tou16_SOURCES = float32tou16.c
float32tou8_SOURCES = float32tou8.c
a52tospdif_SOURCES = a52tospdif.c
a52tofloat32_SOURCES = a52tofloat32.c
fixed32tos16_SOURCES = fixed32tos16.c
fixed32tofloat32_SOURCES = fixed32tofloat32.c
s16tofloat32_SOURCES = s16tofloat32.c
/*****************************************************************************
* a52tofloat32.c: ATSC A/52 aka AC-3 decoder plugin for VLC.
* This plugin makes use of liba52 to decode A/52 audio
* (http://liba52.sf.net/).
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: a52tofloat32.c,v 1.1 2002/09/02 23:17:05 massiot Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
* Christophe Massiot <massiot@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <vlc/vlc.h>
#include <stdlib.h> /* malloc(), free() */
#include <string.h> /* strdup() */
#ifdef HAVE_STDINT_H
# include <stdint.h> /* int16_t .. */
#elif HAVE_INTTYPES_H
# include <inttypes.h> /* int16_t .. */
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef USE_A52DEC_TREE /* liba52 header file */
# include "include/a52.h"
#else
# include "a52dec/a52.h"
#endif
#include "audio_output.h"
#include "aout_internal.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int Create ( vlc_object_t * );
static void Destroy ( vlc_object_t * );
static void DoWork ( aout_instance_t *, aout_filter_t *, aout_buffer_t *,
aout_buffer_t * );
/*****************************************************************************
* Local structures
*****************************************************************************/
struct aout_filter_sys_t
{
a52_state_t * p_liba52; /* liba52 internal structure */
vlc_bool_t b_dynrng; /* see below */
int i_flags; /* liba52 flags, see a52dec/doc/liba52.txt */
int i_nb_channels; /* number of float32 per sample */
};
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define DYNRNG_TEXT N_("A/52 dynamic range compression")
#define DYNRNG_LONGTEXT N_( \
"Dynamic range compression makes the loud sounds softer, and the soft " \
"sounds louder, so you can more easily listen to the stream in a noisy " \
"environment without disturbing anyone. If you disable the dynamic range "\
"compression the playback will be more adapted to a movie theater or a " \
"listening room.")
vlc_module_begin();
add_category_hint( N_("Miscellaneous"), NULL );
add_bool( "a52-dynrng", 1, NULL, DYNRNG_TEXT, DYNRNG_LONGTEXT );
set_description( _("ATSC A/52 aka AC-3 audio decoder module") );
set_capability( "audio filter", 100 );
set_callbacks( Create, Destroy );
vlc_module_end();
/*****************************************************************************
* Create:
*****************************************************************************/
static int Create( vlc_object_t * _p_filter )
{
aout_filter_t * p_filter = (aout_filter_t *)_p_filter;
struct aout_filter_sys_t * p_sys;
if ( p_filter->input.i_format != AOUT_FMT_A52
|| p_filter->output.i_format != AOUT_FMT_FLOAT32 )
{
return -1;
}
if ( p_filter->input.i_rate != p_filter->output.i_rate )
{
return -1;
}
/* Allocate the memory needed to store the module's structure */
p_sys = p_filter->p_sys = malloc( sizeof(struct aout_filter_sys_t) );
if( p_sys == NULL )
{
msg_Err( p_filter, "out of memory" );
return -1;
}
p_sys->b_dynrng = config_GetInt( p_filter, "a52-dynrng" );
/* We'll do our own downmixing, thanks. */
p_sys->i_nb_channels = aout_FormatNbChannels( &p_filter->output );
switch ( p_filter->output.i_channels & AOUT_CHAN_MASK )
{
case AOUT_CHAN_CHANNEL: p_sys->i_flags = A52_CHANNEL; break;
case AOUT_CHAN_CHANNEL1: p_sys->i_flags = A52_CHANNEL1; break;
case AOUT_CHAN_CHANNEL2: p_sys->i_flags = A52_CHANNEL2; break;
case AOUT_CHAN_MONO: p_sys->i_flags = A52_MONO; break;
case AOUT_CHAN_STEREO: p_sys->i_flags = A52_STEREO; break;
case AOUT_CHAN_DOLBY: p_sys->i_flags = A52_DOLBY; break;
case AOUT_CHAN_3F: p_sys->i_flags = A52_3F; break;
case AOUT_CHAN_2F1R: p_sys->i_flags = A52_2F1R; break;
case AOUT_CHAN_3F1R: p_sys->i_flags = A52_3F1R; break;
case AOUT_CHAN_2F2R: p_sys->i_flags = A52_2F2R; break;
case AOUT_CHAN_3F2R: p_sys->i_flags = A52_3F2R; break;
default:
msg_Err( p_filter, "unknow sample format !" );
free( p_sys );
return -1;
}
if ( p_filter->output.i_channels & AOUT_CHAN_LFE )
{
p_sys->i_flags |= A52_LFE;
}
p_sys->i_flags |= A52_ADJUST_LEVEL;
/* Initialize liba52 */
p_sys->p_liba52 = a52_init( 0 );
if( p_sys->p_liba52 == NULL )
{
msg_Err( p_filter, "unable to initialize liba52" );
return -1;
}
p_filter->pf_do_work = DoWork;
p_filter->b_in_place = 0;
return 0;
}
/*****************************************************************************
* Interleave: helper function to interleave channels
*****************************************************************************/
static void Interleave( float * p_out, const float * p_in, int i_channels )
{
int i, j;
for ( j = 0; j < i_channels; j++ )
{
for ( i = 0; i < 256; i++ )
{
p_out[i * i_channels + j] = p_in[j * 256 + i];
}
}
}
/*****************************************************************************
* DoWork: decode an ATSC A/52 frame.
*****************************************************************************/
static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
aout_buffer_t * p_in_buf, aout_buffer_t * p_out_buf )
{
struct aout_filter_sys_t * p_sys = p_filter->p_sys;
sample_t i_sample_level = 1;
int i_flags = p_sys->i_flags;
int i_bytes_per_block = 256 * p_sys->i_nb_channels
* sizeof(float);
int i;
/* Do the actual decoding now. */
a52_frame( p_sys->p_liba52, p_in_buf->p_buffer,
&i_flags, &i_sample_level, 0 );
if ( i_flags != p_sys->i_flags )
{
msg_Err( p_filter,
"liba52 couldn't do the requested downmix 0x%x->0x%x",
p_sys->i_flags, i_flags );
memset( p_out_buf->p_buffer, 0, i_bytes_per_block * 6 );
return;
}
if( !p_sys->b_dynrng )
{
a52_dynrng( p_filter->p_sys->p_liba52, NULL, NULL );
}
for ( i = 0; i < 6; i++ )
{
sample_t * p_samples;
if( a52_block( p_sys->p_liba52 ) )
{
msg_Warn( p_filter, "a52_block failed for block %d", i );
}
p_samples = a52_samples( p_sys->p_liba52 );
/* Interleave the *$% samples. */
Interleave( (float *)(p_out_buf->p_buffer + i * i_bytes_per_block),
p_samples, p_sys->i_nb_channels );
}
p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
p_out_buf->i_nb_bytes = i_bytes_per_block * 6;
}
/*****************************************************************************
* Destroy : deallocate data structures
*****************************************************************************/
static void Destroy( vlc_object_t * _p_filter )
{
aout_filter_t * p_filter = (aout_filter_t *)_p_filter;
struct aout_filter_sys_t * p_sys = p_filter->p_sys;
a52_free( p_sys->p_liba52 );
free( p_sys );
}
......@@ -2,7 +2,7 @@
* a52tospdif.c : encapsulates A/52 frames into S/PDIF packets
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: a52tospdif.c,v 1.10 2002/08/26 23:00:22 massiot Exp $
* $Id: a52tospdif.c,v 1.11 2002/09/02 23:17:05 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Stphane Borel <stef@via.ecp.fr>
......@@ -42,7 +42,6 @@
* Local prototypes
*****************************************************************************/
static int Create ( vlc_object_t * );
static void DoWork ( aout_instance_t *, aout_filter_t *, aout_buffer_t *,
aout_buffer_t * );
......@@ -56,9 +55,7 @@ vlc_module_begin();
vlc_module_end();
/*****************************************************************************
* Create: allocate trivial mixer
*****************************************************************************
* This function allocates and initializes a Crop vout method.
* Create:
*****************************************************************************/
static int Create( vlc_object_t *p_this )
{
......
......@@ -2,7 +2,7 @@
* oss.c : OSS /dev/dsp module for vlc
*****************************************************************************
* Copyright (C) 2000-2002 VideoLAN
* $Id: oss.c,v 1.22 2002/08/31 22:10:25 stef Exp $
* $Id: oss.c,v 1.23 2002/09/02 23:17:05 massiot Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -174,8 +174,25 @@ static int Open( vlc_object_t *p_this )
if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0
|| i_format != p_aout->output.output.i_format )
{
msg_Err( p_aout, "cannot set audio output format (%i)", i_format );
return VLC_EGENERIC;
if ( i_format == AOUT_FMT_SPDIF )
{
/* Retry with S16 */
msg_Warn( p_aout, "cannot set audio output format (%i)", i_format );
p_aout->output.output.i_format = i_format = AOUT_FMT_S16_NE;
p_aout->output.i_nb_samples = FRAME_SIZE;
if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0
|| i_format != p_aout->output.output.i_format )
{
msg_Err( p_aout, "cannot set audio output format (%i)",
i_format );
return VLC_EGENERIC;
}
}
else
{
msg_Err( p_aout, "cannot set audio output format (%i)", i_format );
return VLC_EGENERIC;
}
}
if ( p_aout->output.output.i_format != AOUT_FMT_SPDIF )
......
......@@ -2,7 +2,7 @@
* sdl.c : SDL audio output plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2002 VideoLAN
* $Id: sdl.c,v 1.10 2002/08/31 19:58:04 stef Exp $
* $Id: sdl.c,v 1.11 2002/09/02 23:17:05 massiot Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -103,6 +103,11 @@ static int Open ( vlc_object_t *p_this )
return VLC_EGENERIC;
}
if ( p_aout->output.output.i_channels > 2 )
p_aout->output.output.i_channels = 2;
p_aout->output.output.i_format = AOUT_FMT_S16_NE;
p_aout->output.i_nb_samples = FRAME_SIZE;
/* TODO: finish and clean this */
desired.freq = p_aout->output.output.i_rate;
......@@ -118,9 +123,6 @@ static int Open ( vlc_object_t *p_this )
return VLC_EGENERIC;
}
p_aout->output.output.i_format = AOUT_FMT_S16_NE;
p_aout->output.i_nb_samples = FRAME_SIZE;
SDL_PauseAudio( 0 );
return VLC_SUCCESS;
......
a52_SOURCES = a52.c
spdif_SOURCES = spdif.c
/*****************************************************************************
* a52.c: ATSC A/52 aka AC-3 decoder plugin for vlc.
* This plugin makes use of liba52 to decode A/52 audio
* (http://liba52.sf.net/).
* a52.c: A/52 basic parser
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: a52.c,v 1.8 2002/08/30 22:22:24 massiot Exp $
* Copyright (C) 2001-2002 VideoLAN
* $Id: a52.c,v 1.9 2002/09/02 23:17:05 massiot Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
* Authors: Stphane Borel <stef@via.ecp.fr>
* Christophe Massiot <massiot@via.ecp.fr>
*
* Michel Lespinasse <walken@zoy.org>
* Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
......@@ -27,49 +27,38 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h> /* memcpy() */
#include <fcntl.h>
#include <vlc/vlc.h>
#include <vlc/aout.h>
#include <vlc/decoder.h>
#include <stdlib.h> /* malloc(), free() */
#include <string.h> /* strdup() */
#ifdef HAVE_STDINT_H
# include <stdint.h> /* int16_t .. */
#elif HAVE_INTTYPES_H
# include <inttypes.h> /* int16_t .. */
#endif
#include <vlc/aout.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef USE_A52DEC_TREE /* liba52 header file */
# include "include/a52.h"
#else
# include "a52dec/a52.h"
#endif
#define A52_FRAME_NB 1536
/*****************************************************************************
* a52_thread_t : a52 decoder thread descriptor
* spdif_thread_t : A52 pass-through thread descriptor
*****************************************************************************/
typedef struct a52_thread_s
typedef struct spdif_thread_s
{
/*
* liba52 properties
* Thread properties
*/
a52_state_t * p_a52_state;
vlc_bool_t b_dynrng;
/* The bit stream structure handles the PES stream at the bit level */
bit_stream_t bit_stream;
vlc_thread_t thread_id; /* id for thread functions */
/*
* Input properties
*/
decoder_fifo_t * p_fifo; /* stores the PES stream data */
data_packet_t * p_data;
/* The bit stream structure handles the PES stream at the bit level */
bit_stream_t bit_stream;
/*
* Output properties
......@@ -77,111 +66,109 @@ typedef struct a52_thread_s
aout_instance_t * p_aout; /* opaque */
aout_input_t * p_aout_input; /* opaque */
audio_sample_format_t output_format;
audio_date_t end_date;
} a52_thread_t;
} spdif_thread_t;
/*****************************************************************************
/****************************************************************************
* Local prototypes
*****************************************************************************/
****************************************************************************/
static int OpenDecoder ( vlc_object_t * );
static int RunDecoder ( decoder_fifo_t * );
static int DecodeFrame ( a52_thread_t *, byte_t * );
static int InitThread ( a52_thread_t *, decoder_fifo_t * );
static void EndThread ( a52_thread_t * );
static int InitThread ( spdif_thread_t *, decoder_fifo_t * );
static void EndThread ( spdif_thread_t * );
static int SyncInfo ( const byte_t *, int *, int *, int * );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define DYNRNG_TEXT N_("A/52 dynamic range compression")
#define DYNRNG_LONGTEXT N_( \
"Dynamic range compression makes the loud sounds softer, and the soft " \
"sounds louder, so you can more easily listen to the stream in a noisy " \
"environment without disturbing anyone. If you disable the dynamic range "\
"compression the playback will be more adapted to a movie theater or a " \
"listening room.")
vlc_module_begin();
add_category_hint( N_("Miscellaneous"), NULL );
add_bool( "a52-dynrng", 1, NULL, DYNRNG_TEXT, DYNRNG_LONGTEXT );
set_description( _("a52 ATSC A/52 aka AC-3 audio decoder module") );
set_capability( "decoder", 60 );
set_description( _("A/52 parser") );
set_capability( "decoder", 0 );
set_callbacks( OpenDecoder, NULL );
add_shortcut( "pass_through" );
add_shortcut( "pass" );
vlc_module_end();
/*****************************************************************************
* OpenDecoder: probe the decoder and return score
*****************************************************************************
* Tries to launch a decoder and return score so that the interface is able
* to choose.
* Tries to launch a decoder and return score so that the interface is able
* to chose.
*****************************************************************************/
static int OpenDecoder( vlc_object_t *p_this )
{
static int OpenDecoder( vlc_object_t *p_this )
{
decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this;
if( p_fifo->i_fourcc != VLC_FOURCC('a','5','2',' ')
&& p_fifo->i_fourcc != VLC_FOURCC('a','5','2','b') )
{
return VLC_EGENERIC;
return VLC_EGENERIC;
}
p_fifo->pf_run = RunDecoder;
return VLC_SUCCESS;
}
/*****************************************************************************
* RunDecoder: this function is called just after the thread is created
*****************************************************************************/
/****************************************************************************
* RunDecoder: the whole thing
****************************************************************************
* This function is called just after the thread is launched.
****************************************************************************/
static int RunDecoder( decoder_fifo_t *p_fifo )
{
a52_thread_t *p_dec;
spdif_thread_t * p_dec;
audio_date_t end_date;
/* Allocate the memory needed to store the thread's structure */
p_dec = (a52_thread_t *)malloc( sizeof(a52_thread_t) );
p_dec = malloc( sizeof(spdif_thread_t) );
if( p_dec == NULL )
{
msg_Err( p_fifo, "out of memory" );
DecoderError( p_fifo );
return -1;
}
if( InitThread( p_dec, p_fifo ) )
if ( InitThread( p_dec, p_fifo ) )
{
msg_Err( p_dec->p_fifo, "could not initialize thread" );
msg_Err( p_fifo, "could not initialize thread" );
DecoderError( p_fifo );
free( p_dec );
return -1;
}
/* liba52 decoder thread's main loop */
while( !p_dec->p_fifo->b_die && !p_dec->p_fifo->b_error )
/* decoder thread's main loop */
while ( !p_dec->p_fifo->b_die && !p_dec->p_fifo->b_error )
{
int i_frame_size, i_flags, i_rate, i_bit_rate;
int i_frame_size, i_channels, i_rate, i_bit_rate;
mtime_t pts;
/* Temporary buffer to store the raw frame to be decoded */
byte_t p_frame_buffer[3840];
byte_t p_header[7];
aout_buffer_t * p_buffer;
/* Look for sync word - should be 0x0b77 */
RealignBits( &p_dec->bit_stream );
while( (ShowBits( &p_dec->bit_stream, 16 ) ) != 0x0b77 &&
(!p_dec->p_fifo->b_die) && (!p_dec->p_fifo->b_error))
while ( (ShowBits( &p_dec->bit_stream, 16 ) ) != 0x0b77 &&
(!p_dec->p_fifo->b_die) && (!p_dec->p_fifo->b_error))
{
RemoveBits( &p_dec->bit_stream, 8 );