/*****************************************************************************
* speex.c: speex decoder/packetizer/encoder module making use of libspeex.
*****************************************************************************
- * Copyright (C) 2003 VideoLAN
+ * Copyright (C) 2003 the VideoLAN team
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
*
* 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.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <vlc/vlc.h>
-#include <vlc/decoder.h>
-#include <vlc/input.h>
+#include <vlc_input.h>
+#include <vlc_codec.h>
+#include <vlc_aout.h>
#include <ogg/ogg.h>
-#include <speex.h>
-#include "speex_header.h"
-#include "speex_stereo.h"
-#include "speex_callbacks.h"
+#include <speex/speex.h>
+#include <speex/speex_header.h>
+#include <speex/speex_stereo.h>
+#include <speex/speex_callbacks.h>
/*****************************************************************************
* decoder_sys_t : speex decoder descriptor
* Module descriptor
*****************************************************************************/
vlc_module_begin();
+ set_category( CAT_INPUT );
+ set_subcategory( SUBCAT_INPUT_ACODEC );
+
set_description( _("Speex audio decoder") );
set_capability( "decoder", 100 );
set_callbacks( OpenDecoder, CloseDecoder );
p_dec->fmt_in.p_extra =
realloc( p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra +
oggpacket.bytes + 2 );
- p_extra = p_dec->fmt_in.p_extra + p_dec->fmt_in.i_extra;
+ p_extra = ((uint8_t *)p_dec->fmt_in.p_extra) + p_dec->fmt_in.i_extra;
*(p_extra++) = oggpacket.bytes >> 8;
*(p_extra++) = oggpacket.bytes & 0xFF;
SpeexCallback callback;
p_sys->p_header = p_header =
- speex_packet_to_header( p_oggpacket->packet, p_oggpacket->bytes );
+ speex_packet_to_header( (char *)p_oggpacket->packet,
+ p_oggpacket->bytes );
if( !p_header )
{
msg_Err( p_dec, "cannot read Speex header" );
if( p_header->speex_version_id > 1 )
{
msg_Err( p_dec, "this file was encoded with Speex bit-stream "
- "version %d, which I don't know how to decode.",
+ "version %d which is not supported by this decoder.",
p_header->speex_version_id );
return VLC_EGENERIC;
}
callback.data = &p_sys->stereo;
speex_decoder_ctl( p_state, SPEEX_SET_HANDLER, &callback );
}
+ if( p_header->nb_channels <= 0 ||
+ p_header->nb_channels > 5 )
+ {
+ msg_Err( p_dec, "invalid number of channels (not between 1 and 5): %i",
+ p_header->nb_channels );
+ return VLC_EGENERIC;
+ }
/* Setup the format */
p_dec->fmt_out.audio.i_physical_channels =
if( p_oggpacket->bytes )
{
/* Copy Ogg packet to Speex bitstream */
- speex_bits_read_from( &p_sys->bits, p_oggpacket->packet,
+ speex_bits_read_from( &p_sys->bits, (char *)p_oggpacket->packet,
p_oggpacket->bytes );
p_sys->i_frame_in_packet = 0;
}
encoder_sys_t *p_sys;
const SpeexMode *p_speex_mode = &speex_nb_mode;
int i_quality, i;
- char *pp_header[2];
+ const char *pp_header[2];
int pi_header[2];
uint8_t *p_extra;
encoder_sys_t *p_sys = p_enc->p_sys;
block_t *p_block, *p_chain = NULL;
- char *p_buffer = p_aout_buf->p_buffer;
+ unsigned char *p_buffer = p_aout_buf->p_buffer;
int i_samples = p_aout_buf->i_nb_samples;
int i_samples_delay = p_sys->i_samples_delay;