#define VORBIS_HEADER_SETUP 3
#define VORBIS_HEADER_TO_FLAG(i) (1 << (i - 1))
#define VORBIS_HEADERS_VALID(p_stream) \
- ((p_stream->special.vorbis.i_headers_flags & 0b111) == 0b111)
+ ((p_stream->special.vorbis.i_headers_flags & 0x07) == 0x07) // 0b111
/*****************************************************************************
* Local prototypes
}
if( Ogg_BeginningOfStream( p_demux ) != VLC_SUCCESS )
- return 0;
+ return VLC_DEMUXER_EOF;
msg_Dbg( p_demux, "beginning of a group of logical streams" );
* Demux an ogg page from the stream
*/
if( Ogg_ReadPage( p_demux, &p_sys->current_page ) != VLC_SUCCESS )
- return 0; /* EOF */
+ return VLC_DEMUXER_EOF; /* EOF */
/* Test for End of Stream */
if( ogg_page_eos( &p_sys->current_page ) )
{
}
}
- return 1;
+ return VLC_DEMUXER_SUCCESS;
}
static void Ogg_ResetStream( logical_stream_t *p_stream )
}
else if( p_stream->fmt.i_cat == AUDIO_ES )
{
+ if ( p_stream->fmt.i_codec == VLC_CODEC_FLAC &&
+ p_stream->p_es && 0 >= p_oggpacket->granulepos &&
+ p_stream->fmt.b_packetized )
+ {
+ /* Handle OggFlac spec violation (multiple frame/packet
+ * by turning on packetizer */
+ msg_Warn( p_demux, "Invalid FLAC in ogg detected. Restarting ES with packetizer." );
+ p_stream->fmt.b_packetized = false;
+ es_out_Del( p_demux->out, p_stream->p_es );
+ p_stream->p_es = es_out_Add( p_demux->out, &p_stream->fmt );
+ }
+
/* Blatant abuse of the i_length field. */
p_block->i_length = p_stream->i_end_trim;
}
i_header_len = (*p_oggpacket->packet & PACKET_LEN_BITS01) >> 6;
i_header_len |= (*p_oggpacket->packet & PACKET_LEN_BITS2) << 1;
+ if( i_header_len >= p_oggpacket->bytes )
+ {
+ msg_Dbg( p_demux, "discarding invalid packet" );
+ block_Release( p_block );
+ return;
+ }
+
if( p_stream->fmt.i_codec == VLC_CODEC_SUBT)
{
/* But with subtitles we need to retrieve the duration first */