[xiph-commits] r16093 - in trunk/xiph-qt: . OggImport/src Theora/src

arek at svn.xiph.org arek at svn.xiph.org
Mon Jun 8 16:16:40 PDT 2009


Author: arek
Date: 2009-06-08 16:16:39 -0700 (Mon, 08 Jun 2009)
New Revision: 16093

Modified:
   trunk/xiph-qt/ChangeLog
   trunk/xiph-qt/OggImport/src/stream_theora.c
   trunk/xiph-qt/Theora/src/TheoraDecoder.c
Log:
	* Theora/src/TheoraDecoder.c:
	Properly resize the packet buffer when necessary - fixes playback
	of HD content (or anything containing compressed Theora frames
	bigger than 64kB).
	* OggImport/src/stream_theora.c:
	Tune the segmentation/duration hack values to handle HD content
	better.



Modified: trunk/xiph-qt/ChangeLog
===================================================================
--- trunk/xiph-qt/ChangeLog	2009-06-08 10:40:08 UTC (rev 16092)
+++ trunk/xiph-qt/ChangeLog	2009-06-08 23:16:39 UTC (rev 16093)
@@ -1,3 +1,14 @@
+2009-06-09  Arek Korbik  <arkadini at gmail.com>
+
+	* Theora/src/TheoraDecoder.c:
+	Properly resize the packet buffer when necessary - fixes playback
+	of HD content (or anything containing compressed Theora frames
+	bigger than 64kB).
+
+	* OggImport/src/stream_theora.c:
+	Tune the segmentation/duration hack values to handle HD content
+	better.
+
 2009-05-24  Arek Korbik  <arkadini at gmail.com>
 
 	* OggExport/src/OggExport.c:

Modified: trunk/xiph-qt/OggImport/src/stream_theora.c
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_theora.c	2009-06-08 10:40:08 UTC (rev 16092)
+++ trunk/xiph-qt/OggImport/src/stream_theora.c	2009-06-08 23:16:39 UTC (rev 16093)
@@ -46,9 +46,9 @@
 #include "samplerefs.h"
 
 
-#define MAX_FPS_DENOMINATOR 198
-#define DESIRED_MULTIPLIER 197
-#define SEGMENT_RATIO_DENOM 3
+#define MAX_FPS_DENOMINATOR 16384
+#define DESIRED_MULTIPLIER 16383
+#define SEGMENT_RATIO_DENOM 5
 
 
 #if TARGET_OS_WIN32

Modified: trunk/xiph-qt/Theora/src/TheoraDecoder.c
===================================================================
--- trunk/xiph-qt/Theora/src/TheoraDecoder.c	2009-06-08 10:40:08 UTC (rev 16092)
+++ trunk/xiph-qt/Theora/src/TheoraDecoder.c	2009-06-08 23:16:39 UTC (rev 16093)
@@ -87,6 +87,42 @@
 #endif /* __APPLE_CC__ */
 
 
+OSErr grow_buffer(Theora_Globals glob, UInt32 min_size) {
+    /* increase the size of the packet buffer, in
+       kPacketBufferAllocIncrement blocks, preserving the content of
+       the used part of the buffer */
+    OSErr err = noErr;
+    UInt32 new_size = glob->p_buffer_len;
+
+    dbg_printf("--:Theora:-  _grow_buffer(%08lx, %ld)\n", (long)glob, min_size);
+
+    while (new_size < min_size)
+        new_size += kPacketBufferAllocIncrement;
+
+    /* first try to resize in-place */
+    SetPtrSize((Ptr) glob->p_buffer, new_size);
+
+    if (err = MemError()) {
+        /* resizing failed: allocate new block, memcpy, release the old block */
+        Ptr p = NewPtr(new_size);
+        if (err = MemError()) goto bail;
+
+        BlockMoveData(glob->p_buffer, p, glob->p_buffer_used);
+
+        DisposePtr((Ptr) glob->p_buffer);
+        glob->p_buffer = (UInt8 *) p;
+    }
+
+    glob->p_buffer_len = new_size;
+
+ bail:
+    if (err)
+        dbg_printf("--:Theora:-  _grow_buffer(%08lx, %ld) failed = %d\n", (long)glob, min_size, err);
+
+    return err;
+}
+
+
 OSErr init_theora_decoder(Theora_Globals glob, CodecDecompressParams *p)
 {
     OSErr err = noErr;
@@ -428,9 +464,10 @@
             if (!memcmp(dataPtr + myDrp->dataSize - 4, "OggS", 4)) {
                 do_decode = false;
                 if (myDrp->dataSize - 4 + glob->p_buffer_used > glob->p_buffer_len) {
-                    dbg_printf("         !!! CodecDecodeBand(): NOT IMPLEMENTED - reallocate with resize!\n");
-                    err = codecErr;
-                } else {
+                    err = grow_buffer(glob, myDrp->dataSize - 4 + glob->p_buffer_used);
+                }
+                /* if the we failed to resize, the "frame" will get dropped anyway, otherwise... */
+                if (!err) {
                     BlockMoveData(dataPtr, glob->p_buffer + glob->p_buffer_used, myDrp->dataSize - 4);
                     glob->p_buffer_used += myDrp->dataSize - 4;
                 }



More information about the commits mailing list