1b815c7f3Sopenharmony_ci/*
2b815c7f3Sopenharmony_ci * Copyright (c) 2011 Apple Inc. All rights reserved.
3b815c7f3Sopenharmony_ci * Copyright (C) 2012-2014 Erik de Castro Lopo <erikd@mega-nerd.com>
4b815c7f3Sopenharmony_ci *
5b815c7f3Sopenharmony_ci * @APPLE_APACHE_LICENSE_HEADER_START@
6b815c7f3Sopenharmony_ci *
7b815c7f3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License") ;
8b815c7f3Sopenharmony_ci * you may not use this file except in compliance with the License.
9b815c7f3Sopenharmony_ci * You may obtain a copy of the License at
10b815c7f3Sopenharmony_ci *
11b815c7f3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
12b815c7f3Sopenharmony_ci *
13b815c7f3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
14b815c7f3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
15b815c7f3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16b815c7f3Sopenharmony_ci * See the License for the specific language governing permissions and
17b815c7f3Sopenharmony_ci * limitations under the License.
18b815c7f3Sopenharmony_ci *
19b815c7f3Sopenharmony_ci * @APPLE_APACHE_LICENSE_HEADER_END@
20b815c7f3Sopenharmony_ci */
21b815c7f3Sopenharmony_ci
22b815c7f3Sopenharmony_ci/*
23b815c7f3Sopenharmony_ci	File:		matrixlib.h
24b815c7f3Sopenharmony_ci
25b815c7f3Sopenharmony_ci	Contains:	ALAC mixing/matrixing routines to/from 32-bit predictor buffers.
26b815c7f3Sopenharmony_ci
27b815c7f3Sopenharmony_ci	Copyright:	Copyright (C) 2004 to 2011 Apple, Inc.
28b815c7f3Sopenharmony_ci*/
29b815c7f3Sopenharmony_ci
30b815c7f3Sopenharmony_ci#ifndef __MATRIXLIB_H
31b815c7f3Sopenharmony_ci#define __MATRIXLIB_H
32b815c7f3Sopenharmony_ci
33b815c7f3Sopenharmony_ci#pragma once
34b815c7f3Sopenharmony_ci
35b815c7f3Sopenharmony_ci#include <stdint.h>
36b815c7f3Sopenharmony_ci
37b815c7f3Sopenharmony_ci#ifdef __cplusplus
38b815c7f3Sopenharmony_ciextern "C" {
39b815c7f3Sopenharmony_ci#endif
40b815c7f3Sopenharmony_ci
41b815c7f3Sopenharmony_ci// 16-bit routines
42b815c7f3Sopenharmony_civoid	mix16 (const int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples, int32_t mixbits, int32_t mixres) ;
43b815c7f3Sopenharmony_civoid	unmix16 (const int32_t * u, int32_t * v, int32_t * out, uint32_t stride, int32_t numSamples, int32_t mixbits, int32_t mixres) ;
44b815c7f3Sopenharmony_ci
45b815c7f3Sopenharmony_ci// 20-bit routines
46b815c7f3Sopenharmony_civoid	mix20 (const int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples, int32_t mixbits, int32_t mixres) ;
47b815c7f3Sopenharmony_civoid	unmix20 (const int32_t * u, int32_t * v, int32_t * out, uint32_t stride, int32_t numSamples, int32_t mixbits, int32_t mixres) ;
48b815c7f3Sopenharmony_ci
49b815c7f3Sopenharmony_ci// 24-bit routines
50b815c7f3Sopenharmony_ci// - 24-bit data sometimes compresses better by shifting off the bottom byte so these routines deal with
51b815c7f3Sopenharmony_ci//	 the specified "unused lower bytes" in the combined "shift" buffer
52b815c7f3Sopenharmony_civoid	mix24 (const int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples,
53b815c7f3Sopenharmony_ci				int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted) ;
54b815c7f3Sopenharmony_civoid	unmix24 (const int32_t * u, int32_t * v, int32_t * out, uint32_t stride, int32_t numSamples,
55b815c7f3Sopenharmony_ci					int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted) ;
56b815c7f3Sopenharmony_ci
57b815c7f3Sopenharmony_ci// 32-bit routines
58b815c7f3Sopenharmony_ci// - note that these really expect the internal data width to be < 32-bit but the arrays are 32-bit
59b815c7f3Sopenharmony_ci// - otherwise, the calculations might overflow into the 33rd bit and be lost
60b815c7f3Sopenharmony_ci// - therefore, these routines deal with the specified "unused lower" bytes in the combined "shift" buffer
61b815c7f3Sopenharmony_civoid	mix32 (const int32_t * in, uint32_t stride, int32_t * u, int32_t * v, int32_t numSamples,
62b815c7f3Sopenharmony_ci				int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted) ;
63b815c7f3Sopenharmony_civoid	unmix32 (const int32_t * u, int32_t * v, int32_t * out, uint32_t stride, int32_t numSamples,
64b815c7f3Sopenharmony_ci				int32_t mixbits, int32_t mixres, uint16_t * shiftUV, int32_t bytesShifted) ;
65b815c7f3Sopenharmony_ci
66b815c7f3Sopenharmony_ci// 20/24/32-bit <-> 32-bit helper routines (not really matrixing but convenient to put here)
67b815c7f3Sopenharmony_civoid	copy20ToPredictor (const int32_t * in, uint32_t stride, int32_t * out, int32_t numSamples) ;
68b815c7f3Sopenharmony_civoid	copy24ToPredictor (const int32_t * in, uint32_t stride, int32_t * out, int32_t numSamples) ;
69b815c7f3Sopenharmony_ci
70b815c7f3Sopenharmony_civoid	copyPredictorTo24 (const int32_t * in, int32_t * out, uint32_t stride, int32_t numSamples) ;
71b815c7f3Sopenharmony_civoid	copyPredictorTo24Shift (const int32_t * in, uint16_t * shift, int32_t * out, uint32_t stride, int32_t numSamples, int32_t bytesShifted) ;
72b815c7f3Sopenharmony_civoid	copyPredictorTo20 (const int32_t * in, int32_t * out, uint32_t stride, int32_t numSamples) ;
73b815c7f3Sopenharmony_ci
74b815c7f3Sopenharmony_civoid	copyPredictorTo32 (const int32_t * in, int32_t * out, uint32_t stride, int32_t numSamples) ;
75b815c7f3Sopenharmony_civoid	copyPredictorTo32Shift (const int32_t * in, uint16_t * shift, int32_t * out, uint32_t stride, int32_t numSamples, int32_t bytesShifted) ;
76b815c7f3Sopenharmony_ci
77b815c7f3Sopenharmony_ci#ifdef __cplusplus
78b815c7f3Sopenharmony_ci}
79b815c7f3Sopenharmony_ci#endif
80b815c7f3Sopenharmony_ci
81b815c7f3Sopenharmony_ci#endif	/* __MATRIXLIB_H */
82