protected int sync_header(byte [] stream){
        int offset = 0;
        
        for(; offset < stream.length; offset++)
            if(stream[offset] == -1 &&
                ((stream[offset+1] & 0xf0) >>> 4)
                == 0xf && (stream[offset+1]&0xf ) != 0xf)
                break;
        
        return offset;
    }