Package net.fec.openrq.decoder

Examples of net.fec.openrq.decoder.SourceBlockDecoder


            list.add(new Object[] {sbDec.information(), true});
        }

        for (SourceBlockEncoder sbEnc : dataEnc.sourceBlockIterable()) {
            final int K = sbEnc.numberOfSourceSymbols();
            final SourceBlockDecoder sbDec = dataDec.sourceBlock(sbEnc.sourceBlockNumber());

            for (int n = 0; n < K / 3; n++) {
                final EncodingPacket pac = sbEnc.sourcePacket(n);
                sbDec.putEncodingPacket(pac);
            }
            // insert decoder with a few source symbols
            list.add(new Object[] {sbDec.information(), true});

            for (int n = K; n < 3 * K / 2; n++) {
                final EncodingPacket pac = sbEnc.repairPacket(n);
                sbDec.putEncodingPacket(pac);
            }
            // insert decoder with a few source and repair symbols
            list.add(new Object[] {sbDec.information(), true});

            for (int n = 3 * K / 2;; n++) {
                final EncodingPacket pac = sbEnc.repairPacket(n);
                sbDec.putEncodingPacket(pac);
                if (sbDec.latestState() != SourceBlockState.INCOMPLETE) {
                    break;
                }
            }
            // insert decoder already decoded or with a decoding failure
            list.add(new Object[] {sbDec.information(), true});
        }

        final int KforZeroSBN = DataUtils.getK(FEC_PARAMS, 0);

        final Set<Integer> empty = Collections.emptySet();


        final byte[] data = TestingCommon.randomBytes(fecParams.dataLengthAsInt(), RAND);
        final ArrayDataEncoder enc = OpenRQ.newEncoder(data, fecParams);
        final ArrayDataDecoder dec = OpenRQ.newDecoder(fecParams, 0);

        for (SourceBlockEncoder sbEnc : enc.sourceBlockIterable()) {
            final SourceBlockDecoder sbDec = dec.sourceBlock(sbEnc.sourceBlockNumber());
            for (EncodingPacket srcPacket : sbEnc.sourcePacketsIterable()) {
                sbDec.putEncodingPacket(srcPacket);
            }
        }

        // compare the original and decoded data
        assertArrayEquals(data, dec.dataArray());

            SourceBlockState sbState = SourceBlockState.INCOMPLETE;

            // this should loop K times
            while (sbState == SourceBlockState.INCOMPLETE) {
                final EncodingPacket packet = sbEnc.encodingPacket(esiIter.next());
                final SourceBlockDecoder sbDec = dec.sourceBlock(packet.sourceBlockNumber());
                sbState = sbDec.putEncodingPacket(packet);
            }

            // if the decoding failed, we need more symbols
            while (sbState != SourceBlockState.DECODED && esiIter.hasNext()) {
                final EncodingPacket packet = sbEnc.encodingPacket(esiIter.next());
                final SourceBlockDecoder sbDec = dec.sourceBlock(packet.sourceBlockNumber());
                sbState = sbDec.putEncodingPacket(packet);
            }

            // if the source block is still not decoded, then we ignore this test
            Assume.assumeTrue(sbState == SourceBlockState.DECODED);
        }

TOP

Related Classes of net.fec.openrq.decoder.SourceBlockDecoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.