shithub: h264bsd

Download patch

ref: 8320437df0136b146b2de73d4e74e904607831f7
parent: b60f5cc63ee8e58d04c50a337ddb777ef05486d5
author: Sam Leitch <sam@luceva.net>
date: Wed Mar 19 05:03:05 EDT 2014

Removed compiled swc. Added FPS status panel to flex test.

diff: cannot open a/flex/lib//null: file does not exist: 'a/flex/lib//null'
--- a/.gitignore
+++ b/.gitignore
@@ -10,4 +10,5 @@
 *.suo
 flex/bin/
 *.swf
+*.swc
 .settings
--- a/flex/Makefile
+++ b/flex/Makefile
@@ -33,4 +33,4 @@
 	"$(FLEX)/bin/mxmlc" -static-link-runtime-shared-libraries -compiler.omit-trace-statements=false -library-path+=bin/h264bsd.swc -library-path+=$(FLEX)/frameworks/libs/ -debug=true test/h264test.mxml -o test/h264test.swf
 
 clean:
-	rm -f test/*.swf lib/*.swc bin/*.swc *.bc *.exe
+	rm -f *.swc *.swf bin/*.swc *.bc *.exe test/*.swf lib/*.swc
binary files a/flex/lib/h264bsd_asm.swc /dev/null differ
--- a/flex/src/h264bsd/Decoder.as
+++ b/flex/src/h264bsd/Decoder.as
@@ -62,7 +62,7 @@
         }
         
         public function queueInput(data:ByteArray):void {
-            if(data == null) return;
+            if(data == null || data.bytesAvailable <= 0) return;
             
             if(_inputPtr != 0) {
                 var combinedData:ByteArray = new ByteArray();
--- a/flex/test/h264test.mxml
+++ b/flex/test/h264test.mxml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                xmlns:s="library://ns.adobe.com/flex/spark" 
-               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
+               xmlns:mx="library://ns.adobe.com/flex/mx">
     <fx:Script>
         <![CDATA[
             import h264bsd.CroppingInfo;
@@ -43,6 +43,7 @@
                     switch(result)
                     {
                         case Decoder.NO_INPUT:
+                            data.position = 0;
                             decoder.queueInput(data);
                             setTimeout(loopBody, 0);
                             break;
@@ -53,6 +54,7 @@
                             break;
                         case Decoder.PIC_RDY:
                             decoder.drawNextOutputPicture(renderTarget.bitmapData);
+                            ++frameCount;
                             setTimeout(loopBody, 0);
                             break;
                         case Decoder.RDY:
@@ -59,16 +61,36 @@
                             loopBody();
                             break;
                         default:
-                            trace("An error has occured in the decoder");
-                            loopBody();
+                            throw new Error("An error has occured in the decoder");
                             break;
                     }
                 }
+
+                var lastUpdateTime:int = getTimer();
+                var lastFrameCount:int = 0;
+                var frameCount:int = 0;
+                setInterval(updateStatus, 1000);
+
+                function updateStatus():void {
+                    var updateTime:int = getTimer();
+                    var interval:int = updateTime - lastUpdateTime;
+                    lastUpdateTime = updateTime;
+
+                    var frameCountSinceLast:int = frameCount - lastFrameCount;
+                    lastFrameCount = frameCount;
+
+                    var frameRate:Number = frameCountSinceLast * 1000 / interval;
+
+                    statusLabel.text = "FPS: " + frameRate.toFixed(2);
+                }
             }
         ]]>
     </fx:Script>
     
     <s:VGroup id="main">
-        <s:Button label="Load File" click="loadFile()"/>
+        <s:HGroup id="statusPanel" verticalAlign="middle">
+            <s:Button label="Load File" click="loadFile()"/>
+            <s:Label id="statusLabel"/>
+        </s:HGroup>
     </s:VGroup>
 </s:Application>