• R/O
  • SSH
  • HTTPS

jyeipegyuu: Commit


Commit MetaInfo

Révision11 (tree)
l'heure2009-09-06 23:25:32
Auteurberupon

Message de Log

記録追加

Change Summary

Modification

--- misc.h (revision 10)
+++ misc.h (revision 11)
@@ -249,7 +249,7 @@
249249 unsigned char riceCoderParam;
250250
251251 size_t srcCount;
252- size_t signFlagsLen;
252+ size_t signFlagsCount;
253253 size_t initialCompressedLen;
254254 size_t riceCodedLen;
255255 size_t compressedLen;
@@ -488,7 +488,7 @@
488488 for (size_t i=0; i<8; ++i) {
489489 size_t blockSize = 1 + i * 2;
490490 CompressInfo& ci = compressInfos[i];
491-
491+ int oldCount = count;
492492 int mini = boost::integer_traits<int>::const_max;
493493 int maxi = boost::integer_traits<int>::const_min;
494494
@@ -526,7 +526,7 @@
526526 ci.mini = mini;
527527 ci.maxi = maxi;
528528 ci.max = std::max(maxi, std::abs(mini));
529-
529+ ci.signFlagsCount = count - oldCount;
530530 from += srcCount;
531531 }
532532 return count;
--- main.cpp (revision 10)
+++ main.cpp (revision 11)
@@ -67,9 +67,8 @@
6767 CompressInfo compressInfos[8] = {0};
6868
6969 Quantizer quantizer;
70- quantizer.init(6*8+0, 0, 0, false);
70+ quantizer.init(6*8+0, 0, 0, true);
7171
72- size_t zeroOneLimit = 1;
7372 size_t totalLen = 0;
7473
7574 // TODO: to design stream byte formats and various JYEIPEGYUU stream classes and implement serialize methods.
@@ -99,20 +98,26 @@
9998 unsigned char* pSignFlags = &signFlags[0];
10099 size_t signFlagCount = collectInfos(pWork2, totalBlockCount, pSignFlags, compressInfos);
101100
101+ size_t zeroOneLimit = 2;
102102 std::vector<unsigned char> zeroOneInfos(totalBlockCount);
103103 unsigned char* pZeroOneInfos = &zeroOneInfos[0];
104- findZeroOneInfos(hBlockCount, vBlockCount, pWork2, &zeroOneInfos[0], zeroOneLimit);
105104
106105 // TODO: to record quantizing zero one limit setting
107106
108107 // 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;
112120 }
113- *((uint32_t*)dest) = bw.nBytes();
114- dest += 4;
115- dest += bw.nBytes();
116121 dest += compress(compressor, hBlockCount, vBlockCount, pZeroOneInfos, zeroOneLimit, compressInfos, pWork2, (unsigned char*)pWork, &work3[0], &work4[0], dest, encoded.size());
117122
118123 // TODO: to record DCT coefficients sign predictor setting
@@ -143,19 +148,23 @@
143148 size_t destLen = work2.size();
144149
145150 // zero one flags
146- uint32_t zeroOneFlagBytes = *(uint32_t*)src;
147- src += 4;
151+ unsigned char zeroOneLimit = *src++;
148152 std::vector<unsigned char> zeroOneFlags(totalBlockCount);
149153 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+ }
155163 }
164+ src += zeroOneFlagBytes;
165+ }else {
166+ pZeroOneFlags = 0;
156167 }
157- src += zeroOneFlagBytes;
158-
159168 src += decompress(compressor, hBlockCount, vBlockCount, pZeroOneFlags, zeroOneLimit, src, compressedLen, &tmp[0], pWork, pWork2, destLen);
160169
161170 // sign flags
Afficher sur ancien navigateur de dépôt.