shithub: h264bsd

Download patch

ref: 82f78dd71211b2cbce2e48ca776959fbf8e74736
parent: 2c655d6217273efb79b3be8aa9570404206373cc
author: Sam Leitch <sam.leitch@calgaryscientific.com>
date: Tue May 6 06:06:40 EDT 2014

Reset the decoder and input stream for each loop of ios. Added notes to README to indicate why it's a good idea.

--- a/README.md
+++ b/README.md
@@ -6,12 +6,19 @@
 
 The intention is to provide a simple H.264 decoder that can be easily invoked from [ffi](http://en.wikipedia.org/wiki/Foreign_function_interface) systems.
 
+## Implementation Notes
+
+Currently, the process of decoding data modifies the data. This has tripped me a a few times in the past, so others should be aware of it.
+
+The decoder only works nicely if it has a single consistent stream to deal with. If you want to change the width/height or restart the stream with a new access unit delimiter, it's better to shutdown and recreate a new decoder.
+
 ## Directories
 
 * *src* The modified source.
 * *test* Contains test data available for all platforms.
-* *win* Visual Studio project files for building.
+* *win* Visual Studio project files and test application.
 * *js* JavaScript version of the library created using [emscripten](http://emscripten.org/).
+* *ios* XCode project and objective-c wrapper classes.
 * *flex* ActionScript version of the library built using [CrossBridge](http://adobe-flash.github.io/crossbridge/).
 
 This project was heavily inspired by [Broadway.js](https://github.com/mbebenita/Broadway). Much love to them for pioneering the idea.
--- a/ios/test/h264bsd Test/ViewController.m
+++ b/ios/test/h264bsd Test/ViewController.m
@@ -125,7 +125,11 @@
         status = [self.decoder decode:self.videoData offset:self.offset length:length bytesRead:&bytesRead];
         
         self.offset += bytesRead;
-        if(self.offset >= self.videoData.length) self.offset = 0;
+        if(self.offset >= self.videoData.length) {
+            self.offset = 0;
+            [self loadVideoData]; // The decoder modifies the in memory data. Better flush it.
+            [self initializeDecoder]; // The decoder doesn't like the new stream discontinuity. Better refresh it.
+        }
     }
     
     [self.view setNeedsDisplay];