mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-24 01:18:08 +01:00
add alac licanse
This commit is contained in:
parent
bb771cef97
commit
3d8c847c13
3 changed files with 338 additions and 0 deletions
241
alac/ALACMagicCookieDescription.txt
Normal file
241
alac/ALACMagicCookieDescription.txt
Normal file
|
@ -0,0 +1,241 @@
|
|||
__________________________________________________________________________________________________________________________________
|
||||
__________________________________________________________________________________________________________________________________
|
||||
Apple Lossless Format "Magic Cookie" Description
|
||||
__________________________________________________________________________________________________________________________________
|
||||
__________________________________________________________________________________________________________________________________
|
||||
|
||||
Many encoded formats for audio require additional, codec specific configuration information in order to operate successfully.
|
||||
This codec specific information is often called a 'magic cookie'. The Apple Lossless codec's 'magic cookie' contains the
|
||||
ALACSpecificConfig and optional ALACChannelLayoutInfo (both described below).
|
||||
|
||||
The 'magic cookie' must accompany the bitstream when stored in any file container (M4A/MP4, CAF) so that it may be provided to the
|
||||
decoder when decoding the bitstream. From the caller's perspective, the 'magic cookie' is opaque and should be stored in the file
|
||||
and presented to the decoder exactly as it is vended from the encoder (and consequently stored in the file).
|
||||
|
||||
The ALAC 'magic cookie' as stored in a file has all fields described in big-endian order (regardless of file format).
|
||||
|
||||
The layout of the 'magic cookie' is as follows:
|
||||
|
||||
|
||||
---------------- ALAC Specific Info (24 bytes) (mandatory) ---------------------------
|
||||
(ALACSpecificConfig) Decoder Info
|
||||
|
||||
---------------- Channel Layout Info (24 bytes) (optional) ----------------------------
|
||||
(ALAC Channel Layout Info) Channel Layout Info
|
||||
|
||||
|
||||
If the channel layout is absent from the cookie, then the following assumptions are made:
|
||||
1 channel - mono
|
||||
2 channels - stereo in left, right order
|
||||
> 2 channels - no specific channel designation or role.
|
||||
|
||||
|
||||
__________________________________________________________________________________________________________________________________
|
||||
* ALAC Specific Info (24 bytes) (mandatory)
|
||||
__________________________________________________________________________________________________________________________________
|
||||
|
||||
The Apple Lossless codec stores specific information about the encoded stream in the ALACSpecificConfig. This
|
||||
info is vended by the encoder and is used to setup the decoder for a given encoded bitstream.
|
||||
|
||||
When read from and written to a file, the fields of this struct must be in big-endian order.
|
||||
When vended by the encoder (and received by the decoder) the struct values will be in big-endian order.
|
||||
|
||||
/*
|
||||
struct ALACSpecificConfig (defined in ALACAudioTypes.h)
|
||||
abstract This struct is used to describe codec provided information about the encoded Apple Lossless bitstream.
|
||||
It must accompany the encoded stream in the containing audio file and be provided to the decoder.
|
||||
|
||||
field frameLength uint32_t indicating the frames per packet when no explicit frames per packet setting is
|
||||
present in the packet header. The encoder frames per packet can be explicitly set
|
||||
but for maximum compatibility, the default encoder setting of 4096 should be used.
|
||||
|
||||
field compatibleVersion uint8_t indicating compatible version,
|
||||
value must be set to 0
|
||||
|
||||
field bitDepth uint8_t describes the bit depth of the source PCM data (maximum value = 32)
|
||||
|
||||
field pb uint8_t currently unused tuning parameter.
|
||||
value should be set to 40
|
||||
|
||||
field mb uint8_t currently unused tuning parameter.
|
||||
value should be set to 10
|
||||
|
||||
field kb uint8_t currently unused tuning parameter.
|
||||
value should be set to 14
|
||||
|
||||
field numChannels uint8_t describes the channel count (1 = mono, 2 = stereo, etc...)
|
||||
when channel layout info is not provided in the 'magic cookie', a channel count > 2
|
||||
describes a set of discreet channels with no specific ordering
|
||||
|
||||
field maxRun uint16_t currently unused.
|
||||
value should be set to 255
|
||||
|
||||
field maxFrameBytes uint32_t the maximum size of an Apple Lossless packet within the encoded stream.
|
||||
value of 0 indicates unknown
|
||||
|
||||
field avgBitRate uint32_t the average bit rate in bits per second of the Apple Lossless stream.
|
||||
value of 0 indicates unknown
|
||||
|
||||
field sampleRate uint32_t sample rate of the encoded stream
|
||||
*/
|
||||
|
||||
typedef struct ALACSpecificConfig
|
||||
{
|
||||
uint32_t frameLength;
|
||||
uint8_t compatibleVersion;
|
||||
uint8_t bitDepth;
|
||||
uint8_t pb;
|
||||
uint8_t mb;
|
||||
uint8_t kb;
|
||||
uint8_t numChannels;
|
||||
uint16_t maxRun;
|
||||
uint32_t maxFrameBytes;
|
||||
uint32_t avgBitRate;
|
||||
uint32_t sampleRate;
|
||||
|
||||
} ALACSpecificConfig;
|
||||
|
||||
|
||||
__________________________________________________________________________________________________________________________________
|
||||
Channel Layout Info (24 bytes) (optional)
|
||||
__________________________________________________________________________________________________________________________________
|
||||
|
||||
The Apple Lossless codec can support a specific set of channel layouts. When channel information is vended
|
||||
by the encoder (in the 'magic cookie'), it is formatted in the the ALACChannelLayoutInfo.
|
||||
|
||||
When read from and written to a file, the fields of this struct must be in big-endian order.
|
||||
When vended by the encoder (and received by the decoder) the struct values will be in big-endian order.
|
||||
|
||||
/*
|
||||
struct ALACChannelLayoutInfo (defined in ALACAudioTypes.h)
|
||||
abstract This struct is used to specify particular channel orderings or configurations.
|
||||
It is an optional portion of the 'magic cookie', being required to describe specific channel layouts (see below)
|
||||
of more than 2 channels.
|
||||
|
||||
field channelLayoutInfoSize uint32_t indicates the size of the channel layout data
|
||||
value should be set to 24
|
||||
|
||||
field channelLayoutInfoID uint32_t identifier indicating that channel layout info is present
|
||||
value = 'chan'
|
||||
|
||||
field versionFlags uint32_t version flags
|
||||
value should be set to 0
|
||||
|
||||
field channelLayoutTag uint32_t channel layout type
|
||||
from defined list in ALACAudioTypes.h (see below)
|
||||
|
||||
field reserved1 uint32_t currently unused field
|
||||
value should be set to 0
|
||||
|
||||
field reserved2 uint32_t currently unused field
|
||||
value should be set to 0
|
||||
*/
|
||||
|
||||
typedef struct ALACChannelLayoutInfo
|
||||
{
|
||||
uint32_t channelLayoutInfoSize;
|
||||
uint32_t channelLayoutInfoID;
|
||||
uint32_t versionFlags;
|
||||
uint32_t channelLayoutTag;
|
||||
uint32_t reserved1;
|
||||
uint32_t reserved2;
|
||||
} ALACChannelLayoutInfo;
|
||||
|
||||
|
||||
* Channel Layout Tags
|
||||
|
||||
These constants will be used to describe the bitstream's channel layout. (defined in ALACAudioTypes.h)
|
||||
|
||||
enum
|
||||
{
|
||||
kALACChannelLayoutTag_Mono = (100<<16) | 1, // C
|
||||
kALACChannelLayoutTag_Stereo = (101<<16) | 2, // L R
|
||||
kALACChannelLayoutTag_MPEG_3_0_B = (113<<16) | 3, // C L R
|
||||
kALACChannelLayoutTag_MPEG_4_0_B = (116<<16) | 4, // C L R Cs
|
||||
kALACChannelLayoutTag_MPEG_5_0_D = (120<<16) | 5, // C L R Ls Rs
|
||||
kALACChannelLayoutTag_MPEG_5_1_D = (124<<16) | 6, // C L R Ls Rs LFE
|
||||
kALACChannelLayoutTag_AAC_6_1 = (142<<16) | 7, // C L R Ls Rs Cs LFE
|
||||
kALACChannelLayoutTag_MPEG_7_1_B = (127<<16) | 8 // C Lc Rc L R Ls Rs LFE (doc: IS-13818-7 MPEG2-AAC)
|
||||
};
|
||||
|
||||
|
||||
__________________________________________________________________________________________________________________________________
|
||||
__________________________________________________________________________________________________________________________________
|
||||
* Storing Apple Lossless Magic Cookie in Audio Files
|
||||
__________________________________________________________________________________________________________________________________
|
||||
__________________________________________________________________________________________________________________________________
|
||||
|
||||
The Apple Lossless Magic Cookie is treated as opaque by file parsing code. The 'magic cookie' vended by the encoder
|
||||
is placed without modification into the audio file and the read from that file and passed (unmodified) to the decoder.
|
||||
|
||||
__________________________________________________________________________________________________________________________________
|
||||
* CAF File
|
||||
|
||||
In a CAF file (Core Audio File), the 'magic cookie' is stored in CAF's Magic Cookie chunk ('kuki').
|
||||
|
||||
__________________________________________________________________________________________________________________________________
|
||||
* MP4/M4A File
|
||||
|
||||
In an MP4/M4A file, the 'magic cookie' is encapsulated in the AudioSample entry of a Sound Description box ('stsd').
|
||||
An ISO style full box header to describe the ALACSpecificConfig portion is appended to the AudioSampleEntry, followed by the
|
||||
'magic cookie' as it is vended by the encoder.
|
||||
|
||||
(All fields are stored in big-endian order: see ISO/IEC 14496-12 for a full description of the SoundDescription and AudioSampleEntry boxes, etc.)
|
||||
|
||||
---------------- SoundDescriptionBox (FullBox) ----------------------------
|
||||
|
||||
SampleEntrySize // = sizeof(SoundDescriptionBox)(16) + sizeof (AudioSampleEntry)(AudioSampleEntry.SampleEntrySize)
|
||||
SampleEntryType // = 'stsd'
|
||||
VersionFlags // = 0
|
||||
EntryCount // = 1
|
||||
|
||||
---------------- Audio Sample Entry (REQUIRED) -----------------------------
|
||||
|
||||
SampleEntrySize // sizeof(AudioSampleEntry)(36) + sizeof(full ISO box header)(12) + sizeof(Apple Lossless Magic Cookie)
|
||||
SampleEntryType // = 'alac', specifies that the AudioSampleEntry describes an Apple Lossless bitstream
|
||||
mReserved[6] // = 0
|
||||
dref index // = 1
|
||||
reserved[2] // = 0
|
||||
channel count // = number of channels as a uint_16 value
|
||||
sample size // = source pcm bitdepth (example = 16bit source pcm)
|
||||
predefined // = 0
|
||||
reserved // = 0
|
||||
sample rate // sample rate as a uint_32 value
|
||||
|
||||
Appended to AudioSampleEntry:
|
||||
|
||||
ALAC Specific Info Size // uint_32 value, = 36 (12 + sizeof(ALACSpecificConfig))
|
||||
ALAC Specific Info ID // uint_32 value, = 'alac', format ID which matches the Audio Sample Entry SampleEntryType field
|
||||
Version Flags // uint_32 value, = 0
|
||||
|
||||
Apple Lossless Magic Cookie // 'magic cookie' vended from ALAC encoder (24 or 48 Bytes)
|
||||
|
||||
__________________________________________________________________________________________________________________________________
|
||||
__________________________________________________________________________________________________________________________________
|
||||
* Compatibility
|
||||
__________________________________________________________________________________________________________________________________
|
||||
__________________________________________________________________________________________________________________________________
|
||||
|
||||
Previous versions of the Apple Lossless encoder vended a different 'magic cookie'. To ensure compatibility, the Apple Lossless decoder
|
||||
must be prepared to parse a 'magic cookie' in the format described below. Note that the 'magic cookie' defined above is
|
||||
encapsulated in the following method and can be extracted as a contiguous set of bytes.
|
||||
|
||||
|
||||
---------------- Format Atom (12 bytes) --------------------------------
|
||||
(uint_32) Format Atom Size // = 12
|
||||
(uint_32) Channel Layout Info ID // = 'frma'
|
||||
(uint_32) Format Type // = 'alac'
|
||||
|
||||
---------------- ALAC Specific Info (36 bytes) (required) --------------
|
||||
(uint_32) ALAC Specific Info Size // = 36 (12 + sizeof(ALACSpecificConfig))
|
||||
(uint_32) ALAC Specific Info ID // = 'alac', format ID which matches the Audio Sample Entry SampleEntryType field
|
||||
(uint_32) Version Flags // = 0
|
||||
|
||||
[ Apple Lossless Magic Cookie (see above) ]
|
||||
|
||||
---------------- Terminator Atom (8 bytes) -----------------------------
|
||||
(uint_32) Channel Layout Info Size // = 8
|
||||
(uint_32) Channel Layout Info ID // = 0
|
||||
|
||||
|
||||
|
53
alac/LICENSE
Normal file
53
alac/LICENSE
Normal file
|
@ -0,0 +1,53 @@
|
|||
Apache License
|
||||
|
||||
Version 2.0, January 2004
|
||||
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
||||
|
||||
You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||
|
||||
You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||
|
||||
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||
|
||||
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
44
alac/ReadMe.txt
Normal file
44
alac/ReadMe.txt
Normal file
|
@ -0,0 +1,44 @@
|
|||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
The Apple Lossless Format
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
Apple Lossless supports the following features. Not all of these are implemented in alacconvert, though they are in the codec code provided.
|
||||
|
||||
1. Bit depths 16, 20, 24 and 32 bits.
|
||||
2. Any arbitrary integer sample rate from 1 to 384,000 Hz. In theory rates up to 4,294,967,295 (2^32 - 1) Hz could be supported.
|
||||
3. From one to eight channels are supported. Channel orders for the supported formats are described as:
|
||||
Num Chan Order
|
||||
1 mono
|
||||
2 stereo (Left, Right)
|
||||
3 MPEG 3.0 B (Center, Left, Right)
|
||||
4 MPEG 4.0 B (Center, Left, Right, Center Surround)
|
||||
5 MPEG 5.0 D (Center, Left, Right, Left Surround, Right Surround)
|
||||
6 MPEG 5.1 D (Center, Left, Right, Left Surround, Right Surround, Low Frequency Effects)
|
||||
7 Apple AAC 6.1 (Center, Left, Right, Left Surround, Right Surround, Center Surround, Low Frequency Effects)
|
||||
8 MPEG 7.1 B (Center, Left Center, Right Center, Left, Right, Left Surround, Right Surround, Low Frequency Effects)
|
||||
4. Packet size defaults to 4096 sample frames of audio per packet. Other packet sizes are certainly possible. However, non-default packet sizes are not guaranteed to work properly on all hardware devices that support Apple Lossless. Packets above 16,384 sample frames are not supported.
|
||||
|
||||
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
This package contains the sources for the Apple Lossless (ALAC) encoder and decoder.
|
||||
|
||||
The "codec" directory contains all the sources necessary for a functioning codec. Also includes is a makefile that will build libalac.a on a UNIX/Linux machine.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
ALACconvert
|
||||
|
||||
The convert-utility directory contains sources to build alacconvert which is a simple utility that demonstrates how to use the included ALAC encoder and decoder.
|
||||
|
||||
alacconvert supports the following formats:
|
||||
|
||||
1. 16- or 24-bit mono or stereo .wav files where the data is little endian integer. Extended WAVE format chunks are not handled.
|
||||
2. 16- or 24-bit mono or stereo .caf (Core Audio Format) files as well as certain multi-channel configurations where the data is big or little endian integer. It does no channel order manipulation.
|
||||
3. ALAC .caf files.
|
||||
|
||||
Three project are provided to build a command line utility called alacconvert that converts cpm data to ALAC or vice versa. A Mac OS X Xcode project, A Windows Visual Studio project, and a generic UNIX/Linux make file.
|
||||
|
||||
Note: When building on Windows, if you are using a version of Visual Studio before Visual Studio 2010, <stdint.h> is not installed. You will need to acquire this file on your own. It can be put in the same directory as the project.
|
||||
|
||||
|
||||
|
Loading…
Reference in a new issue