[xiph-commits] r7918 - experimental/derf/theora-exp/examples
tterribe at motherfish-iii.xiph.org
tterribe at motherfish-iii.xiph.org
Wed Oct 6 14:42:03 PDT 2004
Author: tterribe
Date: 2004-10-06 14:42:03 -0700 (Wed, 06 Oct 2004)
New Revision: 7918
Modified:
experimental/derf/theora-exp/examples/dump_video.c
experimental/derf/theora-exp/examples/player_example.c
Log:
Fix some header packet handling.
- ogg_stream_packetpeek only fails when a hole is encountered, which is normal
in e.g., a network stream when you connect in mid-broadcast.
- Don't pull in an extra page after we find the first Theora data packet, as
there might be only one in a very short stream.
Also, we now tell libtheoradec about the timestamps on packets when we have
them, like the mainline player_example does.
In reality, we should only have to do this after a seek or a hole in the data,
and we should backtrack from the last packet in a page to the first to assign
a timestamp to the very first frame after such an event.
Modified: experimental/derf/theora-exp/examples/dump_video.c
===================================================================
--- experimental/derf/theora-exp/examples/dump_video.c 2004-10-06 14:07:55 UTC (rev 7917)
+++ experimental/derf/theora-exp/examples/dump_video.c 2004-10-06 21:42:03 UTC (rev 7918)
@@ -217,11 +217,7 @@
/* look for further theora headers */
while(theora_processing_headers&&(ret=ogg_stream_packetpeek(&to,&op))){
- if(ret<0){
- fprintf(stderr,
- "Error parsing Theora stream headers; corrupt stream?\n");
- exit(1);
- }
+ if(ret<0)continue;
theora_processing_headers=theora_decode_headerin(&ti,&tc,&ts,&op);
if(theora_processing_headers<0){
printf("Error parsing Theora stream headers; corrupt stream?\n");
@@ -234,6 +230,10 @@
theora_p++;
}
+ /*Stop now so we don't fail if there aren't enough pages in a short
+ stream.*/
+ if(!(theora_p && theora_processing_headers))break;
+
/* The header pages/packets will arrive before anything else we
care about, or the stream is not obeying spec */
Modified: experimental/derf/theora-exp/examples/player_example.c
===================================================================
--- experimental/derf/theora-exp/examples/player_example.c 2004-10-06 14:07:55 UTC (rev 7917)
+++ experimental/derf/theora-exp/examples/player_example.c 2004-10-06 21:42:03 UTC (rev 7918)
@@ -521,11 +521,7 @@
/* look for further theora headers */
while(theora_processing_headers&&(ret=ogg_stream_packetpeek(&to,&op))){
- if(ret<0){
- fprintf(stderr,
- "Error parsing Theora stream headers; corrupt stream?\n");
- exit(1);
- }
+ if(ret<0)continue;
theora_processing_headers=theora_decode_headerin(&ti,&tc,&ts,&op);
if(theora_processing_headers<0){
printf("Error parsing Theora stream headers; corrupt stream?\n");
@@ -552,6 +548,10 @@
if(vorbis_p==3)break;
}
+ /*Stop now so we don't fail if there aren't enough pages in a short
+ stream.*/
+ if(!(theora_p&&theora_processing_headers)&&!(vorbis_p&&vorbis_p<3))break;
+
/* The header pages/packets will arrive before anything else we
care about, or the stream is not obeying spec */
@@ -665,6 +665,16 @@
sizeof(pp_level));
pp_inc=0;
}
+ /*HACK: This should be set after a seek or a gap, but we might not have
+ a granulepos for the first packet (we only have them for the last
+ packet on a page), so we just set it as often as we get it.
+ To do this right, we should back-track from the last packet on the
+ page and compute the correct granulepos for the first packet after
+ a seek or a gap.*/
+ if(op.granulepos>=0){
+ theora_decoder_ctl(td,OC_DECCTL_SET_GRANPOS,&op.granulepos,
+ sizeof(op.granulepos));
+ }
if(theora_decode_packetin(td,&op,&videobuf_granulepos)>=0){
videobuf_time=theora_granule_time(td,videobuf_granulepos);
More information about the commits
mailing list