diff --git a/.github/workflows/miri.sh b/.github/workflows/miri.sh new file mode 100755 index 000000000000..27c6f5eecc87 --- /dev/null +++ b/.github/workflows/miri.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# +# Script +# +# Must be run with nightly rust for example +# rustup default nightly + + +export MIRIFLAGS="-Zmiri-disable-isolation" +cargo miri setup +cargo clean + +run_miri() { + # Currently only the arrow crate is tested with miri + # IO related tests and some unsupported tests are skipped + cargo miri test -p arrow -- --skip csv --skip ipc --skip json +} + +# If MIRI fails, automatically retry +# Seems like miri is occasionally killed by the github runner +# https://github.com/apache/arrow-rs/issues/879 +for i in `seq 1 5`; do + echo "Starting Arrow MIRI run..." + run_miri && break + echo "foo" > /tmp/data.txt +done diff --git a/.github/workflows/miri.yaml b/.github/workflows/miri.yaml index 136b0e136008..bcbb48ed31fc 100644 --- a/.github/workflows/miri.yaml +++ b/.github/workflows/miri.yaml @@ -23,25 +23,17 @@ on: pull_request: jobs: - miri-checks: name: MIRI runs-on: ubuntu-latest strategy: matrix: arch: [amd64] - rust: [nightly-2021-07-04] + rust: [nightly-2021-10-23] steps: - uses: actions/checkout@v2 with: submodules: true - - uses: actions/cache@v2 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-miri-${{ hashFiles('**/Cargo.lock') }} - name: Setup Rust toolchain run: | rustup toolchain install ${{ matrix.rust }} @@ -50,11 +42,6 @@ jobs: - name: Run Miri Checks env: RUST_BACKTRACE: full - RUST_LOG: 'trace' + RUST_LOG: "trace" run: | - export MIRIFLAGS="-Zmiri-disable-isolation" - cargo miri setup - cargo clean - # Currently only the arrow crate is tested with miri - # IO related tests and some unsupported tests are skipped - cargo miri test -p arrow -- --skip csv --skip ipc --skip json + bash .github/workflows/miri.sh diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 20392efa5102..1f062d20f1f3 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -267,6 +267,11 @@ jobs: - uses: actions/checkout@v2 with: submodules: true + - name: Setup Rust toolchain + run: | + rustup toolchain install ${{ matrix.rust }} + rustup default ${{ matrix.rust }} + rustup component add rustfmt clippy - name: Cache Cargo uses: actions/cache@v2 with: @@ -287,6 +292,8 @@ jobs: export ARROW_TEST_DATA=$(pwd)/testing/data export PARQUET_TEST_DATA=$(pwd)/parquet-testing/data + rustup toolchain install stable + rustup default stable cargo install --version 0.18.2 cargo-tarpaulin cargo tarpaulin --all --out Xml - name: Report coverage diff --git a/arrow-flight/Cargo.toml b/arrow-flight/Cargo.toml index 4b50f4e5b9e9..256272284502 100644 --- a/arrow-flight/Cargo.toml +++ b/arrow-flight/Cargo.toml @@ -19,7 +19,8 @@ name = "arrow-flight" description = "Apache Arrow Flight" version = "7.0.0-SNAPSHOT" -edition = "2018" +edition = "2021" +rust-version = "1.56" authors = ["Apache Arrow "] homepage = "https://github.com/apache/arrow-rs" repository = "https://github.com/apache/arrow-rs" @@ -28,20 +29,20 @@ license = "Apache-2.0" [dependencies] arrow = { path = "../arrow", version = "7.0.0-SNAPSHOT" } base64 = "0.13" -tonic = "0.5" +tonic = "0.6" bytes = "1" -prost = "0.8" -prost-derive = "0.8" +prost = "0.9" +prost-derive = "0.9" tokio = { version = "1.0", features = ["macros", "rt", "rt-multi-thread"] } [dev-dependencies] futures = { version = "0.3", default-features = false, features = ["alloc"]} [build-dependencies] -tonic-build = "0.5" +tonic-build = "0.6" # Pin specific version of the tonic-build dependencies to avoid auto-generated # (and checked in) arrow.flight.protocol.rs from changing -proc-macro2 = "=1.0.27" +proc-macro2 = "=1.0.30" #[lib] #name = "flight" diff --git a/arrow-flight/src/arrow.flight.protocol.rs b/arrow-flight/src/arrow.flight.protocol.rs index b1a79ee72031..5775c0177590 100644 --- a/arrow-flight/src/arrow.flight.protocol.rs +++ b/arrow-flight/src/arrow.flight.protocol.rs @@ -229,7 +229,7 @@ pub mod flight_service_client { impl FlightServiceClient where T: tonic::client::GrpcService, - T::ResponseBody: Body + Send + Sync + 'static, + T::ResponseBody: Body + Send + 'static, T::Error: Into, ::Error: Into + Send, { @@ -513,7 +513,6 @@ pub mod flight_service_server { #[doc = "Server streaming response type for the Handshake method."] type HandshakeStream: futures_core::Stream> + Send - + Sync + 'static; #[doc = ""] #[doc = " Handshake between client and server. Depending on the server, the"] @@ -527,7 +526,6 @@ pub mod flight_service_server { #[doc = "Server streaming response type for the ListFlights method."] type ListFlightsStream: futures_core::Stream> + Send - + Sync + 'static; #[doc = ""] #[doc = " Get a list of available streams given a particular criteria. Most flight"] @@ -567,7 +565,6 @@ pub mod flight_service_server { #[doc = "Server streaming response type for the DoGet method."] type DoGetStream: futures_core::Stream> + Send - + Sync + 'static; #[doc = ""] #[doc = " Retrieve a single stream associated with a particular descriptor"] @@ -581,7 +578,6 @@ pub mod flight_service_server { #[doc = "Server streaming response type for the DoPut method."] type DoPutStream: futures_core::Stream> + Send - + Sync + 'static; #[doc = ""] #[doc = " Push a stream to the flight service associated with a particular"] @@ -597,7 +593,6 @@ pub mod flight_service_server { #[doc = "Server streaming response type for the DoExchange method."] type DoExchangeStream: futures_core::Stream> + Send - + Sync + 'static; #[doc = ""] #[doc = " Open a bidirectional data channel for a given descriptor. This"] @@ -612,7 +607,6 @@ pub mod flight_service_server { #[doc = "Server streaming response type for the DoAction method."] type DoActionStream: futures_core::Stream> + Send - + Sync + 'static; #[doc = ""] #[doc = " Flight services can support an arbitrary number of simple actions in"] @@ -628,7 +622,6 @@ pub mod flight_service_server { #[doc = "Server streaming response type for the ListActions method."] type ListActionsStream: futures_core::Stream> + Send - + Sync + 'static; #[doc = ""] #[doc = " A flight service exposes all of the available action types that it has"] @@ -674,7 +667,7 @@ pub mod flight_service_server { impl tonic::codegen::Service> for FlightServiceServer where T: FlightService, - B: Body + Send + Sync + 'static, + B: Body + Send + 'static, B::Error: Into + Send + 'static, { type Response = http::Response; diff --git a/arrow-pyarrow-integration-testing/Cargo.toml b/arrow-pyarrow-integration-testing/Cargo.toml index c0c20f6d2889..afb38f273524 100644 --- a/arrow-pyarrow-integration-testing/Cargo.toml +++ b/arrow-pyarrow-integration-testing/Cargo.toml @@ -24,7 +24,8 @@ repository = "https://github.com/apache/arrow-rs" authors = ["Apache Arrow "] license = "Apache-2.0" keywords = [ "arrow" ] -edition = "2018" +edition = "2021" +rust-version = "1.56" [lib] name = "arrow_pyarrow_integration_testing" diff --git a/arrow/Cargo.toml b/arrow/Cargo.toml index 88623211dab7..c88826f06080 100644 --- a/arrow/Cargo.toml +++ b/arrow/Cargo.toml @@ -29,7 +29,8 @@ include = [ "src/**/*.rs", "Cargo.toml", ] -edition = "2018" +edition = "2021" +rust-version = "1.56" [lib] name = "arrow" diff --git a/arrow/src/array/array_binary.rs b/arrow/src/array/array_binary.rs index 89a3efd2caf2..0592c048c030 100644 --- a/arrow/src/array/array_binary.rs +++ b/arrow/src/array/array_binary.rs @@ -891,10 +891,18 @@ mod tests { assert!(binary_array.is_valid(i)); assert!(!binary_array.is_null(i)); } + } + + #[test] + fn test_binary_array_with_offsets() { + let values: [u8; 12] = [ + b'h', b'e', b'l', b'l', b'o', b'p', b'a', b'r', b'q', b'u', b'e', b't', + ]; + let offsets: [i32; 4] = [0, 5, 5, 12]; // Test binary array with offset let array_data = ArrayData::builder(DataType::Binary) - .len(4) + .len(2) .offset(1) .add_buffer(Buffer::from_slice_ref(&offsets)) .add_buffer(Buffer::from_slice_ref(&values)) @@ -947,10 +955,18 @@ mod tests { assert!(binary_array.is_valid(i)); assert!(!binary_array.is_null(i)); } + } + + #[test] + fn test_large_binary_array_with_offsets() { + let values: [u8; 12] = [ + b'h', b'e', b'l', b'l', b'o', b'p', b'a', b'r', b'q', b'u', b'e', b't', + ]; + let offsets: [i64; 4] = [0, 5, 5, 12]; // Test binary array with offset let array_data = ArrayData::builder(DataType::LargeBinary) - .len(4) + .len(2) .offset(1) .add_buffer(Buffer::from_slice_ref(&offsets)) .add_buffer(Buffer::from_slice_ref(&values)) @@ -1138,7 +1154,7 @@ mod tests { .build() .unwrap(); let list_array = ListArray::from(array_data); - BinaryArray::from(list_array); + drop(BinaryArray::from(list_array)); } #[test] @@ -1196,28 +1212,27 @@ mod tests { #[test] #[should_panic( - expected = "FixedSizeBinaryArray can only be created from list array of u8 values \ - (i.e. FixedSizeList>)." + expected = "FixedSizeBinaryArray can only be created from FixedSizeList arrays" )] fn test_fixed_size_binary_array_from_incorrect_list_array() { let values: [u32; 12] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; let values_data = ArrayData::builder(DataType::UInt32) .len(12) .add_buffer(Buffer::from_slice_ref(&values)) - .add_child_data(ArrayData::builder(DataType::Boolean).build().unwrap()) .build() .unwrap(); - let array_data = ArrayData::builder(DataType::FixedSizeList( - Box::new(Field::new("item", DataType::Binary, false)), - 4, - )) - .len(3) - .add_child_data(values_data) - .build() - .unwrap(); + let array_data = unsafe { + ArrayData::builder(DataType::FixedSizeList( + Box::new(Field::new("item", DataType::Binary, false)), + 4, + )) + .len(3) + .add_child_data(values_data) + .build_unchecked() + }; let list_array = FixedSizeListArray::from(array_data); - FixedSizeBinaryArray::from(list_array); + drop(FixedSizeBinaryArray::from(list_array)); } #[test] diff --git a/arrow/src/array/array_boolean.rs b/arrow/src/array/array_boolean.rs index 07f3da6c4147..3b1959431bfc 100644 --- a/arrow/src/array/array_boolean.rs +++ b/arrow/src/array/array_boolean.rs @@ -332,10 +332,11 @@ mod tests { #[should_panic(expected = "BooleanArray data should contain a single buffer only \ (values buffer)")] fn test_boolean_array_invalid_buffer_len() { - let data = ArrayData::builder(DataType::Boolean) - .len(5) - .build() - .unwrap(); - BooleanArray::from(data); + let data = unsafe { + ArrayData::builder(DataType::Boolean) + .len(5) + .build_unchecked() + }; + drop(BooleanArray::from(data)); } } diff --git a/arrow/src/array/array_list.rs b/arrow/src/array/array_list.rs index fbba8fcf412d..7de357a1dc20 100644 --- a/arrow/src/array/array_list.rs +++ b/arrow/src/array/array_list.rs @@ -552,9 +552,10 @@ mod tests { assert!(!list_array.is_null(i)); } - // Now test with a non-zero offset + // Now test with a non-zero offset (skip first element) + // [[3, 4, 5], [6, 7]] let list_data = ArrayData::builder(list_data_type) - .len(3) + .len(2) .offset(1) .add_buffer(value_offsets) .add_child_data(value_data.clone()) @@ -565,7 +566,7 @@ mod tests { let values = list_array.values(); assert_eq!(&value_data, values.data()); assert_eq!(DataType::Int32, list_array.value_type()); - assert_eq!(3, list_array.len()); + assert_eq!(2, list_array.len()); assert_eq!(0, list_array.null_count()); assert_eq!(6, list_array.value_offsets()[1]); assert_eq!(2, list_array.value_length(1)); @@ -642,8 +643,9 @@ mod tests { } // Now test with a non-zero offset + // [[3, 4, 5], [6, 7]] let list_data = ArrayData::builder(list_data_type) - .len(3) + .len(2) .offset(1) .add_buffer(value_offsets) .add_child_data(value_data.clone()) @@ -654,7 +656,7 @@ mod tests { let values = list_array.values(); assert_eq!(&value_data, values.data()); assert_eq!(DataType::Int32, list_array.value_type()); - assert_eq!(3, list_array.len()); + assert_eq!(2, list_array.len()); assert_eq!(0, list_array.null_count()); assert_eq!(6, list_array.value_offsets()[1]); assert_eq!(2, list_array.value_length(1)); @@ -763,12 +765,13 @@ mod tests { Box::new(Field::new("item", DataType::Int32, false)), 3, ); - let list_data = ArrayData::builder(list_data_type) - .len(3) - .add_child_data(value_data) - .build() - .unwrap(); - FixedSizeListArray::from(list_data); + let list_data = unsafe { + ArrayData::builder(list_data_type) + .len(3) + .add_child_data(value_data) + .build_unchecked() + }; + drop(FixedSizeListArray::from(list_data)); } #[test] @@ -1038,19 +1041,21 @@ mod tests { expected = "ListArray data should contain a single buffer only (value offsets)" )] fn test_list_array_invalid_buffer_len() { - let value_data = ArrayData::builder(DataType::Int32) - .len(8) - .add_buffer(Buffer::from_slice_ref(&[0, 1, 2, 3, 4, 5, 6, 7])) - .build() - .unwrap(); + let value_data = unsafe { + ArrayData::builder(DataType::Int32) + .len(8) + .add_buffer(Buffer::from_slice_ref(&[0, 1, 2, 3, 4, 5, 6, 7])) + .build_unchecked() + }; let list_data_type = DataType::List(Box::new(Field::new("item", DataType::Int32, false))); - let list_data = ArrayData::builder(list_data_type) - .len(3) - .add_child_data(value_data) - .build() - .unwrap(); - ListArray::from(list_data); + let list_data = unsafe { + ArrayData::builder(list_data_type) + .len(3) + .add_child_data(value_data) + .build_unchecked() + }; + drop(ListArray::from(list_data)); } #[test] @@ -1061,12 +1066,13 @@ mod tests { let value_offsets = Buffer::from_slice_ref(&[0, 2, 5, 7]); let list_data_type = DataType::List(Box::new(Field::new("item", DataType::Int32, false))); - let list_data = ArrayData::builder(list_data_type) - .len(3) - .add_buffer(value_offsets) - .build() - .unwrap(); - ListArray::from(list_data); + let list_data = unsafe { + ArrayData::builder(list_data_type) + .len(3) + .add_buffer(value_offsets) + .build_unchecked() + }; + drop(ListArray::from(list_data)); } #[test] @@ -1088,7 +1094,7 @@ mod tests { .add_child_data(value_data) .build() .unwrap(); - ListArray::from(list_data); + drop(ListArray::from(list_data)); } #[test] @@ -1101,7 +1107,7 @@ mod tests { .add_buffer(buf2) .build() .unwrap(); - Int32Array::from(array_data); + drop(Int32Array::from(array_data)); } #[test] @@ -1112,19 +1118,21 @@ mod tests { let buf2 = buf.slice(1); let values: [i32; 8] = [0; 8]; - let value_data = ArrayData::builder(DataType::Int32) - .add_buffer(Buffer::from_slice_ref(&values)) - .build() - .unwrap(); + let value_data = unsafe { + ArrayData::builder(DataType::Int32) + .add_buffer(Buffer::from_slice_ref(&values)) + .build_unchecked() + }; let list_data_type = DataType::List(Box::new(Field::new("item", DataType::Int32, false))); - let list_data = ArrayData::builder(list_data_type) - .add_buffer(buf2) - .add_child_data(value_data) - .build() - .unwrap(); - ListArray::from(list_data); + let list_data = unsafe { + ArrayData::builder(list_data_type) + .add_buffer(buf2) + .add_child_data(value_data) + .build_unchecked() + }; + drop(ListArray::from(list_data)); } #[test] diff --git a/arrow/src/array/array_map.rs b/arrow/src/array/array_map.rs index bd888ff83e9b..caccebcc56e3 100644 --- a/arrow/src/array/array_map.rs +++ b/arrow/src/array/array_map.rs @@ -320,7 +320,7 @@ mod tests { // Now test with a non-zero offset let map_data = ArrayData::builder(map_array.data_type().clone()) - .len(3) + .len(2) .offset(1) .add_buffer(map_array.data().buffers()[0].clone()) .add_child_data(map_array.data().child_data()[0].clone()) @@ -331,7 +331,7 @@ mod tests { let values = map_array.values(); assert_eq!(&value_data, values.data()); assert_eq!(DataType::UInt32, map_array.value_type()); - assert_eq!(3, map_array.len()); + assert_eq!(2, map_array.len()); assert_eq!(0, map_array.null_count()); assert_eq!(6, map_array.value_offsets()[1]); assert_eq!(2, map_array.value_length(1)); diff --git a/arrow/src/array/array_primitive.rs b/arrow/src/array/array_primitive.rs index a93e703946d1..ac56b4a97cc7 100644 --- a/arrow/src/array/array_primitive.rs +++ b/arrow/src/array/array_primitive.rs @@ -894,7 +894,7 @@ mod tests { #[test] fn test_primitive_array_builder() { // Test building a primitive array with ArrayData builder and offset - let buf = Buffer::from_slice_ref(&[0, 1, 2, 3, 4]); + let buf = Buffer::from_slice_ref(&[0i32, 1, 2, 3, 4, 5, 6]); let buf2 = buf.clone(); let data = ArrayData::builder(DataType::Int32) .len(5) @@ -950,8 +950,16 @@ mod tests { #[should_panic(expected = "PrimitiveArray data should contain a single buffer only \ (values buffer)")] fn test_primitive_array_invalid_buffer_len() { - let data = ArrayData::builder(DataType::Int32).len(5).build().unwrap(); - Int32Array::from(data); + let buffer = Buffer::from_slice_ref(&[0i32, 1, 2, 3, 4]); + let data = unsafe { + ArrayData::builder(DataType::Int32) + .add_buffer(buffer.clone()) + .add_buffer(buffer) + .len(5) + .build_unchecked() + }; + + drop(Int32Array::from(data)); } #[test] diff --git a/arrow/src/array/array_string.rs b/arrow/src/array/array_string.rs index c07f34a6b726..0d8dcf1a68e3 100644 --- a/arrow/src/array/array_string.rs +++ b/arrow/src/array/array_string.rs @@ -405,7 +405,7 @@ mod tests { #[should_panic(expected = "[Large]StringArray expects Datatype::[Large]Utf8")] fn test_string_array_from_int() { let array = LargeStringArray::from(vec!["a", "b"]); - StringArray::from(array.data().clone()); + drop(StringArray::from(array.data().clone())); } #[test] diff --git a/arrow/src/array/array_struct.rs b/arrow/src/array/array_struct.rs index a1cab7f50c70..33458c3ba454 100644 --- a/arrow/src/array/array_struct.rs +++ b/arrow/src/array/array_struct.rs @@ -408,7 +408,7 @@ mod tests { expected = "the field data types must match the array data in a StructArray" )] fn test_struct_array_from_mismatched_types() { - StructArray::from(vec![ + drop(StructArray::from(vec![ ( Field::new("b", DataType::Int16, false), Arc::new(BooleanArray::from(vec![false, false, true, true])) @@ -418,7 +418,7 @@ mod tests { Field::new("c", DataType::Utf8, false), Arc::new(Int32Array::from(vec![42, 28, 19, 31])), ), - ]); + ])); } #[test] @@ -515,7 +515,7 @@ mod tests { expected = "all child arrays of a StructArray must have the same length" )] fn test_invalid_struct_child_array_lengths() { - StructArray::from(vec![ + drop(StructArray::from(vec![ ( Field::new("b", DataType::Float32, false), Arc::new(Float32Array::from(vec![1.1])) as Arc, @@ -524,6 +524,6 @@ mod tests { Field::new("c", DataType::Float64, false), Arc::new(Float64Array::from(vec![2.2, 3.3])), ), - ]); + ])); } } diff --git a/arrow/src/array/array_union.rs b/arrow/src/array/array_union.rs index 6460e072646b..56efcfb30c75 100644 --- a/arrow/src/array/array_union.rs +++ b/arrow/src/array/array_union.rs @@ -137,7 +137,10 @@ impl UnionArray { } } - Ok(Self::new(type_ids, value_offsets, child_arrays, bitmap)) + let new_self = Self::new(type_ids, value_offsets, child_arrays, bitmap); + new_self.data().validate()?; + + Ok(new_self) } /// Accesses the child array for `type_id`. diff --git a/arrow/src/array/cast.rs b/arrow/src/array/cast.rs index dfc15608555f..e4284ef2218b 100644 --- a/arrow/src/array/cast.rs +++ b/arrow/src/array/cast.rs @@ -92,3 +92,4 @@ array_downcast_fn!(as_largestring_array, LargeStringArray); array_downcast_fn!(as_boolean_array, BooleanArray); array_downcast_fn!(as_null_array, NullArray); array_downcast_fn!(as_struct_array, StructArray); +array_downcast_fn!(as_union_array, UnionArray); diff --git a/arrow/src/array/data.rs b/arrow/src/array/data.rs index dbc54342b034..3ca14d85b9db 100644 --- a/arrow/src/array/data.rs +++ b/arrow/src/array/data.rs @@ -18,11 +18,12 @@ //! Contains `ArrayData`, a generic representation of Arrow array data which encapsulates //! common attributes and operations for Arrow array. +use std::convert::TryInto; use std::mem; use std::sync::Arc; use crate::datatypes::{DataType, IntervalUnit}; -use crate::error::Result; +use crate::error::{ArrowError, Result}; use crate::{bitmap::Bitmap, datatypes::ArrowNativeType}; use crate::{ buffer::{Buffer, MutableBuffer}, @@ -189,6 +190,28 @@ pub(crate) fn new_buffers(data_type: &DataType, capacity: usize) -> [MutableBuff } } +/// Ensures that at least `min_size` elements of type `data_type` can +/// be stored in a buffer of `buffer_size`. +/// +/// `buffer_index` is used in error messages to identify which buffer +/// had the invalid index +fn ensure_size( + data_type: &DataType, + min_size: usize, + buffer_size: usize, + buffer_index: usize, +) -> Result<()> { + // if min_size is zero, may not have buffers (e.g. NullArray) + if min_size > 0 && buffer_size < min_size { + Err(ArrowError::InvalidArgumentError(format!( + "Need at least {} bytes in buffers[{}] in array of type {:?}, but got {}", + buffer_size, buffer_index, data_type, min_size + ))) + } else { + Ok(()) + } +} + /// Maps 2 [`MutableBuffer`]s into a vector of [Buffer]s whose size depends on `data_type`. #[inline] pub(crate) fn into_buffers( @@ -313,18 +336,6 @@ impl ArrayData { Ok(new_self) } - /// Validates that buffers in this ArrayData are sufficiently - /// sized, to store `len` + `offset` total elements of - /// `data_type`. - /// - /// This check is "cheap" in the sense that it does not validate the - /// contents of the buffers (e.g. that string offsets for UTF8 arrays - /// are within the length of the buffer). - pub fn validate(&self) -> Result<()> { - // will be filled in a subsequent PR - Ok(()) - } - /// Returns a builder to construct a `ArrayData` instance. #[inline] pub const fn builder(data_type: DataType) -> ArrayDataBuilder { @@ -559,6 +570,437 @@ impl ArrayData { ) } } + + /// "cheap" validation of an `ArrayData`. Ensures buffers are + /// sufficiently sized to store `len` + `offset` total elements of + /// `data_type` and performs other inexpensive consistency checks. + /// + /// This check is "cheap" in the sense that it does not validate the + /// contents of the buffers (e.g. that all offsets for UTF8 arrays + /// are within the bounds of the values buffer). + /// + /// TODO: add a validate_full that validates the offsets and valid utf8 data + pub fn validate(&self) -> Result<()> { + // Need at least this mich space in each buffer + let len_plus_offset = self.len + self.offset; + + // Check that the data layout conforms to the spec + let layout = layout(&self.data_type); + + // Will validate Union when conforms to new spec: + // https://github.com/apache/arrow-rs/issues/85 + if matches!(&self.data_type, DataType::Union(_)) { + return Ok(()); + } + if self.buffers.len() != layout.buffers.len() { + return Err(ArrowError::InvalidArgumentError(format!( + "Expected {} buffers in array of type {:?}, got {}", + layout.buffers.len(), + self.data_type, + self.buffers.len(), + ))); + } + + for (i, (buffer, spec)) in + self.buffers.iter().zip(layout.buffers.iter()).enumerate() + { + match spec { + BufferSpec::FixedWidth { byte_width } => { + let min_buffer_size = len_plus_offset + .checked_mul(*byte_width) + .expect("integer overflow computing min buffer size"); + + if buffer.len() < min_buffer_size { + return Err(ArrowError::InvalidArgumentError(format!( + "Need at least {} bytes in buffers[{}] in array of type {:?}, but got {}", + min_buffer_size, i, self.data_type, buffer.len() + ))); + } + } + BufferSpec::VariableWidth => { + // not cheap to validate (need to look at the + // data). Partially checked in validate_offsets + // called below. Can check with `validate_full` + } + BufferSpec::BitMap => { + let min_buffer_size = bit_util::ceil(len_plus_offset, 8); + if buffer.len() < min_buffer_size { + return Err(ArrowError::InvalidArgumentError(format!( + "Need at least {} bytes for bitmap in buffers[{}] in array of type {:?}, but got {}", + min_buffer_size, i, self.data_type, buffer.len() + ))); + } + } + BufferSpec::AlwaysNull => { + // Nothing to validate + } + } + } + + if self.null_count > self.len { + return Err(ArrowError::InvalidArgumentError(format!( + "null_count {} for an array exceeds length of {} elements", + self.null_count, self.len + ))); + } + + // check null bit buffer size + if let Some(null_bit_buffer) = self.null_bitmap.as_ref() { + let needed_len = bit_util::ceil(len_plus_offset, 8); + if null_bit_buffer.len() < needed_len { + return Err(ArrowError::InvalidArgumentError(format!( + "null_bit_buffer size too small. got {} needed {}", + null_bit_buffer.len(), + needed_len + ))); + } + } else if self.null_count > 0 { + return Err(ArrowError::InvalidArgumentError(format!( + "Array of type {} has {} nulls but no null bitmap", + self.data_type, self.null_count + ))); + } + + self.validate_child_data()?; + + // Additional Type specific checks + match &self.data_type { + DataType::Utf8 | DataType::Binary => { + self.validate_offsets::(&self.buffers[0], self.buffers[1].len())?; + } + DataType::LargeUtf8 | DataType::LargeBinary => { + self.validate_offsets::(&self.buffers[0], self.buffers[1].len())?; + } + DataType::Dictionary(key_type, _value_type) => { + // At the moment, constructing a DictionaryArray will also check this + if !DataType::is_dictionary_key_type(key_type) { + return Err(ArrowError::InvalidArgumentError(format!( + "Dictionary values must be integer, but was {}", + key_type + ))); + } + } + _ => {} + }; + + Ok(()) + } + + /// Does a cheap sanity check that the `self.len` values in `buffer` are valid + /// offsets (of type T> into some other buffer of `values_length` bytes long + fn validate_offsets( + &self, + buffer: &Buffer, + values_length: usize, + ) -> Result<()> { + // Validate that there are the correct number of offsets for this array's length + let required_offsets = self.len + self.offset + 1; + + // An empty list-like array can have 0 offsets + if buffer.is_empty() { + return Ok(()); + } + + if (buffer.len() / std::mem::size_of::()) < required_offsets { + return Err(ArrowError::InvalidArgumentError(format!( + "Offsets buffer size (bytes): {} isn't large enough for {}. Length {} needs {}", + buffer.len(), self.data_type, self.len, required_offsets + ))); + } + + // Justification: buffer size was validated above + let offsets = unsafe { &(buffer.typed_data::()[self.offset..]) }; + + let first_offset = offsets[0].to_usize().ok_or_else(|| { + ArrowError::InvalidArgumentError(format!( + "Error converting offset[0] ({}) to usize for {}", + offsets[0], self.data_type + )) + })?; + + let last_offset = offsets[self.len].to_usize().ok_or_else(|| { + ArrowError::InvalidArgumentError(format!( + "Error converting offset[{}] ({}) to usize for {}", + self.len, offsets[self.len], self.data_type + )) + })?; + + if first_offset > values_length { + return Err(ArrowError::InvalidArgumentError(format!( + "First offset {} of {} is larger than values length {}", + first_offset, self.data_type, values_length, + ))); + } + + if last_offset > values_length { + return Err(ArrowError::InvalidArgumentError(format!( + "Last offset {} of {} is larger than values length {}", + last_offset, self.data_type, values_length, + ))); + } + + if first_offset > last_offset { + return Err(ArrowError::InvalidArgumentError(format!( + "First offset {} in {} is smaller than last offset {}", + first_offset, self.data_type, last_offset, + ))); + } + + Ok(()) + } + + /// Validates the layout of `child_data` ArrayData structures + fn validate_child_data(&self) -> Result<()> { + match &self.data_type { + DataType::List(field) | DataType::Map(field, _) => { + let values_data = self.get_single_valid_child_data(field.data_type())?; + self.validate_offsets::(&self.buffers[0], values_data.len)?; + Ok(()) + } + DataType::LargeList(field) => { + let values_data = self.get_single_valid_child_data(field.data_type())?; + self.validate_offsets::(&self.buffers[0], values_data.len)?; + Ok(()) + } + DataType::FixedSizeList(field, list_size) => { + let values_data = self.get_single_valid_child_data(field.data_type())?; + + let list_size: usize = (*list_size).try_into().map_err(|_| { + ArrowError::InvalidArgumentError(format!( + "{} has a negative list_size {}", + self.data_type, list_size + )) + })?; + + let expected_values_len = self.len + .checked_mul(list_size) + .expect("integer overflow computing expected number of expected values in FixedListSize"); + + if values_data.len < expected_values_len { + return Err(ArrowError::InvalidArgumentError(format!( + "Values length {} is less than the length ({}) multiplied by the value size ({}) for {}", + values_data.len, list_size, list_size, self.data_type + ))); + } + + Ok(()) + } + DataType::Struct(fields) => { + self.validate_num_child_data(fields.len())?; + for (i, field) in fields.iter().enumerate() { + let field_data = self.get_valid_child_data(i, field.data_type())?; + + // C++ does this check, but it is not clear why + // field_data checks only len, but self checks len+offset + if field_data.len < (self.len + self.offset) { + return Err(ArrowError::InvalidArgumentError(format!( + "{} child array #{} for field {} has length smaller than expected for struct array ({} < {})", + self.data_type, i, field.name(), field_data.len, self.len + self.offset + ))); + } + } + Ok(()) + } + DataType::Union(_fields) => { + // Validate Union Array as part of implementing new Union semantics + // See comments in `ArrayData::validate()` + // https://github.com/apache/arrow-rs/issues/85 + Ok(()) + } + DataType::Dictionary(_key_type, value_type) => { + self.get_single_valid_child_data(value_type)?; + Ok(()) + } + _ => { + // other types do not have child data + if !self.child_data.is_empty() { + return Err(ArrowError::InvalidArgumentError(format!( + "Expected no child arrays for type {} but got {}", + self.data_type, + self.child_data.len() + ))); + } + Ok(()) + } + } + } + + /// Ensures that this array data has a single child_data with the + /// expected type, and calls `validate()` on it. Returns a + /// reference to that child_data + fn get_single_valid_child_data( + &self, + expected_type: &DataType, + ) -> Result<&ArrayData> { + self.validate_num_child_data(1)?; + self.get_valid_child_data(0, expected_type) + } + + /// Returns `Err` if self.child_data does not have exactly `expected_len` elements + fn validate_num_child_data(&self, expected_len: usize) -> Result<()> { + if self.child_data().len() != expected_len { + Err(ArrowError::InvalidArgumentError(format!( + "Value data for {} should contain {} child data array(s), had {}", + self.data_type(), + expected_len, + self.child_data.len() + ))) + } else { + Ok(()) + } + } + + /// Ensures that `child_data[i]` has the expected type, calls + /// `validate()` on it, and returns a reference to that child_data + fn get_valid_child_data( + &self, + i: usize, + expected_type: &DataType, + ) -> Result<&ArrayData> { + let values_data = self.child_data + .get(i) + .ok_or_else(|| { + ArrowError::InvalidArgumentError(format!( + "{} did not have enough child arrays. Expected at least {} but had only {}", + self.data_type, i+1, self.child_data.len() + )) + })?; + + if expected_type != &values_data.data_type { + return Err(ArrowError::InvalidArgumentError(format!( + "Child type mismatch for {}. Expected {} but child data had {}", + self.data_type, expected_type, values_data.data_type + ))); + } + + values_data.validate()?; + Ok(values_data) + } +} + +/// Return the expected [`DataTypeLayout`] Arrays of this data +/// type are expected to have +fn layout(data_type: &DataType) -> DataTypeLayout { + // based on C/C++ implementation in + // https://github.com/apache/arrow/blob/661c7d749150905a63dd3b52e0a04dac39030d95/cpp/src/arrow/type.h (and .cc) + use std::mem::size_of; + match data_type { + DataType::Null => DataTypeLayout::new_empty(), + DataType::Boolean => DataTypeLayout { + buffers: vec![BufferSpec::BitMap], + }, + DataType::Int8 => DataTypeLayout::new_fixed_width(size_of::()), + DataType::Int16 => DataTypeLayout::new_fixed_width(size_of::()), + DataType::Int32 => DataTypeLayout::new_fixed_width(size_of::()), + DataType::Int64 => DataTypeLayout::new_fixed_width(size_of::()), + DataType::UInt8 => DataTypeLayout::new_fixed_width(size_of::()), + DataType::UInt16 => DataTypeLayout::new_fixed_width(size_of::()), + DataType::UInt32 => DataTypeLayout::new_fixed_width(size_of::()), + DataType::UInt64 => DataTypeLayout::new_fixed_width(size_of::()), + DataType::Float16 => unimplemented!(), + DataType::Float32 => DataTypeLayout::new_fixed_width(size_of::()), + DataType::Float64 => DataTypeLayout::new_fixed_width(size_of::()), + DataType::Timestamp(_, _) => DataTypeLayout::new_fixed_width(size_of::()), + DataType::Date32 => DataTypeLayout::new_fixed_width(size_of::()), + DataType::Date64 => DataTypeLayout::new_fixed_width(size_of::()), + DataType::Time32(_) => DataTypeLayout::new_fixed_width(size_of::()), + DataType::Time64(_) => DataTypeLayout::new_fixed_width(size_of::()), + DataType::Interval(IntervalUnit::YearMonth) => { + DataTypeLayout::new_fixed_width(size_of::()) + } + DataType::Interval(IntervalUnit::DayTime) => { + DataTypeLayout::new_fixed_width(size_of::()) + } + DataType::Duration(_) => DataTypeLayout::new_fixed_width(size_of::()), + DataType::Binary => DataTypeLayout::new_binary(size_of::()), + DataType::FixedSizeBinary(bytes_per_value) => { + let bytes_per_value: usize = (*bytes_per_value) + .try_into() + .expect("negative size for fixed size binary"); + DataTypeLayout::new_fixed_width(bytes_per_value) + } + DataType::LargeBinary => DataTypeLayout::new_binary(size_of::()), + DataType::Utf8 => DataTypeLayout::new_binary(size_of::()), + DataType::LargeUtf8 => DataTypeLayout::new_binary(size_of::()), + DataType::List(_) => DataTypeLayout::new_fixed_width(size_of::()), + DataType::FixedSizeList(_, _) => DataTypeLayout::new_empty(), // all in child data + DataType::LargeList(_) => DataTypeLayout::new_fixed_width(size_of::()), + DataType::Struct(_) => DataTypeLayout::new_empty(), // all in child data, + DataType::Union(_) => { + DataTypeLayout::new_fixed_width(size_of::()) + // Note sparse unions only have one buffer (u8) type_ids, + // and dense unions have 2 (type_ids as well as offsets). + // https://github.com/apache/arrow-rs/issues/85 + } + DataType::Dictionary(key_type, _value_type) => layout(key_type), + DataType::Decimal(_, _) => { + // Decimals are always some fixed width; The rust implemenation + // always uses 16 bytes / size of i128 + DataTypeLayout::new_fixed_width(size_of::()) + } + DataType::Map(_, _) => { + // same as ListType + DataTypeLayout::new_fixed_width(size_of::()) + } + } +} + +/// Layout specification for a data type +#[derive(Debug, PartialEq)] +// Note: Follows structure from C++: https://github.com/apache/arrow/blob/master/cpp/src/arrow/type.h#L91 +struct DataTypeLayout { + /// A vector of buffer layout specifications, one for each expected buffer + pub buffers: Vec, +} + +impl DataTypeLayout { + /// Describes a basic numeric array where each element has a fixed width + pub fn new_fixed_width(byte_width: usize) -> Self { + Self { + buffers: vec![BufferSpec::FixedWidth { byte_width }], + } + } + + /// Describes arrays which have no data of their own + /// (e.g. FixedSizeList). Note such arrays may still have a Null + /// Bitmap + pub fn new_empty() -> Self { + Self { buffers: vec![] } + } + + /// Describes a basic numeric array where each element has a fixed + /// with offset buffer of `offset_byte_width` bytes, followed by a + /// variable width data buffer + pub fn new_binary(offset_byte_width: usize) -> Self { + Self { + buffers: vec![ + // offsets + BufferSpec::FixedWidth { + byte_width: offset_byte_width, + }, + // values + BufferSpec::VariableWidth, + ], + } + } +} + +/// Layout specification for a single data type buffer +#[derive(Debug, PartialEq)] +enum BufferSpec { + /// each element has a fixed width + FixedWidth { byte_width: usize }, + /// Variable width, such as string data for utf8 data + VariableWidth, + /// Buffer holds a bitmap. + /// + /// Note: Unlike the C++ implementation, the null/validity buffer + /// is handled specially rather than as another of the buffers in + /// the spec, so this variant is only used for the Boolean type. + BitMap, + /// Buffer is always null. Unused currently in Rust implementation, + /// (used in C++ for Union type) + AlwaysNull, } impl PartialEq for ArrayData { @@ -672,23 +1114,38 @@ impl ArrayDataBuilder { mod tests { use super::*; + use crate::array::{Array, Int32Array, StringArray}; use crate::buffer::Buffer; + use crate::datatypes::Field; use crate::util::bit_util; #[test] - fn test_new() { - let arr_data = - ArrayData::try_new(DataType::Boolean, 10, Some(1), None, 2, vec![], vec![]) - .unwrap(); - assert_eq!(10, arr_data.len()); - assert_eq!(1, arr_data.null_count()); - assert_eq!(2, arr_data.offset()); - assert_eq!(0, arr_data.buffers().len()); - assert_eq!(0, arr_data.child_data().len()); + fn test_builder() { + // Buffer needs to be at least 25 long + let v = (0..25).collect::>(); + let b1 = Buffer::from_slice_ref(&v); + let arr_data = ArrayData::builder(DataType::Int32) + .len(20) + .offset(5) + .add_buffer(b1) + .null_bit_buffer(Buffer::from(vec![ + 0b01011111, 0b10110101, 0b01100011, 0b00011110, + ])) + .build() + .unwrap(); + + assert_eq!(20, arr_data.len()); + assert_eq!(10, arr_data.null_count()); + assert_eq!(5, arr_data.offset()); + assert_eq!(1, arr_data.buffers().len()); + assert_eq!( + Buffer::from_slice_ref(&v).as_slice(), + arr_data.buffers()[0].as_slice() + ); } #[test] - fn test_builder() { + fn test_builder_with_child_data() { let child_arr_data = ArrayData::try_new( DataType::Int32, 5, @@ -699,24 +1156,17 @@ mod tests { vec![], ) .unwrap(); - let v = vec![0, 1, 2, 3]; - let b1 = Buffer::from(&v[..]); - let arr_data = ArrayData::builder(DataType::Int32) - .len(20) - .offset(5) - .add_buffer(b1) - .null_bit_buffer(Buffer::from(vec![ - 0b01011111, 0b10110101, 0b01100011, 0b00011110, - ])) + + let data_type = DataType::Struct(vec![Field::new("x", DataType::Int32, true)]); + + let arr_data = ArrayData::builder(data_type) + .len(5) + .offset(0) .add_child_data(child_arr_data.clone()) .build() .unwrap(); - assert_eq!(20, arr_data.len()); - assert_eq!(10, arr_data.null_count()); - assert_eq!(5, arr_data.offset()); - assert_eq!(1, arr_data.buffers().len()); - assert_eq!(&[0, 1, 2, 3], arr_data.buffers()[0].as_slice()); + assert_eq!(5, arr_data.len()); assert_eq!(1, arr_data.child_data().len()); assert_eq!(child_arr_data, arr_data.child_data()[0]); } @@ -729,6 +1179,7 @@ mod tests { bit_util::set_bit(&mut bit_v, 10); let arr_data = ArrayData::builder(DataType::Int32) .len(16) + .add_buffer(make_i32_buffer(16)) .null_bit_buffer(Buffer::from(bit_v)) .build() .unwrap(); @@ -742,6 +1193,7 @@ mod tests { let arr_data = ArrayData::builder(DataType::Int32) .len(12) .offset(2) + .add_buffer(make_i32_buffer(14)) // requires at least 14 bytes of space, .null_bit_buffer(Buffer::from(bit_v)) .build() .unwrap(); @@ -756,6 +1208,7 @@ mod tests { bit_util::set_bit(&mut bit_v, 10); let arr_data = ArrayData::builder(DataType::Int32) .len(16) + .add_buffer(make_i32_buffer(16)) .null_bit_buffer(Buffer::from(bit_v)) .build() .unwrap(); @@ -771,6 +1224,7 @@ mod tests { bit_util::set_bit(&mut bit_v, 10); let data = ArrayData::builder(DataType::Int32) .len(16) + .add_buffer(make_i32_buffer(16)) .null_bit_buffer(Buffer::from(bit_v)) .build() .unwrap(); @@ -788,8 +1242,16 @@ mod tests { #[test] fn test_equality() { - let int_data = ArrayData::builder(DataType::Int32).build().unwrap(); - let float_data = ArrayData::builder(DataType::Float32).build().unwrap(); + let int_data = ArrayData::builder(DataType::Int32) + .len(1) + .add_buffer(make_i32_buffer(1)) + .build() + .unwrap(); + let float_data = ArrayData::builder(DataType::Float32) + .len(1) + .add_buffer(make_f32_buffer(1)) + .build() + .unwrap(); assert_ne!(int_data, float_data); } @@ -802,4 +1264,380 @@ mod tests { let count = count_nulls(null_buffer.as_ref(), 4, 8); assert_eq!(count, 3); } + + #[test] + #[should_panic( + expected = "Need at least 80 bytes in buffers[0] in array of type Int64, but got 8" + )] + fn test_buffer_too_small() { + let buffer = Buffer::from_slice_ref(&[0i32, 2i32]); + // should fail as the declared size (10*8 = 80) is larger than the underlying bfufer (8) + ArrayData::try_new(DataType::Int64, 10, Some(0), None, 0, vec![buffer], vec![]) + .unwrap(); + } + + #[test] + #[should_panic( + expected = "Need at least 16 bytes in buffers[0] in array of type Int64, but got 8" + )] + fn test_buffer_too_small_offset() { + let buffer = Buffer::from_slice_ref(&[0i32, 2i32]); + // should fail -- size is ok, but also has offset + ArrayData::try_new(DataType::Int64, 1, Some(0), None, 1, vec![buffer], vec![]) + .unwrap(); + } + + #[test] + #[should_panic(expected = "Expected 1 buffers in array of type Int64, got 2")] + fn test_bad_number_of_buffers() { + let buffer1 = Buffer::from_slice_ref(&[0i32, 2i32]); + let buffer2 = Buffer::from_slice_ref(&[0i32, 2i32]); + ArrayData::try_new( + DataType::Int64, + 1, + Some(0), + None, + 0, + vec![buffer1, buffer2], + vec![], + ) + .unwrap(); + } + + #[test] + #[should_panic(expected = "integer overflow computing min buffer size")] + fn test_fixed_width_overflow() { + let buffer = Buffer::from_slice_ref(&[0i32, 2i32]); + ArrayData::try_new( + DataType::Int64, + usize::MAX, + Some(0), + None, + 0, + vec![buffer], + vec![], + ) + .unwrap(); + } + + #[test] + #[should_panic(expected = "null_bit_buffer size too small. got 8 needed 13")] + fn test_bitmap_too_small() { + let buffer = make_i32_buffer(100); + let null_bit_buffer = Buffer::from(vec![0b11111111]); + + ArrayData::try_new( + DataType::Int32, + 100, + Some(0), + Some(null_bit_buffer), + 0, + vec![buffer], + vec![], + ) + .unwrap(); + } + + #[test] + #[should_panic(expected = "null_count 3 for an array exceeds length of 2 elements")] + fn test_bad_null_count() { + let buffer = Buffer::from_slice_ref(&[0i32, 2i32]); + ArrayData::try_new(DataType::Int32, 2, Some(3), None, 0, vec![buffer], vec![]) + .unwrap(); + } + + // Test creating a dictionary with a non integer type + #[test] + #[should_panic(expected = "Dictionary values must be integer, but was Utf8")] + fn test_non_int_dictionary() { + let i32_buffer = Buffer::from_slice_ref(&[0i32, 2i32]); + let data_type = + DataType::Dictionary(Box::new(DataType::Utf8), Box::new(DataType::Int32)); + let child_data = ArrayData::try_new( + DataType::Int32, + 1, + Some(0), + None, + 0, + vec![i32_buffer.clone()], + vec![], + ) + .unwrap(); + ArrayData::try_new( + data_type, + 1, + Some(0), + None, + 0, + vec![i32_buffer.clone(), i32_buffer], + vec![child_data], + ) + .unwrap(); + } + + #[test] + #[should_panic(expected = "Expected LargeUtf8 but child data had Utf8")] + fn test_mismatched_dictionary_types() { + // test w/ dictionary created with a child array data that has type different than declared + let string_array: StringArray = + vec![Some("foo"), Some("bar")].into_iter().collect(); + let i32_buffer = Buffer::from_slice_ref(&[0i32, 1i32]); + // Dict says LargeUtf8 but array is Utf8 + let data_type = DataType::Dictionary( + Box::new(DataType::Int32), + Box::new(DataType::LargeUtf8), + ); + let child_data = string_array.data().clone(); + ArrayData::try_new( + data_type, + 1, + Some(0), + None, + 0, + vec![i32_buffer], + vec![child_data], + ) + .unwrap(); + } + + #[test] + #[should_panic( + expected = "Offsets buffer size (bytes): 8 isn't large enough for Utf8. Length 2 needs 3" + )] + fn test_validate_offsets_i32() { + let data_buffer = Buffer::from_slice_ref(&"abcdef".as_bytes()); + let offsets_buffer = Buffer::from_slice_ref(&[0i32, 2i32]); + ArrayData::try_new( + DataType::Utf8, + 2, + None, + None, + 0, + vec![offsets_buffer, data_buffer], + vec![], + ) + .unwrap(); + } + + #[test] + #[should_panic( + expected = "Offsets buffer size (bytes): 16 isn't large enough for LargeUtf8. Length 2 needs 3" + )] + fn test_validate_offsets_i64() { + let data_buffer = Buffer::from_slice_ref(&"abcdef".as_bytes()); + let offsets_buffer = Buffer::from_slice_ref(&[0i64, 2i64]); + ArrayData::try_new( + DataType::LargeUtf8, + 2, + None, + None, + 0, + vec![offsets_buffer, data_buffer], + vec![], + ) + .unwrap(); + } + + #[test] + #[should_panic(expected = "Error converting offset[0] (-2) to usize for Utf8")] + fn test_validate_offsets_negative_first_i32() { + let data_buffer = Buffer::from_slice_ref(&"abcdef".as_bytes()); + let offsets_buffer = Buffer::from_slice_ref(&[-2i32, 1i32, 3i32]); + ArrayData::try_new( + DataType::Utf8, + 2, + None, + None, + 0, + vec![offsets_buffer, data_buffer], + vec![], + ) + .unwrap(); + } + + #[test] + #[should_panic(expected = "Error converting offset[2] (-3) to usize for Utf8")] + fn test_validate_offsets_negative_last_i32() { + let data_buffer = Buffer::from_slice_ref(&"abcdef".as_bytes()); + let offsets_buffer = Buffer::from_slice_ref(&[0i32, 2i32, -3i32]); + ArrayData::try_new( + DataType::Utf8, + 2, + None, + None, + 0, + vec![offsets_buffer, data_buffer], + vec![], + ) + .unwrap(); + } + + #[test] + #[should_panic(expected = "First offset 4 in Utf8 is smaller than last offset 3")] + fn test_validate_offsets_range_too_small() { + let data_buffer = Buffer::from_slice_ref(&"abcdef".as_bytes()); + // start offset is larger than end + let offsets_buffer = Buffer::from_slice_ref(&[4i32, 2i32, 3i32]); + ArrayData::try_new( + DataType::Utf8, + 2, + None, + None, + 0, + vec![offsets_buffer, data_buffer], + vec![], + ) + .unwrap(); + } + + #[test] + #[should_panic(expected = "Last offset 10 of Utf8 is larger than values length 6")] + fn test_validate_offsets_range_too_large() { + let data_buffer = Buffer::from_slice_ref(&"abcdef".as_bytes()); + // 10 is off the end of the buffer + let offsets_buffer = Buffer::from_slice_ref(&[0i32, 2i32, 10i32]); + ArrayData::try_new( + DataType::Utf8, + 2, + None, + None, + 0, + vec![offsets_buffer, data_buffer], + vec![], + ) + .unwrap(); + } + + #[test] + #[should_panic(expected = "First offset 10 of Utf8 is larger than values length 6")] + fn test_validate_offsets_first_too_large() { + let data_buffer = Buffer::from_slice_ref(&"abcdef".as_bytes()); + // 10 is off the end of the buffer + let offsets_buffer = Buffer::from_slice_ref(&[10i32, 2i32, 10i32]); + ArrayData::try_new( + DataType::Utf8, + 2, + None, + None, + 0, + vec![offsets_buffer, data_buffer], + vec![], + ) + .unwrap(); + } + + #[test] + fn test_validate_offsets_first_too_large_skipped() { + let data_buffer = Buffer::from_slice_ref(&"abcdef".as_bytes()); + // 10 is off the end of the buffer, but offset starts at 1 so it is skipped + let offsets_buffer = Buffer::from_slice_ref(&[10i32, 2i32, 3i32, 4i32]); + let data = ArrayData::try_new( + DataType::Utf8, + 2, + None, + None, + 1, + vec![offsets_buffer, data_buffer], + vec![], + ) + .unwrap(); + let array: StringArray = data.into(); + let expected: StringArray = vec![Some("c"), Some("d")].into_iter().collect(); + assert_eq!(array, expected); + } + + #[test] + #[should_panic(expected = "Last offset 8 of Utf8 is larger than values length 6")] + fn test_validate_offsets_last_too_large() { + let data_buffer = Buffer::from_slice_ref(&"abcdef".as_bytes()); + // 10 is off the end of the buffer + let offsets_buffer = Buffer::from_slice_ref(&[5i32, 7i32, 8i32]); + ArrayData::try_new( + DataType::Utf8, + 2, + None, + None, + 0, + vec![offsets_buffer, data_buffer], + vec![], + ) + .unwrap(); + } + + #[test] + #[should_panic( + expected = "Values length 4 is less than the length (2) multiplied by the value size (2) for FixedSizeList" + )] + fn test_validate_fixed_size_list() { + // child has 4 elements, + let child_array = vec![Some(1), Some(2), Some(3), None] + .into_iter() + .collect::(); + + // but claim we have 3 elements for a fixed size of 2 + // 10 is off the end of the buffer + let field = Field::new("field", DataType::Int32, true); + ArrayData::try_new( + DataType::FixedSizeList(Box::new(field), 2), + 3, + None, + None, + 0, + vec![], + vec![child_array.data().clone()], + ) + .unwrap(); + } + + #[test] + #[should_panic(expected = "Child type mismatch for Struct")] + fn test_validate_struct_child_type() { + let field1 = vec![Some(1), Some(2), Some(3), None] + .into_iter() + .collect::(); + + // validate the the type of struct fields matches child fields + ArrayData::try_new( + DataType::Struct(vec![Field::new("field1", DataType::Int64, true)]), + 3, + None, + None, + 0, + vec![], + vec![field1.data().clone()], + ) + .unwrap(); + } + + #[test] + #[should_panic( + expected = "child array #0 for field field1 has length smaller than expected for struct array (4 < 6)" + )] + fn test_validate_struct_child_length() { + // field length only has 4 items, but array claims to have 6 + let field1 = vec![Some(1), Some(2), Some(3), None] + .into_iter() + .collect::(); + + ArrayData::try_new( + DataType::Struct(vec![Field::new("field1", DataType::Int32, true)]), + 6, + None, + None, + 0, + vec![], + vec![field1.data().clone()], + ) + .unwrap(); + } + + /// returns a buffer initialized with some constant value for tests + fn make_i32_buffer(n: usize) -> Buffer { + Buffer::from_slice_ref(&vec![42i32; n]) + } + + /// returns a buffer initialized with some constant value for tests + fn make_f32_buffer(n: usize) -> Buffer { + Buffer::from_slice_ref(&vec![42f32; n]) + } } diff --git a/arrow/src/array/mod.rs b/arrow/src/array/mod.rs index 63b8b6146389..5d4e57a7625a 100644 --- a/arrow/src/array/mod.rs +++ b/arrow/src/array/mod.rs @@ -441,7 +441,7 @@ pub use self::ord::{build_compare, DynComparator}; pub use self::cast::{ as_boolean_array, as_dictionary_array, as_generic_binary_array, as_generic_list_array, as_large_list_array, as_largestring_array, as_list_array, - as_null_array, as_primitive_array, as_string_array, as_struct_array, + as_null_array, as_primitive_array, as_string_array, as_struct_array, as_union_array, }; // ------------------------------ C Data Interface --------------------------- diff --git a/arrow/src/array/transform/mod.rs b/arrow/src/array/transform/mod.rs index a598f0d7167e..2c1884861f68 100644 --- a/arrow/src/array/transform/mod.rs +++ b/arrow/src/array/transform/mod.rs @@ -182,8 +182,6 @@ fn build_extend_dictionary( max: usize, ) -> Option { use crate::datatypes::*; - use std::convert::TryInto; - match array.data_type() { DataType::Dictionary(child_data_type, _) => match child_data_type.as_ref() { DataType::UInt8 => { diff --git a/arrow/src/compute/kernels/cast.rs b/arrow/src/compute/kernels/cast.rs index 69733fa1bd9b..8b09df06aa89 100644 --- a/arrow/src/compute/kernels/cast.rs +++ b/arrow/src/compute/kernels/cast.rs @@ -68,6 +68,44 @@ pub fn can_cast_types(from_type: &DataType, to_type: &DataType) -> bool { } match (from_type, to_type) { + ( + Null, + Boolean + | Int8 + | UInt8 + | Int16 + | UInt16 + | Int32 + | UInt32 + | Float32 + | Date32 + | Time32(_) + | Int64 + | UInt64 + | Float64 + | Date64 + | List(_) + | Dictionary(_, _), + ) + | ( + Boolean + | Int8 + | UInt8 + | Int16 + | UInt16 + | Int32 + | UInt32 + | Float32 + | Date32 + | Time32(_) + | Int64 + | UInt64 + | Float64 + | Date64 + | List(_) + | Dictionary(_, _), + Null, + ) => true, (Struct(_), _) => false, (_, Struct(_)) => false, (LargeList(list_from), LargeList(list_to)) => { @@ -93,133 +131,71 @@ pub fn can_cast_types(from_type: &DataType, to_type: &DataType) -> bool { (Utf8, LargeUtf8) => true, (LargeUtf8, Utf8) => true, - (Utf8, Date32) => true, - (Utf8, Date64) => true, - (Utf8, Timestamp(TimeUnit::Nanosecond, None)) => true, + (Utf8, Date32 | Date64 | Timestamp(TimeUnit::Nanosecond, None)) => true, (Utf8, _) => DataType::is_numeric(to_type), - (LargeUtf8, Date32) => true, - (LargeUtf8, Date64) => true, - (LargeUtf8, Timestamp(TimeUnit::Nanosecond, None)) => true, + (LargeUtf8, Date32 | Date64 | Timestamp(TimeUnit::Nanosecond, None)) => true, (LargeUtf8, _) => DataType::is_numeric(to_type), (Timestamp(_, _), Utf8) | (Timestamp(_, _), LargeUtf8) => true, - (_, Utf8) | (_, LargeUtf8) => { - DataType::is_numeric(from_type) || from_type == &Binary - } + (_, Utf8 | LargeUtf8) => DataType::is_numeric(from_type) || from_type == &Binary, // start numeric casts - (UInt8, UInt16) => true, - (UInt8, UInt32) => true, - (UInt8, UInt64) => true, - (UInt8, Int8) => true, - (UInt8, Int16) => true, - (UInt8, Int32) => true, - (UInt8, Int64) => true, - (UInt8, Float32) => true, - (UInt8, Float64) => true, - - (UInt16, UInt8) => true, - (UInt16, UInt32) => true, - (UInt16, UInt64) => true, - (UInt16, Int8) => true, - (UInt16, Int16) => true, - (UInt16, Int32) => true, - (UInt16, Int64) => true, - (UInt16, Float32) => true, - (UInt16, Float64) => true, - - (UInt32, UInt8) => true, - (UInt32, UInt16) => true, - (UInt32, UInt64) => true, - (UInt32, Int8) => true, - (UInt32, Int16) => true, - (UInt32, Int32) => true, - (UInt32, Int64) => true, - (UInt32, Float32) => true, - (UInt32, Float64) => true, - - (UInt64, UInt8) => true, - (UInt64, UInt16) => true, - (UInt64, UInt32) => true, - (UInt64, Int8) => true, - (UInt64, Int16) => true, - (UInt64, Int32) => true, - (UInt64, Int64) => true, - (UInt64, Float32) => true, - (UInt64, Float64) => true, - - (Int8, UInt8) => true, - (Int8, UInt16) => true, - (Int8, UInt32) => true, - (Int8, UInt64) => true, - (Int8, Int16) => true, - (Int8, Int32) => true, - (Int8, Int64) => true, - (Int8, Float32) => true, - (Int8, Float64) => true, - - (Int16, UInt8) => true, - (Int16, UInt16) => true, - (Int16, UInt32) => true, - (Int16, UInt64) => true, - (Int16, Int8) => true, - (Int16, Int32) => true, - (Int16, Int64) => true, - (Int16, Float32) => true, - (Int16, Float64) => true, - - (Int32, UInt8) => true, - (Int32, UInt16) => true, - (Int32, UInt32) => true, - (Int32, UInt64) => true, - (Int32, Int8) => true, - (Int32, Int16) => true, - (Int32, Int64) => true, - (Int32, Float32) => true, - (Int32, Float64) => true, - - (Int64, UInt8) => true, - (Int64, UInt16) => true, - (Int64, UInt32) => true, - (Int64, UInt64) => true, - (Int64, Int8) => true, - (Int64, Int16) => true, - (Int64, Int32) => true, - (Int64, Float32) => true, - (Int64, Float64) => true, - - (Float32, UInt8) => true, - (Float32, UInt16) => true, - (Float32, UInt32) => true, - (Float32, UInt64) => true, - (Float32, Int8) => true, - (Float32, Int16) => true, - (Float32, Int32) => true, - (Float32, Int64) => true, - (Float32, Float64) => true, - - (Float64, UInt8) => true, - (Float64, UInt16) => true, - (Float64, UInt32) => true, - (Float64, UInt64) => true, - (Float64, Int8) => true, - (Float64, Int16) => true, - (Float64, Int32) => true, - (Float64, Int64) => true, - (Float64, Float32) => true, + ( + UInt8, + UInt16 | UInt32 | UInt64 | Int8 | Int16 | Int32 | Int64 | Float32 | Float64, + ) => true, + + ( + UInt16, + UInt8 | UInt32 | UInt64 | Int8 | Int16 | Int32 | Int64 | Float32 | Float64, + ) => true, + + ( + UInt32, + UInt8 | UInt16 | UInt64 | Int8 | Int16 | Int32 | Int64 | Float32 | Float64, + ) => true, + + ( + UInt64, + UInt8 | UInt16 | UInt32 | Int8 | Int16 | Int32 | Int64 | Float32 | Float64, + ) => true, + + ( + Int8, + UInt8 | UInt16 | UInt32 | UInt64 | Int16 | Int32 | Int64 | Float32 | Float64, + ) => true, + + ( + Int16, + UInt8 | UInt16 | UInt32 | UInt64 | Int8 | Int32 | Int64 | Float32 | Float64, + ) => true, + + ( + Int32, + UInt8 | UInt16 | UInt32 | UInt64 | Int8 | Int16 | Int64 | Float32 | Float64, + ) => true, + + ( + Int64, + UInt8 | UInt16 | UInt32 | UInt64 | Int8 | Int16 | Int32 | Float32 | Float64, + ) => true, + + ( + Float32, + UInt8 | UInt16 | UInt32 | UInt64 | Int8 | Int16 | Int32 | Int64 | Float64, + ) => true, + + ( + Float64, + UInt8 | UInt16 | UInt32 | UInt64 | Int8 | Int16 | Int32 | Int64 | Float32, + ) => true, // end numeric casts // temporal casts - (Int32, Date32) => true, - (Int32, Date64) => true, - (Int32, Time32(_)) => true, - (Date32, Int32) => true, - (Date32, Int64) => true, + (Int32, Date32 | Date64 | Time32(_)) => true, + (Date32, Int32 | Int64) => true, (Time32(_), Int32) => true, - (Int64, Date64) => true, - (Int64, Date32) => true, - (Int64, Time64(_)) => true, - (Date64, Int64) => true, - (Date64, Int32) => true, + (Int64, Date64 | Date32 | Time64(_)) => true, + (Date64, Int64 | Int32) => true, (Time64(_), Int64) => true, (Date32, Date64) => true, (Date64, Date32) => true, @@ -233,12 +209,9 @@ pub fn can_cast_types(from_type: &DataType, to_type: &DataType) -> bool { } (Timestamp(_, _), Int64) => true, (Int64, Timestamp(_, _)) => true, - (Timestamp(_, _), Timestamp(_, _)) => true, - (Timestamp(_, _), Date32) => true, - (Timestamp(_, _), Date64) => true, + (Timestamp(_, _), Timestamp(_, _) | Date32 | Date64) => true, // date64 to timestamp might not make sense, (Int64, Duration(_)) => true, - (Null, Int32) => true, (_, _) => false, } } @@ -301,6 +274,44 @@ pub fn cast_with_options( return Ok(array.clone()); } match (from_type, to_type) { + ( + Null, + Boolean + | Int8 + | UInt8 + | Int16 + | UInt16 + | Int32 + | UInt32 + | Float32 + | Date32 + | Time32(_) + | Int64 + | UInt64 + | Float64 + | Date64 + | List(_) + | Dictionary(_, _), + ) + | ( + Boolean + | Int8 + | UInt8 + | Int16 + | UInt16 + | Int32 + | UInt32 + | Float32 + | Date32 + | Time32(_) + | Int64 + | UInt64 + | Float64 + | Date64 + | List(_) + | Dictionary(_, _), + Null, + ) => Ok(new_null_array(to_type, array.len())), (Struct(_), _) => Err(ArrowError::CastError( "Cannot cast from struct to other types".to_string(), )), @@ -946,10 +957,6 @@ pub fn cast_with_options( } } } - - // null to primitive/flat types - (Null, Int32) => Ok(Arc::new(Int32Array::from(vec![None; array.len()]))), - (_, _) => Err(ArrowError::CastError(format!( "Casting from {:?} to {:?} not supported", from_type, to_type, @@ -2082,6 +2089,7 @@ mod tests { assert_eq!(4, values.null_count()); let u16arr = values.as_any().downcast_ref::().unwrap(); + // expect 4 nulls: negative numbers and overflow let expected: UInt16Array = vec![Some(0), Some(0), Some(0), None, None, None, Some(2), None] .into_iter() @@ -3518,17 +3526,39 @@ mod tests { } #[test] - fn test_cast_null_array_to_int32() { - let array = Arc::new(NullArray::new(6)) as ArrayRef; + fn test_cast_null_array_from_and_to_others() { + macro_rules! typed_test { + ($ARR_TYPE:ident, $DATATYPE:ident, $TYPE:tt) => {{ + { + let array = Arc::new(NullArray::new(6)) as ArrayRef; + let expected = $ARR_TYPE::from(vec![None; 6]); + let cast_type = DataType::$DATATYPE; + let cast_array = cast(&array, &cast_type).expect("cast failed"); + let cast_array = as_primitive_array::<$TYPE>(&cast_array); + assert_eq!(cast_array.data_type(), &cast_type); + assert_eq!(cast_array, &expected); + } + { + let array = Arc::new($ARR_TYPE::from(vec![None; 4])) as ArrayRef; + let expected = NullArray::new(4); + let cast_array = cast(&array, &DataType::Null).expect("cast failed"); + let cast_array = as_null_array(&cast_array); + assert_eq!(cast_array.data_type(), &DataType::Null); + assert_eq!(cast_array, &expected); + } + }}; + } - let expected = Int32Array::from(vec![None; 6]); + typed_test!(Int16Array, Int16, Int16Type); + typed_test!(Int32Array, Int32, Int32Type); + typed_test!(Int64Array, Int64, Int64Type); - // Cast to a dictionary (same value type, Utf8) - let cast_type = DataType::Int32; - let cast_array = cast(&array, &cast_type).expect("cast failed"); - let cast_array = as_primitive_array::(&cast_array); - assert_eq!(cast_array.data_type(), &cast_type); - assert_eq!(cast_array, &expected); + typed_test!(UInt16Array, UInt16, UInt16Type); + typed_test!(UInt32Array, UInt32, UInt32Type); + typed_test!(UInt64Array, UInt64, UInt64Type); + + typed_test!(Float32Array, Float32, Float32Type); + typed_test!(Float64Array, Float64, Float64Type); } /// Print the `DictionaryArray` `array` as a vector of strings diff --git a/arrow/src/compute/kernels/comparison.rs b/arrow/src/compute/kernels/comparison.rs index 1f0cb1a39cd2..9d49e899de8c 100644 --- a/arrow/src/compute/kernels/comparison.rs +++ b/arrow/src/compute/kernels/comparison.rs @@ -580,10 +580,8 @@ pub fn regexp_is_match_utf8_scalar( Some(flag) => format!("(?{}){}", flag, regex), None => regex.to_string(), }; - if pattern == *"" { - for _i in 0..array.len() { - result.append(true); - } + if pattern.is_empty() { + result.append_n(array.len(), true); } else { let re = Regex::new(pattern.as_str()).map_err(|e| { ArrowError::ComputeError(format!( @@ -597,6 +595,7 @@ pub fn regexp_is_match_utf8_scalar( } } + let buffer = result.finish(); let data = unsafe { ArrayData::new_unchecked( DataType::Boolean, @@ -604,7 +603,7 @@ pub fn regexp_is_match_utf8_scalar( None, null_bit_buffer, 0, - vec![result.finish()], + vec![buffer], vec![], ) }; @@ -657,37 +656,37 @@ where } /// Perform `left == right` operation on [`BooleanArray`] -fn eq_bool(left: &BooleanArray, right: &BooleanArray) -> Result { +pub fn eq_bool(left: &BooleanArray, right: &BooleanArray) -> Result { binary_boolean_op(left, right, |a, b| !(a ^ b)) } /// Perform `left != right` operation on [`BooleanArray`] -fn neq_bool(left: &BooleanArray, right: &BooleanArray) -> Result { +pub fn neq_bool(left: &BooleanArray, right: &BooleanArray) -> Result { binary_boolean_op(left, right, |a, b| (a ^ b)) } /// Perform `left < right` operation on [`BooleanArray`] -fn lt_bool(left: &BooleanArray, right: &BooleanArray) -> Result { +pub fn lt_bool(left: &BooleanArray, right: &BooleanArray) -> Result { binary_boolean_op(left, right, |a, b| ((!a) & b)) } /// Perform `left <= right` operation on [`BooleanArray`] -fn lt_eq_bool(left: &BooleanArray, right: &BooleanArray) -> Result { +pub fn lt_eq_bool(left: &BooleanArray, right: &BooleanArray) -> Result { binary_boolean_op(left, right, |a, b| !(a & (!b))) } /// Perform `left > right` operation on [`BooleanArray`] -fn gt_bool(left: &BooleanArray, right: &BooleanArray) -> Result { +pub fn gt_bool(left: &BooleanArray, right: &BooleanArray) -> Result { binary_boolean_op(left, right, |a, b| (a & (!b))) } /// Perform `left >= right` operation on [`BooleanArray`] -fn gt_eq_bool(left: &BooleanArray, right: &BooleanArray) -> Result { +pub fn gt_eq_bool(left: &BooleanArray, right: &BooleanArray) -> Result { binary_boolean_op(left, right, |a, b| !((!a) & b)) } /// Perform `left == right` operation on [`BooleanArray`] and a scalar -fn eq_bool_scalar(left: &BooleanArray, right: bool) -> Result { +pub fn eq_bool_scalar(left: &BooleanArray, right: bool) -> Result { let len = left.len(); let left_offset = left.offset(); @@ -716,7 +715,7 @@ fn eq_bool_scalar(left: &BooleanArray, right: bool) -> Result { } /// Perform `left != right` operation on [`BooleanArray`] and a scalar -fn neq_bool_scalar(left: &BooleanArray, right: bool) -> Result { +pub fn neq_bool_scalar(left: &BooleanArray, right: bool) -> Result { eq_bool_scalar(left, !right) } diff --git a/arrow/src/compute/util.rs b/arrow/src/compute/util.rs index f4ddbaf56d1e..e4808e25199c 100644 --- a/arrow/src/compute/util.rs +++ b/arrow/src/compute/util.rs @@ -184,7 +184,8 @@ pub(super) mod tests { offset: usize, null_bit_buffer: Option, ) -> Arc { - // empty vec for buffers and children is not really correct, but for these tests we only care about the null bitmap + let buffer = Buffer::from(&vec![11; len]); + Arc::new( ArrayData::try_new( DataType::UInt8, @@ -192,7 +193,7 @@ pub(super) mod tests { None, null_bit_buffer, offset, - vec![], + vec![buffer], vec![], ) .unwrap(), diff --git a/arrow/src/csv/reader.rs b/arrow/src/csv/reader.rs index bee9d073cd60..21924f78c5db 100644 --- a/arrow/src/csv/reader.rs +++ b/arrow/src/csv/reader.rs @@ -1343,6 +1343,8 @@ mod tests { assert_eq!(infer_field_schema("10"), DataType::Int64); assert_eq!(infer_field_schema("10.2"), DataType::Float64); assert_eq!(infer_field_schema(".2"), DataType::Float64); + // Should be parsed as Float or Int. See https://github.com/apache/arrow-rs/issues/929 + assert_eq!(infer_field_schema("2."), DataType::Utf8); assert_eq!(infer_field_schema("true"), DataType::Boolean); assert_eq!(infer_field_schema("false"), DataType::Boolean); assert_eq!(infer_field_schema("2020-11-08"), DataType::Date32); diff --git a/arrow/src/csv/writer.rs b/arrow/src/csv/writer.rs index c6e49f0d6a3d..50fd9ef7a0ad 100644 --- a/arrow/src/csv/writer.rs +++ b/arrow/src/csv/writer.rs @@ -35,7 +35,7 @@ //! Field::new("c1", DataType::Utf8, false), //! Field::new("c2", DataType::Float64, true), //! Field::new("c3", DataType::UInt32, false), -//! Field::new("c3", DataType::Boolean, true), +//! Field::new("c4", DataType::Boolean, true), //! ]); //! let c1 = StringArray::from(vec![ //! "Lorem ipsum dolor sit amet", diff --git a/arrow/src/datatypes/datatype.rs b/arrow/src/datatypes/datatype.rs index 1cbec341cf37..96fb18be6ec9 100644 --- a/arrow/src/datatypes/datatype.rs +++ b/arrow/src/datatypes/datatype.rs @@ -477,6 +477,16 @@ impl DataType { ) } + /// Returns true if this type is valid as a dictionary key + /// (e.g. [`super::ArrowDictionaryKeyType`] + pub fn is_dictionary_key_type(t: &DataType) -> bool { + use DataType::*; + matches!( + t, + UInt8 | UInt16 | UInt32 | UInt64 | Int8 | Int16 | Int32 | Int64 + ) + } + /// Compares the datatype with another, ignoring nested field names /// and metadata. pub(crate) fn equals_datatype(&self, other: &DataType) -> bool { diff --git a/arrow/src/datatypes/field.rs b/arrow/src/datatypes/field.rs index 497dbb389fd7..4ed06610e0dc 100644 --- a/arrow/src/datatypes/field.rs +++ b/arrow/src/datatypes/field.rs @@ -107,6 +107,36 @@ impl Field { self.nullable } + /// Returns a (flattened) vector containing all fields contained within this field (including it self) + pub(crate) fn fields(&self) -> Vec<&Field> { + let mut collected_fields = vec![self]; + match &self.data_type { + DataType::Struct(fields) | DataType::Union(fields) => { + collected_fields.extend(fields.iter().map(|f| f.fields()).flatten()) + } + DataType::List(field) + | DataType::LargeList(field) + | DataType::FixedSizeList(field, _) + | DataType::Map(field, _) => collected_fields.push(field), + _ => (), + } + + collected_fields + } + + /// Returns a vector containing all (potentially nested) `Field` instances selected by the + /// dictionary ID they use + #[inline] + pub(crate) fn fields_with_dict_id(&self, id: i64) -> Vec<&Field> { + self.fields() + .into_iter() + .filter(|&field| { + matches!(field.data_type(), DataType::Dictionary(_, _)) + && field.dict_id == id + }) + .collect() + } + /// Returns the dictionary ID, if this is a dictionary type. #[inline] pub const fn dict_id(&self) -> Option { @@ -572,3 +602,61 @@ impl std::fmt::Display for Field { write!(f, "{:?}", self) } } + +#[cfg(test)] +mod test { + use super::{DataType, Field}; + + #[test] + fn test_fields_with_dict_id() { + let dict1 = Field::new_dict( + "dict1", + DataType::Dictionary(DataType::Utf8.into(), DataType::Int32.into()), + false, + 10, + false, + ); + let dict2 = Field::new_dict( + "dict2", + DataType::Dictionary(DataType::Int32.into(), DataType::Int8.into()), + false, + 20, + false, + ); + + let field = Field::new( + "struct]>", + DataType::Struct(vec![ + dict1.clone(), + Field::new( + "list[struct]>]", + DataType::List(Box::new(Field::new( + "struct]>", + DataType::Struct(vec![ + dict1.clone(), + Field::new( + "list[struct]", + DataType::List(Box::new(Field::new( + "struct", + DataType::Struct(vec![dict2.clone()]), + false, + ))), + false, + ), + ]), + false, + ))), + false, + ), + ]), + false, + ); + + for field in field.fields_with_dict_id(10) { + assert_eq!(dict1, *field); + } + for field in field.fields_with_dict_id(20) { + assert_eq!(dict2, *field); + } + } +} diff --git a/arrow/src/datatypes/schema.rs b/arrow/src/datatypes/schema.rs index cfc0744954b1..cc8ddbd72bb3 100644 --- a/arrow/src/datatypes/schema.rs +++ b/arrow/src/datatypes/schema.rs @@ -159,6 +159,12 @@ impl Schema { &self.fields } + /// Returns a vector with references to all fields (including nested fields) + #[inline] + pub(crate) fn all_fields(&self) -> Vec<&Field> { + self.fields.iter().map(|f| f.fields()).flatten().collect() + } + /// Returns an immutable reference of a specific `Field` instance selected using an /// offset within the internal `fields` vector. pub fn field(&self, i: usize) -> &Field { @@ -175,7 +181,8 @@ impl Schema { pub fn fields_with_dict_id(&self, dict_id: i64) -> Vec<&Field> { self.fields .iter() - .filter(|f| f.dict_id() == Some(dict_id)) + .map(|f| f.fields_with_dict_id(dict_id)) + .flatten() .collect() } diff --git a/arrow/src/error.rs b/arrow/src/error.rs index 86896c016882..ef7abbbddef9 100644 --- a/arrow/src/error.rs +++ b/arrow/src/error.rs @@ -65,7 +65,7 @@ impl From for ArrowError { csv_crate::ErrorKind::Io(error) => ArrowError::CsvError(error.to_string()), csv_crate::ErrorKind::Utf8 { pos: _, err } => ArrowError::CsvError(format!( "Encountered UTF-8 error while reading CSV file: {}", - err.to_string() + err )), csv_crate::ErrorKind::UnequalLengths { expected_len, len, .. diff --git a/arrow/src/ffi.rs b/arrow/src/ffi.rs index a61f291bd4ab..ef79479f3efb 100644 --- a/arrow/src/ffi.rs +++ b/arrow/src/ffi.rs @@ -132,9 +132,9 @@ unsafe extern "C" fn release_schema(schema: *mut FFI_ArrowSchema) { let schema = &mut *schema; // take ownership back to release it. - CString::from_raw(schema.format as *mut c_char); + drop(CString::from_raw(schema.format as *mut c_char)); if !schema.name.is_null() { - CString::from_raw(schema.name as *mut c_char); + drop(CString::from_raw(schema.name as *mut c_char)); } if !schema.private_data.is_null() { let private_data = Box::from_raw(schema.private_data as *mut SchemaPrivateData); diff --git a/arrow/src/ipc/reader.rs b/arrow/src/ipc/reader.rs index e925e2af8f4b..3878586e50c2 100644 --- a/arrow/src/ipc/reader.rs +++ b/arrow/src/ipc/reader.rs @@ -495,7 +495,7 @@ pub fn read_dictionary( // in the reader. Note that a dictionary batch may be shared between many fields. // We don't currently record the isOrdered field. This could be general // attributes of arrays. - for (i, field) in schema.fields().iter().enumerate() { + for (i, field) in schema.all_fields().iter().enumerate() { if field.dict_id() == Some(id) { // Add (possibly multiple) array refs to the dictionaries array. dictionaries_by_field[i] = Some(dictionary_values.clone()); @@ -582,7 +582,7 @@ impl FileReader { let schema = ipc::convert::fb_to_schema(ipc_schema); // Create an array of optional dictionary value arrays, one per field. - let mut dictionaries_by_field = vec![None; schema.fields().len()]; + let mut dictionaries_by_field = vec![None; schema.all_fields().len()]; for block in footer.dictionaries().unwrap() { // read length from end of offset let mut message_size: [u8; 4] = [0; 4]; @@ -923,7 +923,7 @@ mod tests { use flate2::read::GzDecoder; - use crate::util::integration_util::*; + use crate::{datatypes, util::integration_util::*}; #[test] fn read_generated_files_014() { @@ -968,6 +968,22 @@ mod tests { FileReader::try_new(file).unwrap(); } + #[test] + #[should_panic( + expected = "Last offset 687865856 of Utf8 is larger than values length 41" + )] + fn read_dictionary_be_not_implemented() { + // The offsets are not translated for big-endian files + // https://github.com/apache/arrow-rs/issues/859 + let testdata = crate::util::test_util::arrow_test_data(); + let file = File::open(format!( + "{}/arrow-ipc-stream/integration/1.0.0-bigendian/generated_dictionary.arrow_file", + testdata + )) + .unwrap(); + FileReader::try_new(file).unwrap(); + } + #[test] fn read_generated_be_files_should_work() { // complementary to the previous test @@ -975,7 +991,6 @@ mod tests { let paths = vec![ "generated_interval", "generated_datetime", - "generated_dictionary", "generated_map", "generated_nested", "generated_null_trivial", @@ -1149,6 +1164,38 @@ mod tests { }) } + #[test] + fn test_roundtrip_nested_dict() { + let inner: DictionaryArray = + vec!["a", "b", "a"].into_iter().collect(); + + let array = Arc::new(inner) as ArrayRef; + + let dctfield = Field::new("dict", array.data_type().clone(), false); + + let s = StructArray::from(vec![(dctfield, array)]); + let struct_array = Arc::new(s) as ArrayRef; + + let schema = Arc::new(Schema::new(vec![Field::new( + "struct", + struct_array.data_type().clone(), + false, + )])); + + let batch = RecordBatch::try_new(schema.clone(), vec![struct_array]).unwrap(); + + let mut buf = Vec::new(); + let mut writer = ipc::writer::FileWriter::try_new(&mut buf, &schema).unwrap(); + writer.write(&batch).unwrap(); + writer.finish().unwrap(); + drop(writer); + + let reader = ipc::reader::FileReader::try_new(std::io::Cursor::new(buf)).unwrap(); + let batch2: std::result::Result, _> = reader.collect(); + + assert_eq!(batch, batch2.unwrap()[0]); + } + /// Read gzipped JSON file fn read_gzip_json(version: &str, path: &str) -> ArrowJson { let testdata = crate::util::test_util::arrow_test_data(); diff --git a/arrow/src/ipc/writer.rs b/arrow/src/ipc/writer.rs index 0376265f4f65..853fc0fc970b 100644 --- a/arrow/src/ipc/writer.rs +++ b/arrow/src/ipc/writer.rs @@ -25,7 +25,7 @@ use std::io::{BufWriter, Write}; use flatbuffers::FlatBufferBuilder; -use crate::array::{ArrayData, ArrayRef}; +use crate::array::{as_struct_array, as_union_array, ArrayData, ArrayRef}; use crate::buffer::{Buffer, MutableBuffer}; use crate::datatypes::*; use crate::error::{ArrowError, Result}; @@ -137,20 +137,45 @@ impl IpcDataGenerator { } } - pub fn encoded_batch( + fn encode_dictionaries( &self, - batch: &RecordBatch, + field: &Field, + column: &ArrayRef, + encoded_dictionaries: &mut Vec, dictionary_tracker: &mut DictionaryTracker, write_options: &IpcWriteOptions, - ) -> Result<(Vec, EncodedData)> { - // TODO: handle nested dictionaries - let schema = batch.schema(); - let mut encoded_dictionaries = Vec::with_capacity(schema.fields().len()); - - for (i, field) in schema.fields().iter().enumerate() { - let column = batch.column(i); - - if let DataType::Dictionary(_key_type, _value_type) = column.data_type() { + ) -> Result<()> { + // TODO: Handle other nested types (map, list, etc) + match column.data_type() { + DataType::Struct(fields) => { + let s = as_struct_array(column); + for (field, &column) in fields.iter().zip(s.columns().iter()) { + self.encode_dictionaries( + field, + column, + encoded_dictionaries, + dictionary_tracker, + write_options, + )?; + } + } + DataType::Union(fields) => { + let union = as_union_array(column); + for (field, ref column) in fields + .iter() + .enumerate() + .map(|(n, f)| (f, union.child(n as i8))) + { + self.encode_dictionaries( + field, + column, + encoded_dictionaries, + dictionary_tracker, + write_options, + )?; + } + } + DataType::Dictionary(_key_type, _value_type) => { let dict_id = field .dict_id() .expect("All Dictionary types have `dict_id`"); @@ -167,10 +192,33 @@ impl IpcDataGenerator { )); } } + _ => (), } - let encoded_message = self.record_batch_to_bytes(batch, write_options); + Ok(()) + } + + pub fn encoded_batch( + &self, + batch: &RecordBatch, + dictionary_tracker: &mut DictionaryTracker, + write_options: &IpcWriteOptions, + ) -> Result<(Vec, EncodedData)> { + let schema = batch.schema(); + let mut encoded_dictionaries = Vec::with_capacity(schema.fields().len()); + for (i, field) in schema.fields().iter().enumerate() { + let column = batch.column(i); + self.encode_dictionaries( + field, + column, + &mut encoded_dictionaries, + dictionary_tracker, + write_options, + )?; + } + + let encoded_message = self.record_batch_to_bytes(batch, write_options); Ok((encoded_dictionaries, encoded_message)) } @@ -1161,4 +1209,68 @@ mod tests { let arrow_json: ArrowJson = serde_json::from_str(&s).unwrap(); arrow_json } + + #[test] + fn track_union_nested_dict() { + let inner: DictionaryArray = vec!["a", "b", "a"].into_iter().collect(); + + let array = Arc::new(inner) as ArrayRef; + + // Dict field with id 2 + let dctfield = + Field::new_dict("dict", array.data_type().clone(), false, 2, false); + + let types = Buffer::from_slice_ref(&[0_i8, 0, 0]); + let offsets = Buffer::from_slice_ref(&[0_i32, 1, 2]); + + let union = + UnionArray::try_new(types, Some(offsets), vec![(dctfield, array)], None) + .unwrap(); + + let schema = Arc::new(Schema::new(vec![Field::new( + "union", + union.data_type().clone(), + false, + )])); + + let batch = RecordBatch::try_new(schema, vec![Arc::new(union)]).unwrap(); + + let gen = IpcDataGenerator {}; + let mut dict_tracker = DictionaryTracker::new(false); + gen.encoded_batch(&batch, &mut dict_tracker, &Default::default()) + .unwrap(); + + // Dictionary with id 2 should have been written to the dict tracker + assert!(dict_tracker.written.contains_key(&2)); + } + + #[test] + fn track_struct_nested_dict() { + let inner: DictionaryArray = vec!["a", "b", "a"].into_iter().collect(); + + let array = Arc::new(inner) as ArrayRef; + + // Dict field with id 2 + let dctfield = + Field::new_dict("dict", array.data_type().clone(), false, 2, false); + + let s = StructArray::from(vec![(dctfield, array)]); + let struct_array = Arc::new(s) as ArrayRef; + + let schema = Arc::new(Schema::new(vec![Field::new( + "struct", + struct_array.data_type().clone(), + false, + )])); + + let batch = RecordBatch::try_new(schema, vec![struct_array]).unwrap(); + + let gen = IpcDataGenerator {}; + let mut dict_tracker = DictionaryTracker::new(false); + gen.encoded_batch(&batch, &mut dict_tracker, &Default::default()) + .unwrap(); + + // Dictionary with id 2 should have been written to the dict tracker + assert!(dict_tracker.written.contains_key(&2)); + } } diff --git a/arrow/src/util/test_util.rs b/arrow/src/util/test_util.rs index 4b193f774178..f02c8d09831d 100644 --- a/arrow/src/util/test_util.rs +++ b/arrow/src/util/test_util.rs @@ -124,7 +124,7 @@ fn get_data_dir(udf_env: &str, submodule_data: &str) -> Result/dev/null 2>&1; then + sha256_verify="shasum -a 256 -c" + sha512_verify="shasum -a 512 -c" +else + sha256_verify="sha256sum -c" + sha512_verify="sha512sum -c" +fi + fetch_archive() { local dist_name=$1 download_rc_file ${dist_name}.tar.gz @@ -60,8 +68,8 @@ fetch_archive() { download_rc_file ${dist_name}.tar.gz.sha256 download_rc_file ${dist_name}.tar.gz.sha512 gpg --verify ${dist_name}.tar.gz.asc ${dist_name}.tar.gz - shasum -a 256 -c ${dist_name}.tar.gz.sha256 - shasum -a 512 -c ${dist_name}.tar.gz.sha512 + ${sha256_verify} ${dist_name}.tar.gz.sha256 + ${sha512_verify} ${dist_name}.tar.gz.sha512 } verify_dir_artifact_signatures() { @@ -75,9 +83,9 @@ verify_dir_artifact_signatures() { pushd $(dirname $artifact) base_artifact=$(basename $artifact) if [ -f $base_artifact.sha256 ]; then - shasum -a 256 -c $base_artifact.sha256 || exit 1 + ${sha256_verify} $base_artifact.sha256 || exit 1 fi - shasum -a 512 -c $base_artifact.sha512 || exit 1 + ${sha512_verify} $base_artifact.sha512 || exit 1 popd done } @@ -139,17 +147,9 @@ test_source_distribution() { cargo publish --dry-run popd - pushd arrow-flight - cargo publish --dry-run - popd - - pushd parquet - cargo publish --dry-run - popd + # Note can't verify parquet/arrow-flight/parquet-derive until arrow is actually published + # as they depend on arrow - pushd parquet_derive - cargo publish --dry-run - popd } TEST_SUCCESS=no diff --git a/integration-testing/Cargo.toml b/integration-testing/Cargo.toml index 7ee23a910f96..c59679c121d8 100644 --- a/integration-testing/Cargo.toml +++ b/integration-testing/Cargo.toml @@ -23,8 +23,9 @@ homepage = "https://github.com/apache/arrow-rs" repository = "https://github.com/apache/arrow-rs" authors = ["Apache Arrow "] license = "Apache-2.0" -edition = "2018" +edition = "2021" publish = false +rust-version = "1.56" [features] logging = ["tracing-subscriber"] @@ -36,10 +37,10 @@ async-trait = "0.1.41" clap = "2.33" futures = "0.3" hex = "0.4" -prost = "0.8" +prost = "0.9" serde = { version = "1.0", features = ["rc"] } serde_derive = "1.0" serde_json = { version = "1.0", features = ["preserve_order"] } tokio = { version = "1.0", features = ["macros", "rt", "rt-multi-thread"] } -tonic = "0.5" -tracing-subscriber = { version = "0.2.15", optional = true } +tonic = "0.6" +tracing-subscriber = { version = "0.3.1", optional = true } diff --git a/integration-testing/src/flight_server_scenarios/auth_basic_proto.rs b/integration-testing/src/flight_server_scenarios/auth_basic_proto.rs index ea7ad3c3385c..b6c11dc8e1a5 100644 --- a/integration-testing/src/flight_server_scenarios/auth_basic_proto.rs +++ b/integration-testing/src/flight_server_scenarios/auth_basic_proto.rs @@ -191,7 +191,8 @@ impl FlightService for AuthBasicProtoScenarioImpl { &self, request: Request>, ) -> Result, Status> { - self.check_auth(request.metadata()).await?; + let metadata = request.metadata(); + self.check_auth(metadata).await?; Err(Status::unimplemented("Not yet implemented")) } @@ -219,7 +220,8 @@ impl FlightService for AuthBasicProtoScenarioImpl { &self, request: Request>, ) -> Result, Status> { - self.check_auth(request.metadata()).await?; + let metadata = request.metadata(); + self.check_auth(metadata).await?; Err(Status::unimplemented("Not yet implemented")) } } diff --git a/parquet/Cargo.toml b/parquet/Cargo.toml index 289513fbed3c..664f74b0702f 100644 --- a/parquet/Cargo.toml +++ b/parquet/Cargo.toml @@ -26,7 +26,8 @@ authors = ["Apache Arrow "] keywords = [ "arrow", "parquet", "hadoop" ] readme = "README.md" build = "build.rs" -edition = "2018" +edition = "2021" +rust-version = "1.56" [dependencies] # update note: pin `parquet-format` to specific version until it does not break at minor diff --git a/parquet/src/data_type.rs b/parquet/src/data_type.rs index 8c64e8629463..6f3468af8381 100644 --- a/parquet/src/data_type.rs +++ b/parquet/src/data_type.rs @@ -36,7 +36,7 @@ use crate::util::{ /// Rust representation for logical type INT96, value is backed by an array of `u32`. /// The type only takes 12 bytes, without extra padding. -#[derive(Clone, Debug, PartialOrd)] +#[derive(Clone, Debug, PartialOrd, Default)] pub struct Int96 { value: Option<[u32; 3]>, } @@ -75,12 +75,6 @@ impl Int96 { } } -impl Default for Int96 { - fn default() -> Self { - Self { value: None } - } -} - impl PartialEq for Int96 { fn eq(&self, other: &Int96) -> bool { match (&self.value, &other.value) { @@ -109,7 +103,7 @@ impl fmt::Display for Int96 { /// Rust representation for BYTE_ARRAY and FIXED_LEN_BYTE_ARRAY Parquet physical types. /// Value is backed by a byte buffer. -#[derive(Clone)] +#[derive(Clone, Default)] pub struct ByteArray { data: Option, } @@ -231,12 +225,6 @@ impl From for ByteArray { } } -impl Default for ByteArray { - fn default() -> Self { - ByteArray { data: None } - } -} - impl PartialEq for ByteArray { fn eq(&self, other: &ByteArray) -> bool { match (&self.data, &other.data) { diff --git a/parquet/src/file/mod.rs b/parquet/src/file/mod.rs index f85de98ccab6..47d8258694d7 100644 --- a/parquet/src/file/mod.rs +++ b/parquet/src/file/mod.rs @@ -19,7 +19,7 @@ //! //! Provides access to file and row group readers and writers, record API, metadata, etc. //! -//! See [`reader::SerializedFileReader`](reader/struct.SerializedFileReader.html) or +//! See [`serialized_reader::SerializedFileReader`](serialized_reader/struct.SerializedFileReader.html) or //! [`writer::SerializedFileWriter`](writer/struct.SerializedFileWriter.html) for a //! starting reference, [`metadata::ParquetMetaData`](metadata/index.html) for file //! metadata, and [`statistics`](statistics/index.html) for working with statistics. diff --git a/parquet/src/record/reader.rs b/parquet/src/record/reader.rs index 8f901f59c3d4..c45e09738b07 100644 --- a/parquet/src/record/reader.rs +++ b/parquet/src/record/reader.rs @@ -136,7 +136,7 @@ impl TreeBuilder { .column_descr_ptr(); let col_reader = row_group_reader.get_column_reader(orig_index).unwrap(); let column = TripletIter::new(col_descr, col_reader, self.batch_size); - Reader::PrimitiveReader(field, column) + Reader::PrimitiveReader(field, Box::new(column)) } else { match field.get_basic_info().converted_type() { // List types @@ -319,7 +319,7 @@ impl TreeBuilder { /// Reader tree for record assembly pub enum Reader { // Primitive reader with type information and triplet iterator - PrimitiveReader(TypePtr, TripletIter), + PrimitiveReader(TypePtr, Box), // Optional reader with definition level of a parent and a reader OptionReader(i16, Box), // Group (struct) reader with type information, definition level and list of child diff --git a/parquet/src/schema/parser.rs b/parquet/src/schema/parser.rs index ba1f566f1792..3a840d209769 100644 --- a/parquet/src/schema/parser.rs +++ b/parquet/src/schema/parser.rs @@ -77,7 +77,7 @@ impl<'a> Tokenizer<'a> { pub fn from_str(string: &'a str) -> Self { let vec = string .split_whitespace() - .flat_map(|t| Self::split_token(t)) + .flat_map(Self::split_token) .collect(); Tokenizer { tokens: vec, diff --git a/parquet/src/util/bit_packing.rs b/parquet/src/util/bit_packing.rs index 6b9673f6c307..758992ab2723 100644 --- a/parquet/src/util/bit_packing.rs +++ b/parquet/src/util/bit_packing.rs @@ -79,3584 +79,3584 @@ unsafe fn nullunpacker32(in_buf: *const u32, mut out: *mut u32) -> *const u32 { } unsafe fn unpack1_32(in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) & 1; + *out = (in_buf.read_unaligned()) & 1; out = out.offset(1); - *out = ((*in_buf) >> 1) & 1; + *out = ((in_buf.read_unaligned()) >> 1) & 1; out = out.offset(1); - *out = ((*in_buf) >> 2) & 1; + *out = ((in_buf.read_unaligned()) >> 2) & 1; out = out.offset(1); - *out = ((*in_buf) >> 3) & 1; + *out = ((in_buf.read_unaligned()) >> 3) & 1; out = out.offset(1); - *out = ((*in_buf) >> 4) & 1; + *out = ((in_buf.read_unaligned()) >> 4) & 1; out = out.offset(1); - *out = ((*in_buf) >> 5) & 1; + *out = ((in_buf.read_unaligned()) >> 5) & 1; out = out.offset(1); - *out = ((*in_buf) >> 6) & 1; + *out = ((in_buf.read_unaligned()) >> 6) & 1; out = out.offset(1); - *out = ((*in_buf) >> 7) & 1; + *out = ((in_buf.read_unaligned()) >> 7) & 1; out = out.offset(1); - *out = ((*in_buf) >> 8) & 1; + *out = ((in_buf.read_unaligned()) >> 8) & 1; out = out.offset(1); - *out = ((*in_buf) >> 9) & 1; + *out = ((in_buf.read_unaligned()) >> 9) & 1; out = out.offset(1); - *out = ((*in_buf) >> 10) & 1; + *out = ((in_buf.read_unaligned()) >> 10) & 1; out = out.offset(1); - *out = ((*in_buf) >> 11) & 1; + *out = ((in_buf.read_unaligned()) >> 11) & 1; out = out.offset(1); - *out = ((*in_buf) >> 12) & 1; + *out = ((in_buf.read_unaligned()) >> 12) & 1; out = out.offset(1); - *out = ((*in_buf) >> 13) & 1; + *out = ((in_buf.read_unaligned()) >> 13) & 1; out = out.offset(1); - *out = ((*in_buf) >> 14) & 1; + *out = ((in_buf.read_unaligned()) >> 14) & 1; out = out.offset(1); - *out = ((*in_buf) >> 15) & 1; + *out = ((in_buf.read_unaligned()) >> 15) & 1; out = out.offset(1); - *out = ((*in_buf) >> 16) & 1; + *out = ((in_buf.read_unaligned()) >> 16) & 1; out = out.offset(1); - *out = ((*in_buf) >> 17) & 1; + *out = ((in_buf.read_unaligned()) >> 17) & 1; out = out.offset(1); - *out = ((*in_buf) >> 18) & 1; + *out = ((in_buf.read_unaligned()) >> 18) & 1; out = out.offset(1); - *out = ((*in_buf) >> 19) & 1; + *out = ((in_buf.read_unaligned()) >> 19) & 1; out = out.offset(1); - *out = ((*in_buf) >> 20) & 1; + *out = ((in_buf.read_unaligned()) >> 20) & 1; out = out.offset(1); - *out = ((*in_buf) >> 21) & 1; + *out = ((in_buf.read_unaligned()) >> 21) & 1; out = out.offset(1); - *out = ((*in_buf) >> 22) & 1; + *out = ((in_buf.read_unaligned()) >> 22) & 1; out = out.offset(1); - *out = ((*in_buf) >> 23) & 1; + *out = ((in_buf.read_unaligned()) >> 23) & 1; out = out.offset(1); - *out = ((*in_buf) >> 24) & 1; + *out = ((in_buf.read_unaligned()) >> 24) & 1; out = out.offset(1); - *out = ((*in_buf) >> 25) & 1; + *out = ((in_buf.read_unaligned()) >> 25) & 1; out = out.offset(1); - *out = ((*in_buf) >> 26) & 1; + *out = ((in_buf.read_unaligned()) >> 26) & 1; out = out.offset(1); - *out = ((*in_buf) >> 27) & 1; + *out = ((in_buf.read_unaligned()) >> 27) & 1; out = out.offset(1); - *out = ((*in_buf) >> 28) & 1; + *out = ((in_buf.read_unaligned()) >> 28) & 1; out = out.offset(1); - *out = ((*in_buf) >> 29) & 1; + *out = ((in_buf.read_unaligned()) >> 29) & 1; out = out.offset(1); - *out = ((*in_buf) >> 30) & 1; + *out = ((in_buf.read_unaligned()) >> 30) & 1; out = out.offset(1); - *out = (*in_buf) >> 31; + *out = (in_buf.read_unaligned()) >> 31; in_buf.offset(1) } unsafe fn unpack2_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 2); + *out = (in_buf.read_unaligned()) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 10) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 10) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 14) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 14) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 18) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 18) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 20) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 20) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 22) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 22) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 24) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 24) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 26) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 26) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 28) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 28) % (1u32 << 2); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 2); + *out = (in_buf.read_unaligned()) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 10) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 10) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 14) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 14) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 18) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 18) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 20) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 20) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 22) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 22) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 24) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 24) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 26) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 26) % (1u32 << 2); out = out.offset(1); - *out = ((*in_buf) >> 28) % (1u32 << 2); + *out = ((in_buf.read_unaligned()) >> 28) % (1u32 << 2); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf.offset(1) } unsafe fn unpack3_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 3); + *out = (in_buf.read_unaligned()) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 3) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 3) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 9) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 9) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 15) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 15) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 18) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 18) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 21) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 21) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 24) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 24) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 27) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 27) % (1u32 << 3); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 1)) << (3 - 1); + *out |= ((in_buf.read_unaligned()) % (1u32 << 1)) << (3 - 1); out = out.offset(1); - *out = ((*in_buf) >> 1) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 1) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 7) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 7) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 10) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 10) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 13) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 13) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 19) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 19) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 22) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 22) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 25) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 25) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 28) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 28) % (1u32 << 3); out = out.offset(1); - *out = (*in_buf) >> 31; + *out = (in_buf.read_unaligned()) >> 31; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (3 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (3 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 5) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 5) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 11) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 11) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 14) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 14) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 17) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 17) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 20) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 20) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 23) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 23) % (1u32 << 3); out = out.offset(1); - *out = ((*in_buf) >> 26) % (1u32 << 3); + *out = ((in_buf.read_unaligned()) >> 26) % (1u32 << 3); out = out.offset(1); - *out = (*in_buf) >> 29; + *out = (in_buf.read_unaligned()) >> 29; in_buf.offset(1) } unsafe fn unpack4_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 4); + *out = (in_buf.read_unaligned()) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 20) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 20) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 24) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 24) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 28) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 28) % (1u32 << 4); out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 4); + *out = (in_buf.read_unaligned()) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 20) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 20) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 24) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 24) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 28) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 28) % (1u32 << 4); out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 4); + *out = (in_buf.read_unaligned()) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 20) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 20) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 24) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 24) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 28) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 28) % (1u32 << 4); out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 4); + *out = (in_buf.read_unaligned()) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 20) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 20) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 24) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 24) % (1u32 << 4); out = out.offset(1); - *out = ((*in_buf) >> 28) % (1u32 << 4); + *out = ((in_buf.read_unaligned()) >> 28) % (1u32 << 4); in_buf.offset(1) } unsafe fn unpack5_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 5); + *out = (in_buf.read_unaligned()) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 5) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 5) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 10) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 10) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 15) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 15) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 20) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 20) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 25) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 25) % (1u32 << 5); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 3)) << (5 - 3); + *out |= ((in_buf.read_unaligned()) % (1u32 << 3)) << (5 - 3); out = out.offset(1); - *out = ((*in_buf) >> 3) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 3) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 13) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 13) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 18) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 18) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 23) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 23) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 28) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 28) % (1u32 << 5); in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 1)) << (5 - 1); + *out |= ((in_buf.read_unaligned()) % (1u32 << 1)) << (5 - 1); out = out.offset(1); - *out = ((*in_buf) >> 1) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 1) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 11) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 11) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 21) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 21) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 26) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 26) % (1u32 << 5); out = out.offset(1); - *out = (*in_buf) >> 31; + *out = (in_buf.read_unaligned()) >> 31; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (5 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (5 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 9) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 9) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 14) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 14) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 19) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 19) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 24) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 24) % (1u32 << 5); out = out.offset(1); - *out = (*in_buf) >> 29; + *out = (in_buf.read_unaligned()) >> 29; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (5 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (5 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 7) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 7) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 17) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 17) % (1u32 << 5); out = out.offset(1); - *out = ((*in_buf) >> 22) % (1u32 << 5); + *out = ((in_buf.read_unaligned()) >> 22) % (1u32 << 5); out = out.offset(1); - *out = (*in_buf) >> 27; + *out = (in_buf.read_unaligned()) >> 27; in_buf.offset(1) } unsafe fn unpack6_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 6); + *out = (in_buf.read_unaligned()) % (1u32 << 6); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 6); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 6); out = out.offset(1); - *out = ((*in_buf) >> 18) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 18) % (1u32 << 6); out = out.offset(1); - *out = ((*in_buf) >> 24) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 24) % (1u32 << 6); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (6 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (6 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 6); out = out.offset(1); - *out = ((*in_buf) >> 10) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 10) % (1u32 << 6); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 6); out = out.offset(1); - *out = ((*in_buf) >> 22) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 22) % (1u32 << 6); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (6 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (6 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 6); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 6); out = out.offset(1); - *out = ((*in_buf) >> 14) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 14) % (1u32 << 6); out = out.offset(1); - *out = ((*in_buf) >> 20) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 20) % (1u32 << 6); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 6); + *out = (in_buf.read_unaligned()) % (1u32 << 6); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 6); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 6); out = out.offset(1); - *out = ((*in_buf) >> 18) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 18) % (1u32 << 6); out = out.offset(1); - *out = ((*in_buf) >> 24) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 24) % (1u32 << 6); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (6 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (6 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 6); out = out.offset(1); - *out = ((*in_buf) >> 10) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 10) % (1u32 << 6); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 6); out = out.offset(1); - *out = ((*in_buf) >> 22) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 22) % (1u32 << 6); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (6 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (6 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 6); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 6); out = out.offset(1); - *out = ((*in_buf) >> 14) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 14) % (1u32 << 6); out = out.offset(1); - *out = ((*in_buf) >> 20) % (1u32 << 6); + *out = ((in_buf.read_unaligned()) >> 20) % (1u32 << 6); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf.offset(1) } unsafe fn unpack7_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 7); + *out = (in_buf.read_unaligned()) % (1u32 << 7); out = out.offset(1); - *out = ((*in_buf) >> 7) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 7) % (1u32 << 7); out = out.offset(1); - *out = ((*in_buf) >> 14) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 14) % (1u32 << 7); out = out.offset(1); - *out = ((*in_buf) >> 21) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 21) % (1u32 << 7); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 3)) << (7 - 3); + *out |= ((in_buf.read_unaligned()) % (1u32 << 3)) << (7 - 3); out = out.offset(1); - *out = ((*in_buf) >> 3) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 3) % (1u32 << 7); out = out.offset(1); - *out = ((*in_buf) >> 10) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 10) % (1u32 << 7); out = out.offset(1); - *out = ((*in_buf) >> 17) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 17) % (1u32 << 7); out = out.offset(1); - *out = ((*in_buf) >> 24) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 24) % (1u32 << 7); out = out.offset(1); - *out = (*in_buf) >> 31; + *out = (in_buf.read_unaligned()) >> 31; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (7 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (7 - 6); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 7); out = out.offset(1); - *out = ((*in_buf) >> 13) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 13) % (1u32 << 7); out = out.offset(1); - *out = ((*in_buf) >> 20) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 20) % (1u32 << 7); out = out.offset(1); - *out = (*in_buf) >> 27; + *out = (in_buf.read_unaligned()) >> 27; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (7 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (7 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 7); out = out.offset(1); - *out = ((*in_buf) >> 9) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 9) % (1u32 << 7); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 7); out = out.offset(1); - *out = ((*in_buf) >> 23) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 23) % (1u32 << 7); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 5)) << (7 - 5); + *out |= ((in_buf.read_unaligned()) % (1u32 << 5)) << (7 - 5); out = out.offset(1); - *out = ((*in_buf) >> 5) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 5) % (1u32 << 7); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 7); out = out.offset(1); - *out = ((*in_buf) >> 19) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 19) % (1u32 << 7); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 1)) << (7 - 1); + *out |= ((in_buf.read_unaligned()) % (1u32 << 1)) << (7 - 1); out = out.offset(1); - *out = ((*in_buf) >> 1) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 1) % (1u32 << 7); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 7); out = out.offset(1); - *out = ((*in_buf) >> 15) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 15) % (1u32 << 7); out = out.offset(1); - *out = ((*in_buf) >> 22) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 22) % (1u32 << 7); out = out.offset(1); - *out = (*in_buf) >> 29; + *out = (in_buf.read_unaligned()) >> 29; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (7 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (7 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 7); out = out.offset(1); - *out = ((*in_buf) >> 11) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 11) % (1u32 << 7); out = out.offset(1); - *out = ((*in_buf) >> 18) % (1u32 << 7); + *out = ((in_buf.read_unaligned()) >> 18) % (1u32 << 7); out = out.offset(1); - *out = (*in_buf) >> 25; + *out = (in_buf.read_unaligned()) >> 25; in_buf.offset(1) } unsafe fn unpack8_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 8); + *out = (in_buf.read_unaligned()) % (1u32 << 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 8); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 8); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 8); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 8); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 8); + *out = (in_buf.read_unaligned()) % (1u32 << 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 8); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 8); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 8); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 8); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 8); + *out = (in_buf.read_unaligned()) % (1u32 << 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 8); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 8); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 8); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 8); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 8); + *out = (in_buf.read_unaligned()) % (1u32 << 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 8); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 8); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 8); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 8); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 8); + *out = (in_buf.read_unaligned()) % (1u32 << 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 8); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 8); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 8); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 8); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 8); + *out = (in_buf.read_unaligned()) % (1u32 << 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 8); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 8); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 8); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 8); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 8); + *out = (in_buf.read_unaligned()) % (1u32 << 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 8); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 8); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 8); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 8); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 8); + *out = (in_buf.read_unaligned()) % (1u32 << 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 8); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 8); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 8); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 8); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf.offset(1) } unsafe fn unpack9_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 9); + *out = (in_buf.read_unaligned()) % (1u32 << 9); out = out.offset(1); - *out = ((*in_buf) >> 9) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 9) % (1u32 << 9); out = out.offset(1); - *out = ((*in_buf) >> 18) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 18) % (1u32 << 9); out = out.offset(1); - *out = (*in_buf) >> 27; + *out = (in_buf.read_unaligned()) >> 27; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (9 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (9 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 9); out = out.offset(1); - *out = ((*in_buf) >> 13) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 13) % (1u32 << 9); out = out.offset(1); - *out = ((*in_buf) >> 22) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 22) % (1u32 << 9); out = out.offset(1); - *out = (*in_buf) >> 31; + *out = (in_buf.read_unaligned()) >> 31; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (9 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (9 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 9); out = out.offset(1); - *out = ((*in_buf) >> 17) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 17) % (1u32 << 9); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 3)) << (9 - 3); + *out |= ((in_buf.read_unaligned()) % (1u32 << 3)) << (9 - 3); out = out.offset(1); - *out = ((*in_buf) >> 3) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 3) % (1u32 << 9); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 9); out = out.offset(1); - *out = ((*in_buf) >> 21) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 21) % (1u32 << 9); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 7)) << (9 - 7); + *out |= ((in_buf.read_unaligned()) % (1u32 << 7)) << (9 - 7); out = out.offset(1); - *out = ((*in_buf) >> 7) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 7) % (1u32 << 9); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 9); out = out.offset(1); - *out = (*in_buf) >> 25; + *out = (in_buf.read_unaligned()) >> 25; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (9 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (9 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 9); out = out.offset(1); - *out = ((*in_buf) >> 11) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 11) % (1u32 << 9); out = out.offset(1); - *out = ((*in_buf) >> 20) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 20) % (1u32 << 9); out = out.offset(1); - *out = (*in_buf) >> 29; + *out = (in_buf.read_unaligned()) >> 29; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (9 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (9 - 6); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 9); out = out.offset(1); - *out = ((*in_buf) >> 15) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 15) % (1u32 << 9); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 1)) << (9 - 1); + *out |= ((in_buf.read_unaligned()) % (1u32 << 1)) << (9 - 1); out = out.offset(1); - *out = ((*in_buf) >> 1) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 1) % (1u32 << 9); out = out.offset(1); - *out = ((*in_buf) >> 10) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 10) % (1u32 << 9); out = out.offset(1); - *out = ((*in_buf) >> 19) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 19) % (1u32 << 9); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 5)) << (9 - 5); + *out |= ((in_buf.read_unaligned()) % (1u32 << 5)) << (9 - 5); out = out.offset(1); - *out = ((*in_buf) >> 5) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 5) % (1u32 << 9); out = out.offset(1); - *out = ((*in_buf) >> 14) % (1u32 << 9); + *out = ((in_buf.read_unaligned()) >> 14) % (1u32 << 9); out = out.offset(1); - *out = (*in_buf) >> 23; + *out = (in_buf.read_unaligned()) >> 23; in_buf.offset(1) } unsafe fn unpack10_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 10); + *out = (in_buf.read_unaligned()) % (1u32 << 10); out = out.offset(1); - *out = ((*in_buf) >> 10) % (1u32 << 10); + *out = ((in_buf.read_unaligned()) >> 10) % (1u32 << 10); out = out.offset(1); - *out = ((*in_buf) >> 20) % (1u32 << 10); + *out = ((in_buf.read_unaligned()) >> 20) % (1u32 << 10); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (10 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (10 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 10); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 10); out = out.offset(1); - *out = ((*in_buf) >> 18) % (1u32 << 10); + *out = ((in_buf.read_unaligned()) >> 18) % (1u32 << 10); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (10 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (10 - 6); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 10); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 10); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 10); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 10); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (10 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (10 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 10); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 10); out = out.offset(1); - *out = ((*in_buf) >> 14) % (1u32 << 10); + *out = ((in_buf.read_unaligned()) >> 14) % (1u32 << 10); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (10 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (10 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 10); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 10); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 10); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 10); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 10); + *out = (in_buf.read_unaligned()) % (1u32 << 10); out = out.offset(1); - *out = ((*in_buf) >> 10) % (1u32 << 10); + *out = ((in_buf.read_unaligned()) >> 10) % (1u32 << 10); out = out.offset(1); - *out = ((*in_buf) >> 20) % (1u32 << 10); + *out = ((in_buf.read_unaligned()) >> 20) % (1u32 << 10); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (10 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (10 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 10); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 10); out = out.offset(1); - *out = ((*in_buf) >> 18) % (1u32 << 10); + *out = ((in_buf.read_unaligned()) >> 18) % (1u32 << 10); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (10 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (10 - 6); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 10); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 10); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 10); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 10); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (10 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (10 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 10); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 10); out = out.offset(1); - *out = ((*in_buf) >> 14) % (1u32 << 10); + *out = ((in_buf.read_unaligned()) >> 14) % (1u32 << 10); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (10 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (10 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 10); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 10); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 10); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 10); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf.offset(1) } unsafe fn unpack11_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 11); + *out = (in_buf.read_unaligned()) % (1u32 << 11); out = out.offset(1); - *out = ((*in_buf) >> 11) % (1u32 << 11); + *out = ((in_buf.read_unaligned()) >> 11) % (1u32 << 11); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 1)) << (11 - 1); + *out |= ((in_buf.read_unaligned()) % (1u32 << 1)) << (11 - 1); out = out.offset(1); - *out = ((*in_buf) >> 1) % (1u32 << 11); + *out = ((in_buf.read_unaligned()) >> 1) % (1u32 << 11); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 11); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 11); out = out.offset(1); - *out = (*in_buf) >> 23; + *out = (in_buf.read_unaligned()) >> 23; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (11 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (11 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 11); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 11); out = out.offset(1); - *out = ((*in_buf) >> 13) % (1u32 << 11); + *out = ((in_buf.read_unaligned()) >> 13) % (1u32 << 11); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 3)) << (11 - 3); + *out |= ((in_buf.read_unaligned()) % (1u32 << 3)) << (11 - 3); out = out.offset(1); - *out = ((*in_buf) >> 3) % (1u32 << 11); + *out = ((in_buf.read_unaligned()) >> 3) % (1u32 << 11); out = out.offset(1); - *out = ((*in_buf) >> 14) % (1u32 << 11); + *out = ((in_buf.read_unaligned()) >> 14) % (1u32 << 11); out = out.offset(1); - *out = (*in_buf) >> 25; + *out = (in_buf.read_unaligned()) >> 25; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (11 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (11 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 11); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 11); out = out.offset(1); - *out = ((*in_buf) >> 15) % (1u32 << 11); + *out = ((in_buf.read_unaligned()) >> 15) % (1u32 << 11); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 5)) << (11 - 5); + *out |= ((in_buf.read_unaligned()) % (1u32 << 5)) << (11 - 5); out = out.offset(1); - *out = ((*in_buf) >> 5) % (1u32 << 11); + *out = ((in_buf.read_unaligned()) >> 5) % (1u32 << 11); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 11); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 11); out = out.offset(1); - *out = (*in_buf) >> 27; + *out = (in_buf.read_unaligned()) >> 27; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (11 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (11 - 6); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 11); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 11); out = out.offset(1); - *out = ((*in_buf) >> 17) % (1u32 << 11); + *out = ((in_buf.read_unaligned()) >> 17) % (1u32 << 11); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 7)) << (11 - 7); + *out |= ((in_buf.read_unaligned()) % (1u32 << 7)) << (11 - 7); out = out.offset(1); - *out = ((*in_buf) >> 7) % (1u32 << 11); + *out = ((in_buf.read_unaligned()) >> 7) % (1u32 << 11); out = out.offset(1); - *out = ((*in_buf) >> 18) % (1u32 << 11); + *out = ((in_buf.read_unaligned()) >> 18) % (1u32 << 11); out = out.offset(1); - *out = (*in_buf) >> 29; + *out = (in_buf.read_unaligned()) >> 29; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (11 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (11 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 11); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 11); out = out.offset(1); - *out = ((*in_buf) >> 19) % (1u32 << 11); + *out = ((in_buf.read_unaligned()) >> 19) % (1u32 << 11); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 9)) << (11 - 9); + *out |= ((in_buf.read_unaligned()) % (1u32 << 9)) << (11 - 9); out = out.offset(1); - *out = ((*in_buf) >> 9) % (1u32 << 11); + *out = ((in_buf.read_unaligned()) >> 9) % (1u32 << 11); out = out.offset(1); - *out = ((*in_buf) >> 20) % (1u32 << 11); + *out = ((in_buf.read_unaligned()) >> 20) % (1u32 << 11); out = out.offset(1); - *out = (*in_buf) >> 31; + *out = (in_buf.read_unaligned()) >> 31; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 10)) << (11 - 10); + *out |= ((in_buf.read_unaligned()) % (1u32 << 10)) << (11 - 10); out = out.offset(1); - *out = ((*in_buf) >> 10) % (1u32 << 11); + *out = ((in_buf.read_unaligned()) >> 10) % (1u32 << 11); out = out.offset(1); - *out = (*in_buf) >> 21; + *out = (in_buf.read_unaligned()) >> 21; in_buf.offset(1) } unsafe fn unpack12_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 12); + *out = (in_buf.read_unaligned()) % (1u32 << 12); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 12); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 12); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (12 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (12 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 12); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 12); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 12); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 12); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (12 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (12 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 12); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 12); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 12); + *out = (in_buf.read_unaligned()) % (1u32 << 12); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 12); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 12); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (12 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (12 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 12); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 12); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 12); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 12); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (12 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (12 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 12); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 12); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 12); + *out = (in_buf.read_unaligned()) % (1u32 << 12); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 12); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 12); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (12 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (12 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 12); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 12); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 12); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 12); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (12 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (12 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 12); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 12); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 12); + *out = (in_buf.read_unaligned()) % (1u32 << 12); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 12); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 12); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (12 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (12 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 12); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 12); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 12); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 12); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (12 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (12 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 12); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 12); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf.offset(1) } unsafe fn unpack13_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 13); + *out = (in_buf.read_unaligned()) % (1u32 << 13); out = out.offset(1); - *out = ((*in_buf) >> 13) % (1u32 << 13); + *out = ((in_buf.read_unaligned()) >> 13) % (1u32 << 13); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 7)) << (13 - 7); + *out |= ((in_buf.read_unaligned()) % (1u32 << 7)) << (13 - 7); out = out.offset(1); - *out = ((*in_buf) >> 7) % (1u32 << 13); + *out = ((in_buf.read_unaligned()) >> 7) % (1u32 << 13); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 1)) << (13 - 1); + *out |= ((in_buf.read_unaligned()) % (1u32 << 1)) << (13 - 1); out = out.offset(1); - *out = ((*in_buf) >> 1) % (1u32 << 13); + *out = ((in_buf.read_unaligned()) >> 1) % (1u32 << 13); out = out.offset(1); - *out = ((*in_buf) >> 14) % (1u32 << 13); + *out = ((in_buf.read_unaligned()) >> 14) % (1u32 << 13); out = out.offset(1); - *out = (*in_buf) >> 27; + *out = (in_buf.read_unaligned()) >> 27; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (13 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (13 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 13); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 13); out = out.offset(1); - *out = (*in_buf) >> 21; + *out = (in_buf.read_unaligned()) >> 21; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (13 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (13 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 13); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 13); out = out.offset(1); - *out = ((*in_buf) >> 15) % (1u32 << 13); + *out = ((in_buf.read_unaligned()) >> 15) % (1u32 << 13); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 9)) << (13 - 9); + *out |= ((in_buf.read_unaligned()) % (1u32 << 9)) << (13 - 9); out = out.offset(1); - *out = ((*in_buf) >> 9) % (1u32 << 13); + *out = ((in_buf.read_unaligned()) >> 9) % (1u32 << 13); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 3)) << (13 - 3); + *out |= ((in_buf.read_unaligned()) % (1u32 << 3)) << (13 - 3); out = out.offset(1); - *out = ((*in_buf) >> 3) % (1u32 << 13); + *out = ((in_buf.read_unaligned()) >> 3) % (1u32 << 13); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 13); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 13); out = out.offset(1); - *out = (*in_buf) >> 29; + *out = (in_buf.read_unaligned()) >> 29; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 10)) << (13 - 10); + *out |= ((in_buf.read_unaligned()) % (1u32 << 10)) << (13 - 10); out = out.offset(1); - *out = ((*in_buf) >> 10) % (1u32 << 13); + *out = ((in_buf.read_unaligned()) >> 10) % (1u32 << 13); out = out.offset(1); - *out = (*in_buf) >> 23; + *out = (in_buf.read_unaligned()) >> 23; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (13 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (13 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 13); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 13); out = out.offset(1); - *out = ((*in_buf) >> 17) % (1u32 << 13); + *out = ((in_buf.read_unaligned()) >> 17) % (1u32 << 13); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 11)) << (13 - 11); + *out |= ((in_buf.read_unaligned()) % (1u32 << 11)) << (13 - 11); out = out.offset(1); - *out = ((*in_buf) >> 11) % (1u32 << 13); + *out = ((in_buf.read_unaligned()) >> 11) % (1u32 << 13); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 5)) << (13 - 5); + *out |= ((in_buf.read_unaligned()) % (1u32 << 5)) << (13 - 5); out = out.offset(1); - *out = ((*in_buf) >> 5) % (1u32 << 13); + *out = ((in_buf.read_unaligned()) >> 5) % (1u32 << 13); out = out.offset(1); - *out = ((*in_buf) >> 18) % (1u32 << 13); + *out = ((in_buf.read_unaligned()) >> 18) % (1u32 << 13); out = out.offset(1); - *out = (*in_buf) >> 31; + *out = (in_buf.read_unaligned()) >> 31; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (13 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (13 - 12); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 13); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 13); out = out.offset(1); - *out = (*in_buf) >> 25; + *out = (in_buf.read_unaligned()) >> 25; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (13 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (13 - 6); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 13); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 13); out = out.offset(1); - *out = (*in_buf) >> 19; + *out = (in_buf.read_unaligned()) >> 19; in_buf.offset(1) } unsafe fn unpack14_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 14); + *out = (in_buf.read_unaligned()) % (1u32 << 14); out = out.offset(1); - *out = ((*in_buf) >> 14) % (1u32 << 14); + *out = ((in_buf.read_unaligned()) >> 14) % (1u32 << 14); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 10)) << (14 - 10); + *out |= ((in_buf.read_unaligned()) % (1u32 << 10)) << (14 - 10); out = out.offset(1); - *out = ((*in_buf) >> 10) % (1u32 << 14); + *out = ((in_buf.read_unaligned()) >> 10) % (1u32 << 14); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (14 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (14 - 6); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 14); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 14); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (14 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (14 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 14); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 14); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 14); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 14); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (14 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (14 - 12); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 14); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 14); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (14 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (14 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 14); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 14); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (14 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (14 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 14); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 14); out = out.offset(1); - *out = (*in_buf) >> 18; + *out = (in_buf.read_unaligned()) >> 18; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 14); + *out = (in_buf.read_unaligned()) % (1u32 << 14); out = out.offset(1); - *out = ((*in_buf) >> 14) % (1u32 << 14); + *out = ((in_buf.read_unaligned()) >> 14) % (1u32 << 14); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 10)) << (14 - 10); + *out |= ((in_buf.read_unaligned()) % (1u32 << 10)) << (14 - 10); out = out.offset(1); - *out = ((*in_buf) >> 10) % (1u32 << 14); + *out = ((in_buf.read_unaligned()) >> 10) % (1u32 << 14); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (14 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (14 - 6); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 14); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 14); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (14 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (14 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 14); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 14); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 14); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 14); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (14 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (14 - 12); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 14); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 14); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (14 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (14 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 14); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 14); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (14 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (14 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 14); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 14); out = out.offset(1); - *out = (*in_buf) >> 18; + *out = (in_buf.read_unaligned()) >> 18; in_buf.offset(1) } unsafe fn unpack15_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 15); + *out = (in_buf.read_unaligned()) % (1u32 << 15); out = out.offset(1); - *out = ((*in_buf) >> 15) % (1u32 << 15); + *out = ((in_buf.read_unaligned()) >> 15) % (1u32 << 15); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 13)) << (15 - 13); + *out |= ((in_buf.read_unaligned()) % (1u32 << 13)) << (15 - 13); out = out.offset(1); - *out = ((*in_buf) >> 13) % (1u32 << 15); + *out = ((in_buf.read_unaligned()) >> 13) % (1u32 << 15); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 11)) << (15 - 11); + *out |= ((in_buf.read_unaligned()) % (1u32 << 11)) << (15 - 11); out = out.offset(1); - *out = ((*in_buf) >> 11) % (1u32 << 15); + *out = ((in_buf.read_unaligned()) >> 11) % (1u32 << 15); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 9)) << (15 - 9); + *out |= ((in_buf.read_unaligned()) % (1u32 << 9)) << (15 - 9); out = out.offset(1); - *out = ((*in_buf) >> 9) % (1u32 << 15); + *out = ((in_buf.read_unaligned()) >> 9) % (1u32 << 15); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 7)) << (15 - 7); + *out |= ((in_buf.read_unaligned()) % (1u32 << 7)) << (15 - 7); out = out.offset(1); - *out = ((*in_buf) >> 7) % (1u32 << 15); + *out = ((in_buf.read_unaligned()) >> 7) % (1u32 << 15); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 5)) << (15 - 5); + *out |= ((in_buf.read_unaligned()) % (1u32 << 5)) << (15 - 5); out = out.offset(1); - *out = ((*in_buf) >> 5) % (1u32 << 15); + *out = ((in_buf.read_unaligned()) >> 5) % (1u32 << 15); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 3)) << (15 - 3); + *out |= ((in_buf.read_unaligned()) % (1u32 << 3)) << (15 - 3); out = out.offset(1); - *out = ((*in_buf) >> 3) % (1u32 << 15); + *out = ((in_buf.read_unaligned()) >> 3) % (1u32 << 15); out = out.offset(1); - *out = (*in_buf) >> 18; + *out = (in_buf.read_unaligned()) >> 18; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 1)) << (15 - 1); + *out |= ((in_buf.read_unaligned()) % (1u32 << 1)) << (15 - 1); out = out.offset(1); - *out = ((*in_buf) >> 1) % (1u32 << 15); + *out = ((in_buf.read_unaligned()) >> 1) % (1u32 << 15); out = out.offset(1); - *out = ((*in_buf) >> 16) % (1u32 << 15); + *out = ((in_buf.read_unaligned()) >> 16) % (1u32 << 15); out = out.offset(1); - *out = (*in_buf) >> 31; + *out = (in_buf.read_unaligned()) >> 31; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 14)) << (15 - 14); + *out |= ((in_buf.read_unaligned()) % (1u32 << 14)) << (15 - 14); out = out.offset(1); - *out = ((*in_buf) >> 14) % (1u32 << 15); + *out = ((in_buf.read_unaligned()) >> 14) % (1u32 << 15); out = out.offset(1); - *out = (*in_buf) >> 29; + *out = (in_buf.read_unaligned()) >> 29; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (15 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (15 - 12); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 15); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 15); out = out.offset(1); - *out = (*in_buf) >> 27; + *out = (in_buf.read_unaligned()) >> 27; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 10)) << (15 - 10); + *out |= ((in_buf.read_unaligned()) % (1u32 << 10)) << (15 - 10); out = out.offset(1); - *out = ((*in_buf) >> 10) % (1u32 << 15); + *out = ((in_buf.read_unaligned()) >> 10) % (1u32 << 15); out = out.offset(1); - *out = (*in_buf) >> 25; + *out = (in_buf.read_unaligned()) >> 25; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (15 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (15 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 15); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 15); out = out.offset(1); - *out = (*in_buf) >> 23; + *out = (in_buf.read_unaligned()) >> 23; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (15 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (15 - 6); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 15); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 15); out = out.offset(1); - *out = (*in_buf) >> 21; + *out = (in_buf.read_unaligned()) >> 21; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (15 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (15 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 15); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 15); out = out.offset(1); - *out = (*in_buf) >> 19; + *out = (in_buf.read_unaligned()) >> 19; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (15 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (15 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 15); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 15); out = out.offset(1); - *out = (*in_buf) >> 17; + *out = (in_buf.read_unaligned()) >> 17; in_buf.offset(1) } unsafe fn unpack16_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 16); + *out = (in_buf.read_unaligned()) % (1u32 << 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 16); + *out = (in_buf.read_unaligned()) % (1u32 << 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 16); + *out = (in_buf.read_unaligned()) % (1u32 << 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 16); + *out = (in_buf.read_unaligned()) % (1u32 << 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 16); + *out = (in_buf.read_unaligned()) % (1u32 << 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 16); + *out = (in_buf.read_unaligned()) % (1u32 << 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 16); + *out = (in_buf.read_unaligned()) % (1u32 << 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 16); + *out = (in_buf.read_unaligned()) % (1u32 << 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 16); + *out = (in_buf.read_unaligned()) % (1u32 << 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 16); + *out = (in_buf.read_unaligned()) % (1u32 << 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 16); + *out = (in_buf.read_unaligned()) % (1u32 << 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 16); + *out = (in_buf.read_unaligned()) % (1u32 << 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 16); + *out = (in_buf.read_unaligned()) % (1u32 << 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 16); + *out = (in_buf.read_unaligned()) % (1u32 << 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 16); + *out = (in_buf.read_unaligned()) % (1u32 << 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; out = out.offset(1); in_buf = in_buf.offset(1); - *out = (*in_buf) % (1u32 << 16); + *out = (in_buf.read_unaligned()) % (1u32 << 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf.offset(1) } unsafe fn unpack17_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 17); + *out = (in_buf.read_unaligned()) % (1u32 << 17); out = out.offset(1); - *out = (*in_buf) >> 17; + *out = (in_buf.read_unaligned()) >> 17; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (17 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (17 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 17); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 17); out = out.offset(1); - *out = (*in_buf) >> 19; + *out = (in_buf.read_unaligned()) >> 19; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (17 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (17 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 17); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 17); out = out.offset(1); - *out = (*in_buf) >> 21; + *out = (in_buf.read_unaligned()) >> 21; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (17 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (17 - 6); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 17); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 17); out = out.offset(1); - *out = (*in_buf) >> 23; + *out = (in_buf.read_unaligned()) >> 23; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (17 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (17 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 17); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 17); out = out.offset(1); - *out = (*in_buf) >> 25; + *out = (in_buf.read_unaligned()) >> 25; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 10)) << (17 - 10); + *out |= ((in_buf.read_unaligned()) % (1u32 << 10)) << (17 - 10); out = out.offset(1); - *out = ((*in_buf) >> 10) % (1u32 << 17); + *out = ((in_buf.read_unaligned()) >> 10) % (1u32 << 17); out = out.offset(1); - *out = (*in_buf) >> 27; + *out = (in_buf.read_unaligned()) >> 27; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (17 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (17 - 12); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 17); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 17); out = out.offset(1); - *out = (*in_buf) >> 29; + *out = (in_buf.read_unaligned()) >> 29; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 14)) << (17 - 14); + *out |= ((in_buf.read_unaligned()) % (1u32 << 14)) << (17 - 14); out = out.offset(1); - *out = ((*in_buf) >> 14) % (1u32 << 17); + *out = ((in_buf.read_unaligned()) >> 14) % (1u32 << 17); out = out.offset(1); - *out = (*in_buf) >> 31; + *out = (in_buf.read_unaligned()) >> 31; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (17 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (17 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 1)) << (17 - 1); + *out |= ((in_buf.read_unaligned()) % (1u32 << 1)) << (17 - 1); out = out.offset(1); - *out = ((*in_buf) >> 1) % (1u32 << 17); + *out = ((in_buf.read_unaligned()) >> 1) % (1u32 << 17); out = out.offset(1); - *out = (*in_buf) >> 18; + *out = (in_buf.read_unaligned()) >> 18; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 3)) << (17 - 3); + *out |= ((in_buf.read_unaligned()) % (1u32 << 3)) << (17 - 3); out = out.offset(1); - *out = ((*in_buf) >> 3) % (1u32 << 17); + *out = ((in_buf.read_unaligned()) >> 3) % (1u32 << 17); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 5)) << (17 - 5); + *out |= ((in_buf.read_unaligned()) % (1u32 << 5)) << (17 - 5); out = out.offset(1); - *out = ((*in_buf) >> 5) % (1u32 << 17); + *out = ((in_buf.read_unaligned()) >> 5) % (1u32 << 17); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 7)) << (17 - 7); + *out |= ((in_buf.read_unaligned()) % (1u32 << 7)) << (17 - 7); out = out.offset(1); - *out = ((*in_buf) >> 7) % (1u32 << 17); + *out = ((in_buf.read_unaligned()) >> 7) % (1u32 << 17); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 9)) << (17 - 9); + *out |= ((in_buf.read_unaligned()) % (1u32 << 9)) << (17 - 9); out = out.offset(1); - *out = ((*in_buf) >> 9) % (1u32 << 17); + *out = ((in_buf.read_unaligned()) >> 9) % (1u32 << 17); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 11)) << (17 - 11); + *out |= ((in_buf.read_unaligned()) % (1u32 << 11)) << (17 - 11); out = out.offset(1); - *out = ((*in_buf) >> 11) % (1u32 << 17); + *out = ((in_buf.read_unaligned()) >> 11) % (1u32 << 17); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 13)) << (17 - 13); + *out |= ((in_buf.read_unaligned()) % (1u32 << 13)) << (17 - 13); out = out.offset(1); - *out = ((*in_buf) >> 13) % (1u32 << 17); + *out = ((in_buf.read_unaligned()) >> 13) % (1u32 << 17); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 15)) << (17 - 15); + *out |= ((in_buf.read_unaligned()) % (1u32 << 15)) << (17 - 15); out = out.offset(1); - *out = (*in_buf) >> 15; + *out = (in_buf.read_unaligned()) >> 15; in_buf.offset(1) } unsafe fn unpack18_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 18); + *out = (in_buf.read_unaligned()) % (1u32 << 18); out = out.offset(1); - *out = (*in_buf) >> 18; + *out = (in_buf.read_unaligned()) >> 18; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (18 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (18 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 18); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 18); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (18 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (18 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 18); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 18); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (18 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (18 - 12); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 18); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 18); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (18 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (18 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (18 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (18 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 18); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 18); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (18 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (18 - 6); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 18); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 18); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 10)) << (18 - 10); + *out |= ((in_buf.read_unaligned()) % (1u32 << 10)) << (18 - 10); out = out.offset(1); - *out = ((*in_buf) >> 10) % (1u32 << 18); + *out = ((in_buf.read_unaligned()) >> 10) % (1u32 << 18); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 14)) << (18 - 14); + *out |= ((in_buf.read_unaligned()) % (1u32 << 14)) << (18 - 14); out = out.offset(1); - *out = (*in_buf) >> 14; + *out = (in_buf.read_unaligned()) >> 14; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 18); + *out = (in_buf.read_unaligned()) % (1u32 << 18); out = out.offset(1); - *out = (*in_buf) >> 18; + *out = (in_buf.read_unaligned()) >> 18; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (18 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (18 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 18); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 18); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (18 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (18 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 18); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 18); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (18 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (18 - 12); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 18); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 18); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (18 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (18 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (18 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (18 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 18); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 18); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (18 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (18 - 6); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 18); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 18); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 10)) << (18 - 10); + *out |= ((in_buf.read_unaligned()) % (1u32 << 10)) << (18 - 10); out = out.offset(1); - *out = ((*in_buf) >> 10) % (1u32 << 18); + *out = ((in_buf.read_unaligned()) >> 10) % (1u32 << 18); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 14)) << (18 - 14); + *out |= ((in_buf.read_unaligned()) % (1u32 << 14)) << (18 - 14); out = out.offset(1); - *out = (*in_buf) >> 14; + *out = (in_buf.read_unaligned()) >> 14; in_buf.offset(1) } unsafe fn unpack19_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 19); + *out = (in_buf.read_unaligned()) % (1u32 << 19); out = out.offset(1); - *out = (*in_buf) >> 19; + *out = (in_buf.read_unaligned()) >> 19; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (19 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (19 - 6); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 19); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 19); out = out.offset(1); - *out = (*in_buf) >> 25; + *out = (in_buf.read_unaligned()) >> 25; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (19 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (19 - 12); out = out.offset(1); - *out = ((*in_buf) >> 12) % (1u32 << 19); + *out = ((in_buf.read_unaligned()) >> 12) % (1u32 << 19); out = out.offset(1); - *out = (*in_buf) >> 31; + *out = (in_buf.read_unaligned()) >> 31; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 18)) << (19 - 18); + *out |= ((in_buf.read_unaligned()) % (1u32 << 18)) << (19 - 18); out = out.offset(1); - *out = (*in_buf) >> 18; + *out = (in_buf.read_unaligned()) >> 18; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 5)) << (19 - 5); + *out |= ((in_buf.read_unaligned()) % (1u32 << 5)) << (19 - 5); out = out.offset(1); - *out = ((*in_buf) >> 5) % (1u32 << 19); + *out = ((in_buf.read_unaligned()) >> 5) % (1u32 << 19); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 11)) << (19 - 11); + *out |= ((in_buf.read_unaligned()) % (1u32 << 11)) << (19 - 11); out = out.offset(1); - *out = ((*in_buf) >> 11) % (1u32 << 19); + *out = ((in_buf.read_unaligned()) >> 11) % (1u32 << 19); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 17)) << (19 - 17); + *out |= ((in_buf.read_unaligned()) % (1u32 << 17)) << (19 - 17); out = out.offset(1); - *out = (*in_buf) >> 17; + *out = (in_buf.read_unaligned()) >> 17; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (19 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (19 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 19); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 19); out = out.offset(1); - *out = (*in_buf) >> 23; + *out = (in_buf.read_unaligned()) >> 23; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 10)) << (19 - 10); + *out |= ((in_buf.read_unaligned()) % (1u32 << 10)) << (19 - 10); out = out.offset(1); - *out = ((*in_buf) >> 10) % (1u32 << 19); + *out = ((in_buf.read_unaligned()) >> 10) % (1u32 << 19); out = out.offset(1); - *out = (*in_buf) >> 29; + *out = (in_buf.read_unaligned()) >> 29; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (19 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (19 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 3)) << (19 - 3); + *out |= ((in_buf.read_unaligned()) % (1u32 << 3)) << (19 - 3); out = out.offset(1); - *out = ((*in_buf) >> 3) % (1u32 << 19); + *out = ((in_buf.read_unaligned()) >> 3) % (1u32 << 19); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 9)) << (19 - 9); + *out |= ((in_buf.read_unaligned()) % (1u32 << 9)) << (19 - 9); out = out.offset(1); - *out = ((*in_buf) >> 9) % (1u32 << 19); + *out = ((in_buf.read_unaligned()) >> 9) % (1u32 << 19); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 15)) << (19 - 15); + *out |= ((in_buf.read_unaligned()) % (1u32 << 15)) << (19 - 15); out = out.offset(1); - *out = (*in_buf) >> 15; + *out = (in_buf.read_unaligned()) >> 15; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (19 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (19 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 19); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 19); out = out.offset(1); - *out = (*in_buf) >> 21; + *out = (in_buf.read_unaligned()) >> 21; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (19 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (19 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 19); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 19); out = out.offset(1); - *out = (*in_buf) >> 27; + *out = (in_buf.read_unaligned()) >> 27; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 14)) << (19 - 14); + *out |= ((in_buf.read_unaligned()) % (1u32 << 14)) << (19 - 14); out = out.offset(1); - *out = (*in_buf) >> 14; + *out = (in_buf.read_unaligned()) >> 14; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 1)) << (19 - 1); + *out |= ((in_buf.read_unaligned()) % (1u32 << 1)) << (19 - 1); out = out.offset(1); - *out = ((*in_buf) >> 1) % (1u32 << 19); + *out = ((in_buf.read_unaligned()) >> 1) % (1u32 << 19); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 7)) << (19 - 7); + *out |= ((in_buf.read_unaligned()) % (1u32 << 7)) << (19 - 7); out = out.offset(1); - *out = ((*in_buf) >> 7) % (1u32 << 19); + *out = ((in_buf.read_unaligned()) >> 7) % (1u32 << 19); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 13)) << (19 - 13); + *out |= ((in_buf.read_unaligned()) % (1u32 << 13)) << (19 - 13); out = out.offset(1); - *out = (*in_buf) >> 13; + *out = (in_buf.read_unaligned()) >> 13; in_buf.offset(1) } unsafe fn unpack20_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 20); + *out = (in_buf.read_unaligned()) % (1u32 << 20); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (20 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (20 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 20); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 20); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (20 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (20 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (20 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (20 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 20); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 20); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (20 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (20 - 12); out = out.offset(1); - *out = (*in_buf) >> 12; + *out = (in_buf.read_unaligned()) >> 12; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 20); + *out = (in_buf.read_unaligned()) % (1u32 << 20); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (20 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (20 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 20); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 20); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (20 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (20 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (20 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (20 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 20); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 20); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (20 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (20 - 12); out = out.offset(1); - *out = (*in_buf) >> 12; + *out = (in_buf.read_unaligned()) >> 12; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 20); + *out = (in_buf.read_unaligned()) % (1u32 << 20); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (20 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (20 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 20); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 20); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (20 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (20 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (20 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (20 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 20); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 20); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (20 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (20 - 12); out = out.offset(1); - *out = (*in_buf) >> 12; + *out = (in_buf.read_unaligned()) >> 12; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 20); + *out = (in_buf.read_unaligned()) % (1u32 << 20); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (20 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (20 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 20); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 20); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (20 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (20 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (20 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (20 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 20); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 20); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (20 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (20 - 12); out = out.offset(1); - *out = (*in_buf) >> 12; + *out = (in_buf.read_unaligned()) >> 12; in_buf.offset(1) } unsafe fn unpack21_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 21); + *out = (in_buf.read_unaligned()) % (1u32 << 21); out = out.offset(1); - *out = (*in_buf) >> 21; + *out = (in_buf.read_unaligned()) >> 21; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 10)) << (21 - 10); + *out |= ((in_buf.read_unaligned()) % (1u32 << 10)) << (21 - 10); out = out.offset(1); - *out = ((*in_buf) >> 10) % (1u32 << 21); + *out = ((in_buf.read_unaligned()) >> 10) % (1u32 << 21); out = out.offset(1); - *out = (*in_buf) >> 31; + *out = (in_buf.read_unaligned()) >> 31; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 20)) << (21 - 20); + *out |= ((in_buf.read_unaligned()) % (1u32 << 20)) << (21 - 20); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 9)) << (21 - 9); + *out |= ((in_buf.read_unaligned()) % (1u32 << 9)) << (21 - 9); out = out.offset(1); - *out = ((*in_buf) >> 9) % (1u32 << 21); + *out = ((in_buf.read_unaligned()) >> 9) % (1u32 << 21); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 19)) << (21 - 19); + *out |= ((in_buf.read_unaligned()) % (1u32 << 19)) << (21 - 19); out = out.offset(1); - *out = (*in_buf) >> 19; + *out = (in_buf.read_unaligned()) >> 19; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (21 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (21 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 21); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 21); out = out.offset(1); - *out = (*in_buf) >> 29; + *out = (in_buf.read_unaligned()) >> 29; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 18)) << (21 - 18); + *out |= ((in_buf.read_unaligned()) % (1u32 << 18)) << (21 - 18); out = out.offset(1); - *out = (*in_buf) >> 18; + *out = (in_buf.read_unaligned()) >> 18; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 7)) << (21 - 7); + *out |= ((in_buf.read_unaligned()) % (1u32 << 7)) << (21 - 7); out = out.offset(1); - *out = ((*in_buf) >> 7) % (1u32 << 21); + *out = ((in_buf.read_unaligned()) >> 7) % (1u32 << 21); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 17)) << (21 - 17); + *out |= ((in_buf.read_unaligned()) % (1u32 << 17)) << (21 - 17); out = out.offset(1); - *out = (*in_buf) >> 17; + *out = (in_buf.read_unaligned()) >> 17; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (21 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (21 - 6); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 21); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 21); out = out.offset(1); - *out = (*in_buf) >> 27; + *out = (in_buf.read_unaligned()) >> 27; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (21 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (21 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 5)) << (21 - 5); + *out |= ((in_buf.read_unaligned()) % (1u32 << 5)) << (21 - 5); out = out.offset(1); - *out = ((*in_buf) >> 5) % (1u32 << 21); + *out = ((in_buf.read_unaligned()) >> 5) % (1u32 << 21); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 15)) << (21 - 15); + *out |= ((in_buf.read_unaligned()) % (1u32 << 15)) << (21 - 15); out = out.offset(1); - *out = (*in_buf) >> 15; + *out = (in_buf.read_unaligned()) >> 15; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (21 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (21 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 21); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 21); out = out.offset(1); - *out = (*in_buf) >> 25; + *out = (in_buf.read_unaligned()) >> 25; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 14)) << (21 - 14); + *out |= ((in_buf.read_unaligned()) % (1u32 << 14)) << (21 - 14); out = out.offset(1); - *out = (*in_buf) >> 14; + *out = (in_buf.read_unaligned()) >> 14; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 3)) << (21 - 3); + *out |= ((in_buf.read_unaligned()) % (1u32 << 3)) << (21 - 3); out = out.offset(1); - *out = ((*in_buf) >> 3) % (1u32 << 21); + *out = ((in_buf.read_unaligned()) >> 3) % (1u32 << 21); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 13)) << (21 - 13); + *out |= ((in_buf.read_unaligned()) % (1u32 << 13)) << (21 - 13); out = out.offset(1); - *out = (*in_buf) >> 13; + *out = (in_buf.read_unaligned()) >> 13; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (21 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (21 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 21); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 21); out = out.offset(1); - *out = (*in_buf) >> 23; + *out = (in_buf.read_unaligned()) >> 23; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (21 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (21 - 12); out = out.offset(1); - *out = (*in_buf) >> 12; + *out = (in_buf.read_unaligned()) >> 12; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 1)) << (21 - 1); + *out |= ((in_buf.read_unaligned()) % (1u32 << 1)) << (21 - 1); out = out.offset(1); - *out = ((*in_buf) >> 1) % (1u32 << 21); + *out = ((in_buf.read_unaligned()) >> 1) % (1u32 << 21); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 11)) << (21 - 11); + *out |= ((in_buf.read_unaligned()) % (1u32 << 11)) << (21 - 11); out = out.offset(1); - *out = (*in_buf) >> 11; + *out = (in_buf.read_unaligned()) >> 11; in_buf.offset(1) } unsafe fn unpack22_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 22); + *out = (in_buf.read_unaligned()) % (1u32 << 22); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (22 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (22 - 12); out = out.offset(1); - *out = (*in_buf) >> 12; + *out = (in_buf.read_unaligned()) >> 12; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (22 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (22 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 22); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 22); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 14)) << (22 - 14); + *out |= ((in_buf.read_unaligned()) % (1u32 << 14)) << (22 - 14); out = out.offset(1); - *out = (*in_buf) >> 14; + *out = (in_buf.read_unaligned()) >> 14; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (22 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (22 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 22); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 22); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (22 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (22 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (22 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (22 - 6); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 22); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 22); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 18)) << (22 - 18); + *out |= ((in_buf.read_unaligned()) % (1u32 << 18)) << (22 - 18); out = out.offset(1); - *out = (*in_buf) >> 18; + *out = (in_buf.read_unaligned()) >> 18; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (22 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (22 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 22); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 22); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 20)) << (22 - 20); + *out |= ((in_buf.read_unaligned()) % (1u32 << 20)) << (22 - 20); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 10)) << (22 - 10); + *out |= ((in_buf.read_unaligned()) % (1u32 << 10)) << (22 - 10); out = out.offset(1); - *out = (*in_buf) >> 10; + *out = (in_buf.read_unaligned()) >> 10; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 22); + *out = (in_buf.read_unaligned()) % (1u32 << 22); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (22 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (22 - 12); out = out.offset(1); - *out = (*in_buf) >> 12; + *out = (in_buf.read_unaligned()) >> 12; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (22 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (22 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 22); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 22); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 14)) << (22 - 14); + *out |= ((in_buf.read_unaligned()) % (1u32 << 14)) << (22 - 14); out = out.offset(1); - *out = (*in_buf) >> 14; + *out = (in_buf.read_unaligned()) >> 14; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (22 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (22 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 22); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 22); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (22 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (22 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (22 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (22 - 6); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 22); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 22); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 18)) << (22 - 18); + *out |= ((in_buf.read_unaligned()) % (1u32 << 18)) << (22 - 18); out = out.offset(1); - *out = (*in_buf) >> 18; + *out = (in_buf.read_unaligned()) >> 18; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (22 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (22 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 22); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 22); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 20)) << (22 - 20); + *out |= ((in_buf.read_unaligned()) % (1u32 << 20)) << (22 - 20); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 10)) << (22 - 10); + *out |= ((in_buf.read_unaligned()) % (1u32 << 10)) << (22 - 10); out = out.offset(1); - *out = (*in_buf) >> 10; + *out = (in_buf.read_unaligned()) >> 10; in_buf.offset(1) } unsafe fn unpack23_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 23); + *out = (in_buf.read_unaligned()) % (1u32 << 23); out = out.offset(1); - *out = (*in_buf) >> 23; + *out = (in_buf.read_unaligned()) >> 23; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 14)) << (23 - 14); + *out |= ((in_buf.read_unaligned()) % (1u32 << 14)) << (23 - 14); out = out.offset(1); - *out = (*in_buf) >> 14; + *out = (in_buf.read_unaligned()) >> 14; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 5)) << (23 - 5); + *out |= ((in_buf.read_unaligned()) % (1u32 << 5)) << (23 - 5); out = out.offset(1); - *out = ((*in_buf) >> 5) % (1u32 << 23); + *out = ((in_buf.read_unaligned()) >> 5) % (1u32 << 23); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 19)) << (23 - 19); + *out |= ((in_buf.read_unaligned()) % (1u32 << 19)) << (23 - 19); out = out.offset(1); - *out = (*in_buf) >> 19; + *out = (in_buf.read_unaligned()) >> 19; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 10)) << (23 - 10); + *out |= ((in_buf.read_unaligned()) % (1u32 << 10)) << (23 - 10); out = out.offset(1); - *out = (*in_buf) >> 10; + *out = (in_buf.read_unaligned()) >> 10; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 1)) << (23 - 1); + *out |= ((in_buf.read_unaligned()) % (1u32 << 1)) << (23 - 1); out = out.offset(1); - *out = ((*in_buf) >> 1) % (1u32 << 23); + *out = ((in_buf.read_unaligned()) >> 1) % (1u32 << 23); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 15)) << (23 - 15); + *out |= ((in_buf.read_unaligned()) % (1u32 << 15)) << (23 - 15); out = out.offset(1); - *out = (*in_buf) >> 15; + *out = (in_buf.read_unaligned()) >> 15; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (23 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (23 - 6); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 23); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 23); out = out.offset(1); - *out = (*in_buf) >> 29; + *out = (in_buf.read_unaligned()) >> 29; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 20)) << (23 - 20); + *out |= ((in_buf.read_unaligned()) % (1u32 << 20)) << (23 - 20); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 11)) << (23 - 11); + *out |= ((in_buf.read_unaligned()) % (1u32 << 11)) << (23 - 11); out = out.offset(1); - *out = (*in_buf) >> 11; + *out = (in_buf.read_unaligned()) >> 11; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (23 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (23 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 23); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 23); out = out.offset(1); - *out = (*in_buf) >> 25; + *out = (in_buf.read_unaligned()) >> 25; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (23 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (23 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 7)) << (23 - 7); + *out |= ((in_buf.read_unaligned()) % (1u32 << 7)) << (23 - 7); out = out.offset(1); - *out = ((*in_buf) >> 7) % (1u32 << 23); + *out = ((in_buf.read_unaligned()) >> 7) % (1u32 << 23); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 21)) << (23 - 21); + *out |= ((in_buf.read_unaligned()) % (1u32 << 21)) << (23 - 21); out = out.offset(1); - *out = (*in_buf) >> 21; + *out = (in_buf.read_unaligned()) >> 21; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (23 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (23 - 12); out = out.offset(1); - *out = (*in_buf) >> 12; + *out = (in_buf.read_unaligned()) >> 12; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 3)) << (23 - 3); + *out |= ((in_buf.read_unaligned()) % (1u32 << 3)) << (23 - 3); out = out.offset(1); - *out = ((*in_buf) >> 3) % (1u32 << 23); + *out = ((in_buf.read_unaligned()) >> 3) % (1u32 << 23); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 17)) << (23 - 17); + *out |= ((in_buf.read_unaligned()) % (1u32 << 17)) << (23 - 17); out = out.offset(1); - *out = (*in_buf) >> 17; + *out = (in_buf.read_unaligned()) >> 17; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (23 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (23 - 8); out = out.offset(1); - *out = ((*in_buf) >> 8) % (1u32 << 23); + *out = ((in_buf.read_unaligned()) >> 8) % (1u32 << 23); out = out.offset(1); - *out = (*in_buf) >> 31; + *out = (in_buf.read_unaligned()) >> 31; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 22)) << (23 - 22); + *out |= ((in_buf.read_unaligned()) % (1u32 << 22)) << (23 - 22); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 13)) << (23 - 13); + *out |= ((in_buf.read_unaligned()) % (1u32 << 13)) << (23 - 13); out = out.offset(1); - *out = (*in_buf) >> 13; + *out = (in_buf.read_unaligned()) >> 13; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (23 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (23 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 23); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 23); out = out.offset(1); - *out = (*in_buf) >> 27; + *out = (in_buf.read_unaligned()) >> 27; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 18)) << (23 - 18); + *out |= ((in_buf.read_unaligned()) % (1u32 << 18)) << (23 - 18); out = out.offset(1); - *out = (*in_buf) >> 18; + *out = (in_buf.read_unaligned()) >> 18; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 9)) << (23 - 9); + *out |= ((in_buf.read_unaligned()) % (1u32 << 9)) << (23 - 9); out = out.offset(1); - *out = (*in_buf) >> 9; + *out = (in_buf.read_unaligned()) >> 9; in_buf.offset(1) } unsafe fn unpack24_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 24); + *out = (in_buf.read_unaligned()) % (1u32 << 24); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (24 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (24 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (24 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (24 - 8); out = out.offset(1); - *out = (*in_buf) >> 8; + *out = (in_buf.read_unaligned()) >> 8; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 24); + *out = (in_buf.read_unaligned()) % (1u32 << 24); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (24 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (24 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (24 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (24 - 8); out = out.offset(1); - *out = (*in_buf) >> 8; + *out = (in_buf.read_unaligned()) >> 8; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 24); + *out = (in_buf.read_unaligned()) % (1u32 << 24); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (24 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (24 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (24 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (24 - 8); out = out.offset(1); - *out = (*in_buf) >> 8; + *out = (in_buf.read_unaligned()) >> 8; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 24); + *out = (in_buf.read_unaligned()) % (1u32 << 24); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (24 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (24 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (24 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (24 - 8); out = out.offset(1); - *out = (*in_buf) >> 8; + *out = (in_buf.read_unaligned()) >> 8; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 24); + *out = (in_buf.read_unaligned()) % (1u32 << 24); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (24 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (24 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (24 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (24 - 8); out = out.offset(1); - *out = (*in_buf) >> 8; + *out = (in_buf.read_unaligned()) >> 8; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 24); + *out = (in_buf.read_unaligned()) % (1u32 << 24); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (24 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (24 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (24 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (24 - 8); out = out.offset(1); - *out = (*in_buf) >> 8; + *out = (in_buf.read_unaligned()) >> 8; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 24); + *out = (in_buf.read_unaligned()) % (1u32 << 24); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (24 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (24 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (24 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (24 - 8); out = out.offset(1); - *out = (*in_buf) >> 8; + *out = (in_buf.read_unaligned()) >> 8; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 24); + *out = (in_buf.read_unaligned()) % (1u32 << 24); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (24 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (24 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (24 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (24 - 8); out = out.offset(1); - *out = (*in_buf) >> 8; + *out = (in_buf.read_unaligned()) >> 8; in_buf.offset(1) } unsafe fn unpack25_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 25); + *out = (in_buf.read_unaligned()) % (1u32 << 25); out = out.offset(1); - *out = (*in_buf) >> 25; + *out = (in_buf.read_unaligned()) >> 25; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 18)) << (25 - 18); + *out |= ((in_buf.read_unaligned()) % (1u32 << 18)) << (25 - 18); out = out.offset(1); - *out = (*in_buf) >> 18; + *out = (in_buf.read_unaligned()) >> 18; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 11)) << (25 - 11); + *out |= ((in_buf.read_unaligned()) % (1u32 << 11)) << (25 - 11); out = out.offset(1); - *out = (*in_buf) >> 11; + *out = (in_buf.read_unaligned()) >> 11; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (25 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (25 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 25); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 25); out = out.offset(1); - *out = (*in_buf) >> 29; + *out = (in_buf.read_unaligned()) >> 29; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 22)) << (25 - 22); + *out |= ((in_buf.read_unaligned()) % (1u32 << 22)) << (25 - 22); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 15)) << (25 - 15); + *out |= ((in_buf.read_unaligned()) % (1u32 << 15)) << (25 - 15); out = out.offset(1); - *out = (*in_buf) >> 15; + *out = (in_buf.read_unaligned()) >> 15; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (25 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (25 - 8); out = out.offset(1); - *out = (*in_buf) >> 8; + *out = (in_buf.read_unaligned()) >> 8; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 1)) << (25 - 1); + *out |= ((in_buf.read_unaligned()) % (1u32 << 1)) << (25 - 1); out = out.offset(1); - *out = ((*in_buf) >> 1) % (1u32 << 25); + *out = ((in_buf.read_unaligned()) >> 1) % (1u32 << 25); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 19)) << (25 - 19); + *out |= ((in_buf.read_unaligned()) % (1u32 << 19)) << (25 - 19); out = out.offset(1); - *out = (*in_buf) >> 19; + *out = (in_buf.read_unaligned()) >> 19; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (25 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (25 - 12); out = out.offset(1); - *out = (*in_buf) >> 12; + *out = (in_buf.read_unaligned()) >> 12; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 5)) << (25 - 5); + *out |= ((in_buf.read_unaligned()) % (1u32 << 5)) << (25 - 5); out = out.offset(1); - *out = ((*in_buf) >> 5) % (1u32 << 25); + *out = ((in_buf.read_unaligned()) >> 5) % (1u32 << 25); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 23)) << (25 - 23); + *out |= ((in_buf.read_unaligned()) % (1u32 << 23)) << (25 - 23); out = out.offset(1); - *out = (*in_buf) >> 23; + *out = (in_buf.read_unaligned()) >> 23; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (25 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (25 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 9)) << (25 - 9); + *out |= ((in_buf.read_unaligned()) % (1u32 << 9)) << (25 - 9); out = out.offset(1); - *out = (*in_buf) >> 9; + *out = (in_buf.read_unaligned()) >> 9; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (25 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (25 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 25); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 25); out = out.offset(1); - *out = (*in_buf) >> 27; + *out = (in_buf.read_unaligned()) >> 27; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 20)) << (25 - 20); + *out |= ((in_buf.read_unaligned()) % (1u32 << 20)) << (25 - 20); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 13)) << (25 - 13); + *out |= ((in_buf.read_unaligned()) % (1u32 << 13)) << (25 - 13); out = out.offset(1); - *out = (*in_buf) >> 13; + *out = (in_buf.read_unaligned()) >> 13; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (25 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (25 - 6); out = out.offset(1); - *out = ((*in_buf) >> 6) % (1u32 << 25); + *out = ((in_buf.read_unaligned()) >> 6) % (1u32 << 25); out = out.offset(1); - *out = (*in_buf) >> 31; + *out = (in_buf.read_unaligned()) >> 31; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 24)) << (25 - 24); + *out |= ((in_buf.read_unaligned()) % (1u32 << 24)) << (25 - 24); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 17)) << (25 - 17); + *out |= ((in_buf.read_unaligned()) % (1u32 << 17)) << (25 - 17); out = out.offset(1); - *out = (*in_buf) >> 17; + *out = (in_buf.read_unaligned()) >> 17; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 10)) << (25 - 10); + *out |= ((in_buf.read_unaligned()) % (1u32 << 10)) << (25 - 10); out = out.offset(1); - *out = (*in_buf) >> 10; + *out = (in_buf.read_unaligned()) >> 10; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 3)) << (25 - 3); + *out |= ((in_buf.read_unaligned()) % (1u32 << 3)) << (25 - 3); out = out.offset(1); - *out = ((*in_buf) >> 3) % (1u32 << 25); + *out = ((in_buf.read_unaligned()) >> 3) % (1u32 << 25); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 21)) << (25 - 21); + *out |= ((in_buf.read_unaligned()) % (1u32 << 21)) << (25 - 21); out = out.offset(1); - *out = (*in_buf) >> 21; + *out = (in_buf.read_unaligned()) >> 21; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 14)) << (25 - 14); + *out |= ((in_buf.read_unaligned()) % (1u32 << 14)) << (25 - 14); out = out.offset(1); - *out = (*in_buf) >> 14; + *out = (in_buf.read_unaligned()) >> 14; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 7)) << (25 - 7); + *out |= ((in_buf.read_unaligned()) % (1u32 << 7)) << (25 - 7); out = out.offset(1); - *out = (*in_buf) >> 7; + *out = (in_buf.read_unaligned()) >> 7; in_buf.offset(1) } unsafe fn unpack26_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 26); + *out = (in_buf.read_unaligned()) % (1u32 << 26); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 20)) << (26 - 20); + *out |= ((in_buf.read_unaligned()) % (1u32 << 20)) << (26 - 20); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 14)) << (26 - 14); + *out |= ((in_buf.read_unaligned()) % (1u32 << 14)) << (26 - 14); out = out.offset(1); - *out = (*in_buf) >> 14; + *out = (in_buf.read_unaligned()) >> 14; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (26 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (26 - 8); out = out.offset(1); - *out = (*in_buf) >> 8; + *out = (in_buf.read_unaligned()) >> 8; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (26 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (26 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 26); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 26); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 22)) << (26 - 22); + *out |= ((in_buf.read_unaligned()) % (1u32 << 22)) << (26 - 22); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (26 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (26 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 10)) << (26 - 10); + *out |= ((in_buf.read_unaligned()) % (1u32 << 10)) << (26 - 10); out = out.offset(1); - *out = (*in_buf) >> 10; + *out = (in_buf.read_unaligned()) >> 10; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (26 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (26 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 26); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 26); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 24)) << (26 - 24); + *out |= ((in_buf.read_unaligned()) % (1u32 << 24)) << (26 - 24); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 18)) << (26 - 18); + *out |= ((in_buf.read_unaligned()) % (1u32 << 18)) << (26 - 18); out = out.offset(1); - *out = (*in_buf) >> 18; + *out = (in_buf.read_unaligned()) >> 18; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (26 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (26 - 12); out = out.offset(1); - *out = (*in_buf) >> 12; + *out = (in_buf.read_unaligned()) >> 12; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (26 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (26 - 6); out = out.offset(1); - *out = (*in_buf) >> 6; + *out = (in_buf.read_unaligned()) >> 6; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 26); + *out = (in_buf.read_unaligned()) % (1u32 << 26); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 20)) << (26 - 20); + *out |= ((in_buf.read_unaligned()) % (1u32 << 20)) << (26 - 20); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 14)) << (26 - 14); + *out |= ((in_buf.read_unaligned()) % (1u32 << 14)) << (26 - 14); out = out.offset(1); - *out = (*in_buf) >> 14; + *out = (in_buf.read_unaligned()) >> 14; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (26 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (26 - 8); out = out.offset(1); - *out = (*in_buf) >> 8; + *out = (in_buf.read_unaligned()) >> 8; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (26 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (26 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 26); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 26); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 22)) << (26 - 22); + *out |= ((in_buf.read_unaligned()) % (1u32 << 22)) << (26 - 22); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (26 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (26 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 10)) << (26 - 10); + *out |= ((in_buf.read_unaligned()) % (1u32 << 10)) << (26 - 10); out = out.offset(1); - *out = (*in_buf) >> 10; + *out = (in_buf.read_unaligned()) >> 10; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (26 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (26 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 26); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 26); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 24)) << (26 - 24); + *out |= ((in_buf.read_unaligned()) % (1u32 << 24)) << (26 - 24); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 18)) << (26 - 18); + *out |= ((in_buf.read_unaligned()) % (1u32 << 18)) << (26 - 18); out = out.offset(1); - *out = (*in_buf) >> 18; + *out = (in_buf.read_unaligned()) >> 18; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (26 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (26 - 12); out = out.offset(1); - *out = (*in_buf) >> 12; + *out = (in_buf.read_unaligned()) >> 12; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (26 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (26 - 6); out = out.offset(1); - *out = (*in_buf) >> 6; + *out = (in_buf.read_unaligned()) >> 6; in_buf.offset(1) } unsafe fn unpack27_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 27); + *out = (in_buf.read_unaligned()) % (1u32 << 27); out = out.offset(1); - *out = (*in_buf) >> 27; + *out = (in_buf.read_unaligned()) >> 27; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 22)) << (27 - 22); + *out |= ((in_buf.read_unaligned()) % (1u32 << 22)) << (27 - 22); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 17)) << (27 - 17); + *out |= ((in_buf.read_unaligned()) % (1u32 << 17)) << (27 - 17); out = out.offset(1); - *out = (*in_buf) >> 17; + *out = (in_buf.read_unaligned()) >> 17; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (27 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (27 - 12); out = out.offset(1); - *out = (*in_buf) >> 12; + *out = (in_buf.read_unaligned()) >> 12; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 7)) << (27 - 7); + *out |= ((in_buf.read_unaligned()) % (1u32 << 7)) << (27 - 7); out = out.offset(1); - *out = (*in_buf) >> 7; + *out = (in_buf.read_unaligned()) >> 7; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (27 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (27 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 27); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 27); out = out.offset(1); - *out = (*in_buf) >> 29; + *out = (in_buf.read_unaligned()) >> 29; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 24)) << (27 - 24); + *out |= ((in_buf.read_unaligned()) % (1u32 << 24)) << (27 - 24); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 19)) << (27 - 19); + *out |= ((in_buf.read_unaligned()) % (1u32 << 19)) << (27 - 19); out = out.offset(1); - *out = (*in_buf) >> 19; + *out = (in_buf.read_unaligned()) >> 19; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 14)) << (27 - 14); + *out |= ((in_buf.read_unaligned()) % (1u32 << 14)) << (27 - 14); out = out.offset(1); - *out = (*in_buf) >> 14; + *out = (in_buf.read_unaligned()) >> 14; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 9)) << (27 - 9); + *out |= ((in_buf.read_unaligned()) % (1u32 << 9)) << (27 - 9); out = out.offset(1); - *out = (*in_buf) >> 9; + *out = (in_buf.read_unaligned()) >> 9; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (27 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (27 - 4); out = out.offset(1); - *out = ((*in_buf) >> 4) % (1u32 << 27); + *out = ((in_buf.read_unaligned()) >> 4) % (1u32 << 27); out = out.offset(1); - *out = (*in_buf) >> 31; + *out = (in_buf.read_unaligned()) >> 31; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 26)) << (27 - 26); + *out |= ((in_buf.read_unaligned()) % (1u32 << 26)) << (27 - 26); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 21)) << (27 - 21); + *out |= ((in_buf.read_unaligned()) % (1u32 << 21)) << (27 - 21); out = out.offset(1); - *out = (*in_buf) >> 21; + *out = (in_buf.read_unaligned()) >> 21; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (27 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (27 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 11)) << (27 - 11); + *out |= ((in_buf.read_unaligned()) % (1u32 << 11)) << (27 - 11); out = out.offset(1); - *out = (*in_buf) >> 11; + *out = (in_buf.read_unaligned()) >> 11; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (27 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (27 - 6); out = out.offset(1); - *out = (*in_buf) >> 6; + *out = (in_buf.read_unaligned()) >> 6; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 1)) << (27 - 1); + *out |= ((in_buf.read_unaligned()) % (1u32 << 1)) << (27 - 1); out = out.offset(1); - *out = ((*in_buf) >> 1) % (1u32 << 27); + *out = ((in_buf.read_unaligned()) >> 1) % (1u32 << 27); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 23)) << (27 - 23); + *out |= ((in_buf.read_unaligned()) % (1u32 << 23)) << (27 - 23); out = out.offset(1); - *out = (*in_buf) >> 23; + *out = (in_buf.read_unaligned()) >> 23; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 18)) << (27 - 18); + *out |= ((in_buf.read_unaligned()) % (1u32 << 18)) << (27 - 18); out = out.offset(1); - *out = (*in_buf) >> 18; + *out = (in_buf.read_unaligned()) >> 18; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 13)) << (27 - 13); + *out |= ((in_buf.read_unaligned()) % (1u32 << 13)) << (27 - 13); out = out.offset(1); - *out = (*in_buf) >> 13; + *out = (in_buf.read_unaligned()) >> 13; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (27 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (27 - 8); out = out.offset(1); - *out = (*in_buf) >> 8; + *out = (in_buf.read_unaligned()) >> 8; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 3)) << (27 - 3); + *out |= ((in_buf.read_unaligned()) % (1u32 << 3)) << (27 - 3); out = out.offset(1); - *out = ((*in_buf) >> 3) % (1u32 << 27); + *out = ((in_buf.read_unaligned()) >> 3) % (1u32 << 27); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 25)) << (27 - 25); + *out |= ((in_buf.read_unaligned()) % (1u32 << 25)) << (27 - 25); out = out.offset(1); - *out = (*in_buf) >> 25; + *out = (in_buf.read_unaligned()) >> 25; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 20)) << (27 - 20); + *out |= ((in_buf.read_unaligned()) % (1u32 << 20)) << (27 - 20); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 15)) << (27 - 15); + *out |= ((in_buf.read_unaligned()) % (1u32 << 15)) << (27 - 15); out = out.offset(1); - *out = (*in_buf) >> 15; + *out = (in_buf.read_unaligned()) >> 15; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 10)) << (27 - 10); + *out |= ((in_buf.read_unaligned()) % (1u32 << 10)) << (27 - 10); out = out.offset(1); - *out = (*in_buf) >> 10; + *out = (in_buf.read_unaligned()) >> 10; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 5)) << (27 - 5); + *out |= ((in_buf.read_unaligned()) % (1u32 << 5)) << (27 - 5); out = out.offset(1); - *out = (*in_buf) >> 5; + *out = (in_buf.read_unaligned()) >> 5; in_buf.offset(1) } unsafe fn unpack28_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 28); + *out = (in_buf.read_unaligned()) % (1u32 << 28); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 24)) << (28 - 24); + *out |= ((in_buf.read_unaligned()) % (1u32 << 24)) << (28 - 24); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 20)) << (28 - 20); + *out |= ((in_buf.read_unaligned()) % (1u32 << 20)) << (28 - 20); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (28 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (28 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (28 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (28 - 12); out = out.offset(1); - *out = (*in_buf) >> 12; + *out = (in_buf.read_unaligned()) >> 12; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (28 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (28 - 8); out = out.offset(1); - *out = (*in_buf) >> 8; + *out = (in_buf.read_unaligned()) >> 8; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (28 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (28 - 4); out = out.offset(1); - *out = (*in_buf) >> 4; + *out = (in_buf.read_unaligned()) >> 4; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 28); + *out = (in_buf.read_unaligned()) % (1u32 << 28); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 24)) << (28 - 24); + *out |= ((in_buf.read_unaligned()) % (1u32 << 24)) << (28 - 24); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 20)) << (28 - 20); + *out |= ((in_buf.read_unaligned()) % (1u32 << 20)) << (28 - 20); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (28 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (28 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (28 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (28 - 12); out = out.offset(1); - *out = (*in_buf) >> 12; + *out = (in_buf.read_unaligned()) >> 12; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (28 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (28 - 8); out = out.offset(1); - *out = (*in_buf) >> 8; + *out = (in_buf.read_unaligned()) >> 8; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (28 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (28 - 4); out = out.offset(1); - *out = (*in_buf) >> 4; + *out = (in_buf.read_unaligned()) >> 4; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 28); + *out = (in_buf.read_unaligned()) % (1u32 << 28); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 24)) << (28 - 24); + *out |= ((in_buf.read_unaligned()) % (1u32 << 24)) << (28 - 24); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 20)) << (28 - 20); + *out |= ((in_buf.read_unaligned()) % (1u32 << 20)) << (28 - 20); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (28 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (28 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (28 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (28 - 12); out = out.offset(1); - *out = (*in_buf) >> 12; + *out = (in_buf.read_unaligned()) >> 12; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (28 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (28 - 8); out = out.offset(1); - *out = (*in_buf) >> 8; + *out = (in_buf.read_unaligned()) >> 8; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (28 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (28 - 4); out = out.offset(1); - *out = (*in_buf) >> 4; + *out = (in_buf.read_unaligned()) >> 4; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 28); + *out = (in_buf.read_unaligned()) % (1u32 << 28); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 24)) << (28 - 24); + *out |= ((in_buf.read_unaligned()) % (1u32 << 24)) << (28 - 24); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 20)) << (28 - 20); + *out |= ((in_buf.read_unaligned()) % (1u32 << 20)) << (28 - 20); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (28 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (28 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (28 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (28 - 12); out = out.offset(1); - *out = (*in_buf) >> 12; + *out = (in_buf.read_unaligned()) >> 12; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (28 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (28 - 8); out = out.offset(1); - *out = (*in_buf) >> 8; + *out = (in_buf.read_unaligned()) >> 8; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (28 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (28 - 4); out = out.offset(1); - *out = (*in_buf) >> 4; + *out = (in_buf.read_unaligned()) >> 4; in_buf.offset(1) } unsafe fn unpack29_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 29); + *out = (in_buf.read_unaligned()) % (1u32 << 29); out = out.offset(1); - *out = (*in_buf) >> 29; + *out = (in_buf.read_unaligned()) >> 29; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 26)) << (29 - 26); + *out |= ((in_buf.read_unaligned()) % (1u32 << 26)) << (29 - 26); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 23)) << (29 - 23); + *out |= ((in_buf.read_unaligned()) % (1u32 << 23)) << (29 - 23); out = out.offset(1); - *out = (*in_buf) >> 23; + *out = (in_buf.read_unaligned()) >> 23; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 20)) << (29 - 20); + *out |= ((in_buf.read_unaligned()) % (1u32 << 20)) << (29 - 20); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 17)) << (29 - 17); + *out |= ((in_buf.read_unaligned()) % (1u32 << 17)) << (29 - 17); out = out.offset(1); - *out = (*in_buf) >> 17; + *out = (in_buf.read_unaligned()) >> 17; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 14)) << (29 - 14); + *out |= ((in_buf.read_unaligned()) % (1u32 << 14)) << (29 - 14); out = out.offset(1); - *out = (*in_buf) >> 14; + *out = (in_buf.read_unaligned()) >> 14; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 11)) << (29 - 11); + *out |= ((in_buf.read_unaligned()) % (1u32 << 11)) << (29 - 11); out = out.offset(1); - *out = (*in_buf) >> 11; + *out = (in_buf.read_unaligned()) >> 11; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (29 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (29 - 8); out = out.offset(1); - *out = (*in_buf) >> 8; + *out = (in_buf.read_unaligned()) >> 8; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 5)) << (29 - 5); + *out |= ((in_buf.read_unaligned()) % (1u32 << 5)) << (29 - 5); out = out.offset(1); - *out = (*in_buf) >> 5; + *out = (in_buf.read_unaligned()) >> 5; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (29 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (29 - 2); out = out.offset(1); - *out = ((*in_buf) >> 2) % (1u32 << 29); + *out = ((in_buf.read_unaligned()) >> 2) % (1u32 << 29); out = out.offset(1); - *out = (*in_buf) >> 31; + *out = (in_buf.read_unaligned()) >> 31; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 28)) << (29 - 28); + *out |= ((in_buf.read_unaligned()) % (1u32 << 28)) << (29 - 28); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 25)) << (29 - 25); + *out |= ((in_buf.read_unaligned()) % (1u32 << 25)) << (29 - 25); out = out.offset(1); - *out = (*in_buf) >> 25; + *out = (in_buf.read_unaligned()) >> 25; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 22)) << (29 - 22); + *out |= ((in_buf.read_unaligned()) % (1u32 << 22)) << (29 - 22); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 19)) << (29 - 19); + *out |= ((in_buf.read_unaligned()) % (1u32 << 19)) << (29 - 19); out = out.offset(1); - *out = (*in_buf) >> 19; + *out = (in_buf.read_unaligned()) >> 19; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (29 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (29 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 13)) << (29 - 13); + *out |= ((in_buf.read_unaligned()) % (1u32 << 13)) << (29 - 13); out = out.offset(1); - *out = (*in_buf) >> 13; + *out = (in_buf.read_unaligned()) >> 13; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 10)) << (29 - 10); + *out |= ((in_buf.read_unaligned()) % (1u32 << 10)) << (29 - 10); out = out.offset(1); - *out = (*in_buf) >> 10; + *out = (in_buf.read_unaligned()) >> 10; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 7)) << (29 - 7); + *out |= ((in_buf.read_unaligned()) % (1u32 << 7)) << (29 - 7); out = out.offset(1); - *out = (*in_buf) >> 7; + *out = (in_buf.read_unaligned()) >> 7; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (29 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (29 - 4); out = out.offset(1); - *out = (*in_buf) >> 4; + *out = (in_buf.read_unaligned()) >> 4; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 1)) << (29 - 1); + *out |= ((in_buf.read_unaligned()) % (1u32 << 1)) << (29 - 1); out = out.offset(1); - *out = ((*in_buf) >> 1) % (1u32 << 29); + *out = ((in_buf.read_unaligned()) >> 1) % (1u32 << 29); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 27)) << (29 - 27); + *out |= ((in_buf.read_unaligned()) % (1u32 << 27)) << (29 - 27); out = out.offset(1); - *out = (*in_buf) >> 27; + *out = (in_buf.read_unaligned()) >> 27; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 24)) << (29 - 24); + *out |= ((in_buf.read_unaligned()) % (1u32 << 24)) << (29 - 24); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 21)) << (29 - 21); + *out |= ((in_buf.read_unaligned()) % (1u32 << 21)) << (29 - 21); out = out.offset(1); - *out = (*in_buf) >> 21; + *out = (in_buf.read_unaligned()) >> 21; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 18)) << (29 - 18); + *out |= ((in_buf.read_unaligned()) % (1u32 << 18)) << (29 - 18); out = out.offset(1); - *out = (*in_buf) >> 18; + *out = (in_buf.read_unaligned()) >> 18; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 15)) << (29 - 15); + *out |= ((in_buf.read_unaligned()) % (1u32 << 15)) << (29 - 15); out = out.offset(1); - *out = (*in_buf) >> 15; + *out = (in_buf.read_unaligned()) >> 15; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (29 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (29 - 12); out = out.offset(1); - *out = (*in_buf) >> 12; + *out = (in_buf.read_unaligned()) >> 12; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 9)) << (29 - 9); + *out |= ((in_buf.read_unaligned()) % (1u32 << 9)) << (29 - 9); out = out.offset(1); - *out = (*in_buf) >> 9; + *out = (in_buf.read_unaligned()) >> 9; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (29 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (29 - 6); out = out.offset(1); - *out = (*in_buf) >> 6; + *out = (in_buf.read_unaligned()) >> 6; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 3)) << (29 - 3); + *out |= ((in_buf.read_unaligned()) % (1u32 << 3)) << (29 - 3); out = out.offset(1); - *out = (*in_buf) >> 3; + *out = (in_buf.read_unaligned()) >> 3; in_buf.offset(1) } unsafe fn unpack30_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 30); + *out = (in_buf.read_unaligned()) % (1u32 << 30); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 28)) << (30 - 28); + *out |= ((in_buf.read_unaligned()) % (1u32 << 28)) << (30 - 28); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 26)) << (30 - 26); + *out |= ((in_buf.read_unaligned()) % (1u32 << 26)) << (30 - 26); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 24)) << (30 - 24); + *out |= ((in_buf.read_unaligned()) % (1u32 << 24)) << (30 - 24); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 22)) << (30 - 22); + *out |= ((in_buf.read_unaligned()) % (1u32 << 22)) << (30 - 22); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 20)) << (30 - 20); + *out |= ((in_buf.read_unaligned()) % (1u32 << 20)) << (30 - 20); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 18)) << (30 - 18); + *out |= ((in_buf.read_unaligned()) % (1u32 << 18)) << (30 - 18); out = out.offset(1); - *out = (*in_buf) >> 18; + *out = (in_buf.read_unaligned()) >> 18; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (30 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (30 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 14)) << (30 - 14); + *out |= ((in_buf.read_unaligned()) % (1u32 << 14)) << (30 - 14); out = out.offset(1); - *out = (*in_buf) >> 14; + *out = (in_buf.read_unaligned()) >> 14; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (30 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (30 - 12); out = out.offset(1); - *out = (*in_buf) >> 12; + *out = (in_buf.read_unaligned()) >> 12; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 10)) << (30 - 10); + *out |= ((in_buf.read_unaligned()) % (1u32 << 10)) << (30 - 10); out = out.offset(1); - *out = (*in_buf) >> 10; + *out = (in_buf.read_unaligned()) >> 10; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (30 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (30 - 8); out = out.offset(1); - *out = (*in_buf) >> 8; + *out = (in_buf.read_unaligned()) >> 8; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (30 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (30 - 6); out = out.offset(1); - *out = (*in_buf) >> 6; + *out = (in_buf.read_unaligned()) >> 6; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (30 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (30 - 4); out = out.offset(1); - *out = (*in_buf) >> 4; + *out = (in_buf.read_unaligned()) >> 4; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (30 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (30 - 2); out = out.offset(1); - *out = (*in_buf) >> 2; + *out = (in_buf.read_unaligned()) >> 2; in_buf = in_buf.offset(1); out = out.offset(1); - *out = (*in_buf) % (1u32 << 30); + *out = (in_buf.read_unaligned()) % (1u32 << 30); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 28)) << (30 - 28); + *out |= ((in_buf.read_unaligned()) % (1u32 << 28)) << (30 - 28); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 26)) << (30 - 26); + *out |= ((in_buf.read_unaligned()) % (1u32 << 26)) << (30 - 26); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 24)) << (30 - 24); + *out |= ((in_buf.read_unaligned()) % (1u32 << 24)) << (30 - 24); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 22)) << (30 - 22); + *out |= ((in_buf.read_unaligned()) % (1u32 << 22)) << (30 - 22); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 20)) << (30 - 20); + *out |= ((in_buf.read_unaligned()) % (1u32 << 20)) << (30 - 20); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 18)) << (30 - 18); + *out |= ((in_buf.read_unaligned()) % (1u32 << 18)) << (30 - 18); out = out.offset(1); - *out = (*in_buf) >> 18; + *out = (in_buf.read_unaligned()) >> 18; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (30 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (30 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 14)) << (30 - 14); + *out |= ((in_buf.read_unaligned()) % (1u32 << 14)) << (30 - 14); out = out.offset(1); - *out = (*in_buf) >> 14; + *out = (in_buf.read_unaligned()) >> 14; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (30 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (30 - 12); out = out.offset(1); - *out = (*in_buf) >> 12; + *out = (in_buf.read_unaligned()) >> 12; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 10)) << (30 - 10); + *out |= ((in_buf.read_unaligned()) % (1u32 << 10)) << (30 - 10); out = out.offset(1); - *out = (*in_buf) >> 10; + *out = (in_buf.read_unaligned()) >> 10; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (30 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (30 - 8); out = out.offset(1); - *out = (*in_buf) >> 8; + *out = (in_buf.read_unaligned()) >> 8; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (30 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (30 - 6); out = out.offset(1); - *out = (*in_buf) >> 6; + *out = (in_buf.read_unaligned()) >> 6; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (30 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (30 - 4); out = out.offset(1); - *out = (*in_buf) >> 4; + *out = (in_buf.read_unaligned()) >> 4; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (30 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (30 - 2); out = out.offset(1); - *out = (*in_buf) >> 2; + *out = (in_buf.read_unaligned()) >> 2; in_buf.offset(1) } unsafe fn unpack31_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = (*in_buf) % (1u32 << 31); + *out = (in_buf.read_unaligned()) % (1u32 << 31); out = out.offset(1); - *out = (*in_buf) >> 31; + *out = (in_buf.read_unaligned()) >> 31; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 30)) << (31 - 30); + *out |= ((in_buf.read_unaligned()) % (1u32 << 30)) << (31 - 30); out = out.offset(1); - *out = (*in_buf) >> 30; + *out = (in_buf.read_unaligned()) >> 30; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 29)) << (31 - 29); + *out |= ((in_buf.read_unaligned()) % (1u32 << 29)) << (31 - 29); out = out.offset(1); - *out = (*in_buf) >> 29; + *out = (in_buf.read_unaligned()) >> 29; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 28)) << (31 - 28); + *out |= ((in_buf.read_unaligned()) % (1u32 << 28)) << (31 - 28); out = out.offset(1); - *out = (*in_buf) >> 28; + *out = (in_buf.read_unaligned()) >> 28; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 27)) << (31 - 27); + *out |= ((in_buf.read_unaligned()) % (1u32 << 27)) << (31 - 27); out = out.offset(1); - *out = (*in_buf) >> 27; + *out = (in_buf.read_unaligned()) >> 27; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 26)) << (31 - 26); + *out |= ((in_buf.read_unaligned()) % (1u32 << 26)) << (31 - 26); out = out.offset(1); - *out = (*in_buf) >> 26; + *out = (in_buf.read_unaligned()) >> 26; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 25)) << (31 - 25); + *out |= ((in_buf.read_unaligned()) % (1u32 << 25)) << (31 - 25); out = out.offset(1); - *out = (*in_buf) >> 25; + *out = (in_buf.read_unaligned()) >> 25; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 24)) << (31 - 24); + *out |= ((in_buf.read_unaligned()) % (1u32 << 24)) << (31 - 24); out = out.offset(1); - *out = (*in_buf) >> 24; + *out = (in_buf.read_unaligned()) >> 24; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 23)) << (31 - 23); + *out |= ((in_buf.read_unaligned()) % (1u32 << 23)) << (31 - 23); out = out.offset(1); - *out = (*in_buf) >> 23; + *out = (in_buf.read_unaligned()) >> 23; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 22)) << (31 - 22); + *out |= ((in_buf.read_unaligned()) % (1u32 << 22)) << (31 - 22); out = out.offset(1); - *out = (*in_buf) >> 22; + *out = (in_buf.read_unaligned()) >> 22; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 21)) << (31 - 21); + *out |= ((in_buf.read_unaligned()) % (1u32 << 21)) << (31 - 21); out = out.offset(1); - *out = (*in_buf) >> 21; + *out = (in_buf.read_unaligned()) >> 21; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 20)) << (31 - 20); + *out |= ((in_buf.read_unaligned()) % (1u32 << 20)) << (31 - 20); out = out.offset(1); - *out = (*in_buf) >> 20; + *out = (in_buf.read_unaligned()) >> 20; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 19)) << (31 - 19); + *out |= ((in_buf.read_unaligned()) % (1u32 << 19)) << (31 - 19); out = out.offset(1); - *out = (*in_buf) >> 19; + *out = (in_buf.read_unaligned()) >> 19; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 18)) << (31 - 18); + *out |= ((in_buf.read_unaligned()) % (1u32 << 18)) << (31 - 18); out = out.offset(1); - *out = (*in_buf) >> 18; + *out = (in_buf.read_unaligned()) >> 18; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 17)) << (31 - 17); + *out |= ((in_buf.read_unaligned()) % (1u32 << 17)) << (31 - 17); out = out.offset(1); - *out = (*in_buf) >> 17; + *out = (in_buf.read_unaligned()) >> 17; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 16)) << (31 - 16); + *out |= ((in_buf.read_unaligned()) % (1u32 << 16)) << (31 - 16); out = out.offset(1); - *out = (*in_buf) >> 16; + *out = (in_buf.read_unaligned()) >> 16; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 15)) << (31 - 15); + *out |= ((in_buf.read_unaligned()) % (1u32 << 15)) << (31 - 15); out = out.offset(1); - *out = (*in_buf) >> 15; + *out = (in_buf.read_unaligned()) >> 15; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 14)) << (31 - 14); + *out |= ((in_buf.read_unaligned()) % (1u32 << 14)) << (31 - 14); out = out.offset(1); - *out = (*in_buf) >> 14; + *out = (in_buf.read_unaligned()) >> 14; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 13)) << (31 - 13); + *out |= ((in_buf.read_unaligned()) % (1u32 << 13)) << (31 - 13); out = out.offset(1); - *out = (*in_buf) >> 13; + *out = (in_buf.read_unaligned()) >> 13; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 12)) << (31 - 12); + *out |= ((in_buf.read_unaligned()) % (1u32 << 12)) << (31 - 12); out = out.offset(1); - *out = (*in_buf) >> 12; + *out = (in_buf.read_unaligned()) >> 12; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 11)) << (31 - 11); + *out |= ((in_buf.read_unaligned()) % (1u32 << 11)) << (31 - 11); out = out.offset(1); - *out = (*in_buf) >> 11; + *out = (in_buf.read_unaligned()) >> 11; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 10)) << (31 - 10); + *out |= ((in_buf.read_unaligned()) % (1u32 << 10)) << (31 - 10); out = out.offset(1); - *out = (*in_buf) >> 10; + *out = (in_buf.read_unaligned()) >> 10; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 9)) << (31 - 9); + *out |= ((in_buf.read_unaligned()) % (1u32 << 9)) << (31 - 9); out = out.offset(1); - *out = (*in_buf) >> 9; + *out = (in_buf.read_unaligned()) >> 9; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 8)) << (31 - 8); + *out |= ((in_buf.read_unaligned()) % (1u32 << 8)) << (31 - 8); out = out.offset(1); - *out = (*in_buf) >> 8; + *out = (in_buf.read_unaligned()) >> 8; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 7)) << (31 - 7); + *out |= ((in_buf.read_unaligned()) % (1u32 << 7)) << (31 - 7); out = out.offset(1); - *out = (*in_buf) >> 7; + *out = (in_buf.read_unaligned()) >> 7; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 6)) << (31 - 6); + *out |= ((in_buf.read_unaligned()) % (1u32 << 6)) << (31 - 6); out = out.offset(1); - *out = (*in_buf) >> 6; + *out = (in_buf.read_unaligned()) >> 6; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 5)) << (31 - 5); + *out |= ((in_buf.read_unaligned()) % (1u32 << 5)) << (31 - 5); out = out.offset(1); - *out = (*in_buf) >> 5; + *out = (in_buf.read_unaligned()) >> 5; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 4)) << (31 - 4); + *out |= ((in_buf.read_unaligned()) % (1u32 << 4)) << (31 - 4); out = out.offset(1); - *out = (*in_buf) >> 4; + *out = (in_buf.read_unaligned()) >> 4; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 3)) << (31 - 3); + *out |= ((in_buf.read_unaligned()) % (1u32 << 3)) << (31 - 3); out = out.offset(1); - *out = (*in_buf) >> 3; + *out = (in_buf.read_unaligned()) >> 3; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 2)) << (31 - 2); + *out |= ((in_buf.read_unaligned()) % (1u32 << 2)) << (31 - 2); out = out.offset(1); - *out = (*in_buf) >> 2; + *out = (in_buf.read_unaligned()) >> 2; in_buf = in_buf.offset(1); - *out |= ((*in_buf) % (1u32 << 1)) << (31 - 1); + *out |= ((in_buf.read_unaligned()) % (1u32 << 1)) << (31 - 1); out = out.offset(1); - *out = (*in_buf) >> 1; + *out = (in_buf.read_unaligned()) >> 1; in_buf.offset(1) } unsafe fn unpack32_32(mut in_buf: *const u32, mut out: *mut u32) -> *const u32 { - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf = in_buf.offset(1); out = out.offset(1); - *out = *in_buf; + *out = in_buf.read_unaligned(); in_buf.offset(1) } diff --git a/parquet/src/util/bit_util.rs b/parquet/src/util/bit_util.rs index 010ed32c8c8b..fa8b9ddac1ea 100644 --- a/parquet/src/util/bit_util.rs +++ b/parquet/src/util/bit_util.rs @@ -554,7 +554,6 @@ impl BitReader { unsafe { let in_buf = &self.buffer.data()[self.byte_offset..]; let mut in_ptr = in_buf as *const [u8] as *const u8 as *const u32; - // FIXME assert!(memory::is_ptr_aligned(in_ptr)); if size_of::() == 4 { while values_to_read - i >= 32 { let out_ptr = &mut batch[i..] as *mut [T] as *mut T as *mut u32; diff --git a/parquet/src/util/hash_util.rs b/parquet/src/util/hash_util.rs index 34d954c3b3e2..f3705bc32f5f 100644 --- a/parquet/src/util/hash_util.rs +++ b/parquet/src/util/hash_util.rs @@ -25,9 +25,9 @@ pub fn hash(data: &T, seed: u32) -> u32 { fn hash_(data: &[u8], seed: u32) -> u32 { #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] - unsafe { + { if is_x86_feature_detected!("sse4.2") { - crc32_hash(data, seed) + unsafe { crc32_hash(data, seed) } } else { murmur_hash2_64a(data, seed as u64) as u32 } @@ -39,7 +39,7 @@ fn hash_(data: &[u8], seed: u32) -> u32 { target_arch = "riscv64", target_arch = "wasm32" ))] - unsafe { + { murmur_hash2_64a(data, seed as u64) as u32 } } @@ -48,19 +48,15 @@ const MURMUR_PRIME: u64 = 0xc6a4a7935bd1e995; const MURMUR_R: i32 = 47; /// Rust implementation of MurmurHash2, 64-bit version for 64-bit platforms -/// -/// SAFTETY Only safe on platforms which support unaligned loads (like x86_64) -unsafe fn murmur_hash2_64a(data_bytes: &[u8], seed: u64) -> u64 { +fn murmur_hash2_64a(data_bytes: &[u8], seed: u64) -> u64 { let len = data_bytes.len(); let len_64 = (len / 8) * 8; - let data_bytes_64 = std::slice::from_raw_parts( - &data_bytes[0..len_64] as *const [u8] as *const u64, - len / 8, - ); let mut h = seed ^ (MURMUR_PRIME.wrapping_mul(data_bytes.len() as u64)); - for v in data_bytes_64 { - let mut k = *v; + for mut k in data_bytes + .chunks_exact(8) + .map(|chunk| u64::from_ne_bytes(chunk.try_into().unwrap())) + { k = k.wrapping_mul(MURMUR_PRIME); k ^= k >> MURMUR_R; k = k.wrapping_mul(MURMUR_PRIME); @@ -146,16 +142,14 @@ mod tests { #[test] fn test_murmur2_64a() { - unsafe { - let result = murmur_hash2_64a(b"hello", 123); - assert_eq!(result, 2597646618390559622); + let result = murmur_hash2_64a(b"hello", 123); + assert_eq!(result, 2597646618390559622); - let result = murmur_hash2_64a(b"helloworld", 123); - assert_eq!(result, 4934371746140206573); + let result = murmur_hash2_64a(b"helloworld", 123); + assert_eq!(result, 4934371746140206573); - let result = murmur_hash2_64a(b"helloworldparquet", 123); - assert_eq!(result, 2392198230801491746); - } + let result = murmur_hash2_64a(b"helloworldparquet", 123); + assert_eq!(result, 2392198230801491746); } #[test] diff --git a/parquet_derive/Cargo.toml b/parquet_derive/Cargo.toml index 31ccba44a263..ac8d49700f51 100644 --- a/parquet_derive/Cargo.toml +++ b/parquet_derive/Cargo.toml @@ -25,7 +25,8 @@ repository = "https://github.com/apache/arrow-rs" authors = ["Apache Arrow "] keywords = [ "parquet" ] readme = "README.md" -edition = "2018" +edition = "2021" +rust-version = "1.56" [lib] proc-macro = true diff --git a/parquet_derive/README.md b/parquet_derive/README.md index d0804db2a1c6..437b1ce2d31a 100644 --- a/parquet_derive/README.md +++ b/parquet_derive/README.md @@ -27,7 +27,9 @@ supported. Derive also has some support for the chrono time library. You must must enable the `chrono` feature to get this support. ## Usage + Add this to your Cargo.toml: + ```toml [dependencies] parquet = "7.0.0-SNAPSHOT" @@ -35,6 +37,7 @@ parquet_derive = "7.0.0-SNAPSHOT" ``` and this to your crate root: + ```rust extern crate parquet; #[macro_use] extern crate parquet_derive; @@ -75,24 +78,29 @@ writer.close().unwrap(); ``` ## Features -- [X] Support writing `String`, `&str`, `bool`, `i32`, `f32`, `f64`, `Vec` + +- [x] Support writing `String`, `&str`, `bool`, `i32`, `f32`, `f64`, `Vec` - [ ] Support writing dictionaries -- [X] Support writing logical types like timestamp -- [X] Derive definition_levels for `Option` +- [x] Support writing logical types like timestamp +- [x] Derive definition_levels for `Option` - [ ] Derive definition levels for nested structures - [ ] Derive writing tuple struct - [ ] Derive writing `tuple` container types ## Requirements + - Same as `parquet-rs` ## Test + Testing a `*_derive` crate requires an intermediate crate. Go to `parquet_derive_test` and run `cargo test` for unit tests. ## Docs + To build documentation, run `cargo doc --no-deps`. To compile and view in the browser, run `cargo doc --no-deps --open`. ## License + Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0. diff --git a/parquet_derive/src/lib.rs b/parquet_derive/src/lib.rs index 6d751500e949..d5d1e6818d73 100644 --- a/parquet_derive/src/lib.rs +++ b/parquet_derive/src/lib.rs @@ -25,7 +25,7 @@ extern crate quote; extern crate parquet; -use syn::{parse_macro_input, Data, DataStruct, DeriveInput}; +use ::syn::{parse_macro_input, Data, DataStruct, DeriveInput}; mod parquet_field; @@ -85,10 +85,7 @@ pub fn parquet_record_writer(input: proc_macro::TokenStream) -> proc_macro::Toke Data::Union(_) => unimplemented!("Union currently is not supported"), }; - let field_infos: Vec<_> = fields - .iter() - .map(|f: &syn::Field| parquet_field::Field::from(f)) - .collect(); + let field_infos: Vec<_> = fields.iter().map(parquet_field::Field::from).collect(); let writer_snippets: Vec = field_infos.iter().map(|x| x.writer_snippet()).collect(); @@ -103,7 +100,7 @@ pub fn parquet_record_writer(input: proc_macro::TokenStream) -> proc_macro::Toke impl #generics RecordWriter<#derived_for #generics> for &[#derived_for #generics] { fn write_to_row_group( &self, - row_group_writer: &mut Box + row_group_writer: &mut Box ) -> Result<(), parquet::errors::ParquetError> { let mut row_group_writer = row_group_writer; let records = &self; // Used by all the writer snippets to be more clear diff --git a/parquet_derive/test/dependency/default-features/Cargo.toml b/parquet_derive/test/dependency/default-features/Cargo.toml index 2a98dd49657e..48d86d95536e 100644 --- a/parquet_derive/test/dependency/default-features/Cargo.toml +++ b/parquet_derive/test/dependency/default-features/Cargo.toml @@ -19,7 +19,8 @@ name = "defeault-features" description = "Models a user application of parquet_derive that uses no additional features of arrow" version = "0.1.0" -edition = "2018" +edition = "2021" +rust-version = "1.56" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/parquet_derive_test/Cargo.toml b/parquet_derive_test/Cargo.toml index f48530b81da5..af3f5869104b 100644 --- a/parquet_derive_test/Cargo.toml +++ b/parquet_derive_test/Cargo.toml @@ -24,10 +24,11 @@ homepage = "https://github.com/apache/arrow-rs" repository = "https://github.com/apache/arrow-rs" authors = ["Apache Arrow "] keywords = [ "parquet" ] -edition = "2018" +edition = "2021" publish = false +rust-version = "1.56" [dependencies] parquet = { path = "../parquet", version = "7.0.0-SNAPSHOT" } parquet_derive = { path = "../parquet_derive", version = "7.0.0-SNAPSHOT" } -chrono = "0.4.19" \ No newline at end of file +chrono = "0.4.19" diff --git a/rustfmt.toml b/rustfmt.toml index c49cccdd9f5d..5c27f462e897 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -edition = "2018" +edition = "2021" +rust-version = "1.56" max_width = 90 # ignore generated files