[xiph-commits] r13633 - in trunk/xiph-qt: . OggImport/src
arek at svn.xiph.org
arek at svn.xiph.org
Sun Aug 26 11:41:50 PDT 2007
Author: arek
Date: 2007-08-26 11:41:50 -0700 (Sun, 26 Aug 2007)
New Revision: 13633
Added:
trunk/xiph-qt/ChangeLog
Modified:
trunk/xiph-qt/OggImport/src/OggImport.c
trunk/xiph-qt/OggImport/src/importer_types.h
trunk/xiph-qt/OggImport/src/stream_theora.c
Log:
* OggImport/src/OggImport.c:
* OggImport/src/importer_types.h:
* OggImport/src/stream_theora.c:
Improve idle loading of files with video - uses slightly more
memory but all avoidable stalling is being avoided. Fixes #1151.
* ChangeLog:
Add the ChangeLog file.
Added: trunk/xiph-qt/ChangeLog
===================================================================
--- trunk/xiph-qt/ChangeLog (rev 0)
+++ trunk/xiph-qt/ChangeLog 2007-08-26 18:41:50 UTC (rev 13633)
@@ -0,0 +1,10 @@
+2007-08-26 Arek Korbik <arkadini at gmail.com>
+
+ * OggImport/src/OggImport.c:
+ * OggImport/src/importer_types.h:
+ * OggImport/src/stream_theora.c:
+ Improve idle loading of files with video - uses slightly more
+ memory but all avoidable stalling is being avoided. Fixes #1151.
+
+ * ChangeLog:
+ Add the ChangeLog file.
Modified: trunk/xiph-qt/OggImport/src/OggImport.c
===================================================================
--- trunk/xiph-qt/OggImport/src/OggImport.c 2007-08-26 14:31:40 UTC (rev 13632)
+++ trunk/xiph-qt/OggImport/src/OggImport.c 2007-08-26 18:41:50 UTC (rev 13633)
@@ -1134,6 +1134,29 @@
return ret;
}
+static Boolean ShouldFlush(OggImportGlobals *globals)
+{
+ Boolean ret = false;
+ UInt32 now = TickCount();
+
+ if (now > globals->tickFlushed + globals->flushStepCheck && GetMovieRate(globals->theMovie) != 0) {
+ // movie is currently playing:
+ // - if video is present don't commit sample refs until
+ // less than 5 seconds of playtime is left (QT will reset video decoder
+ // every time samples are added, QT is just nice like that)
+ // - if we only have audio - commit every flushStepNormal ticks, unless near the end of the
+ // currently loaded data - then just commit (practically - every flushStepCheck ticks)
+ if ((globals->timeLoaded - GetMovieTime(globals->theMovie, NULL) < globals->flushMinTimeLeft) ||
+ (!globals->hasVideoTrack && now > globals->tickFlushed + globals->flushStepNormal))
+ ret = true;
+ } else if (now > globals->tickFlushed + globals->flushStepNormal) {
+ // movie is not playing - commit sample refs every 'flushStepNormal' ticks
+ ret = true;
+ }
+
+ return ret;
+}
+
static ComponentResult XQTGetFileSize(OggImportGlobalsPtr globals);
static ComponentResult StateProcess(OggImportGlobalsPtr globals) {
@@ -1148,6 +1171,7 @@
dbg_printf(" - (:kStateInitial:)\n");
globals->dataOffset = globals->dataStartOffset;
globals->numTracksSeen = 0;
+ globals->hasVideoTrack = false;
globals->timeLoaded = 0;
globals->timeLoadedSubSecond = 0.0;
globals->tickFlushed = 0;
@@ -1244,7 +1268,7 @@
}
if (globals->usingIdle) {
- if (TickCount() > globals->tickFlushed + globals->flushStep)
+ if (ShouldFlush(globals))
FlushAllStreams(globals, false);
}
}
@@ -1868,7 +1892,10 @@
if (globals->usingIdle) {
globals->notifyStep = 420; // ~60 ticks per second
- globals->flushStep = 60;
+ globals->flushStepNormal = 90;
+ globals->flushStepCheck = 30;
+ // 5 seconds, assuming movie timescale is static
+ globals->flushMinTimeLeft = 5 * GetMovieTimeScale(globals->theMovie);
#if 1
err = JustStartImport(globals, dataRef, dataRefType);
#else
@@ -1907,7 +1934,7 @@
break;
case kStateReadingPages:
- if (globals->timeLoaded > 0) {
+ if (globals->timeLoaded > globals->flushMinTimeLeft) {
if (globals->sizeInitialised && S64Compare(globals->dataEndOffset, S64Set(-1)) == 0) {
*loadState = kMovieLoadStatePlaythroughOK;
} else if (globals->sizeInitialised && globals->totalTime > 0) {
@@ -1937,6 +1964,8 @@
} else {
*loadState = kMovieLoadStatePlayable;
}
+ } else if (globals->timeLoaded > 0) {
+ *loadState = kMovieLoadStatePlayable;
} else {
*loadState = kMovieLoadStateLoading;
}
Modified: trunk/xiph-qt/OggImport/src/importer_types.h
===================================================================
--- trunk/xiph-qt/OggImport/src/importer_types.h 2007-08-26 14:31:40 UTC (rev 13632)
+++ trunk/xiph-qt/OggImport/src/importer_types.h 2007-08-26 18:41:50 UTC (rev 13633)
@@ -200,12 +200,15 @@
int numTracksStarted;
int numTracksSeen; // completed tracks
Track firstTrack;
+ Boolean hasVideoTrack;
TimeValue timeLoaded;
Float64 timeLoadedSubSecond; // last second fraction remainder
UInt32 tickFlushed;
- UInt32 flushStep;
+ UInt32 flushStepCheck;
+ UInt32 flushStepNormal;
+ UInt32 flushMinTimeLeft;
UInt32 tickNotified;
UInt32 notifyStep;
Modified: trunk/xiph-qt/OggImport/src/stream_theora.c
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_theora.c 2007-08-26 14:31:40 UTC (rev 13632)
+++ trunk/xiph-qt/OggImport/src/stream_theora.c 2007-08-26 18:41:50 UTC (rev 13633)
@@ -204,6 +204,8 @@
si->theTrack = NewMovieTrack(globals->theMovie,
frame_width << 16 | (frame_width_fraction & 0xffff),
si->si_theora.ti.pic_height << 16, 0);
+ if (si->theTrack)
+ globals->hasVideoTrack = true;
return ret;
};
More information about the commits
mailing list