X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fmux%2Fwav.c;h=b9e3482723f482d116c695270c2770b50ea510bb;hb=1fbd0f24404187cc2d7454285f592ad23bf7a3de;hp=b901a0b4c950001d99e2af3dd114791adafc7a88;hpb=df61d33b06e2b3cbbe746b2f5a9bea5b370c24ff;p=vlc diff --git a/modules/mux/wav.c b/modules/mux/wav.c index b901a0b4c9..b9e3482723 100644 --- a/modules/mux/wav.c +++ b/modules/mux/wav.c @@ -1,24 +1,24 @@ /***************************************************************************** * wav.c: wav muxer module for vlc ***************************************************************************** - * Copyright (C) 2004, 2006 the VideoLAN team + * Copyright (C) 2004, 2006 VLC authors and VideoLAN * $Id$ * * Authors: Gildas Bazin * - * 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 + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** @@ -29,7 +29,8 @@ # include "config.h" #endif -#include +#include +#include #include #include #include @@ -41,21 +42,21 @@ static int Open ( vlc_object_t * ); static void Close ( vlc_object_t * ); -vlc_module_begin(); - set_description( _("WAV muxer") ); - set_capability( "sout mux", 5 ); - set_category( CAT_SOUT ); - set_subcategory( SUBCAT_SOUT_MUX ); - set_callbacks( Open, Close ); - add_shortcut( "wav" ); -vlc_module_end(); +vlc_module_begin () + set_description( N_("WAV muxer") ) + set_capability( "sout mux", 5 ) + set_category( CAT_SOUT ) + set_subcategory( SUBCAT_SOUT_MUX ) + set_callbacks( Open, Close ) + add_shortcut( "wav" ) +vlc_module_end () /***************************************************************************** * Exported prototypes *****************************************************************************/ static int Control ( sout_mux_t *, int, va_list ); static int AddStream( sout_mux_t *, sout_input_t * ); -static int DelStream( sout_mux_t *, sout_input_t * ); +static void DelStream( sout_mux_t *, sout_input_t * ); static int Mux ( sout_mux_t * ); #define MAX_CHANNELS 6 @@ -74,25 +75,20 @@ struct sout_mux_sys_t uint32_t waveheader2[2]; uint32_t i_channel_mask; - bool b_chan_reorder; /* do we need channel reordering */ - int pi_chan_table[AOUT_CHAN_MAX]; + uint8_t i_chans_to_reorder; /* do we need channel reordering */ + uint8_t pi_chan_table[AOUT_CHAN_MAX]; }; - -static const uint32_t pi_channels_src[] = - { AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT, - AOUT_CHAN_MIDDLELEFT, AOUT_CHAN_MIDDLERIGHT, - AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT, - AOUT_CHAN_CENTER, AOUT_CHAN_LFE, 0 }; static const uint32_t pi_channels_in[] = { WAVE_SPEAKER_FRONT_LEFT, WAVE_SPEAKER_FRONT_RIGHT, WAVE_SPEAKER_SIDE_LEFT, WAVE_SPEAKER_SIDE_RIGHT, - WAVE_SPEAKER_BACK_LEFT, WAVE_SPEAKER_BACK_RIGHT, + WAVE_SPEAKER_BACK_LEFT, WAVE_SPEAKER_BACK_RIGHT, WAVE_SPEAKER_BACK_CENTER, WAVE_SPEAKER_FRONT_CENTER, WAVE_SPEAKER_LOW_FREQUENCY, 0 }; static const uint32_t pi_channels_out[] = { WAVE_SPEAKER_FRONT_LEFT, WAVE_SPEAKER_FRONT_RIGHT, WAVE_SPEAKER_FRONT_CENTER, WAVE_SPEAKER_LOW_FREQUENCY, WAVE_SPEAKER_BACK_LEFT, WAVE_SPEAKER_BACK_RIGHT, + WAVE_SPEAKER_BACK_CENTER, WAVE_SPEAKER_SIDE_LEFT, WAVE_SPEAKER_SIDE_RIGHT, 0 }; /***************************************************************************** @@ -109,11 +105,13 @@ static int Open( vlc_object_t *p_this ) p_mux->pf_mux = Mux; p_mux->p_sys = p_sys = malloc( sizeof( sout_mux_sys_t ) ); + if( !p_sys ) + return VLC_ENOMEM; p_sys->b_used = false; p_sys->b_header = true; p_sys->i_data = 0; - p_sys->b_chan_reorder = 0; + p_sys->i_chans_to_reorder = 0; return VLC_SUCCESS; } @@ -160,7 +158,8 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input ) GUID subformat_guid = {0, 0, 0x10,{0x80, 0, 0, 0xaa, 0, 0x38, 0x9b, 0x71}}; sout_mux_sys_t *p_sys = p_mux->p_sys; WAVEFORMATEX *p_waveformat = &p_sys->waveformat.Format; - int i_bytes_per_sample, i_format; + int i_bytes_per_sample; + uint16_t i_format; bool b_ext; if( p_input->p_fmt->i_cat != AUDIO_ES ) @@ -182,26 +181,20 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input ) p_sys->i_channel_mask = 0; if( p_input->p_fmt->audio.i_physical_channels ) { - unsigned int i; - - for( i = 0; i < sizeof(pi_channels_in)/sizeof(uint32_t); i++ ) - { - if( p_input->p_fmt->audio.i_physical_channels & pi_channels_src[i]) + for( unsigned i = 0; i < pi_vlc_chan_order_wg4[i]; i++ ) + if( p_input->p_fmt->audio.i_physical_channels & pi_vlc_chan_order_wg4[i]) p_sys->i_channel_mask |= pi_channels_in[i]; - } - p_sys->b_chan_reorder = + p_sys->i_chans_to_reorder = aout_CheckChannelReorder( pi_channels_in, pi_channels_out, p_sys->i_channel_mask, - p_input->p_fmt->audio.i_channels, p_sys->pi_chan_table ); - msg_Dbg( p_mux, "channel mask: %x, reordering: %i", - p_sys->i_channel_mask, (int)p_sys->b_chan_reorder ); + msg_Dbg( p_mux, "channel mask: %x, reordering: %u", + p_sys->i_channel_mask, p_sys->i_chans_to_reorder ); } - i_format = p_input->p_fmt->i_codec == VLC_FOURCC('f', 'l', '3', '2') ? - WAVE_FORMAT_IEEE_FLOAT : WAVE_FORMAT_PCM; + fourcc_to_wf_tag( p_input->p_fmt->i_codec, &i_format ); b_ext = p_sys->b_ext = p_input->p_fmt->audio.i_channels > 2; /* Build a WAV header for the output data */ @@ -246,7 +239,7 @@ static block_t *GetHeader( sout_mux_t *p_mux ) { sout_mux_sys_t *p_sys = p_mux->p_sys; block_t *p_block = - block_New( p_mux, sizeof( WAVEFORMATEXTENSIBLE ) + 7 * 4 ); + block_Alloc( sizeof( WAVEFORMATEXTENSIBLE ) + 7 * 4 ); SetDWLE( &p_sys->waveheader[1], 20 + (p_sys->b_ext ? 40 : 16) + p_sys->i_data ); /* Length */ @@ -262,7 +255,7 @@ static block_t *GetHeader( sout_mux_t *p_mux ) return p_block; } -static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input ) +static void DelStream( sout_mux_t *p_mux, sout_input_t *p_input ) { VLC_UNUSED(p_input); msg_Dbg( p_mux, "removing input" ); @@ -272,8 +265,6 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input ) { sout_AccessOutWrite( p_mux->p_access, GetHeader( p_mux ) ); } - - return VLC_SUCCESS; } static int Mux( sout_mux_t *p_mux ) @@ -297,11 +288,10 @@ static int Mux( sout_mux_t *p_mux ) p_sys->i_data += p_block->i_buffer; /* Do the channel reordering */ - if( p_sys->b_chan_reorder ) + if( p_sys->i_chans_to_reorder ) aout_ChannelReorder( p_block->p_buffer, p_block->i_buffer, - p_input->p_fmt->audio.i_channels, - p_sys->pi_chan_table, - p_input->p_fmt->audio.i_bitspersample ); + p_sys->i_chans_to_reorder, + p_sys->pi_chan_table, p_input->p_fmt->i_codec ); sout_AccessOutWrite( p_mux->p_access, p_block ); }