Home | History | Annotate | Download | only in formats

Lines Matching refs:idx

25    * Read a signed byte from the idx into the raw array.
27 public static long getSignedByteFromByte(byte[] raw, int idx) {
28 return (long) raw[idx];
32 * Read an unsigned byte from the idx into the raw array.
34 public static long getUnsignedByteFromByte(byte[] raw, int idx) {
35 return ((long) raw[idx]) & 0xff;
39 * Read an unsigned lower 4 bits from the idx into the raw array.
41 public static long getUnsignedLowNibbleFromByte(byte[] raw, int idx) {
42 return ((long) raw[idx]) & 0xf;
46 * Read an unsigned higher 4 bits from the idx into the raw array.
48 public static long getUnsignedHighNibbleFromByte(byte[] raw, int idx) {
49 return (((long) raw[idx]) >> 4) & 0xf;
53 * Read an unsigned 2 bytes as a short from the idx into the raw array.
55 public static long getUnsignedShortFromTwoBytes(byte[] raw, int idx) {
56 return (long) ( (((long) raw[idx]) & 0xff)
57 | ((((long) raw[idx + 1]) & 0xff) << 8));
61 * Read a signed 2 bytes as a short from the idx into the raw array.
63 public static long getSignedShortFromTwoBytes(byte[] raw, int idx) {
64 return (long) ( (((long) raw[idx]) & 0xff)
65 | (((long) raw[idx + 1]) << 8));
69 * Read an unsigned 4 bytes as an int from the idx into the raw array.
71 public static long getUnsignedIntFromFourBytes(byte[] raw, int idx) {
72 return (long) ( (((long) raw[idx]) & 0xff)
73 | ((((long) raw[idx + 1]) & 0xff) << 8)
74 | ((((long) raw[idx + 2]) & 0xff) << 16)
75 | ((((long) raw[idx + 3]) & 0xff) << 24) );
79 * Read a signed 4 bytes as an int from the idx into the raw array.
81 public static long getSignedIntFromFourBytes(byte[] raw, int idx) {
82 return (long) ( (((long) raw[idx]) & 0xff)
83 | ((((long) raw[idx + 1]) & 0xff) << 8)
84 | ((((long) raw[idx + 2]) & 0xff) << 16)
85 | (((long) raw[idx + 3]) << 24) );
89 * Read a signed 8 bytes as a long from the idx into the raw array.
91 public static long getSignedLongFromEightBytes(byte[] raw, int idx) {
92 return (long) ( (((long) raw[idx]) & 0xff)
93 | ((((long) raw[idx + 1]) & 0xff) << 8)
94 | ((((long) raw[idx + 2]) & 0xff) << 16)
95 | ((((long) raw[idx + 3]) & 0xff) << 24)
96 | ((((long) raw[idx + 4]) & 0xff) << 32)
97 | ((((long) raw[idx + 5]) & 0xff) << 40)
98 | ((((long) raw[idx + 6]) & 0xff) << 48)
99 | (((long) raw[idx + 7]) << 56) );
103 * Given an idx into a raw array, and an int, write that int into the array at that position.
105 public static void writeUnsignedIntToFourBytes(byte[] raw, int idx, int value) {
106 raw[idx] = (byte) (value & 0xFF);
107 raw[idx + 1] = (byte) ((value & 0xFF00) >>> 8);
108 raw[idx + 2] = (byte) ((value & 0xFF0000) >>> 16);
109 raw[idx + 3] = (byte) ((value & 0xFF000000) >>> 24);
113 * Given an idx into a raw array, and a short, write that int into the array at that position.
115 public static void writeUnsignedShortToTwoBytes(byte[] raw, int idx, int value) {
116 raw[idx] = (byte) (value & 0xFF);
117 raw[idx + 1] = (byte) ((value & 0xFF00) >>> 8);