CSJ2K.j2k.entropy.decoder.StdEntropyDecoder.conceal C# (CSharp) Метод

conceal() приватный Метод

Conceals decoding errors detected in the last bit-plane. The concealement resets the state of the decoded data to what it was before the decoding of bit-plane 'bp' started. No more data should be decoded after this method is called for this code-block's data to which it is applied.
private conceal ( CSJ2K.j2k.image.DataBlk cblk, int bp ) : void
cblk CSJ2K.j2k.image.DataBlk The code-block's data /// ///
bp int The last decoded bit-plane (which contains errors). /// ///
Результат void
        private void conceal(DataBlk cblk, int bp)
        {
            int l; // line index
            int k; // array index
            int kmax; // 'k' limit
            int dk; // Value of data[k]
            int[] data; // the data array
            int setmask; // Bitmask to set approximation to 1/2 of
            // known interval on significant data
            int resetmask; // Bitmask to erase all the data from
            // bit-plane 'bp'

            // Initialize masks
            setmask = 1 << bp;
            resetmask = (- 1) << (bp);

            // Get the data array
            data = (int[]) cblk.Data;

            // Visit each sample, apply the reset mask to it and add an
            // approximation if significant.
            for (l = cblk.h - 1, k = cblk.offset; l >= 0; l--)
            {
                for (kmax = k + cblk.w; k < kmax; k++)
                {
                    dk = data[k];
                    if ((dk & resetmask & 0x7FFFFFFF) != 0)
                    {
                        // Something was decoded in previous bit-planes => set the
                        // approximation for previous bit-plane
                        data[k] = (dk & resetmask) | setmask;
                    }
                    else
                    {
                        // Was insignificant in previous bit-planes = set to zero
                        data[k] = 0;
                    }
                }
                k += cblk.scanw - cblk.w;
            }
        }