CPD Results

The following document contains the results of PMD's CPD 4.1.

Duplications

File Line
org\kc7bfi\jflac\io\BitInputStream.java 439
org\kc7bfi\jflac\io\BitInputStream.java 524
                while (true) {
                    if (state == 0) {
                        if (blurb != 0) {
                            for (j = 0; (blurb & BLURB_TOP_BIT_ONE) == 0; j++) blurb <<= 1;
                            msbs += j;
                            // dispose of the unary end bit
                            blurb <<= 1;
                            j++;
                            cbits += j;
                            uval = 0;
                            lsbsLeft = parameter;
                            state++;
                            //totalBitsRead += msbs;
                            if (cbits == BITS_PER_BLURB) {
                                cbits = 0;
                                readCRC16 = CRC16.update(saveBlurb, readCRC16);
                                break;
                            }
                        } else {
                            msbs += BITS_PER_BLURB - cbits;
                            cbits = 0;
                            readCRC16 = CRC16.update(saveBlurb, readCRC16);
                            //totalBitsRead += msbs;
                            break;
                        }
                    } else {
                        int availableBits = BITS_PER_BLURB - cbits;
                        if (lsbsLeft >= availableBits) {
                            uval <<= availableBits;
                            uval |= ((blurb & 0xff) >> cbits);
                            cbits = 0;
                            readCRC16 = CRC16.update(saveBlurb, readCRC16);
                            //totalBitsRead += availableBits;
                            if (lsbsLeft == availableBits) {
                                // compose the value
                                uval |= (msbs << parameter);
                                if ((uval & 1) != 0)
                                    vals[pos + valI++] = -((int) (uval >> 1)) - 1;
                                else
                                    vals[pos + valI++] = (int) (uval >> 1);
                                if (valI == nvals)
                                    break;
                                msbs = 0;
                                state = 0;
                            }
                            lsbsLeft -= availableBits;
                            break;
                        } else {
                            uval <<= lsbsLeft;
                            uval |= ((blurb & 0xff) >> (BITS_PER_BLURB - lsbsLeft));
                            blurb <<= lsbsLeft;
                            cbits += lsbsLeft;
                            //totalBitsRead += lsbsLeft;
                            // compose the value
                            uval |= (msbs << parameter);
                            if ((uval & 1) != 0)
                                vals[pos + valI++] = -((int) (uval >> 1)) - 1;
                            else
                                vals[pos + valI++] = (int) (uval >> 1);
                            if (valI == nvals) {
                                // back up one if we exited the for loop because
                                // we read all nvals but the end came in the
                                // middle of a blurb
                                i--;
                                break;
                            }
                            msbs = 0;
                            state = 0;
                        }
                    }
                }

File Line
org\kc7bfi\jflac\FixedPredictor.java 44
org\kc7bfi\jflac\FixedPredictor.java 108
        long totalError0 = 0, totalError1 = 0, totalError2 = 0, totalError3 = 0, totalError4 = 0;
        int i, order;
        
        for (i = 0; i < dataLen; i++) {
            error = data[i];
            totalError0 += Math.abs(error);
            save = error;
            error -= lastError0;
            totalError1 += Math.abs(error);
            lastError0 = save;
            save = error;
            error -= lastError1;
            totalError2 += Math.abs(error);
            lastError1 = save;
            save = error;
            error -= lastError2;
            totalError3 += Math.abs(error);
            lastError2 = save;
            save = error;
            error -= lastError3;
            totalError4 += Math.abs(error);
            lastError3 = save;
        }
        
        if (totalError0 < Math.min(Math.min(Math.min(totalError1, totalError2), totalError3), totalError4))
            order = 0;
        else if (totalError1 < Math.min(Math.min(totalError2, totalError3), totalError4))
            order = 1;
        else if (totalError2 < Math.min(totalError3, totalError4))
            order = 2;
        else if (totalError3 < totalError4)
            order = 3;
        else
            order = 4;
        
        // Estimate the expected number of bits per residual signal sample.
        // 'total_error*' is linearly related to the variance of the residual
        // signal, so we use it directly to compute E(|x|)
        // with VC++ you have to spoon feed it the casting
        residualBitsPerSample[0] = (double) ((totalError0 > 0) ? Math.log(M_LN2 * (double) (long) totalError0 / (double) dataLen) / M_LN2 : 0.0);

File Line
org\kc7bfi\jflac\io\BitInputStream.java 634
org\kc7bfi\jflac\io\BitInputStream.java 688
        if (((x & 0x80) == 0)) { // 0xxxxxxx
            v = x;
            i = 0;
        } else if (((x & 0xC0) != 0) && ((x & 0x20) == 0)) { // 110xxxxx
            v = x & 0x1F;
            i = 1;
        } else if (((x & 0xE0) != 0) && ((x & 0x10) == 0)) { // 1110xxxx
            v = x & 0x0F;
            i = 2;
        } else if (((x & 0xF0) != 0) && ((x & 0x08) == 0)) { // 11110xxx
            v = x & 0x07;
            i = 3;
        } else if (((x & 0xF8) != 0) && ((x & 0x04) == 0)) { // 111110xx
            v = x & 0x03;
            i = 4;
        } else if (((x & 0xFC) != 0) && ((x & 0x02) == 0)) { // 1111110x
            v = x & 0x01;
            i = 5;
        } else if (((x & 0xFE) != 0) && ((x & 0x01) == 0)) { // 11111110

File Line
org\kc7bfi\jflac\io\BitOutputStream.java 533
org\kc7bfi\jflac\io\BitOutputStream.java 541
            writeRawUInt(0x80 | (int) ((val >> 30) & 0x3F), 8);
            writeRawUInt(0x80 | (int) ((val >> 24) & 0x3F), 8);
            writeRawUInt(0x80 | (int) ((val >> 18) & 0x3F), 8);
            writeRawUInt(0x80 | (int) ((val >> 12) & 0x3F), 8);
            writeRawUInt(0x80 | (int) ((val >> 6) & 0x3F), 8);
            writeRawUInt(0x80 | (int) (val & 0x3F), 8);
        }