Commit 9000920a authored by Christophe Massiot's avatar Christophe Massiot

* Trivial resampler plug-in (resampling still non-functional)

* Begun writing some hooks for forthcoming S/PDIF support
* ./modules/access/vcd/cdrom.c: compile fix for Darwin
parent 7ba73a88
This diff is collapsed.
......@@ -445,6 +445,7 @@ PLUGINS="${PLUGINS} codec/mpeg_video/idct/idct codec/mpeg_video/idct/idctclassic
#PLUGINS="${PLUGINS} codec/a52old/imdct/imdct codec/a52old/downmix/downmix codec/mpeg_audio/mpeg_audio codec/a52old/a52old codec/lpcm/lpcm codec/spdif/spdif"
PLUGINS="${PLUGINS} video_filter/deinterlace/deinterlace video_filter/invert video_filter/wall video_filter/transform video_filter/distort video_filter/clone video_filter/crop"
PLUGINS="${PLUGINS} audio_filter/converter/float32tos16"
PLUGINS="${PLUGINS} audio_filter/resampler/trivial"
PLUGINS="${PLUGINS} audio_mixer/trivial"
PLUGINS="${PLUGINS} audio_output/file"
#PLUGINS="${PLUGINS} visualization/scope/scope"
......
......@@ -2,7 +2,7 @@
* audio_output.h : audio output interface
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: audio_output.h,v 1.53 2002/08/08 00:35:10 sam Exp $
* $Id: audio_output.h,v 1.54 2002/08/09 23:46:53 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -42,9 +42,11 @@ struct audio_sample_format_t
#define AOUT_FMT_S8 0x00000040
#define AOUT_FMT_U16_LE 0x00000080 /* Little endian U16 */
#define AOUT_FMT_U16_BE 0x00000100 /* Big endian U16 */
#define AOUT_FMT_A52 0x00000400 /* ATSC A/52 (for SP/DIF) */
#define AOUT_FMT_FLOAT32 0x00000800
#define AOUT_FMT_FIXED32 0x00001000
#define AOUT_FMT_SPDIF 0x00000400 /* S/PDIF hardware support */
#define AOUT_FMT_FLOAT32 0x00010000
#define AOUT_FMT_FIXED32 0x00020000
#define AOUT_FMT_A52 0x00100000
#define AOUT_FMT_DTS 0x00200000
#define AOUT_FMTS_IDENTICAL( p_first, p_second ) ( \
(p_first->i_format == p_second->i_format) \
......@@ -60,6 +62,11 @@ struct audio_sample_format_t
# define AOUT_FMT_U16_NE AOUT_FMT_U16_LE
#endif
#define AOUT_FMT_IS_SPDIF( p_format ) \
( (p_format->i_format == AOUT_FMT_SPDIF) \
|| (p_format->i_format == AOUT_FMT_A52) \
|| (p_format->i_format == AOUT_FMT_DTS) )
/*****************************************************************************
* aout_buffer_t : audio output buffer
*****************************************************************************/
......@@ -74,6 +81,8 @@ struct aout_buffer_t
struct aout_buffer_t * p_next;
};
#define AOUT_SPDIF_FRAME 1536
/*****************************************************************************
* Prototypes
*****************************************************************************/
......@@ -84,7 +93,9 @@ VLC_EXPORT( void, aout_DeleteInstance, ( aout_instance_t * ) );
VLC_EXPORT( aout_buffer_t *, aout_BufferNew, ( aout_instance_t *, aout_input_t *, size_t ) );
VLC_EXPORT( void, aout_BufferDelete, ( aout_instance_t *, aout_input_t *, aout_buffer_t * ) );
VLC_EXPORT( void, aout_BufferPlay, ( aout_instance_t *, aout_input_t *, aout_buffer_t * ) );
VLC_EXPORT( int, aout_FormatToBytes, ( audio_sample_format_t * p_format ) );
VLC_EXPORT( int, aout_FormatTo, ( audio_sample_format_t * p_format, int ) );
#define aout_FormatToByterate(a,b) aout_FormatTo(a,b)
#define aout_FormatToSize(a,b) aout_FormatTo(a,b)
/* From input.c : */
#define aout_InputNew(a,b,c) __aout_InputNew(VLC_OBJECT(a),b,c)
......
/* include/defs.h.in. Generated automatically from configure.in by autoheader 2.13. */
/* include/defs.h.in. Generated automatically from configure.in by autoheader. */
/* Define if using alloca.c. */
#undef C_ALLOCA
......
......@@ -36,7 +36,7 @@ struct module_symbols_t
int (* __vlc_thread_create_inner) ( vlc_object_t *, char *, int, char *, void * ( * ) ( void * ), vlc_bool_t ) ;
int (* __vlc_threads_end_inner) ( vlc_object_t * ) ;
int (* __vlc_threads_init_inner) ( vlc_object_t * ) ;
int (* aout_FormatToBytes_inner) ( audio_sample_format_t * p_format ) ;
int (* aout_FormatTo_inner) ( audio_sample_format_t * p_format, int ) ;
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 * ) ;
......@@ -205,7 +205,7 @@ struct module_symbols_t
# define aout_BufferNew p_symbols->aout_BufferNew_inner
# define aout_BufferPlay p_symbols->aout_BufferPlay_inner
# define aout_DeleteInstance p_symbols->aout_DeleteInstance_inner
# define aout_FormatToBytes p_symbols->aout_FormatToBytes_inner
# define aout_FormatTo p_symbols->aout_FormatTo_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
......
......@@ -2,7 +2,7 @@
* cdrom.c: cdrom tools
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: cdrom.c,v 1.2 2002/08/08 22:28:22 sam Exp $
* $Id: cdrom.c,v 1.3 2002/08/09 23:47:22 massiot Exp $
*
* Author: Johan Bilien <jobi@via.ecp.fr>
* Jon Lech Johansen <jon-vl@nanocrew.net>
......@@ -62,7 +62,7 @@
* Platform specific
*****************************************************************************/
#if defined( SYS_DARWIN )
CDTOC *getTOC( const char * );
CDTOC *getTOC( vlc_object_t *, const char * );
#define freeTOC( p ) free( (void*)p )
int getNumberOfDescriptors( CDTOC * );
int getNumberOfTracks( CDTOC *, int );
......@@ -81,7 +81,7 @@ int ioctl_GetTrackCount( vlc_object_t * p_this, int i_fd, const char *psz_dev )
CDTOC *pTOC;
int i_descriptors;
if( ( pTOC = getTOC( psz_dev ) ) == NULL )
if( ( pTOC = getTOC( p_this, psz_dev ) ) == NULL )
{
msg_Err( p_this, "failed to get the TOC" );
return( -1 );
......@@ -134,7 +134,7 @@ int * ioctl_GetSectors( vlc_object_t *p_this, int i_fd, const char *psz_dev )
int i_leadout = -1;
CDTOCDescriptor *pTrackDescriptors;
if( ( pTOC = getTOC( psz_dev ) ) == NULL )
if( ( pTOC = getTOC( p_this, psz_dev ) ) == NULL )
{
msg_Err( p_this, "failed to get the TOC" );
return( NULL );
......@@ -334,7 +334,7 @@ int ioctl_ReadSector( vlc_object_t *p_this,
/****************************************************************************
* getTOC: get the TOC
****************************************************************************/
CDTOC *getTOC( const char *psz_dev )
CDTOC *getTOC( vlc_object_t * p_this, const char *psz_dev )
{
mach_port_t port;
char *psz_devname;
......
......@@ -2,7 +2,7 @@
* float32tos16.c : converter from float32 to signed 16 bits integer
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: float32tos16.c,v 1.1 2002/08/08 22:26:56 massiot Exp $
* $Id: float32tos16.c,v 1.2 2002/08/09 23:47:22 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -94,5 +94,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
else *p_out = *p_in * 32768.0;
p_in++; p_out++;
}
p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
}
/*****************************************************************************
* trivial.c : trivial resampler (skips samples or pads with zeroes)
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: trivial.c,v 1.1 2002/08/09 23:47:22 massiot Exp $
*
* Authors: 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 <errno.h>
#include <stdlib.h> /* malloc(), free() */
#include <string.h>
#include <vlc/vlc.h>
#include "audio_output.h"
#include "aout_internal.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int Create ( vlc_object_t * );
static void DoWork ( aout_instance_t *, aout_filter_t *, aout_buffer_t *,
aout_buffer_t * );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin();
set_description( _("aout filter for trivial resampling") );
set_capability( "audio filter", 1 );
set_callbacks( Create, NULL );
vlc_module_end();
/*****************************************************************************
* Create: allocate trivial mixer
*****************************************************************************
* This function allocates and initializes a Crop vout method.
*****************************************************************************/
static int Create( vlc_object_t *p_this )
{
aout_filter_t * p_filter = (aout_filter_t *)p_this;
p_filter->pf_do_work = DoWork;
p_filter->b_in_place = 1;
return 0;
}
/*****************************************************************************
* DoWork: convert a buffer
*****************************************************************************/
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 )
{
int i_in_nb = p_in_buf->i_nb_samples;
int i_out_nb = i_in_nb * p_filter->output.i_rate
/ p_filter->input.i_rate;
if ( p_out_buf != p_in_buf )
{
/* For whatever reason the buffer allocator decided to allocate
* a new buffer. */
p_aout->p_vlc->pf_memcpy( p_out_buf->p_buffer, p_in_buf->p_buffer,
__MIN(i_out_nb, i_in_nb) );
}
if ( i_out_nb > i_in_nb )
{
/* Pad with zeroes. */
memset( p_out_buf->p_buffer + i_in_nb, 0, i_out_nb - i_in_nb );
}
p_out_buf->i_nb_samples = i_out_nb;
}
......@@ -2,7 +2,7 @@
* file.c : audio output which writes the samples to a file
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: file.c,v 1.2 2002/08/08 22:28:22 sam Exp $
* $Id: file.c,v 1.3 2002/08/09 23:47:23 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -136,8 +136,8 @@ static int SetFormat( aout_instance_t * p_aout )
static void Play( aout_instance_t * p_aout, aout_buffer_t * p_buffer )
{
if( fwrite( p_buffer->p_buffer,
p_buffer->i_nb_samples
* aout_FormatToBytes( &p_aout->output.output ), 1,
aout_FormatToSize( &p_aout->output.output,
p_buffer->i_nb_samples ), 1,
(FILE *)p_aout->output.p_sys ) != 1 )
{
msg_Err( p_aout, "write error (%s)", strerror(errno) );
......
......@@ -2,7 +2,7 @@
* oss.c : OSS /dev/dsp module for vlc
*****************************************************************************
* Copyright (C) 2000-2002 VideoLAN
* $Id: oss.c,v 1.3 2002/08/08 22:28:22 sam Exp $
* $Id: oss.c,v 1.4 2002/08/09 23:47:23 massiot Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -170,15 +170,24 @@ static int SetFormat( aout_instance_t *p_aout )
}
/* Set the output format */
i_format = AOUT_FMT_S16_NE;
if ( AOUT_FMT_IS_SPDIF( &p_aout->output.output ) )
{
p_aout->output.output.i_format = i_format = AOUT_FMT_SPDIF;
p_aout->output.i_nb_samples = 1;
}
else
{
p_aout->output.output.i_format = i_format = AOUT_FMT_S16_NE;
p_aout->output.i_nb_samples = DEFAULT_FRAME_SIZE;
}
if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0
|| i_format != AOUT_FMT_S16_NE )
|| i_format != p_aout->output.output.i_format )
{
msg_Err( p_aout, "cannot set audio output format (%i)",
i_format );
return -1;
}
p_aout->output.output.i_format = AOUT_FMT_S16_NE;
/* FIXME */
if ( p_aout->output.output.i_channels > 2 )
......@@ -222,8 +231,6 @@ static int SetFormat( aout_instance_t *p_aout )
p_aout->output.output.i_rate = i_rate;
}
p_aout->output.i_nb_samples = DEFAULT_FRAME_SIZE;
p_sys->b_initialized = VLC_TRUE;
return 0;
......@@ -299,7 +306,7 @@ static int OSSThread( aout_instance_t * p_aout )
continue;
}
i_bytes_per_sample = aout_FormatToBytes( &p_aout->output.output );
i_bytes_per_sample = aout_FormatToSize( &p_aout->output.output, 1 );
next_date = (mtime_t)GetBufInfo( p_aout ) * 1000000
/ i_bytes_per_sample
/ p_aout->output.output.i_rate;
......
......@@ -2,7 +2,7 @@
* audio_output.c : audio output instance
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: audio_output.c,v 1.90 2002/08/07 21:36:56 massiot Exp $
* $Id: audio_output.c,v 1.91 2002/08/09 23:47:23 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -159,10 +159,10 @@ void aout_BufferPlay( aout_instance_t * p_aout, aout_input_t * p_input,
}
/*****************************************************************************
* aout_FormatToBytes : return the number bytes/sample for format
* (didn't know where else to put it)
* aout_FormatTo : compute the number of bytes/sample for format (used for
* aout_FormatToByterate and aout_FormatToSize)
*****************************************************************************/
int aout_FormatToBytes( audio_sample_format_t * p_format )
int aout_FormatTo( audio_sample_format_t * p_format, int i_multiplier )
{
int i_result;
......@@ -185,14 +185,18 @@ int aout_FormatToBytes( audio_sample_format_t * p_format )
i_result = 4;
break;
case AOUT_FMT_A52:
i_result = 1; /* This is a bit special... sample == byte */
break;
case AOUT_FMT_SPDIF:
case AOUT_FMT_A52: /* Actually smaller and variable, but who cares ? */
case AOUT_FMT_DTS: /* Unimplemented and untested */
/* Please note that we don't multiply by multiplier, because i_rate
* and i_nb_samples do not have any sense for S/PDIF (yes, it
* _is_ kludgy). --Meuuh */
return AOUT_SPDIF_FRAME;
default:
i_result = 0; /* will segfault much sooner... */
return 0; /* will segfault much sooner... */
}
return i_result * p_format->i_channels;
return i_result * p_format->i_channels * i_multiplier;
}
......@@ -2,7 +2,7 @@
* filters.c : audio output filters management
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: filters.c,v 1.1 2002/08/07 21:36:56 massiot Exp $
* $Id: filters.c,v 1.2 2002/08/09 23:47:23 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -26,12 +26,13 @@
*****************************************************************************/
#include <stdlib.h> /* calloc(), malloc(), free() */
#include <string.h>
#include <vlc/vlc.h>
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
#endif
#include <vlc/vlc.h>
#include "audio_output.h"
#include "aout_internal.h"
......@@ -160,10 +161,10 @@ void aout_FiltersHintBuffers( aout_instance_t * p_aout,
{
aout_filter_t * p_filter = pp_filters[i];
int i_output_size = aout_FormatToBytes( &p_filter->output )
* p_filter->output.i_rate;
int i_input_size = aout_FormatToBytes( &p_filter->input )
* p_filter->input.i_rate;
int i_output_size = aout_FormatToByterate( &p_filter->output,
p_filter->output.i_rate );
int i_input_size = aout_FormatToByterate( &p_filter->input,
p_filter->input.i_rate );
p_first_alloc->i_bytes_per_sec = __MAX( p_first_alloc->i_bytes_per_sec,
i_output_size );
......
......@@ -2,7 +2,7 @@
* input.c : internal management of input streams for the audio output
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: input.c,v 1.1 2002/08/07 21:36:56 massiot Exp $
* $Id: input.c,v 1.2 2002/08/09 23:47:23 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -116,8 +116,8 @@ static aout_input_t * InputNew( aout_instance_t * p_aout,
/* i_bytes_per_sec is still == -1 if no filters */
p_input->input_alloc.i_bytes_per_sec = __MAX(
p_input->input_alloc.i_bytes_per_sec,
aout_FormatToBytes( &p_input->input )
* p_input->input.i_rate );
aout_FormatToByterate( &p_input->input,
p_input->input.i_rate ) );
/* Allocate in the heap, it is more convenient for the decoder. */
p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
......
......@@ -2,7 +2,7 @@
* output.c : internal management of output streams for the audio output
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: output.c,v 1.1 2002/08/07 21:36:56 massiot Exp $
* $Id: output.c,v 1.2 2002/08/09 23:47:23 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -110,8 +110,8 @@ int aout_OutputNew( aout_instance_t * p_aout,
/* Prepare hints for the buffer allocator. */
p_aout->mixer.output_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
p_aout->mixer.output_alloc.i_bytes_per_sec
= aout_FormatToBytes( &p_aout->output.output )
* p_aout->output.output.i_rate;
= aout_FormatToByterate( &p_aout->output.output,
p_aout->output.output.i_rate );
aout_FiltersHintBuffers( p_aout, p_aout->output.pp_filters,
p_aout->output.i_nb_filters,
......
......@@ -184,7 +184,7 @@ static const char * module_error( char *psz_buffer )
(p_symbols)->aout_BufferNew_inner = aout_BufferNew; \
(p_symbols)->aout_BufferDelete_inner = aout_BufferDelete; \
(p_symbols)->aout_BufferPlay_inner = aout_BufferPlay; \
(p_symbols)->aout_FormatToBytes_inner = aout_FormatToBytes; \
(p_symbols)->aout_FormatTo_inner = aout_FormatTo; \
(p_symbols)->__aout_InputNew_inner = __aout_InputNew; \
(p_symbols)->aout_InputDelete_inner = aout_InputDelete; \
(p_symbols)->aout_OutputNextBuffer_inner = aout_OutputNextBuffer; \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment