summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGregory Maxwell <greg@xiph.org>2010-03-29 05:35:11 +0000
committerGregory Maxwell <greg@xiph.org>2010-03-29 05:35:11 +0000
commiteb2fce499cd8a19bbf4bd821a8c78887bce84873 (patch)
treee0b1f2c856e7f794d49c809aaff648a94c55ff3a /src
parent88f38d57803e82f207020a5535adf9b214954633 (diff)
downloadogg-git-eb2fce499cd8a19bbf4bd821a8c78887bce84873.tar.gz
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.
svn path=/trunk/ogg/; revision=17098
Diffstat (limited to 'src')
-rw-r--r--src/framing.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/framing.c b/src/framing.c
index ca93036..e719ebc 100644
--- a/src/framing.c
+++ b/src/framing.c
@@ -369,7 +369,7 @@ int ogg_stream_packetin(ogg_stream_state *os,ogg_packet *op){
/* 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 @@ static int ogg_stream_flush_i(ogg_stream_state *os,ogg_page *og, int force){
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 @@ static int ogg_stream_flush_i(ogg_stream_state *os,ogg_page *og, int force){
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,7 +530,22 @@ int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og){
(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){