A computer-implemented method for compressing digital data includes obtaining a sequence of digital data values; mapping the sequence of digital data values to a sequence of code words having non-uniform bit lengths; packing the sequence of code words into a sequence of storage words having uniform bit length and corresponding to a fixed-size piece of data handled as a unit by the instruction set or the hardware of a processor; and outputting the sequence of storage words together with a first bitmask indicating the bit length of each code word, wherein in the method is implemented using special purpose vector instructions.