void save_bucket(const ColorBucket &b, SimpleSymbolCoder<FLIFBitChanceMeta, RacOut<IO>, 18> &coder, const ColorRanges *srcRanges, const int plane, const prevPlanes &pixelL, const prevPlanes &pixelU) const { if (plane<3) for (int p=0; p<plane; p++) { if (!cb->exists(p,pixelL,pixelU)) { if (!b.empty()) {printf("\nBucket does not exist but is not empty!\n"); assert(false);} return; } } ColorVal smin,smax; minmax(srcRanges,plane,pixelL,pixelU,smin,smax); if (b.min > b.max) { coder.write_int(0, 1, 0); // empty bucket return; } else coder.write_int(0, 1, 1); // non-empty bucket if (smin==smax) { return;} coder.write_int(smin, smax, b.min); coder.write_int(b.min, smax, b.max); if (b.min == b.max) return; // singleton bucket if (b.min + 1 == b.max) return; // bucket contains two consecutive values coder.write_int(0, 1, b.discrete); if (b.discrete) { assert((int)b.values.size() < b.max-b.min+1); // no discrete buckets that are completely full coder.write_int(2, std::min((int)max_per_colorbucket[plane],b.max-b.min), b.values.size()); ColorVal v=b.min; int nb = b.values.size(); for (int p=1; p < nb - 1; p++) { coder.write_int(v+1, b.max+1-nb+p, b.values[p]); v = b.values[p]; } } }
void save_bucket(const ColorBucket &b, SimpleSymbolCoder<FLIFBitChanceMeta, RacOut<IO>, 24> &coder, const ColorRanges *srcRanges, const int plane, const prevPlanes &pixelL, const prevPlanes &pixelU) const { if (plane<3) for (int p=0; p<plane; p++) { if (!cb->exists(p,pixelL,pixelU)) { if (!b.empty()) {printf("\nBucket does not exist but is not empty!\n"); assert(false);} return; } } // SimpleBitCoder<FLIFBitChanceMeta, RacOut> bcoder(rac); // if (b.min > b.max) printf("SHOULD NOT HAPPEN!\n"); ColorVal smin,smax; minmax(srcRanges,plane,pixelL,pixelU,smin,smax); if (smin==smax) { return;} // b.printshort(); // b.print(); if (b.min > b.max) { coder.write_int(0, 1, 0); // empty bucket return; } else coder.write_int(0, 1, 1); // non-empty bucket coder.write_int(smin, smax, b.min); coder.write_int(b.min, smax, b.max); if (b.min == b.max) return; // singleton bucket if (b.min + 1 == b.max) return; // bucket contains two consecutive values coder.write_int(0, 1, b.discrete); if (b.discrete) { coder.write_int(2, max_per_colorbucket[plane], b.values.size()); ColorVal v=b.min; /* if (b.values.size() > 10) { v++; bcoder.set( 0x1000 * (b.values.size()-2) / (b.max-b.min-1) ); for (unsigned int p=1; p < b.values.size() - 1; p++) { while (v<b.values[p]) { bcoder.write(0); v++; } bcoder.write(1); v++; } } else */ for (unsigned int p=1; p < b.values.size() - 1; p++) { coder.write_int(v+1, b.max-1, b.values[p]); // coder.write_int(0, b.max-v-2, b.values[p]-v-1); v = b.values[p]; } } }