/*****************************************************************************
* dts.c: parse DTS audio sync info and packetize the stream
*****************************************************************************
- * Copyright (C) 2003 VideoLAN
- * $Id: dts.c,v 1.16 2004/02/06 18:15:44 gbazin Exp $
+ * Copyright (C) 2003-2005 the VideoLAN team
+ * $Id$
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Gildas Bazin <gbazin@netcourrier.com>
*
* 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_block_helper.h"
+#include <vlc_codec.h>
+#include <vlc_aout.h>
+#include <vlc_block_helper.h>
#define DTS_HEADER_SIZE 14
mtime_t i_pts;
- int i_frame_size, i_bit_rate;
- unsigned int i_frame_length, i_rate, i_channels, i_channels_conf;
+ unsigned int i_bit_rate;
+ unsigned int i_frame_size;
+ unsigned int i_frame_length;
+ unsigned int i_rate;
+ unsigned int i_channels;
+ unsigned int i_channels_conf;
};
enum {
add_submodule();
set_description( _("DTS audio packetizer") );
set_capability( "packetizer", 10 );
- set_callbacks( OpenPacketizer, NULL );
+ set_callbacks( OpenPacketizer, CloseDecoder );
vlc_module_end();
/*****************************************************************************
/* Set output properties */
p_dec->fmt_out.i_cat = AUDIO_ES;
p_dec->fmt_out.i_codec = VLC_FOURCC('d','t','s',' ');
+ p_dec->fmt_out.audio.i_rate = 0; /* So end_date gets initialized */
/* Set callback */
p_dec->pf_decode_audio = (aout_buffer_t *(*)(decoder_t *, block_t **))
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)->b_discontinuity )
+ 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;
}
block_BytestreamPush( &p_sys->bytestream, *pp_block );
p_dec->fmt_out.audio.i_rate = p_sys->i_rate;
p_dec->fmt_out.audio.i_channels = p_sys->i_channels;
- p_dec->fmt_out.audio.i_bytes_per_frame = p_sys->i_frame_size;
+ /* Hack for DTS S/PDIF filter which needs to pad the DTS frames */
+ p_dec->fmt_out.audio.i_bytes_per_frame =
+ __MAX( p_sys->i_frame_size, p_sys->i_frame_length * 4 );
p_dec->fmt_out.audio.i_frame_length = p_sys->i_frame_length;
p_dec->fmt_out.audio.i_original_channels = p_sys->i_channels_conf;