* Copyright (C) 2001-2002 the VideoLAN team
* $Id$
*
- * Authors: Stéphane Borel <stef@via.ecp.fr>
+ * Authors: Stéphane Borel <stef@via.ecp.fr>
* Christophe Massiot <massiot@via.ecp.fr>
* 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>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
-#include "vlc_block_helper.h"
+#include <vlc/vlc.h>
+#include <vlc_codec.h>
+#include <vlc_aout.h>
+#include <vlc_input.h>
+#include <vlc_block_helper.h>
#define A52_HEADER_SIZE 7
int i_frame_size, i_bit_rate;
unsigned int i_rate, i_channels, i_channels_conf;
+ int i_input_rate;
};
enum {
static void CloseDecoder ( vlc_object_t * );
static void *DecodeBlock ( decoder_t *, block_t ** );
-static int SyncInfo ( const byte_t *, int *, int *, int *,int * );
+static int SyncInfo ( const byte_t *, unsigned int *, unsigned int *,
+ unsigned int *, int * );
static uint8_t *GetOutBuffer ( decoder_t *, void ** );
static aout_buffer_t *GetAoutBuffer( decoder_t * );
p_sys->i_state = STATE_NOSYNC;
aout_DateSet( &p_sys->end_date, 0 );
- p_sys->bytestream = block_BytestreamInit( p_dec );
+ p_sys->bytestream = block_BytestreamInit();
+ p_sys->i_input_rate = INPUT_RATE_DEFAULT;
/* Set output properties */
p_dec->fmt_out.i_cat = AUDIO_ES;
if( !pp_block || !*pp_block ) return NULL;
- if( !aout_DateGet( &p_sys->end_date ) && !(*pp_block)->i_pts )
+ if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
{
- /* We've just started the stream, wait for the first PTS. */
+ if( (*pp_block)->i_flags&BLOCK_FLAG_CORRUPTED )
+ {
+ p_sys->i_state = STATE_NOSYNC;
+ block_BytestreamFlush( &p_sys->bytestream );
+ }
+// aout_DateSet( &p_sys->end_date, 0 );
block_Release( *pp_block );
return NULL;
}
- if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
+ if( !aout_DateGet( &p_sys->end_date ) && !(*pp_block)->i_pts )
{
- p_sys->i_state = STATE_NOSYNC;
+ /* We've just started the stream, wait for the first PTS. */
+ block_Release( *pp_block );
+ return NULL;
}
+ if( (*pp_block)->i_rate > 0 )
+ p_sys->i_input_rate = (*pp_block)->i_rate;
+
block_BytestreamPush( &p_sys->bytestream, *pp_block );
while( 1 )
if( p_buf == NULL ) return NULL;
p_buf->start_date = aout_DateGet( &p_sys->end_date );
- p_buf->end_date = aout_DateIncrement( &p_sys->end_date, A52_FRAME_NB );
+ p_buf->end_date = aout_DateIncrement( &p_sys->end_date,
+ A52_FRAME_NB * p_sys->i_input_rate / INPUT_RATE_DEFAULT );
return p_buf;
}
p_block->i_pts = p_block->i_dts = aout_DateGet( &p_sys->end_date );
- p_block->i_length = aout_DateIncrement( &p_sys->end_date, A52_FRAME_NB ) -
- p_block->i_pts;
+ p_block->i_length =
+ aout_DateIncrement( &p_sys->end_date,
+ A52_FRAME_NB * p_sys->i_input_rate / INPUT_RATE_DEFAULT ) -
+ p_block->i_pts;
return p_block;
}
* their SyncInfo...
*****************************************************************************/
static int SyncInfo( const byte_t * p_buf,
- int * pi_channels, int * pi_channels_conf,
- int * pi_sample_rate, int * pi_bit_rate )
+ unsigned int * pi_channels,
+ unsigned int * pi_channels_conf,
+ unsigned int * pi_sample_rate, int * pi_bit_rate )
{
static const uint8_t halfrate[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3 };
static const int rate[] = { 32, 40, 48, 56, 64, 80, 96, 112,