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:
Sat Feb 02 01:18:15 2013 +0000
Parent:
5:85e99ec2e7b5
Commit message:
aanIDCT add range_limit()

Changed in this revision

aanIDCT.cpp Show annotated file Show diff for this revision Revisions of this file
inverseDCT.h Show annotated file Show diff for this revision Revisions of this file
diff -r 85e99ec2e7b5 -r d7ee458cacd1 aanIDCT.cpp
--- a/aanIDCT.cpp	Sun Jan 27 11:00:50 2013 +0000
+++ b/aanIDCT.cpp	Sat Feb 02 01:18:15 2013 +0000
@@ -1,4 +1,4 @@
-// aanIDCT.cpp
+// aanIDCT.cpp 2013/2/1
 // based: http://www.ijg.org/ libjpeg(jpeg-8d)jidctfst.c jidctflt.c jidctmgr.c
 #include "mbed.h"
 #include "aanIDCT.h"
@@ -48,6 +48,26 @@
     return DESCALE(x, PASS1_BITS+LOG2_CONST);
 }
 
+#if 1
+int8_t range_limit(int val) {
+    if (val < -128) {
+        return -128;
+    } else if (val > 127) {
+        return 127;
+    }
+    return val;
+}
+#else
+inline int8_t range_limit(int val) {
+    if (val < -128) {
+        return -128;
+    } else if (val > 127) {
+        return 127;
+    }
+    return val;
+}
+#endif
+
 void aanIDCT::conv(int8_t output[], int16_t input[])
 {
     uint16_t* quant = (uint16_t*)aanscales;
@@ -117,7 +137,7 @@
                ws[pos+7] == 0) {
             int dcval = ws[pos+0];
             for(int x = 0; x < DCTSIZE; x++) {
-                output[pos+x] = IDESCALE(dcval);
+                output[pos+x] = range_limit(IDESCALE(dcval));
             }
             continue;
         }
@@ -150,13 +170,13 @@
         int tmp5 = tmp11 - tmp6;
         int tmp4 = tmp10 - tmp5;
 
-        output[pos+0] = IDESCALE(tmp0 + tmp7);
-        output[pos+7] = IDESCALE(tmp0 - tmp7);
-        output[pos+1] = IDESCALE(tmp1 + tmp6);
-        output[pos+6] = IDESCALE(tmp1 - tmp6);
-        output[pos+2] = IDESCALE(tmp2 + tmp5);
-        output[pos+5] = IDESCALE(tmp2 - tmp5);
-        output[pos+3] = IDESCALE(tmp3 + tmp4);
-        output[pos+4] = IDESCALE(tmp3 - tmp4);
+        output[pos+0] = range_limit(IDESCALE(tmp0 + tmp7));
+        output[pos+7] = range_limit(IDESCALE(tmp0 - tmp7));
+        output[pos+1] = range_limit(IDESCALE(tmp1 + tmp6));
+        output[pos+6] = range_limit(IDESCALE(tmp1 - tmp6));
+        output[pos+2] = range_limit(IDESCALE(tmp2 + tmp5));
+        output[pos+5] = range_limit(IDESCALE(tmp2 - tmp5));
+        output[pos+3] = range_limit(IDESCALE(tmp3 + tmp4));
+        output[pos+4] = range_limit(IDESCALE(tmp3 - tmp4));
     }
 }
diff -r 85e99ec2e7b5 -r d7ee458cacd1 inverseDCT.h
--- a/inverseDCT.h	Sun Jan 27 11:00:50 2013 +0000
+++ b/inverseDCT.h	Sat Feb 02 01:18:15 2013 +0000
@@ -1,3 +1,4 @@
+// inverseDCT.h 2013/1/28
 #ifndef INVERSE_DCT_H
 #define INVERSE_DCT_H