File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -53,14 +53,24 @@ class UInt12Array {
5353 memcpy (&word, data + firstBytePos, sizeof (uint32_t ));
5454 return word >> ((index & 1 ) << 2 );
5555 }
56+
5657 void bulkSet (uint16_t * source, size_t length) {
57- for (size_t i = 0 , j = 0 ; i < length;) {
58+ size_t volume_needed = (length / 2 )*3 + (length % 1 ) * 2 ;
59+ assert (volume_needed <= byteCount);
60+ size_t i = 0 , j = 0 ;
61+ for (; i + 1 < length;) {
5862 uint32_t a = source[i++];
5963 uint32_t b = source[i++];
6064 data[j++] = (uint8_t ) (a);
6165 data[j++] = (uint8_t ) ((a >> 8 ) | (b << 4 ));
6266 data[j++] = (uint8_t ) (b >> 4 );
6367 }
68+ if (i < length) {
69+ uint32_t a = source[i++];
70+ uint32_t b = 0 ; // duh
71+ data[j++] = (uint8_t ) (a);
72+ data[j++] = (uint8_t ) ((a >> 8 ) | (b << 4 ));
73+ }
6474 }
6575 inline void set (size_t index, uint32_t value) {
6676 size_t wordpos = (index >> 1 ) * 3 ;
You can’t perform that action at this time.
0 commit comments