aglib.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. File: aglib.h
  22. Copyright: (C) 2001-2011 Apple, Inc.
  23. */
  24. #ifndef AGLIB_H
  25. #define AGLIB_H
  26. #include <stdint.h>
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. #define QBSHIFT 9
  31. #define QB (1<<QBSHIFT)
  32. #define PB0 40
  33. #define MB0 10
  34. #define KB0 14
  35. #define MAX_RUN_DEFAULT 255
  36. #define MMULSHIFT 2
  37. #define MDENSHIFT (QBSHIFT - MMULSHIFT - 1)
  38. #define MOFF ((1<<(MDENSHIFT-2)))
  39. #define BITOFF 24
  40. /* Max. prefix of 1's. */
  41. #define MAX_PREFIX_16 9
  42. #define MAX_PREFIX_TOLONG_16 15
  43. #define MAX_PREFIX_32 9
  44. /* Max. bits in 16-bit data type */
  45. #define MAX_DATATYPE_BITS_16 16
  46. typedef struct AGParamRec
  47. {
  48. uint32_t mb, mb0, pb, kb, wb, qb;
  49. uint32_t fw, sw;
  50. uint32_t maxrun;
  51. // fw = 1, sw = 1;
  52. } AGParamRec, *AGParamRecPtr;
  53. struct BitBuffer;
  54. void set_standard_ag_params(AGParamRecPtr params, uint32_t fullwidth, uint32_t sectorwidth);
  55. void set_ag_params(AGParamRecPtr params, uint32_t m, uint32_t p, uint32_t k, uint32_t f, uint32_t s, uint32_t maxrun);
  56. int32_t dyn_comp(AGParamRecPtr params, int32_t * pc, struct BitBuffer * bitstream, int32_t numSamples, int32_t bitSize, uint32_t * outNumBits);
  57. int32_t dyn_decomp(AGParamRecPtr params, struct BitBuffer * bitstream, int32_t * pc, int32_t numSamples, int32_t maxSize, uint32_t * outNumBits);
  58. #ifdef __cplusplus
  59. }
  60. #endif
  61. #endif //#ifndef AGLIB_H