oggdemux: handle theora streams with 0 keyoffset

This commit is contained in:
David Schleef 2009-11-25 17:04:41 -08:00
parent a8e99f80df
commit d2c9d7fc1c
2 changed files with 23 additions and 1 deletions

View file

@ -299,6 +299,26 @@ setup_theora_mapper (GstOggStream * pad, ogg_packet * packet)
return TRUE;
}
static gint64
granulepos_to_granule_theora (GstOggStream * pad, gint64 granulepos)
{
gint64 keyindex, keyoffset;
if (pad->granuleshift != 0) {
keyindex = granulepos >> pad->granuleshift;
keyoffset = granulepos - (keyindex << pad->granuleshift);
if (keyoffset == 0) {
pad->theora_has_zero_keyoffset = TRUE;
}
if (pad->theora_has_zero_keyoffset) {
keyoffset++;
}
return keyindex + keyoffset;
} else {
return granulepos;
}
}
static gboolean
is_keyframe_theora (GstOggStream * pad, gint64 granulepos)
{
@ -944,7 +964,7 @@ static const GstOggMap mappers[] = {
"\200theora", 7, 42,
"video/x-theora",
setup_theora_mapper,
granulepos_to_granule_default,
granulepos_to_granule_theora,
granule_to_granulepos_default,
is_keyframe_theora,
is_header_theora,

View file

@ -63,6 +63,8 @@ struct _GstOggStream
int vorbis_log2_num_modes;
int vorbis_mode_sizes[256];
int last_size;
/* theora stuff */
gboolean theora_has_zero_keyoffset;
};