huffmancode to decode in real-time for motion-jpeg

Dependents:   BaseJpegDecode_example SimpleJpegDecode_example Dumb_box_rev2

example code:

Import programBaseJpegDecode_example

BaseJpegDeocde exampe program

Import programSimpleJpegDecode_example

convert JPEG stream data to bitmap, BaseJpegDecode example program

Files at this revision

API Documentation at this revision

Comitter:
va009039
Date:
Wed Dec 05 12:38:56 2012 +0000
Parent:
3:a7547692071d
Child:
5:85e99ec2e7b5
Commit message:
bug fix

Changed in this revision

BaseJpegDecode.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/BaseJpegDecode.cpp	Mon Nov 05 22:47:05 2012 +0000
+++ b/BaseJpegDecode.cpp	Wed Dec 05 12:38:56 2012 +0000
@@ -9,7 +9,7 @@
 #define DBG_WAIT(A)
 #endif
 
-#if 1
+#if 0
 #define DBG_ASSERT(A) while(!(A)){fprintf(stderr,"\n\n%s@%d %s ASSERT!\n\n",__PRETTY_FUNCTION__,__LINE__,#A);exit(1);};
 #else
 #define DBG_ASSERT(A) 
@@ -49,6 +49,9 @@
     clear();
     pHD = new HuffmanDecode;
     DBG_ASSERT(pHD);
+    if (pHD == NULL) {
+        return;
+    }
     qt[0] = new uint8_t[64];
     qt[1] = new uint8_t[64];
     DBG_ASSERT(qt[0]);
@@ -84,7 +87,11 @@
         m_param1 = c;
         DBG_ASSERT(m_param1 == 0 || m_param1 == 1);
     } else {
-        qt[m_param1][(pos%65)-1] = c;
+        if (m_param1 == 0 || m_param1 == 1) { 
+            if(qt[m_param1]) {
+                qt[m_param1][(pos%65)-1] = c;
+            }
+        }
     }
 }