xref: /third_party/libsnd/src/ALAC/aglib.h (revision b815c7f3)
1/*
2 * Copyright (c) 2011 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License") ;
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 *	 http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21/*
22	File:		aglib.h
23
24	Copyright:	(C) 2001-2011 Apple, Inc.
25*/
26
27#ifndef AGLIB_H
28#define AGLIB_H
29
30#include <stdint.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36#define QBSHIFT		9
37#define QB			(1 << QBSHIFT)
38#define PB0			40
39#define MB0			10
40#define KB0			14
41#define MAX_RUN_DEFAULT 255
42
43#define MMULSHIFT	2
44#define MDENSHIFT	(QBSHIFT - MMULSHIFT - 1)
45#define MOFF		((1 << (MDENSHIFT - 2)))
46
47#define BITOFF 24
48
49/* Max. prefix of 1's. */
50#define MAX_PREFIX_16			9
51#define MAX_PREFIX_TOLONG_16	15
52#define MAX_PREFIX_32			9
53
54/* Max. bits in 16-bit data type */
55#define MAX_DATATYPE_BITS_16	16
56
57typedef struct AGParamRec
58{
59	uint32_t mb, mb0, pb, kb, wb, qb ;
60	uint32_t fw, sw ;
61
62	uint32_t maxrun ;
63
64	// fw = 1, sw = 1 ;
65
66} AGParamRec, *AGParamRecPtr ;
67
68struct BitBuffer ;
69
70void	set_standard_ag_params (AGParamRecPtr params, uint32_t fullwidth, uint32_t sectorwidth) ;
71void	set_ag_params (AGParamRecPtr params, uint32_t m, uint32_t p, uint32_t k, uint32_t f, uint32_t s, uint32_t maxrun) ;
72
73int32_t	dyn_comp (AGParamRecPtr params, int32_t * pc, struct BitBuffer * bitstream, int32_t numSamples, int32_t bitSize, uint32_t * outNumBits) ;
74int32_t	dyn_decomp (AGParamRecPtr params, struct BitBuffer * bitstream, int32_t * pc, int32_t numSamples, int32_t maxSize, uint32_t * outNumBits) ;
75
76
77#ifdef __cplusplus
78}
79#endif
80
81#endif //#ifndef AGLIB_H
82