[xiph-commits] r17098 - in trunk/ogg: include/ogg src
gmaxwell at svn.xiph.org
gmaxwell at svn.xiph.org
Sun Mar 28 22:35:11 PDT 2010
Author: gmaxwell
Date: 2010-03-28 22:35:11 -0700 (Sun, 28 Mar 2010)
New Revision: 17098
Modified:
trunk/ogg/include/ogg/ogg.h
trunk/ogg/src/framing.c
Log:
Add a 'ogg_stream_pageout_fill' function to allow smart applications with delay sensitive flushing to produce big pages. Increase the default minimum fill amount to 8 based on latency measurements with actual files. These changes may be controversial but since we've recently had a release I thought there would be no harm in getting them into the repository for discussion.
Modified: trunk/ogg/include/ogg/ogg.h
===================================================================
--- trunk/ogg/include/ogg/ogg.h 2010-03-29 02:14:55 UTC (rev 17097)
+++ trunk/ogg/include/ogg/ogg.h 2010-03-29 05:35:11 UTC (rev 17098)
@@ -159,6 +159,7 @@
extern int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov,
int count, long e_o_s, ogg_int64_t granulepos);
extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
+extern int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int nfill);
extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og);
/* Ogg BITSTREAM PRIMITIVES: decoding **************************/
Modified: trunk/ogg/src/framing.c
===================================================================
--- trunk/ogg/src/framing.c 2010-03-29 02:14:55 UTC (rev 17097)
+++ trunk/ogg/src/framing.c 2010-03-29 05:35:11 UTC (rev 17098)
@@ -369,7 +369,7 @@
/* Conditionally flush a page; force==0 will only flush nominal-size
pages, force==1 forces us to flush a page regardless of page size
so long as there's any data available at all. */
-static int ogg_stream_flush_i(ogg_stream_state *os,ogg_page *og, int force){
+static int ogg_stream_flush_i(ogg_stream_state *os,ogg_page *og, int force, int nfill){
int i;
int vals=0;
int maxvals=(os->lacing_fill>255?255:os->lacing_fill);
@@ -407,7 +407,7 @@
int packets_done=0;
int packet_just_done=0;
for(vals=0;vals<maxvals;vals++){
- if(acc>4096 && packet_just_done>=4){
+ if(acc>nfill && packet_just_done>=8){
force=1;
break;
}
@@ -515,7 +515,7 @@
an page regardless of size in the middle of a stream. */
int ogg_stream_flush(ogg_stream_state *os,ogg_page *og){
- return ogg_stream_flush_i(os,og,1);
+ return ogg_stream_flush_i(os,og,1,4096);
}
/* This constructs pages from buffered packet segments. The pointers
@@ -530,9 +530,24 @@
(os->lacing_fill&&!os->b_o_s)) /* 'initial header page' case */
force=1;
- return(ogg_stream_flush_i(os,og,force));
+ return(ogg_stream_flush_i(os,og,force,4096));
}
+/* Like the above, but an argument is provided to adjust the nominal
+page size for applications which are smart enough to provide their
+own delay based flushing */
+
+int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int nfill){
+ int force=0;
+ if(ogg_stream_check(os)) return 0;
+
+ if((os->e_o_s&&os->lacing_fill) || /* 'were done, now flush' case */
+ (os->lacing_fill&&!os->b_o_s)) /* 'initial header page' case */
+ force=1;
+
+ return(ogg_stream_flush_i(os,og,force,nfill));
+}
+
int ogg_stream_eos(ogg_stream_state *os){
if(ogg_stream_check(os)) return 1;
return os->e_o_s;
More information about the commits
mailing list