int tq = (reference[ofs] & 0xFF) % 16; int pq = (reference[ofs] & 0xFF) / 16;
int tq = reference[ofs] & 0xF; int pq = (reference[ofs] & 0xFF) >> 4;
public int[] getQuantizationTablesKeys() {	int[] keys = new int[4];	int keysIndex = 0;	int totalLength = getSegmentLength() - 2;	int ofs = 4;	while (totalLength > 64) {		int tq = (reference[ofs] & 0xFF) % 16;		int pq = (reference[ofs] & 0xFF) / 16;		if (pq == 0) {			ofs += 65;			totalLength -= 65;		} else {			ofs += 129;			totalLength -= 129;		}		if (keysIndex >= keys.length) {			int[] newKeys = new int[keys.length + 4];			System.arraycopy(keys, 0, newKeys, 0, keys.length);			keys = newKeys;		}		keys[keysIndex] = tq;		keysIndex++;	}	int[] newKeys = new int[keysIndex];	System.arraycopy(keys, 0, newKeys, 0, keysIndex);	return newKeys;}