[vlc-devel] [PATCH 2/4] demux: ogg: fix find_first_granule for packets that span multiple pages
Michael Tänzer
neo at nhng.de
Sun Jan 31 00:29:23 CET 2016
If the granulepos is negative we need to pagein the page nevertheless
because it might contain a packet that is continued on the next page. Also
we want to return the position of the first page containing the packet.
---
modules/demux/oggseek.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/modules/demux/oggseek.c b/modules/demux/oggseek.c
index d5b6f49..104954d 100644
--- a/modules/demux/oggseek.c
+++ b/modules/demux/oggseek.c
@@ -334,7 +334,6 @@ static int64_t find_first_page_granule( demux_t *p_demux,
*i_granulepos = -1;
int64_t i_bytes_to_read = i_pos2 - i_pos1 + 1;
int64_t i_bytes_read;
- int64_t i_pages_checked = 0;
int64_t i_packets_checked;
demux_sys_t *p_sys = p_demux->p_sys;
@@ -407,23 +406,22 @@ static int64_t find_first_page_granule( demux_t *p_demux,
return p_sys->i_input_position;
}
- if ( ogg_page_granulepos( &p_sys->current_page ) <= 0 )
+ // found a page
+ if ( ogg_stream_pagein( &p_stream->os, &p_sys->current_page ) != 0 )
{
+ /* page is not for this stream or incomplete */
p_sys->i_input_position += i_result;
- i_bytes_to_read += OGGSEEK_BYTES_TO_READ;
continue;
}
- // found a page
- if ( ogg_stream_pagein( &p_stream->os, &p_sys->current_page ) != 0 )
+ if ( ogg_page_granulepos( &p_sys->current_page ) <= 0 )
{
- /* page is not for this stream or incomplete */
+ /* A negative granulepos means that the packet continues on the
+ * next page => read the next page */
p_sys->i_input_position += i_result;
- if ( ! i_pages_checked ) i_pos1 = p_sys->i_input_position;
continue;
}
- i_pages_checked++;
i_packets_checked = 0;
while ( ogg_stream_packetout( &p_stream->os, &op ) > 0 )
@@ -439,6 +437,7 @@ static int64_t find_first_page_granule( demux_t *p_demux,
/* -> start of next page */
p_sys->i_input_position += i_result;
+ i_pos1 = p_sys->i_input_position;
}
}
--
2.5.0
More information about the vlc-devel
mailing list