Commit a5533c21 authored by Vincent Penquerc'h's avatar Vincent Penquerc'h Committed by Wim Taymans

oggstream: fix interpretation of Theora granule position

The offset part of the granpos is not a sign of the newer encoding.
Use the version number instead.

This fixes the criticals thrown by theoraparse, and (at last) the
remaining part of #553244.
parent 60ff7c0e
......@@ -342,6 +342,11 @@ setup_theora_mapper (GstOggStream * pad, ogg_packet * packet)
{
guint8 *data = packet->packet;
guint w, h, par_d, par_n;
guint8 vmaj, vmin, vrev;
vmaj = data[7];
vmin = data[8];
vrev = data[9];
w = GST_READ_UINT24_BE (data + 14) & 0xFFFFFF;
h = GST_READ_UINT24_BE (data + 17) & 0xFFFFFF;
......@@ -371,6 +376,12 @@ setup_theora_mapper (GstOggStream * pad, ogg_packet * packet)
return FALSE;
}
/* The interpretation of the granule position has changed with 3.2.1.
The granule is now made from the number of frames encoded, rather than
the index of the frame being encoded - so three is a difference of 1. */
pad->theora_has_zero_keyoffset =
((vmaj << 16) | (vmin << 8) | vrev) < 0x030201;
pad->caps = gst_caps_new_simple ("video/x-theora", NULL);
if (w > 0 && h > 0) {
......@@ -398,9 +409,6 @@ granulepos_to_granule_theora (GstOggStream * pad, gint64 granulepos)
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++;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment