src/main/java/org/jcodec/codecs/h264/H264Utils.java
public static void wipePSinplace(ByteBuffer _in, Collection<ByteBuffer> spsList, Collection<ByteBuffer> ppsList) {
        ByteBuffer dup = _in.duplicate();
        while (dup.hasRemaining()) {
            ByteBuffer buf = H264Utils.nextNALUnit(dup);
            if (buf == null)
                break;

            NALUnit nu = NALUnit.read(buf);
            if (nu.type == NALUnitType.PPS) {
                if (ppsList != null)
                    ppsList.add(NIOUtils.duplicate(buf));
                _in.position(dup.position());
            } else if (nu.type == NALUnitType.SPS) {
                if (spsList != null)
                    spsList.add(NIOUtils.duplicate(buf));
                _in.position(dup.position());
            } else if (nu.type == NALUnitType.IDR_SLICE || nu.type == NALUnitType.NON_IDR_SLICE)
                break;
        }
    }
public static void wipePSinplace(ByteBuffer _in, Collection<ByteBuffer> spsList, Collection<ByteBuffer> ppsList) {
        ByteBuffer dup = _in.duplicate();
        while (dup.hasRemaining()) {
            ByteBuffer buf = H264Utils.nextNALUnit(dup);
            if (buf == null)
                break;

            NALUnit nu = NALUnit.read(buf);
            if (nu.type == NALUnitType.PPS) {
                if (ppsList != null)
                    ppsList.add(NIOUtils.duplicate(buf));
                _in.position(dup.position());
            } else if (nu.type == NALUnitType.SPS) {
                if (spsList != null)
                    spsList.add(NIOUtils.duplicate(buf));
                _in.position(dup.position());
            } else if (nu.type == NALUnitType.IDR_SLICE || nu.type == NALUnitType.NON_IDR_SLICE)
                break;
        }
    }
public static void wipePSinplace ( ByteBuffer _in , Collection < ByteBuffer > spsList , Collection < ByteBuffer > ppsList ) { ByteBuffer dup = _in . duplicate ( ) ; while ( dup . hasRemaining ( ) ) { ByteBuffer buf = H264Utils . nextNALUnit ( dup ) ; if ( buf == null ) break ; NALUnit nu = NALUnit . read ( buf ) ; if ( nu . type == NALUnitType . PPS ) { if ( ppsList != null ) ppsList . add ( NIOUtils . duplicate ( buf ) ) ; _in . position ( dup . position ( ) ) ; } else if ( nu . type == NALUnitType . SPS ) { if ( spsList != null ) spsList . add ( NIOUtils . duplicate ( buf ) ) ; _in . position ( dup . position ( ) ) ; } else if ( nu . type == NALUnitType . IDR_SLICE || nu . type == NALUnitType . NON_IDR_SLICE ) break ; } }
Wipes AVC parameter sets ( SPS/PPS ) from the packet ( inplace operation
)

@param in
AVC frame encoded in Annex B NAL unit format
@param spsList
Storage for leading SPS structures ( can be null, then all
leading SPSs are discarded ).
@param ppsList
Storage for leading PPS structures ( can be null, then all
leading PPSs are discarded ).
Wipes AVC parameter sets ( SPS / PPS ) from the packet ( inplace operation )