src/main/java/org/jcodec/codecs/common/biari/Packed4BitList.java
public static int set(int list, int val, int n) {
        int cnt = (list >> 28) & 0xf;
        int newc = n + 1;
        cnt = newc > cnt ? newc : cnt;
        return (list & CLEAR_MASK[n]) | ((val & 0xff) << (n << 2)) | (cnt << 28);
    }
public static int set(int list, int val, int n) {
        int cnt = (list >> 28) & 0xf;
        int newc = n + 1;
        cnt = newc > cnt ? newc : cnt;
        return (list & CLEAR_MASK[n]) | ((val & 0xff) << (n << 2)) | (cnt << 28);
    }
Sets a 4 bit value into the list

@param list
@param val
@param n
@return