Exemplo n.º 1
0
    const ColorBucket load_bucket(SimpleSymbolCoder<FLIFBitChanceMeta, RacIn<IO>, 18> &coder, const ColorRanges *srcRanges, const int plane, const prevPlanes &pixelL, const prevPlanes &pixelU) const {
        ColorBucket b;
        if (plane<3)
        for (int p=0; p<plane; p++) {
                if (!cb->exists(p,pixelL,pixelU)) return b;
        }
//        SimpleBitCoder<FLIFBitChanceMeta, RacIn> bcoder(rac);

        ColorVal smin,smax;
        minmax(srcRanges,plane,pixelL,pixelU,smin,smax);

        int exists = coder.read_int(0, 1);
        if (exists == 0) {
           return b; // empty bucket
        }
        if (smin == smax) {b.min = b.max = smin; b.discrete=false; return b;}
        b.min = coder.read_int(smin, smax);
        b.max = coder.read_int(b.min, smax);
        if (b.min == b.max) { b.discrete=false; return b; }
        if (b.min + 1 == b.max) { b.discrete=false; return b; }
        b.discrete = coder.read_int(0,1);
        if (b.discrete) {
           int nb = coder.read_int(2, std::min((int)max_per_colorbucket[plane],b.max-b.min));
           b.values.push_back(b.min);
           ColorVal v=b.min;
             for (int p=1; p < nb-1; p++) {
               b.values.push_back(coder.read_int(v+1, b.max+1-nb+p));
               v = b.values[p];
             }
           if (b.min < b.max) b.values.push_back(b.max);
        }
        return b;
    }
Exemplo n.º 2
0
    ColorBucket load_bucket(SimpleSymbolCoder<FLIFBitChanceMeta, RacIn<IO>, 24> &coder, const ColorRanges *srcRanges, const int plane, const prevPlanes &pixelL, const prevPlanes &pixelU) {
        ColorBucket b;
        if (plane<3)
        for (int p=0; p<plane; p++) {
                if (!cb->exists(p,pixelL,pixelU)) return b;
        }
//        SimpleBitCoder<FLIFBitChanceMeta, RacIn> bcoder(rac);

        ColorVal smin,smax;
        minmax(srcRanges,plane,pixelL,pixelU,smin,smax);
        if (smin == smax) {b.min = b.max = smin; b.discrete=false; return b;}

        int exists = coder.read_int(0, 1);
        if (exists == 0) {
           return b; // empty bucket
        }
        b.min = coder.read_int(smin, smax);
        b.max = coder.read_int(b.min, smax);
        if (b.min == b.max) { b.discrete=false; return b; }
        if (b.min + 1 == b.max) { b.discrete=false; return b; }
        b.discrete = coder.read_int(0,1);
        if (b.discrete) {
           int nb = coder.read_int(2, max_per_colorbucket[plane]);
           b.values.push_back(b.min);
           ColorVal v=b.min;
/*           if (nb > 10) {
             v++;
             bcoder.set( 0x1000 * (nb-2) / (b.max-b.min-1) );
             for (int p=1; p < nb - 1; p++) {
               while (bcoder.read() == 0) { v++; }
               b.values.push_back(v); v++;
             }
           } else */
             for (int p=1; p < nb-1; p++) {
               b.values.push_back(coder.read_int(v+1, b.max-1));
//               b.values.push_back(v+1+coder.read_int(0, b.max-v-2));
//               printf("val %i\n",b.values[p]);
               v = b.values[p];
             }
           if (b.min < b.max) b.values.push_back(b.max);
        }
//        b.print();
        return b;
    }