1 /*****************************************************************************
2 * es.c : Generic audio ES input module for vlc
3 *****************************************************************************
4 * Copyright (C) 2001-2008 the VideoLAN team
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8 * Gildas Bazin <gbazin@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
33 #include <vlc_common.h>
34 #include <vlc_plugin.h>
35 #include <vlc_demux.h>
36 #include <vlc_codec.h>
37 #include <vlc_codecs.h>
38 #include <vlc_input.h>
40 #include "../../codec/a52.h"
42 /*****************************************************************************
44 *****************************************************************************/
45 static int Open ( vlc_object_t * );
46 static void Close( vlc_object_t * );
49 set_category( CAT_INPUT )
50 set_subcategory( SUBCAT_INPUT_DEMUX )
51 set_description( N_("MPEG-I/II/4 / A52 / DTS / MLP audio" ) )
52 set_capability( "demux", 155 )
53 set_callbacks( Open, Close )
55 add_shortcut( "mpga" )
59 add_shortcut( "mp4a" )
65 add_shortcut( "eac3" )
73 /*****************************************************************************
75 *****************************************************************************/
76 static int Demux ( demux_t * );
77 static int Control( demux_t *, int, va_list );
84 int (*pf_probe)( demux_t *p_demux, int64_t *pi_offset );
85 int (*pf_init)( demux_t *p_demux );
95 decoder_t *p_packetizer;
98 mtime_t i_time_offset;
102 bool b_estimate_bitrate;
103 int i_bitrate_avg; /* extracted from Xing header */
105 bool b_initial_sync_failed;
109 int64_t i_stream_offset;
121 static int MpgaProbe( demux_t *p_demux, int64_t *pi_offset );
122 static int MpgaInit( demux_t *p_demux );
124 static int AacProbe( demux_t *p_demux, int64_t *pi_offset );
125 static int AacInit( demux_t *p_demux );
127 static int EA52Probe( demux_t *p_demux, int64_t *pi_offset );
128 static int A52Probe( demux_t *p_demux, int64_t *pi_offset );
129 static int A52Init( demux_t *p_demux );
131 static int DtsProbe( demux_t *p_demux, int64_t *pi_offset );
132 static int DtsInit( demux_t *p_demux );
134 static int MlpProbe( demux_t *p_demux, int64_t *pi_offset );
135 static int MlpInit( demux_t *p_demux );
137 static const codec_t p_codec[] = {
138 { VLC_CODEC_MP4A, false, "mp4 audio", AacProbe, AacInit },
139 { VLC_CODEC_MPGA, false, "mpeg audio", MpgaProbe, MpgaInit },
140 { VLC_CODEC_A52, true, "a52 audio", A52Probe, A52Init },
141 { VLC_CODEC_EAC3, true, "eac3 audio", EA52Probe, A52Init },
142 { VLC_CODEC_DTS, false, "dts audio", DtsProbe, DtsInit },
143 { VLC_CODEC_TRUEHD, false, "mlp audio", MlpProbe, MlpInit },
145 { 0, false, NULL, NULL, NULL }
148 /*****************************************************************************
149 * Open: initializes demux structures
150 *****************************************************************************/
151 static int Open( vlc_object_t * p_this )
153 demux_t *p_demux = (demux_t*)p_this;
160 for( i_index = 0; p_codec[i_index].i_codec != 0; i_index++ )
162 if( !p_codec[i_index].pf_probe( p_demux, &i_offset ) )
166 if( p_codec[i_index].i_codec == 0 )
169 DEMUX_INIT_COMMON(); p_sys = p_demux->p_sys;
170 memset( p_sys, 0, sizeof( demux_sys_t ) );
171 p_sys->codec = p_codec[i_index];
173 p_sys->b_start = true;
174 p_sys->i_stream_offset = i_offset;
175 p_sys->b_estimate_bitrate = true;
176 p_sys->i_bitrate_avg = 0;
177 p_sys->b_big_endian = false;
179 if( stream_Seek( p_demux->s, p_sys->i_stream_offset ) )
185 if( p_sys->codec.pf_init( p_demux ) )
191 msg_Dbg( p_demux, "detected format %4.4s", (const char*)&p_sys->codec.i_codec );
193 /* Load the audio packetizer */
194 es_format_Init( &fmt, AUDIO_ES, p_sys->codec.i_codec );
195 p_sys->p_packetizer = demux_PacketizerNew( p_demux, &fmt, p_sys->codec.psz_name );
196 if( !p_sys->p_packetizer )
204 /*****************************************************************************
205 * Demux: reads and demuxes data packets
206 *****************************************************************************
207 * Returns -1 in case of error, 0 in case of EOF, 1 otherwise
208 *****************************************************************************/
209 static int Demux( demux_t *p_demux )
211 demux_sys_t *p_sys = p_demux->p_sys;
212 block_t *p_block_in, *p_block_out;
214 if( p_sys->codec.b_use_word )
216 /* Make sure we are word aligned */
217 int64_t i_pos = stream_Tell( p_demux->s );
219 stream_Read( p_demux->s, NULL, 1 );
222 if( ( p_block_in = stream_Block( p_demux->s, p_sys->i_packet_size ) ) == NULL )
225 if( p_sys->codec.b_use_word && !p_sys->b_big_endian && p_block_in->i_buffer > 0 )
227 /* Convert to big endian */
228 swab( p_block_in->p_buffer, p_block_in->p_buffer, p_block_in->i_buffer );
231 p_block_in->i_pts = p_block_in->i_dts = p_sys->b_start || p_sys->b_initial_sync_failed ? 1 : 0;
232 p_sys->b_initial_sync_failed = p_sys->b_start; /* Only try to resync once */
234 while( ( p_block_out = p_sys->p_packetizer->pf_packetize( p_sys->p_packetizer, &p_block_in ) ) )
236 p_sys->b_initial_sync_failed = false;
239 block_t *p_next = p_block_out->p_next;
243 p_sys->p_packetizer->fmt_out.b_packetized = true;
244 p_sys->p_es = es_out_Add( p_demux->out,
245 &p_sys->p_packetizer->fmt_out);
248 /* Try the xing header */
249 if( p_sys->xing.i_bytes && p_sys->xing.i_frames &&
250 p_sys->xing.i_frame_samples )
252 p_sys->i_bitrate_avg = p_sys->xing.i_bytes * INT64_C(8) *
253 p_sys->p_packetizer->fmt_out.audio.i_rate /
254 p_sys->xing.i_frames / p_sys->xing.i_frame_samples;
256 if( p_sys->i_bitrate_avg > 0 )
257 p_sys->b_estimate_bitrate = false;
259 /* Use the bitrate as initual value */
260 if( p_sys->b_estimate_bitrate )
261 p_sys->i_bitrate_avg = p_sys->p_packetizer->fmt_out.i_bitrate;
264 p_sys->i_pts = p_block_out->i_pts;
266 /* Re-estimate bitrate */
267 if( p_sys->b_estimate_bitrate && p_sys->i_pts > 1 + INT64_C(500000) )
268 p_sys->i_bitrate_avg = 8*INT64_C(1000000)*p_sys->i_bytes/(p_sys->i_pts-1);
269 p_sys->i_bytes += p_block_out->i_buffer;
271 /* Correct timestamp */
272 p_block_out->i_pts += p_sys->i_time_offset;
273 p_block_out->i_dts += p_sys->i_time_offset;
275 es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block_out->i_dts );
277 es_out_Send( p_demux->out, p_sys->p_es, p_block_out );
279 p_block_out = p_next;
283 if( p_sys->b_initial_sync_failed )
284 msg_Dbg( p_demux, "did not sync on first block" );
285 p_sys->b_start = false;
289 /*****************************************************************************
290 * Close: frees unused data
291 *****************************************************************************/
292 static void Close( vlc_object_t * p_this )
294 demux_t *p_demux = (demux_t*)p_this;
295 demux_sys_t *p_sys = p_demux->p_sys;
297 demux_PacketizerDestroy( p_sys->p_packetizer );
301 /*****************************************************************************
303 *****************************************************************************/
304 static int Control( demux_t *p_demux, int i_query, va_list args )
306 demux_sys_t *p_sys = p_demux->p_sys;
312 va_copy ( args_save, args );
316 case DEMUX_HAS_UNSUPPORTED_META:
317 pb_bool = (bool*)va_arg( args, bool* );
322 pi64 = (int64_t*)va_arg( args, int64_t * );
323 *pi64 = p_sys->i_pts + p_sys->i_time_offset;
326 case DEMUX_GET_LENGTH:
327 i_ret = demux_vaControlHelper( p_demux->s, p_sys->i_stream_offset, -1,
328 p_sys->i_bitrate_avg, 1, i_query,
330 /* No bitrate, we can't have it precisely, but we can compute
331 * a raw approximation with time/position */
332 if( i_ret && !p_sys->i_bitrate_avg )
334 float f_pos = (double)(uint64_t)( stream_Tell( p_demux->s ) ) /
335 (double)(uint64_t)( stream_Size( p_demux->s ) );
336 /* The first few seconds are guaranteed to be very whacky,
337 * don't bother trying ... Too bad */
339 (p_sys->i_pts + p_sys->i_time_offset) < 8000000 )
342 pi64 = (int64_t *)va_arg( args_save, int64_t * );
343 *pi64 = (p_sys->i_pts + p_sys->i_time_offset) / f_pos;
350 /* FIXME TODO: implement a high precision seek (with mp3 parsing)
351 * needed for multi-input */
353 i_ret = demux_vaControlHelper( p_demux->s, p_sys->i_stream_offset, -1,
354 p_sys->i_bitrate_avg, 1, i_query,
356 if( !i_ret && p_sys->i_bitrate_avg > 0 &&
357 (i_query == DEMUX_SET_POSITION || i_query == DEMUX_SET_TIME) )
359 int64_t i_time = INT64_C(8000000) * ( stream_Tell(p_demux->s) - p_sys->i_stream_offset ) /
360 p_sys->i_bitrate_avg;
362 /* Fix time_offset */
364 p_sys->i_time_offset = i_time - p_sys->i_pts;
370 /*****************************************************************************
372 *****************************************************************************/
373 #define WAV_PROBE_SIZE (512*1024)
374 static int WavSkipHeader( demux_t *p_demux, int *pi_skip, const int pi_format[] )
376 const uint8_t *p_peek;
382 /* Check if we are dealing with a WAV file */
383 if( stream_Peek( p_demux->s, &p_peek, 12+8 ) != 12 + 8 )
386 if( memcmp( p_peek, "RIFF", 4 ) || memcmp( &p_peek[8], "WAVE", 4 ) )
389 /* Find the wave format header */
391 while( memcmp( p_peek + i_peek - 8, "fmt ", 4 ) )
393 uint32_t i_len = GetDWLE( p_peek + i_peek - 4 );
394 if( i_len > WAV_PROBE_SIZE || i_peek + i_len > WAV_PROBE_SIZE )
398 if( stream_Peek( p_demux->s, &p_peek, i_peek ) != i_peek )
402 /* Sanity check the wave format header */
403 uint32_t i_len = GetDWLE( p_peek + i_peek - 4 );
404 if( i_len > WAV_PROBE_SIZE )
408 if( stream_Peek( p_demux->s, &p_peek, i_peek ) != i_peek )
410 const int i_format = GetWLE( p_peek + i_peek - i_len - 8 /* wFormatTag */ );
412 for( i_format_idx = 0; pi_format[i_format_idx] != WAVE_FORMAT_UNKNOWN; i_format_idx++ )
414 if( i_format == pi_format[i_format_idx] )
417 if( pi_format[i_format_idx] == WAVE_FORMAT_UNKNOWN )
420 if( i_format == WAVE_FORMAT_PCM )
422 if( GetWLE( p_peek + i_peek - i_len - 6 /* nChannels */ ) != 2 )
424 if( GetDWLE( p_peek + i_peek - i_len - 4 /* nSamplesPerSec */ ) !=
429 /* Skip the wave header */
430 while( memcmp( p_peek + i_peek - 8, "data", 4 ) )
432 uint32_t i_len = GetDWLE( p_peek + i_peek - 4 );
433 if( i_len > WAV_PROBE_SIZE || i_peek + i_len > WAV_PROBE_SIZE )
437 if( stream_Peek( p_demux->s, &p_peek, i_peek ) != i_peek )
444 static int GenericProbe( demux_t *p_demux, int64_t *pi_offset,
445 const char * ppsz_name[],
446 int (*pf_check)( const uint8_t * ), int i_check_size,
447 const int pi_wav_format[] )
452 const uint8_t *p_peek;
455 b_forced_demux = false;
456 for( int i = 0; ppsz_name[i] != NULL; i++ )
458 b_forced_demux |= demux_IsForced( p_demux, ppsz_name[i] );
461 i_offset = stream_Tell( p_demux->s );
463 if( WavSkipHeader( p_demux, &i_skip, pi_wav_format ) )
465 if( !b_forced_demux )
468 const bool b_wav = i_skip > 0;
471 * It is common that wav files have some sort of garbage at the begining */
472 const int i_probe = i_skip + i_check_size + ( b_wav ? 16000 : 0);
473 const int i_peek = stream_Peek( p_demux->s, &p_peek, i_probe );
474 if( i_peek < i_skip + i_check_size )
476 msg_Err( p_demux, "cannot peek" );
481 if( i_skip + i_check_size > i_peek )
483 if( !b_forced_demux )
487 const int i_size = pf_check( &p_peek[i_skip] );
490 if( i_size == 0 || 1)
493 /* If we have the frame size, check the next frame for
494 * extra robustness */
495 if( i_skip + i_check_size + i_size <= i_peek )
497 if( pf_check( &p_peek[i_skip+i_size] ) >= 0 )
504 *pi_offset = i_offset + i_skip;
508 /*****************************************************************************
510 *****************************************************************************/
511 static int MpgaCheckSync( const uint8_t *p_peek )
513 uint32_t h = GetDWBE( p_peek );
515 if( ((( h >> 21 )&0x07FF) != 0x07FF ) /* header sync */
516 || (((h >> 17)&0x03) == 0 ) /* valid layer ?*/
517 || (((h >> 12)&0x0F) == 0x0F )
518 || (((h >> 12)&0x0F) == 0x00 ) /* valid bitrate ? */
519 || (((h >> 10) & 0x03) == 0x03 ) /* valide sampling freq ? */
520 || ((h & 0x03) == 0x02 )) /* valid emphasis ? */
527 #define MPGA_VERSION( h ) ( 1 - (((h)>>19)&0x01) )
528 #define MPGA_MODE(h) (((h)>> 6)&0x03)
530 static int MpgaGetFrameSamples( uint32_t h )
532 const int i_layer = 3 - (((h)>>17)&0x03);
540 return MPGA_VERSION(h) ? 576 : 1152;
546 static int MpgaProbe( demux_t *p_demux, int64_t *pi_offset )
548 const int pi_wav[] = { WAVE_FORMAT_MPEG, WAVE_FORMAT_MPEGLAYER3, WAVE_FORMAT_UNKNOWN };
553 const uint8_t *p_peek;
556 b_forced = demux_IsPathExtension( p_demux, ".mp3" );
557 b_forced_demux = demux_IsForced( p_demux, "mp3" ) ||
558 demux_IsForced( p_demux, "mpga" );
560 i_offset = stream_Tell( p_demux->s );
562 if( WavSkipHeader( p_demux, &i_skip, pi_wav ) )
564 if( !b_forced_demux )
570 if( stream_Peek( p_demux->s, &p_peek, i_skip + 4 ) < i_skip + 4 )
573 if( !MpgaCheckSync( &p_peek[i_skip] ) )
578 if( !b_forced_demux && !b_forced )
581 i_peek = stream_Peek( p_demux->s, &p_peek, i_skip + 8096 );
582 while( i_skip + 4 < i_peek )
584 if( MpgaCheckSync( &p_peek[i_skip] ) )
591 if( !b_ok && !b_forced_demux )
594 *pi_offset = i_offset + i_skip;
598 static void MpgaXingSkip( const uint8_t **pp_xing, int *pi_xing, int i_count )
600 if(i_count > *pi_xing )
603 (*pp_xing) += i_count;
604 (*pi_xing) -= i_count;
607 static uint32_t MpgaXingGetDWBE( const uint8_t **pp_xing, int *pi_xing, uint32_t i_default )
612 uint32_t v = GetDWBE( *pp_xing );
614 MpgaXingSkip( pp_xing, pi_xing, 4 );
619 static int MpgaInit( demux_t *p_demux )
621 demux_sys_t *p_sys = p_demux->p_sys;
623 const uint8_t *p_peek;
627 p_sys->i_packet_size = 1024;
629 /* Load a potential xing header */
630 i_peek = stream_Peek( p_demux->s, &p_peek, 4 + 1024 );
631 if( i_peek < 4 + 21 )
634 const uint32_t header = GetDWBE( p_peek );
635 if( !MpgaCheckSync( p_peek ) )
639 const uint8_t *p_xing = p_peek;
643 if( MPGA_VERSION( header ) == 0 )
644 i_skip = MPGA_MODE( header ) != 3 ? 36 : 21;
646 i_skip = MPGA_MODE( header ) != 3 ? 21 : 13;
648 if( i_skip + 8 >= i_xing || memcmp( &p_xing[i_skip], "Xing", 4 ) )
651 const uint32_t i_flags = GetDWBE( &p_xing[i_skip+4] );
653 MpgaXingSkip( &p_xing, &i_xing, i_skip + 8 );
656 p_sys->xing.i_frames = MpgaXingGetDWBE( &p_xing, &i_xing, 0 );
658 p_sys->xing.i_bytes = MpgaXingGetDWBE( &p_xing, &i_xing, 0 );
659 if( i_flags&0x04 ) /* TODO Support XING TOC to improve seeking accuracy */
660 MpgaXingSkip( &p_xing, &i_xing, 100 );
663 /* FIXME: doesn't return the right bitrage average, at least
665 p_sys->xing.i_bitrate_avg = MpgaXingGetDWBE( &p_xing, &i_xing, 0 );
666 msg_Dbg( p_demux, "xing vbr value present (%d)",
667 p_sys->xing.i_bitrate_avg );
670 if( p_sys->xing.i_frames > 0 && p_sys->xing.i_bytes > 0 )
672 p_sys->xing.i_frame_samples = MpgaGetFrameSamples( header );
673 msg_Dbg( p_demux, "xing frames&bytes value present "
674 "(%d bytes, %d frames, %d samples/frame)",
675 p_sys->xing.i_bytes, p_sys->xing.i_frames,
676 p_sys->xing.i_frame_samples );
681 /*****************************************************************************
683 *****************************************************************************/
684 static int AacProbe( demux_t *p_demux, int64_t *pi_offset )
690 const uint8_t *p_peek;
692 b_forced = demux_IsPathExtension( p_demux, ".aac" ) ||
693 demux_IsPathExtension( p_demux, ".aacp" );
694 b_forced_demux = demux_IsForced( p_demux, "m4a" ) ||
695 demux_IsForced( p_demux, "aac" ) ||
696 demux_IsForced( p_demux, "mp4a" );
698 if( !b_forced_demux && !b_forced )
701 i_offset = stream_Tell( p_demux->s );
703 /* peek the begining (10 is for adts header) */
704 if( stream_Peek( p_demux->s, &p_peek, 10 ) < 10 )
706 msg_Err( p_demux, "cannot peek" );
709 if( !strncmp( (char *)p_peek, "ADIF", 4 ) )
711 msg_Err( p_demux, "ADIF file. Not yet supported. (Please report)" );
715 *pi_offset = i_offset;
718 static int AacInit( demux_t *p_demux )
720 demux_sys_t *p_sys = p_demux->p_sys;
722 p_sys->i_packet_size = 4096;
728 /*****************************************************************************
730 *****************************************************************************/
731 static int A52CheckSync( const uint8_t *p_peek, bool *p_big_endian, bool b_eac3 )
733 vlc_a52_header_t header;
734 uint8_t p_tmp[VLC_A52_HEADER_SIZE];
736 *p_big_endian = p_peek[0] == 0x0b && p_peek[1] == 0x77;
739 swab( p_peek, p_tmp, VLC_A52_HEADER_SIZE );
743 if( vlc_a52_header_Parse( &header, p_peek, VLC_A52_HEADER_SIZE ) )
746 if( !header.b_eac3 != !b_eac3 )
748 return header.i_size;
750 static int EA52CheckSyncProbe( const uint8_t *p_peek )
753 return A52CheckSync( p_peek, &b_dummy, true );
756 static int EA52Probe( demux_t *p_demux, int64_t *pi_offset )
758 const char *ppsz_name[] = { "eac3", NULL };
759 const int pi_wav[] = { WAVE_FORMAT_PCM, WAVE_FORMAT_A52, WAVE_FORMAT_UNKNOWN };
761 return GenericProbe( p_demux, pi_offset, ppsz_name, EA52CheckSyncProbe, VLC_A52_HEADER_SIZE, pi_wav );
764 static int A52CheckSyncProbe( const uint8_t *p_peek )
767 return A52CheckSync( p_peek, &b_dummy, false );
770 static int A52Probe( demux_t *p_demux, int64_t *pi_offset )
772 const char *ppsz_name[] = { "a52", "ac3", NULL };
773 const int pi_wav[] = { WAVE_FORMAT_PCM, WAVE_FORMAT_A52, WAVE_FORMAT_UNKNOWN };
775 return GenericProbe( p_demux, pi_offset, ppsz_name, A52CheckSyncProbe, VLC_A52_HEADER_SIZE, pi_wav );
778 static int A52Init( demux_t *p_demux )
780 demux_sys_t *p_sys = p_demux->p_sys;
782 p_sys->b_big_endian = false;
783 p_sys->i_packet_size = 1024;
785 const uint8_t *p_peek;
787 /* peek the begining */
788 if( stream_Peek( p_demux->s, &p_peek, VLC_A52_HEADER_SIZE ) >= VLC_A52_HEADER_SIZE )
790 A52CheckSync( p_peek, &p_sys->b_big_endian, true );
795 /*****************************************************************************
797 *****************************************************************************/
798 static int DtsCheckSync( const uint8_t *p_peek )
800 /* TODO return frame size for robustness */
802 /* 14 bits, little endian version of the bitstream */
803 if( p_peek[0] == 0xff && p_peek[1] == 0x1f &&
804 p_peek[2] == 0x00 && p_peek[3] == 0xe8 &&
805 (p_peek[4] & 0xf0) == 0xf0 && p_peek[5] == 0x07 )
809 /* 14 bits, big endian version of the bitstream */
810 else if( p_peek[0] == 0x1f && p_peek[1] == 0xff &&
811 p_peek[2] == 0xe8 && p_peek[3] == 0x00 &&
812 p_peek[4] == 0x07 && (p_peek[5] & 0xf0) == 0xf0)
816 /* 16 bits, big endian version of the bitstream */
817 else if( p_peek[0] == 0x7f && p_peek[1] == 0xfe &&
818 p_peek[2] == 0x80 && p_peek[3] == 0x01 )
822 /* 16 bits, little endian version of the bitstream */
823 else if( p_peek[0] == 0xfe && p_peek[1] == 0x7f &&
824 p_peek[2] == 0x01 && p_peek[3] == 0x80 )
832 static int DtsProbe( demux_t *p_demux, int64_t *pi_offset )
834 const char *ppsz_name[] = { "dts", NULL };
835 const int pi_wav[] = { WAVE_FORMAT_PCM, WAVE_FORMAT_DTS, WAVE_FORMAT_UNKNOWN };
837 return GenericProbe( p_demux, pi_offset, ppsz_name, DtsCheckSync, 11, pi_wav );
839 static int DtsInit( demux_t *p_demux )
841 demux_sys_t *p_sys = p_demux->p_sys;
843 p_sys->i_packet_size = 16384;
848 /*****************************************************************************
850 *****************************************************************************/
851 static int MlpCheckSync( const uint8_t *p_peek )
853 if( p_peek[4+0] != 0xf8 || p_peek[4+1] != 0x72 || p_peek[4+2] != 0x6f )
856 if( p_peek[4+3] != 0xba && p_peek[4+3] != 0xbb )
859 /* TODO checksum and real size for robustness */
862 static int MlpProbe( demux_t *p_demux, int64_t *pi_offset )
864 const char *ppsz_name[] = { "mlp", "thd", NULL };
865 const int pi_wav[] = { WAVE_FORMAT_PCM, WAVE_FORMAT_UNKNOWN };
867 return GenericProbe( p_demux, pi_offset, ppsz_name, MlpCheckSync, 4+28+16*4, pi_wav );
869 static int MlpInit( demux_t *p_demux )
872 demux_sys_t *p_sys = p_demux->p_sys;
874 p_sys->i_packet_size = 4096;