Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: BaseJpegDecode_example SimpleJpegDecode_example Dumb_box_rev2
Revision 6:d7ee458cacd1, committed 2013-02-02
- 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 |
--- 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));
}
}
--- 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