記録追加
@@ -249,7 +249,7 @@ | ||
249 | 249 | unsigned char riceCoderParam; |
250 | 250 | |
251 | 251 | size_t srcCount; |
252 | - size_t signFlagsLen; | |
252 | + size_t signFlagsCount; | |
253 | 253 | size_t initialCompressedLen; |
254 | 254 | size_t riceCodedLen; |
255 | 255 | size_t compressedLen; |
@@ -488,7 +488,7 @@ | ||
488 | 488 | for (size_t i=0; i<8; ++i) { |
489 | 489 | size_t blockSize = 1 + i * 2; |
490 | 490 | CompressInfo& ci = compressInfos[i]; |
491 | - | |
491 | + int oldCount = count; | |
492 | 492 | int mini = boost::integer_traits<int>::const_max; |
493 | 493 | int maxi = boost::integer_traits<int>::const_min; |
494 | 494 |
@@ -526,7 +526,7 @@ | ||
526 | 526 | ci.mini = mini; |
527 | 527 | ci.maxi = maxi; |
528 | 528 | ci.max = std::max(maxi, std::abs(mini)); |
529 | - | |
529 | + ci.signFlagsCount = count - oldCount; | |
530 | 530 | from += srcCount; |
531 | 531 | } |
532 | 532 | return count; |
@@ -67,9 +67,8 @@ | ||
67 | 67 | CompressInfo compressInfos[8] = {0}; |
68 | 68 | |
69 | 69 | Quantizer quantizer; |
70 | - quantizer.init(6*8+0, 0, 0, false); | |
70 | + quantizer.init(6*8+0, 0, 0, true); | |
71 | 71 | |
72 | - size_t zeroOneLimit = 1; | |
73 | 72 | size_t totalLen = 0; |
74 | 73 | |
75 | 74 | // TODO: to design stream byte formats and various JYEIPEGYUU stream classes and implement serialize methods. |
@@ -99,20 +98,26 @@ | ||
99 | 98 | unsigned char* pSignFlags = &signFlags[0]; |
100 | 99 | size_t signFlagCount = collectInfos(pWork2, totalBlockCount, pSignFlags, compressInfos); |
101 | 100 | |
101 | + size_t zeroOneLimit = 2; | |
102 | 102 | std::vector<unsigned char> zeroOneInfos(totalBlockCount); |
103 | 103 | unsigned char* pZeroOneInfos = &zeroOneInfos[0]; |
104 | - findZeroOneInfos(hBlockCount, vBlockCount, pWork2, &zeroOneInfos[0], zeroOneLimit); | |
105 | 104 | |
106 | 105 | // TODO: to record quantizing zero one limit setting |
107 | 106 | |
108 | 107 | // quantizing zero one flags |
109 | - BitWriter bw(dest+4); | |
110 | - for (size_t i=0; i<totalBlockCount; ++i) { | |
111 | - bw.putBit(pZeroOneInfos[i]); | |
108 | + *dest++ = zeroOneLimit; | |
109 | + if (zeroOneLimit != 0) { | |
110 | + findZeroOneInfos(hBlockCount, vBlockCount, pWork2, &zeroOneInfos[0], zeroOneLimit); | |
111 | + BitWriter bw(dest+4); | |
112 | + for (size_t i=0; i<totalBlockCount; ++i) { | |
113 | + bw.putBit(pZeroOneInfos[i]); | |
114 | + } | |
115 | + *((uint32_t*)dest) = bw.nBytes(); | |
116 | + dest += 4; | |
117 | + dest += bw.nBytes(); | |
118 | + }else { | |
119 | + pZeroOneInfos = 0; | |
112 | 120 | } |
113 | - *((uint32_t*)dest) = bw.nBytes(); | |
114 | - dest += 4; | |
115 | - dest += bw.nBytes(); | |
116 | 121 | dest += compress(compressor, hBlockCount, vBlockCount, pZeroOneInfos, zeroOneLimit, compressInfos, pWork2, (unsigned char*)pWork, &work3[0], &work4[0], dest, encoded.size()); |
117 | 122 | |
118 | 123 | // TODO: to record DCT coefficients sign predictor setting |
@@ -143,19 +148,23 @@ | ||
143 | 148 | size_t destLen = work2.size(); |
144 | 149 | |
145 | 150 | // zero one flags |
146 | - uint32_t zeroOneFlagBytes = *(uint32_t*)src; | |
147 | - src += 4; | |
151 | + unsigned char zeroOneLimit = *src++; | |
148 | 152 | std::vector<unsigned char> zeroOneFlags(totalBlockCount); |
149 | 153 | unsigned char* pZeroOneFlags = &zeroOneFlags[0]; |
150 | - { | |
151 | - BitReader reader(src); | |
152 | - assert(totalBlockCount <= zeroOneFlagBytes*8); | |
153 | - for (size_t i=0; i<zeroOneFlagBytes*8; ++i) { | |
154 | - zeroOneFlags[i] = reader.getBit(); | |
154 | + if (zeroOneLimit != 0) { | |
155 | + uint32_t zeroOneFlagBytes = *(uint32_t*)src; | |
156 | + src += 4; | |
157 | + { | |
158 | + BitReader reader(src); | |
159 | + assert(totalBlockCount <= zeroOneFlagBytes*8); | |
160 | + for (size_t i=0; i<zeroOneFlagBytes*8; ++i) { | |
161 | + zeroOneFlags[i] = reader.getBit(); | |
162 | + } | |
155 | 163 | } |
164 | + src += zeroOneFlagBytes; | |
165 | + }else { | |
166 | + pZeroOneFlags = 0; | |
156 | 167 | } |
157 | - src += zeroOneFlagBytes; | |
158 | - | |
159 | 168 | src += decompress(compressor, hBlockCount, vBlockCount, pZeroOneFlags, zeroOneLimit, src, compressedLen, &tmp[0], pWork, pWork2, destLen); |
160 | 169 | |
161 | 170 | // sign flags |