test
Dependencies: Nanopb iSerial mbed BaseJpegDecode FatFileSystem SDFileSystem RingBuffer Camera_LS_Y201
extlib/BaseJpegDecode/inverseDCT.cpp@0:d69efd0ee139, 2014-09-18 (annotated)
- Committer:
- cgraham
- Date:
- Thu Sep 18 15:21:47 2014 +0000
- Revision:
- 0:d69efd0ee139
test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cgraham | 0:d69efd0ee139 | 1 | #include "mbed.h" |
cgraham | 0:d69efd0ee139 | 2 | #include "inverseDCT.h" |
cgraham | 0:d69efd0ee139 | 3 | |
cgraham | 0:d69efd0ee139 | 4 | #ifdef USE_IDCT_AAN |
cgraham | 0:d69efd0ee139 | 5 | const int zigzag[64] = |
cgraham | 0:d69efd0ee139 | 6 | {0, |
cgraham | 0:d69efd0ee139 | 7 | 1, 8, |
cgraham | 0:d69efd0ee139 | 8 | 16, 9, 2, |
cgraham | 0:d69efd0ee139 | 9 | 3,10,17,24, |
cgraham | 0:d69efd0ee139 | 10 | 32,25,18,11, 4, |
cgraham | 0:d69efd0ee139 | 11 | 5,12,19,26,33,40, |
cgraham | 0:d69efd0ee139 | 12 | 48,41,34,27,20,13,6, |
cgraham | 0:d69efd0ee139 | 13 | 7,14,21,28,35,42,49,56, |
cgraham | 0:d69efd0ee139 | 14 | 57,50,43,36,29,22,15, |
cgraham | 0:d69efd0ee139 | 15 | 23,30,37,44,51,58, |
cgraham | 0:d69efd0ee139 | 16 | 59,52,45,38,31, |
cgraham | 0:d69efd0ee139 | 17 | 39,46,53,60, |
cgraham | 0:d69efd0ee139 | 18 | 61,54,47, |
cgraham | 0:d69efd0ee139 | 19 | 55,62, |
cgraham | 0:d69efd0ee139 | 20 | 63}; |
cgraham | 0:d69efd0ee139 | 21 | |
cgraham | 0:d69efd0ee139 | 22 | void inverseDCT::inputBLOCK(int mcu, int block, int scan, int value) { |
cgraham | 0:d69efd0ee139 | 23 | if (scan == 0) { |
cgraham | 0:d69efd0ee139 | 24 | for(int i = 0; i < 64; i++) { |
cgraham | 0:d69efd0ee139 | 25 | m_s[i] = 0; |
cgraham | 0:d69efd0ee139 | 26 | } |
cgraham | 0:d69efd0ee139 | 27 | } |
cgraham | 0:d69efd0ee139 | 28 | m_s[zigzag[scan]] = value; |
cgraham | 0:d69efd0ee139 | 29 | if (scan == 63) { // last |
cgraham | 0:d69efd0ee139 | 30 | idct.conv(reinterpret_cast<int8_t*>(m_s), m_s); |
cgraham | 0:d69efd0ee139 | 31 | outputBLOCK(mcu, block, reinterpret_cast<int8_t*>(m_s)); |
cgraham | 0:d69efd0ee139 | 32 | } |
cgraham | 0:d69efd0ee139 | 33 | }; |
cgraham | 0:d69efd0ee139 | 34 | #endif //USE_IDCT_AAN |
cgraham | 0:d69efd0ee139 | 35 | |
cgraham | 0:d69efd0ee139 | 36 | #ifdef USE_IDCT_TABLE |
cgraham | 0:d69efd0ee139 | 37 | #include "inverseDCT_table.h" |
cgraham | 0:d69efd0ee139 | 38 | void inverseDCT::inputBLOCK(int mcu, int block, int scan, int value) |
cgraham | 0:d69efd0ee139 | 39 | { |
cgraham | 0:d69efd0ee139 | 40 | if (scan == 0) { |
cgraham | 0:d69efd0ee139 | 41 | int t = value * 32 / 8; |
cgraham | 0:d69efd0ee139 | 42 | for(int i = 0; i < 64; i++) { |
cgraham | 0:d69efd0ee139 | 43 | m_sum[i] = t; |
cgraham | 0:d69efd0ee139 | 44 | } |
cgraham | 0:d69efd0ee139 | 45 | return; |
cgraham | 0:d69efd0ee139 | 46 | } |
cgraham | 0:d69efd0ee139 | 47 | |
cgraham | 0:d69efd0ee139 | 48 | if (value != 0) { |
cgraham | 0:d69efd0ee139 | 49 | for(int xy = 0; xy < 64; xy++) { |
cgraham | 0:d69efd0ee139 | 50 | m_sum[xy] += idct_table[scan*64+xy] * value / 16; |
cgraham | 0:d69efd0ee139 | 51 | } |
cgraham | 0:d69efd0ee139 | 52 | } |
cgraham | 0:d69efd0ee139 | 53 | |
cgraham | 0:d69efd0ee139 | 54 | if (scan == 63) { |
cgraham | 0:d69efd0ee139 | 55 | int8_t* result = reinterpret_cast<int8_t*>(m_sum); |
cgraham | 0:d69efd0ee139 | 56 | for(int i = 0; i < 64; i++) { |
cgraham | 0:d69efd0ee139 | 57 | int t = m_sum[i] / 32; |
cgraham | 0:d69efd0ee139 | 58 | if (t > 127) { |
cgraham | 0:d69efd0ee139 | 59 | t = 127; |
cgraham | 0:d69efd0ee139 | 60 | } else if (t < -128) { |
cgraham | 0:d69efd0ee139 | 61 | t = -128; |
cgraham | 0:d69efd0ee139 | 62 | } |
cgraham | 0:d69efd0ee139 | 63 | result[i] = t; |
cgraham | 0:d69efd0ee139 | 64 | } |
cgraham | 0:d69efd0ee139 | 65 | outputBLOCK(mcu, block, result); |
cgraham | 0:d69efd0ee139 | 66 | } |
cgraham | 0:d69efd0ee139 | 67 | } |
cgraham | 0:d69efd0ee139 | 68 | #endif //USE_IDCT_TABLE |