Commit 4313e0f9 authored by ogg.k.ogg.k's avatar ogg.k.ogg.k
Browse files

allow granpos to time as soon as the first header is decoded

parent 217defbc
......@@ -48,6 +48,7 @@ public class Info {
public byte version_minor;
public byte version_subminor;
public int keyframe_granule_shift;
public long keyframe_frequency_force;
/* codec_setup_info */
......@@ -108,7 +109,8 @@ public class Info {
target_bitrate = opb.readB(24);
quality = opb.readB(6);
keyframe_frequency_force = 1<<opb.readB(5);
keyframe_granule_shift = opb.readB(5);
keyframe_frequency_force = 1<<keyframe_granule_shift;
pixel_fmt = PixelFormat.formats[opb.readB(2)];
if (pixel_fmt==PixelFormat.TH_PF_RSVD)
......
......@@ -47,6 +47,7 @@ public class KateDec extends Element implements OggPayload
private long basetime = 0;
private long lastTs;
private boolean haveBOS = false;
private boolean haveDecoder = false;
/*
......@@ -71,6 +72,9 @@ public class KateDec extends Element implements OggPayload
public int takeHeader (Packet op)
{
int ret = ki.decodeHeader(kc, op);
if (ret >= 0) {
haveBOS = true;
}
if (ret > 0) {
k.decodeInit(ki);
Debug.debug("Kate decoder ready");
......
......@@ -37,6 +37,7 @@ public class TheoraDec extends Element implements OggPayload
private long lastTs;
private boolean needKeyframe;
private boolean haveBOS = false;
private boolean haveDecoder = false;
/*
......@@ -52,7 +53,10 @@ public class TheoraDec extends Element implements OggPayload
byte header;
ret = ti.decodeHeader(tc, op);
header = op.packet_base[op.packet];
if (header == -126) {
if (header == -128) {
haveBOS = true;
}
else if (header == -126) {
ts.decodeInit(ti);
haveDecoder = true;
}
......@@ -98,12 +102,14 @@ public class TheoraDec extends Element implements OggPayload
{
long res;
if (gp < 0 || !haveDecoder)
if (gp < 0 || !haveBOS)
return -1;
res = (long) (ts.granuleTime(gp) * Clock.SECOND);
long iframe=gp>>ti.keyframe_granule_shift;
long pframe=gp-(iframe<<ti.keyframe_granule_shift);
return res;
return (long)((iframe+pframe)*
((double)ti.fps_denominator/ti.fps_numerator) * Clock.SECOND);
}
private Pad srcPad = new Pad(Pad.SRC, "src") {
......
Supports Markdown
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