+ decoder_sys_t *p_sys = p_dec->p_sys;
+ block_t *p_block;
+
+ p_block = block_New( p_dec, p_sys->i_frame_size );
+ if( p_block == NULL ) return NULL;
+
+ 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;
+
+ return p_block;
+}
+
+/*****************************************************************************
+ * SyncInfo: parse A/52 sync info
+ *****************************************************************************
+ * This code is borrowed from liba52 by Aaron Holtzman & Michel Lespinasse,
+ * since we don't want to oblige S/PDIF people to use liba52 just to get
+ * 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 )
+{
+ 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,
+ 128, 160, 192, 224, 256, 320, 384, 448,
+ 512, 576, 640 };
+ static const uint8_t lfeon[8] = { 0x10, 0x10, 0x04, 0x04,
+ 0x04, 0x01, 0x04, 0x01 };
+ int frmsizecod;
+ int bitrate;
+ int half;
+ int acmod;
+
+ if ((p_buf[0] != 0x0b) || (p_buf[1] != 0x77)) /* syncword */
+ return 0;
+
+ if (p_buf[5] >= 0x60) /* bsid >= 12 */
+ return 0;
+ half = halfrate[p_buf[5] >> 3];
+
+ /* acmod, dsurmod and lfeon */
+ acmod = p_buf[6] >> 5;
+ if ( (p_buf[6] & 0xf8) == 0x50 )
+ {
+ /* Dolby surround = stereo + Dolby */
+ *pi_channels = 2;
+ *pi_channels_conf = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT
+ | AOUT_CHAN_DOLBYSTEREO;
+ }
+ else switch ( acmod )