1
0
mirror of https://github.com/mstorsjo/fdk-aac.git synced 2025-02-25 15:07:56 +01:00

Upgrade to FDKv2

am: 6cfabd3536

Change-Id: I5abc38a4b00222ae983a057f006b0af9bd61ffb3
This commit is contained in:
Fraunhofer IIS FDK 2018-04-30 17:22:06 -07:00 committed by android-build-merger
commit df390e3492
450 changed files with 164126 additions and 83284 deletions

4
.clang-format Normal file
View File

@ -0,0 +1,4 @@
BasedOnStyle: Google
SortIncludes: false
# Do not reformat the Doxygen-style comments in the code
CommentPragmas : "^ * \\\\"

View File

@ -11,16 +11,22 @@ cc_library_static {
"libMpegTPEnc/src/*.cpp",
"libSBRdec/src/*.cpp",
"libSBRenc/src/*.cpp",
"libArithCoding/src/*.cpp",
"libDRCdec/src/*.cpp",
"libSACdec/src/*.cpp",
"libSACenc/src/*.cpp",
],
cflags: [
"-Werror",
"-Wno-constant-conversion",
"-Wno-sequence-point",
"-Wno-extra",
"-Wno-unused-parameter",
"-Wno-#warnings",
"-Wno-constant-logical-operand",
"-Wuninitialized",
"-Wno-self-assign",
],
sanitize: {
misc_undefined:["unsigned-integer-overflow", "signed-integer-overflow"],
cfi: true,
},
export_include_dirs: [
"libAACdec/include",
"libAACenc/include",
@ -31,5 +37,9 @@ cc_library_static {
"libMpegTPEnc/include",
"libSBRdec/include",
"libSBRenc/include",
"libArithCoding/include",
"libDRCdec/include",
"libSACdec/include",
"libSACenc/include",
],
}

106
NOTICE
View File

@ -1,72 +1,84 @@
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

173
libAACdec/src/FDK_delay.cpp Normal file
View File

@ -0,0 +1,173 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
Fraunhofer Institute for Integrated Circuits IIS
Attention: Audio and Multimedia Departments - FDK AAC LL
Am Wolfsmantel 33
91058 Erlangen, Germany
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): Matthias Hildenbrand
Description:
*******************************************************************************/
#include "FDK_delay.h"
#include "genericStds.h"
#define MAX_FRAME_LENGTH (1024)
INT FDK_Delay_Create(FDK_SignalDelay* data, const USHORT delay,
const UCHAR num_channels) {
FDK_ASSERT(data != NULL);
FDK_ASSERT(num_channels > 0);
if (delay > 0) {
data->delay_line =
(INT_PCM*)FDKcalloc(num_channels * delay, sizeof(INT_PCM));
if (data->delay_line == NULL) {
return -1;
}
} else {
data->delay_line = NULL;
}
data->num_channels = num_channels;
data->delay = delay;
return 0;
}
void FDK_Delay_Apply(FDK_SignalDelay* data, FIXP_PCM* time_buffer,
const UINT frame_length, const UCHAR channel) {
FDK_ASSERT(data != NULL);
if (data->delay > 0) {
C_ALLOC_SCRATCH_START(tmp, FIXP_PCM, MAX_FRAME_LENGTH)
FDK_ASSERT(frame_length <= MAX_FRAME_LENGTH);
FDK_ASSERT(channel < data->num_channels);
FDK_ASSERT(time_buffer != NULL);
if (frame_length >= data->delay) {
FDKmemcpy(tmp, &time_buffer[frame_length - data->delay],
data->delay * sizeof(FIXP_PCM));
FDKmemmove(&time_buffer[data->delay], &time_buffer[0],
(frame_length - data->delay) * sizeof(FIXP_PCM));
FDKmemcpy(&time_buffer[0], &data->delay_line[channel * data->delay],
data->delay * sizeof(FIXP_PCM));
FDKmemcpy(&data->delay_line[channel * data->delay], tmp,
data->delay * sizeof(FIXP_PCM));
} else {
FDKmemcpy(tmp, &time_buffer[0], frame_length * sizeof(FIXP_PCM));
FDKmemcpy(&time_buffer[0], &data->delay_line[channel * data->delay],
frame_length * sizeof(FIXP_PCM));
FDKmemcpy(&data->delay_line[channel * data->delay],
&data->delay_line[channel * data->delay + frame_length],
(data->delay - frame_length) * sizeof(FIXP_PCM));
FDKmemcpy(&data->delay_line[channel * data->delay +
(data->delay - frame_length)],
tmp, frame_length * sizeof(FIXP_PCM));
}
C_ALLOC_SCRATCH_END(tmp, FIXP_PCM, MAX_FRAME_LENGTH)
}
return;
}
void FDK_Delay_Destroy(FDK_SignalDelay* data) {
if (data->delay_line != NULL) {
FDKfree(data->delay_line);
}
data->delay_line = NULL;
data->delay = 0;
data->num_channels = 0;
return;
}

152
libAACdec/src/FDK_delay.h Normal file
View File

@ -0,0 +1,152 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
Fraunhofer Institute for Integrated Circuits IIS
Attention: Audio and Multimedia Departments - FDK AAC LL
Am Wolfsmantel 33
91058 Erlangen, Germany
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): Matthias Hildenbrand
Description:
*******************************************************************************/
#ifndef FDK_DELAY_H
#define FDK_DELAY_H
#include "aac_rom.h"
/**
* Structure representing one delay element for multiple channels.
*/
typedef struct {
INT_PCM* delay_line; /*!< Pointer which stores allocated delay line. */
USHORT delay; /*!< Delay required in samples (per channel). */
UCHAR num_channels; /*!< Number of channels to delay. */
} FDK_SignalDelay;
/**
* \brief Create delay element for multiple channels with fixed delay value.
*
* \param data Pointer delay element structure.
* \param delay Required delay value in samples per channel.
* \param num_channels Required number of channels.
*
* \return -1 on out of memory, else 0
*/
INT FDK_Delay_Create(FDK_SignalDelay* data, const USHORT delay,
const UCHAR num_channels);
/**
* \brief Apply delay to one channel (non-interleaved storage assumed).
*
* \param data Pointer delay element structure.
* \param time_buffer Pointer to signal to delay.
* \param frame_length Frame length of input/output signal (needs to be >=
* delay).
* \param channel Index of current channel (0 <= channel < num_channels).
*
* \return void
*/
void FDK_Delay_Apply(FDK_SignalDelay* data, FIXP_PCM* time_buffer,
const UINT frame_length, const UCHAR channel);
/**
* \brief Destroy delay element.
*
* \param data Pointer delay element structure.
*
* \return void
*/
void FDK_Delay_Destroy(FDK_SignalDelay* data);
#endif /* #ifndef FDK_DELAY_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,13 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
/**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl
Author(s): Josef Hoepfl
******************************************************************************/
Description:
*******************************************************************************/
#include "aac_ram.h"
#include "aac_rom.h"
@ -93,10 +106,17 @@ amm-info@iis.fraunhofer.de
#define WORKBUFFER1_TAG 0
#define WORKBUFFER2_TAG 1
/*! The structure AAC_DECODER_INSTANCE is the top level structure holding all decoder configurations,
handles and structs.
#define WORKBUFFER3_TAG 4
#define WORKBUFFER4_TAG 5
#define WORKBUFFER5_TAG 6
#define WORKBUFFER6_TAG 7
/*! The structure AAC_DECODER_INSTANCE is the top level structure holding all
decoder configurations, handles and structs.
*/
C_ALLOC_MEM(AacDecoder, AAC_DECODER_INSTANCE, 1)
C_ALLOC_MEM(AacDecoder, struct AAC_DECODER_INSTANCE, 1)
/*!
\name StaticAacData
@ -105,21 +125,36 @@ C_ALLOC_MEM(AacDecoder, AAC_DECODER_INSTANCE, 1)
*/
/* @{ */
/*! The structure CAacDecoderStaticChannelInfo contains the static sideinfo which is needed
for the decoding of one aac channel. <br>
Dimension: #AacDecoderChannels */
/*! The structure CAacDecoderStaticChannelInfo contains the static sideinfo
which is needed for the decoding of one aac channel. <br> Dimension:
#AacDecoderChannels */
C_ALLOC_MEM2(AacDecoderStaticChannelInfo, CAacDecoderStaticChannelInfo, 1, (8))
/*! The structure CAacDecoderChannelInfo contains the dynamic sideinfo which is needed
for the decoding of one aac channel. <br>
Dimension: #AacDecoderChannels */
/*! The structure CAacDecoderChannelInfo contains the dynamic sideinfo which is
needed for the decoding of one aac channel. <br> Dimension:
#AacDecoderChannels */
C_AALLOC_MEM2(AacDecoderChannelInfo, CAacDecoderChannelInfo, 1, (8))
/*! Overlap buffer */
C_ALLOC_MEM2(OverlapBuffer, FIXP_DBL, OverlapBufferSize, (8))
C_AALLOC_MEM2(OverlapBuffer, FIXP_DBL, OverlapBufferSize, (8))
C_ALLOC_MEM(DrcInfo, CDrcInfo, 1)
/*! The structure CpePersistentData holds the persistent data shared by both
channels of a CPE. <br> It needs to be allocated for each CPE. <br>
Dimension: 1 */
C_ALLOC_MEM(CpePersistentData, CpePersistentData, 1)
/*! The structure CCplxPredictionData holds data for complex stereo prediction.
<br> Dimension: 1
*/
C_ALLOC_MEM(CplxPredictionData, CCplxPredictionData, 1)
/*! The buffer holds time samples for the crossfade in case of an USAC DASH IPF
config change Dimension: (8)
*/
C_ALLOC_MEM2(TimeDataFlush, INT_PCM, TIME_DATA_FLUSH_SIZE, (8))
/* @} */
/*!
@ -128,15 +163,23 @@ C_ALLOC_MEM(DrcInfo, CDrcInfo, 1)
Dynamic memory areas, might be reused in other algorithm sections,
e.g. the sbr decoder
*/
C_ALLOC_MEM_OVERLAY(WorkBufferCore2, FIXP_DBL, ((8)*1024), SECT_DATA_L2, WORKBUFFER2_TAG)
/* Take into consideration to make use of the WorkBufferCore[3/4] for decoder
* configurations with more than 2 channels */
C_ALLOC_MEM_OVERLAY(WorkBufferCore2, FIXP_DBL, ((8) * 1024), SECT_DATA_L2,
WORKBUFFER2_TAG)
C_ALLOC_MEM_OVERLAY(WorkBufferCore1, CWorkBufferCore1, 1, SECT_DATA_L1, WORKBUFFER1_TAG)
/* @{ */
/* @} */
C_ALLOC_MEM_OVERLAY(WorkBufferCore3, FIXP_DBL, WB_SECTION_SIZE, SECT_DATA_L2,
WORKBUFFER3_TAG)
C_AALLOC_MEM(WorkBufferCore4, FIXP_DBL, WB_SECTION_SIZE)
C_ALLOC_MEM_OVERLAY(WorkBufferCore6, SCHAR,
fMax((INT)(sizeof(FIXP_DBL) * WB_SECTION_SIZE),
(INT)sizeof(CAacDecoderCommonData)),
SECT_DATA_L2, WORKBUFFER6_TAG)
C_ALLOC_MEM_OVERLAY(WorkBufferCore1, CWorkBufferCore1, 1, SECT_DATA_L1,
WORKBUFFER1_TAG)
/* double buffer size needed for de-/interleaving */
C_ALLOC_MEM_OVERLAY(WorkBufferCore5, PCM_DEC, (8) * (1024 * 4) * 2,
SECT_DATA_EXTERN, WORKBUFFER5_TAG)

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,14 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
/**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl
Description:
******************************************************************************/
*******************************************************************************/
#ifndef AAC_RAM_H
#define AAC_RAM_H
@ -97,13 +109,15 @@ amm-info@iis.fraunhofer.de
#include "channel.h"
#include "ac_arith_coder.h"
#include "aacdec_hcr_types.h"
#include "aacdec_hcr.h"
/* End of formal fix.h */
#define MAX_SYNCHS 10
#define SAMPL_FREQS 12
#define MAX_SYNCHS 10
#define SAMPL_FREQS 12
H_ALLOC_MEM(AacDecoder, AAC_DECODER_INSTANCE)
@ -113,8 +127,21 @@ H_ALLOC_MEM(AacDecoderStaticChannelInfo, CAacDecoderStaticChannelInfo)
H_ALLOC_MEM(AacDecoderChannelInfo, CAacDecoderChannelInfo)
H_ALLOC_MEM(OverlapBuffer, FIXP_DBL)
H_ALLOC_MEM(CpePersistentData, CpePersistentData)
H_ALLOC_MEM(CplxPredictionData, CCplxPredictionData)
H_ALLOC_MEM(SpectralCoeffs, FIXP_DBL)
H_ALLOC_MEM(SpecScale, SHORT)
H_ALLOC_MEM(TimeDataFlush, INT_PCM)
H_ALLOC_MEM_OVERLAY(WorkBufferCore1, CWorkBufferCore1)
H_ALLOC_MEM_OVERLAY(WorkBufferCore2, FIXP_DBL)
H_ALLOC_MEM_OVERLAY(WorkBufferCore3, FIXP_DBL)
H_ALLOC_MEM(WorkBufferCore4, FIXP_DBL)
H_ALLOC_MEM_OVERLAY(WorkBufferCore5, PCM_DEC)
H_ALLOC_MEM_OVERLAY(WorkBufferCore6, SCHAR)
#endif /* #ifndef AAC_RAM_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,14 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
/**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl
Description: Definition of constant tables
******************************************************************************/
*******************************************************************************/
#ifndef AAC_ROM_H
#define AAC_ROM_H
@ -96,13 +108,26 @@ amm-info@iis.fraunhofer.de
#include "aacdec_hcr_types.h"
#include "aacdec_hcrs.h"
#define AAC_NF_NO_RANDOM_VAL 512 /*!< Size of random number array for noise floor */
#define PCM_DEC FIXP_DBL
#define MAXVAL_PCM_DEC MAXVAL_DBL
#define MINVAL_PCM_DEC MINVAL_DBL
#define FIXP_DBL2PCM_DEC(x) (x)
#define PCM_DEC2FIXP_DBL(x) (x)
#define PCM_DEC_BITS DFRACT_BITS
#define PCM_DEC2FX_PCM(x) FX_DBL2FX_PCM(x)
#define FX_PCM2PCM_DEC(x) FX_PCM2FX_DBL(x)
#define AACDEC_MAX_CH_CONF 14
#define AACDEC_CH_ELEMENTS_TAB_SIZE 7 /*!< Size of element tables */
#define AAC_NF_NO_RANDOM_VAL \
512 /*!< Size of random number array for noise floor */
#define INV_QUANT_TABLESIZE 256
extern const FIXP_DBL InverseQuantTable [INV_QUANT_TABLESIZE + 1] ;
extern const FIXP_DBL MantissaTable [4][14] ;
extern const SCHAR ExponentTable [4][14] ;
extern const FIXP_DBL InverseQuantTable[INV_QUANT_TABLESIZE + 1];
extern const FIXP_DBL MantissaTable[4][14];
extern const SCHAR ExponentTable[4][14];
#define NUM_LD_COEF_512 1536
#define NUM_LD_COEF_480 1440
@ -112,6 +137,11 @@ extern const SCHAR ExponentTable [4][14] ;
#define WTS2 (-2)
extern const FIXP_WTB LowDelaySynthesis512[1536];
extern const FIXP_WTB LowDelaySynthesis480[1440];
extern const FIXP_WTB LowDelaySynthesis256[768];
extern const FIXP_WTB LowDelaySynthesis240[720];
extern const FIXP_WTB LowDelaySynthesis160[480];
extern const FIXP_WTB LowDelaySynthesis128[384];
extern const FIXP_WTB LowDelaySynthesis120[360];
typedef struct {
const SHORT *sfbOffsetLong;
@ -123,13 +153,9 @@ typedef struct {
extern const SFB_INFO sfbOffsetTables[5][16];
/* Huffman tables */
enum {
HuffmanBits = 2,
HuffmanEntries = (1 << HuffmanBits)
};
enum { HuffmanBits = 2, HuffmanEntries = (1 << HuffmanBits) };
typedef struct
{
typedef struct {
const USHORT (*CodeBook)[HuffmanEntries];
UCHAR Dimension;
UCHAR numBits;
@ -139,28 +165,26 @@ typedef struct
extern const CodeBookDescription AACcodeBookDescriptionTable[13];
extern const CodeBookDescription AACcodeBookDescriptionSCL;
extern const STATEFUNC aStateConstant2State[];
extern const STATEFUNC aStateConstant2State[];
extern const SCHAR aCodebook2StartInt[];
extern const SCHAR aCodebook2StartInt[];
extern const UCHAR aMinOfCbPair[];
extern const UCHAR aMaxOfCbPair[];
extern const UCHAR aMinOfCbPair[];
extern const UCHAR aMaxOfCbPair[];
extern const UCHAR aMaxCwLen[];
extern const UCHAR aDimCb[];
extern const UCHAR aDimCbShift[];
extern const UCHAR aSignCb[];
extern const UCHAR aCbPriority[];
extern const UCHAR aMaxCwLen[];
extern const UCHAR aDimCb[];
extern const UCHAR aDimCbShift[];
extern const UCHAR aSignCb[];
extern const UCHAR aCbPriority[];
extern const UINT *aHuffTable[];
extern const SCHAR *aQuantTable[];
extern const UINT *aHuffTable[];
extern const SCHAR *aQuantTable[];
extern const USHORT aLargestAbsoluteValue[];
extern const UINT aHuffTreeRvlcEscape[];
extern const UINT aHuffTreeRvlCodewds[];
extern const USHORT aLargestAbsoluteValue[];
extern const UINT aHuffTreeRvlcEscape[];
extern const UINT aHuffTreeRvlCodewds[];
extern const UCHAR tns_max_bands_tbl[13][2];
@ -172,7 +196,10 @@ extern const UCHAR tns_max_bands_tbl_512[13];
extern const FIXP_TCC FDKaacDec_tnsCoeff3[8];
extern const FIXP_TCC FDKaacDec_tnsCoeff4[16];
extern const USHORT randomSign[AAC_NF_NO_RANDOM_VAL/16];
extern const UCHAR FDKaacDec_tnsCoeff3_gain_ld[];
extern const UCHAR FDKaacDec_tnsCoeff4_gain_ld[];
extern const USHORT AacDec_randomSign[AAC_NF_NO_RANDOM_VAL / 16];
extern const FIXP_DBL pow2_div24minus1[47];
extern const int offsetTab[2][16];
@ -183,6 +210,28 @@ extern const UCHAR channelMappingTablePassthrough[15][8];
extern const UCHAR channelMappingTableWAV[15][8];
/* Lookup tables for elements in ER bitstream */
extern const MP4_ELEMENT_ID elementsTab[15][7];
extern const MP4_ELEMENT_ID elementsTab[AACDEC_MAX_CH_CONF]
[AACDEC_CH_ELEMENTS_TAB_SIZE];
#define SF_FNA_COEFFS \
1 /* Compile-time prescaler for MDST-filter coefficients. */
/* SF_FNA_COEFFS > 0 should only be considered for FIXP_DBL-coefficients */
/* (i.e. if CPLX_PRED_FILTER_16BIT is not defined). */
/* With FIXP_DBL loss of precision is possible for SF_FNA_COEFFS > 11. */
#ifdef CPLX_PRED_FILTER_16BIT
#define FIXP_FILT FIXP_SGL
#define FILT(a) ((FL2FXCONST_SGL(a)) >> SF_FNA_COEFFS)
#else
#define FIXP_FILT FIXP_DBL
#define FILT(a) ((FL2FXCONST_DBL(a)) >> SF_FNA_COEFFS)
#endif
extern const FIXP_FILT mdst_filt_coef_curr[20][3]; /* MDST-filter coefficient
tables used for current
window */
extern const FIXP_FILT mdst_filt_coef_prev[6][4]; /* MDST-filter coefficient
tables used for previous
window */
#endif /* #ifndef AAC_ROM_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,111 +90,103 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
/**************************** AAC decoder library ******************************
Author(s): Christian Griebel
Description: Dynamic range control (DRC) decoder tool for AAC
******************************************************************************/
*******************************************************************************/
#ifndef AACDEC_DRC_H
#define AACDEC_DRC_H
#include "tp_data.h" /* for program config element support */
#include "tp_data.h" /* for program config element support */
#include "aacdec_drc_types.h"
#include "channel.h"
#include "FDK_bitstream.h"
#define AACDEC_DRC_DFLT_EXPIRY_FRAMES ( 50 ) /* Default DRC data expiry time in AAC frames */
#define AACDEC_DRC_DFLT_EXPIRY_FRAMES \
(0) /* Default DRC data expiry time in AAC frames */
/* #define AACDEC_DRC_IGNORE_FRAMES_WITH_MULTIPLE_CH_THREADS */ /* The name says
it all. */
/* #define AACDEC_DRC_DEBUG */
/**
* \brief DRC module setting parameters
*/
typedef enum
{
typedef enum {
DRC_CUT_SCALE = 0,
DRC_BOOST_SCALE,
TARGET_REF_LEVEL,
DRC_BS_DELAY,
DRC_DATA_EXPIRY_FRAME,
APPLY_NORMALIZATION,
APPLY_HEAVY_COMPRESSION
APPLY_HEAVY_COMPRESSION,
DEFAULT_PRESENTATION_MODE,
ENCODER_TARGET_LEVEL,
MAX_OUTPUT_CHANNELS,
UNIDRC_PRECEDENCE
} AACDEC_DRC_PARAM;
/**
* \brief DRC module interface functions
*/
void aacDecoder_drcInit (
HANDLE_AAC_DRC self );
void aacDecoder_drcInit(HANDLE_AAC_DRC self);
void aacDecoder_drcInitChannelData (
CDrcChannelData *pDrcChannel );
void aacDecoder_drcInitChannelData(CDrcChannelData *pDrcChannel);
AAC_DECODER_ERROR aacDecoder_drcSetParam (
HANDLE_AAC_DRC self,
AACDEC_DRC_PARAM param,
INT value );
AAC_DECODER_ERROR aacDecoder_drcSetParam(HANDLE_AAC_DRC self,
AACDEC_DRC_PARAM param, INT value);
int aacDecoder_drcMarkPayload (
HANDLE_AAC_DRC self,
HANDLE_FDK_BITSTREAM hBs,
AACDEC_DRC_PAYLOAD_TYPE type );
int aacDecoder_drcMarkPayload(HANDLE_AAC_DRC self, HANDLE_FDK_BITSTREAM hBs,
AACDEC_DRC_PAYLOAD_TYPE type);
int aacDecoder_drcProlog (
HANDLE_AAC_DRC self,
HANDLE_FDK_BITSTREAM hBs,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[],
UCHAR pceInstanceTag,
UCHAR channelMapping[],
int numChannels );
int aacDecoder_drcProlog(
HANDLE_AAC_DRC self, HANDLE_FDK_BITSTREAM hBs,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[],
UCHAR pceInstanceTag, UCHAR channelMapping[], int validChannels);
/**
* \brief Apply DRC. If SBR is present, DRC data is handed over to the SBR decoder.
* \brief Apply DRC. If SBR is present, DRC data is handed over to the SBR
* decoder.
* \param self AAC decoder instance
* \param pSbrDec pointer to SBR decoder instance
* \param pAacDecoderChannelInfo AAC decoder channel instance to be processed
* \param pDrcDat DRC channel data
* \param extGain Pointer to a FIXP_DBL where a externally applyable gain will be stored into (independently on whether it will be apply internally or not).
* At function call the buffer must hold the scale (0 >= scale < DFRACT_BITS) to be applied on the gain value.
* \param extGain Pointer to a FIXP_DBL where a externally applyable gain will
* be stored into (independently on whether it will be apply internally or not).
* At function call the buffer must hold the scale (0 >= scale <
* DFRACT_BITS) to be applied on the gain value.
* \param ch channel index
* \param aacFrameSize AAC frame size
* \param bSbrPresent flag indicating that SBR is present, in which case DRC is handed over to the SBR instance pSbrDec
* \param bSbrPresent flag indicating that SBR is present, in which case DRC is
* handed over to the SBR instance pSbrDec
*/
void aacDecoder_drcApply (
HANDLE_AAC_DRC self,
void *pSbrDec,
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CDrcChannelData *pDrcDat,
FIXP_DBL *extGain,
int ch,
int aacFrameSize,
int bSbrPresent );
void aacDecoder_drcApply(HANDLE_AAC_DRC self, void *pSbrDec,
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CDrcChannelData *pDrcDat, FIXP_DBL *extGain, int ch,
int aacFrameSize, int bSbrPresent);
int aacDecoder_drcEpilog (
HANDLE_AAC_DRC self,
HANDLE_FDK_BITSTREAM hBs,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[],
UCHAR pceInstanceTag,
UCHAR channelMapping[],
int validChannels );
int aacDecoder_drcEpilog(
HANDLE_AAC_DRC self, HANDLE_FDK_BITSTREAM hBs,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[],
UCHAR pceInstanceTag, UCHAR channelMapping[], int validChannels);
/**
* \brief Get metadata information found in bitstream.
* \param self DRC module instance handle.
* \param pPresMode Pointer to field where the presentation mode will be written to.
* \param pProgRefLevel Pointer to field where the program reference level will be written to.
* \param pPresMode Pointer to field where the presentation mode will be written
* to.
* \param pProgRefLevel Pointer to field where the program reference level will
* be written to.
* \return Nothing.
*/
void aacDecoder_drcGetInfo (
HANDLE_AAC_DRC self,
SCHAR *pPresMode,
SCHAR *pProgRefLevel );
void aacDecoder_drcGetInfo(HANDLE_AAC_DRC self, SCHAR *pPresMode,
SCHAR *pProgRefLevel);
#endif /* AACDEC_DRC_H */
#endif /* AACDEC_DRC_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,96 +90,131 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
/**************************** AAC decoder library ******************************
Author(s): Christian Griebel
Description: Dynamic range control (DRC) global data types
******************************************************************************/
*******************************************************************************/
#ifndef AACDEC_DRC_TYPES_H
#define AACDEC_DRC_TYPES_H
#include "common_fix.h"
#define MAX_DRC_THREADS ( 3 ) /* Heavy compression value is handled just like MPEG DRC data */
#define MAX_DRC_BANDS ( 16 ) /* 2^LEN_DRC_BAND_INCR (LEN_DRC_BAND_INCR = 4) */
#define MAX_DRC_THREADS \
((8) + 1) /* Heavy compression value is handled just like MPEG DRC data */
#define MAX_DRC_BANDS (16) /* 2^LEN_DRC_BAND_INCR (LEN_DRC_BAND_INCR = 4) */
/**
* \brief DRC module global data types
*/
typedef enum
{
UNKNOWN_PAYLOAD = 0,
MPEG_DRC_EXT_DATA = 1,
DVB_DRC_ANC_DATA = 2
typedef enum {
UNKNOWN_PAYLOAD = 0,
MPEG_DRC_EXT_DATA = 1,
DVB_DRC_ANC_DATA = 2
} AACDEC_DRC_PAYLOAD_TYPE;
typedef struct
{
UINT expiryCount;
UINT numBands;
USHORT bandTop[MAX_DRC_BANDS];
SHORT drcInterpolationScheme;
UCHAR drcValue[MAX_DRC_BANDS];
SCHAR drcDataType;
/**
* \brief Options for parameter handling / presentation mode
*/
typedef enum {
DISABLED_PARAMETER_HANDLING = -1, /*!< DRC parameter handling disabled, all
parameters are applied as requested. */
ENABLED_PARAMETER_HANDLING =
0, /*!< Apply changes to requested DRC parameters to prevent clipping */
DRC_PRESENTATION_MODE_1 = 1, /*!< DRC Presentation mode 1*/
DRC_PRESENTATION_MODE_2 = 2 /*!< DRC Presentation mode 2*/
} AACDEC_DRC_PARAMETER_HANDLING;
typedef struct {
UINT expiryCount;
UINT numBands;
USHORT bandTop[MAX_DRC_BANDS];
SHORT drcInterpolationScheme;
UCHAR drcValue[MAX_DRC_BANDS];
SCHAR drcDataType;
} CDrcChannelData;
typedef struct
{
UINT excludedChnsMask;
SCHAR progRefLevel;
SCHAR presMode; /* Presentation mode: 0 (not indicated), 1, 2, and 3 (reserved). */
SCHAR pceInstanceTag;
typedef struct {
UINT excludedChnsMask;
SCHAR progRefLevel;
SCHAR presMode; /* Presentation mode: 0 (not indicated), 1, 2, and 3
(reserved). */
SCHAR pceInstanceTag;
CDrcChannelData channelData;
} CDrcPayload;
typedef struct
{
FIXP_DBL cut; /* The attenuation scale factor currently used. */
FIXP_DBL usrCut; /* The latest attenuation scale factor set by user. */
FIXP_DBL boost; /* The boost scale factor currently used. */
FIXP_DBL usrBoost; /* The latest boost scale factor set by user. */
typedef struct {
/* DRC parameters: Latest user requests */
FIXP_DBL usrCut;
FIXP_DBL usrBoost;
UCHAR usrApplyHeavyCompression;
UINT expiryFrame;
SCHAR targetRefLevel;
UCHAR bsDelayEnable;
UCHAR applyDigitalNorm;
UCHAR applyHeavyCompression;
/* DRC parameters: Currently used, possibly changed by
* aacDecoder_drcParameterHandling */
FIXP_DBL cut; /* attenuation scale factor */
FIXP_DBL boost; /* boost scale factor */
SCHAR targetRefLevel; /* target reference level for loudness normalization */
UCHAR applyHeavyCompression; /* heavy compression (DVB) flag */
UINT expiryFrame;
UCHAR bsDelayEnable;
UCHAR applyDigitalNorm;
AACDEC_DRC_PARAMETER_HANDLING defaultPresentationMode;
UCHAR encoderTargetLevel;
} CDrcParams;
typedef struct {
CDrcParams
params; /* Module parameters that can be set by user (via SetParam API
function) */
typedef struct
{
CDrcParams params; /* Module parameters that can be set by user (via SetParam API function) */
UCHAR enable; /* Switch that controls dynamic range processing */
UCHAR digitalNorm; /* Switch to en-/disable reference level normalization in
digital domain */
UCHAR enable; /* Switch that controls dynamic range processing */
UCHAR digitalNorm; /* Switch to en-/disable reference level normalization in digital domain */
UCHAR update; /* Flag indicating the change of a user or bitstream parameter
which affects aacDecoder_drcParameterHandling */
INT numOutChannels; /* Number of output channels */
INT prevAacNumChannels; /* Previous number of channels of aac bitstream, used
for update flag */
USHORT numPayloads; /* The number of DRC data payload elements found within frame */
USHORT numThreads; /* The number of DRC data threads extracted from the found payload elements */
SCHAR progRefLevel; /* Program reference level for all channels */
UCHAR progRefLevelPresent; /* Program reference level found in bitstream */
USHORT numPayloads; /* The number of DRC data payload elements found within
frame */
USHORT
numThreads; /* The number of DRC data threads extracted from the found
payload elements */
SCHAR progRefLevel; /* Program reference level for all channels */
UCHAR progRefLevelPresent; /* Program reference level found in bitstream */
UINT prlExpiryCount; /* Counter that can be used to monitor the life time of the program reference level. */
UINT prlExpiryCount; /* Counter that can be used to monitor the life time of
the program reference level. */
SCHAR presMode; /* Presentation mode as defined in ETSI TS 101 154 */
UCHAR dvbAncDataAvailable; /* Flag that indicates whether DVB ancillary data is present or not */
UINT dvbAncDataPosition; /* Used to store the DVB ancillary data payload position in the bitstream (only one per frame) */
UINT drcPayloadPosition[MAX_DRC_THREADS]; /* Used to store the DRC payload positions in the bitstream */
SCHAR presMode; /* Presentation mode as defined in ETSI TS 101 154 */
UCHAR dvbAncDataAvailable; /* Flag that indicates whether DVB ancillary data
is present or not */
UINT dvbAncDataPosition; /* Used to store the DVB ancillary data payload
position in the bitstream (only one per frame) */
UINT drcPayloadPosition[MAX_DRC_THREADS]; /* Used to store the DRC payload
positions in the bitstream */
UCHAR
uniDrcPrecedence; /* Flag for signalling that uniDrc is active and takes
precedence over legacy DRC */
} CDrcInfo;
typedef CDrcInfo *HANDLE_AAC_DRC;
#endif /* AACDEC_DRC_TYPES_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,48 +90,39 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ***************************
/**************************** AAC decoder library ******************************
Author(s): Robert Weidner (DSP Solutions)
Description: HCR Decoder: Interface function declaration; common defines
and structures; defines for switching error-generator,
-detector, and -concealment
*******************************************************************************/
#ifndef _AACDEC_HCR_H_
#define _AACDEC_HCR_H_
#ifndef AACDEC_HCR_H
#define AACDEC_HCR_H
#include "channelinfo.h"
#include "FDK_bitstream.h"
void HcrInitRom (H_HCR_INFO hHcr);
UINT HcrInit(H_HCR_INFO pHcr,
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
UINT HcrInit(H_HCR_INFO pHcr, CAacDecoderChannelInfo *pAacDecoderChannelInfo,
const SamplingRateInfo *pSamplingRateInfo,
HANDLE_FDK_BITSTREAM bs);
UINT HcrDecoder (H_HCR_INFO hHcr,
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
const SamplingRateInfo *pSamplingRateInfo,
HANDLE_FDK_BITSTREAM bs);
void CarryBitToBranchValue(
UCHAR carryBit,
UINT treeNode,
UINT *branchValue,
UINT *branchNode
);
HANDLE_FDK_BITSTREAM bs);
UINT HcrDecoder(H_HCR_INFO hHcr, CAacDecoderChannelInfo *pAacDecoderChannelInfo,
const SamplingRateInfo *pSamplingRateInfo,
HANDLE_FDK_BITSTREAM bs);
void CarryBitToBranchValue(UCHAR carryBit, UINT treeNode, UINT *branchValue,
UINT *branchNode);
void CHcr_Read (HANDLE_FDK_BITSTREAM bs,
CAacDecoderChannelInfo *pAacDecoderChannelInfo);
void HcrMuteErroneousLines(H_HCR_INFO hHcr);
void CHcr_Read(HANDLE_FDK_BITSTREAM bs,
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
const MP4_ELEMENT_ID globalHcrType);
void HcrMuteErroneousLines(H_HCR_INFO hHcr);
void setHcrType(H_HCR_INFO hHcr, MP4_ELEMENT_ID type);
INT getHcrType(H_HCR_INFO hHcr);
void setHcrType(H_HCR_INFO hHcr, MP4_ELEMENT_ID type);
INT getHcrType(H_HCR_INFO hHcr);
#endif /* _AACDEC_HCR_H_ */
#endif /* AACDEC_HCR_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,39 +90,38 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ***************************
/**************************** AAC decoder library ******************************
Author(s): Robert Weidner (DSP Solutions)
Description: HCR Decoder: Bitstream reading
*******************************************************************************/
#include "aacdec_hcr_bit.h"
/*---------------------------------------------------------------------------------------------
description: This function toggles the read direction.
-----------------------------------------------------------------------------------------------
input: current read direction
-----------------------------------------------------------------------------------------------
return: new read direction
-------------------------------------------------------------------------------------------- */
UCHAR ToggleReadDirection(UCHAR readDirection)
{
if ( readDirection == FROM_LEFT_TO_RIGHT ) {
--------------------------------------------------------------------------------------------
*/
UCHAR ToggleReadDirection(UCHAR readDirection) {
if (readDirection == FROM_LEFT_TO_RIGHT) {
return FROM_RIGHT_TO_LEFT;
}
else {
} else {
return FROM_LEFT_TO_RIGHT;
}
}
/*---------------------------------------------------------------------------------------------
description: This function returns a bit from the bitstream according to read direction.
It is called very often, therefore it makes sense to inline it (runtime).
description: This function returns a bit from the bitstream according to
read direction. It is called very often, therefore it makes sense to inline it
(runtime).
-----------------------------------------------------------------------------------------------
input: - handle to FDK bitstream
- reference value marking start of bitfield
@ -120,28 +130,25 @@ UCHAR ToggleReadDirection(UCHAR readDirection)
- readDirection
-----------------------------------------------------------------------------------------------
return: - bit from bitstream
-------------------------------------------------------------------------------------------- */
UINT HcrGetABitFromBitstream(HANDLE_FDK_BITSTREAM bs,
USHORT *pLeftStartOfSegment,
USHORT *pRightStartOfSegment,
UCHAR readDirection)
{
UINT bit;
INT readBitOffset;
--------------------------------------------------------------------------------------------
*/
UINT HcrGetABitFromBitstream(HANDLE_FDK_BITSTREAM bs, INT *pLeftStartOfSegment,
INT *pRightStartOfSegment, UCHAR readDirection) {
UINT bit;
INT readBitOffset;
if (readDirection == FROM_LEFT_TO_RIGHT) {
readBitOffset = *pLeftStartOfSegment-FDKgetBitCnt(bs);
if( readBitOffset ) {
readBitOffset = *pLeftStartOfSegment - FDKgetBitCnt(bs);
if (readBitOffset) {
FDKpushBiDirectional(bs, readBitOffset);
}
bit = FDKreadBits(bs, 1);
*pLeftStartOfSegment += 1;
}
else {
readBitOffset = *pRightStartOfSegment-FDKgetBitCnt(bs);
if( readBitOffset ) {
} else {
readBitOffset = *pRightStartOfSegment - FDKgetBitCnt(bs);
if (readBitOffset) {
FDKpushBiDirectional(bs, readBitOffset);
}
@ -152,14 +159,5 @@ UINT HcrGetABitFromBitstream(HANDLE_FDK_BITSTREAM bs,
*pRightStartOfSegment -= 1;
}
#if ERROR_GENERATOR_BIT_STREAM_HCR
static int a;
if ((++a % MODULO_DIVISOR_HCR) == 0) {
bit = (bit == 0) ? 1 : 0;
}
#endif
return (bit);
}

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,28 +90,24 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ***************************
/**************************** AAC decoder library ******************************
Author(s): Robert Weidner (DSP Solutions)
Description: HCR Decoder: Bitstream reading prototypes
*******************************************************************************/
#ifndef _AACDEC_HCR_BIT_H_
#define _AACDEC_HCR_BIT_H_
#ifndef AACDEC_HCR_BIT_H
#define AACDEC_HCR_BIT_H
#include "aacdec_hcr.h"
UCHAR ToggleReadDirection(UCHAR readDirection);
UINT HcrGetABitFromBitstream(HANDLE_FDK_BITSTREAM bs,
USHORT *pLeftStartOfSegment,
USHORT *pRightStartOfSegment,
UCHAR readDirection);
UINT HcrGetABitFromBitstream(HANDLE_FDK_BITSTREAM bs, INT *pLeftStartOfSegment,
INT *pRightStartOfSegment, UCHAR readDirection);
#endif /* _AACDEC_HCR_BIT_H_ */
#endif /* AACDEC_HCR_BIT_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,20 +90,19 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ***************************
/**************************** AAC decoder library ******************************
Author(s): Robert Weidner (DSP Solutions)
Description: HCR Decoder: Common defines and structures; defines for
switching error-generator, -detector, and -concealment;
*******************************************************************************/
#ifndef _AACDEC_HCR_TYPES_H_
#define _AACDEC_HCR_TYPES_H_
#ifndef AACDEC_HCR_TYPES_H
#define AACDEC_HCR_TYPES_H
#include "FDK_bitstream.h"
#include "overlapadd.h"
@ -100,186 +110,249 @@ amm-info@iis.fraunhofer.de
/* ------------------------------------------------ */
/* ------------------------------------------------ */
#define LINES_PER_UNIT 4
#define LINES_PER_UNIT 4
/* ------------------------------------------------ */
/* ------------------------------------------------ */
/* ----------- basic HCR configuration ------------ */
#define MAX_SFB_HCR (((1024/8) / LINES_PER_UNIT) * 8) /* (8 * 16) is not enough because sfbs are split in units for blocktype short */
#define NUMBER_OF_UNIT_GROUPS (LINES_PER_UNIT * 8)
#define LINES_PER_UNIT_GROUP (1024 / NUMBER_OF_UNIT_GROUPS) /* 15 16 30 32 */
#define MAX_SFB_HCR \
(((1024 / 8) / LINES_PER_UNIT) * 8) /* (8 * 16) is not enough because sfbs \
are split in units for blocktype \
short */
#define NUMBER_OF_UNIT_GROUPS (LINES_PER_UNIT * 8)
#define LINES_PER_UNIT_GROUP (1024 / NUMBER_OF_UNIT_GROUPS) /* 15 16 30 32 */
/* ------------------------------------------------ */
/* ------------------------------------------------ */
/* ------------------------------------------------ */
#define FROM_LEFT_TO_RIGHT 0
#define FROM_RIGHT_TO_LEFT 1
#define FROM_LEFT_TO_RIGHT 0
#define FROM_RIGHT_TO_LEFT 1
#define MAX_CB_PAIRS 23
#define MAX_HCR_SETS 14
#define MAX_CB_PAIRS 23
#define MAX_HCR_SETS 14
#define ESCAPE_VALUE 16
#define POSITION_OF_FLAG_A 21
#define POSITION_OF_FLAG_B 20
#define ESCAPE_VALUE 16
#define POSITION_OF_FLAG_A 21
#define POSITION_OF_FLAG_B 20
#define MAX_CB 32 /* last used CB is cb #31 when VCB11 is used */
#define MAX_CB 32 /* last used CB is cb #31 when VCB11 is used */
#define MAX_CB_CHECK 32 /* support for VCB11 available -- is more general, could therefore used in both cases */
#define MAX_CB_CHECK \
32 /* support for VCB11 available -- is more general, could therefore used \
in both cases */
#define NUMBER_OF_BIT_IN_WORD 32
#define NUMBER_OF_BIT_IN_WORD 32
/* log */
#define THIRTYTWO_LOG_DIV_TWO_LOG 5
#define EIGHT_LOG_DIV_TWO_LOG 3
#define FOUR_LOG_DIV_TWO_LOG 2
#define THIRTYTWO_LOG_DIV_TWO_LOG 5
#define EIGHT_LOG_DIV_TWO_LOG 3
#define FOUR_LOG_DIV_TWO_LOG 2
/* borders */
#define CPE_TOP_LENGTH 12288
#define SCE_TOP_LENGTH 6144
#define LEN_OF_LONGEST_CW_TOP_LENGTH 49
#define CPE_TOP_LENGTH 12288
#define SCE_TOP_LENGTH 6144
#define LEN_OF_LONGEST_CW_TOP_LENGTH 49
/* qsc's of high level */
#define Q_VALUE_INVALID 8192 /* mark a invalid line with this value (to be concealed later on) */
#define HCR_DIRAC 500 /* a line of high level */
#define Q_VALUE_INVALID \
8192 /* mark a invalid line with this value (to be concealed later on) */
#define HCR_DIRAC 500 /* a line of high level */
/* masks */
#define MASK_LEFT 0xFFF000
#define MASK_RIGHT 0xFFF
#define CLR_BIT_10 0x3FF
#define TEST_BIT_10 0x400
#define MASK_LEFT 0xFFF000
#define MASK_RIGHT 0xFFF
#define CLR_BIT_10 0x3FF
#define TEST_BIT_10 0x400
#define LEFT_OFFSET 12
/* when set HCR is replaced by a dummy-module which just fills the outputbuffer with a dirac sequence */
/* use this if HCR is suspected to write in other modules -- if error is stell there, HCR is innocent */
#define USE_HCR_DUMMY 0
#define LEFT_OFFSET 12
/* when set HCR is replaced by a dummy-module which just fills the outputbuffer
* with a dirac sequence */
/* use this if HCR is suspected to write in other modules -- if error is stell
* there, HCR is innocent */
/* ------------------------------ */
/* - insert HCR errors - */
/* ------------------------------ */
/* modify input lengths -- high protected */
#define ERROR_LORSD 0 /* offset: error if different from zero */
#define ERROR_LOLC 0 /* offset: error if different from zero */
/* modify input lengths -- high protected */
#define ERROR_LORSD 0 /* offset: error if different from zero */
#define ERROR_LOLC 0 /* offset: error if different from zero */
/* segments are earlier empty as expected when decoding PCWs */
#define ERROR_PCW_BODY 0 /* set a positive values to trigger the error (make segments earlyer appear to be empty) */
#define ERROR_PCW_BODY_SIGN 0 /* set a positive values to trigger the error (make segments earlyer appear to be empty) */
#define ERROR_PCW_BODY_SIGN_ESC 0 /* set a positive values to trigger the error (make segments earlyer appear to be empty) */
/* segments are earlier empty as expected when decoding PCWs */
#define ERROR_PCW_BODY \
0 /* set a positive values to trigger the error (make segments earlyer \
appear to be empty) */
#define ERROR_PCW_BODY_SIGN \
0 /* set a positive values to trigger the error (make segments earlyer \
appear to be empty) */
#define ERROR_PCW_BODY_SIGN_ESC \
0 /* set a positive values to trigger the error (make segments earlyer \
appear to be empty) */
/* pretend there are too many bits decoded (enlarge length of codeword) at PCWs -- use a positive value */
#define ERROR_PCW_BODY_ONLY_TOO_LONG 0 /* set a positive values to trigger the error */
#define ERROR_PCW_BODY_SIGN_TOO_LONG 0 /* set a positive values to trigger the error */
#define ERROR_PCW_BODY_SIGN_ESC_TOO_LONG 0 /* set a positive values to trigger the error */
/* pretend there are too many bits decoded (enlarge length of codeword) at PCWs
* -- use a positive value */
#define ERROR_PCW_BODY_ONLY_TOO_LONG \
0 /* set a positive values to trigger the error */
#define ERROR_PCW_BODY_SIGN_TOO_LONG \
0 /* set a positive values to trigger the error */
#define ERROR_PCW_BODY_SIGN_ESC_TOO_LONG \
0 /* set a positive values to trigger the error */
/* modify HCR bitstream block */
#define ERROR_GENERATOR_BIT_STREAM_HCR 0 /* modify every <MODULO_DIVISOR_HCR>-bit when reading from bitstream */ /* !!! BEWARE!!! if RVLC is active, also RVLC data at ESC2 will be modified !!! */
#define MODULO_DIVISOR_HCR 30
/* modify HCR bitstream block */
#define MODULO_DIVISOR_HCR 30
/* ------------------------------ */
/* - detect HCR errors - */
/* ------------------------------ */
/* check input data */
#define CHECK_VALID_HCR_INPUT 1 /* it is highly recommended to check input data */
/* check input data */
/* during decoding */
#define CHECK_SEGMENTATION_IMMEDIATELY 1 /* the 2 or 4 lines of a detected PCW-decoding-error is marked */
/* during decoding */
#define CHECK_SEGMENTATION_FINAL 1 /* all the segments are checked -- therefore -- if this check passes, its a kind of evidence that the
decoded PCWs and non-PCWs are fine */
/* all the segments are checked -- therefore -- if this check passes, its a kind
of evidence that the decoded PCWs and non-PCWs are fine */
#define DETECT_TOO_LONG_CW_READS 1 /* if a codeword is decoded there exists a border for the number of bits, which are allowed to read for this
codeword. This border is the minimum of the length of the longest codeword (for the currently used
codebook) and the separately transmitted 'lengthOfLongestCodeword' in this frame and channel. The number
of decoded bits is counted (for PCWs only -- there it makes really sense in my opinion). If this number
exceeds the border (derived as minimum -- see above), a error is detected. */
/* if a codeword is decoded there exists a border for the number of bits, which
are allowed to read for this codeword. This border is the minimum of the
length of the longest codeword (for the currently used codebook) and the
separately transmitted 'lengthOfLongestCodeword' in this frame and channel.
The number of decoded bits is counted (for PCWs only -- there it makes really
sense in my opinion). If this number exceeds the border (derived as minimum
-- see above), a error is detected. */
#define STATE_MACHINE_ERROR_CHECK 1 /* test if the number of remaining bits in a segment is _below_ zero. If there are no errors the lowest
allowed value for remainingBitsInSegment is zero. This check also could be set to zero (save runtime) */
/* other */
#define VALID_LAV_ERROR_TRIGGER 1 /* when set to '1', avoid setting the LAV-Flag in errorLog due to a previous-line-marking (at PCW decoder). A little
more runtime is needed then when writing values out into output-buffer. */
/* -----------------------------------------------------------------------------------------------------
This error check could be set to zero because due to a test within
RVLC-Escape-huffman-Decoder a too long codeword could not be detected -- it
seems that for RVLC-Escape-Codeword the coderoom is used to 100%. Therefore I
assume that the coderoom is used to 100% also for the codebooks 1..11 used at
HCR Therefore this test is deactivated pending further notice
-----------------------------------------------------------------------------------------------------
*/
#define HCR_LISTEN_TO_MUTED_LINES 0 /* listen to the "error-concealment" for testing */
/* test if the number of remaining bits in a segment is _below_ zero. If there
are no errors the lowest allowed value for remainingBitsInSegment is zero.
This check also could be set to zero (save runtime) */
/* other */
/* when set to '1', avoid setting the LAV-Flag in errorLog due to a
previous-line-marking (at PCW decoder). A little more runtime is needed then
when writing values out into output-buffer. */
/* ------------------------------ */
/* - conceal HCR errors - */
/* ------------------------------ */
#define HCR_ERROR_CONCEALMENT 1 /* if set to '1', HCR _mutes_ the erred quantized spectral coefficients */
#define HCR_ERROR_CONCEALMENT \
1 /* if set to '1', HCR _mutes_ the erred quantized spectral coefficients */
// ------------------------------------------------------------------------------------------------------------------
// errorLog: A word of 32 bits used for logging possible errors within HCR
// in case of distorted bitstreams. Table of all known errors:
// errorLog: A word of 32 bits used for
// logging possible errors within HCR
// in case of distorted
// bitstreams. Table of all
// known errors:
// ------------------------------------------------------------------------------------------------------------------------
// bit fatal location meaning
// ----+-----+-----------+--------------------------------------
#define SEGMENT_OVERRIDE_ERR_PCW_BODY 0x80000000 // 31 no PCW-Dec During PCW decoding it is checked after every PCW if there are too many bits decoded (immediate check).
#define SEGMENT_OVERRIDE_ERR_PCW_BODY_SIGN 0x40000000 // 30 no PCW-Dec During PCW decoding it is checked after every PCW if there are too many bits decoded (immediate check).
#define SEGMENT_OVERRIDE_ERR_PCW_BODY_SIGN_ESC 0x20000000 // 29 no PCW-Dec During PCW decoding it is checked after every PCW if there are too many bits decoded (immediate check).
#define EXTENDED_SORTED_COUNTER_OVERFLOW 0x10000000 // 28 yes Init-Dec Error during extending sideinfo (neither a PCW nor a nonPCW was decoded so far)
// 0x08000000 // 27 reserved
// 0x04000000 // 26 reserved
// 0x02000000 // 25 reserved
// 0x01000000 // 24 reserved
// 0x00800000 // 23 reserved
// 0x00400000 // 22 reserved
// 0x00200000 // 21 reserved
// 0x00100000 // 20 reserved
// bit fatal location meaning
// ----+-----+-----------+--------------------------------------
#define SEGMENT_OVERRIDE_ERR_PCW_BODY \
0x80000000 // 31 no PCW-Dec During PCW decoding it is checked after
// every PCW if there are too many bits decoded (immediate
// check).
#define SEGMENT_OVERRIDE_ERR_PCW_BODY_SIGN \
0x40000000 // 30 no PCW-Dec During PCW decoding it is checked after
// every PCW if there are too many bits decoded (immediate
// check).
#define SEGMENT_OVERRIDE_ERR_PCW_BODY_SIGN_ESC \
0x20000000 // 29 no PCW-Dec During PCW decoding it is checked after
// every PCW if there are too many bits decoded (immediate
// check).
#define EXTENDED_SORTED_COUNTER_OVERFLOW \
0x10000000 // 28 yes Init-Dec Error during extending sideinfo
// (neither a PCW nor a nonPCW was decoded so far)
// 0x08000000 // 27 reserved
// 0x04000000 // 26 reserved
// 0x02000000 // 25 reserved
// 0x01000000 // 24 reserved
// 0x00800000 // 23 reserved
// 0x00400000 // 22 reserved
// 0x00200000 // 21 reserved
// 0x00100000 // 20 reserved
/* special errors */
#define TOO_MANY_PCW_BODY_BITS_DECODED 0x00080000 // 19 yes PCW-Dec During PCW-body-decoding too many bits have been read from bitstream -- advice: skip non-PCW decoding
#define TOO_MANY_PCW_BODY_SIGN_BITS_DECODED 0x00040000 // 18 yes PCW-Dec During PCW-body-sign-decoding too many bits have been read from bitstream -- advice: skip non-PCW decoding
#define TOO_MANY_PCW_BODY_SIGN_ESC_BITS_DECODED 0x00020000 // 17 yes PCW-Dec During PCW-body-sign-esc-decoding too many bits have been read from bitstream -- advice: skip non-PCW decoding
/* special errors */
#define TOO_MANY_PCW_BODY_BITS_DECODED \
0x00080000 // 19 yes PCW-Dec During PCW-body-decoding too many bits
// have been read from bitstream -- advice: skip non-PCW decoding
#define TOO_MANY_PCW_BODY_SIGN_BITS_DECODED \
0x00040000 // 18 yes PCW-Dec During PCW-body-sign-decoding too many
// bits have been read from bitstream -- advice: skip non-PCW
// decoding
#define TOO_MANY_PCW_BODY_SIGN_ESC_BITS_DECODED \
0x00020000 // 17 yes PCW-Dec During PCW-body-sign-esc-decoding too
// many bits have been read from bitstream -- advice: skip
// non-PCW decoding
// 0x00010000 // 16 reserved
#define STATE_ERROR_BODY_ONLY \
0x00008000 // 15 no NonPCW-Dec State machine returned with error
#define STATE_ERROR_BODY_SIGN__BODY \
0x00004000 // 14 no NonPCW-Dec State machine returned with error
#define STATE_ERROR_BODY_SIGN__SIGN \
0x00002000 // 13 no NonPCW-Dec State machine returned with error
#define STATE_ERROR_BODY_SIGN_ESC__BODY \
0x00001000 // 12 no NonPCW-Dec State machine returned with error
#define STATE_ERROR_BODY_SIGN_ESC__SIGN \
0x00000800 // 11 no NonPCW-Dec State machine returned with error
#define STATE_ERROR_BODY_SIGN_ESC__ESC_PREFIX \
0x00000400 // 10 no NonPCW-Dec State machine returned with error
#define STATE_ERROR_BODY_SIGN_ESC__ESC_WORD \
0x00000200 // 9 no NonPCW-Dec State machine returned with error
#define HCR_SI_LENGTHS_FAILURE \
0x00000100 // 8 yes Init-Dec LengthOfLongestCodeword must not be
// less than lenghtOfReorderedSpectralData
#define NUM_SECT_OUT_OF_RANGE_SHORT_BLOCK \
0x00000080 // 7 yes Init-Dec The number of sections is not within
// the allowed range (short block)
#define NUM_SECT_OUT_OF_RANGE_LONG_BLOCK \
0x00000040 // 6 yes Init-Dec The number of sections is not within
// the allowed range (long block)
#define LINE_IN_SECT_OUT_OF_RANGE_SHORT_BLOCK \
0x00000020 // 5 yes Init-Dec The number of lines per section is not
// within the allowed range (short block)
#define CB_OUT_OF_RANGE_SHORT_BLOCK \
0x00000010 // 4 yes Init-Dec The codebook is not within the allowed
// range (short block)
#define LINE_IN_SECT_OUT_OF_RANGE_LONG_BLOCK \
0x00000008 // 3 yes Init-Dec The number of lines per section is not
// within the allowed range (long block)
#define CB_OUT_OF_RANGE_LONG_BLOCK \
0x00000004 // 2 yes Init-Dec The codebook is not within the allowed
// range (long block)
#define LAV_VIOLATION \
0x00000002 // 1 no Final The absolute value of at least one
// decoded line was too high for the according codebook.
#define BIT_IN_SEGMENTATION_ERROR \
0x00000001 // 0 no Final After PCW and non-PWC-decoding at least
// one segment is not zero (global check).
// 0x00010000 // 16 reserved
#define STATE_ERROR_BODY_ONLY 0x00008000 // 15 no NonPCW-Dec State machine returned with error
#define STATE_ERROR_BODY_SIGN__BODY 0x00004000 // 14 no NonPCW-Dec State machine returned with error
#define STATE_ERROR_BODY_SIGN__SIGN 0x00002000 // 13 no NonPCW-Dec State machine returned with error
#define STATE_ERROR_BODY_SIGN_ESC__BODY 0x00001000 // 12 no NonPCW-Dec State machine returned with error
#define STATE_ERROR_BODY_SIGN_ESC__SIGN 0x00000800 // 11 no NonPCW-Dec State machine returned with error
#define STATE_ERROR_BODY_SIGN_ESC__ESC_PREFIX 0x00000400 // 10 no NonPCW-Dec State machine returned with error
#define STATE_ERROR_BODY_SIGN_ESC__ESC_WORD 0x00000200 // 9 no NonPCW-Dec State machine returned with error
#define HCR_SI_LENGTHS_FAILURE 0x00000100 // 8 yes Init-Dec LengthOfLongestCodeword must not be less than lenghtOfReorderedSpectralData
#define NUM_SECT_OUT_OF_RANGE_SHORT_BLOCK 0x00000080 // 7 yes Init-Dec The number of sections is not within the allowed range (short block)
#define NUM_SECT_OUT_OF_RANGE_LONG_BLOCK 0x00000040 // 6 yes Init-Dec The number of sections is not within the allowed range (long block)
#define LINE_IN_SECT_OUT_OF_RANGE_SHORT_BLOCK 0x00000020 // 5 yes Init-Dec The number of lines per section is not within the allowed range (short block)
#define CB_OUT_OF_RANGE_SHORT_BLOCK 0x00000010 // 4 yes Init-Dec The codebook is not within the allowed range (short block)
#define LINE_IN_SECT_OUT_OF_RANGE_LONG_BLOCK 0x00000008 // 3 yes Init-Dec The number of lines per section is not within the allowed range (long block)
#define CB_OUT_OF_RANGE_LONG_BLOCK 0x00000004 // 2 yes Init-Dec The codebook is not within the allowed range (long block)
#define LAV_VIOLATION 0x00000002 // 1 no Final The absolute value of at least one decoded line was too high for the according codebook.
#define BIT_IN_SEGMENTATION_ERROR 0x00000001 // 0 no Final After PCW and non-PWC-decoding at least one segment is not zero (global check).
/*----------*/
#define HCR_FATAL_PCW_ERROR_MASK 0x100E01FC
typedef enum {
PCW_BODY,
PCW_BODY_SIGN,
PCW_BODY_SIGN_ESC
} PCW_TYPE;
/*----------*/
#define HCR_FATAL_PCW_ERROR_MASK 0x100E01FC
typedef enum { PCW_BODY, PCW_BODY_SIGN, PCW_BODY_SIGN_ESC } PCW_TYPE;
/* interface Decoder <---> HCR */
typedef struct {
UINT errorLog;
SPECTRAL_PTR pQuantizedSpectralCoefficientsBase;
int quantizedSpectralCoefficientsIdx;
SHORT lengthOfReorderedSpectralData;
SHORT numSection;
SHORT *pNumLineInSect;
USHORT bitstreamIndex;
SCHAR lengthOfLongestCodeword;
UCHAR *pCodebook;
UINT errorLog;
SPECTRAL_PTR pQuantizedSpectralCoefficientsBase;
int quantizedSpectralCoefficientsIdx;
SHORT lengthOfReorderedSpectralData;
SHORT numSection;
SHORT *pNumLineInSect;
INT bitstreamIndex;
SCHAR lengthOfLongestCodeword;
UCHAR *pCodebook;
} HCR_INPUT_OUTPUT;
typedef struct {
@ -287,80 +360,73 @@ typedef struct {
const UCHAR *pMaxOfCbPair;
} HCR_CB_PAIRS;
typedef struct{
typedef struct {
const USHORT *pLargestAbsVal;
const UCHAR *pMaxCwLength;
const UCHAR *pCbDimension;
const UCHAR *pCbDimShift;
const UCHAR *pCbSign;
const UCHAR *pCbPriority;
const UCHAR *pMaxCwLength;
const UCHAR *pCbDimension;
const UCHAR *pCbDimShift;
const UCHAR *pCbSign;
const UCHAR *pCbPriority;
} HCR_TABLE_INFO;
typedef struct{
UINT numSegment;
UINT pSegmentBitfield[((1024>>1)/NUMBER_OF_BIT_IN_WORD+1)];
UINT pCodewordBitfield[((1024>>1)/NUMBER_OF_BIT_IN_WORD+1)];
UINT segmentOffset;
FIXP_DBL pTempValues[1024];
USHORT pLeftStartOfSegment[1024>>1];
USHORT pRightStartOfSegment[1024>>1];
SCHAR pRemainingBitsInSegment[1024>>1];
UCHAR readDirection;
UCHAR numWordForBitfield;
USHORT pNumBitValidInLastWord;
typedef struct {
UINT numSegment;
UINT pSegmentBitfield[((1024 >> 1) / NUMBER_OF_BIT_IN_WORD + 1)];
UINT pCodewordBitfield[((1024 >> 1) / NUMBER_OF_BIT_IN_WORD + 1)];
UINT segmentOffset;
INT pLeftStartOfSegment[1024 >> 1];
INT pRightStartOfSegment[1024 >> 1];
SCHAR pRemainingBitsInSegment[1024 >> 1];
UCHAR readDirection;
UCHAR numWordForBitfield;
USHORT pNumBitValidInLastWord;
} HCR_SEGMENT_INFO;
typedef struct{
typedef struct {
UINT numCodeword;
UINT numSortedSection;
USHORT pNumCodewordInSection[MAX_SFB_HCR];
USHORT pNumSortedCodewordInSection[MAX_SFB_HCR];
USHORT pNumExtendedSortedCodewordInSection[MAX_SFB_HCR + MAX_HCR_SETS];
int numExtendedSortedCodewordInSectionIdx;
USHORT pNumExtendedSortedSectionsInSets[MAX_HCR_SETS];
int numExtendedSortedSectionsInSetsIdx;
USHORT pReorderOffset[MAX_SFB_HCR];
UCHAR pSortedCodebook[MAX_SFB_HCR];
UINT numCodeword;
UINT numSortedSection;
USHORT pNumCodewordInSection[MAX_SFB_HCR];
USHORT pNumSortedCodewordInSection[MAX_SFB_HCR];
USHORT pNumExtendedSortedCodewordInSection[MAX_SFB_HCR+MAX_HCR_SETS];
int numExtendedSortedCodewordInSectionIdx;
USHORT pNumExtendedSortedSectionsInSets[MAX_HCR_SETS];
int numExtendedSortedSectionsInSetsIdx;
USHORT pReorderOffset[MAX_SFB_HCR];
UCHAR pSortedCodebook[MAX_SFB_HCR];
UCHAR pExtendedSortedCodebook[MAX_SFB_HCR+MAX_HCR_SETS];
int extendedSortedCodebookIdx;
#if DETECT_TOO_LONG_CW_READS
UCHAR pMaxLenOfCbInExtSrtSec[MAX_SFB_HCR+MAX_HCR_SETS];
int maxLenOfCbInExtSrtSecIdx;
#endif
UCHAR pCodebookSwitch[MAX_SFB_HCR];
UCHAR pExtendedSortedCodebook[MAX_SFB_HCR + MAX_HCR_SETS];
int extendedSortedCodebookIdx;
UCHAR pMaxLenOfCbInExtSrtSec[MAX_SFB_HCR + MAX_HCR_SETS];
int maxLenOfCbInExtSrtSecIdx;
UCHAR pCodebookSwitch[MAX_SFB_HCR];
} HCR_SECTION_INFO;
typedef UINT (*STATEFUNC)(HANDLE_FDK_BITSTREAM, void*);
typedef UINT (*STATEFUNC)(HANDLE_FDK_BITSTREAM, void *);
typedef struct{
typedef struct {
/* worst-case and 1024/4 non-PCWs exist in worst-case */
FIXP_DBL *pResultBase; /* Base address for spectral data output target buffer */
UINT iNode[1024>>2]; /* Helper indices for code books */
USHORT iResultPointer[1024>>2]; /* Helper indices for accessing pResultBase */
UINT pEscapeSequenceInfo[1024>>2];
UINT codewordOffset;
STATEFUNC pState;
UCHAR pCodebook[1024>>2];
UCHAR pCntSign[1024>>2];
/* this array holds the states coded as integer values within the range [0,1,..,7] */
SCHAR pSta[1024>>2];
FIXP_DBL
*pResultBase; /* Base address for spectral data output target buffer */
UINT iNode[1024 >> 2]; /* Helper indices for code books */
USHORT
iResultPointer[1024 >> 2]; /* Helper indices for accessing pResultBase */
UINT pEscapeSequenceInfo[1024 >> 2];
UINT codewordOffset;
STATEFUNC pState;
UCHAR pCodebook[1024 >> 2];
UCHAR pCntSign[1024 >> 2];
/* this array holds the states coded as integer values within the range
* [0,1,..,7] */
SCHAR pSta[1024 >> 2];
} HCR_NON_PCW_SIDEINFO;
typedef struct{
HCR_INPUT_OUTPUT decInOut;
HCR_CB_PAIRS cbPairs;
HCR_TABLE_INFO tableInfo;
HCR_SEGMENT_INFO segmentInfo;
HCR_SECTION_INFO sectionInfo;
HCR_NON_PCW_SIDEINFO nonPcwSideinfo;
INT globalHcrType;
typedef struct {
HCR_INPUT_OUTPUT decInOut;
HCR_SEGMENT_INFO segmentInfo;
HCR_SECTION_INFO sectionInfo;
HCR_NON_PCW_SIDEINFO nonPcwSideinfo;
} CErHcrInfo;
typedef CErHcrInfo *H_HCR_INFO;
typedef CErHcrInfo *H_HCR_INFO;
#endif /* _AACDEC_HCR_TYPES_H_ */
#endif /* AACDEC_HCR_TYPES_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,75 +90,87 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ***************************
/**************************** AAC decoder library ******************************
Author(s): Robert Weidner (DSP Solutions)
Description: HCR Decoder: Defines of state-constants, masks and
state-prototypes
*******************************************************************************/
#ifndef _AACDEC_HCRS_H_
#define _AACDEC_HCRS_H_
#ifndef AACDEC_HCRS_H
#define AACDEC_HCRS_H
#include "FDK_bitstream.h"
#include "aacdec_hcr_types.h"
/* The four different kinds of types of states are: */
/* different states are defined as constants */ /* start middle=self next stop */
#define STOP_THIS_STATE 0 /* */
#define BODY_ONLY 1 /* X X X */
#define BODY_SIGN__BODY 2 /* X X X X [stop if no sign] */
#define BODY_SIGN__SIGN 3 /* X X [stop if sign bits decoded] */
#define BODY_SIGN_ESC__BODY 4 /* X X X X [stop if no sign] */
#define BODY_SIGN_ESC__SIGN 5 /* X X X [stop if no escape sequence] */
#define BODY_SIGN_ESC__ESC_PREFIX 6 /* X X */
#define BODY_SIGN_ESC__ESC_WORD 7 /* X X X [stop if abs(second qsc) != 16] */
/* The four different kinds of types of states are: */
/* different states are defined as constants */ /* start middle=self next
stop */
#define STOP_THIS_STATE \
0 /* */
#define BODY_ONLY \
1 /* X X X */
#define BODY_SIGN__BODY \
2 /* X X X X [stop if no sign] */
#define BODY_SIGN__SIGN \
3 /* X X [stop if sign bits decoded] */
#define BODY_SIGN_ESC__BODY \
4 /* X X X X [stop if no sign] */
#define BODY_SIGN_ESC__SIGN \
5 /* X X X [stop if no escape sequence] */
#define BODY_SIGN_ESC__ESC_PREFIX \
6 /* X X */
#define BODY_SIGN_ESC__ESC_WORD \
7 /* X X X [stop if abs(second qsc) != 16] */
/* examples: */
/* BODY_ONLY means only the codeword body will be decoded; no sign bits will follow and no escapesequence will follow */
/* BODY_ONLY means only the codeword body will be decoded; no
* sign bits will follow and no escapesequence will follow */
/* BODY_SIGN__BODY means that the codeword consists of two parts; body and sign part. The part '__BODY' after the two underscores shows */
/* that the bits which are currently decoded belong to the '__BODY' of the codeword and not to the sign part. */
/* BODY_SIGN__BODY means that the codeword consists of two parts;
* body and sign part. The part '__BODY' after the two underscores shows */
/* that the bits which are currently decoded belong
* to the '__BODY' of the codeword and not to the sign part. */
/* BODY_SIGN_ESC__ESC_PB means that the codeword consists of three parts; body, sign and (here: two) escape sequences; */
/* BODY_SIGN_ESC__ESC_PB means that the codeword consists of three parts;
* body, sign and (here: two) escape sequences; */
/* P = Prefix = ones */
/* W = Escape Word */
/* A = first possible (of two) Escape sequeces */
/* B = second possible (of two) Escape sequeces */
/* The part after the two underscores shows that the current bits which are decoded belong to the '__ESC_PB' - part of the */
/* codeword. That means the body and the sign bits are decoded completely and the bits which are decoded now belong to */
/* the escape sequence [P = prefix; B=second possible escape sequence] */
/* The part after the two underscores shows that
* the current bits which are decoded belong to the '__ESC_PB' - part of the */
/* codeword. That means the body and the sign bits
* are decoded completely and the bits which are decoded now belong to */
/* the escape sequence [P = prefix; B=second
* possible escape sequence] */
#define MSB_31_MASK 0x80000000 /* masks MSB (= Bit 31) in a 32 bit word */
#define DIMENSION_OF_ESCAPE_CODEBOOK 2 /* for cb >= 11 is dimension 2 */
#define ESCAPE_CODEBOOK 11
#define MSB_31_MASK 0x80000000 /* masks MSB (= Bit 31) in a 32 bit word */
#define DIMENSION_OF_ESCAPE_CODEBOOK 2 /* for cb >= 11 is dimension 2 */
#define ESCAPE_CODEBOOK 11
#define MASK_ESCAPE_PREFIX_UP 0x000F0000
#define LSB_ESCAPE_PREFIX_UP 16
#define MASK_ESCAPE_PREFIX_UP 0x000F0000
#define LSB_ESCAPE_PREFIX_UP 16
#define MASK_ESCAPE_PREFIX_DOWN 0x0000F000
#define LSB_ESCAPE_PREFIX_DOWN 12
#define MASK_ESCAPE_WORD 0x00000FFF
#define MASK_FLAG_A 0x00200000
#define MASK_FLAG_B 0x00100000
#define MASK_ESCAPE_PREFIX_DOWN 0x0000F000
#define LSB_ESCAPE_PREFIX_DOWN 12
#define MASK_ESCAPE_WORD 0x00000FFF
#define MASK_FLAG_A 0x00200000
#define MASK_FLAG_B 0x00100000
extern void DecodeNonPCWs(HANDLE_FDK_BITSTREAM bs, H_HCR_INFO hHcr);
UINT Hcr_State_BODY_ONLY (HANDLE_FDK_BITSTREAM, void*);
UINT Hcr_State_BODY_SIGN__BODY (HANDLE_FDK_BITSTREAM, void*);
UINT Hcr_State_BODY_SIGN__SIGN (HANDLE_FDK_BITSTREAM, void*);
UINT Hcr_State_BODY_SIGN_ESC__BODY (HANDLE_FDK_BITSTREAM, void*);
UINT Hcr_State_BODY_SIGN_ESC__SIGN (HANDLE_FDK_BITSTREAM, void*);
UINT Hcr_State_BODY_SIGN_ESC__ESC_PREFIX (HANDLE_FDK_BITSTREAM, void*);
UINT Hcr_State_BODY_SIGN_ESC__ESC_WORD (HANDLE_FDK_BITSTREAM, void*);
#endif /* _AACDEC_HCRS_H_ */
UINT Hcr_State_BODY_ONLY(HANDLE_FDK_BITSTREAM, void*);
UINT Hcr_State_BODY_SIGN__BODY(HANDLE_FDK_BITSTREAM, void*);
UINT Hcr_State_BODY_SIGN__SIGN(HANDLE_FDK_BITSTREAM, void*);
UINT Hcr_State_BODY_SIGN_ESC__BODY(HANDLE_FDK_BITSTREAM, void*);
UINT Hcr_State_BODY_SIGN_ESC__SIGN(HANDLE_FDK_BITSTREAM, void*);
UINT Hcr_State_BODY_SIGN_ESC__ESC_PREFIX(HANDLE_FDK_BITSTREAM, void*);
UINT Hcr_State_BODY_SIGN_ESC__ESC_WORD(HANDLE_FDK_BITSTREAM, void*);
#endif /* AACDEC_HCRS_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,18 +90,18 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
/**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl
Description: perceptual noise substitution tool
******************************************************************************/
*******************************************************************************/
#include "aacdec_pns.h"
#include "aac_ram.h"
#include "aac_rom.h"
#include "channelinfo.h"
@ -99,45 +110,38 @@ amm-info@iis.fraunhofer.de
#include "genericStds.h"
#define NOISE_OFFSET 90 /* cf. ISO 14496-3 p. 175 */
#define NOISE_OFFSET 90 /* cf. ISO 14496-3 p. 175 */
/*!
\brief Reset InterChannel and PNS data
The function resets the InterChannel and PNS data
*/
void CPns_ResetData(
CPnsData *pPnsData,
CPnsInterChannelData *pPnsInterChannelData
)
{
void CPns_ResetData(CPnsData *pPnsData,
CPnsInterChannelData *pPnsInterChannelData) {
FDK_ASSERT(pPnsData != NULL);
FDK_ASSERT(pPnsInterChannelData != NULL);
/* Assign pointer always, since pPnsData is not persistent data */
pPnsData->pPnsInterChannelData = pPnsInterChannelData;
pPnsData->PnsActive = 0;
pPnsData->CurrentEnergy = 0;
FDKmemclear(pPnsData->pnsUsed,(8*16)*sizeof(UCHAR));
FDKmemclear(pPnsInterChannelData->correlated,(8*16)*sizeof(UCHAR));
FDKmemclear(pPnsData->pnsUsed, (8 * 16) * sizeof(UCHAR));
FDKmemclear(pPnsInterChannelData->correlated, (8 * 16) * sizeof(UCHAR));
}
/*!
\brief Initialize PNS data
\brief Update PNS noise generator state.
The function initializes the PNS data
The function sets the seed for PNS noise generation.
It can be used to link two or more channels in terms of PNS.
*/
void CPns_InitPns(
CPnsData *pPnsData,
CPnsInterChannelData *pPnsInterChannelData,
INT* currentSeed, INT* randomSeed)
{
/* save pointer to inter channel data */
pPnsData->pPnsInterChannelData = pPnsInterChannelData;
void CPns_UpdateNoiseState(CPnsData *pPnsData, INT *currentSeed,
INT *randomSeed) {
/* use pointer because seed has to be
same, left and right channel ! */
pPnsData->currentSeed = currentSeed;
pPnsData->randomSeed = randomSeed;
pPnsData->randomSeed = randomSeed;
}
/*!
@ -148,11 +152,8 @@ void CPns_InitPns(
\return PNS used
*/
int CPns_IsPnsUsed (const CPnsData *pPnsData,
const int group,
const int band)
{
unsigned pns_band = group*16+band;
int CPns_IsPnsUsed(const CPnsData *pPnsData, const int group, const int band) {
unsigned pns_band = group * 16 + band;
return pPnsData->pnsUsed[pns_band] & (UCHAR)1;
}
@ -162,13 +163,10 @@ int CPns_IsPnsUsed (const CPnsData *pPnsData,
The function activates the noise correlation between the channel pair
*/
void CPns_SetCorrelation(CPnsData *pPnsData,
const int group,
const int band,
const int outofphase)
{
void CPns_SetCorrelation(CPnsData *pPnsData, const int group, const int band,
const int outofphase) {
CPnsInterChannelData *pInterChannelData = pPnsData->pPnsInterChannelData;
unsigned pns_band = group*16+band;
unsigned pns_band = group * 16 + band;
pInterChannelData->correlated[pns_band] = (outofphase) ? 3 : 1;
}
@ -181,13 +179,10 @@ void CPns_SetCorrelation(CPnsData *pPnsData,
\return PNS is correlated
*/
static
int CPns_IsCorrelated(const CPnsData *pPnsData,
const int group,
const int band)
{
static int CPns_IsCorrelated(const CPnsData *pPnsData, const int group,
const int band) {
CPnsInterChannelData *pInterChannelData = pPnsData->pPnsInterChannelData;
unsigned pns_band = group*16+band;
unsigned pns_band = group * 16 + band;
return (pInterChannelData->correlated[pns_band] & 0x01) ? 1 : 0;
}
@ -200,13 +195,10 @@ int CPns_IsCorrelated(const CPnsData *pPnsData,
\return PNS is out-of-phase
*/
static
int CPns_IsOutOfPhase(const CPnsData *pPnsData,
const int group,
const int band)
{
static int CPns_IsOutOfPhase(const CPnsData *pPnsData, const int group,
const int band) {
CPnsInterChannelData *pInterChannelData = pPnsData->pPnsInterChannelData;
unsigned pns_band = group*16+band;
unsigned pns_band = group * 16 + band;
return (pInterChannelData->correlated[pns_band] & 0x02) ? 1 : 0;
}
@ -216,36 +208,30 @@ int CPns_IsOutOfPhase(const CPnsData *pPnsData,
The function reads the PNS information from the bitstream
*/
void CPns_Read (CPnsData *pPnsData,
HANDLE_FDK_BITSTREAM bs,
const CodeBookDescription *hcb,
SHORT *pScaleFactor,
UCHAR global_gain,
int band,
int group /* = 0 */)
{
int delta ;
UINT pns_band = group*16+band;
void CPns_Read(CPnsData *pPnsData, HANDLE_FDK_BITSTREAM bs,
const CodeBookDescription *hcb, SHORT *pScaleFactor,
UCHAR global_gain, int band, int group /* = 0 */) {
int delta;
UINT pns_band = group * 16 + band;
if (pPnsData->PnsActive) {
/* Next PNS band case */
delta = CBlock_DecodeHuffmanWord (bs, hcb) - 60;
delta = CBlock_DecodeHuffmanWord(bs, hcb) - 60;
} else {
/* First PNS band case */
int noiseStartValue = FDKreadBits(bs,9);
int noiseStartValue = FDKreadBits(bs, 9);
delta = noiseStartValue - 256 ;
delta = noiseStartValue - 256;
pPnsData->PnsActive = 1;
pPnsData->CurrentEnergy = global_gain - NOISE_OFFSET;
}
pPnsData->CurrentEnergy += delta ;
pPnsData->CurrentEnergy += delta;
pScaleFactor[pns_band] = pPnsData->CurrentEnergy;
pPnsData->pnsUsed[pns_band] = 1;
}
/**
* \brief Generate a vector of noise of given length. The noise values are
* scaled in order to yield a noise energy of 1.0
@ -254,32 +240,29 @@ void CPns_Read (CPnsData *pPnsData,
* \param pRandomState pointer to the state of the random generator being used.
* \return exponent of generated noise vector.
*/
static int GenerateRandomVector (FIXP_DBL *RESTRICT spec,
int size,
int *pRandomState)
{
static int GenerateRandomVector(FIXP_DBL *RESTRICT spec, int size,
int *pRandomState) {
int i, invNrg_e = 0, nrg_e = 0;
FIXP_DBL invNrg_m, nrg_m = FL2FXCONST_DBL(0.0f) ;
FIXP_DBL invNrg_m, nrg_m = FL2FXCONST_DBL(0.0f);
FIXP_DBL *RESTRICT ptr = spec;
int randomState = *pRandomState;
#define GEN_NOISE_NRG_SCALE 7
/* Generate noise and calculate energy. */
for (i=0; i<size; i++)
{
randomState = (1664525L * randomState) + 1013904223L; // Numerical Recipes
nrg_m = fPow2AddDiv2(nrg_m, (FIXP_DBL)randomState>>GEN_NOISE_NRG_SCALE);
for (i = 0; i < size; i++) {
randomState =
(((INT64)1664525 * randomState) + (INT64)1013904223) & 0xFFFFFFFF;
nrg_m = fPow2AddDiv2(nrg_m, (FIXP_DBL)randomState >> GEN_NOISE_NRG_SCALE);
*ptr++ = (FIXP_DBL)randomState;
}
nrg_e = GEN_NOISE_NRG_SCALE*2 + 1;
nrg_e = GEN_NOISE_NRG_SCALE * 2 + 1;
/* weight noise with = 1 / sqrt_nrg; */
invNrg_m = invSqrtNorm2(nrg_m<<1, &invNrg_e);
invNrg_e += -((nrg_e-1)>>1);
invNrg_m = invSqrtNorm2(nrg_m << 1, &invNrg_e);
invNrg_e += -((nrg_e - 1) >> 1);
for (i=size; i--; )
{
for (i = size; i--;) {
spec[i] = fMult(spec[i], invNrg_m);
}
@ -289,8 +272,8 @@ static int GenerateRandomVector (FIXP_DBL *RESTRICT spec,
return invNrg_e;
}
static void ScaleBand (FIXP_DBL *RESTRICT spec, int size, int scaleFactor, int specScale, int noise_e, int out_of_phase)
{
static void ScaleBand(FIXP_DBL *RESTRICT spec, int size, int scaleFactor,
int specScale, int noise_e, int out_of_phase) {
int i, shift, sfExponent;
FIXP_DBL sfMatissa;
@ -308,20 +291,19 @@ static void ScaleBand (FIXP_DBL *RESTRICT spec, int size, int scaleFactor, int s
shift = sfExponent - specScale + 1 + noise_e;
/* Apply gain to noise values */
if (shift>=0) {
shift = fixMin( shift, DFRACT_BITS-1 );
for (i = size ; i-- != 0; ) {
spec [i] = fMultDiv2 (spec [i], sfMatissa) << shift;
if (shift >= 0) {
shift = fixMin(shift, DFRACT_BITS - 1);
for (i = size; i-- != 0;) {
spec[i] = fMultDiv2(spec[i], sfMatissa) << shift;
}
} else {
shift = fixMin( -shift, DFRACT_BITS-1 );
for (i = size ; i-- != 0; ) {
spec [i] = fMultDiv2 (spec [i], sfMatissa) >> shift;
shift = fixMin(-shift, DFRACT_BITS - 1);
for (i = size; i-- != 0;) {
spec[i] = fMultDiv2(spec[i], sfMatissa) >> shift;
}
}
}
/*!
\brief Apply PNS
@ -329,51 +311,48 @@ static void ScaleBand (FIXP_DBL *RESTRICT spec, int size, int scaleFactor, int s
flagged as noisy bands
*/
void CPns_Apply (const CPnsData *pPnsData,
const CIcsInfo *pIcsInfo,
SPECTRAL_PTR pSpectrum,
const SHORT *pSpecScale,
const SHORT *pScaleFactor,
const SamplingRateInfo *pSamplingRateInfo,
const INT granuleLength,
const int channel)
{
void CPns_Apply(const CPnsData *pPnsData, const CIcsInfo *pIcsInfo,
SPECTRAL_PTR pSpectrum, const SHORT *pSpecScale,
const SHORT *pScaleFactor,
const SamplingRateInfo *pSamplingRateInfo,
const INT granuleLength, const int channel) {
if (pPnsData->PnsActive) {
const short *BandOffsets = GetScaleFactorBandOffsets(pIcsInfo, pSamplingRateInfo);
const short *BandOffsets =
GetScaleFactorBandOffsets(pIcsInfo, pSamplingRateInfo);
int ScaleFactorBandsTransmitted = GetScaleFactorBandsTransmitted(pIcsInfo);
for (int window = 0, group = 0; group < GetWindowGroups(pIcsInfo); group++) {
for (int groupwin = 0; groupwin < GetWindowGroupLength(pIcsInfo, group); groupwin++, window++) {
for (int window = 0, group = 0; group < GetWindowGroups(pIcsInfo);
group++) {
for (int groupwin = 0; groupwin < GetWindowGroupLength(pIcsInfo, group);
groupwin++, window++) {
FIXP_DBL *spectrum = SPEC(pSpectrum, window, granuleLength);
for (int band = 0 ; band < ScaleFactorBandsTransmitted; band++) {
if (CPns_IsPnsUsed (pPnsData, group, band)) {
UINT pns_band = group*16+band;
for (int band = 0; band < ScaleFactorBandsTransmitted; band++) {
if (CPns_IsPnsUsed(pPnsData, group, band)) {
UINT pns_band = window * 16 + band;
int bandWidth = BandOffsets [band + 1] - BandOffsets [band] ;
int bandWidth = BandOffsets[band + 1] - BandOffsets[band];
int noise_e;
FDK_ASSERT(bandWidth >= 0);
if (channel > 0 && CPns_IsCorrelated(pPnsData, group, band))
{
noise_e = GenerateRandomVector (spectrum + BandOffsets [band], bandWidth,
&pPnsData->randomSeed [pns_band]) ;
}
else
{
pPnsData->randomSeed [pns_band] = *pPnsData->currentSeed ;
if (channel > 0 && CPns_IsCorrelated(pPnsData, group, band)) {
noise_e =
GenerateRandomVector(spectrum + BandOffsets[band], bandWidth,
&pPnsData->randomSeed[pns_band]);
} else {
pPnsData->randomSeed[pns_band] = *pPnsData->currentSeed;
noise_e = GenerateRandomVector (spectrum + BandOffsets [band], bandWidth,
pPnsData->currentSeed) ;
noise_e = GenerateRandomVector(spectrum + BandOffsets[band],
bandWidth, pPnsData->currentSeed);
}
int outOfPhase = CPns_IsOutOfPhase (pPnsData, group, band);
int outOfPhase = CPns_IsOutOfPhase(pPnsData, group, band);
ScaleBand (spectrum + BandOffsets [band], bandWidth,
pScaleFactor[pns_band],
pSpecScale[window], noise_e, outOfPhase) ;
ScaleBand(spectrum + BandOffsets[band], bandWidth,
pScaleFactor[group * 16 + band], pSpecScale[window],
noise_e, outOfPhase);
}
}
}

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,22 +90,22 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
/**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl
Description: perceptual noise substitution tool
******************************************************************************/
*******************************************************************************/
#ifndef PNS_H
#define PNS_H
#ifndef AACDEC_PNS_H
#define AACDEC_PNS_H
#include "common_fix.h"
#define NO_OFBANDS ((8*16))
#define NO_OFBANDS ((8 * 16))
typedef struct {
UCHAR correlated[NO_OFBANDS];
@ -102,19 +113,17 @@ typedef struct {
typedef struct {
CPnsInterChannelData *pPnsInterChannelData;
UCHAR pnsUsed[NO_OFBANDS];
int CurrentEnergy;
UCHAR PnsActive;
INT *currentSeed;
INT *randomSeed;
UCHAR pnsUsed[NO_OFBANDS];
int CurrentEnergy;
UCHAR PnsActive;
INT *currentSeed;
INT *randomSeed;
} CPnsData;
void CPns_InitPns ( CPnsData *pPnsData,
CPnsInterChannelData *pPnsInterChannelData,
INT* currentSeed,
INT* randomSeed );
void CPns_UpdateNoiseState(CPnsData *pPnsData, INT *currentSeed,
INT *randomSeed);
void CPns_ResetData ( CPnsData *pPnsData, CPnsInterChannelData *pPnsInterChannelData );
void CPns_ResetData(CPnsData *pPnsData,
CPnsInterChannelData *pPnsInterChannelData);
#endif /* #ifndef PNS_H */
#endif /* #ifndef AACDEC_PNS_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,21 +90,24 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
/**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl
Description: temporal noise shaping tool
******************************************************************************/
*******************************************************************************/
#include "aacdec_tns.h"
#include "aac_rom.h"
#include "FDK_bitstream.h"
#include "channelinfo.h"
#include "FDK_lpc.h"
#define TNS_MAXIMUM_ORDER_AAC 12
/*!
\brief Reset tns data
@ -102,19 +116,20 @@ amm-info@iis.fraunhofer.de
\return none
*/
void CTns_Reset(CTnsData *pTnsData)
{
void CTns_Reset(CTnsData *pTnsData) {
/* Note: the following FDKmemclear should not be required. */
FDKmemclear(pTnsData->Filter, TNS_MAX_WINDOWS*TNS_MAXIMUM_FILTERS*sizeof(CFilter));
FDKmemclear(pTnsData->NumberOfFilters, TNS_MAX_WINDOWS*sizeof(UCHAR));
FDKmemclear(pTnsData->Filter,
TNS_MAX_WINDOWS * TNS_MAXIMUM_FILTERS * sizeof(CFilter));
FDKmemclear(pTnsData->NumberOfFilters, TNS_MAX_WINDOWS * sizeof(UCHAR));
pTnsData->DataPresent = 0;
pTnsData->Active = 0;
}
void CTns_ReadDataPresentFlag(HANDLE_FDK_BITSTREAM bs, /*!< pointer to bitstream */
CTnsData *pTnsData) /*!< pointer to aac decoder channel info */
void CTns_ReadDataPresentFlag(
HANDLE_FDK_BITSTREAM bs, /*!< pointer to bitstream */
CTnsData *pTnsData) /*!< pointer to aac decoder channel info */
{
pTnsData->DataPresent = (UCHAR) FDKreadBits(bs,1);
pTnsData->DataPresent = (UCHAR)FDKreadBits(bs, 1);
}
/*!
@ -125,83 +140,89 @@ void CTns_ReadDataPresentFlag(HANDLE_FDK_BITSTREAM bs, /*!< pointer to bitstr
\return none
*/
AAC_DECODER_ERROR CTns_Read(HANDLE_FDK_BITSTREAM bs,
CTnsData *pTnsData,
const CIcsInfo *pIcsInfo,
const UINT flags)
{
UCHAR n_filt,order;
UCHAR length,coef_res,coef_compress;
AAC_DECODER_ERROR CTns_Read(HANDLE_FDK_BITSTREAM bs, CTnsData *pTnsData,
const CIcsInfo *pIcsInfo, const UINT flags) {
UCHAR n_filt, order;
UCHAR length, coef_res, coef_compress;
UCHAR window;
UCHAR wins_per_frame = GetWindowsPerFrame(pIcsInfo);
UCHAR isLongFlag = IsLongBlock(pIcsInfo);
UCHAR wins_per_frame;
UCHAR isLongFlag;
UCHAR start_window;
AAC_DECODER_ERROR ErrorStatus = AAC_DEC_OK;
if (!pTnsData->DataPresent) {
return ErrorStatus;
}
for (window = 0; window < wins_per_frame; window++)
{
pTnsData->NumberOfFilters[window] = n_filt = (UCHAR) FDKreadBits(bs, isLongFlag ? 2 : 1);
start_window = 0;
wins_per_frame = GetWindowsPerFrame(pIcsInfo);
isLongFlag = IsLongBlock(pIcsInfo);
}
if (pTnsData->NumberOfFilters[window] > TNS_MAXIMUM_FILTERS){
pTnsData->NumberOfFilters[window] = n_filt = TNS_MAXIMUM_FILTERS;
}
pTnsData->GainLd = 0;
if (n_filt)
{
for (window = start_window; window < wins_per_frame; window++) {
pTnsData->NumberOfFilters[window] = n_filt =
(UCHAR)FDKreadBits(bs, isLongFlag ? 2 : 1);
if (n_filt) {
int index;
UCHAR nextstopband;
coef_res = (UCHAR) FDKreadBits(bs,1);
coef_res = (UCHAR)FDKreadBits(bs, 1);
nextstopband = GetScaleFactorBandsTotal(pIcsInfo);
for (index=0; index < n_filt; index++)
{
for (index = 0; index < n_filt; index++) {
CFilter *filter = &pTnsData->Filter[window][index];
length = (UCHAR)FDKreadBits(bs, isLongFlag ? 6 : 4);
if (length > nextstopband){
if (length > nextstopband) {
length = nextstopband;
}
filter->StartBand = nextstopband - length;
filter->StopBand = nextstopband;
filter->StopBand = nextstopband;
nextstopband = filter->StartBand;
{
filter->Order = order = (UCHAR) FDKreadBits(bs, isLongFlag ? 5 : 3);
if (flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA)) {
/* max(Order) = 15 (long), 7 (short) */
filter->Order = order = (UCHAR)FDKreadBits(bs, isLongFlag ? 4 : 3);
} else {
filter->Order = order = (UCHAR)FDKreadBits(bs, isLongFlag ? 5 : 3);
if (filter->Order > TNS_MAXIMUM_ORDER) {
ErrorStatus = AAC_DEC_TNS_READ_ERROR;
return ErrorStatus;
}
}
if (filter->Order > TNS_MAXIMUM_ORDER){
filter->Order = order = TNS_MAXIMUM_ORDER;
}
if (order)
{
UCHAR coef,s_mask;
FDK_ASSERT(order <=
TNS_MAXIMUM_ORDER); /* avoid illegal memory access */
if (order) {
UCHAR coef, s_mask;
UCHAR i;
SCHAR n_mask;
static const UCHAR sgn_mask[] = { 0x2, 0x4, 0x8 };
static const SCHAR neg_mask[] = { ~0x3, ~0x7, ~0xF };
filter->Direction = FDKreadBits(bs,1) ? -1 : 1;
static const UCHAR sgn_mask[] = {0x2, 0x4, 0x8};
static const SCHAR neg_mask[] = {~0x3, ~0x7, ~0xF};
coef_compress = (UCHAR) FDKreadBits(bs,1);
filter->Direction = FDKreadBits(bs, 1) ? -1 : 1;
coef_compress = (UCHAR)FDKreadBits(bs, 1);
filter->Resolution = coef_res + 3;
s_mask = sgn_mask[coef_res + 1 - coef_compress];
n_mask = neg_mask[coef_res + 1 - coef_compress];
for (i=0; i < order; i++)
{
coef = (UCHAR) FDKreadBits(bs,filter->Resolution - coef_compress);
for (i = 0; i < order; i++) {
coef = (UCHAR)FDKreadBits(bs, filter->Resolution - coef_compress);
filter->Coeff[i] = (coef & s_mask) ? (coef | n_mask) : coef;
}
pTnsData->GainLd = 4;
}
}
}
@ -212,115 +233,35 @@ AAC_DECODER_ERROR CTns_Read(HANDLE_FDK_BITSTREAM bs,
return ErrorStatus;
}
void CTns_ReadDataPresentUsac(HANDLE_FDK_BITSTREAM hBs, CTnsData *pTnsData0,
CTnsData *pTnsData1, UCHAR *ptns_on_lr,
const CIcsInfo *pIcsInfo, const UINT flags,
const UINT elFlags, const int fCommonWindow) {
int common_tns = 0;
static void CTns_Filter (FIXP_DBL *spec, int size, int inc, FIXP_TCC coeff [], int order)
{
// - Simple all-pole filter of order "order" defined by
// y(n) = x(n) - a(2)*y(n-1) - ... - a(order+1)*y(n-order)
//
// - The state variables of the filter are initialized to zero every time
//
// - The output data is written over the input data ("in-place operation")
//
// - An input vector of "size" samples is processed and the index increment
// to the next data sample is given by "inc"
int i,j,N;
FIXP_DBL *pSpec;
FIXP_DBL maxVal=FL2FXCONST_DBL(0.0);
INT s;
FDK_ASSERT(order <= TNS_MAXIMUM_ORDER);
C_ALLOC_SCRATCH_START(state, FIXP_DBL, TNS_MAXIMUM_ORDER);
FDKmemclear(state, order*sizeof(FIXP_DBL));
for (i=0; i<size; i++) {
maxVal = fixMax(maxVal,fixp_abs(spec[i]));
if (fCommonWindow) {
common_tns = FDKreadBit(hBs);
}
{ *ptns_on_lr = FDKreadBit(hBs); }
if (common_tns) {
pTnsData0->DataPresent = 1;
CTns_Read(hBs, pTnsData0, pIcsInfo, flags);
if ( maxVal > FL2FXCONST_DBL(0.03125*0.70710678118) )
s = fixMax(CntLeadingZeros(maxVal)-6,0);
else
s = fixMax(CntLeadingZeros(maxVal)-5,0);
pTnsData0->DataPresent = 0;
pTnsData0->Active = 1;
*pTnsData1 = *pTnsData0;
} else {
int tns_present_both;
s = fixMin(s,2);
s = s-1;
if (inc == -1)
pSpec = &spec[size - 1];
else
pSpec = &spec[0];
FIXP_TCC *pCoeff;
#define FIRST_PART_FLTR \
FIXP_DBL x, *pState = state; \
pCoeff = coeff; \
\
if (s < 0) \
x = (pSpec [0]>>1) + fMultDiv2 (*pCoeff++, pState [0]) ; \
else \
x = (pSpec [0]<<s) + fMultDiv2 (*pCoeff++, pState [0]) ;
#define INNER_FLTR_INLINE \
x = fMultAddDiv2 (x, *pCoeff, pState [1]); \
pState [0] = pState [1] - (fMultDiv2 (*pCoeff++, x) <<2) ; \
pState++;
#define LAST_PART_FLTR \
if (s < 0) \
*pSpec = x << 1; \
else \
*pSpec = x >> s; \
*pState =(-x) << 1; \
pSpec += inc ;
if (order>8)
{
N = (order-1)&7;
for (i = size ; i != 0 ; i--)
{
FIRST_PART_FLTR
for (j = N; j > 0 ; j--) { INNER_FLTR_INLINE }
INNER_FLTR_INLINE INNER_FLTR_INLINE INNER_FLTR_INLINE INNER_FLTR_INLINE
INNER_FLTR_INLINE INNER_FLTR_INLINE INNER_FLTR_INLINE INNER_FLTR_INLINE
LAST_PART_FLTR
}
} else if (order>4) {
N = (order-1)&3;
for (i = size ; i != 0 ; i--)
{
FIRST_PART_FLTR
for (j = N; j > 0 ; j--) { INNER_FLTR_INLINE }
INNER_FLTR_INLINE INNER_FLTR_INLINE INNER_FLTR_INLINE INNER_FLTR_INLINE
LAST_PART_FLTR
}
} else {
N = order-1;
for (i = size ; i != 0 ; i--)
{
FIRST_PART_FLTR
for (j = N; j > 0 ; j--) { INNER_FLTR_INLINE }
LAST_PART_FLTR
}
}
C_ALLOC_SCRATCH_END(state, FIXP_DBL, TNS_MAXIMUM_ORDER);
tns_present_both = FDKreadBit(hBs);
if (tns_present_both) {
pTnsData0->DataPresent = 1;
pTnsData1->DataPresent = 1;
} else {
pTnsData1->DataPresent = FDKreadBit(hBs);
pTnsData0->DataPresent = !pTnsData1->DataPresent;
}
}
}
/*!
@ -330,83 +271,91 @@ static void CTns_Filter (FIXP_DBL *spec, int size, int inc, FIXP_TCC coeff [], i
\return none
*/
void CTns_Apply (
CTnsData *RESTRICT pTnsData, /*!< pointer to aac decoder info */
const CIcsInfo *pIcsInfo,
SPECTRAL_PTR pSpectralCoefficient,
const SamplingRateInfo *pSamplingRateInfo,
const INT granuleLength
)
{
int window,index,start,stop,size;
void CTns_Apply(CTnsData *RESTRICT pTnsData, /*!< pointer to aac decoder info */
const CIcsInfo *pIcsInfo, SPECTRAL_PTR pSpectralCoefficient,
const SamplingRateInfo *pSamplingRateInfo,
const INT granuleLength, const UCHAR nbands,
const UCHAR igf_active, const UINT flags) {
int window, index, start, stop, size, start_window, wins_per_frame;
if (pTnsData->Active) {
C_AALLOC_SCRATCH_START(coeff, FIXP_TCC, TNS_MAXIMUM_ORDER)
if (pTnsData->Active)
{
C_AALLOC_SCRATCH_START(coeff, FIXP_TCC, TNS_MAXIMUM_ORDER);
{
start_window = 0;
wins_per_frame = GetWindowsPerFrame(pIcsInfo);
}
for (window=0; window < GetWindowsPerFrame(pIcsInfo); window++)
{
FIXP_DBL *pSpectrum = SPEC(pSpectralCoefficient, window, granuleLength);
for (window = start_window; window < wins_per_frame; window++) {
FIXP_DBL *pSpectrum;
for (index=0; index < pTnsData->NumberOfFilters[window]; index++)
{
CFilter *RESTRICT filter = &pTnsData->Filter[window][index];
{ pSpectrum = SPEC(pSpectralCoefficient, window, granuleLength); }
if (filter->Order > 0)
{
FIXP_TCC *pCoeff;
int tns_max_bands;
for (index = 0; index < pTnsData->NumberOfFilters[window]; index++) {
CFilter *filter = &pTnsData->Filter[window][index];
pCoeff = &coeff[filter->Order-1];
if (filter->Resolution == 3)
{
int i;
for (i=0; i < filter->Order; i++)
*pCoeff-- = FDKaacDec_tnsCoeff3[filter->Coeff[i]+4];
}
else
{
int i;
for (i=0; i < filter->Order; i++)
*pCoeff-- = FDKaacDec_tnsCoeff4[filter->Coeff[i]+8];
}
if (filter->Order > 0) {
FIXP_TCC *pCoeff;
UCHAR tns_max_bands;
switch (granuleLength) {
case 480:
tns_max_bands = tns_max_bands_tbl_480[pSamplingRateInfo->samplingRateIndex];
break;
case 512:
tns_max_bands = tns_max_bands_tbl_512[pSamplingRateInfo->samplingRateIndex];
break;
default:
tns_max_bands = GetMaximumTnsBands(pIcsInfo, pSamplingRateInfo->samplingRateIndex);
break;
}
pCoeff = coeff;
if (filter->Resolution == 3) {
int i;
for (i = 0; i < filter->Order; i++)
*pCoeff++ = FDKaacDec_tnsCoeff3[filter->Coeff[i] + 4];
} else {
int i;
for (i = 0; i < filter->Order; i++)
*pCoeff++ = FDKaacDec_tnsCoeff4[filter->Coeff[i] + 8];
}
start = fixMin( fixMin(filter->StartBand, tns_max_bands),
GetScaleFactorBandsTransmitted(pIcsInfo) );
switch (granuleLength) {
case 480:
tns_max_bands =
tns_max_bands_tbl_480[pSamplingRateInfo->samplingRateIndex];
break;
case 512:
tns_max_bands =
tns_max_bands_tbl_512[pSamplingRateInfo->samplingRateIndex];
break;
default:
tns_max_bands = GetMaximumTnsBands(
pIcsInfo, pSamplingRateInfo->samplingRateIndex);
/* See redefinition of TNS_MAX_BANDS table */
if ((flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA)) &&
(pSamplingRateInfo->samplingRateIndex > 5)) {
tns_max_bands += 1;
}
break;
}
start = GetScaleFactorBandOffsets(pIcsInfo, pSamplingRateInfo)[start];
start = fixMin(fixMin(filter->StartBand, tns_max_bands), nbands);
stop = fixMin( fixMin(filter->StopBand, tns_max_bands),
GetScaleFactorBandsTransmitted(pIcsInfo) );
start = GetScaleFactorBandOffsets(pIcsInfo, pSamplingRateInfo)[start];
stop = GetScaleFactorBandOffsets(pIcsInfo, pSamplingRateInfo)[stop];
if (igf_active) {
stop = fixMin(filter->StopBand, nbands);
} else {
stop = fixMin(fixMin(filter->StopBand, tns_max_bands), nbands);
}
size = stop - start;
stop = GetScaleFactorBandOffsets(pIcsInfo, pSamplingRateInfo)[stop];
if (size > 0) {
CTns_Filter(&pSpectrum[start],
size,
filter->Direction,
coeff,
filter->Order );
}
size = stop - start;
if (size) {
C_ALLOC_SCRATCH_START(state, FIXP_DBL, TNS_MAXIMUM_ORDER)
FDKmemclear(state, TNS_MAXIMUM_ORDER * sizeof(FIXP_DBL));
CLpc_SynthesisLattice(pSpectrum + start, size, 0, 0,
filter->Direction, coeff, filter->Order,
state);
C_ALLOC_SCRATCH_END(state, FIXP_DBL, TNS_MAXIMUM_ORDER)
}
}
}
C_AALLOC_SCRATCH_END(coeff, FIXP_TCC, TNS_MAXIMUM_ORDER);
}
C_AALLOC_SCRATCH_END(coeff, FIXP_TCC, TNS_MAXIMUM_ORDER)
}
}

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,29 +90,37 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
/**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl
Description: temporal noise shaping tool
******************************************************************************/
*******************************************************************************/
#ifndef TNS_H
#define TNS_H
#ifndef AACDEC_TNS_H
#define AACDEC_TNS_H
#include "common_fix.h"
enum
{
TNS_MAX_WINDOWS = 8, /* 8 */
TNS_MAXIMUM_ORDER = 20, /* 12 for AAC-LC and AAC-SSR. Set to 20 for AAC-Main (AOT 1). Some broken encoders also do order 20 for AAC-LC :( */
enum {
TNS_MAX_WINDOWS = 8, /* 8 */
TNS_MAXIMUM_FILTERS = 3
};
typedef struct
{
/* TNS_MAXIMUM_ORDER (for memory allocation)
12 for AAC-LC and AAC-SSR. Set to 20 for AAC-Main (AOT 1). Some broken
encoders also do order 20 for AAC-LC :( 15 for USAC (AOT 42)
*/
#define TNS_MAXIMUM_ORDER (20)
#if (TNS_MAXIMUM_ORDER < 15)
#error USAC: TNS filter order up 15 can be signaled!
#endif
typedef struct {
SCHAR Coeff[TNS_MAXIMUM_ORDER];
UCHAR StartBand;
@ -113,14 +132,18 @@ typedef struct
UCHAR Order;
} CFilter;
typedef struct
{
typedef struct {
CFilter Filter[TNS_MAX_WINDOWS][TNS_MAXIMUM_FILTERS];
UCHAR NumberOfFilters[TNS_MAX_WINDOWS];
UCHAR DataPresent;
UCHAR Active;
/* log2 of the maximum total filter gains. The value is required to
keep necessary mantissa headroom so that while applying the TNS predictor
the mantissas do not overflow. */
UCHAR GainLd;
} CTnsData;
void CTns_Reset(CTnsData *pTnsData);
#endif /* #ifndef TNS_H */
#endif /* #ifndef AACDEC_TNS_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2015 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,14 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
/**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl
Description:
******************************************************************************/
*******************************************************************************/
#ifndef AACDECODER_H
#define AACDECODER_H
@ -104,134 +116,238 @@ amm-info@iis.fraunhofer.de
#include "genericStds.h"
#include "FDK_qmf_domain.h"
#include "sbrdecoder.h"
#include "aacdec_drc.h"
#include "pcmutils_lib.h"
#include "limiter.h"
#include "pcmdmx_lib.h"
#include "FDK_drcDecLib.h"
/* Capabilities flags */
#define CAPF_AAC_LC 0x00000001
#define CAPF_AAC_LD 0x00000002
#define CAPF_AAC_SCAL 0x00000004
#define CAPF_AAC_ER 0x00000008
#define CAPF_AAC_480 0x00000010
#define CAPF_AAC_512 0x00000020
#define CAPF_AAC_960 0x00000040
#define CAPF_AAC_1024 0x00000080
#define CAPF_AAC_HCR 0x00000100
#define CAPF_AAC_VCB11 0x00000200
#define CAPF_AAC_RVLC 0x00000400
#define CAPF_AAC_MPEG4 0x00000800 /* PNS */
#define CAPF_AAC_DRC 0x00001000
#define CAPF_AAC_CONCEAL 0x00002000
#define CAPF_AAC_DRM_BSFORMAT 0x00004000
#define CAPF_AAC_BSAC 0x00008000
#include "limiter.h"
#include "FDK_delay.h"
#define TIME_DATA_FLUSH_SIZE (128)
#define TIME_DATA_FLUSH_SIZE_SF (7)
#define AACDEC_MAX_NUM_PREROLL_AU_USAC (3)
#if (AACDEC_MAX_NUM_PREROLL_AU < 3)
#undef AACDEC_MAX_NUM_PREROLL_AU
#define AACDEC_MAX_NUM_PREROLL_AU AACDEC_MAX_NUM_PREROLL_AU_USAC
#endif
typedef struct AAC_DECODER_INSTANCE *HANDLE_AACDECODER;
enum { L = 0, R = 1 };
enum
{
L = 0,
R = 1
typedef struct {
unsigned char *buffer;
int bufferSize;
int offset[8];
int nrElements;
} CAncData;
typedef enum { NOT_DEFINED = -1, MODE_HQ = 0, MODE_LP = 1 } QMF_MODE;
typedef struct {
int bsDelay;
} SBR_PARAMS;
enum {
AACDEC_FLUSH_OFF = 0,
AACDEC_RSV60_CFG_CHANGE_ATSC_FLUSH_ON = 1,
AACDEC_RSV60_DASH_IPF_ATSC_FLUSH_ON = 2,
AACDEC_USAC_DASH_IPF_FLUSH_ON = 3
};
enum {
AACDEC_BUILD_UP_OFF = 0,
AACDEC_RSV60_BUILD_UP_ON = 1,
AACDEC_RSV60_BUILD_UP_ON_IN_BAND = 2,
AACDEC_USAC_BUILD_UP_ON = 3,
AACDEC_RSV60_BUILD_UP_IDLE = 4,
AACDEC_RSV60_BUILD_UP_IDLE_IN_BAND = 5
};
typedef struct {
unsigned char *buffer;
int bufferSize;
int offset[8];
int nrElements;
} CAncData;
typedef enum {
NOT_DEFINED = -1,
MODE_HQ = 0,
MODE_LP = 1
} QMF_MODE;
typedef struct {
int bsDelay;
} SBR_PARAMS;
/* Usac Extension Elements */
USAC_EXT_ELEMENT_TYPE usacExtElementType[(3)];
UINT usacExtElementDefaultLength[(3)];
UCHAR usacExtElementPayloadFrag[(3)];
} CUsacCoreExtensions;
/* AAC decoder (opaque toward userland) struct declaration */
struct AAC_DECODER_INSTANCE {
INT aacChannels; /*!< Amount of AAC decoder channels allocated. */
INT ascChannels; /*!< Amount of AAC decoder channels signalled in ASC. */
INT blockNumber; /*!< frame counter */
INT aacChannels; /*!< Amount of AAC decoder channels allocated. */
INT ascChannels[(1 *
1)]; /*!< Amount of AAC decoder channels signalled in ASC. */
INT blockNumber; /*!< frame counter */
INT nrOfLayers;
INT nrOfLayers;
INT outputInterleaved; /*!< PCM output format (interleaved/none interleaved). */
INT outputInterleaved; /*!< PCM output format (interleaved/none interleaved).
*/
HANDLE_TRANSPORTDEC hInput; /*!< Transport layer handle. */
HANDLE_TRANSPORTDEC hInput; /*!< Transport layer handle. */
SamplingRateInfo samplingRateInfo; /*!< Sampling Rate information table */
SamplingRateInfo
samplingRateInfo[(1 * 1)]; /*!< Sampling Rate information table */
UCHAR frameOK; /*!< Will be unset if a consistency check, e.g. CRC etc. fails */
UCHAR
frameOK; /*!< Will be unset if a consistency check, e.g. CRC etc. fails */
UINT flags; /*!< Flags for internal decoder use. DO NOT USE self::streaminfo::flags ! */
UINT flags[(1 * 1)]; /*!< Flags for internal decoder use. DO NOT USE
self::streaminfo::flags ! */
UINT elFlags[(3 * ((8) * 2) + (((8) * 2)) / 2 + 4 * (1) +
1)]; /*!< Flags for internal decoder use (element specific). DO
NOT USE self::streaminfo::flags ! */
MP4_ELEMENT_ID elements[(8)]; /*!< Table where the element Id's are listed */
UCHAR elTags[(8)]; /*!< Table where the elements id Tags are listed */
UCHAR chMapping[(8)]; /*!< Table of MPEG canonical order to bitstream channel order mapping. */
MP4_ELEMENT_ID elements[(3 * ((8) * 2) + (((8) * 2)) / 2 + 4 * (1) +
1)]; /*!< Table where the element Id's are listed */
UCHAR elTags[(3 * ((8) * 2) + (((8) * 2)) / 2 + 4 * (1) +
1)]; /*!< Table where the elements id Tags are listed */
UCHAR chMapping[((8) * 2)]; /*!< Table of MPEG canonical order to bitstream
channel order mapping. */
AUDIO_CHANNEL_TYPE channelType[(8)]; /*!< Audio channel type of each output audio channel (from 0 upto numChannels). */
UCHAR channelIndices[(8)]; /*!< Audio channel index for each output audio channel (from 0 upto numChannels). */
/* See ISO/IEC 13818-7:2005(E), 8.5.3.2 Explicit channel mapping using a program_config_element() */
AUDIO_CHANNEL_TYPE channelType[(8)]; /*!< Audio channel type of each output
audio channel (from 0 upto
numChannels). */
UCHAR channelIndices[(8)]; /*!< Audio channel index for each output audio
channel (from 0 upto numChannels). */
/* See ISO/IEC 13818-7:2005(E), 8.5.3.2 Explicit channel mapping using a
* program_config_element() */
FDK_channelMapDescr mapDescr; /*!< Describes the output channel mapping. */
UCHAR chMapIndex; /*!< Index to access one line of the channelOutputMapping
table. This is required because not all 8 channel
configurations have the same output mapping. */
INT sbrDataLen; /*!< Expected length of the SBR remaining in bitbuffer after
the AAC payload has been pared. */
const UCHAR (*channelOutputMapping)[8]; /*!< Table for MPEG canonical order to output channel order mapping. */
UCHAR chMapIndex; /*!< Index to access one line of the channelOutputMapping table. This is required
because not all 8 channel configurations have the same output mapping. */
CProgramConfig pce;
CStreamInfo
streamInfo; /*!< Pointer to StreamInfo data (read from the bitstream) */
CAacDecoderChannelInfo
*pAacDecoderChannelInfo[(8)]; /*!< Temporal channel memory */
CAacDecoderStaticChannelInfo
*pAacDecoderStaticChannelInfo[(8)]; /*!< Persistent channel memory */
CProgramConfig pce;
CStreamInfo streamInfo; /*!< pointer to StreamInfo data (read from the bitstream) */
CAacDecoderChannelInfo *pAacDecoderChannelInfo[(8)]; /*!< Temporal channel memory */
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[(8)]; /*!< Persistent channel memory */
FIXP_DBL *workBufferCore2;
PCM_DEC *pTimeData2;
INT timeData2Size;
CAacDecoderCommonData aacCommonData; /*!< Temporal shared data for all channels hooked into pAacDecoderChannelInfo */
CpePersistentData *cpeStaticData[(
3 * ((8) * 2) + (((8) * 2)) / 2 + 4 * (1) +
1)]; /*!< Pointer to persistent data shared by both channels of a CPE.
This structure is allocated once for each CPE. */
CConcealParams concealCommonData;
CConcealParams concealCommonData;
CConcealmentMethod concealMethodUser;
INT aacChannelsPrev; /*!< The amount of AAC core channels of the last successful decode call. */
AUDIO_CHANNEL_TYPE channelTypePrev[(8)]; /*!< Array holding the channelType values of the last successful decode call. */
UCHAR channelIndicesPrev[(8)]; /*!< Array holding the channelIndices values of the last successful decode call. */
CUsacCoreExtensions usacCoreExt; /*!< Data and handles to extend USAC FD/LPD
core decoder (SBR, MPS, ...) */
UINT numUsacElements[(1 * 1)];
UCHAR usacStereoConfigIndex[(3 * ((8) * 2) + (((8) * 2)) / 2 + 4 * (1) + 1)];
const CSUsacConfig *pUsacConfig[(1 * 1)];
INT nbDiv; /*!< number of frame divisions in LPD-domain */
UCHAR useLdQmfTimeAlign;
HANDLE_SBRDECODER hSbrDecoder; /*!< SBR decoder handle. */
UCHAR sbrEnabled; /*!< flag to store if SBR has been detected */
UCHAR sbrEnabledPrev; /*!< flag to store if SBR has been detected from previous frame */
UCHAR psPossible; /*!< flag to store if PS is possible */
SBR_PARAMS sbrParams; /*!< struct to store all sbr parameters */
INT aacChannelsPrev; /*!< The amount of AAC core channels of the last
successful decode call. */
AUDIO_CHANNEL_TYPE channelTypePrev[(8)]; /*!< Array holding the channelType
values of the last successful
decode call. */
UCHAR
channelIndicesPrev[(8)]; /*!< Array holding the channelIndices values of
the last successful decode call. */
QMF_MODE qmfModeCurr; /*!< The current QMF mode */
QMF_MODE qmfModeUser; /*!< The QMF mode requested by the library user */
UCHAR
downscaleFactor; /*!< Variable to store a supported ELD downscale factor
of 1, 2, 3 or 4 */
UCHAR downscaleFactorInBS; /*!< Variable to store the (not necessarily
supported) ELD downscale factor discovered in
the bitstream */
HANDLE_AAC_DRC hDrcInfo; /*!< handle to DRC data structure */
HANDLE_SBRDECODER hSbrDecoder; /*!< SBR decoder handle. */
UCHAR sbrEnabled; /*!< flag to store if SBR has been detected */
UCHAR sbrEnabledPrev; /*!< flag to store if SBR has been detected from
previous frame */
UCHAR psPossible; /*!< flag to store if PS is possible */
SBR_PARAMS sbrParams; /*!< struct to store all sbr parameters */
UCHAR *pDrmBsBuffer; /*!< Pointer to dynamic buffer which is used to reverse
the bits of the DRM SBR payload */
USHORT drmBsBufferSize; /*!< Size of the dynamic buffer which is used to
reverse the bits of the DRM SBR payload */
FDK_QMF_DOMAIN
qmfDomain; /*!< Instance of module for QMF domain data handling */
CAncData ancData; /*!< structure to handle ancillary data */
QMF_MODE qmfModeCurr; /*!< The current QMF mode */
QMF_MODE qmfModeUser; /*!< The QMF mode requested by the library user */
HANDLE_PCM_DOWNMIX hPcmUtils; /*!< privat data for the PCM utils. */
TDLimiterPtr hLimiter; /*!< Handle of time domain limiter. */
UCHAR limiterEnableUser; /*!< The limiter configuration requested by the library user */
UCHAR limiterEnableCurr; /*!< The current limiter configuration. */
HANDLE_AAC_DRC hDrcInfo; /*!< handle to DRC data structure */
INT metadataExpiry; /*!< Metadata expiry time in milli-seconds. */
FIXP_DBL extGain[1]; /*!< Gain that must be applied to the output signal. */
UINT extGainDelay; /*!< Delay that must be accounted for extGain. */
void *pMpegSurroundDecoder; /*!< pointer to mpeg surround decoder structure */
UCHAR mpsEnableUser; /*!< MPS enable user flag */
UCHAR mpsEnableCurr; /*!< MPS enable decoder state */
UCHAR mpsApplicable; /*!< MPS applicable */
SCHAR mpsOutputMode; /*!< setting: normal = 0, binaural = 1, stereo = 2, 5.1ch
= 3 */
INT mpsOutChannelsLast; /*!< The amount of channels returned by the last
successful MPS decoder call. */
INT mpsFrameSizeLast; /*!< The frame length returned by the last successful
MPS decoder call. */
INT_PCM pcmOutputBuffer[(8)*(2048)];
CAncData ancData; /*!< structure to handle ancillary data */
HANDLE_PCM_DOWNMIX hPcmUtils; /*!< privat data for the PCM utils. */
TDLimiterPtr hLimiter; /*!< Handle of time domain limiter. */
UCHAR limiterEnableUser; /*!< The limiter configuration requested by the
library user */
UCHAR limiterEnableCurr; /*!< The current limiter configuration. */
FIXP_DBL extGain[1]; /*!< Gain that must be applied to the output signal. */
UINT extGainDelay; /*!< Delay that must be accounted for extGain. */
INT_PCM pcmOutputBuffer[(8) * (1024 * 2)];
HANDLE_DRC_DECODER hUniDrcDecoder;
UCHAR multibandDrcPresent;
UCHAR numTimeSlots;
UINT loudnessInfoSetPosition[3];
SCHAR defaultTargetLoudness;
INT_PCM
*pTimeDataFlush[((8) * 2)]; /*!< Pointer to the flushed time data which
will be used for the crossfade in case of
an USAC DASH IPF config change */
UCHAR flushStatus; /*!< Indicates flush status: on|off */
SCHAR flushCnt; /*!< Flush frame counter */
UCHAR buildUpStatus; /*!< Indicates build up status: on|off */
SCHAR buildUpCnt; /*!< Build up frame counter */
UCHAR hasAudioPreRoll; /*!< Indicates preRoll status: on|off */
UINT prerollAULength[AACDEC_MAX_NUM_PREROLL_AU + 1]; /*!< Relative offset of
the prerollAU end
position to the AU
start position in the
bitstream */
INT accessUnit; /*!< Number of the actual processed preroll accessUnit */
UCHAR applyCrossfade; /*!< if set crossfade for seamless stream switching is
applied */
FDK_SignalDelay usacResidualDelay; /*!< Delay residual signal to compensate
for eSBR delay of DMX signal in case of
stereoConfigIndex==2. */
};
#define AAC_DEBUG_EXTHLP "\
#define AAC_DEBUG_EXTHLP \
"\
--- AAC-Core ---\n\
0x00010000 Header data\n\
0x00020000 CRC data\n\
@ -272,7 +388,8 @@ void CAacDecoder_SignalInterruption(HANDLE_AACDECODER self);
\return Error code
*/
AAC_DECODER_ERROR CAacDecoder_AncDataInit(CAncData *ancData, unsigned char *buffer, int size);
AAC_DECODER_ERROR CAacDecoder_AncDataInit(CAncData *ancData,
unsigned char *buffer, int size);
/*!
\brief Get one ancillary data element
@ -280,20 +397,22 @@ AAC_DECODER_ERROR CAacDecoder_AncDataInit(CAncData *ancData, unsigned char *buff
\ancData Pointer to ancillary data structure
\index Index of the anc data element to get
\ptr Pointer to a buffer receiving a pointer to the requested anc data element
\size Pointer to a buffer receiving the length of the requested anc data element
\size Pointer to a buffer receiving the length of the requested anc data
element
\return Error code
*/
AAC_DECODER_ERROR CAacDecoder_AncDataGet(CAncData *ancData, int index, unsigned char **ptr, int *size);
AAC_DECODER_ERROR CAacDecoder_AncDataGet(CAncData *ancData, int index,
unsigned char **ptr, int *size);
/* initialization of aac decoder */
LINKSPEC_H HANDLE_AACDECODER CAacDecoder_Open(TRANSPORT_TYPE bsFormat);
/* Initialization of stream-info elements */
/* Initialization of channel elements */
LINKSPEC_H AAC_DECODER_ERROR CAacDecoder_Init(HANDLE_AACDECODER self,
const CSAudioSpecificConfig *asc);
const CSAudioSpecificConfig *asc,
UCHAR configMode,
UCHAR *configChanged);
/*!
\brief Decodes one aac frame
@ -308,18 +427,39 @@ LINKSPEC_H AAC_DECODER_ERROR CAacDecoder_Init(HANDLE_AACDECODER self,
\return error status
*/
LINKSPEC_H AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
HANDLE_AACDECODER self,
const UINT flags,
INT_PCM *pTimeData,
const INT timeDataSize,
const INT interleaved
);
HANDLE_AACDECODER self, const UINT flags, FIXP_PCM *pTimeData,
const INT timeDataSize, const int timeDataChannelOffset);
/* Free config dependent AAC memory */
LINKSPEC_H AAC_DECODER_ERROR CAacDecoder_FreeMem(HANDLE_AACDECODER self,
const int subStreamIndex);
/* Prepare crossfade for USAC DASH IPF config change */
LINKSPEC_H AAC_DECODER_ERROR CAacDecoder_PrepareCrossFade(
const INT_PCM *pTimeData, INT_PCM **pTimeDataFlush, const INT numChannels,
const INT frameSize, const INT interleaved);
/* Apply crossfade for USAC DASH IPF config change */
LINKSPEC_H AAC_DECODER_ERROR CAacDecoder_ApplyCrossFade(
INT_PCM *pTimeData, INT_PCM **pTimeDataFlush, const INT numChannels,
const INT frameSize, const INT interleaved);
/* Set flush and build up mode */
LINKSPEC_H AAC_DECODER_ERROR CAacDecoder_CtrlCFGChange(HANDLE_AACDECODER self,
UCHAR flushStatus,
SCHAR flushCnt,
UCHAR buildUpStatus,
SCHAR buildUpCnt);
/* Parse preRoll Extension Payload */
LINKSPEC_H AAC_DECODER_ERROR CAacDecoder_PreRollExtensionPayloadParse(
HANDLE_AACDECODER self, UINT *numPrerollAU, UINT *prerollAUOffset,
UINT *prerollAULength);
/* Destroy aac decoder */
LINKSPEC_H void CAacDecoder_Close ( HANDLE_AACDECODER self );
LINKSPEC_H void CAacDecoder_Close(HANDLE_AACDECODER self);
/* get streaminfo handle from decoder */
LINKSPEC_H CStreamInfo* CAacDecoder_GetStreamInfo ( HANDLE_AACDECODER self );
LINKSPEC_H CStreamInfo *CAacDecoder_GetStreamInfo(HANDLE_AACDECODER self);
#endif /* #ifndef AACDECODER_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,16 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/******************************** Fraunhofer IIS ***************************
/**************************** AAC decoder library ******************************
Author(s): Arthur Tritthart
Description: (ARM optimised) Scaling of spectral data
******************************************************************************/
*******************************************************************************/
#define FUNCTION_CBlock_ScaleSpectralData_func1
@ -97,26 +107,20 @@ amm-info@iis.fraunhofer.de
loop overhead per sample, that goes down to 1-cycle per sample
with an optimal 4x-loop construct (do - 4x - while).
*/
FDK_INLINE static void CBlock_ScaleSpectralData_func1(
FIXP_DBL *pSpectrum,
int max_band,
const SHORT * RESTRICT BandOffsets,
int SpecScale_window,
const SHORT * RESTRICT pSfbScale,
int window)
{
static inline void CBlock_ScaleSpectralData_func1(
FIXP_DBL *pSpectrum, int maxSfbs, const SHORT *RESTRICT BandOffsets,
int SpecScale_window, const SHORT *RESTRICT pSfbScale, int window) {
int band_offset = 0;
for (int band=0; band < max_band; band++)
{
for (int band = 0; band < maxSfbs; band++) {
int runs = band_offset;
band_offset = BandOffsets[band+1];
runs = band_offset - runs; /* is always a multiple of 4 */
int scale = SpecScale_window-pSfbScale[window*16+band];
if (scale)
{
do
{
band_offset = BandOffsets[band + 1];
runs = band_offset - runs; /* is always a multiple of 4 */
FDK_ASSERT((runs & 3) == 0);
int scale =
fMin(DFRACT_BITS - 1, SpecScale_window - pSfbScale[window * 16 + band]);
if (scale) {
do {
FIXP_DBL tmp0, tmp1, tmp2, tmp3;
tmp0 = pSpectrum[0];
tmp1 = pSpectrum[1];
@ -130,11 +134,9 @@ FDK_INLINE static void CBlock_ScaleSpectralData_func1(
*pSpectrum++ = tmp1;
*pSpectrum++ = tmp2;
*pSpectrum++ = tmp3;
} while ((runs = runs-4) != 0);
}
else
{
pSpectrum+= runs;
} while ((runs = runs - 4) != 0);
} else {
pSpectrum += runs;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,14 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
/**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl
Description: long/short-block decoding
******************************************************************************/
*******************************************************************************/
#ifndef BLOCK_H
#define BLOCK_H
@ -97,25 +109,19 @@ amm-info@iis.fraunhofer.de
#include "FDK_bitstream.h"
/* PNS (of block) */
void CPns_Read (CPnsData *pPnsData,
HANDLE_FDK_BITSTREAM bs,
const CodeBookDescription *hcb,
SHORT *pScaleFactor,
UCHAR global_gain,
int band,
int group);
void CPns_Apply (const CPnsData *pPnsData,
const CIcsInfo *pIcsInfo,
SPECTRAL_PTR pSpectrum,
const SHORT *pSpecScale,
const SHORT *pScaleFactor,
const SamplingRateInfo *pSamplingRateInfo,
const INT granuleLength,
const int channel);
void CPns_Read(CPnsData *pPnsData, HANDLE_FDK_BITSTREAM bs,
const CodeBookDescription *hcb, SHORT *pScaleFactor,
UCHAR global_gain, int band, int group);
void CPns_Apply(const CPnsData *pPnsData, const CIcsInfo *pIcsInfo,
SPECTRAL_PTR pSpectrum, const SHORT *pSpecScale,
const SHORT *pScaleFactor,
const SamplingRateInfo *pSamplingRateInfo,
const INT granuleLength, const int channel);
void CBlock_ApplyNoise(CAacDecoderChannelInfo *pAacDecoderChannelInfo,
SamplingRateInfo *pSamplingRateInfo, ULONG *nfRandomSeed,
UCHAR *band_is_noise);
/* TNS (of block) */
/*!
@ -126,28 +132,21 @@ void CPns_Apply (const CPnsData *pPnsData,
\return none
*/
void CTns_ReadDataPresentFlag(HANDLE_FDK_BITSTREAM bs,
CTnsData *pTnsData);
void CTns_ReadDataPresentFlag(HANDLE_FDK_BITSTREAM bs, CTnsData *pTnsData);
void CTns_ReadDataPresentUsac(
HANDLE_FDK_BITSTREAM hBs,
CTnsData *pTnsData0,
CTnsData *pTnsData1,
const CIcsInfo *pIcsInfo,
const UINT flags,
const int fCommonWindow
);
void CTns_ReadDataPresentUsac(HANDLE_FDK_BITSTREAM hBs, CTnsData *pTnsData0,
CTnsData *pTnsData1, UCHAR *ptns_on_lr,
const CIcsInfo *pIcsInfo, const UINT flags,
const UINT elFlags, const int fCommonWindow);
AAC_DECODER_ERROR CTns_Read(HANDLE_FDK_BITSTREAM bs,
CTnsData *pTnsData,
const CIcsInfo *pIcsInfo,
const UINT flags);
AAC_DECODER_ERROR CTns_Read(HANDLE_FDK_BITSTREAM bs, CTnsData *pTnsData,
const CIcsInfo *pIcsInfo, const UINT flags);
void CTns_Apply ( CTnsData *RESTRICT pTnsData, /*!< pointer to aac decoder info */
const CIcsInfo *pIcsInfo,
SPECTRAL_PTR pSpectralCoefficient,
const SamplingRateInfo *pSamplingRateInfo,
const INT granuleLength);
void CTns_Apply(CTnsData *RESTRICT pTnsData, /*!< pointer to aac decoder info */
const CIcsInfo *pIcsInfo, SPECTRAL_PTR pSpectralCoefficient,
const SamplingRateInfo *pSamplingRateInfo,
const INT granuleLength, const UCHAR nbands,
const UCHAR igf_active, const UINT flags);
/* Block */
@ -155,17 +154,16 @@ LONG CBlock_GetEscape(HANDLE_FDK_BITSTREAM bs, const LONG q);
/**
* \brief Read scale factor data. See chapter 4.6.2.3.2 of ISO/IEC 14496-3.
* The SF_OFFSET = 100 value referenced in chapter 4.6.2.3.3 is already substracted
* from the scale factor values. Also includes PNS data reading.
* The SF_OFFSET = 100 value referenced in chapter 4.6.2.3.3 is already
* substracted from the scale factor values. Also includes PNS data reading.
* \param bs bit stream handle data source
* \param pAacDecoderChannelInfo channel context info were decoded data is stored into.
* \param pAacDecoderChannelInfo channel context info were decoded data is
* stored into.
* \param flags the decoder flags.
*/
AAC_DECODER_ERROR CBlock_ReadScaleFactorData(
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
HANDLE_FDK_BITSTREAM bs,
const UINT flags
);
CAacDecoderChannelInfo *pAacDecoderChannelInfo, HANDLE_FDK_BITSTREAM bs,
const UINT flags);
/**
* \brief Read Huffman encoded spectral data.
@ -173,111 +171,124 @@ AAC_DECODER_ERROR CBlock_ReadScaleFactorData(
* \param pSamplingRateInfo sampling rate info (sfb offsets).
* \param flags syntax flags.
*/
AAC_DECODER_ERROR CBlock_ReadSpectralData(HANDLE_FDK_BITSTREAM bs,
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
const SamplingRateInfo *pSamplingRateInfo,
const UINT flags);
AAC_DECODER_ERROR CBlock_ReadSectionData(HANDLE_FDK_BITSTREAM bs,
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
const SamplingRateInfo *pSamplingRateInfo,
const UINT flags);
AAC_DECODER_ERROR CBlock_ReadSpectralData(
HANDLE_FDK_BITSTREAM bs, CAacDecoderChannelInfo *pAacDecoderChannelInfo,
const SamplingRateInfo *pSamplingRateInfo, const UINT flags);
/**
* \brief find a common exponent (shift factor) for all sfb in each Spectral window, and store them into
* CAacDecoderChannelInfo::specScale.
* \brief Read Arithmetic encoded spectral data.
* \param pAacDecoderChannelInfo channel context info.
* \param pAacDecoderStaticChannelInfo static channel context info.
* \param pSamplingRateInfo sampling rate info (sfb offsets).
* \param frame_length spectral window length.
* \param flags syntax flags.
* \return error code.
*/
AAC_DECODER_ERROR CBlock_ReadAcSpectralData(
HANDLE_FDK_BITSTREAM hBs, CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
const SamplingRateInfo *pSamplingRateInfo, const UINT frame_length,
const UINT flags);
AAC_DECODER_ERROR CBlock_ReadSectionData(
HANDLE_FDK_BITSTREAM bs, CAacDecoderChannelInfo *pAacDecoderChannelInfo,
const SamplingRateInfo *pSamplingRateInfo, const UINT flags);
/**
* \brief find a common exponent (shift factor) for all sfb in each Spectral
* window, and store them into CAacDecoderChannelInfo::specScale.
* \param pAacDecoderChannelInfo channel context info.
* \param UCHAR maxSfbs maximum number of SFBs to be processed (might differ
* from pAacDecoderChannelInfo->icsInfo.MaxSfBands)
* \param pSamplingRateInfo sampling rate info (sfb offsets).
*/
void CBlock_ScaleSpectralData(CAacDecoderChannelInfo *pAacDecoderChannelInfo, SamplingRateInfo *pSamplingRateInfo);
void CBlock_ScaleSpectralData(CAacDecoderChannelInfo *pAacDecoderChannelInfo,
UCHAR maxSfbs,
SamplingRateInfo *pSamplingRateInfo);
/**
* \brief Apply TNS and PNS tools.
*/
void ApplyTools ( CAacDecoderChannelInfo *pAacDecoderChannelInfo[],
const SamplingRateInfo *pSamplingRateInfo,
const UINT flags,
const int channel );
void ApplyTools(CAacDecoderChannelInfo *pAacDecoderChannelInfo[],
const SamplingRateInfo *pSamplingRateInfo, const UINT flags,
const UINT elFlags, const int channel, const int maybe_jstereo);
/**
* \brief Transform MDCT spectral data into time domain
*/
void CBlock_FrequencyToTime(CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
INT_PCM outSamples[],
const SHORT frameLen,
const int stride,
const int frameOk,
FIXP_DBL *pWorkBuffer1);
void CBlock_FrequencyToTime(
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
CAacDecoderChannelInfo *pAacDecoderChannelInfo, FIXP_PCM outSamples[],
const SHORT frameLen, const int frameOk, FIXP_DBL *pWorkBuffer1,
UINT elFlags, INT elCh);
/**
* \brief Transform double lapped MDCT (AAC-ELD) spectral data into time domain.
*/
void CBlock_FrequencyToTimeLowDelay(CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
INT_PCM outSamples[],
const short frameLen,
const char stride);
void CBlock_FrequencyToTimeLowDelay(
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
CAacDecoderChannelInfo *pAacDecoderChannelInfo, FIXP_PCM outSamples[],
const short frameLen);
AAC_DECODER_ERROR CBlock_InverseQuantizeSpectralData(CAacDecoderChannelInfo *pAacDecoderChannelInfo, SamplingRateInfo *pSamplingRateInfo);
AAC_DECODER_ERROR CBlock_InverseQuantizeSpectralData(
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
SamplingRateInfo *pSamplingRateInfo, UCHAR *band_is_noise,
UCHAR active_band_search);
/**
* \brief Calculate 2^(lsb/4) * value^(4/3)
* \param pValue pointer to quantized value. The inverse quantized result is stored back here.
* \param lsb 2 LSBs of the scale factor (scaleFactor % 4) applied as power 2 factor to the
* resulting inverse quantized value.
* \param pValue pointer to quantized value. The inverse quantized result is
* stored back here.
* \param lsb 2 LSBs of the scale factor (scaleFactor % 4) applied as power 2
* factor to the resulting inverse quantized value.
* \return the exponent of the result (mantissa) stored into *pValue.
*/
FDK_INLINE
int EvaluatePower43 ( FIXP_DBL *pValue,
UINT lsb )
{
int EvaluatePower43(FIXP_DBL *pValue, UINT lsb) {
FIXP_DBL value;
UINT freeBits;
UINT exponent;
value = *pValue;
freeBits = fNormz (value) ;
exponent = DFRACT_BITS - freeBits ;
FDK_ASSERT (exponent < 14);
freeBits = fNormz(value);
exponent = DFRACT_BITS - freeBits;
FDK_ASSERT(exponent < 14);
UINT x = (((int)value << freeBits) >> 19) ;
UINT tableIndex = (x & 0x0FFF) >> 4 ;
FIXP_DBL invQVal ;
UINT x = (((int)value << freeBits) >> 19);
UINT tableIndex = (x & 0x0FFF) >> 4;
FIXP_DBL invQVal;
x = x & 0x0F;
UINT r0=(LONG)InverseQuantTable [tableIndex+0];
UINT r1=(LONG)InverseQuantTable [tableIndex+1];
USHORT nx=16-x;
UINT temp=(r0)*nx+(r1)*x;
UINT r0 = (LONG)InverseQuantTable[tableIndex + 0];
UINT r1 = (LONG)InverseQuantTable[tableIndex + 1];
USHORT nx = 16 - x;
UINT temp = (r0)*nx + (r1)*x;
invQVal = (FIXP_DBL)temp;
FDK_ASSERT(lsb < 4);
*pValue = fMultDiv2 (invQVal, MantissaTable [lsb][exponent]) ;
*pValue = fMultDiv2(invQVal, MantissaTable[lsb][exponent]);
/* + 1 compensates fMultDiv2(). */
return ExponentTable [lsb][exponent] + 1;
return ExponentTable[lsb][exponent] + 1;
}
/* Recalculate gain */
FIXP_DBL get_gain(const FIXP_DBL *x, const FIXP_DBL *y, int n);
/**
* \brief determine the required shift scale for the given quantized value and scale (factor % 4) value.
* \brief determine the required shift scale for the given quantized value and
* scale (factor % 4) value.
*/
FDK_INLINE int GetScaleFromValue (FIXP_DBL value, unsigned int lsb)
{
if (value!=(FIXP_DBL)0)
{
int scale = EvaluatePower43 (&value, lsb) ;
return CntLeadingZeros (value) - scale - 2 ;
}
else
return 0; /* Return zero, because its useless to scale a zero value, saves workload and avoids scaling overshifts. */
FDK_INLINE int GetScaleFromValue(FIXP_DBL value, unsigned int lsb) {
if (value != (FIXP_DBL)0) {
int scale = EvaluatePower43(&value, lsb);
return CntLeadingZeros(value) - scale - 2;
} else
return 0; /* Return zero, because its useless to scale a zero value, saves
workload and avoids scaling overshifts. */
}
//#ifdef AACDEC_HUFFMANDECODER_ENABLE
/*!
\brief Read huffman codeword
@ -286,27 +297,24 @@ FDK_INLINE int GetScaleFromValue (FIXP_DBL value, unsigned int lsb)
\return index value
*/
inline int CBlock_DecodeHuffmanWord( HANDLE_FDK_BITSTREAM bs, /*!< pointer to bitstream */
const CodeBookDescription *hcb ) /*!< pointer to codebook description */
inline int CBlock_DecodeHuffmanWord(
HANDLE_FDK_BITSTREAM bs, /*!< pointer to bitstream */
const CodeBookDescription *hcb) /*!< pointer to codebook description */
{
UINT val;
UINT index = 0;
const USHORT (*CodeBook) [HuffmanEntries] = hcb->CodeBook;
const USHORT(*CodeBook)[HuffmanEntries] = hcb->CodeBook;
while (1)
{
val = CodeBook[index][FDKreadBits(bs,HuffmanBits)]; /* Expensive memory access */
while (1) {
val = CodeBook[index]
[FDKreadBits(bs, HuffmanBits)]; /* Expensive memory access */
if ((val & 1) == 0)
{
index = val>>2;
if ((val & 1) == 0) {
index = val >> 2;
continue;
}
else
{
if (val & 2)
{
FDKpushBackCache(bs,1);
} else {
if (val & 2) {
FDKpushBackCache(bs, 1);
}
val >>= 2;
@ -316,7 +324,22 @@ inline int CBlock_DecodeHuffmanWord( HANDLE_FDK_BITSTREAM bs,
return val;
}
inline int CBlock_DecodeHuffmanWordCB(
HANDLE_FDK_BITSTREAM bs, /*!< pointer to bitstream */
const USHORT (
*CodeBook)[HuffmanEntries]) /*!< pointer to codebook description */
{
UINT index = 0;
//#endif /* AACDEC_HUFFMANDECODER_ENABLE */
while (1) {
index = CodeBook[index][FDKread2Bits(bs)]; /* Expensive memory access */
if (index & 1) break;
index >>= 2;
}
if (index & 2) {
FDKpushBackCache(bs, 1);
}
return index >> 2;
}
#endif /* #ifndef BLOCK_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,46 +90,48 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
/**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl
Description:
******************************************************************************/
*******************************************************************************/
#ifndef CHANNEL_H
#define CHANNEL_H
#include "common_fix.h"
#include "FDK_bitstream.h"
#include "FDK_tools_rom.h"
#include "channelinfo.h"
#include "tpdec_lib.h"
/**
* \brief Init codeBook SFB indices (section data) with HCB_ESC. Useful for bitstreams
* which do not have any section data, but still SFB's (scale factor bands). This has
* the effect that upto the amount of transmitted SFB are treated as non-zero.
* \param pAacDecoderChannelInfo channel info structure containing a valid icsInfo struct.
* \brief Init codeBook SFB indices (section data) with HCB_ESC. Useful for
* bitstreams which do not have any section data, but still SFB's (scale factor
* bands). This has the effect that upto the amount of transmitted SFB are
* treated as non-zero.
* \param pAacDecoderChannelInfo channel info structure containing a valid
* icsInfo struct.
*/
void CChannel_CodebookTableInit(CAacDecoderChannelInfo *pAacDecoderChannelInfo);
/**
* \brief decode a channel element. To be called after CChannelElement_Read()
* \param pAacDecoderChannelInfo pointer to channel data struct. Depending on el_channels either one or two.
* \param pAacDecoderChannelInfo pointer to channel data struct. Depending on
* el_channels either one or two.
* \param pSamplingRateInfo pointer to sample rate information structure
* \param el_channels amount of channels of the element to be decoded.
* \param output pointer to time domain output buffer (ACELP)
* \param stride factor for accessing output
*/
void CChannelElement_Decode ( CAacDecoderChannelInfo *pAacDecoderChannelInfo[2],
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[2],
SamplingRateInfo *pSamplingRateInfo,
UINT flags,
int el_channels );
void CChannelElement_Decode(
CAacDecoderChannelInfo *pAacDecoderChannelInfo[2],
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[2],
SamplingRateInfo *pSamplingRateInfo, UINT flags, UINT elFlags,
int el_channels);
/**
* \brief Read channel element of given type from bitstream.
@ -126,23 +139,22 @@ void CChannelElement_Decode ( CAacDecoderChannelInfo *pAacDecoderChannelInfo[2],
* \param pAacDecoderChannelInfo pointer array to store channel information.
* \param aot Audio Object Type
* \param pSamplingRateInfo sampling rate info table.
* \param flags parser guidance flags
* \param numberOfChannels amoun of channels contained in the object to be parsed.
* \param epConfig the current epConfig value obtained from the Audio Specific Config.
* \param flags common parser guidance flags
* \param elFlags element specific parser guidance flags
* \param numberOfChannels amoun of channels contained in the object to be
* parsed.
* \param epConfig the current epConfig value obtained from the Audio Specific
* Config.
* \param pTp transport decoder handle required for ADTS CRC checking.
* ...
* \return an AAC_DECODER_ERROR error code.
*/
AAC_DECODER_ERROR CChannelElement_Read(HANDLE_FDK_BITSTREAM hBs,
CAacDecoderChannelInfo *pAacDecoderChannelInfo[],
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[],
const AUDIO_OBJECT_TYPE aot,
const SamplingRateInfo *pSamplingRateInfo,
const UINT flags,
const UINT frame_length,
const UCHAR numberOfChannels,
const SCHAR epConfig,
HANDLE_TRANSPORTDEC pTpDec
);
AAC_DECODER_ERROR CChannelElement_Read(
HANDLE_FDK_BITSTREAM hBs, CAacDecoderChannelInfo *pAacDecoderChannelInfo[],
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[],
const AUDIO_OBJECT_TYPE aot, SamplingRateInfo *pSamplingRateInfo,
const UINT flags, const UINT elFlags, const UINT frame_length,
const UCHAR numberOfChannels, const SCHAR epConfig,
HANDLE_TRANSPORTDEC pTpDec);
#endif /* #ifndef CHANNEL_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,27 +90,23 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
/**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl
Description: individual channel stream info
******************************************************************************/
*******************************************************************************/
#include "channelinfo.h"
#include "aac_rom.h"
#include "aac_ram.h"
#include "FDK_bitstream.h"
AAC_DECODER_ERROR IcsReadMaxSfb (
HANDLE_FDK_BITSTREAM bs,
CIcsInfo *pIcsInfo,
const SamplingRateInfo *pSamplingRateInfo
)
{
AAC_DECODER_ERROR IcsReadMaxSfb(HANDLE_FDK_BITSTREAM bs, CIcsInfo *pIcsInfo,
const SamplingRateInfo *pSamplingRateInfo) {
AAC_DECODER_ERROR ErrorStatus = AAC_DEC_OK;
int nbits;
@ -110,36 +117,31 @@ AAC_DECODER_ERROR IcsReadMaxSfb (
nbits = 4;
pIcsInfo->TotalSfBands = pSamplingRateInfo->NumberOfScaleFactorBands_Short;
}
pIcsInfo->MaxSfBands = (UCHAR) FDKreadBits(bs, nbits);
pIcsInfo->MaxSfBands = (UCHAR)FDKreadBits(bs, nbits);
if (pIcsInfo->MaxSfBands > pIcsInfo->TotalSfBands){
if (pIcsInfo->MaxSfBands > pIcsInfo->TotalSfBands) {
ErrorStatus = AAC_DEC_PARSE_ERROR;
}
return ErrorStatus;
}
AAC_DECODER_ERROR IcsRead(HANDLE_FDK_BITSTREAM bs,
CIcsInfo *pIcsInfo,
const SamplingRateInfo* pSamplingRateInfo,
const UINT flags)
{
AAC_DECODER_ERROR IcsRead(HANDLE_FDK_BITSTREAM bs, CIcsInfo *pIcsInfo,
const SamplingRateInfo *pSamplingRateInfo,
const UINT flags) {
AAC_DECODER_ERROR ErrorStatus = AAC_DEC_OK;
pIcsInfo->Valid = 0;
if (flags & AC_ELD){
pIcsInfo->WindowSequence = OnlyLongSequence;
if (flags & AC_ELD) {
pIcsInfo->WindowSequence = BLOCK_LONG;
pIcsInfo->WindowShape = 0;
}
else {
if ( !(flags & (AC_USAC|AC_RSVD50)) ) {
FDKreadBits(bs,1);
} else {
if (!(flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA))) {
FDKreadBits(bs, 1);
}
pIcsInfo->WindowSequence = (UCHAR) FDKreadBits(bs,2);
pIcsInfo->WindowShape = (UCHAR) FDKreadBits(bs,1);
pIcsInfo->WindowSequence = (BLOCK_TYPE)FDKreadBits(bs, 2);
pIcsInfo->WindowShape = (UCHAR)FDKreadBits(bs, 1);
if (flags & AC_LD) {
if (pIcsInfo->WindowShape) {
pIcsInfo->WindowShape = 2; /* select low overlap instead of KBD */
@ -148,8 +150,8 @@ AAC_DECODER_ERROR IcsRead(HANDLE_FDK_BITSTREAM bs,
}
/* Sanity check */
if ( (flags & (AC_ELD|AC_LD)) && pIcsInfo->WindowSequence != OnlyLongSequence) {
pIcsInfo->WindowSequence = OnlyLongSequence;
if ((flags & (AC_ELD | AC_LD)) && pIcsInfo->WindowSequence != BLOCK_LONG) {
pIcsInfo->WindowSequence = BLOCK_LONG;
ErrorStatus = AAC_DEC_PARSE_ERROR;
goto bail;
}
@ -159,11 +161,12 @@ AAC_DECODER_ERROR IcsRead(HANDLE_FDK_BITSTREAM bs,
goto bail;
}
if (IsLongBlock(pIcsInfo))
{
if ( !(flags & (AC_ELD|AC_SCALABLE|AC_BSAC|AC_USAC|AC_RSVD50)) ) /* If not ELD nor Scalable nor BSAC nor USAC syntax then ... */
if (IsLongBlock(pIcsInfo)) {
if (!(flags & (AC_ELD | AC_SCALABLE | AC_BSAC | AC_USAC | AC_RSVD50 |
AC_RSV603DA))) /* If not ELD nor Scalable nor BSAC nor USAC
syntax then ... */
{
if ((UCHAR)FDKreadBits(bs,1) != 0 ) /* UCHAR PredictorDataPresent */
if ((UCHAR)FDKreadBits(bs, 1) != 0) /* UCHAR PredictorDataPresent */
{
ErrorStatus = AAC_DEC_UNSUPPORTED_PREDICTION;
goto bail;
@ -172,45 +175,36 @@ AAC_DECODER_ERROR IcsRead(HANDLE_FDK_BITSTREAM bs,
pIcsInfo->WindowGroups = 1;
pIcsInfo->WindowGroupLength[0] = 1;
}
else
{
} else {
INT i;
UINT mask;
pIcsInfo->ScaleFactorGrouping = (UCHAR) FDKreadBits(bs,7);
pIcsInfo->ScaleFactorGrouping = (UCHAR)FDKreadBits(bs, 7);
pIcsInfo->WindowGroups = 0 ;
pIcsInfo->WindowGroups = 0;
for (i=0; i < (8-1); i++)
{
for (i = 0; i < (8 - 1); i++) {
mask = 1 << (6 - i);
pIcsInfo->WindowGroupLength[i] = 1;
if (pIcsInfo->ScaleFactorGrouping & mask)
{
if (pIcsInfo->ScaleFactorGrouping & mask) {
pIcsInfo->WindowGroupLength[pIcsInfo->WindowGroups]++;
}
else
{
} else {
pIcsInfo->WindowGroups++;
}
}
/* loop runs to i < 7 only */
pIcsInfo->WindowGroupLength[8-1] = 1;
pIcsInfo->WindowGroupLength[8 - 1] = 1;
pIcsInfo->WindowGroups++;
}
bail:
if (ErrorStatus == AAC_DEC_OK)
pIcsInfo->Valid = 1;
if (ErrorStatus == AAC_DEC_OK) pIcsInfo->Valid = 1;
return ErrorStatus;
}
/*
interleave codebooks the following way
@ -224,53 +218,80 @@ bail:
(270w) (271w)
*/
/*
Table entries are sorted as following:
| num_swb_long_window | sfbands_long | num_swb_short_window | sfbands_short |
*/
AAC_DECODER_ERROR getSamplingRateInfo(
SamplingRateInfo *t,
UINT samplesPerFrame,
UINT samplingRateIndex,
UINT samplingRate
)
{
AAC_DECODER_ERROR getSamplingRateInfo(SamplingRateInfo *t, UINT samplesPerFrame,
UINT samplingRateIndex,
UINT samplingRate) {
int index = 0;
/* Search closest samplerate according to ISO/IEC 13818-7:2005(E) 8.2.4 (Table
* 38): */
if ((samplingRateIndex >= 15) || (samplesPerFrame == 768)) {
const UINT borders[] = {(UINT)-1, 92017, 75132, 55426, 46009, 37566,
27713, 23004, 18783, 13856, 11502, 9391};
UINT i, samplingRateSearch = samplingRate;
if (samplesPerFrame == 768) {
samplingRateSearch = (samplingRate * 4) / 3;
}
for (i = 0; i < 11; i++) {
if (borders[i] > samplingRateSearch &&
samplingRateSearch >= borders[i + 1]) {
break;
}
}
samplingRateIndex = i;
}
t->samplingRateIndex = samplingRateIndex;
t->samplingRate = samplingRate;
switch (samplesPerFrame) {
case 1024:
index = 0;
break;
case 960:
index = 1;
break;
case 512:
index = 3;
break;
case 480:
index = 4;
break;
case 1024:
index = 0;
break;
case 960:
index = 1;
break;
case 768:
index = 2;
break;
case 512:
index = 3;
break;
case 480:
index = 4;
break;
default:
default:
return AAC_DEC_UNSUPPORTED_FORMAT;
}
t->ScaleFactorBands_Long =
sfbOffsetTables[index][samplingRateIndex].sfbOffsetLong;
t->ScaleFactorBands_Short =
sfbOffsetTables[index][samplingRateIndex].sfbOffsetShort;
t->NumberOfScaleFactorBands_Long =
sfbOffsetTables[index][samplingRateIndex].numberOfSfbLong;
t->NumberOfScaleFactorBands_Short =
sfbOffsetTables[index][samplingRateIndex].numberOfSfbShort;
if (t->ScaleFactorBands_Long == NULL ||
t->NumberOfScaleFactorBands_Long == 0) {
t->samplingRate = 0;
return AAC_DEC_UNSUPPORTED_FORMAT;
}
t->ScaleFactorBands_Long = sfbOffsetTables[index][samplingRateIndex].sfbOffsetLong;
t->ScaleFactorBands_Short = sfbOffsetTables[index][samplingRateIndex].sfbOffsetShort;
t->NumberOfScaleFactorBands_Long = sfbOffsetTables[index][samplingRateIndex].numberOfSfbLong;
t->NumberOfScaleFactorBands_Short = sfbOffsetTables[index][samplingRateIndex].numberOfSfbShort;
if (t->ScaleFactorBands_Long == NULL || t->NumberOfScaleFactorBands_Long == 0) {
return AAC_DEC_UNSUPPORTED_FORMAT;
}
FDK_ASSERT(t->ScaleFactorBands_Long[t->NumberOfScaleFactorBands_Long] == samplesPerFrame);
FDK_ASSERT(t->ScaleFactorBands_Short == NULL || t->ScaleFactorBands_Short[t->NumberOfScaleFactorBands_Short]*8 == samplesPerFrame);
FDK_ASSERT((UINT)t->ScaleFactorBands_Long[t->NumberOfScaleFactorBands_Long] ==
samplesPerFrame);
FDK_ASSERT(
t->ScaleFactorBands_Short == NULL ||
(UINT)t->ScaleFactorBands_Short[t->NumberOfScaleFactorBands_Short] * 8 ==
samplesPerFrame);
return AAC_DEC_OK;
}

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,14 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
/**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl
Description: individual channel stream info
******************************************************************************/
*******************************************************************************/
#ifndef CHANNELINFO_H
#define CHANNELINFO_H
@ -108,10 +120,21 @@ amm-info@iis.fraunhofer.de
#include "aacdec_hcr_types.h"
#include "rvlc_info.h"
#include "usacdec_acelp.h"
#include "usacdec_const.h"
#include "usacdec_rom.h"
#include "ac_arith_coder.h"
#include "conceal_types.h"
#include "aacdec_drc_types.h"
#include "aacdec_drc_types.h"
#define WB_SECTION_SIZE (1024 * 2)
#define DRM_BS_BUFFER_SIZE \
(512) /* size of the dynamic buffer which is used to reverse the bits of \
the DRM SBR payload */
/* Output rendering mode */
typedef enum {
@ -122,21 +145,11 @@ typedef enum {
AACDEC_RENDER_INTIMDCT
} AACDEC_RENDER_MODE;
enum {
MAX_QUANTIZED_VALUE = 8191
};
enum { MAX_QUANTIZED_VALUE = 8191 };
enum
{
OnlyLongSequence = 0,
LongStartSequence,
EightShortSequence,
LongStopSequence
};
typedef enum { FD_LONG, FD_SHORT, LPD } USAC_COREMODE;
typedef struct
{
typedef struct {
const SHORT *ScaleFactorBands_Long;
const SHORT *ScaleFactorBands_Short;
UCHAR NumberOfScaleFactorBands_Long;
@ -145,200 +158,315 @@ typedef struct
UINT samplingRate;
} SamplingRateInfo;
typedef struct
{
typedef struct {
UCHAR CommonWindow;
UCHAR GlobalGain;
} CRawDataInfo;
typedef struct
{
typedef struct {
UCHAR WindowGroupLength[8];
UCHAR WindowGroups;
UCHAR Valid;
UCHAR WindowShape; /* 0: sine window, 1: KBD, 2: low overlap */
UCHAR WindowSequence; /* See enum above, 0: long, 1: start, 2: short, 3: stop */
UCHAR WindowShape; /* 0: sine window, 1: KBD, 2: low overlap */
BLOCK_TYPE WindowSequence; /* mdct.h; 0: long, 1: start, 2: short, 3: stop */
UCHAR MaxSfBands;
UCHAR max_sfb_ste;
UCHAR ScaleFactorGrouping;
UCHAR TotalSfBands;
} CIcsInfo;
enum
{
enum {
ZERO_HCB = 0,
ESCBOOK = 11,
ESCBOOK = 11,
NSPECBOOKS = ESCBOOK + 1,
BOOKSCL = NSPECBOOKS,
NOISE_HCB = 13,
BOOKSCL = NSPECBOOKS,
NOISE_HCB = 13,
INTENSITY_HCB2 = 14,
INTENSITY_HCB = 15,
INTENSITY_HCB = 15,
LAST_HCB
};
#define TNS_SCALE 3
/* This struct holds the persistent data shared by both channels of a CPE.
It needs to be allocated for each CPE. */
typedef struct {
CJointStereoPersistentData jointStereoPersistentData;
} CpePersistentData;
/*
* This struct must be allocated one for every channel and must be persistent.
*/
typedef struct
{
typedef struct {
FIXP_DBL *pOverlapBuffer;
mdct_t IMdct;
CArcoData *hArCo;
INT pnsCurrentSeed;
CDrcChannelData drcData;
/* LPD memory */
FIXP_DBL old_synth[PIT_MAX_MAX - L_SUBFR];
INT old_T_pf[SYN_SFD];
FIXP_DBL old_gain_pf[SYN_SFD];
FIXP_DBL mem_bpf[L_FILT + L_SUBFR];
UCHAR
old_bpf_control_info; /* (1: enable, 0: disable) bpf for past superframe
*/
USAC_COREMODE last_core_mode; /* core mode used by the decoder in previous
frame. (not signalled by the bitstream, see
CAacDecoderChannelInfo::core_mode_last !! )
*/
UCHAR last_lpd_mode; /* LPD mode used by the decoder in last LPD subframe
(not signalled by the bitstream, see
CAacDecoderChannelInfo::lpd_mode_last !! ) */
UCHAR last_last_lpd_mode; /* LPD mode used in second last LPD subframe
(not signalled by the bitstream) */
UCHAR last_lpc_lost; /* Flag indicating that the previous LPC is lost */
FIXP_LPC
lpc4_lsf[M_LP_FILTER_ORDER]; /* Last LPC4 coefficients in LSF domain. */
FIXP_LPC lsf_adaptive_mean[M_LP_FILTER_ORDER]; /* Adaptive mean of LPC
coefficients in LSF domain
for concealment. */
FIXP_LPC lp_coeff_old[2][M_LP_FILTER_ORDER]; /* Last LPC coefficients in LP
domain. lp_coeff_old[0] is lpc4 (coeffs for
right folding point of last tcx frame),
lp_coeff_old[1] are coeffs for left folding
point of last tcx frame */
INT lp_coeff_old_exp[2];
FIXP_SGL
oldStability; /* LPC coeff stability value from last frame (required for
TCX concealment). */
UINT numLostLpdFrames; /* Number of consecutive lost subframes. */
/* TCX memory */
FIXP_DBL last_tcx_gain;
INT last_tcx_gain_e;
FIXP_DBL last_alfd_gains[32]; /* Scaled by one bit. */
SHORT last_tcx_pitch;
UCHAR last_tcx_noise_factor;
/* ACELP memory */
CAcelpStaticMem acelp;
ULONG nfRandomSeed; /* seed value for USAC noise filling random generator */
CDrcChannelData drcData;
CConcealmentInfo concealmentInfo;
} CAacDecoderStaticChannelInfo;
CpePersistentData *pCpeStaticData;
} CAacDecoderStaticChannelInfo;
/*
* This union must be allocated for every element (up to 2 channels).
*/
typedef struct {
/* Common bit stream data */
SHORT aScaleFactor[(8*16)]; /* Spectral scale factors for each sfb in each window. */
SHORT aSfbScale[(8*16)]; /* could be free after ApplyTools() */
UCHAR aCodeBook[(8*16)]; /* section data: codebook for each window and sfb. */
CTnsData TnsData;
CRawDataInfo RawDataInfo;
SHORT aScaleFactor[(
8 * 16)]; /* Spectral scale factors for each sfb in each window. */
SHORT aSfbScale[(8 * 16)]; /* could be free after ApplyTools() */
UCHAR
aCodeBook[(8 * 16)]; /* section data: codebook for each window and sfb. */
UCHAR band_is_noise[(8 * 16)];
CTnsData TnsData;
CRawDataInfo RawDataInfo;
shouldBeUnion {
struct {
CPulseData PulseData;
SHORT aNumLineInSec4Hcr[MAX_SFB_HCR]; /* needed once for all channels except for Drm syntax */
UCHAR aCodeBooks4Hcr[MAX_SFB_HCR]; /* needed once for all channels except for Drm syntax. Same as "aCodeBook" ? */
SHORT aNumLineInSec4Hcr[MAX_SFB_HCR]; /* needed once for all channels
except for Drm syntax */
UCHAR
aCodeBooks4Hcr[MAX_SFB_HCR]; /* needed once for all channels except for
Drm syntax. Same as "aCodeBook" ? */
SHORT lenOfReorderedSpectralData;
SCHAR lenOfLongestCodeword;
SCHAR numberSection;
SCHAR rvlcCurrentScaleFactorOK;
SCHAR rvlcIntensityUsed;
} aac;
} specificTo;
struct {
UCHAR fd_noise_level_and_offset;
UCHAR tns_active;
UCHAR tns_on_lr;
UCHAR tcx_noise_factor[4];
UCHAR tcx_global_gain[4];
} usac;
}
specificTo;
} CAacDecoderDynamicData;
typedef shouldBeUnion {
CAacDecoderDynamicData pAacDecoderDynamicData[2];
UCHAR DrmBsBuffer[DRM_BS_BUFFER_SIZE];
/* Common signal data, can be used once the bit stream data from above is not used anymore. */
/* Common signal data, can be used once the bit stream data from above is not
* used anymore. */
FIXP_DBL mdctOutTemp[1024];
FIXP_DBL sbrWorkBuffer[1024*2];
} CWorkBufferCore1;
FIXP_DBL synth_buf[(PIT_MAX_MAX + SYN_DELAY + L_FRAME_PLUS)];
FIXP_DBL workBuffer[WB_SECTION_SIZE];
}
CWorkBufferCore1;
/* Common data referenced by all channels */
typedef struct {
CWorkBufferCore1 *workBufferCore1;
FIXP_DBL* workBufferCore2;
CAacDecoderDynamicData pAacDecoderDynamicData[2];
CPnsInterChannelData pnsInterChannelData;
INT pnsCurrentSeed;
INT pnsRandomSeed[(8*16)];
INT pnsRandomSeed[(8 * 16)];
CJointStereoData jointStereoData; /* One for one element */
CJointStereoData jointStereoData; /* One for one element */
shouldBeUnion {
struct {
CErHcrInfo erHcrInfo;
CErRvlcInfo erRvlcInfo;
SHORT aRvlcScfEsc[RVLC_MAX_SFB]; /* needed once for all channels */
SHORT aRvlcScfFwd[RVLC_MAX_SFB]; /* needed once for all channels */
SHORT aRvlcScfBwd[RVLC_MAX_SFB]; /* needed once for all channels */
SHORT aRvlcScfEsc[RVLC_MAX_SFB]; /* needed once for all channels */
SHORT aRvlcScfFwd[RVLC_MAX_SFB]; /* needed once for all channels */
SHORT aRvlcScfBwd[RVLC_MAX_SFB]; /* needed once for all channels */
} aac;
} overlay;
}
overlay;
} CAacDecoderCommonData;
typedef struct {
CWorkBufferCore1 *pWorkBufferCore1;
CCplxPredictionData *cplxPredictionData;
} CAacDecoderCommonStaticData;
/*
* This struct must be allocated one for every channels of every element and must be persistent.
* Among its members, the following memory areas can be overwritten under the given conditions:
* - pSpectralCoefficient The memory pointed to can be overwritten after time signal rendering.
* This struct must be allocated one for every channel of every element and must
* be persistent. Among its members, the following memory areas can be
* overwritten under the given conditions:
* - pSpectralCoefficient The memory pointed to can be overwritten after time
* signal rendering.
* - data can be overwritten after time signal rendering.
* - pDynData memory pointed to can be overwritten after each CChannelElement_Decode() call.
* - pComData->overlay memory pointed to can be overwritten after each CChannelElement_Decode() call..
* - pDynData memory pointed to can be overwritten after each
* CChannelElement_Decode() call.
* - pComData->overlay memory pointed to can be overwritten after each
* CChannelElement_Decode() call..
*/
typedef struct
{
SPECTRAL_PTR pSpectralCoefficient; /* Spectral coefficients of each window */
SHORT specScale[8]; /* Scale shift values of each spectrum window */
CIcsInfo icsInfo;
INT granuleLength; /* Size of smallest spectrum piece */
UCHAR ElementInstanceTag;
AACDEC_RENDER_MODE renderMode; /* Output signal rendering mode */
typedef struct {
shouldBeUnion {
struct {
FIXP_DBL fac_data0[LFAC];
UCHAR fac_data_e[4];
FIXP_DBL
*fac_data[4]; /* Pointers to unused parts of pSpectralCoefficient */
UCHAR core_mode; /* current core mode */
USAC_COREMODE
core_mode_last; /* previous core mode, signalled in the bitstream
(not done by the decoder, see
CAacDecoderStaticChannelInfo::last_core_mode !!)*/
UCHAR lpd_mode_last; /* previous LPD mode, signalled in the bitstream
(not done by the decoder, see
CAacDecoderStaticChannelInfo::last_core_mode !!)*/
UCHAR mod[4];
UCHAR bpf_control_info; /* (1: enable, 0: disable) bpf for current
superframe */
FIXP_LPC lsp_coeff[5][M_LP_FILTER_ORDER]; /* linear prediction
coefficients in LSP domain */
FIXP_LPC
lp_coeff[5][M_LP_FILTER_ORDER]; /* linear prediction coefficients in
LP domain */
INT lp_coeff_exp[5];
FIXP_LPC lsf_adaptive_mean_cand
[M_LP_FILTER_ORDER]; /* concealment: is copied to
CAacDecoderStaticChannelInfo->lsf_adaptive_mean once frame is
assumed to be correct*/
FIXP_SGL aStability[4]; /* LPC coeff stability values required for ACELP
and TCX (concealment) */
CAcelpChannelData acelp[4];
FIXP_DBL tcx_gain[4];
SCHAR tcx_gain_e[4];
} usac;
struct {
CPnsData PnsData; /* Not required for USAC */
} aac;
}
data;
struct {
} usac;
} data;
SPECTRAL_PTR pSpectralCoefficient; /* Spectral coefficients of each window */
SHORT specScale[8]; /* Scale shift values of each spectrum window */
CIcsInfo icsInfo;
INT granuleLength; /* Size of smallest spectrum piece */
UCHAR ElementInstanceTag;
CAacDecoderDynamicData *pDynData; /* Data required for one element and discarded after decoding */
CAacDecoderCommonData *pComData; /* Data required for one channel at a time during decode */
AACDEC_RENDER_MODE renderMode; /* Output signal rendering mode */
CAacDecoderDynamicData *
pDynData; /* Data required for one element and discarded after decoding */
CAacDecoderCommonData
*pComData; /* Data required for one channel at a time during decode */
CAacDecoderCommonStaticData *pComStaticData; /* Persistent data required for
one channel at a time during
decode */
int currAliasingSymmetry; /* required for RSVD60 MCT */
} CAacDecoderChannelInfo;
/* channelinfo.cpp */
AAC_DECODER_ERROR getSamplingRateInfo(SamplingRateInfo *t, UINT samplesPerFrame, UINT samplingRateIndex, UINT samplingRate);
AAC_DECODER_ERROR getSamplingRateInfo(SamplingRateInfo *t, UINT samplesPerFrame,
UINT samplingRateIndex,
UINT samplingRate);
/**
* \brief Read max SFB from bit stream and assign TotalSfBands according
* to the window sequence and sample rate.
* \param hBs bit stream handle as data source
* \param pIcsInfo IcsInfo structure to read the window sequence and store MaxSfBands and TotalSfBands
* \param pIcsInfo IcsInfo structure to read the window sequence and store
* MaxSfBands and TotalSfBands
* \param pSamplingRateInfo read only
*/
AAC_DECODER_ERROR IcsReadMaxSfb (
HANDLE_FDK_BITSTREAM hBs,
CIcsInfo *pIcsInfo,
const SamplingRateInfo *pSamplingRateInfo
);
AAC_DECODER_ERROR IcsReadMaxSfb(HANDLE_FDK_BITSTREAM hBs, CIcsInfo *pIcsInfo,
const SamplingRateInfo *pSamplingRateInfo);
AAC_DECODER_ERROR IcsRead(
HANDLE_FDK_BITSTREAM bs,
CIcsInfo *pIcsInfo,
const SamplingRateInfo* SamplingRateInfoTable,
const UINT flags
);
AAC_DECODER_ERROR IcsRead(HANDLE_FDK_BITSTREAM bs, CIcsInfo *pIcsInfo,
const SamplingRateInfo *SamplingRateInfoTable,
const UINT flags);
/* stereo.cpp, only called from this file */
/*!
\brief Applies MS stereo.
\brief Applies MS stereo.
The function applies MS stereo.
\param pAacDecoderChannelInfo aac channel info.
\param pScaleFactorBandOffsets pointer to scalefactor band offsets.
\param pWindowGroupLength pointer to window group length array.
\param windowGroups number of window groups.
\param scaleFactorBandsTransmittedL number of transmitted scalefactor bands in left channel.
\param scaleFactorBandsTransmittedR number of transmitted scalefactor bands in right channel.
May differ from scaleFactorBandsTransmittedL only for USAC.
\return none
\param scaleFactorBandsTransmittedL number of transmitted scalefactor bands in
left channel. \param scaleFactorBandsTransmittedR number of transmitted
scalefactor bands in right channel. May differ from
scaleFactorBandsTransmittedL only for USAC. \return none
*/
void CJointStereo_ApplyMS(CAacDecoderChannelInfo *pAacDecoderChannelInfo[2],
const short *pScaleFactorBandOffsets,
const UCHAR *pWindowGroupLength,
const int windowGroups,
const int scaleFactorBandsTransmittedL,
const int scaleFactorBandsTransmittedR);
void CJointStereo_ApplyMS(
CAacDecoderChannelInfo *pAacDecoderChannelInfo[2],
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[2],
FIXP_DBL *spectrumL, FIXP_DBL *spectrumR, SHORT *SFBleftScale,
SHORT *SFBrightScale, SHORT *specScaleL, SHORT *specScaleR,
const SHORT *pScaleFactorBandOffsets, const UCHAR *pWindowGroupLength,
const int windowGroups, const int max_sfb_ste_outside,
const int scaleFactorBandsTransmittedL,
const int scaleFactorBandsTransmittedR, FIXP_DBL *store_dmx_re_prev,
SHORT *store_dmx_re_prev_e, const int mainband_flag);
/*!
\brief Applies intensity stereo
@ -360,91 +488,79 @@ void CJointStereo_ApplyIS(CAacDecoderChannelInfo *pAacDecoderChannelInfo[2],
const int scaleFactorBandsTransmitted,
const UINT CommonWindow);
/* aacdec_pns.cpp */
int CPns_IsPnsUsed (const CPnsData *pPnsData,
const int group,
const int band);
int CPns_IsPnsUsed(const CPnsData *pPnsData, const int group, const int band);
void CPns_SetCorrelation(CPnsData *pPnsData,
const int group,
const int band,
void CPns_SetCorrelation(CPnsData *pPnsData, const int group, const int band,
const int outofphase);
/****************** inline functions ******************/
inline UCHAR IsValid(const CIcsInfo *pIcsInfo)
{
return pIcsInfo->Valid;
inline UCHAR IsValid(const CIcsInfo *pIcsInfo) { return pIcsInfo->Valid; }
inline UCHAR IsLongBlock(const CIcsInfo *pIcsInfo) {
return (pIcsInfo->WindowSequence != BLOCK_SHORT);
}
inline UCHAR IsLongBlock(const CIcsInfo *pIcsInfo)
{
return (pIcsInfo->WindowSequence != EightShortSequence);
}
inline UCHAR GetWindowShape(const CIcsInfo *pIcsInfo)
{
inline UCHAR GetWindowShape(const CIcsInfo *pIcsInfo) {
return pIcsInfo->WindowShape;
}
inline UCHAR GetWindowSequence(const CIcsInfo *pIcsInfo)
{
inline BLOCK_TYPE GetWindowSequence(const CIcsInfo *pIcsInfo) {
return pIcsInfo->WindowSequence;
}
inline const SHORT *GetScaleFactorBandOffsets(const CIcsInfo *pIcsInfo, const SamplingRateInfo* samplingRateInfo)
{
if (IsLongBlock(pIcsInfo))
{
inline const SHORT *GetScaleFactorBandOffsets(
const CIcsInfo *pIcsInfo, const SamplingRateInfo *samplingRateInfo) {
if (IsLongBlock(pIcsInfo)) {
return samplingRateInfo->ScaleFactorBands_Long;
}
else
{
} else {
return samplingRateInfo->ScaleFactorBands_Short;
}
}
inline int GetWindowsPerFrame(const CIcsInfo *pIcsInfo)
{
return (pIcsInfo->WindowSequence == EightShortSequence) ? 8 : 1;
inline UCHAR GetNumberOfScaleFactorBands(
const CIcsInfo *pIcsInfo, const SamplingRateInfo *samplingRateInfo) {
if (IsLongBlock(pIcsInfo)) {
return samplingRateInfo->NumberOfScaleFactorBands_Long;
} else {
return samplingRateInfo->NumberOfScaleFactorBands_Short;
}
}
inline UCHAR GetWindowGroups(const CIcsInfo *pIcsInfo)
{
inline int GetWindowsPerFrame(const CIcsInfo *pIcsInfo) {
return (pIcsInfo->WindowSequence == BLOCK_SHORT) ? 8 : 1;
}
inline UCHAR GetWindowGroups(const CIcsInfo *pIcsInfo) {
return pIcsInfo->WindowGroups;
}
inline UCHAR GetWindowGroupLength(const CIcsInfo *pIcsInfo, const INT index)
{
inline UCHAR GetWindowGroupLength(const CIcsInfo *pIcsInfo, const INT index) {
return pIcsInfo->WindowGroupLength[index];
}
inline const UCHAR *GetWindowGroupLengthTable(const CIcsInfo *pIcsInfo)
{
inline const UCHAR *GetWindowGroupLengthTable(const CIcsInfo *pIcsInfo) {
return pIcsInfo->WindowGroupLength;
}
inline UCHAR GetScaleFactorBandsTransmitted(const CIcsInfo *pIcsInfo)
{
inline UCHAR GetScaleFactorBandsTransmitted(const CIcsInfo *pIcsInfo) {
return pIcsInfo->MaxSfBands;
}
inline UCHAR GetScaleMaxFactorBandsTransmitted(const CIcsInfo *pIcsInfo0, const CIcsInfo *pIcsInfo1)
{
inline UCHAR GetScaleMaxFactorBandsTransmitted(const CIcsInfo *pIcsInfo0,
const CIcsInfo *pIcsInfo1) {
return fMax(pIcsInfo0->MaxSfBands, pIcsInfo1->MaxSfBands);
}
inline UCHAR GetScaleFactorBandsTotal(const CIcsInfo *pIcsInfo)
{
inline UCHAR GetScaleFactorBandsTotal(const CIcsInfo *pIcsInfo) {
return pIcsInfo->TotalSfBands;
}
/* Note: This function applies to AAC-LC only ! */
inline UCHAR GetMaximumTnsBands(const CIcsInfo *pIcsInfo, const int samplingRateIndex)
{
inline UCHAR GetMaximumTnsBands(const CIcsInfo *pIcsInfo,
const int samplingRateIndex) {
return tns_max_bands_tbl[samplingRateIndex][!IsLongBlock(pIcsInfo)];
}
#endif /* #ifndef CHANNELINFO_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,70 +90,63 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
/**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl
Description: independent channel concealment
******************************************************************************/
*******************************************************************************/
#ifndef _CONCEAL_H_
#define _CONCEAL_H_
#include "aacdecoder_lib.h"
#ifndef CONCEAL_H
#define CONCEAL_H
#include "channelinfo.h"
#define AACDEC_CONCEAL_PARAM_NOT_SPECIFIED ( 0xFFFE )
#define AACDEC_CONCEAL_PARAM_NOT_SPECIFIED (0xFFFE)
void CConcealment_InitCommonData (CConcealParams *pConcealCommonData);
void CConcealment_InitCommonData(CConcealParams *pConcealCommonData);
void CConcealment_InitChannelData (CConcealmentInfo *hConcealmentInfo,
CConcealParams *pConcealCommonData,
int samplesPerFrame);
void CConcealment_InitChannelData(CConcealmentInfo *hConcealmentInfo,
CConcealParams *pConcealCommonData,
AACDEC_RENDER_MODE initRenderMode,
int samplesPerFrame);
CConcealmentMethod
CConcealment_GetMethod (CConcealParams *pConcealCommonData);
CConcealmentMethod CConcealment_GetMethod(CConcealParams *pConcealCommonData);
UINT
CConcealment_GetDelay (CConcealParams *pConcealCommonData);
UINT CConcealment_GetDelay(CConcealParams *pConcealCommonData);
AAC_DECODER_ERROR
CConcealment_SetParams (CConcealParams *concealParams,
int method,
int fadeOutSlope,
int fadeInSlope,
int muteRelease,
int comfNoiseLevel);
CConcealment_SetParams(CConcealParams *concealParams, int method,
int fadeOutSlope, int fadeInSlope, int muteRelease,
FIXP_DBL comfNoiseLevel);
CConcealmentState
CConcealment_GetState (CConcealmentInfo *hConcealmentInfo);
CConcealmentState CConcealment_GetState(CConcealmentInfo *hConcealmentInfo);
AAC_DECODER_ERROR
CConcealment_SetAttenuation (CConcealParams *concealParams,
SHORT *fadeOutAttenuationVector,
SHORT *fadeInAttenuationVector);
CConcealment_SetAttenuation(CConcealParams *concealParams,
const SHORT *fadeOutAttenuationVector,
const SHORT *fadeInAttenuationVector);
void CConcealment_Store (CConcealmentInfo *hConcealmentInfo,
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo );
void CConcealment_Store(
CConcealmentInfo *hConcealmentInfo,
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo);
int CConcealment_Apply (CConcealmentInfo *hConcealmentInfo,
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
const SamplingRateInfo *pSamplingRateInfo,
const int samplesPerFrame,
const UCHAR lastLpdMode,
const int FrameOk,
const UINT flags);
int CConcealment_Apply(
CConcealmentInfo *hConcealmentInfo,
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
const SamplingRateInfo *pSamplingRateInfo, const int samplesPerFrame,
const UCHAR lastLpdMode, const int FrameOk, const UINT flags);
FIXP_DBL
CConcealment_GetFadeFactor (CConcealmentInfo *hConcealmentInfo,
const int fPreviousFactor);
int CConcealment_GetLastFrameOk(CConcealmentInfo *hConcealmentInfo,
const int fBeforeApply);
int CConcealment_GetLastFrameOk (CConcealmentInfo *hConcealmentInfo,
const int fBeforeApply);
INT CConcealment_TDFading(
int len, CAacDecoderStaticChannelInfo **ppAacDecoderStaticChannelInfo,
FIXP_PCM *pcmdata, FIXP_PCM *pcmdata_1);
#endif /* #ifndef _CONCEAL_H_ */
#endif /* #ifndef CONCEAL_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,48 +90,45 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
/**************************** AAC decoder library ******************************
Author(s): Christian Griebel
Description: Error concealment structs and types
******************************************************************************/
*******************************************************************************/
#ifndef CONCEAL_TYPES_H
#define CONCEAL_TYPES_H
#include "machine_type.h"
#include "common_fix.h"
#include "rvlc_info.h"
#include "usacdec_lpc.h"
#define CONCEAL_MAX_NUM_FADE_FACTORS ( 16 )
#define CONCEAL_MAX_NUM_FADE_FACTORS (32)
#define FIXP_CNCL FIXP_DBL
#define FL2FXCONST_CNCL FL2FXCONST_DBL
#define FX_DBL2FX_CNCL
#define FX_CNCL2FX_DBL
#define CNCL_FRACT_BITS DFRACT_BITS
#define FIXP_CNCL FIXP_DBL
#define FL2FXCONST_CNCL FL2FXCONST_DBL
#define FX_DBL2FX_CNCL
#define FX_CNCL2FX_DBL
#define CNCL_FRACT_BITS DFRACT_BITS
/* Warning: Do not ever change these values. */
typedef enum
{
ConcealMethodNone = -1,
ConcealMethodMute = 0,
ConcealMethodNoise = 1,
ConcealMethodInter = 2,
ConcealMethodTonal = 3
typedef enum {
ConcealMethodNone = -1,
ConcealMethodMute = 0,
ConcealMethodNoise = 1,
ConcealMethodInter = 2,
ConcealMethodTonal = 3
} CConcealmentMethod;
typedef enum
{
typedef enum {
ConcealState_Ok,
ConcealState_Single,
ConcealState_FadeIn,
@ -129,50 +137,67 @@ typedef enum
} CConcealmentState;
typedef struct {
FIXP_SGL fadeOutFactor[CONCEAL_MAX_NUM_FADE_FACTORS];
FIXP_SGL fadeInFactor[CONCEAL_MAX_NUM_FADE_FACTORS];
typedef struct
{
FIXP_SGL fadeOutFactor[CONCEAL_MAX_NUM_FADE_FACTORS];
FIXP_SGL fadeInFactor [CONCEAL_MAX_NUM_FADE_FACTORS];
CConcealmentMethod method;
CConcealmentMethod method;
int numFadeOutFrames;
int numFadeInFrames;
int numMuteReleaseFrames;
int comfortNoiseLevel;
int numFadeOutFrames;
int numFadeInFrames;
int numMuteReleaseFrames;
FIXP_DBL comfortNoiseLevel;
} CConcealParams;
typedef enum {
FADE_TIMEDOMAIN_TOSPECTRALMUTE = 1,
FADE_TIMEDOMAIN_FROMSPECTRALMUTE,
FADE_TIMEDOMAIN
} TDfadingType;
typedef struct
{
typedef struct {
CConcealParams *pConcealParams;
FIXP_CNCL spectralCoefficient[1024];
SHORT specScale[8];
SHORT specScale[8];
INT iRandomPhase;
INT prevFrameOk[2];
INT cntFadeFrames;
INT cntValidFrames;
INT iRandomPhase;
INT prevFrameOk[2];
INT cntValidFrames;
INT cntFadeFrames; /* State for signal fade-in/out */
/* States for signal fade-out of frames with more than one window/subframe -
[0] used by Update CntFadeFrames mode of CConcealment_ApplyFadeOut, [1] used
by FadeOut mode */
int winGrpOffset[2]; /* State for signal fade-out of frames with more than one
window/subframe */
int attGrpOffset[2]; /* State for faster signal fade-out of frames with
transient signal parts */
SHORT aRvlcPreviousScaleFactor[RVLC_MAX_SFB]; /* needed once per channel */
UCHAR aRvlcPreviousCodebook[RVLC_MAX_SFB]; /* needed once per channel */
SCHAR lastRenderMode;
UCHAR windowShape;
BLOCK_TYPE windowSequence;
UCHAR lastWinGrpLen;
CConcealmentState concealState;
CConcealmentState concealState_old;
FIXP_DBL fade_old; /* last fading factor */
TDfadingType lastFadingType; /* last fading type */
SHORT aRvlcPreviousScaleFactor[RVLC_MAX_SFB]; /* needed once per channel */
UCHAR aRvlcPreviousCodebook[RVLC_MAX_SFB]; /* needed once per channel */
SCHAR rvlcPreviousScaleFactorOK;
SCHAR rvlcPreviousBlockType;
SCHAR lastRenderMode;
UCHAR windowShape;
UCHAR windowSequence;
UCHAR lastWinGrpLen;
CConcealmentState concealState;
FIXP_LPC lsf4[M_LP_FILTER_ORDER];
FIXP_DBL last_tcx_gain;
INT last_tcx_gain_e;
ULONG TDNoiseSeed;
FIXP_PCM TDNoiseStates[3];
FIXP_SGL TDNoiseCoef[3];
FIXP_SGL TDNoiseAtt;
} CConcealmentInfo;
#endif /* #ifndef CONCEAL_TYPES_H */

View File

@ -1,97 +0,0 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
5. CONTACT INFORMATION
Fraunhofer Institute for Integrated Circuits IIS
Attention: Audio and Multimedia Departments - FDK AAC LL
Am Wolfsmantel 33
91058 Erlangen, Germany
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
Author(s): Josef Hoepfl
Description: debug output
******************************************************************************/
#ifndef DEBUG_H
#define DEBUG_H
#include "machine_type.h"
#endif

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,19 +90,18 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************************************************************\
*
* filename: ldfiltbank.c
* project : MPEG-4 Audio Decoder
* contents/description: low delay filterbank
*
\***************************************************************************/
/**************************** AAC decoder library ******************************
Author(s):
Description: low delay filterbank
*******************************************************************************/
#include "ldfiltbank.h"
#include "aac_rom.h"
#include "dct.h"
#include "FDK_tools_rom.h"
@ -99,110 +109,166 @@ amm-info@iis.fraunhofer.de
#define LDFB_HEADROOM 2
static void multE2_DinvF_fdk(INT_PCM *output, FIXP_DBL* x, const FIXP_WTB* fb, FIXP_DBL* z, const int N, const int stride)
{
int i, scale;
#if defined(__arm__)
#endif
static void multE2_DinvF_fdk(FIXP_PCM *output, FIXP_DBL *x, const FIXP_WTB *fb,
FIXP_DBL *z, const int N) {
int i;
/* scale for FIXP_DBL -> INT_PCM conversion. */
scale = (DFRACT_BITS - SAMPLE_BITS) - LDFB_HEADROOM;
const int scale = (DFRACT_BITS - SAMPLE_BITS) - LDFB_HEADROOM;
#if ((DFRACT_BITS - SAMPLE_BITS - LDFB_HEADROOM) > 0)
FIXP_DBL rnd_val_wts0 = (FIXP_DBL)0;
FIXP_DBL rnd_val_wts1 = (FIXP_DBL)0;
if (-WTS0 - 1 + scale)
rnd_val_wts0 = (FIXP_DBL)(1 << (-WTS0 - 1 + scale - 1));
if (-WTS1 - 1 + scale)
rnd_val_wts1 = (FIXP_DBL)(1 << (-WTS1 - 1 + scale - 1));
#endif
for(i=0;i<N/4;i++)
{
for (i = 0; i < N / 4; i++) {
FIXP_DBL z0, z2, tmp;
z2 = x[N/2+i];
z0 = z2 + ( fMultDiv2(z[N/2+i], fb[2*N + i]) >> (-WTS2-1) );
z2 = x[N / 2 + i];
z0 = z2 + (fMultDiv2(z[N / 2 + i], fb[2 * N + i]) >> (-WTS2 - 1));
z[N/2+i] = x[N/2-1-i] + ( fMultDiv2(z[N + i], fb[2*N + N/2 + i]) >> (-WTS2-1) );
z[N / 2 + i] = x[N / 2 - 1 - i] +
(fMultDiv2(z[N + i], fb[2 * N + N / 2 + i]) >> (-WTS2 - 1));
tmp = ( fMultDiv2(z[N/2+i], fb[N+N/2-1-i]) + fMultDiv2(z[i], fb[N+N/2+i]) ) ;
tmp = (fMultDiv2(z[N / 2 + i], fb[N + N / 2 - 1 - i]) +
fMultDiv2(z[i], fb[N + N / 2 + i]));
#if (SAMPLE_BITS <= 16)
FDK_ASSERT( (-WTS1-1 + scale) >= 0);
output[(N*3/4-1-i)*stride] = (INT_PCM)SATURATE_RIGHT_SHIFT(tmp, -WTS1-1 + scale, SAMPLE_BITS);
#if ((DFRACT_BITS - SAMPLE_BITS - LDFB_HEADROOM) > 0)
FDK_ASSERT((-WTS1 - 1 + scale) >= 0);
FDK_ASSERT(tmp <= ((FIXP_DBL)0x7FFFFFFF -
rnd_val_wts1)); /* rounding must not cause overflow */
output[(N * 3 / 4 - 1 - i)] = (FIXP_PCM)SATURATE_RIGHT_SHIFT(
tmp + rnd_val_wts1, -WTS1 - 1 + scale, PCM_OUT_BITS);
#else
FDK_ASSERT( (WTS1+1 - scale) >= 0);
output[(N*3/4-1-i)*stride] = (INT_PCM)SATURATE_LEFT_SHIFT(tmp, WTS1+1 - scale, SAMPLE_BITS);
FDK_ASSERT((WTS1 + 1 - scale) >= 0);
output[(N * 3 / 4 - 1 - i)] =
(FIXP_PCM)SATURATE_LEFT_SHIFT(tmp, WTS1 + 1 - scale, PCM_OUT_BITS);
#endif
z[i] = z0;
z[N + i] = z2;
}
for(i=N/4;i<N/2;i++)
{
for (i = N / 4; i < N / 2; i++) {
FIXP_DBL z0, z2, tmp0, tmp1;
z2 = x[N/2+i];
z0 = z2 + ( fMultDiv2(z[N/2+i], fb[2*N + i]) >> (-WTS2-1) );
z2 = x[N / 2 + i];
z0 = z2 + (fMultDiv2(z[N / 2 + i], fb[2 * N + i]) >> (-WTS2 - 1));
z[N/2+i] = x[N/2-1-i] + ( fMultDiv2(z[N + i], fb[2*N + N/2 + i]) >> (-WTS2-1) );
z[N / 2 + i] = x[N / 2 - 1 - i] +
(fMultDiv2(z[N + i], fb[2 * N + N / 2 + i]) >> (-WTS2 - 1));
tmp0 = ( fMultDiv2(z[N/2+i], fb[N/2-1-i]) + fMultDiv2(z[i], fb[N/2+i]) ) ;
tmp1 = ( fMultDiv2(z[N/2+i], fb[N+N/2-1-i]) + fMultDiv2(z[i], fb[N+N/2+i]) ) ;
tmp0 = (fMultDiv2(z[N / 2 + i], fb[N / 2 - 1 - i]) +
fMultDiv2(z[i], fb[N / 2 + i]));
tmp1 = (fMultDiv2(z[N / 2 + i], fb[N + N / 2 - 1 - i]) +
fMultDiv2(z[i], fb[N + N / 2 + i]));
#if (SAMPLE_BITS <= 16)
FDK_ASSERT( (-WTS0-1 + scale) >= 0);
output[(i-N/4)*stride] = (INT_PCM)SATURATE_RIGHT_SHIFT(tmp0, -WTS0-1 + scale, SAMPLE_BITS);
output[(N*3/4-1-i)*stride] = (INT_PCM)SATURATE_RIGHT_SHIFT(tmp1, -WTS1-1 + scale, SAMPLE_BITS);
#if ((DFRACT_BITS - SAMPLE_BITS - LDFB_HEADROOM) > 0)
FDK_ASSERT((-WTS0 - 1 + scale) >= 0);
FDK_ASSERT(tmp0 <= ((FIXP_DBL)0x7FFFFFFF -
rnd_val_wts0)); /* rounding must not cause overflow */
FDK_ASSERT(tmp1 <= ((FIXP_DBL)0x7FFFFFFF -
rnd_val_wts1)); /* rounding must not cause overflow */
output[(i - N / 4)] = (FIXP_PCM)SATURATE_RIGHT_SHIFT(
tmp0 + rnd_val_wts0, -WTS0 - 1 + scale, PCM_OUT_BITS);
output[(N * 3 / 4 - 1 - i)] = (FIXP_PCM)SATURATE_RIGHT_SHIFT(
tmp1 + rnd_val_wts1, -WTS1 - 1 + scale, PCM_OUT_BITS);
#else
FDK_ASSERT( (WTS0+1 - scale) >= 0);
output[(i-N/4)*stride] = (INT_PCM)SATURATE_LEFT_SHIFT(tmp0, WTS0+1 - scale, SAMPLE_BITS);
output[(N*3/4-1-i)*stride] = (INT_PCM)SATURATE_LEFT_SHIFT(tmp1, WTS1+1 - scale, SAMPLE_BITS);
FDK_ASSERT((WTS0 + 1 - scale) >= 0);
output[(i - N / 4)] =
(FIXP_PCM)SATURATE_LEFT_SHIFT(tmp0, WTS0 + 1 - scale, PCM_OUT_BITS);
output[(N * 3 / 4 - 1 - i)] =
(FIXP_PCM)SATURATE_LEFT_SHIFT(tmp1, WTS1 + 1 - scale, PCM_OUT_BITS);
#endif
z[i] = z0;
z[N + i] = z2;
}
/* Exchange quarter parts of x to bring them in the "right" order */
for(i=0;i<N/4;i++)
{
FIXP_DBL tmp0 = fMultDiv2(z[i], fb[N/2+i]);
for (i = 0; i < N / 4; i++) {
FIXP_DBL tmp0 = fMultDiv2(z[i], fb[N / 2 + i]);
#if (SAMPLE_BITS <= 16)
FDK_ASSERT( (-WTS0-1 + scale) >= 0);
output[(N*3/4 + i)*stride] = (INT_PCM)SATURATE_RIGHT_SHIFT(tmp0, -WTS0-1 + scale, SAMPLE_BITS);
#if ((DFRACT_BITS - SAMPLE_BITS - LDFB_HEADROOM) > 0)
FDK_ASSERT((-WTS0 - 1 + scale) >= 0);
FDK_ASSERT(tmp0 <= ((FIXP_DBL)0x7FFFFFFF -
rnd_val_wts0)); /* rounding must not cause overflow */
output[(N * 3 / 4 + i)] = (FIXP_PCM)SATURATE_RIGHT_SHIFT(
tmp0 + rnd_val_wts0, -WTS0 - 1 + scale, PCM_OUT_BITS);
#else
FDK_ASSERT( (WTS0+1 - scale) >= 0);
output[(N*3/4 + i)*stride] = (INT_PCM)SATURATE_LEFT_SHIFT(tmp0, WTS0+1 - scale, SAMPLE_BITS);
FDK_ASSERT((WTS0 + 1 - scale) >= 0);
output[(N * 3 / 4 + i)] =
(FIXP_PCM)SATURATE_LEFT_SHIFT(tmp0, WTS0 + 1 - scale, PCM_OUT_BITS);
#endif
}
}
int InvMdctTransformLowDelay_fdk (FIXP_DBL *mdctData, const int mdctData_e, INT_PCM *output, FIXP_DBL *fs_buffer, const int stride, const int N) {
int InvMdctTransformLowDelay_fdk(FIXP_DBL *mdctData, const int mdctData_e,
FIXP_PCM *output, FIXP_DBL *fs_buffer,
const int N) {
const FIXP_WTB *coef;
FIXP_DBL gain = (FIXP_DBL)0;
int scale = mdctData_e + MDCT_OUT_HEADROOM - LDFB_HEADROOM; /* The LDFB_HEADROOM is compensated inside multE2_DinvF_fdk() below */
int scale = mdctData_e + MDCT_OUT_HEADROOM -
LDFB_HEADROOM; /* The LDFB_HEADROOM is compensated inside
multE2_DinvF_fdk() below */
/* Select LD window slope */
if (N == 512)
coef = (FIXP_WTB*)LowDelaySynthesis512;
else
coef = (FIXP_WTB*)LowDelaySynthesis480;
switch (N) {
case 256:
coef = LowDelaySynthesis256;
break;
case 240:
coef = LowDelaySynthesis240;
break;
case 160:
coef = LowDelaySynthesis160;
break;
case 128:
coef = LowDelaySynthesis128;
break;
case 120:
coef = LowDelaySynthesis120;
break;
case 512:
coef = LowDelaySynthesis512;
break;
case 480:
default:
coef = LowDelaySynthesis480;
break;
}
/*
Apply exponent and 1/N factor.
Note: "scale" is off by one because for LD_MDCT the window length is twice
the window length of a regular MDCT. This is corrected inside multE2_DinvF_fdk().
Refer to ISO/IEC 14496-3:2009 page 277, chapter 4.6.20.2 "Low Delay Window".
the window length of a regular MDCT. This is corrected inside
multE2_DinvF_fdk(). Refer to ISO/IEC 14496-3:2009 page 277,
chapter 4.6.20.2 "Low Delay Window".
*/
imdct_gain(&gain, &scale, N);
dct_IV(mdctData, N, &scale);
if (N == 256 || N == 240 || N == 160) {
scale -= 1;
} else if (N == 128 || N == 120) {
scale -= 2;
}
if (gain != (FIXP_DBL)0) {
scaleValuesWithFactor(mdctData, gain, N, scale);
} else {
scaleValues(mdctData, N, scale);
}
/* Since all exponent and factors have been applied, current exponent is zero. */
multE2_DinvF_fdk(output, mdctData, coef, fs_buffer, N, stride);
/* Since all exponent and factors have been applied, current exponent is zero.
*/
multE2_DinvF_fdk(output, mdctData, coef, fs_buffer, N);
return (1);
}

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,31 +90,23 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************************************************************\
*
/**************************** AAC decoder library ******************************
* filename: ldfiltbank.h
* project : MPEG-4 Audio Decoder
* contents/description: low delay filterbank interface
*
\***************************************************************************/
Author(s):
#ifndef _LDFILTBANK_H
#define _LDFILTBANK_H
Description: low delay filterbank interface
*******************************************************************************/
#ifndef LDFILTBANK_H
#define LDFILTBANK_H
#include "common_fix.h"
int InvMdctTransformLowDelay_fdk (
FIXP_DBL *mdctdata_m,
const int mdctdata_e,
INT_PCM *mdctOut,
FIXP_DBL *fs_buffer,
const int stride,
const int frameLength
);
int InvMdctTransformLowDelay_fdk(FIXP_DBL *mdctdata_m, const int mdctdata_e,
FIXP_PCM *mdctOut, FIXP_DBL *fs_buffer,
const int frameLength);
#endif

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,27 +90,31 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
/**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl
Description:
******************************************************************************/
*******************************************************************************/
#ifndef OVERLAPADD_H
#define OVERLAPADD_H
#include "common_fix.h"
#define OverlapBufferSize (1024*2)
/* ELD uses different overlap which is twice the frame size: */
#define OverlapBufferSize (768)
typedef FIXP_DBL SPECTRUM[1024];
typedef FIXP_DBL * SPECTRAL_PTR;
typedef FIXP_DBL* SPECTRAL_PTR;
#define SPEC_LONG(ptr) (ptr)
#define SPEC(ptr,w,gl) ((ptr)+((w)*(gl)))
#define SPEC_LONG(ptr) (ptr)
#define SPEC(ptr, w, gl) ((ptr) + ((w) * (gl)))
#define SPEC_TCX(ptr, f, gl, fb) \
((ptr) + ((f) * (gl * 2) * (((fb) == 0) ? 1 : 2)))
#endif /* #ifndef OVERLAPADD_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,42 +90,37 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
/**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl
Description: pulse data tool
******************************************************************************/
*******************************************************************************/
#include "pulsedata.h"
#include "channelinfo.h"
INT CPulseData_Read(
HANDLE_FDK_BITSTREAM bs,
CPulseData *const PulseData,
const SHORT *sfb_startlines,
const void *pIcsInfo,
const SHORT frame_length
)
{
int i, k=0;
const UINT MaxSfBands = GetScaleFactorBandsTransmitted((CIcsInfo*)pIcsInfo);
INT CPulseData_Read(HANDLE_FDK_BITSTREAM bs, CPulseData *const PulseData,
const SHORT *sfb_startlines, const void *pIcsInfo,
const SHORT frame_length) {
int i, k = 0;
const UINT MaxSfBands =
GetScaleFactorBandsTransmitted((const CIcsInfo *)pIcsInfo);
/* reset pulse data flag */
PulseData->PulseDataPresent = 0;
if ((PulseData->PulseDataPresent = (UCHAR) FDKreadBit(bs)) != 0) {
if (!IsLongBlock((CIcsInfo*)pIcsInfo)) {
if ((PulseData->PulseDataPresent = (UCHAR)FDKreadBit(bs)) != 0) {
if (!IsLongBlock((const CIcsInfo *)pIcsInfo)) {
return AAC_DEC_DECODE_FRAME_ERROR;
}
PulseData->NumberPulse = (UCHAR) FDKreadBits(bs,2);
PulseData->PulseStartBand = (UCHAR) FDKreadBits(bs,6);
PulseData->NumberPulse = (UCHAR)FDKreadBits(bs, 2);
PulseData->PulseStartBand = (UCHAR)FDKreadBits(bs, 6);
if (PulseData->PulseStartBand >= MaxSfBands) {
return AAC_DEC_DECODE_FRAME_ERROR;
@ -122,37 +128,37 @@ INT CPulseData_Read(
k = sfb_startlines[PulseData->PulseStartBand];
for (i=0; i<=PulseData->NumberPulse; i++) {
PulseData->PulseOffset[i] = (UCHAR) FDKreadBits(bs,5);
PulseData->PulseAmp[i] = (UCHAR) FDKreadBits(bs,4);
for (i = 0; i <= PulseData->NumberPulse; i++) {
PulseData->PulseOffset[i] = (UCHAR)FDKreadBits(bs, 5);
PulseData->PulseAmp[i] = (UCHAR)FDKreadBits(bs, 4);
k += PulseData->PulseOffset[i];
}
if (k >= frame_length) {
return AAC_DEC_DECODE_FRAME_ERROR;
return AAC_DEC_DECODE_FRAME_ERROR;
}
}
return 0;
}
void CPulseData_Apply(CPulseData *PulseData, /*!< pointer to pulse data side info */
const short *pScaleFactorBandOffsets, /*!< pointer to scalefactor band offsets */
FIXP_DBL *coef) /*!< pointer to spectrum */
void CPulseData_Apply(
CPulseData *PulseData, /*!< pointer to pulse data side info */
const short
*pScaleFactorBandOffsets, /*!< pointer to scalefactor band offsets */
FIXP_DBL *coef) /*!< pointer to spectrum */
{
int i,k;
int i, k;
if (PulseData->PulseDataPresent)
{
if (PulseData->PulseDataPresent) {
k = pScaleFactorBandOffsets[PulseData->PulseStartBand];
for (i=0; i<=PulseData->NumberPulse; i++)
{
for (i = 0; i <= PulseData->NumberPulse; i++) {
k += PulseData->PulseOffset[i];
if (coef [k] > (FIXP_DBL)0) coef[k] += (FIXP_DBL)(int)PulseData->PulseAmp[i];
else coef[k] -= (FIXP_DBL)(int)PulseData->PulseAmp[i];
if (coef[k] > (FIXP_DBL)0)
coef[k] += (FIXP_DBL)(int)PulseData->PulseAmp[i];
else
coef[k] -= (FIXP_DBL)(int)PulseData->PulseAmp[i];
}
}
}

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,27 +90,25 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
/**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl
Description: pulse data tool
******************************************************************************/
*******************************************************************************/
#ifndef PULSEDATA_H
#define PULSEDATA_H
#include "common_fix.h"
#include "FDK_bitstream.h"
#define N_MAX_LINES 4
typedef struct
{
typedef struct {
UCHAR PulseDataPresent;
UCHAR NumberPulse;
UCHAR PulseStartBand;
@ -114,17 +123,14 @@ typedef struct
* the bitstream.
*
* \param bs bit stream handle data source.
* \param PulseData pointer to a CPulseData were the decoded data is stored into.
* \param PulseData pointer to a CPulseData were the decoded data is stored
* into.
* \param MaxSfBands max number of scale factor bands.
* \return 0 on success, != 0 on parse error.
*/
INT CPulseData_Read(
const HANDLE_FDK_BITSTREAM bs,
CPulseData *const PulseData,
const SHORT *sfb_startlines,
const void *pIcsInfo,
const SHORT frame_length
);
INT CPulseData_Read(const HANDLE_FDK_BITSTREAM bs, CPulseData *const PulseData,
const SHORT *sfb_startlines, const void *pIcsInfo,
const SHORT frame_length);
/**
* \brief Apply pulse data to spectral lines
@ -134,12 +140,11 @@ INT CPulseData_Read(
*
* \param PulseData pointer to the previously decoded pulse data.
* \param pScaleFactorBandOffsets scale factor band line offset table.
* \param coef pointer to the spectral data were pulse data should be applied to.
* \param coef pointer to the spectral data were pulse data should be applied
* to.
* \return none
*/
*/
void CPulseData_Apply(CPulseData *PulseData,
const short *pScaleFactorBandOffsets,
FIXP_DBL *coef);
const short *pScaleFactorBandOffsets, FIXP_DBL *coef);
#endif /* #ifndef PULSEDATA_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,7 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s):
Description:
*******************************************************************************/
/*!
\file
@ -90,8 +109,6 @@ amm-info@iis.fraunhofer.de
#ifndef RVLC_H
#define RVLC_H
#include "aacdecoder.h"
#include "channel.h"
#include "rvlc_info.h"
@ -100,35 +117,37 @@ amm-info@iis.fraunhofer.de
/* errorLogRvlc: A word of 32 bits used for logging possible errors */
/* within RVLC in case of distorted bitstreams. */
/* ------------------------------------------------------------------- */
#define RVLC_ERROR_ALL_ESCAPE_WORDS_INVALID 0x80000000 /* ESC-Dec During RVLC-Escape-decoding there have been more bits decoded as there are available */
#define RVLC_ERROR_RVL_SUM_BIT_COUNTER_BELOW_ZERO_FWD 0x40000000 /* RVL-Dec negative sum-bitcounter during RVL-fwd-decoding (long+shrt) */
#define RVLC_ERROR_RVL_SUM_BIT_COUNTER_BELOW_ZERO_BWD 0x20000000 /* RVL-Dec negative sum-bitcounter during RVL-fwd-decoding (long+shrt) */
#define RVLC_ERROR_FORBIDDEN_CW_DETECTED_FWD 0x08000000 /* RVL-Dec forbidden codeword detected fwd (long+shrt) */
#define RVLC_ERROR_FORBIDDEN_CW_DETECTED_BWD 0x04000000 /* RVL-Dec forbidden codeword detected bwd (long+shrt) */
#define RVLC_ERROR_ALL_ESCAPE_WORDS_INVALID \
0x80000000 /* ESC-Dec During RVLC-Escape-decoding there have been more \
bits decoded as there are available */
#define RVLC_ERROR_RVL_SUM_BIT_COUNTER_BELOW_ZERO_FWD \
0x40000000 /* RVL-Dec negative sum-bitcounter during RVL-fwd-decoding \
(long+shrt) */
#define RVLC_ERROR_RVL_SUM_BIT_COUNTER_BELOW_ZERO_BWD \
0x20000000 /* RVL-Dec negative sum-bitcounter during RVL-fwd-decoding \
(long+shrt) */
#define RVLC_ERROR_FORBIDDEN_CW_DETECTED_FWD \
0x08000000 /* RVL-Dec forbidden codeword detected fwd (long+shrt) */
#define RVLC_ERROR_FORBIDDEN_CW_DETECTED_BWD \
0x04000000 /* RVL-Dec forbidden codeword detected bwd (long+shrt) */
void CRvlc_Read(CAacDecoderChannelInfo *pAacDecoderChannelInfo,
HANDLE_FDK_BITSTREAM bs);
void CRvlc_Read (CAacDecoderChannelInfo *pAacDecoderChannelInfo,
HANDLE_FDK_BITSTREAM bs);
void CRvlc_Decode (CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
HANDLE_FDK_BITSTREAM bs);
void CRvlc_Decode(CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
HANDLE_FDK_BITSTREAM bs);
/**
* \brief performe sanity checks to the channel data corresponding to one channel element.
* \brief performe sanity checks to the channel data corresponding to one
* channel element.
* \param pAacDecoderChannelInfo
* \param pAacDecoderStaticChannelInfo
* \param elChannels amount of channels of the channel element.
*/
void CRvlc_ElementCheck (
CAacDecoderChannelInfo *pAacDecoderChannelInfo[],
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[],
const UINT flags,
const INT elChannels
);
void CRvlc_ElementCheck(
CAacDecoderChannelInfo *pAacDecoderChannelInfo[],
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[],
const UINT flags, const INT elChannels);
#endif /* RVLC_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,7 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s):
Description:
*******************************************************************************/
/*!
\file
@ -89,88 +108,96 @@ amm-info@iis.fraunhofer.de
#ifndef RVLC_INFO_H
#define RVLC_INFO_H
#define FWD 0 /* bitstream decoding direction forward (RVL coded part) */
#define BWD 1 /* bitstream decoding direction backward (RVL coded part) */
#define MAX_RVL 7 /* positive RVLC escape */
#define MIN_RVL -7 /* negative RVLC escape */
#define MAX_ALLOWED_DPCM_INDEX \
14 /* the maximum allowed index of a decoded dpcm value (offset \
'TABLE_OFFSET' incl --> must be subtracted) */
#define TABLE_OFFSET \
7 /* dpcm offset of valid output values of rvl table decoding, the rvl table \
ouly returns positive values, therefore the offset */
#define MAX_LEN_RVLC_CODE_WORD 9 /* max length of a RVL codeword in bits */
#define MAX_LEN_RVLC_ESCAPE_WORD \
20 /* max length of huffman coded RVLC escape word in bits */
#define FWD 0 /* bitstream decoding direction forward (RVL coded part) */
#define BWD 1 /* bitstream decoding direction backward (RVL coded part) */
#define DPCM_NOISE_NRG_BITS 9
#define SF_OFFSET 100 /* offset for correcting scf value */
#define MAX_RVL 7 /* positive RVLC escape */
#define MIN_RVL -7 /* negative RVLC escape */
#define MAX_ALLOWED_DPCM_INDEX 14 /* the maximum allowed index of a decoded dpcm value (offset 'TABLE_OFFSET' incl --> must be subtracted) */
#define TABLE_OFFSET 7 /* dpcm offset of valid output values of rvl table decoding, the rvl table ouly returns positive values, therefore the offset */
#define MAX_LEN_RVLC_CODE_WORD 9 /* max length of a RVL codeword in bits */
#define MAX_LEN_RVLC_ESCAPE_WORD 20 /* max length of huffman coded RVLC escape word in bits */
#define CONCEAL_MAX_INIT 1311 /* arbitrary value */
#define CONCEAL_MIN_INIT -1311 /* arbitrary value */
#define DPCM_NOISE_NRG_BITS 9
#define SF_OFFSET 100 /* offset for correcting scf value */
#define CONCEAL_MAX_INIT 1311 /* arbitrary value */
#define CONCEAL_MIN_INIT -1311 /* arbitrary value */
#define RVLC_MAX_SFB ((8) * (16))
#define RVLC_MAX_SFB ((8) * (16))
/* sideinfo of RVLC */
typedef struct
{
/* ------- ESC 1 Data: --------- */ /* order of RVLC-bitstream components in bitstream (RVLC-initialization), every component appears only once in bitstream */
INT sf_concealment; /* 1 */
INT rev_global_gain; /* 2 */
SHORT length_of_rvlc_sf; /* 3 */ /* original value, gets modified (subtract 9) in case of noise (PNS); is kept for later use */
INT dpcm_noise_nrg; /* 4 optional */
INT sf_escapes_present; /* 5 */
SHORT length_of_rvlc_escapes; /* 6 optional */
INT dpcm_noise_last_position; /* 7 optional */
typedef struct {
/* ------- ESC 1 Data: --------- */ /* order of RVLC-bitstream components in
bitstream (RVLC-initialization), every
component appears only once in
bitstream */
INT sf_concealment; /* 1 */
INT rev_global_gain; /* 2 */
SHORT length_of_rvlc_sf; /* 3 */ /* original value, gets modified
(subtract 9) in case of noise
(PNS); is kept for later use */
INT dpcm_noise_nrg; /* 4 optional */
INT sf_escapes_present; /* 5 */
SHORT length_of_rvlc_escapes; /* 6 optional */
INT dpcm_noise_last_position; /* 7 optional */
INT dpcm_is_last_position;
INT dpcm_is_last_position;
SHORT length_of_rvlc_sf_fwd; /* length_of_rvlc_sf used for forward decoding */
SHORT length_of_rvlc_sf_bwd; /* length_of_rvlc_sf used for backward decoding */
SHORT length_of_rvlc_sf_fwd; /* length_of_rvlc_sf used for forward decoding */
SHORT
length_of_rvlc_sf_bwd; /* length_of_rvlc_sf used for backward decoding */
/* for RVL-Codeword decoder to distinguish between fwd and bwd decoding */
SHORT *pRvlBitCnt_RVL;
USHORT *pBitstrIndxRvl_RVL;
SHORT *pRvlBitCnt_RVL;
INT *pBitstrIndxRvl_RVL;
UCHAR numWindowGroups;
UCHAR maxSfbTransmitted;
UCHAR first_noise_group;
UCHAR first_noise_band;
UCHAR direction;
UCHAR numWindowGroups;
UCHAR maxSfbTransmitted;
UCHAR first_noise_group;
UCHAR first_noise_band;
UCHAR direction;
/* bitstream indices */
USHORT bitstreamIndexRvlFwd; /* base address of RVL-coded-scalefactor data (ESC 2) for forward decoding */
USHORT bitstreamIndexRvlBwd; /* base address of RVL-coded-scalefactor data (ESC 2) for backward decoding */
USHORT bitstreamIndexEsc; /* base address where RVLC-escapes start (ESC 2) */
INT bitstreamIndexRvlFwd; /* base address of RVL-coded-scalefactor data (ESC
2) for forward decoding */
INT bitstreamIndexRvlBwd; /* base address of RVL-coded-scalefactor data (ESC
2) for backward decoding */
INT bitstreamIndexEsc; /* base address where RVLC-escapes start (ESC 2) */
/* decoding trees */
const UINT *pHuffTreeRvlCodewds;
const UINT *pHuffTreeRvlcEscape;
/* escape counters */
UCHAR numDecodedEscapeWordsFwd; /* when decoding RVL-codes forward */
UCHAR numDecodedEscapeWordsBwd; /* when decoding RVL-codes backward */
UCHAR numDecodedEscapeWordsEsc; /* when decoding the escape-Words */
UCHAR numDecodedEscapeWordsFwd; /* when decoding RVL-codes forward */
UCHAR numDecodedEscapeWordsBwd; /* when decoding RVL-codes backward */
UCHAR numDecodedEscapeWordsEsc; /* when decoding the escape-Words */
SCHAR noise_used;
SCHAR intensity_used;
SCHAR sf_used;
SCHAR noise_used;
SCHAR intensity_used;
SCHAR sf_used;
SHORT firstScf;
SHORT lastScf;
SHORT firstNrg;
SHORT lastNrg;
SHORT firstIs;
SHORT lastIs;
SHORT firstScf;
SHORT lastScf;
SHORT firstNrg;
SHORT lastNrg;
SHORT firstIs;
SHORT lastIs;
/* ------ RVLC error detection ------ */
UINT errorLogRvlc; /* store RVLC errors */
SHORT conceal_min; /* is set at backward decoding */
SHORT conceal_max; /* is set at forward decoding */
SHORT conceal_min_esc; /* is set at backward decoding */
SHORT conceal_max_esc; /* is set at forward decoding */
UINT errorLogRvlc; /* store RVLC errors */
SHORT conceal_min; /* is set at backward decoding */
SHORT conceal_max; /* is set at forward decoding */
SHORT conceal_min_esc; /* is set at backward decoding */
SHORT conceal_max_esc; /* is set at forward decoding */
} CErRvlcInfo;
typedef CErRvlcInfo RVLC_INFO; /* temp */
#endif /* RVLC_INFO_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,7 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s):
Description:
*******************************************************************************/
/*!
\file
@ -89,28 +108,27 @@ amm-info@iis.fraunhofer.de
#include "rvlcbit.h"
/*---------------------------------------------------------------------------------------------
function: rvlcReadBitFromBitstream
description: This function returns a bit from the bitstream according to read direction.
It is called very often, therefore it makes sense to inline it (runtime).
description: This function returns a bit from the bitstream according to
read direction. It is called very often, therefore it makes sense to inline it
(runtime).
-----------------------------------------------------------------------------------------------
input: - bitstream
- pPosition
- readDirection
-----------------------------------------------------------------------------------------------
return: - bit from bitstream
-------------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------------
*/
UCHAR rvlcReadBitFromBitstream (HANDLE_FDK_BITSTREAM bs,
USHORT *pPosition,
UCHAR readDirection)
{
UINT bit;
INT readBitOffset = *pPosition-FDKgetBitCnt(bs);
UCHAR rvlcReadBitFromBitstream(HANDLE_FDK_BITSTREAM bs, INT *pPosition,
UCHAR readDirection) {
UINT bit;
INT readBitOffset = *pPosition - FDKgetBitCnt(bs);
if( readBitOffset ) {
if (readBitOffset) {
FDKpushBiDirectional(bs, readBitOffset);
}
@ -128,4 +146,3 @@ UCHAR rvlcReadBitFromBitstream (HANDLE_FDK_BITSTREAM bs,
return (bit);
}

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,11 +90,12 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ***************************
/**************************** AAC decoder library ******************************
Author(s): Robert Weidner (DSP Solutions)
Description: RVLC Decoder: Bitstream reading
*******************************************************************************/
@ -91,13 +103,9 @@ amm-info@iis.fraunhofer.de
#ifndef RVLCBIT_H
#define RVLCBIT_H
#include "rvlc.h"
UCHAR rvlcReadBitFromBitstream (HANDLE_FDK_BITSTREAM bs,
USHORT *pPosition,
UCHAR readDirection);
UCHAR rvlcReadBitFromBitstream(HANDLE_FDK_BITSTREAM bs, INT *pPosition,
UCHAR readDirection);
#endif /* RVLCBIT_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,7 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s):
Description:
*******************************************************************************/
/*!
\file
@ -90,23 +109,19 @@ amm-info@iis.fraunhofer.de
#ifndef RVLCCONCEAL_H
#define RVLCCONCEAL_H
#include "rvlc.h"
void BidirectionalEstimation_UseLowerScfOfCurrentFrame(CAacDecoderChannelInfo *pAacDecoderChannelInfo);
void BidirectionalEstimation_UseLowerScfOfCurrentFrame(
CAacDecoderChannelInfo *pAacDecoderChannelInfo);
void BidirectionalEstimation_UseScfOfPrevFrameAsReference(
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo
);
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo);
void StatisticalEstimation (CAacDecoderChannelInfo *pAacDecoderChannelInfo);
void PredictiveInterpolation (
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo
);
void StatisticalEstimation(CAacDecoderChannelInfo *pAacDecoderChannelInfo);
void PredictiveInterpolation(
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo);
#endif /* RVLCCONCEAL_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,35 +90,100 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
/**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl
Description: joint stereo processing
******************************************************************************/
*******************************************************************************/
#ifndef STEREO_H
#define STEREO_H
#include "machine_type.h"
#include "FDK_bitstream.h"
#include "common_fix.h"
enum
{
JointStereoMaximumGroups = 8,
JointStereoMaximumBands = 64
};
#define SFB_PER_PRED_BAND 2
typedef struct
{
#define SR_FNA_OUT \
0 /* Additional scaling of the CJointStereo_filterAndAdd()-output to avoid \
overflows. */
/* The scaling factor can be set to 0 if the coefficients are prescaled
* appropriately. */
/* Prescaling via factor SF_FNA_COEFFS is done at compile-time but should only
* be */
/* utilized if the coefficients are stored as FIXP_DBL. (cp. aac_rom.cpp/.h) */
/* The NO_CPLX_PRED_BUGFIX-switch was introduced to enable decoding of
conformance-streams in way that they are comparable to buggy
reference-streams. This is established by storing the prediction direction
for computation of the "downmix MDCT of previous frame". This is not standard
compliant. Once correct reference-streams for complex-stereo-prediction are
available this switch becomes obsolete.
*/
/*#define NO_CPLX_PRED_BUGFIX*/
enum { JointStereoMaximumGroups = 8, JointStereoMaximumBands = 64 };
typedef struct {
UCHAR pred_dir; // 0 = prediction from mid to side channel, 1 = vice versa
UCHAR
igf_pred_dir; // 0 = prediction from mid to side channel, 1 = vice versa
UCHAR complex_coef; // 0 = alpha_q_im[x] is 0 for all prediction bands, 1 =
// alpha_q_im[x] is transmitted via bitstream
UCHAR use_prev_frame; // 0 = use current frame for MDST estimation, 1 = use
// current and previous frame
SHORT alpha_q_re[JointStereoMaximumGroups][JointStereoMaximumBands];
SHORT alpha_q_im[JointStereoMaximumGroups][JointStereoMaximumBands];
} CCplxPredictionData;
/* joint stereo scratch memory (valid for this frame) */
typedef struct {
UCHAR MsMaskPresent;
UCHAR MsUsed[JointStereoMaximumBands]; /*!< every arry element contains flags for up to 8 groups */
UCHAR MsUsed[JointStereoMaximumBands]; /*!< every arry element contains flags
for up to 8 groups. this array is
also utilized for complex stereo
prediction. */
UCHAR IGF_MsMaskPresent;
UCHAR cplx_pred_flag; /* stereo complex prediction was signalled for this
frame */
UCHAR igf_cplx_pred_flag;
/* The following array and variable are needed for the case when INF is
* active */
FIXP_DBL store_dmx_re_prev[1024];
SHORT store_dmx_re_prev_e;
} CJointStereoData;
/* joint stereo persistent memory */
typedef struct {
UCHAR clearSpectralCoeffs; /* indicates that the spectral coeffs must be
cleared because the transform splitting active
flag of the left and right channel was different
*/
FIXP_DBL *scratchBuffer; /* pointer to scratch buffer */
FIXP_DBL
*spectralCoeffs[2]; /* spectral coefficients of this channel utilized by
complex stereo prediction */
SHORT *specScale[2];
SHORT alpha_q_re_prev[JointStereoMaximumGroups][JointStereoMaximumBands];
SHORT alpha_q_im_prev[JointStereoMaximumGroups][JointStereoMaximumBands];
UCHAR winSeqPrev;
UCHAR winShapePrev;
UCHAR winGroupsPrev;
} CJointStereoPersistentData;
/*!
\brief Read joint stereo data from bitstream
@ -115,20 +191,21 @@ typedef struct
The function reads joint stereo data from bitstream.
\param bs bit stream handle data source.
\param pJointStereoData pointer to stereo data structure to receive decoded data.
\param windowGroups number of window groups.
\param scaleFactorBandsTransmitted number of transmitted scalefactor bands.
\param flags decoder flags
\param pJointStereoData pointer to stereo data structure to receive decoded
data. \param windowGroups number of window groups. \param
scaleFactorBandsTransmitted number of transmitted scalefactor bands. \param
flags decoder flags
\return 0 on success, -1 on error.
*/
int CJointStereo_Read(
HANDLE_FDK_BITSTREAM bs,
CJointStereoData *pJointStereoData,
int windowGroups,
int scaleFactorBandsTransmitted,
UINT flags
);
int CJointStereo_Read(HANDLE_FDK_BITSTREAM bs,
CJointStereoData *pJointStereoData,
const int windowGroups,
const int scaleFactorBandsTransmitted,
const int max_sfb_ste_clear,
CJointStereoPersistentData *pJointStereoPersistentData,
CCplxPredictionData *cplxPredictionData,
int cplxPredictionActiv, int scaleFactorBandsTotal,
int windowSequence, const UINT flags);
#endif /* #ifndef STEREO_H */

View File

@ -0,0 +1,439 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
Fraunhofer Institute for Integrated Circuits IIS
Attention: Audio and Multimedia Departments - FDK AAC LL
Am Wolfsmantel 33
91058 Erlangen, Germany
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s):
Description: ACELP
*******************************************************************************/
#include "usacdec_ace_d4t64.h"
#define L_SUBFR 64 /* Subframe size */
/*
* D_ACELP_add_pulse
*
* Parameters:
* pos I: position of pulse
* nb_pulse I: number of pulses
* track I: track
* code O: fixed codebook
*
* Function:
* Add pulses to fixed codebook
*
* Returns:
* void
*/
static void D_ACELP_add_pulse(SHORT pos[], SHORT nb_pulse, SHORT track,
FIXP_COD code[]) {
SHORT i, k;
for (k = 0; k < nb_pulse; k++) {
/* i = ((pos[k] & (16-1))*NB_TRACK) + track; */
i = ((pos[k] & (16 - 1)) << 2) + track;
if ((pos[k] & 16) == 0) {
code[i] = code[i] + (FIXP_COD)(512 << (COD_BITS - FRACT_BITS));
} else {
code[i] = code[i] - (FIXP_COD)(512 << (COD_BITS - FRACT_BITS));
}
}
return;
}
/*
* D_ACELP_decode_1p_N1
*
* Parameters:
* index I: pulse index
* N I: number of bits for position
* offset I: offset
* pos O: position of the pulse
*
* Function:
* Decode 1 pulse with N+1 bits
*
* Returns:
* void
*/
static void D_ACELP_decode_1p_N1(LONG index, SHORT N, SHORT offset,
SHORT pos[]) {
SHORT pos1;
LONG i, mask;
mask = ((1 << N) - 1);
/*
* Decode 1 pulse with N+1 bits
*/
pos1 = (SHORT)((index & mask) + offset);
i = ((index >> N) & 1);
if (i == 1) {
pos1 += 16;
}
pos[0] = pos1;
return;
}
/*
* D_ACELP_decode_2p_2N1
*
* Parameters:
* index I: pulse index
* N I: number of bits for position
* offset I: offset
* pos O: position of the pulse
*
* Function:
* Decode 2 pulses with 2*N+1 bits
*
* Returns:
* void
*/
static void D_ACELP_decode_2p_2N1(LONG index, SHORT N, SHORT offset,
SHORT pos[]) {
SHORT pos1, pos2;
LONG mask, i;
mask = ((1 << N) - 1);
/*
* Decode 2 pulses with 2*N+1 bits
*/
pos1 = (SHORT)(((index >> N) & mask) + offset);
i = (index >> (2 * N)) & 1;
pos2 = (SHORT)((index & mask) + offset);
if ((pos2 - pos1) < 0) {
if (i == 1) {
pos1 += 16;
} else {
pos2 += 16;
}
} else {
if (i == 1) {
pos1 += 16;
pos2 += 16;
}
}
pos[0] = pos1;
pos[1] = pos2;
return;
}
/*
* D_ACELP_decode_3p_3N1
*
* Parameters:
* index I: pulse index
* N I: number of bits for position
* offset I: offset
* pos O: position of the pulse
*
* Function:
* Decode 3 pulses with 3*N+1 bits
*
* Returns:
* void
*/
static void D_ACELP_decode_3p_3N1(LONG index, SHORT N, SHORT offset,
SHORT pos[]) {
SHORT j;
LONG mask, idx;
/*
* Decode 3 pulses with 3*N+1 bits
*/
mask = ((1 << ((2 * N) - 1)) - 1);
idx = index & mask;
j = offset;
if (((index >> ((2 * N) - 1)) & 1) == 1) {
j += (1 << (N - 1));
}
D_ACELP_decode_2p_2N1(idx, N - 1, j, pos);
mask = ((1 << (N + 1)) - 1);
idx = (index >> (2 * N)) & mask;
D_ACELP_decode_1p_N1(idx, N, offset, pos + 2);
return;
}
/*
* D_ACELP_decode_4p_4N1
*
* Parameters:
* index I: pulse index
* N I: number of bits for position
* offset I: offset
* pos O: position of the pulse
*
* Function:
* Decode 4 pulses with 4*N+1 bits
*
* Returns:
* void
*/
static void D_ACELP_decode_4p_4N1(LONG index, SHORT N, SHORT offset,
SHORT pos[]) {
SHORT j;
LONG mask, idx;
/*
* Decode 4 pulses with 4*N+1 bits
*/
mask = ((1 << ((2 * N) - 1)) - 1);
idx = index & mask;
j = offset;
if (((index >> ((2 * N) - 1)) & 1) == 1) {
j += (1 << (N - 1));
}
D_ACELP_decode_2p_2N1(idx, N - 1, j, pos);
mask = ((1 << ((2 * N) + 1)) - 1);
idx = (index >> (2 * N)) & mask;
D_ACELP_decode_2p_2N1(idx, N, offset, pos + 2);
return;
}
/*
* D_ACELP_decode_4p_4N
*
* Parameters:
* index I: pulse index
* N I: number of bits for position
* offset I: offset
* pos O: position of the pulse
*
* Function:
* Decode 4 pulses with 4*N bits
*
* Returns:
* void
*/
static void D_ACELP_decode_4p_4N(LONG index, SHORT N, SHORT offset,
SHORT pos[]) {
SHORT j, n_1;
/*
* Decode 4 pulses with 4*N bits
*/
n_1 = N - 1;
j = offset + (1 << n_1);
switch ((index >> ((4 * N) - 2)) & 3) {
case 0:
if (((index >> ((4 * n_1) + 1)) & 1) == 0) {
D_ACELP_decode_4p_4N1(index, n_1, offset, pos);
} else {
D_ACELP_decode_4p_4N1(index, n_1, j, pos);
}
break;
case 1:
D_ACELP_decode_1p_N1((index >> ((3 * n_1) + 1)), n_1, offset, pos);
D_ACELP_decode_3p_3N1(index, n_1, j, pos + 1);
break;
case 2:
D_ACELP_decode_2p_2N1((index >> ((2 * n_1) + 1)), n_1, offset, pos);
D_ACELP_decode_2p_2N1(index, n_1, j, pos + 2);
break;
case 3:
D_ACELP_decode_3p_3N1((index >> (n_1 + 1)), n_1, offset, pos);
D_ACELP_decode_1p_N1(index, n_1, j, pos + 3);
break;
}
return;
}
/*
* D_ACELP_decode_4t
*
* Parameters:
* index I: index
* mode I: speech mode
* code I: (Q9) algebraic (fixed) codebook excitation
*
* Function:
* 20, 36, 44, 52, 64, 72, 88 bits algebraic codebook.
* 4 tracks x 16 positions per track = 64 samples.
*
* 20 bits 5+5+5+5 --> 4 pulses in a frame of 64 samples.
* 36 bits 9+9+9+9 --> 8 pulses in a frame of 64 samples.
* 44 bits 13+9+13+9 --> 10 pulses in a frame of 64 samples.
* 52 bits 13+13+13+13 --> 12 pulses in a frame of 64 samples.
* 64 bits 2+2+2+2+14+14+14+14 --> 16 pulses in a frame of 64 samples.
* 72 bits 10+2+10+2+10+14+10+14 --> 18 pulses in a frame of 64 samples.
* 88 bits 11+11+11+11+11+11+11+11 --> 24 pulses in a frame of 64 samples.
*
* All pulses can have two (2) possible amplitudes: +1 or -1.
* Each pulse can sixteen (16) possible positions.
*
* codevector length 64
* number of track 4
* number of position 16
*
* Returns:
* void
*/
void D_ACELP_decode_4t64(SHORT index[], int nbits, FIXP_COD code[]) {
LONG L_index;
SHORT k, pos[6];
FDKmemclear(code, L_SUBFR * sizeof(FIXP_COD));
/* decode the positions and signs of pulses and build the codeword */
switch (nbits) {
case 12:
for (k = 0; k < 4; k += 2) {
L_index = index[2 * (k / 2) + 1];
D_ACELP_decode_1p_N1(L_index, 4, 0, pos);
D_ACELP_add_pulse(pos, 1, 2 * (index[2 * (k / 2)]) + k / 2, code);
}
break;
case 16: {
int i = 0;
int offset = index[i++];
offset = (offset == 0) ? 1 : 3;
for (k = 0; k < 4; k++) {
if (k != offset) {
L_index = index[i++];
D_ACELP_decode_1p_N1(L_index, 4, 0, pos);
D_ACELP_add_pulse(pos, 1, k, code);
}
}
} break;
case 20:
for (k = 0; k < 4; k++) {
L_index = (LONG)index[k];
D_ACELP_decode_1p_N1(L_index, 4, 0, pos);
D_ACELP_add_pulse(pos, 1, k, code);
}
break;
case 28:
for (k = 0; k < 4 - 2; k++) {
L_index = (LONG)index[k];
D_ACELP_decode_2p_2N1(L_index, 4, 0, pos);
D_ACELP_add_pulse(pos, 2, k, code);
}
for (k = 2; k < 4; k++) {
L_index = (LONG)index[k];
D_ACELP_decode_1p_N1(L_index, 4, 0, pos);
D_ACELP_add_pulse(pos, 1, k, code);
}
break;
case 36:
for (k = 0; k < 4; k++) {
L_index = (LONG)index[k];
D_ACELP_decode_2p_2N1(L_index, 4, 0, pos);
D_ACELP_add_pulse(pos, 2, k, code);
}
break;
case 44:
for (k = 0; k < 4 - 2; k++) {
L_index = (LONG)index[k];
D_ACELP_decode_3p_3N1(L_index, 4, 0, pos);
D_ACELP_add_pulse(pos, 3, k, code);
}
for (k = 2; k < 4; k++) {
L_index = (LONG)index[k];
D_ACELP_decode_2p_2N1(L_index, 4, 0, pos);
D_ACELP_add_pulse(pos, 2, k, code);
}
break;
case 52:
for (k = 0; k < 4; k++) {
L_index = (LONG)index[k];
D_ACELP_decode_3p_3N1(L_index, 4, 0, pos);
D_ACELP_add_pulse(pos, 3, k, code);
}
break;
case 64:
for (k = 0; k < 4; k++) {
L_index = (((LONG)index[k] << 14) + (LONG)index[k + 4]);
D_ACELP_decode_4p_4N(L_index, 4, 0, pos);
D_ACELP_add_pulse(pos, 4, k, code);
}
break;
default:
FDK_ASSERT(0);
}
return;
}

View File

@ -0,0 +1,117 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
Fraunhofer Institute for Integrated Circuits IIS
Attention: Audio and Multimedia Departments - FDK AAC LL
Am Wolfsmantel 33
91058 Erlangen, Germany
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s):
Description: ACELP
*******************************************************************************/
#ifndef USACDEC_ACE_D4T64_H
#define USACDEC_ACE_D4T64_H
#include "common_fix.h"
/* Data type definition for the fixed codebook vector */
#define FIXP_COD FIXP_SGL
#define FX_COD2FX_DBL(x) (FX_SGL2FX_DBL(x))
#define FX_DBL2FX_COD(x) FX_DBL2FX_SGL((x) + (FIXP_DBL)0x8000)
#define FX_SGL2FX_COD(x) (x)
#define COD_BITS FRACT_BITS
void D_ACELP_decode_4t64(SHORT index[], int nbits, FIXP_COD code[]);
#endif /* USACDEC_ACE_D4T64_H */

View File

@ -0,0 +1,229 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
Fraunhofer Institute for Integrated Circuits IIS
Attention: Audio and Multimedia Departments - FDK AAC LL
Am Wolfsmantel 33
91058 Erlangen, Germany
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): Matthias Hildenbrand
Description: USAC ACELP LTP filter
*******************************************************************************/
#include "usacdec_ace_ltp.h"
#include "genericStds.h"
#include "common_fix.h"
#define UP_SAMP 4
#define L_INTERPOL2 16
#define L_SUBFR 64
#define A2 FL2FX_SGL(2 * 0.18f)
#define B FL2FX_SGL(0.64f)
static const LONG Pred_lt4_inter4_2[UP_SAMP][L_INTERPOL2] = {
{(LONG)0x0000FFFC, (LONG)0x0008FFFC, (LONG)0xFFEB004C, (LONG)0xFF50014A,
(LONG)0xFDD90351, (LONG)0xFB2A06CD, (LONG)0xF6920D46, (LONG)0xEBB42B35,
(LONG)0x6D9EEF39, (LONG)0x0618FE0F, (LONG)0xFFE00131, (LONG)0xFE5501C5,
(LONG)0xFE5E015D, (LONG)0xFEF700B6, (LONG)0xFF920037, (LONG)0xFFEC0003},
{(LONG)0x0002FFF2, (LONG)0x0026FFBD, (LONG)0x005DFF98, (LONG)0x0055FFEF,
(LONG)0xFF89015F, (LONG)0xFD3A04E5, (LONG)0xF7D90DAA, (LONG)0xE67A50EE,
(LONG)0x50EEE67A, (LONG)0x0DAAF7D9, (LONG)0x04E5FD3A, (LONG)0x015FFF89,
(LONG)0xFFEF0055, (LONG)0xFF98005D, (LONG)0xFFBD0026, (LONG)0xFFF20002},
{(LONG)0x0003FFEC, (LONG)0x0037FF92, (LONG)0x00B6FEF7, (LONG)0x015DFE5E,
(LONG)0x01C5FE55, (LONG)0x0131FFE0, (LONG)0xFE0F0618, (LONG)0xEF396D9E,
(LONG)0x2B35EBB4, (LONG)0x0D46F692, (LONG)0x06CDFB2A, (LONG)0x0351FDD9,
(LONG)0x014AFF50, (LONG)0x004CFFEB, (LONG)0xFFFC0008, (LONG)0xFFFC0000},
{(LONG)0x0002FFF2, (LONG)0x002BFF9E, (LONG)0x00B9FECE, (LONG)0x01CFFD75,
(LONG)0x035EFBC1, (LONG)0x0521FA0C, (LONG)0x06AAF8C9, (LONG)0x07907852,
(LONG)0x0790F8C9, (LONG)0x06AAFA0C, (LONG)0x0521FBC1, (LONG)0x035EFD75,
(LONG)0x01CFFECE, (LONG)0x00B9FF9E, (LONG)0x002BFFF2, (LONG)0x00020000}};
void Pred_lt4(FIXP_DBL exc[], /* in/out: excitation buffer */
int T0, /* input : integer pitch lag */
int frac /* input : fraction of lag in range 0..3 */
) {
int j;
FIXP_DBL *x;
const LONG *interpol;
FIXP_DBL L_sumb, L_sumt;
x = &exc[-T0 - L_INTERPOL2 + 1];
/* remap frac and x:
0 -> 3 x (unchanged)
1 -> 0 x--
2 -> 1 x--
3 -> 2 x--
*/
if (--frac < 0)
frac += UP_SAMP;
else
x--;
j = L_SUBFR + 1;
do {
LONG filt;
FIXP_DBL x0, x1;
FIXP_DBL *xi = x++;
interpol = Pred_lt4_inter4_2[frac];
int i = 3;
filt = *interpol++;
x0 = *xi++;
x1 = *xi++;
L_sumt = fMultDiv2(x0, (FIXP_SGL)((SHORT)(filt >> 16)));
L_sumb = fMultDiv2(x1, (FIXP_SGL)((SHORT)filt));
do {
filt = *interpol++;
x0 = *xi++;
x1 = *xi++;
L_sumt = fMultAddDiv2(L_sumt, x0, (FIXP_SGL)((SHORT)(filt >> 16)));
L_sumb = fMultAddDiv2(L_sumb, x1, (FIXP_SGL)((SHORT)filt));
filt = *interpol++;
x0 = *xi++;
x1 = *xi++;
L_sumt = fMultAddDiv2(L_sumt, x0, (FIXP_SGL)((SHORT)(filt >> 16)));
L_sumb = fMultAddDiv2(L_sumb, x1, (FIXP_SGL)((SHORT)filt));
filt = *interpol++;
x0 = *xi++;
x1 = *xi++;
L_sumt = fMultAddDiv2(L_sumt, x0, (FIXP_SGL)((SHORT)(filt >> 16)));
L_sumb = fMultAddDiv2(L_sumb, x1, (FIXP_SGL)((SHORT)filt));
filt = *interpol++;
x0 = *xi++;
x1 = *xi++;
L_sumt = fMultAddDiv2(L_sumt, x0, (FIXP_SGL)((SHORT)(filt >> 16)));
L_sumb = fMultAddDiv2(L_sumb, x1, (FIXP_SGL)((SHORT)filt));
filt = *interpol++;
x0 = *xi++;
x1 = *xi++;
L_sumt = fMultAddDiv2(L_sumt, x0, (FIXP_SGL)((SHORT)(filt >> 16)));
L_sumb = fMultAddDiv2(L_sumb, x1, (FIXP_SGL)((SHORT)filt));
} while (--i != 0);
L_sumb <<= 1;
L_sumb = fAddSaturate(L_sumt << 1, L_sumb);
*exc++ = L_sumb;
} while (--j != 0);
return;
}
void Pred_lt4_postfilter(FIXP_DBL exc[] /* in/out: excitation buffer */
) {
/*
exc[i] = A*exc[i-1] + B*exc[i] + A*exc[i+1]
exc[i+1] = A*exc[i] + B*exc[i+1] + A*exc[i+2] ; i = 0:2:62
*/
int i;
FIXP_DBL sum0, sum1, a_exc0, a_exc1;
a_exc0 = fMultDiv2(A2, exc[-1]);
a_exc1 = fMultDiv2(A2, exc[0]);
/* ARM926: 22 cycles/iteration */
for (i = 0; i < L_SUBFR; i += 2) {
sum0 = a_exc0 + fMult(B, exc[i]);
sum1 = a_exc1 + fMult(B, exc[i + 1]);
a_exc0 = fMultDiv2(A2, exc[i + 1]);
a_exc1 = fMultDiv2(A2, exc[i + 2]);
exc[i] = sum0 + a_exc0;
exc[i + 1] = sum1 + a_exc1;
}
return;
}

View File

@ -0,0 +1,128 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
Fraunhofer Institute for Integrated Circuits IIS
Attention: Audio and Multimedia Departments - FDK AAC LL
Am Wolfsmantel 33
91058 Erlangen, Germany
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): Matthias Hildenbrand
Description: USAC ACELP LTP filter
*******************************************************************************/
#ifndef USACDEC_ACE_LTP_H
#define USACDEC_ACE_LTP_H
#include "common_fix.h"
/**
* \brief Compute the initial adaptive codebook excitation v'(n) by
* interpolating the past excitation vector u'(n).
* \param exc points to adaptive codebook of current subframe (input/output)
* \param T0 integer part of decoded pitch lag (input)
* \param frac fractional part of decoded pitch lag (0..3) (input)
*/
void Pred_lt4(FIXP_DBL exc[], /* in/out: excitation buffer */
int T0, /* input : integer pitch lag */
int frac /* input : fraction of lag */
);
/**
* \brief Compute the adaptive codebook excitation v(n) in case of
* ltp_filtering_flag == 0.
* \param exc points to adaptive codebook of current subframe (input/output)
*/
void Pred_lt4_postfilter(FIXP_DBL exc[] /* in/out: excitation buffer */
);
#endif /* USACDEC_ACE_LTP_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,280 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
Fraunhofer Institute for Integrated Circuits IIS
Attention: Audio and Multimedia Departments - FDK AAC LL
Am Wolfsmantel 33
91058 Erlangen, Germany
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): Matthias Hildenbrand
Description: USAC ACELP frame decoder
*******************************************************************************/
#ifndef USACDEC_ACELP_H
#define USACDEC_ACELP_H
#include "common_fix.h"
#include "FDK_bitstream.h"
#include "usacdec_const.h"
#include "usacdec_rom.h"
//#define ENHANCED_TCX_TD_CONCEAL_ENABLE
/** Structure which holds the ACELP internal persistent memory */
typedef struct {
FIXP_DBL old_exc_mem[PIT_MAX_MAX + L_INTERPOL];
FIXP_DBL old_syn_mem[M_LP_FILTER_ORDER]; /* synthesis filter states */
FIXP_SGL A[M_LP_FILTER_ORDER];
INT A_exp;
FIXP_DBL gc_threshold;
FIXP_DBL de_emph_mem;
FIXP_SGL past_gpit;
FIXP_DBL past_gcode;
USHORT old_T0;
UCHAR old_T0_frac;
FIXP_DBL deemph_mem_wsyn;
FIXP_DBL wsyn_rms;
SHORT seed_ace;
} CAcelpStaticMem;
/** Structure which holds the parameter data needed to decode one ACELP frame.
*/
typedef struct {
UCHAR
acelp_core_mode; /**< mean excitation energy index for whole ACELP frame
*/
UCHAR mean_energy; /**< acelp core mode for whole ACELP frame */
USHORT T0[NB_SUBFR];
UCHAR T0_frac[NB_SUBFR];
UCHAR ltp_filtering_flag[NB_SUBFR]; /**< controlls whether LTP postfilter is
active for each ACELP subframe */
SHORT icb_index[NB_SUBFR]
[8]; /**< innovative codebook index for each ACELP subframe */
UCHAR gains[NB_SUBFR]; /**< gain index for each ACELP subframe */
} CAcelpChannelData;
/**
* \brief Read the acelp_coding() bitstream part.
* \param[in] hBs bitstream handle to read data from.
* \param[out] acelpData pointer to structure to store the parsed data of one
* ACELP frame.
* \param[in] acelp_core_mode the ACELP core mode index.
* \param[in] coreCoderFrameLength length of core coder frame (1024|768)
*/
INT CLpd_AcelpRead(HANDLE_FDK_BITSTREAM hBs, CAcelpChannelData *acelpData,
INT acelp_core_mode, INT i_offset, INT coreCoderFrameLength);
/**
* \brief Initialization of memory before one LPD frame is decoded
* \param[out] synth_buf synthesis buffer to be initialized, exponent = SF_SYNTH
* \param[in] old_synth past synthesis of previous LPD frame, exponent =
* SF_SYNTH
* \param[out] synth_buf_fb fullband synthesis buffer to be initialized,
* exponent = SF_SYNTH
* \param[in] old_synth_fb past fullband synthesis of previous LPD frame,
* exponent = SF_SYNTH
* \param[out] pitch vector where decoded pitch lag values are stored
* \param[in] old_T_pf past pitch lag values of previous LPD frame
* \param[in] samplingRate sampling rate for pitch lag offset calculation
* \param[out] i_offset pitch lag offset for the decoding of the pitch lag
* \param[in] coreCoderFrameLength length of core coder frame (1024|768)
*/
void Acelp_PreProcessing(FIXP_DBL *synth_buf, FIXP_DBL *old_synth, INT *pitch,
INT *old_T_pf, FIXP_DBL *pit_gain,
FIXP_DBL *old_gain_pf, INT samplingRate, INT *i_offset,
INT coreCoderFrameLength, INT synSfd,
INT nbSubfrSuperfr);
/**
* \brief Save tail of buffers for the initialization of the next LPD frame
* \param[in] synth_buf synthesis of current LPD frame, exponent = SF_SYNTH
* \param[out] old_synth memory where tail of fullband synth_buf is stored,
* exponent = SF_SYNTH
* \param[in] synth_buf_fb fullband synthesis of current LPD frame, exponent =
* SF_SYNTH
* \param[out] old_synth_fb memory where tail of fullband synth_buf is stored,
* exponent = SF_SYNTH
* \param[in] pitch decoded pitch lag values of current LPD frame
* \param[out] old_T_pf memory where last SYN_SFD pitch lag values are stored
*/
void Acelp_PostProcessing(FIXP_DBL *synth_buf, FIXP_DBL *old_synth, INT *pitch,
INT *old_T_pf, INT coreCoderFrameLength, INT synSfd,
INT nbSubfrSuperfr);
/**
* \brief Decode one ACELP frame (three or four ACELP subframes with 64 samples
* each)
* \param[in,out] acelp_mem pointer to ACELP memory structure
* \param[in] i_offset pitch lag offset
* \param[in] lsp_old LPC filter in LSP domain corresponding to previous frame
* \param[in] lsp_new LPC filter in LSP domain corresponding to current frame
* \param[in] stab_fac stability factor constrained by 0<=stab_fac<=1.0,
* exponent = SF_STAB
* \param[in] acelpData pointer to struct with data which is needed for decoding
* one ACELP frame
* \param[out] synth ACELP output signal
* \param[out] pT four decoded pitch lag values
* \param[in] coreCoderFrameLength length of core coder frame (1024|768)
*/
void CLpd_AcelpDecode(CAcelpStaticMem *acelp_mem, INT i_offset,
const FIXP_LPC lsp_old[M_LP_FILTER_ORDER],
const FIXP_LPC lsp_new[M_LP_FILTER_ORDER],
FIXP_SGL stab_fac, CAcelpChannelData *acelpData,
INT numLostSubframes, int lastLpcLost, int frameCnt,
FIXP_DBL synth[], int pT[], FIXP_DBL *pit_gain,
INT coreCoderFrameLength);
/**
* \brief Reset ACELP internal memory.
* \param[out] acelp_mem pointer to ACELP memory structure
*/
void CLpd_AcelpReset(CAcelpStaticMem *acelp_mem);
/**
* \brief Initialize ACELP internal memory in case of FAC before ACELP decoder
* is called
* \param[in] synth points to end+1 of past valid synthesis signal, exponent =
* SF_SYNTH
* \param[in] last_lpd_mode last lpd mode
* \param[in] last_last_lpd_mode lpd mode before last_lpd_mode
* \param[in] A_new LP synthesis filter coeffs corresponding to last frame,
* exponent = SF_A_COEFFS
* \param[in] A_old LP synthesis filter coeffs corresponding to the frame before
* last frame, exponent = SF_A_COEFFS
* \param[in,out] acelp_mem pointer to ACELP memory structure
* \param[in] coreCoderFrameLength length of core coder frame (1024|768)
*/
void CLpd_AcelpPrepareInternalMem(const FIXP_DBL *synth, UCHAR last_lpd_mode,
UCHAR last_last_lpd_mode,
const FIXP_LPC *A_new, const INT A_new_exp,
const FIXP_LPC *A_old, const INT A_old_exp,
CAcelpStaticMem *acelp_mem,
INT coreCoderFrameLength, UCHAR lpd_mode);
/**
* \brief Calculate zero input response (zir) of the acelp synthesis filter
* \param[in] A LP synthesis filter coefficients, exponent = SF_A_COEFFS
* \param[in,out] acelp_mem pointer to ACELP memory structure
* \param[in] length length of zir
* \param[out] zir pointer to zir output buffer, exponent = SF_SYNTH
*/
void CLpd_Acelp_Zir(const FIXP_LPC A[], const INT A_exp,
CAcelpStaticMem *acelp_mem, const INT length,
FIXP_DBL zir[], int doDeemph);
/**
* \brief Borrow static excitation memory from ACELP decoder
* \param[in] acelp_mem pointer to ACELP memory structure
* \param[in] length number of requested FIXP_DBL values
* \return pointer to requested memory
*
* The caller has to take care not to overwrite valid memory areas.
* During TCX/FAC calculations and before CLpd_AcelpPrepareInternalMem() is
* called, the following memory size is available:
* - 256 samples in case of ACELP -> TCX20 -> ACELP transition
* - PIT_MAX_MAX+L_INTERPOL samples in all other cases
*/
FIXP_DBL *CLpd_ACELP_GetFreeExcMem(CAcelpStaticMem *acelp_mem, INT length);
void CLpd_TcxTDConceal(CAcelpStaticMem *acelp_mem, SHORT *pitch,
const FIXP_LPC lsp_old[M_LP_FILTER_ORDER],
const FIXP_LPC lsp_new[M_LP_FILTER_ORDER],
const FIXP_SGL stab_fac, INT numLostSubframes,
FIXP_DBL synth[], INT coreCoderFrameLength,
UCHAR last_tcx_noise_factor);
inline SHORT E_UTIL_random(SHORT *seed) {
*seed = (SHORT)((((LONG)*seed * (LONG)31821) >> 1) + (LONG)13849);
return (*seed);
}
#endif /* USACDEC_ACELP_H */

View File

@ -0,0 +1,202 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
Fraunhofer Institute for Integrated Circuits IIS
Attention: Audio and Multimedia Departments - FDK AAC LL
Am Wolfsmantel 33
91058 Erlangen, Germany
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): Manuel Jander
Description: USAC related constants
*******************************************************************************/
#ifndef USACDEC_CONST_H
#define USACDEC_CONST_H
/* scale factors */
#define SF_CODE 6 /* exponent of code[], fixed codebook vector */
#define SF_GAIN_C 16 /* exponent of gain code and smoothed gain code */
#define SF_EXC 16 /* exponent of exc[] and exc2[], excitation buffer */
#define SF_GAIN_P 1 /* exponent of gain_pit */
#define SF_PFAC 0 /* exponent of period/voicing factor */
#define SF_SYNTH SF_EXC /* exponent of synthesis buffer */
#define SF_A_COEFFS 3 /* exponent of LP domain synthesis filter coefficient */
#define SF_STAB 1 /* exponent of stability factor */
/* definitions which are independent of coreCoderFrameLength */
#define M_LP_FILTER_ORDER 16 /* LP filter order */
#define PIT_MIN_12k8 34 /* Minimum pitch lag with resolution 1/4 */
#define PIT_MAX_12k8 231 /* Maximum pitch lag for fs=12.8kHz */
#define FSCALE_DENOM 12800 /* Frequency scale denominator */
#define FAC_FSCALE_MIN \
6000 /* Minimum allowed frequency scale for acelp decoder */
#if !defined(LPD_MAX_CORE_SR)
#define LPD_MAX_CORE_SR 24000 /* Default value from ref soft */
#endif
#define FAC_FSCALE_MAX \
LPD_MAX_CORE_SR /* Maximum allowed frequency scale for acelp decoder */
/* Maximum pitch lag (= 411 for fs_max = 24000) */
#define PIT_MAX_TMP \
(PIT_MAX_12k8 + \
(6 * \
((((FAC_FSCALE_MAX * PIT_MIN_12k8) + (FSCALE_DENOM / 2)) / FSCALE_DENOM) - \
PIT_MIN_12k8)))
#if (PIT_MAX_TMP < \
256) /* cannot be smaller because of tcx time domain concealment */
#define PIT_MAX_MAX 256
#else
#define PIT_MAX_MAX PIT_MAX_TMP
#endif
#define NB_DIV 4 /* number of division (20ms) per 80ms frame */
#define L_SUBFR 64 /* subframe size (5ms) */
#define BPF_SFD 1 /* bass postfilter delay (subframe) */
#define BPF_DELAY (BPF_SFD * L_SUBFR) /* bass postfilter delay (samples) */
#define L_FILT 12 /* Delay of up-sampling filter (bass post-filter) */
#define L_EXTRA 96 /* for bass post-filter */
#define L_INTERPOL \
(16 + 1) /* Length of filter for interpolation (acelp decoder) */
/* definitions for coreCoderFrameLength = 1024 */
#define L_FRAME_PLUS_1024 1024 /* length of one 80ms superframe */
#define L_DIV_1024 \
(L_FRAME_PLUS_1024 / NB_DIV) /* length of one acelp or tcx20 frame */
#define NB_SUBFR_1024 \
(L_DIV_1024 / L_SUBFR) /* number of 5ms subframe per division */
#define NB_SUBFR_SUPERFR_1024 \
(L_FRAME_PLUS_1024 / L_SUBFR) /* number of 5ms subframe per 80ms frame */
#define AAC_SFD_1024 (NB_SUBFR_SUPERFR_1024 / 2) /* AAC delay (subframe) */
#define AAC_DELAY_1024 (AAC_SFD_1024 * L_SUBFR) /* AAC delay (samples) */
#define SYN_SFD_1024 (AAC_SFD_1024 - BPF_SFD) /* synthesis delay (subframe) */
#define SYN_DELAY_1024 \
(SYN_SFD_1024 * L_SUBFR) /* synthesis delay (samples) \
*/
#define LFAC_1024 (L_DIV_1024 / 2) /* FAC frame length */
#define LFAC_SHORT_1024 \
(L_DIV_1024 / 4) /* for transitions EIGHT_SHORT FD->LPD and vv. */
#define FDNS_NPTS_1024 64 /* FD noise shaping resolution (64=100Hz/point) */
/* definitions for coreCoderFrameLength = 768 */
#define L_FRAME_PLUS_768 768
#define L_DIV_768 \
(L_FRAME_PLUS_768 / NB_DIV) /* length of one acelp or tcx20 frame */
#define NB_SUBFR_768 \
(L_DIV_768 / L_SUBFR) /* number of 5ms subframe per division */
#define NB_SUBFR_SUPERFR_768 \
(L_FRAME_PLUS_768 / L_SUBFR) /* number of 5ms subframe per 80ms frame */
#define AAC_SFD_768 (NB_SUBFR_SUPERFR_768 / 2) /* AAC delay (subframe) */
#define AAC_DELAY_768 (AAC_SFD_768 * L_SUBFR) /* AAC delay (samples) */
#define SYN_SFD_768 (AAC_SFD_768 - BPF_SFD) /* synthesis delay (subframe) */
#define SYN_DELAY_768 (SYN_SFD_768 * L_SUBFR) /* synthesis delay (samples) */
#define LFAC_768 (L_DIV_768 / 2) /* FAC frame length */
#define LFAC_SHORT_768 \
(L_DIV_768 / 4) /* for transitions EIGHT_SHORT FD->LPD and vv. */
/* maximum (used for memory allocation) */
#define L_FRAME_PLUS L_FRAME_PLUS_1024
#define L_DIV L_DIV_1024
#define NB_SUBFR NB_SUBFR_1024
#define NB_SUBFR_SUPERFR NB_SUBFR_SUPERFR_1024
#define AAC_SFD AAC_SFD_1024
#define AAC_DELAY AAC_DELAY_1024
#define SYN_SFD SYN_SFD_1024
#define SYN_DELAY SYN_DELAY_1024
#define LFAC LFAC_1024
#define LFAC_SHORT LFAC_SHORT_1024
#define FDNS_NPTS FDNS_NPTS_1024
#endif /* USACDEC_CONST_H */

View File

@ -0,0 +1,743 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
Fraunhofer Institute for Integrated Circuits IIS
Attention: Audio and Multimedia Departments - FDK AAC LL
Am Wolfsmantel 33
91058 Erlangen, Germany
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): Manuel Jander
Description: USAC FAC
*******************************************************************************/
#include "usacdec_fac.h"
#include "usacdec_const.h"
#include "usacdec_lpc.h"
#include "usacdec_acelp.h"
#include "usacdec_rom.h"
#include "dct.h"
#include "FDK_tools_rom.h"
#include "mdct.h"
#define SPEC_FAC(ptr, i, gl) ((ptr) + ((i) * (gl)))
FIXP_DBL *CLpd_FAC_GetMemory(CAacDecoderChannelInfo *pAacDecoderChannelInfo,
UCHAR mod[NB_DIV], int *pState) {
FIXP_DBL *ptr;
int i;
int k = 0;
int max_windows = 8;
FDK_ASSERT(*pState >= 0 && *pState < max_windows);
/* Look for free space to store FAC data. 2 FAC data blocks fit into each TCX
* spectral data block. */
for (i = *pState; i < max_windows; i++) {
if (mod[i >> 1] == 0) {
break;
}
}
*pState = i + 1;
if (i == max_windows) {
ptr = pAacDecoderChannelInfo->data.usac.fac_data0;
} else {
FDK_ASSERT(mod[(i >> 1)] == 0);
ptr = SPEC_FAC(pAacDecoderChannelInfo->pSpectralCoefficient, i,
pAacDecoderChannelInfo->granuleLength << k);
}
return ptr;
}
int CLpd_FAC_Read(HANDLE_FDK_BITSTREAM hBs, FIXP_DBL *pFac, UCHAR *pFacScale,
int length, int use_gain, int frame) {
FIXP_DBL fac_gain;
int fac_gain_e = 0;
if (use_gain) {
CLpd_DecodeGain(&fac_gain, &fac_gain_e, FDKreadBits(hBs, 7));
}
if (CLpc_DecodeAVQ(hBs, pFac, 1, 1, length) != 0) {
return -1;
}
{
int scale;
scale = getScalefactor(pFac, length);
scaleValues(pFac, length, scale);
pFacScale[frame] = DFRACT_BITS - 1 - scale;
}
if (use_gain) {
int i;
pFacScale[frame] += fac_gain_e;
for (i = 0; i < length; i++) {
pFac[i] = fMult(pFac[i], fac_gain);
}
}
return 0;
}
/**
* \brief Apply synthesis filter with zero input to x. The overall filter gain
* is 1.0.
* \param a LPC filter coefficients.
* \param length length of the input/output data vector x.
* \param x input/output vector, where the synthesis filter is applied in place.
*/
static void Syn_filt_zero(const FIXP_LPC a[], const INT a_exp, INT length,
FIXP_DBL x[]) {
int i, j;
FIXP_DBL L_tmp;
for (i = 0; i < length; i++) {
L_tmp = (FIXP_DBL)0;
for (j = 0; j < fMin(i, M_LP_FILTER_ORDER); j++) {
L_tmp -= fMultDiv2(a[j], x[i - (j + 1)]);
}
L_tmp = scaleValue(L_tmp, a_exp + 1);
x[i] = scaleValueSaturate((x[i] >> 1) + (L_tmp >> 1),
1); /* Avoid overflow issues and saturate. */
}
}
/* Table is also correct for coreCoderFrameLength = 768. Factor 3/4 is canceled
out: gainFac = 0.5 * sqrt(fac_length/lFrame)
*/
static const FIXP_DBL gainFac[4] = {0x40000000, 0x2d413ccd, 0x20000000,
0x16a09e66};
void CFac_ApplyGains(FIXP_DBL fac_data[LFAC], const INT fac_length,
const FIXP_DBL tcx_gain, const FIXP_DBL alfd_gains[],
const INT mod) {
FIXP_DBL facFactor;
int i;
FDK_ASSERT((fac_length == 128) || (fac_length == 96));
/* 2) Apply gain factor to FAC data */
facFactor = fMult(gainFac[mod], tcx_gain);
for (i = 0; i < fac_length; i++) {
fac_data[i] = fMult(fac_data[i], facFactor);
}
/* 3) Apply spectrum deshaping using alfd_gains */
for (i = 0; i < fac_length / 4; i++) {
int k;
k = i >> (3 - mod);
fac_data[i] = fMult(fac_data[i], alfd_gains[k])
<< 1; /* alfd_gains is scaled by one bit. */
}
}
static void CFac_CalcFacSignal(FIXP_DBL *pOut, FIXP_DBL *pFac,
const int fac_scale, const int fac_length,
const FIXP_LPC A[M_LP_FILTER_ORDER],
const INT A_exp, const int fAddZir,
const int isFdFac) {
FIXP_LPC wA[M_LP_FILTER_ORDER];
FIXP_DBL tf_gain = (FIXP_DBL)0;
int wlength;
int scale = fac_scale;
/* obtain tranform gain. */
imdct_gain(&tf_gain, &scale, isFdFac ? 0 : fac_length);
/* 4) Compute inverse DCT-IV of FAC data. Output scale of DCT IV is 16 bits.
*/
dct_IV(pFac, fac_length, &scale);
/* dct_IV scale = log2(fac_length). "- 7" is a factor of 2/128 */
if (tf_gain != (FIXP_DBL)0) { /* non-radix 2 transform gain */
int i;
for (i = 0; i < fac_length; i++) {
pFac[i] = fMult(tf_gain, pFac[i]);
}
}
scaleValuesSaturate(pOut, pFac, fac_length,
scale); /* Avoid overflow issues and saturate. */
E_LPC_a_weight(wA, A, M_LP_FILTER_ORDER);
/* We need the output of the IIR filter to be longer than "fac_length".
For this reason we run it with zero input appended to the end of the input
sequence, i.e. we generate its ZIR and extend the output signal.*/
FDKmemclear(pOut + fac_length, fac_length * sizeof(FIXP_DBL));
wlength = 2 * fac_length;
/* 5) Apply weighted synthesis filter to FAC data, including optional Zir (5.
* item 4). */
Syn_filt_zero(wA, A_exp, wlength, pOut);
}
INT CLpd_FAC_Mdct2Acelp(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *pFac,
const int fac_scale, FIXP_LPC *A, INT A_exp,
INT nrOutSamples, const INT fac_length,
const INT isFdFac, UCHAR prevWindowShape) {
FIXP_DBL *pOvl;
FIXP_DBL *pOut0;
const FIXP_WTP *pWindow;
int i, fl, nrSamples = 0;
FDK_ASSERT(fac_length <= 1024 / (4 * 2));
fl = fac_length * 2;
pWindow = FDKgetWindowSlope(fl, prevWindowShape);
/* Adapt window slope length in case of frame loss. */
if (hMdct->prev_fr != fl) {
int nl = 0;
imdct_adapt_parameters(hMdct, &fl, &nl, fac_length, pWindow, nrOutSamples);
FDK_ASSERT(nl == 0);
}
if (nrSamples < nrOutSamples) {
pOut0 = output;
nrSamples += hMdct->ov_offset;
/* Purge buffered output. */
FDKmemcpy(pOut0, hMdct->overlap.time, hMdct->ov_offset * sizeof(pOut0[0]));
hMdct->ov_offset = 0;
}
pOvl = hMdct->overlap.freq + hMdct->ov_size - 1;
if (nrSamples >= nrOutSamples) {
pOut0 = hMdct->overlap.time + hMdct->ov_offset;
hMdct->ov_offset += hMdct->prev_nr + fl / 2;
} else {
pOut0 = output + nrSamples;
nrSamples += hMdct->prev_nr + fl / 2;
}
if (hMdct->prevPrevAliasSymmetry == 0) {
for (i = 0; i < hMdct->prev_nr; i++) {
FIXP_DBL x = -(*pOvl--);
*pOut0 = IMDCT_SCALE_DBL(x);
pOut0++;
}
} else {
for (i = 0; i < hMdct->prev_nr; i++) {
FIXP_DBL x = (*pOvl--);
*pOut0 = IMDCT_SCALE_DBL(x);
pOut0++;
}
}
hMdct->prev_nr = 0;
{
if (pFac != NULL) {
/* Note: The FAC gain might have been applied directly after bit stream
* parse in this case. */
CFac_CalcFacSignal(pOut0, pFac, fac_scale, fac_length, A, A_exp, 0,
isFdFac);
} else {
/* Clear buffer because of the overlap and ADD! */
FDKmemclear(pOut0, fac_length * sizeof(FIXP_DBL));
}
}
i = 0;
if (hMdct->prevPrevAliasSymmetry == 0) {
for (; i < fl / 2; i++) {
FIXP_DBL x0;
/* Overlap Add */
x0 = -fMult(*pOvl--, pWindow[i].v.re);
*pOut0 += IMDCT_SCALE_DBL(x0);
pOut0++;
}
} else {
for (; i < fl / 2; i++) {
FIXP_DBL x0;
/* Overlap Add */
x0 = fMult(*pOvl--, pWindow[i].v.re);
*pOut0 += IMDCT_SCALE_DBL(x0);
pOut0++;
}
}
if (hMdct->pFacZir !=
0) { /* this should only happen for ACELP -> TCX20 -> ACELP transition */
FIXP_DBL *pOut = pOut0 - fl / 2; /* fl/2 == fac_length */
for (i = 0; i < fl / 2; i++) {
pOut[i] += IMDCT_SCALE_DBL(hMdct->pFacZir[i]);
}
hMdct->pFacZir = NULL;
}
hMdct->prev_fr = 0;
hMdct->prev_nr = 0;
hMdct->prev_tl = 0;
hMdct->prevPrevAliasSymmetry = hMdct->prevAliasSymmetry;
return nrSamples;
}
INT CLpd_FAC_Acelp2Mdct(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *_pSpec,
const SHORT spec_scale[], const int nSpec,
FIXP_DBL *pFac, const int fac_scale,
const INT fac_length, INT noOutSamples, const INT tl,
const FIXP_WTP *wrs, const INT fr, FIXP_LPC A[16],
INT A_exp, CAcelpStaticMem *acelp_mem,
const FIXP_DBL gain, const int last_frame_lost,
const int isFdFac, const UCHAR last_lpd_mode,
const int k, int currAliasingSymmetry) {
FIXP_DBL *pCurr, *pOvl, *pSpec;
const FIXP_WTP *pWindow;
const FIXP_WTB *FacWindowZir_conceal;
UCHAR doFacZirConceal = 0;
int doDeemph = 1;
const FIXP_WTB *FacWindowZir, *FacWindowSynth;
FIXP_DBL *pOut0 = output, *pOut1;
int w, i, fl, nl, nr, f_len, nrSamples = 0, s = 0, scale, total_gain_e;
FIXP_DBL *pF, *pFAC_and_FAC_ZIR = NULL;
FIXP_DBL total_gain = gain;
FDK_ASSERT(fac_length <= 1024 / (4 * 2));
switch (fac_length) {
/* coreCoderFrameLength = 1024 */
case 128:
pWindow = SineWindow256;
FacWindowZir = FacWindowZir128;
FacWindowSynth = FacWindowSynth128;
break;
case 64:
pWindow = SineWindow128;
FacWindowZir = FacWindowZir64;
FacWindowSynth = FacWindowSynth64;
break;
case 32:
pWindow = SineWindow64;
FacWindowZir = FacWindowZir32;
FacWindowSynth = FacWindowSynth32;
break;
/* coreCoderFrameLength = 768 */
case 96:
pWindow = SineWindow192;
FacWindowZir = FacWindowZir96;
FacWindowSynth = FacWindowSynth96;
break;
case 48:
pWindow = SineWindow96;
FacWindowZir = FacWindowZir48;
FacWindowSynth = FacWindowSynth48;
break;
default:
FDK_ASSERT(0);
return 0;
}
FacWindowZir_conceal = FacWindowSynth;
/* Derive NR and NL */
fl = fac_length * 2;
nl = (tl - fl) >> 1;
nr = (tl - fr) >> 1;
if (noOutSamples > nrSamples) {
/* Purge buffered output. */
FDKmemcpy(pOut0, hMdct->overlap.time, hMdct->ov_offset * sizeof(pOut0[0]));
nrSamples = hMdct->ov_offset;
hMdct->ov_offset = 0;
}
if (nrSamples >= noOutSamples) {
pOut1 = hMdct->overlap.time + hMdct->ov_offset;
if (hMdct->ov_offset < fac_length) {
pOut0 = output + nrSamples;
} else {
pOut0 = pOut1;
}
hMdct->ov_offset += fac_length + nl;
} else {
pOut1 = output + nrSamples;
pOut0 = output + nrSamples;
}
{
pFAC_and_FAC_ZIR = CLpd_ACELP_GetFreeExcMem(acelp_mem, 2 * fac_length);
{
const FIXP_DBL *pTmp1, *pTmp2;
doFacZirConceal |= ((last_frame_lost != 0) && (k == 0));
doDeemph &= (last_lpd_mode != 4);
if (doFacZirConceal) {
/* ACELP contribution in concealment case:
Use ZIR with a modified ZIR window to preserve some more energy.
Dont use FAC, which contains wrong information for concealed frame
Dont use last ACELP samples, but double ZIR, instead (afterwards) */
FDKmemclear(pFAC_and_FAC_ZIR, 2 * fac_length * sizeof(FIXP_DBL));
FacWindowSynth = (FIXP_WTB *)pFAC_and_FAC_ZIR;
FacWindowZir = FacWindowZir_conceal;
} else {
CFac_CalcFacSignal(pFAC_and_FAC_ZIR, pFac, fac_scale + s, fac_length, A,
A_exp, 1, isFdFac);
}
/* 6) Get windowed past ACELP samples and ACELP ZIR signal */
/*
* Get ACELP ZIR (pFac[]) and ACELP past samples (pOut0[]) and add them
* to the FAC synth signal contribution on pOut1[].
*/
{
{
CLpd_Acelp_Zir(A, A_exp, acelp_mem, fac_length, pFac, doDeemph);
pTmp1 = pOut0;
pTmp2 = pFac;
}
for (i = 0, w = 0; i < fac_length; i++) {
FIXP_DBL x;
/* Div2 is compensated by table scaling */
x = fMultDiv2(pTmp2[i], FacWindowZir[w]);
x += fMultDiv2(pTmp1[-i - 1], FacWindowSynth[w]);
x += pFAC_and_FAC_ZIR[i];
pOut1[i] = x;
w++;
}
}
if (doFacZirConceal) {
/* ZIR is the only ACELP contribution, so double it */
scaleValues(pOut1, fac_length, 1);
}
}
}
if (nrSamples < noOutSamples) {
nrSamples += fac_length + nl;
}
/* Obtain transform gain */
total_gain = gain;
total_gain_e = 0;
imdct_gain(&total_gain, &total_gain_e, tl);
/* IMDCT overlap add */
scale = total_gain_e;
pSpec = _pSpec;
/* Note:when comming from an LPD frame (TCX/ACELP) the previous alisaing
* symmetry must always be 0 */
if (currAliasingSymmetry == 0) {
dct_IV(pSpec, tl, &scale);
} else {
FIXP_DBL _tmp[1024 + ALIGNMENT_DEFAULT / sizeof(FIXP_DBL)];
FIXP_DBL *tmp = (FIXP_DBL *)ALIGN_PTR(_tmp);
C_ALLOC_ALIGNED_REGISTER(tmp, sizeof(_tmp));
dst_III(pSpec, tmp, tl, &scale);
C_ALLOC_ALIGNED_UNREGISTER(tmp);
}
/* Optional scaling of time domain - no yet windowed - of current spectrum */
if (total_gain != (FIXP_DBL)0) {
scaleValuesWithFactor(pSpec, total_gain, tl, spec_scale[0] + scale);
} else {
scaleValues(pSpec, tl, spec_scale[0] + scale);
}
pOut1 += fl / 2 - 1;
pCurr = pSpec + tl - fl / 2;
for (i = 0; i < fl / 2; i++) {
FIXP_DBL x1;
/* FAC signal is already on pOut1, because of that the += operator. */
x1 = fMult(*pCurr++, pWindow[i].v.re);
FDK_ASSERT((pOut1 >= hMdct->overlap.time &&
pOut1 < hMdct->overlap.time + hMdct->ov_size) ||
(pOut1 >= output && pOut1 < output + 1024));
*pOut1 += IMDCT_SCALE_DBL(-x1);
pOut1--;
}
/* NL output samples TL/2+FL/2..TL. - current[FL/2..0] */
pOut1 += (fl / 2) + 1;
pFAC_and_FAC_ZIR += fac_length; /* set pointer to beginning of FAC ZIR */
if (nl == 0) {
/* save pointer to write FAC ZIR data later */
hMdct->pFacZir = pFAC_and_FAC_ZIR;
} else {
FDK_ASSERT(nl >= fac_length);
/* FAC ZIR will be added now ... */
hMdct->pFacZir = NULL;
}
pF = pFAC_and_FAC_ZIR;
f_len = fac_length;
pCurr = pSpec + tl - fl / 2 - 1;
for (i = 0; i < nl; i++) {
FIXP_DBL x = -(*pCurr--);
/* 5) (item 4) Synthesis filter Zir component, FAC ZIR (another one). */
if (i < f_len) {
x += *pF++;
}
FDK_ASSERT((pOut1 >= hMdct->overlap.time &&
pOut1 < hMdct->overlap.time + hMdct->ov_size) ||
(pOut1 >= output && pOut1 < output + 1024));
*pOut1 = IMDCT_SCALE_DBL(x);
pOut1++;
}
hMdct->prev_nr = nr;
hMdct->prev_fr = fr;
hMdct->prev_wrs = wrs;
hMdct->prev_tl = tl;
hMdct->prevPrevAliasSymmetry = hMdct->prevAliasSymmetry;
hMdct->prevAliasSymmetry = currAliasingSymmetry;
fl = fr;
nl = nr;
pOvl = pSpec + tl / 2 - 1;
pOut0 = pOut1;
for (w = 1; w < nSpec; w++) /* for ACELP -> FD short */
{
const FIXP_WTP *pWindow_prev;
/* Setup window pointers */
pWindow_prev = hMdct->prev_wrs;
/* Current spectrum */
pSpec = _pSpec + w * tl;
scale = total_gain_e;
/* For the second, third, etc. short frames the alisaing symmetry is equal,
* either (0,0) or (1,1) */
if (currAliasingSymmetry == 0) {
/* DCT IV of current spectrum */
dct_IV(pSpec, tl, &scale);
} else {
dst_IV(pSpec, tl, &scale);
}
/* Optional scaling of time domain - no yet windowed - of current spectrum
*/
/* and de-scale current spectrum signal (time domain, no yet windowed) */
if (total_gain != (FIXP_DBL)0) {
scaleValuesWithFactor(pSpec, total_gain, tl, spec_scale[w] + scale);
} else {
scaleValues(pSpec, tl, spec_scale[w] + scale);
}
if (noOutSamples <= nrSamples) {
/* Divert output first half to overlap buffer if we already got enough
* output samples. */
pOut0 = hMdct->overlap.time + hMdct->ov_offset;
hMdct->ov_offset += hMdct->prev_nr + fl / 2;
} else {
/* Account output samples */
nrSamples += hMdct->prev_nr + fl / 2;
}
/* NR output samples 0 .. NR. -overlap[TL/2..TL/2-NR] */
for (i = 0; i < hMdct->prev_nr; i++) {
FIXP_DBL x = -(*pOvl--);
*pOut0 = IMDCT_SCALE_DBL(x);
pOut0++;
}
if (noOutSamples <= nrSamples) {
/* Divert output second half to overlap buffer if we already got enough
* output samples. */
pOut1 = hMdct->overlap.time + hMdct->ov_offset + fl / 2 - 1;
hMdct->ov_offset += fl / 2 + nl;
} else {
pOut1 = pOut0 + (fl - 1);
nrSamples += fl / 2 + nl;
}
/* output samples before window crossing point NR .. TL/2.
* -overlap[TL/2-NR..TL/2-NR-FL/2] + current[NR..TL/2] */
/* output samples after window crossing point TL/2 .. TL/2+FL/2.
* -overlap[0..FL/2] - current[TL/2..FL/2] */
pCurr = pSpec + tl - fl / 2;
if (currAliasingSymmetry == 0) {
for (i = 0; i < fl / 2; i++) {
FIXP_DBL x0, x1;
cplxMult(&x1, &x0, *pCurr++, -*pOvl--, pWindow_prev[i]);
*pOut0 = IMDCT_SCALE_DBL(x0);
*pOut1 = IMDCT_SCALE_DBL(-x1);
pOut0++;
pOut1--;
}
} else {
if (hMdct->prevPrevAliasSymmetry == 0) {
/* Jump DST II -> DST IV for the second window */
for (i = 0; i < fl / 2; i++) {
FIXP_DBL x0, x1;
cplxMult(&x1, &x0, *pCurr++, -*pOvl--, pWindow_prev[i]);
*pOut0 = IMDCT_SCALE_DBL(x0);
*pOut1 = IMDCT_SCALE_DBL(x1);
pOut0++;
pOut1--;
}
} else {
/* Jump DST IV -> DST IV from the second window on */
for (i = 0; i < fl / 2; i++) {
FIXP_DBL x0, x1;
cplxMult(&x1, &x0, *pCurr++, *pOvl--, pWindow_prev[i]);
*pOut0 = IMDCT_SCALE_DBL(x0);
*pOut1 = IMDCT_SCALE_DBL(x1);
pOut0++;
pOut1--;
}
}
}
if (hMdct->pFacZir != 0) {
/* add FAC ZIR of previous ACELP -> mdct transition */
FIXP_DBL *pOut = pOut0 - fl / 2;
FDK_ASSERT(fl / 2 <= 128);
for (i = 0; i < fl / 2; i++) {
pOut[i] += IMDCT_SCALE_DBL(hMdct->pFacZir[i]);
}
hMdct->pFacZir = NULL;
}
pOut0 += (fl / 2);
/* NL output samples TL/2+FL/2..TL. - current[FL/2..0] */
pOut1 += (fl / 2) + 1;
pCurr = pSpec + tl - fl / 2 - 1;
for (i = 0; i < nl; i++) {
FIXP_DBL x = -(*pCurr--);
*pOut1 = IMDCT_SCALE_DBL(x);
pOut1++;
}
/* Set overlap source pointer for next window pOvl = pSpec + tl/2 - 1; */
pOvl = pSpec + tl / 2 - 1;
/* Previous window values. */
hMdct->prev_nr = nr;
hMdct->prev_fr = fr;
hMdct->prev_tl = tl;
hMdct->prev_wrs = pWindow_prev;
hMdct->prevPrevAliasSymmetry = hMdct->prevAliasSymmetry;
hMdct->prevAliasSymmetry = currAliasingSymmetry;
}
/* Save overlap */
pOvl = hMdct->overlap.freq + hMdct->ov_size - tl / 2;
FDK_ASSERT(pOvl >= hMdct->overlap.time + hMdct->ov_offset);
FDK_ASSERT(tl / 2 <= hMdct->ov_size);
for (i = 0; i < tl / 2; i++) {
pOvl[i] = _pSpec[i + (w - 1) * tl];
}
return nrSamples;
}

191
libAACdec/src/usacdec_fac.h Normal file
View File

@ -0,0 +1,191 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
Fraunhofer Institute for Integrated Circuits IIS
Attention: Audio and Multimedia Departments - FDK AAC LL
Am Wolfsmantel 33
91058 Erlangen, Germany
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): Manuel Jander
Description: USAC FAC
*******************************************************************************/
#ifndef USACDEC_FAC_H
#define USACDEC_FAC_H
#include "channelinfo.h"
#include "FDK_bitstream.h"
/**
* \brief Get the address of a memory area of the spectral data memory were the
* FAC data can be stored into.
* \param spec SPECTRAL_PTR pointing to the current spectral data.
* \param mod the current LPD mod array.
* \param pState pointer to a private state variable which must be 0 for the
* first call and not changed externally.
* \param isFullbandLPD is 1 if fullband LPD mode is on, otherwise it is 0.
*/
FIXP_DBL *CLpd_FAC_GetMemory(CAacDecoderChannelInfo *pAacDecoderChannelInfo,
UCHAR mod[NB_SUBFR], int *pState);
/**
* \brief read a fac bitstream data block.
* \param hBs a bit stream handle, where the fac bitstream data is located.
* \param pFac pointer to were the FAC data will be stored into.
* \param pFacScale pointer to were the FAC data scale value will be stored
* into.
* \param tcx_gain value to be used as FAC gain. If zero, read fac_gain from
* bitstream.
* \param tcx_gain_e exponen value of tcx_gain.
* \param frame the subframe to be considered from the current superframe.
* Always 0 for FD case.
* \return 0 on success, -1 on error.
*/
int CLpd_FAC_Read(HANDLE_FDK_BITSTREAM hBs, FIXP_DBL *pFac, UCHAR *pFacScale,
int length, int use_gain, int frame);
/**
* \brief Apply TCX and ALFD gains to FAC data.
* \param fac_data pointer to FAC data.
* \param fac_length FAC length (128 or 96).
* \param tcx_gain TCX gain
* \param alfd_gains pointer to alfd gains.
* \param mod mod value (1,2,3) of TCX frame where the FAC signal needs to be
* applied.
*/
void CFac_ApplyGains(FIXP_DBL fac_data[LFAC], const INT fac_length,
const FIXP_DBL tcx_gain, const FIXP_DBL alfd_gains[],
const INT mod);
/**
* \brief Do FAC transition from frequency domain to ACELP domain.
*/
INT CLpd_FAC_Mdct2Acelp(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *pFac_data,
const int fac_data_e, FIXP_LPC *A, INT A_exp,
INT nrOutSamples, const INT fac_length,
const INT isFdFac, UCHAR prevWindowShape);
/**
* \brief Do FAC transition from ACELP domain to frequency domain.
* \param hMdct MDCT context.
* \param output pointer for time domain output.
* \param pSpec pointer to MDCT spectrum input.
* \param spec_scale MDCT spectrum exponents.
* \param nSpec amount of contiguos MDCT spectra.
* \param pFac pointer to FAC MDCT domain data.
* \param fac_scale exponent of FAC data.
* \param fac_length length of FAC data.
* \param nrSamples room in samples in output buffer.
* \param tl MDCT transform length of pSpec.
* \param wrs right MDCT window slope.
* \param fr right MDCT window slope length.
* \param A LP domain filter coefficients.
* \param deemph_mem deemphasis filter state.
* \param gain gain to be applied to FAC data before overlap add.
* \param old_syn_mem Synthesis filter state.
* \param isFdFac indicates fac processing from or to FD.
* \param pFacData fac data stored for fullband LPD.
* \param elFlags element specific parser guidance flags.
* \param isFacForFullband indicates that fac is processed for fullband LPD.
*/
INT CLpd_FAC_Acelp2Mdct(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *pSpec,
const SHORT spec_scale[], const int nSpec,
FIXP_DBL *pFac_data, const int fac_data_e,
const INT fac_length, INT nrSamples, const INT tl,
const FIXP_WTP *wrs, const INT fr, FIXP_LPC A[16],
INT A_exp, CAcelpStaticMem *acelp_mem,
const FIXP_DBL gain, const int last_frame_lost,
const int isFdFac, const UCHAR last_lpd, const int k,
int currAliasingSymmetry);
#endif /* USACDEC_FAC_H */

File diff suppressed because it is too large Load Diff

190
libAACdec/src/usacdec_lpc.h Normal file
View File

@ -0,0 +1,190 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
Fraunhofer Institute for Integrated Circuits IIS
Attention: Audio and Multimedia Departments - FDK AAC LL
Am Wolfsmantel 33
91058 Erlangen, Germany
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): Matthias Hildenbrand, Manuel Jander
Description: USAC LPC/AVQ decode
*******************************************************************************/
#ifndef USACDEC_LPC_H
#define USACDEC_LPC_H
#include "channelinfo.h"
#include "common_fix.h"
#include "FDK_bitstream.h"
#include "usacdec_rom.h"
#define LSPARG_SCALE 10
/**
* \brief AVQ (refinement) decode
* \param hBs bitstream handle
* \param lsfq buffer for AVQ decode output.
* \param nk_mode quantization mode.
* \param nqn amount of split/interleaved RE8 vectors.
* \param total amount of individual data values to decode.
* \return 0 on success, -1 on error.
*/
int CLpc_DecodeAVQ(HANDLE_FDK_BITSTREAM hBs, FIXP_DBL *lsfq, int nk_mode,
int nqn, int length);
/**
* \brief Read and decode LPC coeficient sets. First stage approximation + AVQ
* decode.
* \param[in] hBs bitstream handle to read data from.
* \param[out] lsp buffer into which the decoded LSP coefficients will be stored
* into.
* \param[in,out] lpc4_lsf buffer into which the decoded LCP4 LSF coefficients
* will be stored into (persistent).
* \param[out] lsf_adaptive_mean_cand lsf adaptive mean vector needed for
* concealment.
* \param[out] pStability array with stability values for the ACELP decoder (and
* concealment).
* \param[in] mod array which defines modes (ACELP, TCX20|40|80) are used in
* the current superframe.
* \param[in] first_lpd_flag indicates the presence of LPC0
* \param[in] last_lpc_lost indicate that LPC4 of previous frame was lost.
* \param[in] last_frame_ok indicate that the last frame was ok.
* \return 0 on success, -1 on error.
*/
int CLpc_Read(HANDLE_FDK_BITSTREAM hBs, FIXP_LPC lsp[][M_LP_FILTER_ORDER],
FIXP_LPC lpc4_lsf[M_LP_FILTER_ORDER],
FIXP_LPC lsf_adaptive_mean_cand[M_LP_FILTER_ORDER],
FIXP_SGL pStability[], UCHAR *mod, int first_lpd_flag,
int last_lpc_lost, int last_frame_ok);
/**
* \brief Generate LPC coefficient sets in case frame loss.
* \param lsp buffer into which the decoded LSP coefficients will be stored
* into.
* \param lpc4_lsf buffer into which the decoded LCP4 LSF coefficients will be
* stored into (persistent).
* \param isf_adaptive_mean
* \param first_lpd_flag indicates the previous LSF4 coefficients lpc4_lsf[] are
* not valid.
*/
void CLpc_Conceal(FIXP_LPC lsp[][M_LP_FILTER_ORDER],
FIXP_LPC lpc4_lsf[M_LP_FILTER_ORDER],
FIXP_LPC isf_adaptive_mean[M_LP_FILTER_ORDER],
const int first_lpd_flag);
/**
* \brief apply absolute weighting
* \param A weighted LPC coefficient vector output. The first coeffcient is
* implicitly 1.0
* \param A LPC coefficient vector. The first coeffcient is implicitly 1.0
* \param m length of vector A
*/
/* static */
void E_LPC_a_weight(FIXP_LPC *wA, const FIXP_LPC *A, const int m);
/**
* \brief decode TCX/FAC gain. In case of TCX the lg/sqrt(rms) part
* must still be applied to obtain the gain value.
* \param gain (o) pointer were the gain mantissa is stored into.
* \param gain_e (o) pointer were the gain exponent is stored into.
* \param gain_code (i) the 7 bit binary word from the bitstream
* representing the gain.
*/
void CLpd_DecodeGain(FIXP_DBL *gain, INT *gain_e, int gain_code);
/**
* \brief convert LSP coefficients into LP domain.
*/
void E_LPC_f_lsp_a_conversion(FIXP_LPC *lsp, FIXP_LPC *a, INT *a_exp);
#endif /* USACDEC_LPC_H */

File diff suppressed because it is too large Load Diff

198
libAACdec/src/usacdec_lpd.h Normal file
View File

@ -0,0 +1,198 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
Fraunhofer Institute for Integrated Circuits IIS
Attention: Audio and Multimedia Departments - FDK AAC LL
Am Wolfsmantel 33
91058 Erlangen, Germany
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): Manuel Jander
Description: USAC Linear Prediction Domain coding
*******************************************************************************/
#ifndef USACDEC_LPD_H
#define USACDEC_LPD_H
#include "channelinfo.h"
#define OPTIMIZE_AVG_PERFORMANCE
/**
* \brief read a lpd_channel_stream.
* \param hBs a bit stream handle, where the lpd_channel_stream is located.
* \param pAacDecoderChannelInfo the channel context structure for storing read
* data.
* \param flags bit stream syntax flags.
* \return AAC_DECODER_ERROR error code.
*/
AAC_DECODER_ERROR CLpdChannelStream_Read(
HANDLE_FDK_BITSTREAM hBs, CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
const SamplingRateInfo *pSamplingRateInfo, UINT flags);
/**
* \brief decode one lpd_channel_stream and render the audio output.
* \param pAacDecoderChannelInfo struct holding the channel information to be
* rendered.
* \param pAacDecoderStaticChannelInfo struct holding the persistent channel
* information to be rendered.
* \param pSamplingRateInfo holds the sampling rate information
* \param elFlags holds the internal decoder flags
*/
void CLpdChannelStream_Decode(
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo, UINT flags);
/**
* \brief generate time domain output signal for LPD channel streams
* \param pAacDecoderStaticChannelInfo
* \param pAacDecoderChannelInfo
* \param pTimeData pointer to output buffer
* \param samplesPerFrame amount of output samples
* \param pSamplingRateInfo holds the sampling rate information
* \param pWorkBuffer1 pointer to work buffer for temporal data
*/
AAC_DECODER_ERROR CLpd_RenderTimeSignal(
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
CAacDecoderChannelInfo *pAacDecoderChannelInfo, FIXP_PCM *pTimeData,
INT samplesPerFrame, SamplingRateInfo *pSamplingRateInfo, UINT frameOk,
UINT flags, UINT strmFlags);
static inline INT CLpd_FAC_getLength(int fNotShortBlock, int fac_length_long) {
if (fNotShortBlock) {
return (fac_length_long);
} else {
return fac_length_long / 2;
}
}
void filtLP(const FIXP_DBL *syn, FIXP_PCM *syn_out, FIXP_DBL *noise,
const FIXP_SGL *filt, INT stop, int len);
/**
* \brief perform a low-frequency pitch enhancement on time domain signal
* \param[in] syn pointer to time domain input signal
* \param[in] synFB pointer to time domain input signal
* \param[in] upsampling factor
* \param[in] T_sf array with past decoded pitch period values for each subframe
* \param[in] non_zero_gain_flags indicates whether pitch gains of past
* subframes are zero or not, msb -> [1 BPF_DELAY subfr][7 SYN_DELAY subfr][16
* new subfr] <- lsb
* \param[in] l_frame length of filtering, must be multiple of L_SUBFR
* \param[in] l_next length of allowed look ahead on syn[i], i < l_frame+l_next
* \param[out] synth_out pointer to time domain output signal
* \param[in,out] mem_bpf pointer to filter memory (L_FILT+L_SUBFR)
*/
void bass_pf_1sf_delay(FIXP_DBL syn[], const INT T_sf[], FIXP_DBL *pit_gain,
const int frame_length, const INT l_frame,
const INT l_next, FIXP_PCM *synth_out,
FIXP_DBL mem_bpf[]);
/**
* \brief random sign generator for FD and TCX noise filling
* \param[in,out] seed pointer to random seed
* \return if return value is zero use positive sign
* \Note: This code is also implemented as a copy in block.cpp, grep for
* "UsacRandomSign"
*/
FDK_INLINE
int UsacRandomSign(ULONG *seed) {
*seed = (ULONG)((UINT64)(*seed) * 69069 + 5);
return (int)((*seed) & 0x10000);
}
void CFdp_Reset(CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo);
#endif /* USACDEC_LPD_H */

File diff suppressed because it is too large Load Diff

154
libAACdec/src/usacdec_rom.h Normal file
View File

@ -0,0 +1,154 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
Fraunhofer Institute for Integrated Circuits IIS
Attention: Audio and Multimedia Departments - FDK AAC LL
Am Wolfsmantel 33
91058 Erlangen, Germany
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): M. Jander
Description: re8.h
*******************************************************************************/
#ifndef USACDEC_ROM_H
#define USACDEC_ROM_H
#include "common_fix.h"
#include "FDK_lpc.h"
#include "usacdec_const.h"
/* RE8 lattice quantiser constants */
#define NB_SPHERE 32
#define NB_LEADER 37
#define NB_LDSIGN 226
#define NB_LDQ3 9
#define NB_LDQ4 28
#define LSF_SCALE 13
/* RE8 lattice quantiser tables */
extern const UINT fdk_dec_tab_factorial[8];
extern const UCHAR fdk_dec_Ia[NB_LEADER];
extern const UCHAR fdk_dec_Ds[NB_LDSIGN];
extern const USHORT fdk_dec_Is[NB_LDSIGN];
extern const UCHAR fdk_dec_Ns[], fdk_dec_A3[], fdk_dec_A4[];
extern const UCHAR fdk_dec_Da[][8];
extern const USHORT fdk_dec_I3[], fdk_dec_I4[];
/* temp float tables for LPC decoding */
extern const FIXP_LPC fdk_dec_lsf_init[16];
extern const FIXP_LPC fdk_dec_dico_lsf_abs_8b[16 * 256];
/* ACELP tables */
#define SF_QUA_GAIN7B 4
extern const FIXP_SGL t_qua_gain7b[128 * 2];
extern const FIXP_SGL lsp_interpol_factor[2][NB_SUBFR];
/* For bass post filter */
#define L_FILT 12 /* Delay of up-sampling filter */
extern const FIXP_SGL fdk_dec_filt_lp[1 + L_FILT];
extern const FIXP_WTB FacWindowSynth128[128];
extern const FIXP_WTB FacWindowZir128[128];
extern const FIXP_WTB FacWindowSynth64[64];
extern const FIXP_WTB FacWindowZir64[64];
extern const FIXP_WTB FacWindowSynth32[32];
extern const FIXP_WTB FacWindowZir32[32];
extern const FIXP_WTB FacWindowSynth96[96];
extern const FIXP_WTB FacWindowZir96[96];
extern const FIXP_WTB FacWindowSynth48[48];
extern const FIXP_WTB FacWindowZir48[48];
#endif /* USACDEC_ROM_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,14 +90,16 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/******************************************************************************
/**************************** AAC encoder library ******************************
Initial authors: M. Lohwasser, M. Gayer
Contents/description:
Author(s): M. Lohwasser, M. Gayer
Description:
*******************************************************************************/
******************************************************************************/
/*!
\file
\brief Memory layout
@ -95,100 +108,101 @@ amm-info@iis.fraunhofer.de
#include "aacEnc_ram.h"
C_AALLOC_MEM (AACdynamic_RAM, FIXP_DBL, AAC_ENC_DYN_RAM_SIZE/sizeof(FIXP_DBL))
C_AALLOC_MEM(AACdynamic_RAM, FIXP_DBL, AAC_ENC_DYN_RAM_SIZE / sizeof(FIXP_DBL))
/*
Static memory areas, must not be overwritten in other sections of the decoder !
Static memory areas, must not be overwritten in other sections of the decoder
!
*/
/*
The structure AacEncoder contains all Encoder structures.
*/
C_ALLOC_MEM (Ram_aacEnc_AacEncoder, AAC_ENC, 1)
C_ALLOC_MEM(Ram_aacEnc_AacEncoder, struct AAC_ENC, 1)
/*
The structure PSY_INTERNAl contains all psych configuration and data pointer.
* PsyStatic holds last and current Psych data.
* PsyInputBuffer contains time input. Signal is needed at the beginning of Psych.
Memory can be reused after signal is in time domain.
* PsyData contains spectral, nrg and threshold information. Necessary data are
copied into PsyOut, so memory is available after leaving psych.
* TnsData, ChaosMeasure, PnsData are temporarily necessary, e.g. use memory from
PsyInputBuffer.
* PsyInputBuffer contains time input. Signal is needed at the beginning of
Psych. Memory can be reused after signal is in time domain.
* PsyData contains spectral, nrg and threshold information. Necessary data
are copied into PsyOut, so memory is available after leaving psych.
* TnsData, ChaosMeasure, PnsData are temporarily necessary, e.g. use memory
from PsyInputBuffer.
*/
C_ALLOC_MEM2 (Ram_aacEnc_PsyElement, PSY_ELEMENT, 1, (8))
C_ALLOC_MEM2(Ram_aacEnc_PsyElement, PSY_ELEMENT, 1, ((8)))
C_ALLOC_MEM (Ram_aacEnc_PsyInternal, PSY_INTERNAL, 1)
C_ALLOC_MEM2 (Ram_aacEnc_PsyStatic, PSY_STATIC, 1, (8))
C_ALLOC_MEM(Ram_aacEnc_PsyInternal, PSY_INTERNAL, 1)
C_ALLOC_MEM2(Ram_aacEnc_PsyStatic, PSY_STATIC, 1, (8))
C_ALLOC_MEM2 (Ram_aacEnc_PsyInputBuffer, INT_PCM, MAX_INPUT_BUFFER_SIZE, (8))
C_ALLOC_MEM2(Ram_aacEnc_PsyInputBuffer, INT_PCM, MAX_INPUT_BUFFER_SIZE, (8))
PSY_DYNAMIC *GetRam_aacEnc_PsyDynamic (int n, UCHAR* dynamic_RAM) {
FDK_ASSERT(dynamic_RAM!=0);
return ((PSY_DYNAMIC*) (dynamic_RAM + P_BUF_1 + n*sizeof(PSY_DYNAMIC)));
}
C_ALLOC_MEM (Ram_bsOutbuffer, UCHAR, OUTPUTBUFFER_SIZE)
PSY_DYNAMIC *GetRam_aacEnc_PsyDynamic(int n, UCHAR *dynamic_RAM) {
FDK_ASSERT(dynamic_RAM != 0);
/* The reinterpret_cast is used to suppress a compiler warning. We know that
* (dynamic_RAM + P_BUF_1 + n*sizeof(PSY_DYNAMIC)) is sufficiently aligned, so
* the cast is safe */
return reinterpret_cast<PSY_DYNAMIC *>(reinterpret_cast<void *>(
dynamic_RAM + P_BUF_1 + n * sizeof(PSY_DYNAMIC)));
}
/*
The structure PSY_OUT holds all psychoaccoustic data needed
in quantization module
*/
C_ALLOC_MEM2 (Ram_aacEnc_PsyOut, PSY_OUT, 1, (1))
C_ALLOC_MEM2 (Ram_aacEnc_PsyOutElements, PSY_OUT_ELEMENT, 1, (1)*(8))
C_ALLOC_MEM2 (Ram_aacEnc_PsyOutChannel, PSY_OUT_CHANNEL, 1, (1)*(8))
C_ALLOC_MEM2(Ram_aacEnc_PsyOut, PSY_OUT, 1, (1))
C_ALLOC_MEM2(Ram_aacEnc_PsyOutElements, PSY_OUT_ELEMENT, 1, (1) * ((8)))
C_ALLOC_MEM2(Ram_aacEnc_PsyOutChannel, PSY_OUT_CHANNEL, 1, (1) * (8))
/*
The structure QC_STATE contains preinitialized settings and quantizer structures.
The structure QC_STATE contains preinitialized settings and quantizer
structures.
* AdjustThreshold structure contains element-wise settings.
* ElementBits contains elemnt-wise bit consumption settings.
* When CRC is active, lookup table is necessary for fast crc calculation.
* Bitcounter contains buffer to find optimal codebooks and minimal bit consumption.
Values are temporarily, so dynamic memory can be used.
* Bitcounter contains buffer to find optimal codebooks and minimal bit
consumption. Values are temporarily, so dynamic memory can be used.
*/
C_ALLOC_MEM (Ram_aacEnc_QCstate, QC_STATE, 1)
C_ALLOC_MEM (Ram_aacEnc_AdjustThreshold, ADJ_THR_STATE, 1)
C_ALLOC_MEM(Ram_aacEnc_QCstate, QC_STATE, 1)
C_ALLOC_MEM(Ram_aacEnc_AdjustThreshold, ADJ_THR_STATE, 1)
C_ALLOC_MEM2 (Ram_aacEnc_AdjThrStateElement, ATS_ELEMENT, 1, (8))
C_ALLOC_MEM2 (Ram_aacEnc_ElementBits, ELEMENT_BITS, 1, (8))
C_ALLOC_MEM (Ram_aacEnc_BitCntrState, BITCNTR_STATE, 1)
INT *GetRam_aacEnc_BitLookUp(int n, UCHAR* dynamic_RAM) {
FDK_ASSERT(dynamic_RAM!=0);
return ((INT*) (dynamic_RAM + P_BUF_1));
}
INT *GetRam_aacEnc_MergeGainLookUp(int n, UCHAR* dynamic_RAM) {
FDK_ASSERT(dynamic_RAM!=0);
return ((INT*) (dynamic_RAM + P_BUF_1 + sizeof(INT)*(MAX_SFB_LONG*(CODE_BOOK_ESC_NDX+1))));
}
C_ALLOC_MEM2(Ram_aacEnc_AdjThrStateElement, ATS_ELEMENT, 1, ((8)))
C_ALLOC_MEM2(Ram_aacEnc_ElementBits, ELEMENT_BITS, 1, ((8)))
C_ALLOC_MEM(Ram_aacEnc_BitCntrState, struct BITCNTR_STATE, 1)
INT *GetRam_aacEnc_BitLookUp(int n, UCHAR *dynamic_RAM) {
FDK_ASSERT(dynamic_RAM != 0);
/* The reinterpret_cast is used to suppress a compiler warning. We know that
* (dynamic_RAM + P_BUF_1) is sufficiently aligned, so the cast is safe */
return reinterpret_cast<INT *>(
reinterpret_cast<void *>(dynamic_RAM + P_BUF_1));
}
INT *GetRam_aacEnc_MergeGainLookUp(int n, UCHAR *dynamic_RAM) {
FDK_ASSERT(dynamic_RAM != 0);
/* The reinterpret_cast is used to suppress a compiler warning. We know that
* (dynamic_RAM + P_BUF_1 + sizeof(INT)*(MAX_SFB_LONG*(CODE_BOOK_ESC_NDX+1)))
* is sufficiently aligned, so the cast is safe */
return reinterpret_cast<INT *>(reinterpret_cast<void *>(
dynamic_RAM + P_BUF_1 +
sizeof(INT) * (MAX_SFB_LONG * (CODE_BOOK_ESC_NDX + 1))));
}
/*
The structure QC_OUT contains settings and structures holding all necessary information
needed in bitstreamwriter.
The structure QC_OUT contains settings and structures holding all necessary
information needed in bitstreamwriter.
*/
C_ALLOC_MEM2 (Ram_aacEnc_QCout, QC_OUT, 1, (1))
C_ALLOC_MEM2 (Ram_aacEnc_QCelement, QC_OUT_ELEMENT, (1), (8))
QC_OUT_CHANNEL *GetRam_aacEnc_QCchannel (int n, UCHAR* dynamic_RAM) {
FDK_ASSERT(dynamic_RAM!=0);
return ((QC_OUT_CHANNEL*) (dynamic_RAM + P_BUF_0 + n*sizeof(QC_OUT_CHANNEL)));
}
C_ALLOC_MEM2(Ram_aacEnc_QCout, QC_OUT, 1, (1))
C_ALLOC_MEM2(Ram_aacEnc_QCelement, QC_OUT_ELEMENT, 1, (1) * ((8)))
QC_OUT_CHANNEL *GetRam_aacEnc_QCchannel(int n, UCHAR *dynamic_RAM) {
FDK_ASSERT(dynamic_RAM != 0);
/* The reinterpret_cast is used to suppress a compiler warning. We know that
* (dynamic_RAM + P_BUF_0 + n*sizeof(QC_OUT_CHANNEL)) is sufficiently aligned,
* so the cast is safe */
return reinterpret_cast<QC_OUT_CHANNEL *>(reinterpret_cast<void *>(
dynamic_RAM + P_BUF_0 + n * sizeof(QC_OUT_CHANNEL)));
}

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,23 +90,24 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/******************************************************************************
/**************************** AAC encoder library ******************************
Initial authors: M. Lohwasser, M. Gayer
Contents/description:
Author(s): M. Lohwasser, M. Gayer
******************************************************************************/
Description:
*******************************************************************************/
/*!
\file
\brief Memory layout
\brief Memory layout
\author Markus Lohwasser
*/
#ifndef AAC_ENC_RAM_H
#define AAC_ENC_RAM_H
#ifndef AACENC_RAM_H
#define AACENC_RAM_H
#include "common_fix.h"
@ -107,32 +119,35 @@ amm-info@iis.fraunhofer.de
#include "bit_cnt.h"
#include "psy_const.h"
#define OUTPUTBUFFER_SIZE (8192) /*!< Output buffer size has to be at least 6144 bits per channel (768 bytes). FDK bitbuffer implementation expects buffer of size 2^n. */
#define OUTPUTBUFFER_SIZE \
(8192) /*!< Output buffer size has to be at least 6144 bits per channel \
(768 bytes). FDK bitbuffer implementation expects buffer of \
size 2^n. */
/*
Moved AAC_ENC struct definition from aac_enc.cpp into aacEnc_ram.h to get size and respective
static memory in aacEnc_ram.cpp.
aac_enc.h is the outward visible header file and putting the struct into would cause necessity
of additional visible header files outside library.
Moved AAC_ENC struct definition from aac_enc.cpp into aacEnc_ram.h to get size
and respective static memory in aacEnc_ram.cpp. aac_enc.h is the outward
visible header file and putting the struct into would cause necessity of
additional visible header files outside library.
*/
/* define hBitstream size: max AAC framelength is 6144 bits/channel */
/*#define BUFFER_BITSTR_SIZE ((6400*(8)/bbWordSize) +((bbWordSize - 1) / bbWordSize))*/
/*#define BUFFER_BITSTR_SIZE ((6400*(8)/bbWordSize) +((bbWordSize - 1) /
* bbWordSize))*/
struct AAC_ENC {
AACENC_CONFIG *config;
AACENC_CONFIG *config;
INT ancillaryBitsPerFrame; /* ancillary bits per frame calculated from
ancillary rate */
INT ancillaryBitsPerFrame; /* ancillary bits per frame calculated from ancillary rate */
CHANNEL_MAPPING channelMapping;
CHANNEL_MAPPING channelMapping;
QC_STATE *qcKernel;
QC_OUT *qcOut[(1)];
QC_STATE *qcKernel;
QC_OUT *qcOut[(1)];
PSY_OUT *psyOut[(1)];
PSY_INTERNAL *psyKernel;
PSY_OUT *psyOut[(1)];
PSY_INTERNAL *psyKernel;
/* lifetime vars */
@ -140,50 +155,61 @@ struct AAC_ENC {
INT bandwidth90dB;
AACENC_BITRATE_MODE bitrateMode;
INT dontWriteAdif; /* use: write ADIF header only before 1st frame */
INT dontWriteAdif; /* use: write ADIF header only before 1st frame */
FIXP_DBL *dynamic_RAM;
FIXP_DBL *dynamic_RAM;
INT maxChannels; /* used while allocation */
INT maxChannels; /* used while allocation */
INT maxElements;
INT maxFrames;
AUDIO_OBJECT_TYPE aot; /* AOT to be used while encoding. */
AUDIO_OBJECT_TYPE aot; /* AOT to be used while encoding. */
};
} ;
#define maxSize(a,b) ( ((a)>(b)) ? (a) : (b) )
#define BIT_LOOK_UP_SIZE ( sizeof(INT)*(MAX_SFB_LONG*(CODE_BOOK_ESC_NDX+1)) )
#define MERGE_GAIN_LOOK_UP_SIZE ( sizeof(INT)*MAX_SFB_LONG )
#define maxSize(a, b) (((a) > (b)) ? (a) : (b))
#define BIT_LOOK_UP_SIZE \
(sizeof(INT) * (MAX_SFB_LONG * (CODE_BOOK_ESC_NDX + 1)))
#define MERGE_GAIN_LOOK_UP_SIZE (sizeof(INT) * MAX_SFB_LONG)
/* Size of AhFlag buffer in function FDKaacEnc_adaptThresholdsToPe() */
#define ADJ_THR_AH_FLAG_SIZE (sizeof(UCHAR) * ((8)) * (2) * MAX_GROUPED_SFB)
/* Size of ThrExp buffer in function FDKaacEnc_adaptThresholdsToPe() */
#define ADJ_THR_THR_EXP_SIZE (sizeof(FIXP_DBL) * ((8)) * (2) * MAX_GROUPED_SFB)
/* Size of sfbNActiveLinesLdData buffer in function FDKaacEnc_correctThresh() */
#define ADJ_THR_ACT_LIN_LD_DATA_SIZE \
(sizeof(FIXP_DBL) * ((8)) * (2) * MAX_GROUPED_SFB)
/* Total amount of dynamic buffer needed in adjust thresholds functionality */
#define ADJ_THR_SIZE \
(ADJ_THR_AH_FLAG_SIZE + ADJ_THR_THR_EXP_SIZE + ADJ_THR_ACT_LIN_LD_DATA_SIZE)
/* Dynamic RAM - Allocation */
/*
++++++++++++++++++++++++++++++++++++++++++++
| P_BUF_0 | P_BUF_1 |
++++++++++++++++++++++++++++++++++++++++++++
| QC_OUT_CH | PSY_DYN |
++++++++++++++++++++++++++++++++++++++++++++
| | BitLookUp+MergeGainLookUp |
++++++++++++++++++++++++++++++++++++++++++++
| | Bitstream output buffer |
++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++
| P_BUF_0 | P_BUF_1 |
+++++++++++++++++++++++++++++++++++++++++++++++++++++
| QC_OUT_CH | PSY_DYN |
+++++++++++++++++++++++++++++++++++++++++++++++++++++
| | BitLookUp+MergeGainLookUp |
+++++++++++++++++++++++++++++++++++++++++++++++++++++
| | AH_FLAG | THR_EXP | ACT_LIN_LD_DATA |
+++++++++++++++++++++++++++++++++++++++++++++++++++++
| | Bitstream output buffer |
+++++++++++++++++++++++++++++++++++++++++++++++++++++
*/
#define BUF_SIZE_0 ( ALIGN_SIZE(sizeof(QC_OUT_CHANNEL)*(8)) )
#define BUF_SIZE_1 ( ALIGN_SIZE(maxSize(sizeof(PSY_DYNAMIC), \
(BIT_LOOK_UP_SIZE+MERGE_GAIN_LOOK_UP_SIZE))) )
#define BUF_SIZE_0 (ALIGN_SIZE(sizeof(QC_OUT_CHANNEL) * (8)))
#define BUF_SIZE_1 \
(ALIGN_SIZE(maxSize(maxSize(sizeof(PSY_DYNAMIC), \
(BIT_LOOK_UP_SIZE + MERGE_GAIN_LOOK_UP_SIZE)), \
ADJ_THR_SIZE)))
#define P_BUF_0 ( 0 )
#define P_BUF_1 ( P_BUF_0 + BUF_SIZE_0 )
#define P_BUF_0 (0)
#define P_BUF_1 (P_BUF_0 + BUF_SIZE_0)
#define AAC_ENC_DYN_RAM_SIZE ( BUF_SIZE_0 + BUF_SIZE_1 )
#define AAC_ENC_DYN_RAM_SIZE (BUF_SIZE_0 + BUF_SIZE_1)
H_ALLOC_MEM (AACdynamic_RAM, FIXP_DBL)
H_ALLOC_MEM(AACdynamic_RAM, FIXP_DBL)
/*
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
END - Dynamic RAM - Allocation */
@ -191,36 +217,33 @@ END - Dynamic RAM - Allocation */
/*
See further Memory Allocation details in aacEnc_ram.cpp
*/
H_ALLOC_MEM (Ram_aacEnc_AacEncoder, AAC_ENC)
H_ALLOC_MEM(Ram_aacEnc_AacEncoder, AAC_ENC)
H_ALLOC_MEM (Ram_aacEnc_PsyElement, PSY_ELEMENT)
H_ALLOC_MEM(Ram_aacEnc_PsyElement, PSY_ELEMENT)
H_ALLOC_MEM (Ram_aacEnc_PsyInternal, PSY_INTERNAL)
H_ALLOC_MEM (Ram_aacEnc_PsyStatic, PSY_STATIC)
H_ALLOC_MEM (Ram_aacEnc_PsyInputBuffer, INT_PCM)
H_ALLOC_MEM(Ram_aacEnc_PsyInternal, PSY_INTERNAL)
H_ALLOC_MEM(Ram_aacEnc_PsyStatic, PSY_STATIC)
H_ALLOC_MEM(Ram_aacEnc_PsyInputBuffer, INT_PCM)
PSY_DYNAMIC *GetRam_aacEnc_PsyDynamic (int n, UCHAR* dynamic_RAM);
H_ALLOC_MEM (Ram_bsOutbuffer, UCHAR)
PSY_DYNAMIC *GetRam_aacEnc_PsyDynamic(int n, UCHAR *dynamic_RAM);
H_ALLOC_MEM (Ram_aacEnc_PsyOutChannel, PSY_OUT_CHANNEL)
H_ALLOC_MEM(Ram_aacEnc_PsyOutChannel, PSY_OUT_CHANNEL)
H_ALLOC_MEM (Ram_aacEnc_PsyOut, PSY_OUT)
H_ALLOC_MEM (Ram_aacEnc_PsyOutElements, PSY_OUT_ELEMENT)
H_ALLOC_MEM(Ram_aacEnc_PsyOut, PSY_OUT)
H_ALLOC_MEM(Ram_aacEnc_PsyOutElements, PSY_OUT_ELEMENT)
H_ALLOC_MEM (Ram_aacEnc_QCstate, QC_STATE)
H_ALLOC_MEM (Ram_aacEnc_AdjustThreshold, ADJ_THR_STATE)
H_ALLOC_MEM(Ram_aacEnc_QCstate, QC_STATE)
H_ALLOC_MEM(Ram_aacEnc_AdjustThreshold, ADJ_THR_STATE)
H_ALLOC_MEM (Ram_aacEnc_AdjThrStateElement, ATS_ELEMENT)
H_ALLOC_MEM (Ram_aacEnc_ElementBits, ELEMENT_BITS)
H_ALLOC_MEM (Ram_aacEnc_BitCntrState, BITCNTR_STATE)
H_ALLOC_MEM(Ram_aacEnc_AdjThrStateElement, ATS_ELEMENT)
H_ALLOC_MEM(Ram_aacEnc_ElementBits, ELEMENT_BITS)
H_ALLOC_MEM(Ram_aacEnc_BitCntrState, BITCNTR_STATE)
INT *GetRam_aacEnc_BitLookUp(int n, UCHAR* dynamic_RAM);
INT *GetRam_aacEnc_MergeGainLookUp(int n, UCHAR* dynamic_RAM);
QC_OUT_CHANNEL *GetRam_aacEnc_QCchannel (int n, UCHAR* dynamic_RAM);
INT *GetRam_aacEnc_BitLookUp(int n, UCHAR *dynamic_RAM);
INT *GetRam_aacEnc_MergeGainLookUp(int n, UCHAR *dynamic_RAM);
QC_OUT_CHANNEL *GetRam_aacEnc_QCchannel(int n, UCHAR *dynamic_RAM);
H_ALLOC_MEM (Ram_aacEnc_QCout, QC_OUT)
H_ALLOC_MEM (Ram_aacEnc_QCelement, QC_OUT_ELEMENT)
#endif /* #ifndef AAC_ENC_RAM_H */
H_ALLOC_MEM(Ram_aacEnc_QCout, QC_OUT)
H_ALLOC_MEM(Ram_aacEnc_QCelement, QC_OUT_ELEMENT)
#endif /* #ifndef AACENC_RAM_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2015 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,39 +90,42 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/******************************************************************************
/**************************** AAC encoder library ******************************
Initial authors: M. Lohwasser, M. Gayer
Contents/description:
Author(s): M. Lohwasser, M. Gayer
Description:
*******************************************************************************/
******************************************************************************/
/*!
\file
\brief Memory layout
\brief Memory layout
\author Markus Lohwasser
*/
#ifndef AAC_ENC_ROM_H
#define AAC_ENC_ROM_H
#ifndef AACENC_ROM_H
#define AACENC_ROM_H
#include "common_fix.h"
#include "psy_const.h"
#include "psy_configuration.h"
#include "FDK_tools_rom.h"
#include "FDK_lpc.h"
/*
Huffman Tables
*/
extern const ULONG FDKaacEnc_huff_ltab1_2[3][3][3][3];
extern const ULONG FDKaacEnc_huff_ltab3_4[3][3][3][3];
extern const ULONG FDKaacEnc_huff_ltab5_6[9][9];
extern const ULONG FDKaacEnc_huff_ltab7_8[8][8];
extern const ULONG FDKaacEnc_huff_ltab9_10[13][13];
extern const UCHAR FDKaacEnc_huff_ltab11[17][17];
extern const UCHAR FDKaacEnc_huff_ltabscf[121];
extern const ULONG FDKaacEnc_huff_ltab1_2[3][3][3][3];
extern const ULONG FDKaacEnc_huff_ltab3_4[3][3][3][3];
extern const ULONG FDKaacEnc_huff_ltab5_6[9][9];
extern const ULONG FDKaacEnc_huff_ltab7_8[8][8];
extern const ULONG FDKaacEnc_huff_ltab9_10[13][13];
extern const UCHAR FDKaacEnc_huff_ltab11[17][17];
extern const UCHAR FDKaacEnc_huff_ltabscf[121];
extern const USHORT FDKaacEnc_huff_ctab1[3][3][3][3];
extern const USHORT FDKaacEnc_huff_ctab2[3][3][3][3];
extern const USHORT FDKaacEnc_huff_ctab3[3][3][3][3];
@ -123,13 +137,13 @@ extern const USHORT FDKaacEnc_huff_ctab8[8][8];
extern const USHORT FDKaacEnc_huff_ctab9[13][13];
extern const USHORT FDKaacEnc_huff_ctab10[13][13];
extern const USHORT FDKaacEnc_huff_ctab11[21][17];
extern const ULONG FDKaacEnc_huff_ctabscf[121];
extern const ULONG FDKaacEnc_huff_ctabscf[121];
/*
quantizer
*/
#define MANT_DIGITS 9
#define MANT_SIZE (1<<MANT_DIGITS)
#define MANT_SIZE (1 << MANT_DIGITS)
#if defined(ARCH_PREFER_MULT_32x16)
#define FIXP_QTD FIXP_SGL
@ -147,50 +161,47 @@ extern const FIXP_DBL FDKaacEnc_mTab_4_3Elc[512];
extern const FIXP_DBL FDKaacEnc_specExpMantTableCombElc[4][14];
extern const UCHAR FDKaacEnc_specExpTableComb[4][14];
/*
table to count used number of bits
*/
extern const SHORT FDKaacEnc_sideInfoTabLong[MAX_SFB_LONG + 1];
extern const SHORT FDKaacEnc_sideInfoTabShort[MAX_SFB_SHORT + 1];
extern const SHORT FDKaacEnc_sideInfoTabLong[];
extern const SHORT FDKaacEnc_sideInfoTabShort[];
/*
Psy Configuration constants
*/
extern const SFB_PARAM_LONG p_FDKaacEnc_8000_long_1024;
extern const SFB_PARAM_LONG p_FDKaacEnc_8000_long_1024;
extern const SFB_PARAM_SHORT p_FDKaacEnc_8000_short_128;
extern const SFB_PARAM_LONG p_FDKaacEnc_11025_long_1024;
extern const SFB_PARAM_LONG p_FDKaacEnc_11025_long_1024;
extern const SFB_PARAM_SHORT p_FDKaacEnc_11025_short_128;
extern const SFB_PARAM_LONG p_FDKaacEnc_12000_long_1024;
extern const SFB_PARAM_LONG p_FDKaacEnc_12000_long_1024;
extern const SFB_PARAM_SHORT p_FDKaacEnc_12000_short_128;
extern const SFB_PARAM_LONG p_FDKaacEnc_16000_long_1024;
extern const SFB_PARAM_LONG p_FDKaacEnc_16000_long_1024;
extern const SFB_PARAM_SHORT p_FDKaacEnc_16000_short_128;
extern const SFB_PARAM_LONG p_FDKaacEnc_22050_long_1024;
extern const SFB_PARAM_LONG p_FDKaacEnc_22050_long_1024;
extern const SFB_PARAM_SHORT p_FDKaacEnc_22050_short_128;
extern const SFB_PARAM_LONG p_FDKaacEnc_24000_long_1024;
extern const SFB_PARAM_LONG p_FDKaacEnc_24000_long_1024;
extern const SFB_PARAM_SHORT p_FDKaacEnc_24000_short_128;
extern const SFB_PARAM_LONG p_FDKaacEnc_32000_long_1024;
extern const SFB_PARAM_LONG p_FDKaacEnc_32000_long_1024;
extern const SFB_PARAM_SHORT p_FDKaacEnc_32000_short_128;
extern const SFB_PARAM_LONG p_FDKaacEnc_44100_long_1024;
extern const SFB_PARAM_LONG p_FDKaacEnc_44100_long_1024;
extern const SFB_PARAM_SHORT p_FDKaacEnc_44100_short_128;
extern const SFB_PARAM_LONG p_FDKaacEnc_48000_long_1024;
extern const SFB_PARAM_LONG p_FDKaacEnc_48000_long_1024;
extern const SFB_PARAM_SHORT p_FDKaacEnc_48000_short_128;
extern const SFB_PARAM_LONG p_FDKaacEnc_64000_long_1024;
extern const SFB_PARAM_LONG p_FDKaacEnc_64000_long_1024;
extern const SFB_PARAM_SHORT p_FDKaacEnc_64000_short_128;
extern const SFB_PARAM_LONG p_FDKaacEnc_88200_long_1024;
extern const SFB_PARAM_LONG p_FDKaacEnc_88200_long_1024;
extern const SFB_PARAM_SHORT p_FDKaacEnc_88200_short_128;
extern const SFB_PARAM_LONG p_FDKaacEnc_96000_long_1024;
extern const SFB_PARAM_LONG p_FDKaacEnc_96000_long_1024;
extern const SFB_PARAM_SHORT p_FDKaacEnc_96000_short_128;
/*
TNS filter coefficients
*/
extern const FIXP_DBL FDKaacEnc_tnsEncCoeff3[8];
extern const FIXP_DBL FDKaacEnc_tnsCoeff3Borders[8];
extern const FIXP_DBL FDKaacEnc_tnsEncCoeff4[16];
extern const FIXP_DBL FDKaacEnc_tnsCoeff4Borders[16];
extern const FIXP_LPC FDKaacEnc_tnsEncCoeff3[8];
extern const FIXP_LPC FDKaacEnc_tnsCoeff3Borders[8];
extern const FIXP_LPC FDKaacEnc_tnsEncCoeff4[16];
extern const FIXP_LPC FDKaacEnc_tnsCoeff4Borders[16];
#define WTC0 WTC
#define WTC1 WTC
@ -198,6 +209,9 @@ extern const FIXP_DBL FDKaacEnc_tnsCoeff4Borders[16];
extern const FIXP_WTB ELDAnalysis512[1536];
extern const FIXP_WTB ELDAnalysis480[1440];
extern const FIXP_WTB ELDAnalysis256[768];
extern const FIXP_WTB ELDAnalysis240[720];
extern const FIXP_WTB ELDAnalysis128[384];
extern const FIXP_WTB ELDAnalysis120[360];
#endif /* #ifndef AAC_ENC_ROM_H */
#endif /* #ifndef AACENC_ROM_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2015 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,17 +90,18 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/************************* Fast MPEG AAC Audio Encoder **********************
/**************************** AAC encoder library ******************************
Initial author: M. Schug / A. Groeschel
contents/description: fast aac coder interface library functions
Author(s): M. Schug / A. Groeschel
******************************************************************************/
Description: fast aac coder interface library functions
#ifndef _aacenc_h_
#define _aacenc_h_
*******************************************************************************/
#ifndef AACENC_H
#define AACENC_H
#include "common_fix.h"
#include "FDK_audio.h"
@ -98,10 +110,7 @@ amm-info@iis.fraunhofer.de
#include "sbr_encoder.h"
#define BITRES_MAX_LD 4000
#define BITRES_MIN_LD 500
#define BITRATE_MAX_LD 70000 /* Max assumed bitrate for bitres calculation */
#define BITRATE_MIN_LD 12000 /* Min assumed bitrate for bitres calculation */
#define MIN_BUFSIZE_PER_EFF_CHAN 6144
#ifdef __cplusplus
extern "C" {
@ -111,192 +120,218 @@ extern "C" {
* AAC-LC error codes.
*/
typedef enum {
AAC_ENC_OK = 0x0000, /*!< All fine. */
AAC_ENC_OK = 0x0000, /*!< All fine. */
AAC_ENC_UNKNOWN = 0x0002, /*!< Error condition is of unknown reason, or from another module. */
AAC_ENC_UNKNOWN = 0x0002, /*!< Error condition is of unknown reason, or from
another module. */
/* initialization errors */
aac_enc_init_error_start = 0x2000,
AAC_ENC_INVALID_HANDLE = 0x2020, /*!< The handle passed to the function call was invalid (probably NULL). */
AAC_ENC_INVALID_FRAME_LENGTH = 0x2080, /*!< Invalid frame length. */
AAC_ENC_INVALID_N_CHANNELS = 0x20e0, /*!< Invalid amount of audio input channels. */
AAC_ENC_INVALID_SFB_TABLE = 0x2140, /*!< Internal encoder error. */
aac_enc_init_error_start = 0x2000,
AAC_ENC_INVALID_HANDLE = 0x2020, /*!< The handle passed to the function call
was invalid (probably NULL). */
AAC_ENC_INVALID_FRAME_LENGTH =
0x2080, /*!< Invalid frame length (must be 1024 or 960). */
AAC_ENC_INVALID_N_CHANNELS =
0x20e0, /*!< Invalid amount of audio input channels. */
AAC_ENC_INVALID_SFB_TABLE = 0x2140, /*!< Internal encoder error. */
AAC_ENC_UNSUPPORTED_AOT = 0x3000, /*!< The Audio Object Type (AOT) is not supported. */
AAC_ENC_UNSUPPORTED_BITRATE = 0x3020, /*!< The chosen bitrate is not supported. */
AAC_ENC_UNSUPPORTED_BITRATE_MODE = 0x3028, /*!< Unsupported bit rate mode (CBR or VBR). */
AAC_ENC_UNSUPPORTED_ANC_BITRATE = 0x3040, /*!< Unsupported ancillay bitrate. */
AAC_ENC_UNSUPPORTED_ANC_MODE = 0x3060,
AAC_ENC_UNSUPPORTED_TRANSPORT_TYPE = 0x3080, /*!< The bitstream format is not supported. */
AAC_ENC_UNSUPPORTED_ER_FORMAT = 0x30a0, /*!< The error resilience tool format is not supported. */
AAC_ENC_UNSUPPORTED_EPCONFIG = 0x30c0, /*!< The error protection format is not supported. */
AAC_ENC_UNSUPPORTED_CHANNELCONFIG = 0x30e0, /*!< The channel configuration (either number or arrangement) is not supported. */
AAC_ENC_UNSUPPORTED_SAMPLINGRATE = 0x3100, /*!< Sample rate of audio input is not supported. */
AAC_ENC_NO_MEMORY = 0x3120, /*!< Could not allocate memory. */
AAC_ENC_PE_INIT_TABLE_NOT_FOUND = 0x3140, /*!< Internal encoder error. */
AAC_ENC_UNSUPPORTED_AOT =
0x3000, /*!< The Audio Object Type (AOT) is not supported. */
AAC_ENC_UNSUPPORTED_FILTERBANK =
0x3010, /*!< Filterbank type is not supported. */
AAC_ENC_UNSUPPORTED_BITRATE =
0x3020, /*!< The chosen bitrate is not supported. */
AAC_ENC_UNSUPPORTED_BITRATE_MODE =
0x3028, /*!< Unsupported bit rate mode (CBR or VBR). */
AAC_ENC_UNSUPPORTED_ANC_BITRATE =
0x3040, /*!< Unsupported ancillay bitrate. */
AAC_ENC_UNSUPPORTED_ANC_MODE = 0x3060,
AAC_ENC_UNSUPPORTED_TRANSPORT_TYPE =
0x3080, /*!< The bitstream format is not supported. */
AAC_ENC_UNSUPPORTED_ER_FORMAT =
0x30a0, /*!< The error resilience tool format is not supported. */
AAC_ENC_UNSUPPORTED_EPCONFIG =
0x30c0, /*!< The error protection format is not supported. */
AAC_ENC_UNSUPPORTED_CHANNELCONFIG =
0x30e0, /*!< The channel configuration (either number or arrangement) is
not supported. */
AAC_ENC_UNSUPPORTED_SAMPLINGRATE =
0x3100, /*!< Sample rate of audio input is not supported. */
AAC_ENC_NO_MEMORY = 0x3120, /*!< Could not allocate memory. */
AAC_ENC_PE_INIT_TABLE_NOT_FOUND = 0x3140, /*!< Internal encoder error. */
aac_enc_init_error_end,
/* encode errors */
aac_enc_error_start = 0x4000,
AAC_ENC_QUANT_ERROR = 0x4020, /*!< Too many bits used in quantization. */
AAC_ENC_WRITTEN_BITS_ERROR = 0x4040, /*!< Unexpected number of written bits, differs to
calculated number of bits. */
AAC_ENC_PNS_TABLE_ERROR = 0x4060, /*!< PNS level out of range. */
AAC_ENC_GLOBAL_GAIN_TOO_HIGH = 0x4080, /*!< Internal quantizer error. */
AAC_ENC_BITRES_TOO_LOW = 0x40a0, /*!< Too few bits in bit reservoir. */
AAC_ENC_BITRES_TOO_HIGH = 0x40a1, /*!< Too many bits in bit reservoir. */
AAC_ENC_INVALID_CHANNEL_BITRATE = 0x4100,
AAC_ENC_INVALID_ELEMENTINFO_TYPE = 0x4120, /*!< Internal encoder error. */
aac_enc_error_start = 0x4000,
AAC_ENC_QUANT_ERROR = 0x4020, /*!< Too many bits used in quantization. */
AAC_ENC_WRITTEN_BITS_ERROR =
0x4040, /*!< Unexpected number of written bits, differs to
calculated number of bits. */
AAC_ENC_PNS_TABLE_ERROR = 0x4060, /*!< PNS level out of range. */
AAC_ENC_GLOBAL_GAIN_TOO_HIGH = 0x4080, /*!< Internal quantizer error. */
AAC_ENC_BITRES_TOO_LOW = 0x40a0, /*!< Too few bits in bit reservoir. */
AAC_ENC_BITRES_TOO_HIGH = 0x40a1, /*!< Too many bits in bit reservoir. */
AAC_ENC_INVALID_CHANNEL_BITRATE = 0x4100,
AAC_ENC_INVALID_ELEMENTINFO_TYPE = 0x4120, /*!< Internal encoder error. */
AAC_ENC_WRITE_SCAL_ERROR = 0x41e0, /*!< Error writing scalefacData. */
AAC_ENC_WRITE_SEC_ERROR = 0x4200, /*!< Error writing sectionData. */
AAC_ENC_WRITE_SPEC_ERROR = 0x4220, /*!< Error writing spectralData. */
AAC_ENC_WRITE_SCAL_ERROR = 0x41e0, /*!< Error writing scalefacData. */
AAC_ENC_WRITE_SEC_ERROR = 0x4200, /*!< Error writing sectionData. */
AAC_ENC_WRITE_SPEC_ERROR = 0x4220, /*!< Error writing spectralData. */
aac_enc_error_end
} AAC_ENCODER_ERROR;
/*-------------------------- defines --------------------------------------*/
#define ANC_DATA_BUFFERSIZE 1024 /* ancBuffer size */
#define MAX_TOTAL_EXT_PAYLOADS (((8) * (1)) + (2+2))
#define ANC_DATA_BUFFERSIZE 1024 /* ancBuffer size */
#define MAX_TOTAL_EXT_PAYLOADS ((((8)) * (1)) + (2 + 2))
typedef enum {
AACENC_BR_MODE_INVALID = -1, /*!< Invalid bitrate mode. */
AACENC_BR_MODE_CBR = 0, /*!< Constant bitrate mode. */
AACENC_BR_MODE_VBR_1 = 1, /*!< Variable bitrate mode, about 32 kbps/channel. */
AACENC_BR_MODE_VBR_2 = 2, /*!< Variable bitrate mode, about 40 kbps/channel. */
AACENC_BR_MODE_VBR_3 = 3, /*!< Variable bitrate mode, about 48-56 kbps/channel. */
AACENC_BR_MODE_VBR_4 = 4, /*!< Variable bitrate mode, about 64 kbps/channel. */
AACENC_BR_MODE_VBR_5 = 5, /*!< Variable bitrate mode, about 80-96 kbps/channel. */
AACENC_BR_MODE_FF = 6, /*!< Fixed frame mode. */
AACENC_BR_MODE_SFR = 7 /*!< Superframe mode. */
AACENC_BR_MODE_INVALID = -1, /*!< Invalid bitrate mode. */
AACENC_BR_MODE_CBR = 0, /*!< Constant bitrate mode. */
AACENC_BR_MODE_VBR_1 = 1, /*!< Variable bitrate mode, very low bitrate. */
AACENC_BR_MODE_VBR_2 = 2, /*!< Variable bitrate mode, low bitrate. */
AACENC_BR_MODE_VBR_3 = 3, /*!< Variable bitrate mode, medium bitrate. */
AACENC_BR_MODE_VBR_4 = 4, /*!< Variable bitrate mode, high bitrate. */
AACENC_BR_MODE_VBR_5 = 5, /*!< Variable bitrate mode, very high bitrate. */
AACENC_BR_MODE_FF = 6, /*!< Fixed frame mode. */
AACENC_BR_MODE_SFR = 7 /*!< Superframe mode. */
} AACENC_BITRATE_MODE;
#define AACENC_BR_MODE_IS_VBR(brMode) ((brMode >= 1) && (brMode <= 5))
typedef enum {
CH_ORDER_MPEG = 0, /*!< MPEG channel ordering (e. g. 5.1: C, L, R, SL, SR, LFE) */
CH_ORDER_WAV /*!< WAV fileformat channel ordering (e. g. 5.1: L, R, C, LFE, SL, SR) */
CH_ORDER_MPEG =
0, /*!< MPEG channel ordering (e. g. 5.1: C, L, R, SL, SR, LFE) */
CH_ORDER_WAV /*!< WAV fileformat channel ordering (e. g. 5.1: L, R, C, LFE,
SL, SR) */
} CHANNEL_ORDER;
/*-------------------- structure definitions ------------------------------*/
struct AACENC_CONFIG {
INT sampleRate; /* encoder sample rate */
INT bitRate; /* encoder bit rate in bits/sec */
INT ancDataBitRate; /* additional bits consumed by anc data or sbr have to be consiedered while configuration */
INT sampleRate; /* encoder sample rate */
INT bitRate; /* encoder bit rate in bits/sec */
INT ancDataBitRate; /* additional bits consumed by anc data or sbr have to be
consiedered while configuration */
INT nSubFrames; /* number of frames in super frame (not ADTS/LATM subframes !) */
AUDIO_OBJECT_TYPE audioObjectType; /* Audio Object Type */
INT nSubFrames; /* number of frames in super frame (not ADTS/LATM subframes !)
*/
AUDIO_OBJECT_TYPE audioObjectType; /* Audio Object Type */
INT averageBits; /* encoder bit rate in bits/superframe */
INT bitrateMode; /* encoder bitrate mode (CBR/VBR) */
INT nChannels; /* number of channels to process */
CHANNEL_ORDER channelOrder; /* Input Channel ordering scheme. */
INT bandWidth; /* targeted audio bandwidth in Hz */
CHANNEL_MODE channelMode; /* encoder channel mode configuration */
INT framelength; /* used frame size */
INT averageBits; /* encoder bit rate in bits/superframe */
AACENC_BITRATE_MODE bitrateMode; /* encoder bitrate mode (CBR/VBR) */
INT nChannels; /* number of channels to process */
CHANNEL_ORDER channelOrder; /* input Channel ordering scheme. */
INT bandWidth; /* targeted audio bandwidth in Hz */
CHANNEL_MODE channelMode; /* encoder channel mode configuration */
INT framelength; /* used frame size */
UINT syntaxFlags; /* bitstreams syntax configuration */
SCHAR epConfig; /* error protection configuration */
UINT syntaxFlags; /* bitstreams syntax configuration */
SCHAR epConfig; /* error protection configuration */
INT anc_Rate; /* ancillary rate, 0 (disabled), -1 (default) else desired rate */
UINT maxAncBytesPerAU;
INT minBitsPerFrame; /* minimum number of bits in AU */
INT maxBitsPerFrame; /* maximum number of bits in AU */
INT bitreservoir; /* size of bitreservoir */
INT anc_Rate; /* ancillary rate, 0 (disabled), -1 (default) else desired rate
*/
UINT maxAncBytesPerAU;
INT minBitsPerFrame; /* minimum number of bits in AU */
INT maxBitsPerFrame; /* maximum number of bits in AU */
INT audioMuxVersion; /* audio mux version in loas/latm transport format */
INT audioMuxVersion; /* audio mux version in loas/latm transport format */
UINT sbrRatio; /* sbr sampling rate ratio: dual- or single-rate */
UINT sbrRatio; /* sbr sampling rate ratio: dual- or single-rate */
UCHAR useTns; /* flag: use temporal noise shaping */
UCHAR usePns; /* flag: use perceptual noise substitution */
UCHAR useIS; /* flag: use intensity coding */
UCHAR useTns; /* flag: use temporal noise shaping */
UCHAR usePns; /* flag: use perceptual noise substitution */
UCHAR useIS; /* flag: use intensity coding */
UCHAR useMS; /* flag: use ms stereo tool */
UCHAR useRequant; /* flag: use afterburner */
UCHAR useRequant; /* flag: use afterburner */
UINT downscaleFactor;
};
typedef struct {
UCHAR *pData; /* pointer to extension payload data */
UINT dataSize; /* extension payload data size in bits */
EXT_PAYLOAD_TYPE dataType; /* extension payload data type */
INT associatedChElement; /* number of the channel element the data is assigned to */
UCHAR *pData; /* pointer to extension payload data */
UINT dataSize; /* extension payload data size in bits */
EXT_PAYLOAD_TYPE dataType; /* extension payload data type */
INT associatedChElement; /* number of the channel element the data is assigned
to */
} AACENC_EXT_PAYLOAD;
typedef struct AAC_ENC *HANDLE_AAC_ENC;
/**
* \brief Calculate framesize in bits for given bit rate, frame length and sampling rate.
* \brief Calculate framesize in bits for given bit rate, frame length and
* sampling rate.
*
* \param bitRate Ttarget bitrate in bits per second.
* \param frameLength Number of audio samples in one frame.
* \param samplingRate Sampling rate in Hz.
*
* \return Framesize in bits per frame.
*/
INT FDKaacEnc_CalcBitsPerFrame(
const INT bitRate,
const INT frameLength,
const INT samplingRate
);
*/
INT FDKaacEnc_CalcBitsPerFrame(const INT bitRate, const INT frameLength,
const INT samplingRate);
/**
* \brief Calculate bitrate in bits per second for given framesize, frame length and sampling rate.
* \brief Calculate bitrate in bits per second for given framesize, frame length
* and sampling rate.
*
* \param bitsPerFrame Framesize in bits per frame.
* \param bitsPerFrame Framesize in bits per frame
* \param frameLength Number of audio samples in one frame.
* \param samplingRate Sampling rate in Hz.
*
* \return Bitrate in bits per second.
*/
INT FDKaacEnc_CalcBitrate(
const INT bitsPerFrame,
const INT frameLength,
const INT samplingRate
);
*/
INT FDKaacEnc_CalcBitrate(const INT bitsPerFrame, const INT frameLength,
const INT samplingRate);
/**
* \brief Limit given bit rate to a valid value
* \param hTpEnc transport encoder handle
* \param aot audio object type
* \param coreSamplingRate the sample rate to be used for the AAC encoder
* \param frameLength the frameLength to be used for the AAC encoder
* \param nChannels number of total channels
* \param nChannelsEff number of effective channels
* \param bitRate the initial bit rate value for which the closest valid bit rate value is searched for
* \param averageBits average bits per frame for fixed framing. Set to -1 if not available.
* \param bitRate the initial bit rate value for which the closest valid bit
* rate value is searched for
* \param averageBits average bits per frame for fixed framing. Set to -1 if not
* available.
* \param optional pointer where the current bits per frame are stored into.
* \param bitrateMode the current bit rate mode
* \param nSubFrames number of sub frames for super framing (not transport frames).
* \param nSubFrames number of sub frames for super framing (not transport
* frames).
* \return a valid bit rate value as close as possible or identical to bitRate
*/
INT FDKaacEnc_LimitBitrate(
HANDLE_TRANSPORTENC hTpEnc,
INT coreSamplingRate,
INT frameLength,
INT nChannels,
INT nChannelsEff,
INT bitRate,
INT averageBits,
INT *pAverageBitsPerFrame,
INT bitrateMode,
INT nSubFrames
);
INT FDKaacEnc_LimitBitrate(HANDLE_TRANSPORTENC hTpEnc, AUDIO_OBJECT_TYPE aot,
INT coreSamplingRate, INT frameLength, INT nChannels,
INT nChannelsEff, INT bitRate, INT averageBits,
INT *pAverageBitsPerFrame,
AACENC_BITRATE_MODE bitrateMode, INT nSubFrames);
/*-----------------------------------------------------------------------------
/**
* \brief Get current state of the bit reservoir
* \param hAacEncoder encoder handle
* \return bit reservoir state in bits
*/
INT FDKaacEnc_GetBitReservoirState(const HANDLE_AAC_ENC hAacEncoder);
functionname: FDKaacEnc_GetVBRBitrate
description: Get VBR bitrate from vbr quality
input params: int vbrQuality (VBR0, VBR1, VBR2)
channelMode
returns: vbr bitrate
/*-----------------------------------------------------------------------------
------------------------------------------------------------------------------*/
INT FDKaacEnc_GetVBRBitrate(INT bitrateMode, CHANNEL_MODE channelMode);
functionname: FDKaacEnc_GetVBRBitrate
description: Get VBR bitrate from vbr quality
input params: int vbrQuality (VBR0, VBR1, VBR2)
channelMode
returns: vbr bitrate
------------------------------------------------------------------------------*/
INT FDKaacEnc_GetVBRBitrate(AACENC_BITRATE_MODE bitrateMode,
CHANNEL_MODE channelMode);
/*-----------------------------------------------------------------------------
@ -305,26 +340,27 @@ INT FDKaacEnc_LimitBitrate(
returns: ---
------------------------------------------------------------------------------*/
void FDKaacEnc_AacInitDefaultConfig(AACENC_CONFIG *config);
void FDKaacEnc_AacInitDefaultConfig(AACENC_CONFIG *config);
/*---------------------------------------------------------------------------
functionname:FDKaacEnc_Open
functionname:FDKaacEnc_Open
description: allocate and initialize a new encoder instance
returns: 0 if success
---------------------------------------------------------------------------*/
AAC_ENCODER_ERROR FDKaacEnc_Open(HANDLE_AAC_ENC *phAacEnc, /* pointer to an encoder handle, initialized on return */
const INT nElements, /* number of maximal elements in instance to support */
const INT nChannels, /* number of maximal channels in instance to support */
const INT nSubFrames); /* support superframing in instance */
AAC_ENCODER_ERROR FDKaacEnc_Initialize(HANDLE_AAC_ENC hAacEncoder, /* pointer to an encoder handle, initialized on return */
AACENC_CONFIG *config, /* pre-initialized config struct */
HANDLE_TRANSPORTENC hTpEnc,
ULONG initFlags);
AAC_ENCODER_ERROR FDKaacEnc_Open(
HANDLE_AAC_ENC
*phAacEnc, /* pointer to an encoder handle, initialized on return */
const INT nElements, /* number of maximal elements in instance to support */
const INT nChannels, /* number of maximal channels in instance to support */
const INT nSubFrames); /* support superframing in instance */
AAC_ENCODER_ERROR FDKaacEnc_Initialize(
HANDLE_AAC_ENC
hAacEncoder, /* pointer to an encoder handle, initialized on return */
AACENC_CONFIG *config, /* pre-initialized config struct */
HANDLE_TRANSPORTENC hTpEnc, ULONG initFlags);
/*---------------------------------------------------------------------------
@ -334,12 +370,11 @@ AAC_ENCODER_ERROR FDKaacEnc_Initialize(HANDLE_AAC_ENC hAacEncoder, /* poin
---------------------------------------------------------------------------*/
AAC_ENCODER_ERROR FDKaacEnc_EncodeFrame( HANDLE_AAC_ENC hAacEnc, /* encoder handle */
HANDLE_TRANSPORTENC hTpEnc,
INT_PCM* inputBuffer,
INT* numOutBytes,
AACENC_EXT_PAYLOAD extPayload[MAX_TOTAL_EXT_PAYLOADS]
);
AAC_ENCODER_ERROR FDKaacEnc_EncodeFrame(
HANDLE_AAC_ENC hAacEnc, /* encoder handle */
HANDLE_TRANSPORTENC hTpEnc, INT_PCM *inputBuffer,
const UINT inputBufferBufSize, INT *numOutBytes,
AACENC_EXT_PAYLOAD extPayload[MAX_TOTAL_EXT_PAYLOADS]);
/*---------------------------------------------------------------------------
@ -349,11 +384,10 @@ AAC_ENCODER_ERROR FDKaacEnc_EncodeFrame( HANDLE_AAC_ENC hAacEnc, /
---------------------------------------------------------------------------*/
void FDKaacEnc_Close( HANDLE_AAC_ENC* phAacEnc); /* encoder handle */
void FDKaacEnc_Close(HANDLE_AAC_ENC *phAacEnc); /* encoder handle */
#ifdef __cplusplus
}
#endif
#endif /* _aacenc_h_ */
#endif /* AACENC_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,43 +90,37 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder **************************
/**************************** AAC encoder library ******************************
Initial author: M. Lohwasser
contents/description: pns.c
Author(s): M. Lohwasser
******************************************************************************/
Description: pns.c
*******************************************************************************/
#include "aacenc_pns.h"
#include "psy_data.h"
#include "pnsparam.h"
#include "noisedet.h"
#include "bit_cnt.h"
#include "interface.h"
/* minCorrelationEnergy = (1.0e-10f)^2 ~ 2^-67 = 2^-47 * 2^-20 */
static const FIXP_DBL minCorrelationEnergy = FL2FXCONST_DBL(0.0); /* FL2FXCONST_DBL((float)FDKpow(2.0,-47)); */
static const FIXP_DBL minCorrelationEnergy =
FL2FXCONST_DBL(0.0); /* FL2FXCONST_DBL((float)FDKpow(2.0,-47)); */
/* noiseCorrelationThresh = 0.6^2 */
static const FIXP_DBL noiseCorrelationThresh = FL2FXCONST_DBL(0.36);
static void FDKaacEnc_FDKaacEnc_noiseDetection( PNS_CONFIG *pnsConf,
PNS_DATA *pnsData,
const INT sfbActive,
const INT *sfbOffset,
INT tnsOrder,
INT tnsPredictionGain,
INT tnsActive,
FIXP_DBL *mdctSpectrum,
INT *sfbMaxScaleSpec,
FIXP_SGL *sfbtonality );
static void FDKaacEnc_FDKaacEnc_noiseDetection(
PNS_CONFIG *pnsConf, PNS_DATA *pnsData, const INT sfbActive,
const INT *sfbOffset, INT tnsOrder, INT tnsPredictionGain, INT tnsActive,
FIXP_DBL *mdctSpectrum, INT *sfbMaxScaleSpec, FIXP_SGL *sfbtonality);
static void FDKaacEnc_CalcNoiseNrgs( const INT sfbActive,
INT *pnsFlag,
FIXP_DBL *sfbEnergyLdData,
INT *noiseNrg );
static void FDKaacEnc_CalcNoiseNrgs(const INT sfbActive, INT *pnsFlag,
FIXP_DBL *sfbEnergyLdData, INT *noiseNrg);
/*****************************************************************************
@ -129,28 +134,15 @@ static void FDKaacEnc_CalcNoiseNrgs( const INT sfbActive,
*****************************************************************************/
AAC_ENCODER_ERROR FDKaacEnc_InitPnsConfiguration(PNS_CONFIG *pnsConf,
INT bitRate,
INT sampleRate,
INT usePns,
INT sfbCnt,
const INT *sfbOffset,
const INT numChan,
const INT isLC)
{
AAC_ENCODER_ERROR FDKaacEnc_InitPnsConfiguration(
PNS_CONFIG *pnsConf, INT bitRate, INT sampleRate, INT usePns, INT sfbCnt,
const INT *sfbOffset, const INT numChan, const INT isLC) {
AAC_ENCODER_ERROR ErrorStatus;
/* init noise detection */
ErrorStatus = FDKaacEnc_GetPnsParam(&pnsConf->np,
bitRate,
sampleRate,
sfbCnt,
sfbOffset,
&usePns,
numChan,
isLC);
if (ErrorStatus != AAC_ENC_OK)
return ErrorStatus;
ErrorStatus = FDKaacEnc_GetPnsParam(&pnsConf->np, bitRate, sampleRate, sfbCnt,
sfbOffset, &usePns, numChan, isLC);
if (ErrorStatus != AAC_ENC_OK) return ErrorStatus;
pnsConf->minCorrelationEnergy = minCorrelationEnergy;
pnsConf->noiseCorrelationThresh = noiseCorrelationThresh;
@ -160,8 +152,6 @@ AAC_ENCODER_ERROR FDKaacEnc_InitPnsConfiguration(PNS_CONFIG *pnsConf,
return AAC_ENC_OK;
}
/*****************************************************************************
functionname: FDKaacEnc_PnsDetect
@ -180,73 +170,55 @@ AAC_ENCODER_ERROR FDKaacEnc_InitPnsConfiguration(PNS_CONFIG *pnsConf,
output: pnsFlag in pns data structure
*****************************************************************************/
void FDKaacEnc_PnsDetect(PNS_CONFIG *pnsConf,
PNS_DATA *pnsData,
const INT lastWindowSequence,
const INT sfbActive,
const INT maxSfbPerGroup,
FIXP_DBL *sfbThresholdLdData,
const INT *sfbOffset,
FIXP_DBL *mdctSpectrum,
INT *sfbMaxScaleSpec,
FIXP_SGL *sfbtonality,
INT tnsOrder,
INT tnsPredictionGain,
INT tnsActive,
FIXP_DBL *sfbEnergyLdData,
INT *noiseNrg )
void FDKaacEnc_PnsDetect(PNS_CONFIG *pnsConf, PNS_DATA *pnsData,
const INT lastWindowSequence, const INT sfbActive,
const INT maxSfbPerGroup, FIXP_DBL *sfbThresholdLdData,
const INT *sfbOffset, FIXP_DBL *mdctSpectrum,
INT *sfbMaxScaleSpec, FIXP_SGL *sfbtonality,
INT tnsOrder, INT tnsPredictionGain, INT tnsActive,
FIXP_DBL *sfbEnergyLdData, INT *noiseNrg)
{
int sfb;
int startNoiseSfb;
if (pnsConf->np.detectionAlgorithmFlags & IS_LOW_COMLEXITY) {
if ( (!pnsConf->usePns) || /* pns enabled? */
(lastWindowSequence == SHORT_WINDOW) ) /* currently only long blocks */
{
FDKmemclear(pnsData->pnsFlag, MAX_GROUPED_SFB*sizeof(INT)); /* clear all pnsFlags */
for (sfb=0; sfb<MAX_GROUPED_SFB; sfb++) {
noiseNrg[sfb] = NO_NOISE_PNS; /* clear nrg's of previous frame */
}
return;
}
/* Reset pns info. */
FDKmemclear(pnsData->pnsFlag, sizeof(pnsData->pnsFlag));
for (sfb = 0; sfb < MAX_GROUPED_SFB; sfb++) {
noiseNrg[sfb] = NO_NOISE_PNS;
}
else {
if(!pnsConf->usePns)
return;
/* PNS only for long Windows */
if (pnsConf->np.detectionAlgorithmFlags & JUST_LONG_WINDOW) {
if(lastWindowSequence != LONG_WINDOW) {
for (sfb = 0; sfb < sfbActive; sfb++) {
pnsData->pnsFlag[sfb] = 0; /* clear all pnsFlags */
}
return;
}
/* Disable PNS and skip detection in certain cases. */
if (pnsConf->usePns == 0) {
return;
} else {
/* AAC - LC core encoder */
if ((pnsConf->np.detectionAlgorithmFlags & IS_LOW_COMPLEXITY) &&
(lastWindowSequence == SHORT_WINDOW)) {
return;
}
/* AAC - (E)LD core encoder */
if (!(pnsConf->np.detectionAlgorithmFlags & IS_LOW_COMPLEXITY) &&
(pnsConf->np.detectionAlgorithmFlags & JUST_LONG_WINDOW) &&
(lastWindowSequence != LONG_WINDOW)) {
return;
}
}
/*
call noise detection
*/
FDKaacEnc_FDKaacEnc_noiseDetection( pnsConf,
pnsData,
sfbActive,
sfbOffset,
tnsOrder,
tnsPredictionGain,
tnsActive,
mdctSpectrum,
sfbMaxScaleSpec,
sfbtonality );
FDKaacEnc_FDKaacEnc_noiseDetection(
pnsConf, pnsData, sfbActive, sfbOffset, tnsOrder, tnsPredictionGain,
tnsActive, mdctSpectrum, sfbMaxScaleSpec, sfbtonality);
/* set startNoiseSfb (long) */
startNoiseSfb = pnsConf->np.startSfb;
/* Set noise substitution status */
for(sfb = 0; sfb < sfbActive; sfb++) {
for (sfb = 0; sfb < sfbActive; sfb++) {
/* No PNS below startNoiseSfb */
if(sfb < startNoiseSfb){
if (sfb < startNoiseSfb) {
pnsData->pnsFlag[sfb] = 0;
continue;
}
@ -258,17 +230,17 @@ void FDKaacEnc_PnsDetect(PNS_CONFIG *pnsConf,
signal in coder band is not masked
*/
if((pnsData->noiseFuzzyMeasure[sfb] > FL2FXCONST_SGL(0.5)) &&
( (sfbThresholdLdData[sfb] + FL2FXCONST_DBL(0.5849625f/64.0f)) /* thr * 1.5 = thrLd +ld(1.5)/64 */
< sfbEnergyLdData[sfb] ) )
{
if ((pnsData->noiseFuzzyMeasure[sfb] > FL2FXCONST_SGL(0.5)) &&
((sfbThresholdLdData[sfb] +
FL2FXCONST_DBL(0.5849625f /
64.0f)) /* thr * 1.5 = thrLd +ld(1.5)/64 */
< sfbEnergyLdData[sfb])) {
/*
mark in psyout flag array that we will code
this band with PNS
*/
pnsData->pnsFlag[sfb] = 1; /* PNS_ON */
}
else{
} else {
pnsData->pnsFlag[sfb] = 0; /* PNS_OFF */
}
@ -276,50 +248,49 @@ void FDKaacEnc_PnsDetect(PNS_CONFIG *pnsConf,
}
/* avoid PNS holes */
if((pnsData->noiseFuzzyMeasure[0]>FL2FXCONST_SGL(0.5f)) && (pnsData->pnsFlag[1])) {
if ((pnsData->noiseFuzzyMeasure[0] > FL2FXCONST_SGL(0.5f)) &&
(pnsData->pnsFlag[1])) {
pnsData->pnsFlag[0] = 1;
}
for(sfb=1; sfb<maxSfbPerGroup-1; sfb++) {
if((pnsData->noiseFuzzyMeasure[sfb]>pnsConf->np.gapFillThr) &&
(pnsData->pnsFlag[sfb-1]) && (pnsData->pnsFlag[sfb+1])) {
for (sfb = 1; sfb < maxSfbPerGroup - 1; sfb++) {
if ((pnsData->noiseFuzzyMeasure[sfb] > pnsConf->np.gapFillThr) &&
(pnsData->pnsFlag[sfb - 1]) && (pnsData->pnsFlag[sfb + 1])) {
pnsData->pnsFlag[sfb] = 1;
}
}
if(maxSfbPerGroup>0) {
if (maxSfbPerGroup > 0) {
/* avoid PNS hole */
if((pnsData->noiseFuzzyMeasure[maxSfbPerGroup-1]>pnsConf->np.gapFillThr) && (pnsData->pnsFlag[maxSfbPerGroup-2])) {
pnsData->pnsFlag[maxSfbPerGroup-1] = 1;
if ((pnsData->noiseFuzzyMeasure[maxSfbPerGroup - 1] >
pnsConf->np.gapFillThr) &&
(pnsData->pnsFlag[maxSfbPerGroup - 2])) {
pnsData->pnsFlag[maxSfbPerGroup - 1] = 1;
}
/* avoid single PNS band */
if(pnsData->pnsFlag[maxSfbPerGroup-2]==0) {
pnsData->pnsFlag[maxSfbPerGroup-1] = 0;
if (pnsData->pnsFlag[maxSfbPerGroup - 2] == 0) {
pnsData->pnsFlag[maxSfbPerGroup - 1] = 0;
}
}
/* avoid single PNS bands */
if(pnsData->pnsFlag[1]==0) {
if (pnsData->pnsFlag[1] == 0) {
pnsData->pnsFlag[0] = 0;
}
for(sfb=1; sfb<maxSfbPerGroup-1; sfb++) {
if((pnsData->pnsFlag[sfb-1]==0)&&(pnsData->pnsFlag[sfb+1]==0)) {
for (sfb = 1; sfb < maxSfbPerGroup - 1; sfb++) {
if ((pnsData->pnsFlag[sfb - 1] == 0) && (pnsData->pnsFlag[sfb + 1] == 0)) {
pnsData->pnsFlag[sfb] = 0;
}
}
/*
calculate noiseNrg's
*/
FDKaacEnc_CalcNoiseNrgs( sfbActive,
pnsData->pnsFlag,
sfbEnergyLdData,
noiseNrg );
FDKaacEnc_CalcNoiseNrgs(sfbActive, pnsData->pnsFlag, sfbEnergyLdData,
noiseNrg);
}
/*****************************************************************************
functionname:FDKaacEnc_FDKaacEnc_noiseDetection
@ -335,49 +306,36 @@ void FDKaacEnc_PnsDetect(PNS_CONFIG *pnsConf,
flags tonal / nontonal
*****************************************************************************/
static void FDKaacEnc_FDKaacEnc_noiseDetection( PNS_CONFIG *pnsConf,
PNS_DATA *pnsData,
const INT sfbActive,
const INT *sfbOffset,
int tnsOrder,
INT tnsPredictionGain,
INT tnsActive,
FIXP_DBL *mdctSpectrum,
INT *sfbMaxScaleSpec,
FIXP_SGL *sfbtonality )
{
INT condition = TRUE;
if ( !(pnsConf->np.detectionAlgorithmFlags & IS_LOW_COMLEXITY) ) {
condition = (tnsOrder > 3);
}
/*
no PNS if heavy TNS activity
clear pnsData->noiseFuzzyMeasure
*/
if((pnsConf->np.detectionAlgorithmFlags & USE_TNS_GAIN_THR) &&
static void FDKaacEnc_FDKaacEnc_noiseDetection(
PNS_CONFIG *pnsConf, PNS_DATA *pnsData, const INT sfbActive,
const INT *sfbOffset, int tnsOrder, INT tnsPredictionGain, INT tnsActive,
FIXP_DBL *mdctSpectrum, INT *sfbMaxScaleSpec, FIXP_SGL *sfbtonality) {
INT condition = TRUE;
if (!(pnsConf->np.detectionAlgorithmFlags & IS_LOW_COMPLEXITY)) {
condition = (tnsOrder > 3);
}
/*
no PNS if heavy TNS activity
clear pnsData->noiseFuzzyMeasure
*/
if ((pnsConf->np.detectionAlgorithmFlags & USE_TNS_GAIN_THR) &&
(tnsPredictionGain >= pnsConf->np.tnsGainThreshold) && condition &&
!((pnsConf->np.detectionAlgorithmFlags & USE_TNS_PNS) && (tnsPredictionGain >= pnsConf->np.tnsPNSGainThreshold) && (tnsActive)) )
{
/* clear all noiseFuzzyMeasure */
FDKmemclear(pnsData->noiseFuzzyMeasure, sfbActive*sizeof(FIXP_SGL));
}
else
{
/*
call noise detection, output in pnsData->noiseFuzzyMeasure,
use real mdct spectral data
*/
FDKaacEnc_noiseDetect( mdctSpectrum,
sfbMaxScaleSpec,
sfbActive,
sfbOffset,
pnsData->noiseFuzzyMeasure,
&pnsConf->np,
sfbtonality);
}
!((pnsConf->np.detectionAlgorithmFlags & USE_TNS_PNS) &&
(tnsPredictionGain >= pnsConf->np.tnsPNSGainThreshold) &&
(tnsActive))) {
/* clear all noiseFuzzyMeasure */
FDKmemclear(pnsData->noiseFuzzyMeasure, sfbActive * sizeof(FIXP_SGL));
} else {
/*
call noise detection, output in pnsData->noiseFuzzyMeasure,
use real mdct spectral data
*/
FDKaacEnc_noiseDetect(mdctSpectrum, sfbMaxScaleSpec, sfbActive, sfbOffset,
pnsData->noiseFuzzyMeasure, &pnsConf->np,
sfbtonality);
}
}
/*****************************************************************************
functionname:FDKaacEnc_CalcNoiseNrgs
@ -391,23 +349,21 @@ static void FDKaacEnc_FDKaacEnc_noiseDetection( PNS_CONFIG *pnsConf,
*****************************************************************************/
static void FDKaacEnc_CalcNoiseNrgs( const INT sfbActive,
INT *RESTRICT pnsFlag,
FIXP_DBL *RESTRICT sfbEnergyLdData,
INT *RESTRICT noiseNrg )
{
static void FDKaacEnc_CalcNoiseNrgs(const INT sfbActive, INT *RESTRICT pnsFlag,
FIXP_DBL *RESTRICT sfbEnergyLdData,
INT *RESTRICT noiseNrg) {
int sfb;
INT tmp = (-LOG_NORM_PCM)<<2;
INT tmp = (-LOG_NORM_PCM) << 2;
for(sfb = 0; sfb < sfbActive; sfb++) {
if(pnsFlag[sfb]) {
INT nrg = (-sfbEnergyLdData[sfb]+FL2FXCONST_DBL(0.5f/64.0f))>>(DFRACT_BITS-1-7);
for (sfb = 0; sfb < sfbActive; sfb++) {
if (pnsFlag[sfb]) {
INT nrg = (-sfbEnergyLdData[sfb] + FL2FXCONST_DBL(0.5f / 64.0f)) >>
(DFRACT_BITS - 1 - 7);
noiseNrg[sfb] = tmp - nrg;
}
}
}
/*****************************************************************************
functionname:FDKaacEnc_CodePnsChannel
@ -422,20 +378,18 @@ static void FDKaacEnc_CalcNoiseNrgs( const INT sfbActive,
*****************************************************************************/
void FDKaacEnc_CodePnsChannel(const INT sfbActive,
PNS_CONFIG *pnsConf,
INT *RESTRICT pnsFlag,
FIXP_DBL *RESTRICT sfbEnergyLdData,
INT *RESTRICT noiseNrg,
FIXP_DBL *RESTRICT sfbThresholdLdData)
{
void FDKaacEnc_CodePnsChannel(const INT sfbActive, PNS_CONFIG *pnsConf,
INT *RESTRICT pnsFlag,
FIXP_DBL *RESTRICT sfbEnergyLdData,
INT *RESTRICT noiseNrg,
FIXP_DBL *RESTRICT sfbThresholdLdData) {
INT sfb;
INT lastiNoiseEnergy = 0;
INT firstPNSband = 1; /* TRUE for first PNS-coded band */
/* no PNS */
if(!pnsConf->usePns) {
for(sfb = 0; sfb < sfbActive; sfb++) {
if (!pnsConf->usePns) {
for (sfb = 0; sfb < sfbActive; sfb++) {
/* no PNS coding */
noiseNrg[sfb] = NO_NOISE_PNS;
}
@ -443,34 +397,32 @@ void FDKaacEnc_CodePnsChannel(const INT sfbActive,
}
/* code PNS */
for(sfb = 0; sfb < sfbActive; sfb++) {
if(pnsFlag[sfb]) {
for (sfb = 0; sfb < sfbActive; sfb++) {
if (pnsFlag[sfb]) {
/* high sfbThreshold causes pe = 0 */
if(noiseNrg[sfb] != NO_NOISE_PNS)
sfbThresholdLdData[sfb] = sfbEnergyLdData[sfb] + FL2FXCONST_DBL(1.0f/LD_DATA_SCALING);
if (noiseNrg[sfb] != NO_NOISE_PNS)
sfbThresholdLdData[sfb] =
sfbEnergyLdData[sfb] + FL2FXCONST_DBL(1.0f / LD_DATA_SCALING);
/* set noiseNrg in valid region */
if(!firstPNSband) {
if (!firstPNSband) {
INT deltaiNoiseEnergy = noiseNrg[sfb] - lastiNoiseEnergy;
if(deltaiNoiseEnergy > CODE_BOOK_PNS_LAV)
noiseNrg[sfb] -= deltaiNoiseEnergy - CODE_BOOK_PNS_LAV;
else if(deltaiNoiseEnergy < -CODE_BOOK_PNS_LAV)
noiseNrg[sfb] -= deltaiNoiseEnergy + CODE_BOOK_PNS_LAV;
}
else {
if (deltaiNoiseEnergy > CODE_BOOK_PNS_LAV)
noiseNrg[sfb] -= deltaiNoiseEnergy - CODE_BOOK_PNS_LAV;
else if (deltaiNoiseEnergy < -CODE_BOOK_PNS_LAV)
noiseNrg[sfb] -= deltaiNoiseEnergy + CODE_BOOK_PNS_LAV;
} else {
firstPNSband = 0;
}
lastiNoiseEnergy = noiseNrg[sfb];
}
else {
} else {
/* no PNS coding */
noiseNrg[sfb] = NO_NOISE_PNS;
}
}
}
/*****************************************************************************
functionname:FDKaacEnc_PreProcessPnsChannelPair
@ -486,37 +438,40 @@ void FDKaacEnc_CodePnsChannel(const INT sfbActive,
*****************************************************************************/
void FDKaacEnc_PreProcessPnsChannelPair(const INT sfbActive,
FIXP_DBL *RESTRICT sfbEnergyLeft,
FIXP_DBL *RESTRICT sfbEnergyRight,
FIXP_DBL *RESTRICT sfbEnergyLeftLD,
FIXP_DBL *RESTRICT sfbEnergyRightLD,
FIXP_DBL *RESTRICT sfbEnergyMid,
PNS_CONFIG *RESTRICT pnsConf,
PNS_DATA *pnsDataLeft,
PNS_DATA *pnsDataRight)
{
void FDKaacEnc_PreProcessPnsChannelPair(
const INT sfbActive, FIXP_DBL *RESTRICT sfbEnergyLeft,
FIXP_DBL *RESTRICT sfbEnergyRight, FIXP_DBL *RESTRICT sfbEnergyLeftLD,
FIXP_DBL *RESTRICT sfbEnergyRightLD, FIXP_DBL *RESTRICT sfbEnergyMid,
PNS_CONFIG *RESTRICT pnsConf, PNS_DATA *pnsDataLeft,
PNS_DATA *pnsDataRight) {
INT sfb;
FIXP_DBL ccf;
if(!pnsConf->usePns)
return;
if (!pnsConf->usePns) return;
FIXP_DBL *RESTRICT pNoiseEnergyCorrelationL = pnsDataLeft->noiseEnergyCorrelation;
FIXP_DBL *RESTRICT pNoiseEnergyCorrelationR = pnsDataRight->noiseEnergyCorrelation;
FIXP_DBL *RESTRICT pNoiseEnergyCorrelationL =
pnsDataLeft->noiseEnergyCorrelation;
FIXP_DBL *RESTRICT pNoiseEnergyCorrelationR =
pnsDataRight->noiseEnergyCorrelation;
for(sfb=0;sfb< sfbActive;sfb++) {
FIXP_DBL quot = (sfbEnergyLeftLD[sfb]>>1) + (sfbEnergyRightLD[sfb]>>1);
for (sfb = 0; sfb < sfbActive; sfb++) {
FIXP_DBL quot = (sfbEnergyLeftLD[sfb] >> 1) + (sfbEnergyRightLD[sfb] >> 1);
if(quot < FL2FXCONST_DBL(-32.0f/(float)LD_DATA_SCALING))
if (quot < FL2FXCONST_DBL(-32.0f / (float)LD_DATA_SCALING))
ccf = FL2FXCONST_DBL(0.0f);
else {
FIXP_DBL accu = sfbEnergyMid[sfb]- (((sfbEnergyLeft[sfb]>>1)+(sfbEnergyRight[sfb]>>1))>>1);
INT sign = (accu < FL2FXCONST_DBL(0.0f)) ? 1 : 0 ;
FIXP_DBL accu =
sfbEnergyMid[sfb] -
(((sfbEnergyLeft[sfb] >> 1) + (sfbEnergyRight[sfb] >> 1)) >> 1);
INT sign = (accu < FL2FXCONST_DBL(0.0f)) ? 1 : 0;
accu = fixp_abs(accu);
ccf = CalcLdData(accu) + FL2FXCONST_DBL((float)1.0f/(float)LD_DATA_SCALING) - quot; /* ld(accu*2) = ld(accu) + 1 */
ccf = (ccf>=FL2FXCONST_DBL(0.0)) ? ((FIXP_DBL)MAXVAL_DBL) : (sign) ? -CalcInvLdData(ccf) : CalcInvLdData(ccf);
ccf = CalcLdData(accu) +
FL2FXCONST_DBL((float)1.0f / (float)LD_DATA_SCALING) -
quot; /* ld(accu*2) = ld(accu) + 1 */
ccf = (ccf >= FL2FXCONST_DBL(0.0))
? ((FIXP_DBL)MAXVAL_DBL)
: (sign) ? -CalcInvLdData(ccf) : CalcInvLdData(ccf);
}
pNoiseEnergyCorrelationL[sfb] = ccf;
@ -524,8 +479,6 @@ void FDKaacEnc_PreProcessPnsChannelPair(const INT sfbActive,
}
}
/*****************************************************************************
functionname:FDKaacEnc_PostProcessPnsChannelPair
@ -542,33 +495,29 @@ void FDKaacEnc_PreProcessPnsChannelPair(const INT sfbActive,
*****************************************************************************/
void FDKaacEnc_PostProcessPnsChannelPair(const INT sfbActive,
PNS_CONFIG *pnsConf,
PNS_DATA *pnsDataLeft,
PNS_DATA *pnsDataRight,
INT *RESTRICT msMask,
INT *msDigest )
{
void FDKaacEnc_PostProcessPnsChannelPair(const INT sfbActive,
PNS_CONFIG *pnsConf,
PNS_DATA *pnsDataLeft,
PNS_DATA *pnsDataRight,
INT *RESTRICT msMask, INT *msDigest) {
INT sfb;
if(!pnsConf->usePns)
return;
if (!pnsConf->usePns) return;
for(sfb=0;sfb<sfbActive;sfb++) {
for (sfb = 0; sfb < sfbActive; sfb++) {
/*
MS post processing
*/
if( msMask[sfb] ) {
if( (pnsDataLeft->pnsFlag[sfb]) &&
(pnsDataRight->pnsFlag[sfb]) ) {
if (msMask[sfb]) {
if ((pnsDataLeft->pnsFlag[sfb]) && (pnsDataRight->pnsFlag[sfb])) {
/* AAC only: Standard */
/* do this to avoid ms flags in layers that should not have it */
if(pnsDataLeft->noiseEnergyCorrelation[sfb] <= pnsConf->noiseCorrelationThresh){
if (pnsDataLeft->noiseEnergyCorrelation[sfb] <=
pnsConf->noiseCorrelationThresh) {
msMask[sfb] = 0;
*msDigest = MS_SOME;
}
}
else {
} else {
/*
No PNS coding
*/
@ -581,8 +530,9 @@ void FDKaacEnc_PostProcessPnsChannelPair(const INT sfbActive,
Use MS flag to signal noise correlation if
pns is active in both channels
*/
if( (pnsDataLeft->pnsFlag[sfb]) && (pnsDataRight->pnsFlag[sfb]) ) {
if(pnsDataLeft->noiseEnergyCorrelation[sfb] > pnsConf->noiseCorrelationThresh) {
if ((pnsDataLeft->pnsFlag[sfb]) && (pnsDataRight->pnsFlag[sfb])) {
if (pnsDataLeft->noiseEnergyCorrelation[sfb] >
pnsConf->noiseCorrelationThresh) {
msMask[sfb] = 1;
*msDigest = MS_SOME;
}

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,35 +90,35 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder **************************
/**************************** AAC encoder library ******************************
Initial author: M. Lohwasser
contents/description: pns.h
Author(s): M. Lohwasser
******************************************************************************/
Description: pns.h
#ifndef __PNS_H
#define __PNS_H
*******************************************************************************/
#ifndef AACENC_PNS_H
#define AACENC_PNS_H
#include "common_fix.h"
#include "pnsparam.h"
#define NO_NOISE_PNS FDK_INT_MIN
typedef struct{
typedef struct {
NOISEPARAMS np;
FIXP_DBL minCorrelationEnergy;
FIXP_DBL noiseCorrelationThresh;
INT usePns;
INT usePns;
} PNS_CONFIG;
typedef struct{
typedef struct {
FIXP_SGL noiseFuzzyMeasure[MAX_GROUPED_SFB];
FIXP_DBL noiseEnergyCorrelation[MAX_GROUPED_SFB];
INT pnsFlag[MAX_GROUPED_SFB];
INT pnsFlag[MAX_GROUPED_SFB];
} PNS_DATA;
#endif
#endif /* AACENC_PNS_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2015 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,25 +90,25 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder **************************
/**************************** AAC encoder library ******************************
Initial author: Alex Groeschel
contents/description: Temporal noise shaping
Author(s): Alex Groeschel
******************************************************************************/
Description: Temporal noise shaping
#ifndef _TNS_H
#define _TNS_H
*******************************************************************************/
#ifndef AACENC_TNS_H
#define AACENC_TNS_H
#include "common_fix.h"
#include "psy_const.h"
#ifndef PI
#define PI 3.1415926535897931f
#define PI 3.1415926535897931f
#endif
/**
@ -114,32 +125,33 @@ amm-info@iis.fraunhofer.de
/* TNS max filter order for Low Complexity MPEG4 profile */
#define TNS_MAX_ORDER 12
#define MAX_NUM_OF_FILTERS 2
#define HIFILT 0 /* index of higher filter */
#define LOFILT 1 /* index of lower filter */
#define HIFILT 0 /* index of higher filter */
#define LOFILT 1 /* index of lower filter */
typedef struct{ /* stuff that is tabulated dependent on bitrate etc. */
INT filterEnabled[MAX_NUM_OF_FILTERS];
INT threshOn[MAX_NUM_OF_FILTERS]; /* min. prediction gain for using tns TABUL*/
INT filterStartFreq[MAX_NUM_OF_FILTERS]; /* lowest freq for lpc TABUL*/
INT tnsLimitOrder[MAX_NUM_OF_FILTERS]; /* Limit for TNS order TABUL*/
INT tnsFilterDirection[MAX_NUM_OF_FILTERS]; /* Filtering direction, 0=up, 1=down TABUL */
INT acfSplit[MAX_NUM_OF_FILTERS];
FIXP_DBL tnsTimeResolution[MAX_NUM_OF_FILTERS]; /* TNS max. time resolution TABUL. Should be fract but MSVC won't compile then */
INT seperateFiltersAllowed;
typedef struct { /* stuff that is tabulated dependent on bitrate etc. */
INT filterEnabled[MAX_NUM_OF_FILTERS];
INT threshOn[MAX_NUM_OF_FILTERS]; /* min. prediction gain for using tns
TABUL*/
INT filterStartFreq[MAX_NUM_OF_FILTERS]; /* lowest freq for lpc TABUL*/
INT tnsLimitOrder[MAX_NUM_OF_FILTERS]; /* Limit for TNS order TABUL*/
INT tnsFilterDirection[MAX_NUM_OF_FILTERS]; /* Filtering direction, 0=up,
1=down TABUL */
INT acfSplit[MAX_NUM_OF_FILTERS];
FIXP_DBL tnsTimeResolution[MAX_NUM_OF_FILTERS]; /* TNS max. time resolution
TABUL. Should be fract but
MSVC won't compile then */
INT seperateFiltersAllowed;
} TNS_PARAMETER_TABULATED;
typedef struct { /*assigned at InitTime*/
typedef struct { /*assigned at InitTime*/
TNS_PARAMETER_TABULATED confTab;
INT isLowDelay;
INT tnsActive;
INT maxOrder; /* max. order of tns filter */
INT maxOrder; /* max. order of tns filter */
INT coefRes;
FIXP_DBL acfWindow[MAX_NUM_OF_FILTERS][TNS_MAX_ORDER+3+1];
FIXP_DBL acfWindow[MAX_NUM_OF_FILTERS][TNS_MAX_ORDER + 3 + 1];
/* now some things that only probably can be done at Init time;
could be they have to be split up for each individual (short) window or
even filter. */
@ -148,55 +160,54 @@ typedef struct { /*assigned at InitTime*/
INT lpcStopBand;
INT lpcStopLine;
}TNS_CONFIG;
} TNS_CONFIG;
typedef struct {
INT tnsActive[MAX_NUM_OF_FILTERS];
INT predictionGain[MAX_NUM_OF_FILTERS];
INT tnsActive[MAX_NUM_OF_FILTERS];
INT predictionGain[MAX_NUM_OF_FILTERS];
} TNS_SUBBLOCK_INFO;
typedef struct{ /*changed at runTime*/
typedef struct { /*changed at runTime*/
TNS_SUBBLOCK_INFO subBlockInfo[TRANS_FAC];
FIXP_DBL ratioMultTable[TRANS_FAC][MAX_SFB_SHORT];
} TNS_DATA_SHORT;
typedef struct{ /*changed at runTime*/
typedef struct { /*changed at runTime*/
TNS_SUBBLOCK_INFO subBlockInfo;
FIXP_DBL ratioMultTable[MAX_SFB_LONG];
} TNS_DATA_LONG;
/* can be implemented as union */
typedef shouldBeUnion{
typedef shouldBeUnion {
TNS_DATA_LONG Long;
TNS_DATA_SHORT Short;
}TNS_DATA_RAW;
}
TNS_DATA_RAW;
typedef struct{
typedef struct {
INT numOfSubblocks;
TNS_DATA_RAW dataRaw;
INT tnsMaxScaleSpec;
INT filtersMerged;
}TNS_DATA;
} TNS_DATA;
typedef struct{
typedef struct {
INT numOfFilters[TRANS_FAC];
INT coefRes[TRANS_FAC];
INT length[TRANS_FAC][MAX_NUM_OF_FILTERS];
INT order[TRANS_FAC][MAX_NUM_OF_FILTERS];
INT direction[TRANS_FAC][MAX_NUM_OF_FILTERS];
INT coefCompress[TRANS_FAC][MAX_NUM_OF_FILTERS];
/* for Long: length TNS_MAX_ORDER (12 for LC) is required -> 12 */
/* for Short: length TRANS_FAC*TNS_MAX_ORDER (only 5 for short LC) is required -> 8*5=40 */
/* Currently TRANS_FAC*TNS_MAX_ORDER = 8*12 = 96 (for LC) is used (per channel)! Memory could be saved here! */
/* for Long: length TNS_MAX_ORDER (12 for LC) is required -> 12 */
/* for Short: length TRANS_FAC*TNS_MAX_ORDER (only 5 for short LC) is required
* -> 8*5=40 */
/* Currently TRANS_FAC*TNS_MAX_ORDER = 8*12 = 96 (for LC) is used (per
* channel)! Memory could be saved here! */
INT coef[TRANS_FAC][MAX_NUM_OF_FILTERS][TNS_MAX_ORDER];
}TNS_INFO;
} TNS_INFO;
INT FDKaacEnc_FreqToBandWithRounding(
const INT freq,
const INT fs,
const INT numOfBands,
const INT *bandStartOffset
);
INT FDKaacEnc_FreqToBandWidthRounding(const INT freq, const INT fs,
const INT numOfBands,
const INT *bandStartOffset);
#endif /* _TNS_H */
#endif /* AACENC_TNS_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2015 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,71 +90,77 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder **************************
/**************************** AAC encoder library ******************************
Initial author: M. Werner
contents/description: Threshold compensation
Author(s): M. Werner
******************************************************************************/
Description: Threshold compensation
#ifndef __ADJ_THR_H
#define __ADJ_THR_H
*******************************************************************************/
#ifndef ADJ_THR_H
#define ADJ_THR_H
#include "common_fix.h"
#include "adj_thr_data.h"
#include "qc_data.h"
#include "line_pe.h"
#include "interface.h"
/*****************************************************************************
functionname: FDKaacEnc_peCalculation
description:
*****************************************************************************/
void FDKaacEnc_peCalculation(PE_DATA *const peData,
const PSY_OUT_CHANNEL *const psyOutChannel[(2)],
QC_OUT_CHANNEL *const qcOutChannel[(2)],
const struct TOOLSINFO *const toolsInfo,
ATS_ELEMENT *const adjThrStateElement,
const INT nChannels);
void FDKaacEnc_peCalculation(
PE_DATA *peData,
PSY_OUT_CHANNEL* psyOutChannel[(2)],
QC_OUT_CHANNEL* qcOutChannel[(2)],
struct TOOLSINFO *toolsInfo,
ATS_ELEMENT* adjThrStateElement,
const INT nChannels
);
/*****************************************************************************
functionname: FDKaacEnc_AdjThrNew
description: allocate ADJ_THR_STATE
*****************************************************************************/
INT FDKaacEnc_AdjThrNew(ADJ_THR_STATE **phAdjThr, INT nElements);
INT FDKaacEnc_AdjThrNew(ADJ_THR_STATE** phAdjThr,
INT nElements);
/*****************************************************************************
functionname: FDKaacEnc_AdjThrInit
description: initialize ADJ_THR_STATE
*****************************************************************************/
void FDKaacEnc_AdjThrInit(
ADJ_THR_STATE *const hAdjThr, const INT meanPe, const INT invQuant,
const CHANNEL_MAPPING *const channelMapping, const INT sampleRate,
const INT totalBitrate, const INT isLowDelay,
const AACENC_BITRES_MODE bitResMode, const INT dZoneQuantEnable,
const INT bitDistributionMode, const FIXP_DBL vbrQualFactor);
void FDKaacEnc_AdjThrInit(ADJ_THR_STATE *hAdjThr,
const INT peMean,
ELEMENT_BITS* elBits[(8)],
INT invQuant,
INT nElements,
INT nChannelsEff,
INT sampleRate,
INT advancedBitsToPe,
FIXP_DBL vbrQualFactor,
const INT dZoneQuantEnable);
/*****************************************************************************
functionname: FDKaacEnc_DistributeBits
description:
*****************************************************************************/
void FDKaacEnc_DistributeBits(
ADJ_THR_STATE *adjThrState, ATS_ELEMENT *AdjThrStateElement,
PSY_OUT_CHANNEL *psyOutChannel[(2)], PE_DATA *peData, INT *grantedPe,
INT *grantedPeCorr, const INT nChannels, const INT commonWindow,
const INT avgBits, const INT bitresBits, const INT maxBitresBits,
const FIXP_DBL maxBitFac, const AACENC_BITRES_MODE bitResMode);
void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState,
ATS_ELEMENT *AdjThrStateElement,
PSY_OUT_CHANNEL *psyOutChannel[(2)],
PE_DATA *peData,
INT *grantedPe,
INT *grantedPeCorr,
const INT nChannels,
const INT commonWindow,
const INT avgBits,
const INT bitresBits,
const INT maxBitresBits,
const FIXP_DBL maxBitFac,
const INT bitDistributionMode);
/*****************************************************************************
functionname: FDKaacEnc_AdjustThresholds
description: adjust thresholds
*****************************************************************************/
void FDKaacEnc_AdjustThresholds(
ADJ_THR_STATE *const hAdjThr, QC_OUT_ELEMENT *const qcElement[((8))],
QC_OUT *const qcOut, const PSY_OUT_ELEMENT *const psyOutElement[((8))],
const INT CBRbitrateMode, const CHANNEL_MAPPING *const cm);
void FDKaacEnc_AdjustThresholds(ATS_ELEMENT* AdjThrStateElement[(8)],
QC_OUT_ELEMENT* qcElement[(8)],
QC_OUT* qcOut,
PSY_OUT_ELEMENT* psyOutElement[(8)],
INT CBRbitrateMode,
INT maxIter2ndGuess,
CHANNEL_MAPPING* cm);
void FDKaacEnc_AdjThrClose(ADJ_THR_STATE** hAdjThr);
/*****************************************************************************
functionname: FDKaacEnc_AdjThrClose
description:
*****************************************************************************/
void FDKaacEnc_AdjThrClose(ADJ_THR_STATE **hAdjThr);
#endif

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2015 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,31 +90,42 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/************************* Fast MPEG AAC Audio Encoder **********************
/**************************** AAC encoder library ******************************
Initial author: M. Schug / A. Groeschel
contents/description: threshold calculations
Author(s): M. Schug / A. Groeschel
******************************************************************************/
Description: threshold calculations
#ifndef __ADJ_THR_DATA_H
#define __ADJ_THR_DATA_H
*******************************************************************************/
#ifndef ADJ_THR_DATA_H
#define ADJ_THR_DATA_H
#include "psy_const.h"
typedef enum {
AACENC_BD_MODE_INTER_ELEMENT = 0,
AACENC_BD_MODE_INTRA_ELEMENT = 1
} AACENC_BIT_DISTRIBUTION_MODE;
typedef enum {
AACENC_BR_MODE_FULL = 0,
AACENC_BR_MODE_REDUCED = 1,
AACENC_BR_MODE_DISABLED = 2
} AACENC_BITRES_MODE;
typedef struct {
FIXP_DBL clipSaveLow, clipSaveHigh;
FIXP_DBL minBitSave, maxBitSave;
FIXP_DBL clipSpendLow, clipSpendHigh;
FIXP_DBL minBitSpend, maxBitSpend;
FIXP_DBL clipSaveLow, clipSaveHigh;
FIXP_DBL minBitSave, maxBitSave;
FIXP_DBL clipSpendLow, clipSpendHigh;
FIXP_DBL minBitSpend, maxBitSpend;
} BRES_PARAM;
typedef struct {
INT modifyMinSnr;
INT startSfbL, startSfbS;
INT modifyMinSnr;
INT startSfbL, startSfbS;
} AH_PARAM;
typedef struct {
@ -118,19 +140,20 @@ typedef struct {
/* parameters for bitreservoir control */
INT peMin, peMax;
/* constant offset to pe */
INT peOffset;
INT peOffset;
/* constant PeFactor */
FIXP_DBL bits2PeFactor_m;
INT bits2PeFactor_e;
INT bits2PeFactor_e;
/* avoid hole parameters */
AH_PARAM ahParam;
/* values for correction of pe */
/* paramters for adaptation of minSnr */
/* parameters for adaptation of minSnr */
MINSNR_ADAPT_PARAM minSnrAdaptParam;
/* values for correction of pe */
INT peLast;
INT dynBitsLast;
FIXP_DBL peCorrectionFactor_m;
INT peCorrectionFactor_e;
INT peCorrectionFactor_e;
/* vbr encoding */
FIXP_DBL vbrQualFactor;
@ -138,13 +161,14 @@ typedef struct {
/* threshold weighting */
FIXP_DBL chaosMeasureEnFac[(2)];
INT lastEnFacPatch[(2)];
INT lastEnFacPatch[(2)];
} ATS_ELEMENT;
typedef struct {
BRES_PARAM bresParamLong, bresParamShort;
ATS_ELEMENT* adjThrStateElem[(8)];
ATS_ELEMENT* adjThrStateElem[((8))];
AACENC_BIT_DISTRIBUTION_MODE bitDistributionMode;
INT maxIter2ndGuess;
} ADJ_THR_STATE;

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,41 +90,44 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Encoder **************************
/**************************** AAC encoder library ******************************
Initial author: M. Werner
contents/description: Band/Line energy calculations
Author(s): M. Werner
******************************************************************************/
Description: Band/Line energy calculations
*******************************************************************************/
#include "band_nrg.h"
/*****************************************************************************
functionname: FDKaacEnc_CalcSfbMaxScaleSpec
description:
input:
output:
*****************************************************************************/
void
FDKaacEnc_CalcSfbMaxScaleSpec(const FIXP_DBL *RESTRICT mdctSpectrum,
const INT *RESTRICT bandOffset,
INT *RESTRICT sfbMaxScaleSpec,
const INT numBands)
{
INT i,j;
void FDKaacEnc_CalcSfbMaxScaleSpec(const FIXP_DBL *RESTRICT mdctSpectrum,
const INT *RESTRICT bandOffset,
INT *RESTRICT sfbMaxScaleSpec,
const INT numBands) {
INT i, j;
FIXP_DBL maxSpc, tmp;
for(i=0; i<numBands; i++) {
for (i = 0; i < numBands; i++) {
maxSpc = (FIXP_DBL)0;
for (j=bandOffset[i]; j<bandOffset[i+1]; j++) {
DWORD_ALIGNED(mdctSpectrum);
for (j = bandOffset[i]; j < bandOffset[i + 1]; j++) {
tmp = fixp_abs(mdctSpectrum[j]);
maxSpc = fixMax(maxSpc, tmp);
}
sfbMaxScaleSpec[i] = (maxSpc==(FIXP_DBL)0) ? (DFRACT_BITS-2) : CntLeadingZeros(maxSpc)-1;
/* CountLeadingBits() is not necessary here since test value is always > 0 */
j = CntLeadingZeros(maxSpc) - 1;
sfbMaxScaleSpec[i] = fixMin((DFRACT_BITS - 2), j);
/* CountLeadingBits() is not necessary here since test value is always > 0
*/
}
}
@ -124,43 +138,45 @@ FDKaacEnc_CalcSfbMaxScaleSpec(const FIXP_DBL *RESTRICT mdctSpectrum,
output:
*****************************************************************************/
FIXP_DBL
FDKaacEnc_CheckBandEnergyOptim(const FIXP_DBL *RESTRICT mdctSpectrum,
INT *RESTRICT sfbMaxScaleSpec,
const INT *RESTRICT bandOffset,
const INT numBands,
FIXP_DBL *RESTRICT bandEnergy,
FIXP_DBL *RESTRICT bandEnergyLdData,
INT minSpecShift)
{
FDKaacEnc_CheckBandEnergyOptim(const FIXP_DBL *const RESTRICT mdctSpectrum,
const INT *const RESTRICT sfbMaxScaleSpec,
const INT *const RESTRICT bandOffset,
const INT numBands,
FIXP_DBL *RESTRICT bandEnergy,
FIXP_DBL *RESTRICT bandEnergyLdData,
const INT minSpecShift) {
INT i, j, scale, nr = 0;
FIXP_DBL maxNrgLd = FL2FXCONST_DBL(-1.0f);
FIXP_DBL maxNrg = 0;
FIXP_DBL spec;
for(i=0; i<numBands; i++) {
scale = fixMax(0, sfbMaxScaleSpec[i]-4);
for (i = 0; i < numBands; i++) {
scale = fixMax(0, sfbMaxScaleSpec[i] - 4);
FIXP_DBL tmp = 0;
for (j=bandOffset[i]; j<bandOffset[i+1]; j++){
spec = mdctSpectrum[j]<<scale;
tmp = fPow2AddDiv2(tmp, spec);
DWORD_ALIGNED(mdctSpectrum);
for (j = bandOffset[i]; j < bandOffset[i + 1]; j++) {
spec = mdctSpectrum[j] << scale;
tmp = fPow2AddDiv2(tmp, spec);
}
bandEnergy[i] = tmp<<1;
bandEnergy[i] = tmp << 1;
/* calculate ld of bandNrg, subtract scaling */
bandEnergyLdData[i] = CalcLdData(bandEnergy[i]);
if (bandEnergyLdData[i] != FL2FXCONST_DBL(-1.0f)) {
bandEnergyLdData[i] -= scale*FL2FXCONST_DBL(2.0/64);
bandEnergyLdData[i] -= scale * FL2FXCONST_DBL(2.0 / 64);
}
/* find index of maxNrg */
if (bandEnergyLdData[i] > maxNrgLd) {
maxNrgLd = bandEnergyLdData[i];
nr = i;
maxNrgLd = bandEnergyLdData[i];
nr = i;
}
}
/* return unscaled maxNrg*/
scale = fixMax(0,sfbMaxScaleSpec[nr]-4);
scale = fixMax(2*(minSpecShift-scale),-(DFRACT_BITS-1));
scale = fixMax(0, sfbMaxScaleSpec[nr] - 4);
scale = fixMax(2 * (minSpecShift - scale), -(DFRACT_BITS - 1));
maxNrg = scaleValue(bandEnergy[nr], scale);
@ -173,187 +189,173 @@ FDKaacEnc_CheckBandEnergyOptim(const FIXP_DBL *RESTRICT mdctSpectrum,
input:
output:
*****************************************************************************/
INT
FDKaacEnc_CalcBandEnergyOptimLong(const FIXP_DBL *RESTRICT mdctSpectrum,
INT *RESTRICT sfbMaxScaleSpec,
const INT *RESTRICT bandOffset,
const INT numBands,
FIXP_DBL *RESTRICT bandEnergy,
FIXP_DBL *RESTRICT bandEnergyLdData)
{
INT FDKaacEnc_CalcBandEnergyOptimLong(const FIXP_DBL *RESTRICT mdctSpectrum,
INT *RESTRICT sfbMaxScaleSpec,
const INT *RESTRICT bandOffset,
const INT numBands,
FIXP_DBL *RESTRICT bandEnergy,
FIXP_DBL *RESTRICT bandEnergyLdData) {
INT i, j, shiftBits = 0;
FIXP_DBL maxNrgLd = FL2FXCONST_DBL(0.0f);
FIXP_DBL spec;
for(i=0; i<numBands; i++) {
INT leadingBits = sfbMaxScaleSpec[i]-4; /* max sfbWidth = 96 ; 2^7=128 => 7/2 = 4 (spc*spc) */
FIXP_DBL tmp = FL2FXCONST_DBL(0.0);
/* don't use scaleValue() here, it increases workload quite sufficiently... */
if (leadingBits>=0) {
for (j=bandOffset[i];j<bandOffset[i+1];j++) {
spec = mdctSpectrum[j]<<leadingBits;
tmp = fPow2AddDiv2(tmp, spec);
}
} else {
INT shift = -leadingBits;
for (j=bandOffset[i];j<bandOffset[i+1];j++){
spec = mdctSpectrum[j]>>shift;
tmp = fPow2AddDiv2(tmp, spec);
}
}
bandEnergy[i] = tmp<<1;
for (i = 0; i < numBands; i++) {
INT leadingBits = sfbMaxScaleSpec[i] -
4; /* max sfbWidth = 96 ; 2^7=128 => 7/2 = 4 (spc*spc) */
FIXP_DBL tmp = FL2FXCONST_DBL(0.0);
/* don't use scaleValue() here, it increases workload quite sufficiently...
*/
if (leadingBits >= 0) {
for (j = bandOffset[i]; j < bandOffset[i + 1]; j++) {
spec = mdctSpectrum[j] << leadingBits;
tmp = fPow2AddDiv2(tmp, spec);
}
} else {
INT shift = -leadingBits;
for (j = bandOffset[i]; j < bandOffset[i + 1]; j++) {
spec = mdctSpectrum[j] >> shift;
tmp = fPow2AddDiv2(tmp, spec);
}
}
bandEnergy[i] = tmp << 1;
}
/* calculate ld of bandNrg, subtract scaling */
LdDataVector(bandEnergy, bandEnergyLdData, numBands);
for(i=numBands; i--!=0; ) {
FIXP_DBL scaleDiff = (sfbMaxScaleSpec[i]-4)*FL2FXCONST_DBL(2.0/64);
for (i = numBands; i-- != 0;) {
FIXP_DBL scaleDiff = (sfbMaxScaleSpec[i] - 4) * FL2FXCONST_DBL(2.0 / 64);
bandEnergyLdData[i] = (bandEnergyLdData[i] >= ((FL2FXCONST_DBL(-1.f)>>1) + (scaleDiff>>1)))
? bandEnergyLdData[i]-scaleDiff : FL2FXCONST_DBL(-1.f);
/* find maxNrgLd */
maxNrgLd = fixMax(maxNrgLd, bandEnergyLdData[i]);
bandEnergyLdData[i] = (bandEnergyLdData[i] >=
((FL2FXCONST_DBL(-1.f) >> 1) + (scaleDiff >> 1)))
? bandEnergyLdData[i] - scaleDiff
: FL2FXCONST_DBL(-1.f);
/* find maxNrgLd */
maxNrgLd = fixMax(maxNrgLd, bandEnergyLdData[i]);
}
if (maxNrgLd<=(FIXP_DBL)0)
{
for(i=numBands; i--!=0; )
{
INT scale = fixMin((sfbMaxScaleSpec[i]-4)<<1,(DFRACT_BITS-1));
bandEnergy[i] = scaleValue(bandEnergy[i], -scale);
}
return 0;
}
else
{ /* scale down NRGs */
while (maxNrgLd>FL2FXCONST_DBL(0.0f))
{
maxNrgLd -= FL2FXCONST_DBL(2.0/64);
shiftBits++;
}
for(i=numBands; i--!=0; )
{
INT scale = fixMin( ((sfbMaxScaleSpec[i]-4)+shiftBits)<<1, (DFRACT_BITS-1));
bandEnergyLdData[i] -= shiftBits*FL2FXCONST_DBL(2.0/64);
bandEnergy[i] = scaleValue(bandEnergy[i], -scale);
}
return shiftBits;
if (maxNrgLd <= (FIXP_DBL)0) {
for (i = numBands; i-- != 0;) {
INT scale = fixMin((sfbMaxScaleSpec[i] - 4) << 1, (DFRACT_BITS - 1));
bandEnergy[i] = scaleValue(bandEnergy[i], -scale);
}
return 0;
} else { /* scale down NRGs */
while (maxNrgLd > FL2FXCONST_DBL(0.0f)) {
maxNrgLd -= FL2FXCONST_DBL(2.0 / 64);
shiftBits++;
}
for (i = numBands; i-- != 0;) {
INT scale = fixMin(((sfbMaxScaleSpec[i] - 4) + shiftBits) << 1,
(DFRACT_BITS - 1));
bandEnergyLdData[i] -= shiftBits * FL2FXCONST_DBL(2.0 / 64);
bandEnergy[i] = scaleValue(bandEnergy[i], -scale);
}
return shiftBits;
}
}
/*****************************************************************************
functionname: FDKaacEnc_CalcBandEnergyOptimShort
description:
input:
output:
*****************************************************************************/
void
FDKaacEnc_CalcBandEnergyOptimShort(const FIXP_DBL *RESTRICT mdctSpectrum,
INT *RESTRICT sfbMaxScaleSpec,
const INT *RESTRICT bandOffset,
const INT numBands,
FIXP_DBL *RESTRICT bandEnergy)
{
void FDKaacEnc_CalcBandEnergyOptimShort(const FIXP_DBL *RESTRICT mdctSpectrum,
INT *RESTRICT sfbMaxScaleSpec,
const INT *RESTRICT bandOffset,
const INT numBands,
FIXP_DBL *RESTRICT bandEnergy) {
INT i, j;
for(i=0; i<numBands; i++)
{
int leadingBits = sfbMaxScaleSpec[i]-3; /* max sfbWidth = 36 ; 2^6=64 => 6/2 = 3 (spc*spc) */
for (i = 0; i < numBands; i++) {
int leadingBits = sfbMaxScaleSpec[i] -
3; /* max sfbWidth = 36 ; 2^6=64 => 6/2 = 3 (spc*spc) */
FIXP_DBL tmp = FL2FXCONST_DBL(0.0);
for (j=bandOffset[i];j<bandOffset[i+1];j++)
{
FIXP_DBL spec = scaleValue(mdctSpectrum[j],leadingBits);
tmp = fPow2AddDiv2(tmp, spec);
for (j = bandOffset[i]; j < bandOffset[i + 1]; j++) {
FIXP_DBL spec = scaleValue(mdctSpectrum[j], leadingBits);
tmp = fPow2AddDiv2(tmp, spec);
}
bandEnergy[i] = tmp;
}
for(i=0; i<numBands; i++)
{
INT scale = (2*(sfbMaxScaleSpec[i]-3))-1; /* max sfbWidth = 36 ; 2^6=64 => 6/2 = 3 (spc*spc) */
scale = fixMax(fixMin(scale,(DFRACT_BITS-1)),-(DFRACT_BITS-1));
bandEnergy[i] = scaleValueSaturate(bandEnergy[i], -scale);
for (i = 0; i < numBands; i++) {
INT scale = (2 * (sfbMaxScaleSpec[i] - 3)) -
1; /* max sfbWidth = 36 ; 2^6=64 => 6/2 = 3 (spc*spc) */
scale = fixMax(fixMin(scale, (DFRACT_BITS - 1)), -(DFRACT_BITS - 1));
bandEnergy[i] = scaleValueSaturate(bandEnergy[i], -scale);
}
}
/*****************************************************************************
functionname: FDKaacEnc_CalcBandNrgMSOpt
description:
input:
output:
*****************************************************************************/
void FDKaacEnc_CalcBandNrgMSOpt(const FIXP_DBL *RESTRICT mdctSpectrumLeft,
const FIXP_DBL *RESTRICT mdctSpectrumRight,
INT *RESTRICT sfbMaxScaleSpecLeft,
INT *RESTRICT sfbMaxScaleSpecRight,
const INT *RESTRICT bandOffset,
const INT numBands,
FIXP_DBL *RESTRICT bandEnergyMid,
FIXP_DBL *RESTRICT bandEnergySide,
INT calcLdData,
FIXP_DBL *RESTRICT bandEnergyMidLdData,
FIXP_DBL *RESTRICT bandEnergySideLdData)
{
void FDKaacEnc_CalcBandNrgMSOpt(
const FIXP_DBL *RESTRICT mdctSpectrumLeft,
const FIXP_DBL *RESTRICT mdctSpectrumRight,
INT *RESTRICT sfbMaxScaleSpecLeft, INT *RESTRICT sfbMaxScaleSpecRight,
const INT *RESTRICT bandOffset, const INT numBands,
FIXP_DBL *RESTRICT bandEnergyMid, FIXP_DBL *RESTRICT bandEnergySide,
INT calcLdData, FIXP_DBL *RESTRICT bandEnergyMidLdData,
FIXP_DBL *RESTRICT bandEnergySideLdData) {
INT i, j, minScale;
FIXP_DBL NrgMid, NrgSide, specm, specs;
for (i=0; i<numBands; i++) {
for (i = 0; i < numBands; i++) {
NrgMid = NrgSide = FL2FXCONST_DBL(0.0);
minScale = fixMin(sfbMaxScaleSpecLeft[i], sfbMaxScaleSpecRight[i])-4;
minScale = fixMin(sfbMaxScaleSpecLeft[i], sfbMaxScaleSpecRight[i]) - 4;
minScale = fixMax(0, minScale);
if (minScale > 0) {
for (j=bandOffset[i];j<bandOffset[i+1];j++) {
FIXP_DBL specL = mdctSpectrumLeft[j]<<(minScale-1);
FIXP_DBL specR = mdctSpectrumRight[j]<<(minScale-1);
specm = specL + specR;
specs = specL - specR;
NrgMid = fPow2AddDiv2(NrgMid, specm);
NrgSide = fPow2AddDiv2(NrgSide, specs);
for (j = bandOffset[i]; j < bandOffset[i + 1]; j++) {
FIXP_DBL specL = mdctSpectrumLeft[j] << (minScale - 1);
FIXP_DBL specR = mdctSpectrumRight[j] << (minScale - 1);
specm = specL + specR;
specs = specL - specR;
NrgMid = fPow2AddDiv2(NrgMid, specm);
NrgSide = fPow2AddDiv2(NrgSide, specs);
}
} else {
for (j=bandOffset[i];j<bandOffset[i+1];j++) {
FIXP_DBL specL = mdctSpectrumLeft[j]>>1;
FIXP_DBL specR = mdctSpectrumRight[j]>>1;
specm = specL + specR;
specs = specL - specR;
NrgMid = fPow2AddDiv2(NrgMid, specm);
NrgSide = fPow2AddDiv2(NrgSide, specs);
for (j = bandOffset[i]; j < bandOffset[i + 1]; j++) {
FIXP_DBL specL = mdctSpectrumLeft[j] >> 1;
FIXP_DBL specR = mdctSpectrumRight[j] >> 1;
specm = specL + specR;
specs = specL - specR;
NrgMid = fPow2AddDiv2(NrgMid, specm);
NrgSide = fPow2AddDiv2(NrgSide, specs);
}
}
bandEnergyMid[i] = NrgMid<<1;
bandEnergySide[i] = NrgSide<<1;
bandEnergyMid[i] = fMin(NrgMid, (FIXP_DBL)MAXVAL_DBL >> 1) << 1;
bandEnergySide[i] = fMin(NrgSide, (FIXP_DBL)MAXVAL_DBL >> 1) << 1;
}
if(calcLdData) {
if (calcLdData) {
LdDataVector(bandEnergyMid, bandEnergyMidLdData, numBands);
LdDataVector(bandEnergySide, bandEnergySideLdData, numBands);
}
for (i=0; i<numBands; i++)
{
INT minScale = fixMin(sfbMaxScaleSpecLeft[i], sfbMaxScaleSpecRight[i]);
INT scale = fixMax(0, 2*(minScale-4));
for (i = 0; i < numBands; i++) {
minScale = fixMin(sfbMaxScaleSpecLeft[i], sfbMaxScaleSpecRight[i]);
INT scale = fixMax(0, 2 * (minScale - 4));
if (calcLdData)
{
/* using the minimal scaling of left and right channel can cause very small energies;
check ldNrg before subtract scaling multiplication: fract*INT we don't need fMult */
if (calcLdData) {
/* using the minimal scaling of left and right channel can cause very
small energies; check ldNrg before subtract scaling multiplication:
fract*INT we don't need fMult */
int minus = scale*FL2FXCONST_DBL(1.0/64);
int minus = scale * FL2FXCONST_DBL(1.0 / 64);
if (bandEnergyMidLdData[i] != FL2FXCONST_DBL(-1.0f))
bandEnergyMidLdData[i] -= minus;
if (bandEnergyMidLdData[i] != FL2FXCONST_DBL(-1.0f))
bandEnergyMidLdData[i] -= minus;
if (bandEnergySideLdData[i] != FL2FXCONST_DBL(-1.0f))
bandEnergySideLdData[i] -= minus;
if (bandEnergySideLdData[i] != FL2FXCONST_DBL(-1.0f))
bandEnergySideLdData[i] -= minus;
}
scale = fixMin(scale, (DFRACT_BITS-1));
bandEnergyMid[i] >>= scale;
scale = fixMin(scale, (DFRACT_BITS - 1));
bandEnergyMid[i] >>= scale;
bandEnergySide[i] >>= scale;
}
}

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,71 +90,53 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder **************************
/**************************** AAC encoder library ******************************
Author(s): M. Werner
Description: Band/Line energy calculation
******************************************************************************/
*******************************************************************************/
#ifndef _BAND_NRG_H
#define _BAND_NRG_H
#ifndef BAND_NRG_H
#define BAND_NRG_H
#include "common_fix.h"
void
FDKaacEnc_CalcSfbMaxScaleSpec(
const FIXP_DBL *mdctSpectrum,
const INT *bandOffset,
INT *sfbMaxScaleSpec,
const INT numBands
);
void FDKaacEnc_CalcSfbMaxScaleSpec(const FIXP_DBL *mdctSpectrum,
const INT *bandOffset, INT *sfbMaxScaleSpec,
const INT numBands);
FIXP_DBL
FDKaacEnc_CheckBandEnergyOptim(
const FIXP_DBL *mdctSpectrum,
INT *sfbMaxScaleSpec,
const INT *bandOffset,
const INT numBands,
FIXP_DBL *bandEnergy,
FIXP_DBL *bandEnergyLdData,
INT minSpecShift
);
FDKaacEnc_CheckBandEnergyOptim(const FIXP_DBL *const RESTRICT mdctSpectrum,
const INT *const RESTRICT sfbMaxScaleSpec,
const INT *const RESTRICT bandOffset,
const INT numBands,
FIXP_DBL *RESTRICT bandEnergy,
FIXP_DBL *RESTRICT bandEnergyLdData,
const INT minSpecShift);
INT
FDKaacEnc_CalcBandEnergyOptimLong(
const FIXP_DBL *mdctSpectrum,
INT *sfbMaxScaleSpec,
const INT *bandOffset,
const INT numBands,
FIXP_DBL *bandEnergy,
FIXP_DBL *bandEnergyLdData
);
void
FDKaacEnc_CalcBandEnergyOptimShort(
const FIXP_DBL *mdctSpectrum,
INT *sfbMaxScaleSpec,
const INT *bandOffset,
const INT numBands,
FIXP_DBL *bandEnergy
);
INT FDKaacEnc_CalcBandEnergyOptimLong(const FIXP_DBL *mdctSpectrum,
INT *sfbMaxScaleSpec,
const INT *bandOffset, const INT numBands,
FIXP_DBL *bandEnergy,
FIXP_DBL *bandEnergyLdData);
void FDKaacEnc_CalcBandEnergyOptimShort(const FIXP_DBL *mdctSpectrum,
INT *sfbMaxScaleSpec,
const INT *bandOffset,
const INT numBands,
FIXP_DBL *bandEnergy);
void FDKaacEnc_CalcBandNrgMSOpt(
const FIXP_DBL *RESTRICT mdctSpectrumLeft,
const FIXP_DBL *RESTRICT mdctSpectrumRight,
INT *RESTRICT sfbMaxScaleSpecLeft,
INT *RESTRICT sfbMaxScaleSpecRight,
const INT *RESTRICT bandOffset,
const INT numBands,
FIXP_DBL *RESTRICT bandEnergyMid,
FIXP_DBL *RESTRICT bandEnergySide,
INT calcLdData,
FIXP_DBL *RESTRICT bandEnergyMidLdData,
FIXP_DBL *RESTRICT bandEnergySideLdData);
const FIXP_DBL *RESTRICT mdctSpectrumLeft,
const FIXP_DBL *RESTRICT mdctSpectrumRight,
INT *RESTRICT sfbMaxScaleSpecLeft, INT *RESTRICT sfbMaxScaleSpecRight,
const INT *RESTRICT bandOffset, const INT numBands,
FIXP_DBL *RESTRICT bandEnergyMid, FIXP_DBL *RESTRICT bandEnergySide,
INT calcLdData, FIXP_DBL *RESTRICT bandEnergyMidLdData,
FIXP_DBL *RESTRICT bandEnergySideLdData);
#endif

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2015 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,20 +90,21 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/************************* Fast MPEG AAC Audio Encoder **********************
/**************************** AAC encoder library ******************************
Initial author: M. Schug / A. Groeschel
contents/description: bandwidth expert
Author(s): M. Schug / A. Groeschel
******************************************************************************/
Description: bandwidth expert
*******************************************************************************/
#include "channel_map.h"
#include "bandwidth.h"
#include "aacEnc_ram.h"
typedef struct{
typedef struct {
INT chanBitRate;
INT bandWidthMono;
INT bandWidth2AndMoreChan;
@ -100,114 +112,71 @@ typedef struct{
} BANDWIDTH_TAB;
static const BANDWIDTH_TAB bandWidthTable[] = {
{0, 3700, 5000},
{12000, 5000, 6400},
{20000, 6900, 9640},
{28000, 9600, 13050},
{40000, 12060, 14260},
{56000, 13950, 15500},
{72000, 14200, 16120},
{96000, 17000, 17000},
{576001,17000, 17000}
};
{0, 3700, 5000}, {12000, 5000, 6400}, {20000, 6900, 9640},
{28000, 9600, 13050}, {40000, 12060, 14260}, {56000, 13950, 15500},
{72000, 14200, 16120}, {96000, 17000, 17000}, {576001, 17000, 17000}};
static const BANDWIDTH_TAB bandWidthTable_LD_22050[] = {
{ 8000, 2000, 2400},
{12000, 2500, 2700},
{16000, 3300, 3100},
{24000, 6250, 7200},
{32000, 9200, 10500},
{40000, 16000, 16000},
{48000, 16000, 16000},
{360001, 16000, 16000}
};
{8000, 2000, 2400}, {12000, 2500, 2700}, {16000, 3300, 3100},
{24000, 6250, 7200}, {32000, 9200, 10500}, {40000, 16000, 16000},
{48000, 16000, 16000}, {282241, 16000, 16000}};
static const BANDWIDTH_TAB bandWidthTable_LD_24000[] = {
{ 8000, 2000, 2000},
{12000, 2000, 2300},
{16000, 2200, 2500},
{24000, 5650, 7200},
{32000, 11600, 12000},
{40000, 12000, 16000},
{48000, 16000, 16000},
{64000, 16000, 16000},
{360001, 16000, 16000}
};
{8000, 2000, 2000}, {12000, 2000, 2300}, {16000, 2200, 2500},
{24000, 5650, 7200}, {32000, 11600, 12000}, {40000, 12000, 16000},
{48000, 16000, 16000}, {64000, 16000, 16000}, {307201, 16000, 16000}};
static const BANDWIDTH_TAB bandWidthTable_LD_32000[] = {
{ 8000, 2000, 2000},
{12000, 2000, 2000},
{24000, 4250, 7200},
{32000, 8400, 9000},
{40000, 9400, 11300},
{48000, 11900, 14700},
{64000, 14800, 16000},
{76000, 16000, 16000},
{360001, 16000, 16000}
};
{8000, 2000, 2000}, {12000, 2000, 2000}, {24000, 4250, 7200},
{32000, 8400, 9000}, {40000, 9400, 11300}, {48000, 11900, 14700},
{64000, 14800, 16000}, {76000, 16000, 16000}, {409601, 16000, 16000}};
static const BANDWIDTH_TAB bandWidthTable_LD_44100[] = {
{ 8000, 2000, 2000},
{24000, 2000, 2000},
{32000, 4400, 5700},
{40000, 7400, 8800},
{48000, 9000, 10700},
{56000, 11000, 12900},
{64000, 14400, 15500},
{80000, 16000, 16200},
{96000, 16500, 16000},
{128000, 16000, 16000},
{360001, 16000, 16000}
};
{8000, 2000, 2000}, {24000, 2000, 2000}, {32000, 4400, 5700},
{40000, 7400, 8800}, {48000, 9000, 10700}, {56000, 11000, 12900},
{64000, 14400, 15500}, {80000, 16000, 16200}, {96000, 16500, 16000},
{128000, 16000, 16000}, {564481, 16000, 16000}};
static const BANDWIDTH_TAB bandWidthTable_LD_48000[] = {
{ 8000, 2000, 2000},
{24000, 2000, 2000},
{32000, 4400, 5700},
{40000, 7400, 8800},
{48000, 9000, 10700},
{56000, 11000, 12800},
{64000, 14300, 15400},
{80000, 16000, 16200},
{96000, 16500, 16000},
{128000, 16000, 16000},
{360001, 16000, 16000}
};
{8000, 2000, 2000}, {24000, 2000, 2000}, {32000, 4400, 5700},
{40000, 7400, 8800}, {48000, 9000, 10700}, {56000, 11000, 12800},
{64000, 14300, 15400}, {80000, 16000, 16200}, {96000, 16500, 16000},
{128000, 16000, 16000}, {614401, 16000, 16000}};
typedef struct{
typedef struct {
AACENC_BITRATE_MODE bitrateMode;
int bandWidthMono;
int bandWidth2AndMoreChan;
} BANDWIDTH_TAB_VBR;
static const BANDWIDTH_TAB_VBR bandWidthTableVBR[]= {
{AACENC_BR_MODE_CBR, 0, 0},
{AACENC_BR_MODE_VBR_1, 13050, 13050},
{AACENC_BR_MODE_VBR_2, 13050, 13050},
{AACENC_BR_MODE_VBR_3, 14260, 14260},
{AACENC_BR_MODE_VBR_4, 15500, 15500},
{AACENC_BR_MODE_VBR_5, 48000, 48000},
{AACENC_BR_MODE_SFR, 0, 0},
{AACENC_BR_MODE_FF, 0, 0}
static const BANDWIDTH_TAB_VBR bandWidthTableVBR[] = {
{AACENC_BR_MODE_CBR, 0, 0},
{AACENC_BR_MODE_VBR_1, 13050, 13050},
{AACENC_BR_MODE_VBR_2, 13050, 13050},
{AACENC_BR_MODE_VBR_3, 14260, 14260},
{AACENC_BR_MODE_VBR_4, 15500, 15500},
{AACENC_BR_MODE_VBR_5, 48000, 48000},
{AACENC_BR_MODE_SFR, 0, 0},
{AACENC_BR_MODE_FF, 0, 0}
};
static INT GetBandwidthEntry(
const INT frameLength,
const INT sampleRate,
const INT chanBitRate,
const INT entryNo)
{
static INT GetBandwidthEntry(const INT frameLength, const INT sampleRate,
const INT chanBitRate, const INT entryNo) {
INT bandwidth = -1;
const BANDWIDTH_TAB *pBwTab = NULL;
INT bwTabSize = 0;
switch (frameLength) {
case 960:
case 1024:
pBwTab = bandWidthTable;
bwTabSize = sizeof(bandWidthTable)/sizeof(BANDWIDTH_TAB);
bwTabSize = sizeof(bandWidthTable) / sizeof(BANDWIDTH_TAB);
break;
case 120:
case 128:
case 240:
case 256:
case 480:
case 512:
switch (sampleRate) {
@ -217,26 +186,26 @@ static INT GetBandwidthEntry(
case 16000:
case 22050:
pBwTab = bandWidthTable_LD_22050;
bwTabSize = sizeof(bandWidthTable_LD_22050)/sizeof(BANDWIDTH_TAB);
bwTabSize = sizeof(bandWidthTable_LD_22050) / sizeof(BANDWIDTH_TAB);
break;
case 24000:
pBwTab = bandWidthTable_LD_24000;
bwTabSize = sizeof(bandWidthTable_LD_24000)/sizeof(BANDWIDTH_TAB);
bwTabSize = sizeof(bandWidthTable_LD_24000) / sizeof(BANDWIDTH_TAB);
break;
case 32000:
pBwTab = bandWidthTable_LD_32000;
bwTabSize = sizeof(bandWidthTable_LD_32000)/sizeof(BANDWIDTH_TAB);
bwTabSize = sizeof(bandWidthTable_LD_32000) / sizeof(BANDWIDTH_TAB);
break;
case (44100):
case 44100:
pBwTab = bandWidthTable_LD_44100;
bwTabSize = sizeof(bandWidthTable_LD_44100)/sizeof(BANDWIDTH_TAB);
bwTabSize = sizeof(bandWidthTable_LD_44100) / sizeof(BANDWIDTH_TAB);
break;
case 48000:
case 64000:
case 88200:
case 96000:
pBwTab = bandWidthTable_LD_48000;
bwTabSize = sizeof(bandWidthTable_LD_48000)/sizeof(BANDWIDTH_TAB);
bwTabSize = sizeof(bandWidthTable_LD_48000) / sizeof(BANDWIDTH_TAB);
break;
}
break;
@ -245,31 +214,38 @@ static INT GetBandwidthEntry(
bwTabSize = 0;
}
if (pBwTab!=NULL) {
if (pBwTab != NULL) {
int i;
for (i=0; i<bwTabSize-1; i++) {
for (i = 0; i < bwTabSize - 1; i++) {
if (chanBitRate >= pBwTab[i].chanBitRate &&
chanBitRate < pBwTab[i+1].chanBitRate)
{
chanBitRate < pBwTab[i + 1].chanBitRate) {
switch (frameLength) {
case 960:
case 1024:
bandwidth = (entryNo==0)
? pBwTab[i].bandWidthMono
: pBwTab[i].bandWidth2AndMoreChan;
bandwidth = (entryNo == 0) ? pBwTab[i].bandWidthMono
: pBwTab[i].bandWidth2AndMoreChan;
break;
case 120:
case 128:
case 240:
case 256:
case 480:
case 512:
{
INT q_res = 0;
INT startBw = (entryNo==0) ? pBwTab[i ].bandWidthMono : pBwTab[i ].bandWidth2AndMoreChan;
INT endBw = (entryNo==0) ? pBwTab[i+1].bandWidthMono : pBwTab[i+1].bandWidth2AndMoreChan;
INT startBr = pBwTab[i].chanBitRate;
INT endBr = pBwTab[i+1].chanBitRate;
case 512: {
INT q_res = 0;
INT startBw = (entryNo == 0) ? pBwTab[i].bandWidthMono
: pBwTab[i].bandWidth2AndMoreChan;
INT endBw = (entryNo == 0) ? pBwTab[i + 1].bandWidthMono
: pBwTab[i + 1].bandWidth2AndMoreChan;
INT startBr = pBwTab[i].chanBitRate;
INT endBr = pBwTab[i + 1].chanBitRate;
FIXP_DBL bwFac_fix = fDivNorm(chanBitRate-startBr, endBr-startBr, &q_res);
bandwidth = (INT)scaleValue(fMult(bwFac_fix, (FIXP_DBL)(endBw-startBw)),q_res) + startBw;
}
break;
FIXP_DBL bwFac_fix =
fDivNorm(chanBitRate - startBr, endBr - startBr, &q_res);
bandwidth =
(INT)scaleValue(fMult(bwFac_fix, (FIXP_DBL)(endBw - startBw)),
q_res) +
startBw;
} break;
default:
bandwidth = -1;
}
@ -281,99 +257,104 @@ static INT GetBandwidthEntry(
return bandwidth;
}
AAC_ENCODER_ERROR FDKaacEnc_DetermineBandWidth(INT* bandWidth,
INT proposedBandWidth,
INT bitrate,
AACENC_BITRATE_MODE bitrateMode,
INT sampleRate,
INT frameLength,
CHANNEL_MAPPING* cm,
CHANNEL_MODE encoderMode)
{
AAC_ENCODER_ERROR FDKaacEnc_DetermineBandWidth(
const INT proposedBandWidth, const INT bitrate,
const AACENC_BITRATE_MODE bitrateMode, const INT sampleRate,
const INT frameLength, const CHANNEL_MAPPING *const cm,
const CHANNEL_MODE encoderMode, INT *const bandWidth) {
AAC_ENCODER_ERROR ErrorStatus = AAC_ENC_OK;
INT chanBitRate = bitrate/cm->nChannels;
INT chanBitRate = bitrate / cm->nChannelsEff;
/* vbr */
switch(bitrateMode){
case AACENC_BR_MODE_VBR_1:
case AACENC_BR_MODE_VBR_2:
case AACENC_BR_MODE_VBR_3:
case AACENC_BR_MODE_VBR_4:
case AACENC_BR_MODE_VBR_5:
if (proposedBandWidth != 0){
/* use given bw */
*bandWidth = proposedBandWidth;
} else {
/* take bw from table */
switch(encoderMode){
case MODE_1:
*bandWidth = bandWidthTableVBR[bitrateMode].bandWidthMono;
break;
case MODE_2:
case MODE_1_2:
case MODE_1_2_1:
case MODE_1_2_2:
case MODE_1_2_2_1:
case MODE_1_2_2_2_1:
case MODE_7_1_REAR_SURROUND:
case MODE_7_1_FRONT_CENTER:
*bandWidth = bandWidthTableVBR[bitrateMode].bandWidth2AndMoreChan;
break;
default:
return AAC_ENC_UNSUPPORTED_CHANNELCONFIG;
switch (bitrateMode) {
case AACENC_BR_MODE_VBR_1:
case AACENC_BR_MODE_VBR_2:
case AACENC_BR_MODE_VBR_3:
case AACENC_BR_MODE_VBR_4:
case AACENC_BR_MODE_VBR_5:
if (proposedBandWidth != 0) {
/* use given bw */
*bandWidth = proposedBandWidth;
} else {
/* take bw from table */
switch (encoderMode) {
case MODE_1:
*bandWidth = bandWidthTableVBR[bitrateMode].bandWidthMono;
break;
case MODE_2:
case MODE_1_2:
case MODE_1_2_1:
case MODE_1_2_2:
case MODE_1_2_2_1:
case MODE_6_1:
case MODE_1_2_2_2_1:
case MODE_7_1_REAR_SURROUND:
case MODE_7_1_FRONT_CENTER:
case MODE_7_1_BACK:
case MODE_7_1_TOP_FRONT:
*bandWidth = bandWidthTableVBR[bitrateMode].bandWidth2AndMoreChan;
break;
default:
return AAC_ENC_UNSUPPORTED_CHANNELCONFIG;
}
}
}
break;
case AACENC_BR_MODE_CBR:
case AACENC_BR_MODE_SFR:
case AACENC_BR_MODE_FF:
break;
case AACENC_BR_MODE_CBR:
case AACENC_BR_MODE_SFR:
case AACENC_BR_MODE_FF:
/* bandwidth limiting */
if (proposedBandWidth != 0) {
*bandWidth = FDKmin(proposedBandWidth, FDKmin(20000, sampleRate>>1));
}
else { /* search reasonable bandwidth */
/* bandwidth limiting */
if (proposedBandWidth != 0) {
*bandWidth = fMin(proposedBandWidth, fMin(20000, sampleRate >> 1));
} else { /* search reasonable bandwidth */
int entryNo = 0;
int entryNo = 0;
switch(encoderMode){
case MODE_1: /* mono */
entryNo = 0; /* use mono bandwith settings */
break;
switch (encoderMode) {
case MODE_1: /* mono */
entryNo = 0; /* use mono bandwidth settings */
break;
case MODE_2: /* stereo */
case MODE_1_2: /* sce + cpe */
case MODE_1_2_1: /* sce + cpe + sce */
case MODE_1_2_2: /* sce + cpe + cpe */
case MODE_1_2_2_1: /* (5.1) sce + cpe + cpe + lfe */
case MODE_1_2_2_2_1: /* (7.1) sce + cpe + cpe + cpe + lfe */
case MODE_7_1_REAR_SURROUND:
case MODE_7_1_FRONT_CENTER:
entryNo = 1; /* use stereo bandwith settings */
break;
case MODE_2: /* stereo */
case MODE_1_2: /* sce + cpe */
case MODE_1_2_1: /* sce + cpe + sce */
case MODE_1_2_2: /* sce + cpe + cpe */
case MODE_1_2_2_1: /* (5.1) sce + cpe + cpe + lfe */
case MODE_6_1:
case MODE_1_2_2_2_1:
case MODE_7_1_REAR_SURROUND:
case MODE_7_1_FRONT_CENTER:
case MODE_7_1_BACK:
case MODE_7_1_TOP_FRONT:
entryNo = 1; /* use stereo bandwidth settings */
break;
default:
return AAC_ENC_UNSUPPORTED_CHANNELCONFIG;
default:
return AAC_ENC_UNSUPPORTED_CHANNELCONFIG;
}
*bandWidth =
GetBandwidthEntry(frameLength, sampleRate, chanBitRate, entryNo);
if (*bandWidth == -1) {
switch (frameLength) {
case 120:
case 128:
case 240:
case 256:
*bandWidth = 16000;
break;
default:
ErrorStatus = AAC_ENC_INVALID_CHANNEL_BITRATE;
}
}
}
*bandWidth = GetBandwidthEntry(
frameLength,
sampleRate,
chanBitRate,
entryNo);
if (*bandWidth==-1) {
ErrorStatus = AAC_ENC_INVALID_CHANNEL_BITRATE;
}
}
break;
default:
*bandWidth = 0;
return AAC_ENC_UNSUPPORTED_BITRATE_MODE;
break;
default:
*bandWidth = 0;
return AAC_ENC_UNSUPPORTED_BITRATE_MODE;
}
*bandWidth = FDKmin(*bandWidth, sampleRate/2);
*bandWidth = fMin(*bandWidth, sampleRate / 2);
return ErrorStatus;;
return ErrorStatus;
}

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,28 +90,25 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/************************* Fast MPEG AAC Audio Encoder **********************
/**************************** AAC encoder library ******************************
Initial author: M. Schug / A. Groeschel
contents/description: bandwidth expert
Author(s): M. Schug / A. Groeschel
******************************************************************************/
Description: bandwidth expert
#ifndef _BANDWIDTH_H
#define _BANDWIDTH_H
*******************************************************************************/
#ifndef BANDWIDTH_H
#define BANDWIDTH_H
#include "qc_data.h"
AAC_ENCODER_ERROR FDKaacEnc_DetermineBandWidth(INT* bandWidth,
INT proposedBandwidth,
INT bitrate,
AACENC_BITRATE_MODE bitrateMode,
INT sampleRate,
INT frameLength,
CHANNEL_MAPPING* cm,
CHANNEL_MODE encoderMode);
AAC_ENCODER_ERROR FDKaacEnc_DetermineBandWidth(
const INT proposedBandWidth, const INT bitrate,
const AACENC_BITRATE_MODE bitrateMode, const INT sampleRate,
const INT frameLength, const CHANNEL_MAPPING *const cm,
const CHANNEL_MODE encoderMode, INT *const bandWidth);
#endif /* BANDWIDTH_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,46 +90,46 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder **************************
/**************************** AAC encoder library ******************************
Initial author: M.Werner
contents/description: Huffman Bitcounter & coder
Author(s): M.Werner
******************************************************************************/
Description: Huffman Bitcounter & coder
#ifndef __BITCOUNT_H
#define __BITCOUNT_H
*******************************************************************************/
#ifndef BIT_CNT_H
#define BIT_CNT_H
#include "common_fix.h"
#include "FDK_bitstream.h"
#include "aacEnc_rom.h"
#define INVALID_BITCOUNT (FDK_INT_MAX/4)
#define INVALID_BITCOUNT (FDK_INT_MAX / 4)
/*
code book number table
*/
enum codeBookNo{
CODE_BOOK_ZERO_NO= 0,
CODE_BOOK_1_NO= 1,
CODE_BOOK_2_NO= 2,
CODE_BOOK_3_NO= 3,
CODE_BOOK_4_NO= 4,
CODE_BOOK_5_NO= 5,
CODE_BOOK_6_NO= 6,
CODE_BOOK_7_NO= 7,
CODE_BOOK_8_NO= 8,
CODE_BOOK_9_NO= 9,
CODE_BOOK_10_NO= 10,
CODE_BOOK_ESC_NO= 11,
CODE_BOOK_RES_NO= 12,
CODE_BOOK_PNS_NO= 13,
CODE_BOOK_IS_OUT_OF_PHASE_NO= 14,
CODE_BOOK_IS_IN_PHASE_NO= 15
enum codeBookNo {
CODE_BOOK_ZERO_NO = 0,
CODE_BOOK_1_NO = 1,
CODE_BOOK_2_NO = 2,
CODE_BOOK_3_NO = 3,
CODE_BOOK_4_NO = 4,
CODE_BOOK_5_NO = 5,
CODE_BOOK_6_NO = 6,
CODE_BOOK_7_NO = 7,
CODE_BOOK_8_NO = 8,
CODE_BOOK_9_NO = 9,
CODE_BOOK_10_NO = 10,
CODE_BOOK_ESC_NO = 11,
CODE_BOOK_RES_NO = 12,
CODE_BOOK_PNS_NO = 13,
CODE_BOOK_IS_OUT_OF_PHASE_NO = 14,
CODE_BOOK_IS_IN_PHASE_NO = 15
};
@ -126,62 +137,64 @@ enum codeBookNo{
code book index table
*/
enum codeBookNdx{
CODE_BOOK_ZERO_NDX,
CODE_BOOK_1_NDX,
CODE_BOOK_2_NDX,
CODE_BOOK_3_NDX,
CODE_BOOK_4_NDX,
CODE_BOOK_5_NDX,
CODE_BOOK_6_NDX,
CODE_BOOK_7_NDX,
CODE_BOOK_8_NDX,
CODE_BOOK_9_NDX,
CODE_BOOK_10_NDX,
CODE_BOOK_ESC_NDX,
CODE_BOOK_RES_NDX,
CODE_BOOK_PNS_NDX,
CODE_BOOK_IS_OUT_OF_PHASE_NDX,
CODE_BOOK_IS_IN_PHASE_NDX,
NUMBER_OF_CODE_BOOKS
enum codeBookNdx {
CODE_BOOK_ZERO_NDX,
CODE_BOOK_1_NDX,
CODE_BOOK_2_NDX,
CODE_BOOK_3_NDX,
CODE_BOOK_4_NDX,
CODE_BOOK_5_NDX,
CODE_BOOK_6_NDX,
CODE_BOOK_7_NDX,
CODE_BOOK_8_NDX,
CODE_BOOK_9_NDX,
CODE_BOOK_10_NDX,
CODE_BOOK_ESC_NDX,
CODE_BOOK_RES_NDX,
CODE_BOOK_PNS_NDX,
CODE_BOOK_IS_OUT_OF_PHASE_NDX,
CODE_BOOK_IS_IN_PHASE_NDX,
NUMBER_OF_CODE_BOOKS
};
/*
code book lav table
*/
enum codeBookLav{
CODE_BOOK_ZERO_LAV=0,
CODE_BOOK_1_LAV=1,
CODE_BOOK_2_LAV=1,
CODE_BOOK_3_LAV=2,
CODE_BOOK_4_LAV=2,
CODE_BOOK_5_LAV=4,
CODE_BOOK_6_LAV=4,
CODE_BOOK_7_LAV=7,
CODE_BOOK_8_LAV=7,
CODE_BOOK_9_LAV=12,
CODE_BOOK_10_LAV=12,
CODE_BOOK_ESC_LAV=16,
CODE_BOOK_SCF_LAV=60,
CODE_BOOK_PNS_LAV=60
};
enum codeBookLav {
CODE_BOOK_ZERO_LAV = 0,
CODE_BOOK_1_LAV = 1,
CODE_BOOK_2_LAV = 1,
CODE_BOOK_3_LAV = 2,
CODE_BOOK_4_LAV = 2,
CODE_BOOK_5_LAV = 4,
CODE_BOOK_6_LAV = 4,
CODE_BOOK_7_LAV = 7,
CODE_BOOK_8_LAV = 7,
CODE_BOOK_9_LAV = 12,
CODE_BOOK_10_LAV = 12,
CODE_BOOK_ESC_LAV = 16,
CODE_BOOK_SCF_LAV = 60,
CODE_BOOK_PNS_LAV = 60
};
INT FDKaacEnc_bitCount(const SHORT *aQuantSpectrum,
const INT noOfSpecLines,
INT maxVal,
INT *bitCountLut);
INT FDKaacEnc_bitCount(const SHORT *aQuantSpectrum, const INT noOfSpecLines,
INT maxVal, INT *bitCountLut);
INT FDKaacEnc_countValues(SHORT *values, INT width, INT codeBook);
INT FDKaacEnc_countValues(SHORT *values, INT width, INT codeBook);
INT FDKaacEnc_codeValues(SHORT *values, INT width, INT codeBook, HANDLE_FDK_BITSTREAM hBitstream);
INT FDKaacEnc_codeValues(SHORT *values, INT width, INT codeBook,
HANDLE_FDK_BITSTREAM hBitstream);
INT FDKaacEnc_codeScalefactorDelta(INT scalefactor, HANDLE_FDK_BITSTREAM hBitstream);
INT FDKaacEnc_codeScalefactorDelta(INT scalefactor,
HANDLE_FDK_BITSTREAM hBitstream);
inline INT FDKaacEnc_bitCountScalefactorDelta(const INT delta)
{
FDK_ASSERT( (0 <= (delta+CODE_BOOK_SCF_LAV)) && ((delta+CODE_BOOK_SCF_LAV)<(int)(sizeof(FDKaacEnc_huff_ltabscf)/sizeof((FDKaacEnc_huff_ltabscf[0])))) );
return((INT)FDKaacEnc_huff_ltabscf[delta+CODE_BOOK_SCF_LAV]);
inline INT FDKaacEnc_bitCountScalefactorDelta(const INT delta) {
FDK_ASSERT((0 <= (delta + CODE_BOOK_SCF_LAV)) &&
((delta + CODE_BOOK_SCF_LAV) <
(int)(sizeof(FDKaacEnc_huff_ltabscf) /
sizeof((FDKaacEnc_huff_ltabscf[0])))));
return ((INT)FDKaacEnc_huff_ltabscf[delta + CODE_BOOK_SCF_LAV]);
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,74 +90,70 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder **************************
/**************************** AAC encoder library ******************************
Initial author: M. Werner
contents/description: Bitstream encoder
Author(s): M. Werner
******************************************************************************/
Description: Bitstream encoder
#ifndef _BITENC_H
#define _BITENC_H
*******************************************************************************/
#ifndef BITENC_H
#define BITENC_H
#include "qc_data.h"
#include "aacenc_tns.h"
#include "channel_map.h"
#include "interface.h" /* obsolete, when PSY_OUT is thrown out of the WritBS-call! */
#include "interface.h" /* obsolete, when PSY_OUT is thrown out of the WritBS-call! */
#include "FDK_audio.h"
#include "aacenc.h"
#include "tpenc_lib.h"
typedef enum{
MAX_ENCODER_CHANNELS = 9,
MAX_BLOCK_TYPES = 4,
MAX_AAC_LAYERS = 9,
MAX_LAYERS = MAX_AAC_LAYERS , /* only one core layer if present */
FIRST_LAY = 1 /* default layer number for AAC nonscalable */
typedef enum {
MAX_ENCODER_CHANNELS = 9,
MAX_BLOCK_TYPES = 4,
MAX_AAC_LAYERS = 9,
MAX_LAYERS = MAX_AAC_LAYERS, /* only one core layer if present */
FIRST_LAY = 1 /* default layer number for AAC nonscalable */
} _MAX_CONST;
#define BUFFER_MX_HUFFCB_SIZE (32*sizeof(INT)) /* our FDK_bitbuffer needs size of power 2 */
#define EL_ID_BITS ( 3 )
#define BUFFER_MX_HUFFCB_SIZE \
(32 * sizeof(INT)) /* our FDK_bitbuffer needs size of power 2 */
#define EL_ID_BITS (3)
/**
* \brief Arbitrary order bitstream writer. This function can either assemble a bit stream
* and write into the bit buffer of hTpEnc or calculate the number of static bits (signal independent)
* TpEnc handle must be NULL in this case. Or also Calculate the minimum possible number of
* static bits which by disabling all tools e.g. MS, TNS and sbfCnt=0. The minCnt parameter
* has to be 1 in this latter case.
* \param hTpEnc Transport encoder handle. If NULL, the number of static bits will be returned into
* *pBitDemand.
* \brief Arbitrary order bitstream writer. This function can either assemble a
* bit stream and write into the bit buffer of hTpEnc or calculate the number of
* static bits (signal independent) TpEnc handle must be NULL in this
* case. Or also Calculate the minimum possible number of static bits
* which by disabling all tools e.g. MS, TNS and sbfCnt=0. The minCnt
* parameter has to be 1 in this latter case.
* \param hTpEnc Transport encoder handle. If NULL, the number of static bits
* will be returned into *pBitDemand.
* \param pElInfo
* \param qcOutChannel
* \param hReorderInfo
* \param psyOutElement
* \param psyOutChannel
* \param syntaxFlags Bit stream syntax flags as defined in FDK_audio.h (Audio Codec flags).
* \param syntaxFlags Bit stream syntax flags as defined in FDK_audio.h (Audio
* Codec flags).
* \param aot
* \param epConfig
* \param pBitDemand Pointer to an int where the amount of bits is returned into. The returned value
* depends on if hTpEnc is NULL and minCnt.
* \param minCnt If non-zero the value returned into *pBitDemand is the absolute minimum required amount of
* static bits in order to write a valid bit stream.
* \param pBitDemand Pointer to an int where the amount of bits is returned
* into. The returned value depends on if hTpEnc is NULL and minCnt.
* \param minCnt If non-zero the value returned into *pBitDemand is the absolute
* minimum required amount of static bits in order to write a valid bit stream.
* \return AAC_ENCODER_ERROR error code
*/
AAC_ENCODER_ERROR FDKaacEnc_ChannelElementWrite( HANDLE_TRANSPORTENC hTpEnc,
ELEMENT_INFO *pElInfo,
QC_OUT_CHANNEL *qcOutChannel[(2)],
PSY_OUT_ELEMENT *psyOutElement,
PSY_OUT_CHANNEL *psyOutChannel[(2)],
UINT syntaxFlags,
AUDIO_OBJECT_TYPE aot,
SCHAR epConfig,
INT *pBitDemand,
UCHAR minCnt
);
AAC_ENCODER_ERROR FDKaacEnc_ChannelElementWrite(
HANDLE_TRANSPORTENC hTpEnc, ELEMENT_INFO *pElInfo,
QC_OUT_CHANNEL *qcOutChannel[(2)], PSY_OUT_ELEMENT *psyOutElement,
PSY_OUT_CHANNEL *psyOutChannel[(2)], UINT syntaxFlags,
AUDIO_OBJECT_TYPE aot, SCHAR epConfig, INT *pBitDemand, UCHAR minCnt);
/**
* \brief Write bit stream or account static bits
* \param hTpEnc transport encoder handle. If NULL, the function will
@ -161,23 +168,17 @@ AAC_ENCODER_ERROR FDKaacEnc_ChannelElementWrite( HANDLE_TRANSPORTENC hTpEnc,
* \param syntaxFlags Flags indicating format specific detail
* \param epConfig Error protection config
*/
AAC_ENCODER_ERROR FDKaacEnc_WriteBitstream (HANDLE_TRANSPORTENC hTpEnc,
CHANNEL_MAPPING *channelMapping,
QC_OUT* qcOut,
PSY_OUT* psyOut,
QC_STATE* qcKernel,
AUDIO_OBJECT_TYPE aot,
UINT syntaxFlags,
SCHAR epConfig
);
AAC_ENCODER_ERROR FDKaacEnc_WriteBitstream(HANDLE_TRANSPORTENC hTpEnc,
CHANNEL_MAPPING *channelMapping,
QC_OUT *qcOut, PSY_OUT *psyOut,
QC_STATE *qcKernel,
AUDIO_OBJECT_TYPE aot,
UINT syntaxFlags, SCHAR epConfig);
INT FDKaacEnc_writeExtensionData( HANDLE_TRANSPORTENC hTpEnc,
QC_OUT_EXTENSION *pExtension,
INT elInstanceTag,
UINT alignAnchor,
UINT syntaxFlags,
AUDIO_OBJECT_TYPE aot,
SCHAR epConfig
);
INT FDKaacEnc_writeExtensionData(HANDLE_TRANSPORTENC hTpEnc,
QC_OUT_EXTENSION *pExtension,
INT elInstanceTag, UINT alignAnchor,
UINT syntaxFlags, AUDIO_OBJECT_TYPE aot,
SCHAR epConfig);
#endif /* _BITENC_H */
#endif /* BITENC_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,460 +90,488 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Encoder **************************
/**************************** AAC encoder library ******************************
Author(s): M. Werner, Tobias Chalupka
Description: Block switching
******************************************************************************/
*******************************************************************************/
/****************** Includes *****************************/
#include "block_switch.h"
#include "genericStds.h"
#define LOWOV_WINDOW _LOWOV_WINDOW
/**************** internal function prototypes ***********/
static FIXP_DBL FDKaacEnc_GetWindowEnergy(const FIXP_DBL in[], const INT blSwWndIdx);
static FIXP_DBL FDKaacEnc_GetWindowEnergy(const FIXP_DBL in[],
const INT blSwWndIdx);
static void FDKaacEnc_CalcWindowEnergy(
BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl,
INT windowLen,
const INT_PCM *pTimeSignal
);
BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl, INT windowLen,
const INT_PCM *pTimeSignal);
/****************** Constants *****************************/
/* LONG START SHORT STOP LOWOV */
static const INT blockType2windowShape[2][5] = { {SINE_WINDOW, KBD_WINDOW, WRONG_WINDOW, SINE_WINDOW, KBD_WINDOW}, /* LD */
{KBD_WINDOW, SINE_WINDOW, SINE_WINDOW, KBD_WINDOW, WRONG_WINDOW} }; /* LC */
/* LONG START
* SHORT STOP LOWOV */
static const INT blockType2windowShape[2][5] = {
{SINE_WINDOW, KBD_WINDOW, WRONG_WINDOW, SINE_WINDOW, KBD_WINDOW}, /* LD */
{KBD_WINDOW, SINE_WINDOW, SINE_WINDOW, KBD_WINDOW, WRONG_WINDOW}}; /* LC */
/* IIR high pass coeffs */
#ifndef SINETABLE_16BIT
static const FIXP_DBL hiPassCoeff[BLOCK_SWITCHING_IIR_LEN]=
{
FL2FXCONST_DBL(-0.5095),FL2FXCONST_DBL(0.7548)
};
static const FIXP_DBL hiPassCoeff[BLOCK_SWITCHING_IIR_LEN] = {
FL2FXCONST_DBL(-0.5095), FL2FXCONST_DBL(0.7548)};
static const FIXP_DBL accWindowNrgFac = FL2FXCONST_DBL(0.3f); /* factor for accumulating filtered window energies */
static const FIXP_DBL accWindowNrgFac =
FL2FXCONST_DBL(0.3f); /* factor for accumulating filtered window energies */
static const FIXP_DBL oneMinusAccWindowNrgFac = FL2FXCONST_DBL(0.7f);
/* static const float attackRatio = 10.0; */ /* lower ratio limit for attacks */
static const FIXP_DBL invAttackRatio = FL2FXCONST_DBL(0.1f); /* inverted lower ratio limit for attacks */
/* static const float attackRatio = 10.0; */ /* lower ratio limit for attacks */
static const FIXP_DBL invAttackRatio =
FL2FXCONST_DBL(0.1f); /* inverted lower ratio limit for attacks */
/* The next constants are scaled, because they are used for comparison with scaled values*/
/* The next constants are scaled, because they are used for comparison with
* scaled values*/
/* minimum energy for attacks */
static const FIXP_DBL minAttackNrg = (FL2FXCONST_DBL(1e+6f*NORM_PCM_ENERGY)>>BLOCK_SWITCH_ENERGY_SHIFT); /* minimum energy for attacks */
static const FIXP_DBL minAttackNrg =
(FL2FXCONST_DBL(1e+6f * NORM_PCM_ENERGY) >>
BLOCK_SWITCH_ENERGY_SHIFT); /* minimum energy for attacks */
#else
static const FIXP_SGL hiPassCoeff[BLOCK_SWITCHING_IIR_LEN]=
{
FL2FXCONST_SGL(-0.5095),FL2FXCONST_SGL(0.7548)
};
static const FIXP_SGL hiPassCoeff[BLOCK_SWITCHING_IIR_LEN] = {
FL2FXCONST_SGL(-0.5095), FL2FXCONST_SGL(0.7548)};
static const FIXP_DBL accWindowNrgFac = FL2FXCONST_DBL(0.3f); /* factor for accumulating filtered window energies */
static const FIXP_DBL accWindowNrgFac =
FL2FXCONST_DBL(0.3f); /* factor for accumulating filtered window energies */
static const FIXP_SGL oneMinusAccWindowNrgFac = FL2FXCONST_SGL(0.7f);
/* static const float attackRatio = 10.0; */ /* lower ratio limit for attacks */
static const FIXP_SGL invAttackRatio = FL2FXCONST_SGL(0.1f); /* inverted lower ratio limit for attacks */
/* static const float attackRatio = 10.0; */ /* lower ratio limit for attacks */
static const FIXP_SGL invAttackRatio =
FL2FXCONST_SGL(0.1f); /* inverted lower ratio limit for attacks */
/* minimum energy for attacks */
static const FIXP_DBL minAttackNrg = (FL2FXCONST_DBL(1e+6f*NORM_PCM_ENERGY)>>BLOCK_SWITCH_ENERGY_SHIFT); /* minimum energy for attacks */
static const FIXP_DBL minAttackNrg =
(FL2FXCONST_DBL(1e+6f * NORM_PCM_ENERGY) >>
BLOCK_SWITCH_ENERGY_SHIFT); /* minimum energy for attacks */
#endif
/**************** internal function prototypes ***********/
/****************** Routines ****************************/
void FDKaacEnc_InitBlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, INT isLowDelay)
{
FDKmemclear (blockSwitchingControl, sizeof(BLOCK_SWITCHING_CONTROL));
void FDKaacEnc_InitBlockSwitching(
BLOCK_SWITCHING_CONTROL *blockSwitchingControl, INT isLowDelay) {
FDKmemclear(blockSwitchingControl, sizeof(BLOCK_SWITCHING_CONTROL));
if (isLowDelay)
{
if (isLowDelay) {
blockSwitchingControl->nBlockSwitchWindows = 4;
blockSwitchingControl->allowShortFrames = 0;
blockSwitchingControl->allowLookAhead = 0;
}
else
{
blockSwitchingControl->allowShortFrames = 0;
blockSwitchingControl->allowLookAhead = 0;
} else {
blockSwitchingControl->nBlockSwitchWindows = 8;
blockSwitchingControl->allowShortFrames = 1;
blockSwitchingControl->allowLookAhead = 1;
blockSwitchingControl->allowShortFrames = 1;
blockSwitchingControl->allowLookAhead = 1;
}
blockSwitchingControl->noOfGroups = MAX_NO_OF_GROUPS;
blockSwitchingControl->noOfGroups = MAX_NO_OF_GROUPS;
/* Initialize startvalue for blocktype */
blockSwitchingControl->lastWindowSequence = LONG_WINDOW;
blockSwitchingControl->windowShape = blockType2windowShape[blockSwitchingControl->allowShortFrames][blockSwitchingControl->lastWindowSequence];
blockSwitchingControl->lastWindowSequence = LONG_WINDOW;
blockSwitchingControl->windowShape =
blockType2windowShape[blockSwitchingControl->allowShortFrames]
[blockSwitchingControl->lastWindowSequence];
}
static const INT suggestedGroupingTable[TRANS_FAC][MAX_NO_OF_GROUPS] =
{
/* Attack in Window 0 */ {1, 3, 3, 1},
/* Attack in Window 1 */ {1, 1, 3, 3},
/* Attack in Window 2 */ {2, 1, 3, 2},
/* Attack in Window 3 */ {3, 1, 3, 1},
/* Attack in Window 4 */ {3, 1, 1, 3},
/* Attack in Window 5 */ {3, 2, 1, 2},
/* Attack in Window 6 */ {3, 3, 1, 1},
/* Attack in Window 7 */ {3, 3, 1, 1}
};
static const INT suggestedGroupingTable[TRANS_FAC][MAX_NO_OF_GROUPS] = {
/* Attack in Window 0 */ {1, 3, 3, 1},
/* Attack in Window 1 */ {1, 1, 3, 3},
/* Attack in Window 2 */ {2, 1, 3, 2},
/* Attack in Window 3 */ {3, 1, 3, 1},
/* Attack in Window 4 */ {3, 1, 1, 3},
/* Attack in Window 5 */ {3, 2, 1, 2},
/* Attack in Window 6 */ {3, 3, 1, 1},
/* Attack in Window 7 */ {3, 3, 1, 1}};
/* change block type depending on current blocktype and whether there's an attack */
/* change block type depending on current blocktype and whether there's an
* attack */
/* assume no look-ahead */
static const INT chgWndSq[2][N_BLOCKTYPES] =
{
/* LONG WINDOW START_WINDOW SHORT_WINDOW STOP_WINDOW, LOWOV_WINDOW, WRONG_WINDOW */
/*no attack*/ {LONG_WINDOW, STOP_WINDOW, WRONG_WINDOW, LONG_WINDOW, STOP_WINDOW , WRONG_WINDOW },
/*attack */ {START_WINDOW, LOWOV_WINDOW, WRONG_WINDOW, START_WINDOW, LOWOV_WINDOW, WRONG_WINDOW }
};
static const INT chgWndSq[2][N_BLOCKTYPES] = {
/* LONG WINDOW START_WINDOW SHORT_WINDOW STOP_WINDOW,
LOWOV_WINDOW, WRONG_WINDOW */
/*no attack*/ {LONG_WINDOW, STOP_WINDOW, WRONG_WINDOW, LONG_WINDOW,
STOP_WINDOW, WRONG_WINDOW},
/*attack */ {START_WINDOW, LOWOV_WINDOW, WRONG_WINDOW, START_WINDOW,
LOWOV_WINDOW, WRONG_WINDOW}};
/* change block type depending on current blocktype and whether there's an attack */
/* change block type depending on current blocktype and whether there's an
* attack */
/* assume look-ahead */
static const INT chgWndSqLkAhd[2][2][N_BLOCKTYPES] =
{
/*attack LONG WINDOW START_WINDOW SHORT_WINDOW STOP_WINDOW LOWOV_WINDOW, WRONG_WINDOW */ /* last attack */
/*no attack*/ { {LONG_WINDOW, SHORT_WINDOW, STOP_WINDOW, LONG_WINDOW, WRONG_WINDOW, WRONG_WINDOW}, /* no attack */
/*attack */ {START_WINDOW, SHORT_WINDOW, SHORT_WINDOW, START_WINDOW, WRONG_WINDOW, WRONG_WINDOW} }, /* no attack */
/*no attack*/ { {LONG_WINDOW, SHORT_WINDOW, SHORT_WINDOW, LONG_WINDOW, WRONG_WINDOW, WRONG_WINDOW}, /* attack */
/*attack */ {START_WINDOW, SHORT_WINDOW, SHORT_WINDOW, START_WINDOW, WRONG_WINDOW, WRONG_WINDOW} } /* attack */
static const INT chgWndSqLkAhd[2][2][N_BLOCKTYPES] = {
/*attack LONG WINDOW START_WINDOW SHORT_WINDOW STOP_WINDOW LOWOV_WINDOW, WRONG_WINDOW */ /* last attack */
/*no attack*/ {
{LONG_WINDOW, SHORT_WINDOW, STOP_WINDOW, LONG_WINDOW, WRONG_WINDOW,
WRONG_WINDOW}, /* no attack */
/*attack */ {START_WINDOW, SHORT_WINDOW, SHORT_WINDOW, START_WINDOW,
WRONG_WINDOW, WRONG_WINDOW}}, /* no attack */
/*no attack*/ {{LONG_WINDOW, SHORT_WINDOW, SHORT_WINDOW, LONG_WINDOW,
WRONG_WINDOW, WRONG_WINDOW}, /* attack */
/*attack */ {START_WINDOW, SHORT_WINDOW, SHORT_WINDOW,
START_WINDOW, WRONG_WINDOW,
WRONG_WINDOW}} /* attack */
};
int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, const INT granuleLength, const int isLFE, const INT_PCM *pTimeSignal)
{
UINT i;
FIXP_DBL enM1, enMax;
int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl,
const INT granuleLength, const int isLFE,
const INT_PCM *pTimeSignal) {
UINT i;
FIXP_DBL enM1, enMax;
UINT nBlockSwitchWindows = blockSwitchingControl->nBlockSwitchWindows;
UINT nBlockSwitchWindows = blockSwitchingControl->nBlockSwitchWindows;
/* for LFE : only LONG window allowed */
if (isLFE) {
/* for LFE : only LONG window allowed */
if (isLFE) {
/* case LFE: */
/* only long blocks, always use sine windows (MPEG2 AAC, MPEG4 AAC) */
blockSwitchingControl->lastWindowSequence = LONG_WINDOW;
blockSwitchingControl->windowShape = SINE_WINDOW;
blockSwitchingControl->noOfGroups = 1;
blockSwitchingControl->groupLen[0] = 1;
/* case LFE: */
/* only long blocks, always use sine windows (MPEG2 AAC, MPEG4 AAC) */
blockSwitchingControl->lastWindowSequence = LONG_WINDOW;
blockSwitchingControl->windowShape = SINE_WINDOW;
blockSwitchingControl->noOfGroups = 1;
blockSwitchingControl->groupLen[0] = 1;
return (0);
};
return(0);
};
/* Save current attack index as last attack index */
blockSwitchingControl->lastattack = blockSwitchingControl->attack;
blockSwitchingControl->lastAttackIndex = blockSwitchingControl->attackIndex;
/* Save current attack index as last attack index */
blockSwitchingControl->lastattack = blockSwitchingControl->attack;
blockSwitchingControl->lastAttackIndex = blockSwitchingControl->attackIndex;
/* Save current window energy as last window energy */
FDKmemcpy(blockSwitchingControl->windowNrg[0],
blockSwitchingControl->windowNrg[1],
sizeof(blockSwitchingControl->windowNrg[0]));
FDKmemcpy(blockSwitchingControl->windowNrgF[0],
blockSwitchingControl->windowNrgF[1],
sizeof(blockSwitchingControl->windowNrgF[0]));
/* Save current window energy as last window energy */
FDKmemcpy(blockSwitchingControl->windowNrg[0], blockSwitchingControl->windowNrg[1], sizeof(blockSwitchingControl->windowNrg[0]));
FDKmemcpy(blockSwitchingControl->windowNrgF[0], blockSwitchingControl->windowNrgF[1], sizeof(blockSwitchingControl->windowNrgF[0]));
if (blockSwitchingControl->allowShortFrames) {
/* Calculate suggested grouping info for the last frame */
if (blockSwitchingControl->allowShortFrames)
{
/* Calculate suggested grouping info for the last frame */
/* Reset grouping info */
FDKmemclear(blockSwitchingControl->groupLen,
sizeof(blockSwitchingControl->groupLen));
/* Reset grouping info */
FDKmemclear (blockSwitchingControl->groupLen, sizeof(blockSwitchingControl->groupLen));
/* Set grouping info */
blockSwitchingControl->noOfGroups = MAX_NO_OF_GROUPS;
/* Set grouping info */
blockSwitchingControl->noOfGroups = MAX_NO_OF_GROUPS;
FDKmemcpy(blockSwitchingControl->groupLen,
suggestedGroupingTable[blockSwitchingControl->lastAttackIndex],
sizeof(blockSwitchingControl->groupLen));
FDKmemcpy(blockSwitchingControl->groupLen, suggestedGroupingTable[blockSwitchingControl->lastAttackIndex], sizeof(blockSwitchingControl->groupLen));
if (blockSwitchingControl->attack == TRUE)
blockSwitchingControl->maxWindowNrg = FDKaacEnc_GetWindowEnergy(blockSwitchingControl->windowNrg[0], blockSwitchingControl->lastAttackIndex);
else
blockSwitchingControl->maxWindowNrg = FL2FXCONST_DBL(0.0);
}
/* Calculate unfiltered and filtered energies in subwindows and combine to segments */
FDKaacEnc_CalcWindowEnergy(blockSwitchingControl, granuleLength>>(nBlockSwitchWindows==4? 2:3 ), pTimeSignal);
/* now calculate if there is an attack */
/* reset attack */
blockSwitchingControl->attack = FALSE;
/* look for attack */
enMax = FL2FXCONST_DBL(0.0f);
enM1 = blockSwitchingControl->windowNrgF[0][nBlockSwitchWindows-1];
for (i=0; i<nBlockSwitchWindows; i++) {
FIXP_DBL tmp = fMultDiv2(oneMinusAccWindowNrgFac, blockSwitchingControl->accWindowNrg);
blockSwitchingControl->accWindowNrg = fMultAdd(tmp, accWindowNrgFac, enM1) ;
if (fMult(blockSwitchingControl->windowNrgF[1][i],invAttackRatio) > blockSwitchingControl->accWindowNrg ) {
blockSwitchingControl->attack = TRUE;
blockSwitchingControl->attackIndex = i;
}
enM1 = blockSwitchingControl->windowNrgF[1][i];
enMax = fixMax(enMax, enM1);
}
if (enMax < minAttackNrg) blockSwitchingControl->attack = FALSE;
/* Check if attack spreads over frame border */
if((blockSwitchingControl->attack == FALSE) && (blockSwitchingControl->lastattack == TRUE)) {
/* if attack is in last window repeat SHORT_WINDOW */
if ( ((blockSwitchingControl->windowNrgF[0][nBlockSwitchWindows-1]>>4) > fMult((FIXP_DBL)(10<<(DFRACT_BITS-1-4)), blockSwitchingControl->windowNrgF[1][1]))
&& (blockSwitchingControl->lastAttackIndex == (INT)nBlockSwitchWindows-1)
)
{
blockSwitchingControl->attack = TRUE;
blockSwitchingControl->attackIndex = 0;
}
}
if(blockSwitchingControl->allowLookAhead)
{
blockSwitchingControl->lastWindowSequence =
chgWndSqLkAhd[blockSwitchingControl->lastattack][blockSwitchingControl->attack][blockSwitchingControl->lastWindowSequence];
}
if (blockSwitchingControl->attack == TRUE)
blockSwitchingControl->maxWindowNrg =
FDKaacEnc_GetWindowEnergy(blockSwitchingControl->windowNrg[0],
blockSwitchingControl->lastAttackIndex);
else
{
/* Low Delay */
blockSwitchingControl->lastWindowSequence =
chgWndSq[blockSwitchingControl->attack][blockSwitchingControl->lastWindowSequence];
blockSwitchingControl->maxWindowNrg = FL2FXCONST_DBL(0.0);
}
/* Calculate unfiltered and filtered energies in subwindows and combine to
* segments */
FDKaacEnc_CalcWindowEnergy(
blockSwitchingControl,
granuleLength >> (nBlockSwitchWindows == 4 ? 2 : 3), pTimeSignal);
/* now calculate if there is an attack */
/* reset attack */
blockSwitchingControl->attack = FALSE;
/* look for attack */
enMax = FL2FXCONST_DBL(0.0f);
enM1 = blockSwitchingControl->windowNrgF[0][nBlockSwitchWindows - 1];
for (i = 0; i < nBlockSwitchWindows; i++) {
FIXP_DBL tmp =
fMultDiv2(oneMinusAccWindowNrgFac, blockSwitchingControl->accWindowNrg);
blockSwitchingControl->accWindowNrg = fMultAdd(tmp, accWindowNrgFac, enM1);
if (fMult(blockSwitchingControl->windowNrgF[1][i], invAttackRatio) >
blockSwitchingControl->accWindowNrg) {
blockSwitchingControl->attack = TRUE;
blockSwitchingControl->attackIndex = i;
}
enM1 = blockSwitchingControl->windowNrgF[1][i];
enMax = fixMax(enMax, enM1);
}
if (enMax < minAttackNrg) blockSwitchingControl->attack = FALSE;
/* update window shape */
blockSwitchingControl->windowShape = blockType2windowShape[blockSwitchingControl->allowShortFrames][blockSwitchingControl->lastWindowSequence];
/* Check if attack spreads over frame border */
if ((blockSwitchingControl->attack == FALSE) &&
(blockSwitchingControl->lastattack == TRUE)) {
/* if attack is in last window repeat SHORT_WINDOW */
if (((blockSwitchingControl->windowNrgF[0][nBlockSwitchWindows - 1] >> 4) >
fMult((FIXP_DBL)(10 << (DFRACT_BITS - 1 - 4)),
blockSwitchingControl->windowNrgF[1][1])) &&
(blockSwitchingControl->lastAttackIndex ==
(INT)nBlockSwitchWindows - 1)) {
blockSwitchingControl->attack = TRUE;
blockSwitchingControl->attackIndex = 0;
}
}
return(0);
if (blockSwitchingControl->allowLookAhead) {
blockSwitchingControl->lastWindowSequence =
chgWndSqLkAhd[blockSwitchingControl->lastattack]
[blockSwitchingControl->attack]
[blockSwitchingControl->lastWindowSequence];
} else {
/* Low Delay */
blockSwitchingControl->lastWindowSequence =
chgWndSq[blockSwitchingControl->attack]
[blockSwitchingControl->lastWindowSequence];
}
/* update window shape */
blockSwitchingControl->windowShape =
blockType2windowShape[blockSwitchingControl->allowShortFrames]
[blockSwitchingControl->lastWindowSequence];
return (0);
}
static FIXP_DBL FDKaacEnc_GetWindowEnergy(const FIXP_DBL in[], const INT blSwWndIdx)
{
/* For coherency, change FDKaacEnc_GetWindowEnergy() to calcluate the energy for a block switching analysis windows,
not for a short block. The same is done FDKaacEnc_CalcWindowEnergy(). The result of FDKaacEnc_GetWindowEnergy()
is used for a comparision of the max energy of left/right channel. */
static FIXP_DBL FDKaacEnc_GetWindowEnergy(const FIXP_DBL in[],
const INT blSwWndIdx) {
/* For coherency, change FDKaacEnc_GetWindowEnergy() to calcluate the energy
for a block switching analysis windows, not for a short block. The same is
done FDKaacEnc_CalcWindowEnergy(). The result of
FDKaacEnc_GetWindowEnergy() is used for a comparision of the max energy of
left/right channel. */
return in[blSwWndIdx];
}
static void FDKaacEnc_CalcWindowEnergy(BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl, INT windowLen, const INT_PCM *pTimeSignal)
{
INT i;
UINT w;
static void FDKaacEnc_CalcWindowEnergy(
BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl, INT windowLen,
const INT_PCM *pTimeSignal) {
INT i;
UINT w;
FIXP_SGL hiPassCoeff0 = hiPassCoeff[0];
FIXP_SGL hiPassCoeff1 = hiPassCoeff[1];
/* sum up scalarproduct of timesignal as windowed Energies */
for (w=0; w < blockSwitchingControl->nBlockSwitchWindows; w++) {
FIXP_DBL temp_windowNrg = FL2FXCONST_DBL(0.0f);
FIXP_DBL temp_windowNrgF = FL2FXCONST_DBL(0.0f);
FIXP_DBL temp_iirState0 = blockSwitchingControl->iirStates[0];
FIXP_DBL temp_iirState1 = blockSwitchingControl->iirStates[1];
/* windowNrg = sum(timesample^2) */
for(i=0;i<windowLen;i++)
{
FIXP_DBL tempUnfiltered, tempFiltred, t1, t2;
/* tempUnfiltered is scaled with 1 to prevent overflows during calculation of tempFiltred */
#if SAMPLE_BITS == DFRACT_BITS
tempUnfiltered = (FIXP_DBL) *pTimeSignal++ >> 1;
#ifndef SINETABLE_16BIT
const FIXP_DBL hiPassCoeff0 = hiPassCoeff[0];
const FIXP_DBL hiPassCoeff1 = hiPassCoeff[1];
#else
tempUnfiltered = (FIXP_DBL) *pTimeSignal++ << (DFRACT_BITS-SAMPLE_BITS-1);
const FIXP_SGL hiPassCoeff0 = hiPassCoeff[0];
const FIXP_SGL hiPassCoeff1 = hiPassCoeff[1];
#endif
t1 = fMultDiv2(hiPassCoeff1, tempUnfiltered-temp_iirState0);
t2 = fMultDiv2(hiPassCoeff0, temp_iirState1);
tempFiltred = (t1 - t2) << 1;
temp_iirState0 = tempUnfiltered;
temp_iirState1 = tempFiltred;
FIXP_DBL temp_iirState0 = blockSwitchingControl->iirStates[0];
FIXP_DBL temp_iirState1 = blockSwitchingControl->iirStates[1];
/* subtract 2 from overallscaling (BLOCK_SWITCH_ENERGY_SHIFT)
* because tempUnfiltered was already scaled with 1 (is 2 after squaring)
* subtract 1 from overallscaling (BLOCK_SWITCH_ENERGY_SHIFT)
* because of fMultDiv2 is doing a scaling by one */
temp_windowNrg += fPow2Div2(tempUnfiltered) >> (BLOCK_SWITCH_ENERGY_SHIFT - 1 - 2);
temp_windowNrgF += fPow2Div2(tempFiltred) >> (BLOCK_SWITCH_ENERGY_SHIFT - 1 - 2);
}
blockSwitchingControl->windowNrg[1][w] = temp_windowNrg;
blockSwitchingControl->windowNrgF[1][w] = temp_windowNrgF;
blockSwitchingControl->iirStates[0] = temp_iirState0;
blockSwitchingControl->iirStates[1] = temp_iirState1;
/* sum up scalarproduct of timesignal as windowed Energies */
for (w = 0; w < blockSwitchingControl->nBlockSwitchWindows; w++) {
ULONG temp_windowNrg = 0x0;
ULONG temp_windowNrgF = 0x0;
/* windowNrg = sum(timesample^2) */
for (i = 0; i < windowLen; i++) {
FIXP_DBL tempUnfiltered, t1, t2;
/* tempUnfiltered is scaled with 1 to prevent overflows during calculation
* of tempFiltred */
#if SAMPLE_BITS == DFRACT_BITS
tempUnfiltered = (FIXP_DBL)*pTimeSignal++ >> 1;
#else
tempUnfiltered = (FIXP_DBL)*pTimeSignal++
<< (DFRACT_BITS - SAMPLE_BITS - 1);
#endif
t1 = fMultDiv2(hiPassCoeff1, tempUnfiltered - temp_iirState0);
t2 = fMultDiv2(hiPassCoeff0, temp_iirState1);
temp_iirState0 = tempUnfiltered;
temp_iirState1 = (t1 - t2) << 1;
temp_windowNrg += (LONG)fPow2Div2(temp_iirState0) >>
(BLOCK_SWITCH_ENERGY_SHIFT - 1 - 2);
temp_windowNrgF += (LONG)fPow2Div2(temp_iirState1) >>
(BLOCK_SWITCH_ENERGY_SHIFT - 1 - 2);
}
blockSwitchingControl->windowNrg[1][w] =
(LONG)fMin(temp_windowNrg, (UINT)MAXVAL_DBL);
blockSwitchingControl->windowNrgF[1][w] =
(LONG)fMin(temp_windowNrgF, (UINT)MAXVAL_DBL);
}
blockSwitchingControl->iirStates[0] = temp_iirState0;
blockSwitchingControl->iirStates[1] = temp_iirState1;
}
static const UCHAR synchronizedBlockTypeTable[5][5] =
{
/* LONG_WINDOW START_WINDOW SHORT_WINDOW STOP_WINDOW LOWOV_WINDOW*/
/* LONG_WINDOW */ {LONG_WINDOW, START_WINDOW, SHORT_WINDOW, STOP_WINDOW, LOWOV_WINDOW},
/* START_WINDOW */ {START_WINDOW, START_WINDOW, SHORT_WINDOW, SHORT_WINDOW, LOWOV_WINDOW},
/* SHORT_WINDOW */ {SHORT_WINDOW, SHORT_WINDOW, SHORT_WINDOW, SHORT_WINDOW, WRONG_WINDOW},
/* STOP_WINDOW */ {STOP_WINDOW, SHORT_WINDOW, SHORT_WINDOW, STOP_WINDOW, LOWOV_WINDOW},
/* LOWOV_WINDOW */ {LOWOV_WINDOW, LOWOV_WINDOW, WRONG_WINDOW, LOWOV_WINDOW, LOWOV_WINDOW},
static const UCHAR synchronizedBlockTypeTable[5][5] = {
/* LONG_WINDOW START_WINDOW SHORT_WINDOW STOP_WINDOW
LOWOV_WINDOW*/
/* LONG_WINDOW */ {LONG_WINDOW, START_WINDOW, SHORT_WINDOW, STOP_WINDOW,
LOWOV_WINDOW},
/* START_WINDOW */
{START_WINDOW, START_WINDOW, SHORT_WINDOW, SHORT_WINDOW, LOWOV_WINDOW},
/* SHORT_WINDOW */
{SHORT_WINDOW, SHORT_WINDOW, SHORT_WINDOW, SHORT_WINDOW, WRONG_WINDOW},
/* STOP_WINDOW */
{STOP_WINDOW, SHORT_WINDOW, SHORT_WINDOW, STOP_WINDOW, LOWOV_WINDOW},
/* LOWOV_WINDOW */
{LOWOV_WINDOW, LOWOV_WINDOW, WRONG_WINDOW, LOWOV_WINDOW, LOWOV_WINDOW},
};
int FDKaacEnc_SyncBlockSwitching (
BLOCK_SWITCHING_CONTROL *blockSwitchingControlLeft,
BLOCK_SWITCHING_CONTROL *blockSwitchingControlRight,
const INT nChannels,
const INT commonWindow )
{
int FDKaacEnc_SyncBlockSwitching(
BLOCK_SWITCHING_CONTROL *blockSwitchingControlLeft,
BLOCK_SWITCHING_CONTROL *blockSwitchingControlRight, const INT nChannels,
const INT commonWindow) {
UCHAR patchType = LONG_WINDOW;
if( nChannels == 2 && commonWindow == TRUE)
{
if (nChannels == 2 && commonWindow == TRUE) {
/* could be better with a channel loop (need a handle to psy_data) */
/* get suggested Block Types and synchronize */
patchType = synchronizedBlockTypeTable[patchType][blockSwitchingControlLeft->lastWindowSequence];
patchType = synchronizedBlockTypeTable[patchType][blockSwitchingControlRight->lastWindowSequence];
patchType = synchronizedBlockTypeTable[patchType][blockSwitchingControlLeft
->lastWindowSequence];
patchType = synchronizedBlockTypeTable[patchType][blockSwitchingControlRight
->lastWindowSequence];
/* sanity check (no change from low overlap window to short winow and vice versa) */
if (patchType == WRONG_WINDOW)
return -1; /* mixed up AAC-LC and AAC-LD */
/* sanity check (no change from low overlap window to short winow and vice
* versa) */
if (patchType == WRONG_WINDOW) return -1; /* mixed up AAC-LC and AAC-LD */
/* Set synchronized Blocktype */
blockSwitchingControlLeft->lastWindowSequence = patchType;
blockSwitchingControlLeft->lastWindowSequence = patchType;
blockSwitchingControlRight->lastWindowSequence = patchType;
/* update window shape */
blockSwitchingControlLeft->windowShape = blockType2windowShape[blockSwitchingControlLeft->allowShortFrames][blockSwitchingControlLeft->lastWindowSequence];
blockSwitchingControlRight->windowShape = blockType2windowShape[blockSwitchingControlLeft->allowShortFrames][blockSwitchingControlRight->lastWindowSequence];
blockSwitchingControlLeft->windowShape =
blockType2windowShape[blockSwitchingControlLeft->allowShortFrames]
[blockSwitchingControlLeft->lastWindowSequence];
blockSwitchingControlRight->windowShape =
blockType2windowShape[blockSwitchingControlLeft->allowShortFrames]
[blockSwitchingControlRight->lastWindowSequence];
}
if (blockSwitchingControlLeft->allowShortFrames)
{
if (blockSwitchingControlLeft->allowShortFrames) {
int i;
if( nChannels == 2 )
{
if (commonWindow == TRUE)
{
if (nChannels == 2) {
if (commonWindow == TRUE) {
/* Synchronize grouping info */
int windowSequenceLeftOld = blockSwitchingControlLeft->lastWindowSequence;
int windowSequenceRightOld = blockSwitchingControlRight->lastWindowSequence;
int windowSequenceLeftOld =
blockSwitchingControlLeft->lastWindowSequence;
int windowSequenceRightOld =
blockSwitchingControlRight->lastWindowSequence;
/* Long Blocks */
if(patchType != SHORT_WINDOW) {
if (patchType != SHORT_WINDOW) {
/* Set grouping info */
blockSwitchingControlLeft->noOfGroups = 1;
blockSwitchingControlRight->noOfGroups = 1;
blockSwitchingControlLeft->groupLen[0] = 1;
blockSwitchingControlLeft->noOfGroups = 1;
blockSwitchingControlRight->noOfGroups = 1;
blockSwitchingControlLeft->groupLen[0] = 1;
blockSwitchingControlRight->groupLen[0] = 1;
for (i = 1; i < MAX_NO_OF_GROUPS; i++)
{
blockSwitchingControlLeft->groupLen[i] = 0;
for (i = 1; i < MAX_NO_OF_GROUPS; i++) {
blockSwitchingControlLeft->groupLen[i] = 0;
blockSwitchingControlRight->groupLen[i] = 0;
}
}
/* Short Blocks */
else {
/* in case all two channels were detected as short-blocks before syncing, use the grouping of channel with higher maxWindowNrg */
if( (windowSequenceLeftOld == SHORT_WINDOW) &&
(windowSequenceRightOld == SHORT_WINDOW) )
{
if(blockSwitchingControlLeft->maxWindowNrg > blockSwitchingControlRight->maxWindowNrg) {
/* Left Channel wins */
blockSwitchingControlRight->noOfGroups = blockSwitchingControlLeft->noOfGroups;
for (i = 0; i < MAX_NO_OF_GROUPS; i++){
blockSwitchingControlRight->groupLen[i] = blockSwitchingControlLeft->groupLen[i];
}
/* in case all two channels were detected as short-blocks before
* syncing, use the grouping of channel with higher maxWindowNrg */
if ((windowSequenceLeftOld == SHORT_WINDOW) &&
(windowSequenceRightOld == SHORT_WINDOW)) {
if (blockSwitchingControlLeft->maxWindowNrg >
blockSwitchingControlRight->maxWindowNrg) {
/* Left Channel wins */
blockSwitchingControlRight->noOfGroups =
blockSwitchingControlLeft->noOfGroups;
for (i = 0; i < MAX_NO_OF_GROUPS; i++) {
blockSwitchingControlRight->groupLen[i] =
blockSwitchingControlLeft->groupLen[i];
}
} else {
/* Right Channel wins */
blockSwitchingControlLeft->noOfGroups =
blockSwitchingControlRight->noOfGroups;
for (i = 0; i < MAX_NO_OF_GROUPS; i++) {
blockSwitchingControlLeft->groupLen[i] =
blockSwitchingControlRight->groupLen[i];
}
}
else {
/* Right Channel wins */
blockSwitchingControlLeft->noOfGroups = blockSwitchingControlRight->noOfGroups;
for (i = 0; i < MAX_NO_OF_GROUPS; i++){
blockSwitchingControlLeft->groupLen[i] = blockSwitchingControlRight->groupLen[i];
}
}
}
else if ( (windowSequenceLeftOld == SHORT_WINDOW) &&
(windowSequenceRightOld != SHORT_WINDOW) )
{
} else if ((windowSequenceLeftOld == SHORT_WINDOW) &&
(windowSequenceRightOld != SHORT_WINDOW)) {
/* else use grouping of short-block channel */
blockSwitchingControlRight->noOfGroups = blockSwitchingControlLeft->noOfGroups;
for (i = 0; i < MAX_NO_OF_GROUPS; i++){
blockSwitchingControlRight->groupLen[i] = blockSwitchingControlLeft->groupLen[i];
blockSwitchingControlRight->noOfGroups =
blockSwitchingControlLeft->noOfGroups;
for (i = 0; i < MAX_NO_OF_GROUPS; i++) {
blockSwitchingControlRight->groupLen[i] =
blockSwitchingControlLeft->groupLen[i];
}
}
else if ( (windowSequenceRightOld == SHORT_WINDOW) &&
(windowSequenceLeftOld != SHORT_WINDOW) )
{
blockSwitchingControlLeft->noOfGroups = blockSwitchingControlRight->noOfGroups;
for (i = 0; i < MAX_NO_OF_GROUPS; i++){
blockSwitchingControlLeft->groupLen[i] = blockSwitchingControlRight->groupLen[i];
} else if ((windowSequenceRightOld == SHORT_WINDOW) &&
(windowSequenceLeftOld != SHORT_WINDOW)) {
blockSwitchingControlLeft->noOfGroups =
blockSwitchingControlRight->noOfGroups;
for (i = 0; i < MAX_NO_OF_GROUPS; i++) {
blockSwitchingControlLeft->groupLen[i] =
blockSwitchingControlRight->groupLen[i];
}
} else {
/* syncing a start and stop window ... */
blockSwitchingControlLeft->noOfGroups = blockSwitchingControlRight->noOfGroups = 2;
blockSwitchingControlLeft->groupLen[0] = blockSwitchingControlRight->groupLen[0] = 4;
blockSwitchingControlLeft->groupLen[1] = blockSwitchingControlRight->groupLen[1] = 4;
blockSwitchingControlLeft->noOfGroups =
blockSwitchingControlRight->noOfGroups = 2;
blockSwitchingControlLeft->groupLen[0] =
blockSwitchingControlRight->groupLen[0] = 4;
blockSwitchingControlLeft->groupLen[1] =
blockSwitchingControlRight->groupLen[1] = 4;
}
} /* Short Blocks */
}
else {
} else {
/* stereo, no common window */
if (blockSwitchingControlLeft->lastWindowSequence!=SHORT_WINDOW){
blockSwitchingControlLeft->noOfGroups = 1;
if (blockSwitchingControlLeft->lastWindowSequence != SHORT_WINDOW) {
blockSwitchingControlLeft->noOfGroups = 1;
blockSwitchingControlLeft->groupLen[0] = 1;
for (i = 1; i < MAX_NO_OF_GROUPS; i++)
{
for (i = 1; i < MAX_NO_OF_GROUPS; i++) {
blockSwitchingControlLeft->groupLen[i] = 0;
}
}
if (blockSwitchingControlRight->lastWindowSequence!=SHORT_WINDOW){
blockSwitchingControlRight->noOfGroups = 1;
if (blockSwitchingControlRight->lastWindowSequence != SHORT_WINDOW) {
blockSwitchingControlRight->noOfGroups = 1;
blockSwitchingControlRight->groupLen[0] = 1;
for (i = 1; i < MAX_NO_OF_GROUPS; i++)
{
for (i = 1; i < MAX_NO_OF_GROUPS; i++) {
blockSwitchingControlRight->groupLen[i] = 0;
}
}
} /* common window */
} else {
/* Mono */
if (blockSwitchingControlLeft->lastWindowSequence!=SHORT_WINDOW){
blockSwitchingControlLeft->noOfGroups = 1;
if (blockSwitchingControlLeft->lastWindowSequence != SHORT_WINDOW) {
blockSwitchingControlLeft->noOfGroups = 1;
blockSwitchingControlLeft->groupLen[0] = 1;
for (i = 1; i < MAX_NO_OF_GROUPS; i++)
{
for (i = 1; i < MAX_NO_OF_GROUPS; i++) {
blockSwitchingControlLeft->groupLen[i] = 0;
}
}
}
} /* allowShortFrames */
/* Translate LOWOV_WINDOW block type to a meaningful window shape. */
if ( ! blockSwitchingControlLeft->allowShortFrames ) {
if ( blockSwitchingControlLeft->lastWindowSequence != LONG_WINDOW
&& blockSwitchingControlLeft->lastWindowSequence != STOP_WINDOW )
{
if (!blockSwitchingControlLeft->allowShortFrames) {
if (blockSwitchingControlLeft->lastWindowSequence != LONG_WINDOW &&
blockSwitchingControlLeft->lastWindowSequence != STOP_WINDOW) {
blockSwitchingControlLeft->lastWindowSequence = LONG_WINDOW;
blockSwitchingControlLeft->windowShape = LOL_WINDOW;
}
}
if (nChannels == 2) {
if ( ! blockSwitchingControlRight->allowShortFrames ) {
if ( blockSwitchingControlRight->lastWindowSequence != LONG_WINDOW
&& blockSwitchingControlRight->lastWindowSequence != STOP_WINDOW )
{
if (!blockSwitchingControlRight->allowShortFrames) {
if (blockSwitchingControlRight->lastWindowSequence != LONG_WINDOW &&
blockSwitchingControlRight->lastWindowSequence != STOP_WINDOW) {
blockSwitchingControlRight->lastWindowSequence = LONG_WINDOW;
blockSwitchingControlRight->windowShape = LOL_WINDOW;
}
@ -541,5 +580,3 @@ int FDKaacEnc_SyncBlockSwitching (
return 0;
}

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,68 +90,73 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Encoder **************************
/**************************** AAC encoder library ******************************
Author(s): M. Werner
Description: Block switching
******************************************************************************/
*******************************************************************************/
#ifndef _BLOCK_SWITCH_H
#define _BLOCK_SWITCH_H
#ifndef BLOCK_SWITCH_H
#define BLOCK_SWITCH_H
#include "common_fix.h"
#include "psy_const.h"
/****************** Defines ******************************/
#define BLOCK_SWITCH_WINDOWS 8 /* number of windows for energy calculation */
#define BLOCK_SWITCH_WINDOWS 8 /* number of windows for energy calculation */
#define BLOCK_SWITCHING_IIR_LEN 2 /* Length of HighPass-IIR-Filter for Attack-Detection */
#define BLOCK_SWITCH_ENERGY_SHIFT 7 /* should be logDualis(BLOCK_SWITCH_WINDOW_LEN) to avoid overflow in windowNrgs. */
#define BLOCK_SWITCHING_IIR_LEN \
2 /* Length of HighPass-IIR-Filter for Attack-Detection */
#define BLOCK_SWITCH_ENERGY_SHIFT \
7 /* should be logDualis(BLOCK_SWITCH_WINDOW_LEN) to avoid overflow in \
windowNrgs. */
#define LAST_WINDOW 0
#define THIS_WINDOW 1
/****************** Structures ***************************/
typedef struct{
INT lastWindowSequence;
INT windowShape;
INT lastWindowShape;
UINT nBlockSwitchWindows; /* number of windows for energy calculation */
INT attack;
INT lastattack;
INT attackIndex;
INT lastAttackIndex;
INT allowShortFrames; /* for Low Delay, don't allow short frames */
INT allowLookAhead; /* for Low Delay, don't do look-ahead */
INT noOfGroups;
INT groupLen[MAX_NO_OF_GROUPS];
FIXP_DBL maxWindowNrg; /* max energy in subwindows */
typedef struct {
INT lastWindowSequence;
INT windowShape;
INT lastWindowShape;
UINT nBlockSwitchWindows; /* number of windows for energy calculation */
INT attack;
INT lastattack;
INT attackIndex;
INT lastAttackIndex;
INT allowShortFrames; /* for Low Delay, don't allow short frames */
INT allowLookAhead; /* for Low Delay, don't do look-ahead */
INT noOfGroups;
INT groupLen[MAX_NO_OF_GROUPS];
FIXP_DBL maxWindowNrg; /* max energy in subwindows */
FIXP_DBL windowNrg[2][BLOCK_SWITCH_WINDOWS]; /* time signal energy in Subwindows (last and current) */
FIXP_DBL windowNrgF[2][BLOCK_SWITCH_WINDOWS]; /* filtered time signal energy in segments (last and current) */
FIXP_DBL accWindowNrg; /* recursively accumulated windowNrgF */
FIXP_DBL
windowNrg[2][BLOCK_SWITCH_WINDOWS]; /* time signal energy in Subwindows
(last and current) */
FIXP_DBL windowNrgF[2][BLOCK_SWITCH_WINDOWS]; /* filtered time signal energy
in segments (last and
current) */
FIXP_DBL accWindowNrg; /* recursively accumulated windowNrgF */
FIXP_DBL iirStates[BLOCK_SWITCHING_IIR_LEN]; /* filter delay-line */
FIXP_DBL iirStates[BLOCK_SWITCHING_IIR_LEN]; /* filter delay-line */
} BLOCK_SWITCHING_CONTROL;
void FDKaacEnc_InitBlockSwitching(
BLOCK_SWITCHING_CONTROL *blockSwitchingControl, INT isLowDelay);
void FDKaacEnc_InitBlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, INT isLowDelay);
int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, const INT granuleLength, const int isLFE, const INT_PCM *pTimeSignal);
int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl,
const INT granuleLength, const int isLFE,
const INT_PCM *pTimeSignal);
int FDKaacEnc_SyncBlockSwitching(
BLOCK_SWITCHING_CONTROL *blockSwitchingControlLeft,
BLOCK_SWITCHING_CONTROL *blockSwitchingControlRight,
const INT noOfChannels,
const INT commonWindow);
BLOCK_SWITCHING_CONTROL *blockSwitchingControlLeft,
BLOCK_SWITCHING_CONTROL *blockSwitchingControlRight, const INT noOfChannels,
const INT commonWindow);
#endif /* #ifndef _BLOCK_SWITCH_H */
#endif /* #ifndef BLOCK_SWITCH_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,21 +90,22 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/************************* Fast MPEG AAC Audio Encoder **********************
/**************************** AAC encoder library ******************************
Initial author: A. Groeschel
contents/description: channel mapping functionality
Author(s): A. Groeschel
******************************************************************************/
Description: channel mapping functionality
*******************************************************************************/
#include "channel_map.h"
#include "bitenc.h"
#include "psy_const.h"
#include "qc_data.h"
#include "aacEnc_ram.h"
#include "FDK_tools_rom.h"
/* channel_assignment treats the relationship of Input file channels
to the encoder channels.
@ -121,369 +133,464 @@ amm-info@iis.fraunhofer.de
LFE 3 5 (LFE)
*/
typedef struct {
CHANNEL_MODE encoderMode;
INT channel_assignment[/*(8)*/12];
} CHANNEL_ASSIGNMENT_INFO_TAB;
static const CHANNEL_ASSIGNMENT_INFO_TAB assignmentInfoTabMpeg[] =
{
{ MODE_INVALID, {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1} }, /* invalid */
{ MODE_1, { 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1} }, /* mono */
{ MODE_2, { 0, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1} }, /* stereo */
{ MODE_1_2, { 0, 1, 2,-1,-1,-1,-1,-1,-1,-1,-1,-1} }, /* 3ch */
{ MODE_1_2_1, { 0, 1, 2, 3,-1,-1,-1,-1,-1,-1,-1,-1} }, /* 4ch */
{ MODE_1_2_2, { 0, 1, 2, 3, 4,-1,-1,-1,-1,-1,-1,-1} }, /* 5ch */
{ MODE_1_2_2_1, { 0, 1, 2, 3, 4, 5,-1,-1,-1,-1,-1,-1} }, /* 5.1ch */
{ MODE_1_2_2_2_1, { 0, 1, 2, 3, 4, 5, 6, 7,-1,-1,-1,-1} }, /* 7.1ch */
{ MODE_7_1_REAR_SURROUND, { 0, 1, 2, 3, 4, 5, 6, 7,-1,-1,-1,-1} }, /* 7.1ch */
{ MODE_7_1_FRONT_CENTER, { 0, 1, 2, 3, 4, 5, 6, 7,-1,-1,-1,-1} } /* 7.1ch */
};
static const CHANNEL_ASSIGNMENT_INFO_TAB assignmentInfoTabWav[] =
{
{ MODE_INVALID, {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1} }, /* invalid */
{ MODE_1, { 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1} }, /* mono */
{ MODE_2, { 0, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1} }, /* stereo */
{ MODE_1_2, { 2, 0, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1} }, /* 3ch */
{ MODE_1_2_1, { 2, 0, 1, 3,-1,-1,-1,-1,-1,-1,-1,-1} }, /* 4ch */
{ MODE_1_2_2, { 2, 0, 1, 3, 4,-1,-1,-1,-1,-1,-1,-1} }, /* 5ch */
{ MODE_1_2_2_1, { 2, 0, 1, 4, 5, 3,-1,-1,-1,-1,-1,-1} }, /* 5.1ch */
{ MODE_1_2_2_2_1, { 2, 6, 7, 0, 1, 4, 5, 3,-1,-1,-1,-1} }, /* 7.1ch */
{ MODE_7_1_REAR_SURROUND, { 2, 0, 1, 6, 7, 4, 5, 3,-1,-1,-1,-1} }, /* 7.1ch */
{ MODE_7_1_FRONT_CENTER, { 2, 6, 7, 0, 1, 4, 5, 3,-1,-1,-1,-1} }, /* 7.1ch */
};
/* Channel mode configuration tab provides,
corresponding number of channels and elements
*/
static const CHANNEL_MODE_CONFIG_TAB channelModeConfig[] =
{
{ MODE_1, 1, 1, 1 }, /* SCE */
{ MODE_2, 2, 2, 1 }, /* CPE */
{ MODE_1_2, 3, 3, 2 }, /* SCE,CPE */
{ MODE_1_2_1, 4, 4, 3 }, /* SCE,CPE,SCE */
{ MODE_1_2_2, 5, 5, 3 }, /* SCE,CPE,CPE */
{ MODE_1_2_2_1, 6, 5, 4 }, /* SCE,CPE,CPE,LFE */
{ MODE_1_2_2_2_1, 8, 7, 5 }, /* SCE,CPE,CPE,CPE,LFE */
{ MODE_7_1_REAR_SURROUND, 8, 7, 5 },
{ MODE_7_1_FRONT_CENTER, 8, 7, 5 },
static const CHANNEL_MODE_CONFIG_TAB channelModeConfig[] = {
{MODE_1, 1, 1, 1}, /* chCfg 1, SCE */
{MODE_2, 2, 2, 1}, /* chCfg 2, CPE */
{MODE_1_2, 3, 3, 2}, /* chCfg 3, SCE,CPE */
{MODE_1_2_1, 4, 4, 3}, /* chCfg 4, SCE,CPE,SCE */
{MODE_1_2_2, 5, 5, 3}, /* chCfg 5, SCE,CPE,CPE */
{MODE_1_2_2_1, 6, 5, 4}, /* chCfg 6, SCE,CPE,CPE,LFE */
{MODE_1_2_2_2_1, 8, 7, 5}, /* chCfg 7, SCE,CPE,CPE,CPE,LFE */
{MODE_6_1, 7, 6, 5}, /* chCfg 11, SCE,CPE,CPE,SCE,LFE */
{MODE_7_1_BACK, 8, 7, 5}, /* chCfg 12, SCE,CPE,CPE,CPE,LFE */
{MODE_7_1_TOP_FRONT, 8, 7, 5}, /* chCfg 14, SCE,CPE,CPE,LFE,CPE */
{MODE_7_1_REAR_SURROUND, 8, 7,
5}, /* same as MODE_7_1_BACK, SCE,CPE,CPE,CPE,LFE */
{MODE_7_1_FRONT_CENTER, 8, 7,
5}, /* same as MODE_1_2_2_2_1, SCE,CPE,CPE,CPE,LFE */
};
#define MAX_MODES (sizeof(assignmentInfoTabWav)/sizeof(CHANNEL_ASSIGNMENT_INFO_TAB))
const INT* FDKaacEnc_getChannelAssignment(CHANNEL_MODE encMode, CHANNEL_ORDER co)
{
const CHANNEL_ASSIGNMENT_INFO_TAB *pTab;
int i;
if (co == CH_ORDER_MPEG)
pTab = assignmentInfoTabMpeg;
else
pTab = assignmentInfoTabWav;
for(i=MAX_MODES-1; i>0; i--) {
if (encMode== pTab[i].encoderMode) {
break;
}
}
return (pTab[i].channel_assignment);
}
AAC_ENCODER_ERROR FDKaacEnc_DetermineEncoderMode(CHANNEL_MODE* mode, INT nChannels)
{
AAC_ENCODER_ERROR FDKaacEnc_DetermineEncoderMode(CHANNEL_MODE* mode,
INT nChannels) {
INT i;
CHANNEL_MODE encMode = MODE_INVALID;
if (*mode==MODE_UNKNOWN) {
for (i=0; i<(INT)sizeof(channelModeConfig)/(INT)sizeof(CHANNEL_MODE_CONFIG_TAB); i++) {
if (channelModeConfig[i].nChannels==nChannels) {
encMode = channelModeConfig[i].encMode;
break;
if (*mode == MODE_UNKNOWN) {
for (i = 0; i < (INT)sizeof(channelModeConfig) /
(INT)sizeof(CHANNEL_MODE_CONFIG_TAB);
i++) {
if (channelModeConfig[i].nChannels == nChannels) {
encMode = channelModeConfig[i].encMode;
break;
}
}
*mode = encMode;
}
else {
} else {
/* check if valid channel configuration */
if (FDKaacEnc_GetChannelModeConfiguration(*mode)->nChannels==nChannels) {
encMode = *mode;
if (FDKaacEnc_GetChannelModeConfiguration(*mode)->nChannels == nChannels) {
encMode = *mode;
}
}
if (encMode==MODE_INVALID) {
if (encMode == MODE_INVALID) {
return AAC_ENC_UNSUPPORTED_CHANNELCONFIG;
}
return AAC_ENC_OK;
}
static INT FDKaacEnc_initElement (ELEMENT_INFO* elInfo, MP4_ELEMENT_ID elType, INT* cnt, CHANNEL_MODE mode, CHANNEL_ORDER co, INT* it_cnt, const FIXP_DBL relBits) {
static INT FDKaacEnc_initElement(ELEMENT_INFO* elInfo, MP4_ELEMENT_ID elType,
INT* cnt, FDK_channelMapDescr* mapDescr,
UINT mapIdx, INT* it_cnt,
const FIXP_DBL relBits) {
INT error = 0;
INT counter = *cnt;
INT error=0;
INT counter =*cnt;
const INT *assign = FDKaacEnc_getChannelAssignment(mode, co);
elInfo->elType=elType;
elInfo->elType = elType;
elInfo->relativeBits = relBits;
switch(elInfo->elType) {
case ID_SCE: case ID_LFE: case ID_CCE:
elInfo->nChannelsInEl=1;
elInfo->ChannelIndex[0]=assign[counter++];
elInfo->instanceTag=it_cnt[elType]++;
break;
case ID_CPE:
elInfo->nChannelsInEl=2;
elInfo->ChannelIndex[0]=assign[counter++];
elInfo->ChannelIndex[1]=assign[counter++];
elInfo->instanceTag=it_cnt[elType]++;
break;
case ID_DSE:
elInfo->nChannelsInEl=0;
elInfo->ChannelIndex[0]=0;
elInfo->ChannelIndex[1]=0;
elInfo->instanceTag=it_cnt[elType]++;
break;
default: error=1;
switch (elInfo->elType) {
case ID_SCE:
case ID_LFE:
case ID_CCE:
elInfo->nChannelsInEl = 1;
elInfo->ChannelIndex[0] =
FDK_chMapDescr_getMapValue(mapDescr, counter++, mapIdx);
elInfo->instanceTag = it_cnt[elType]++;
break;
case ID_CPE:
elInfo->nChannelsInEl = 2;
elInfo->ChannelIndex[0] =
FDK_chMapDescr_getMapValue(mapDescr, counter++, mapIdx);
elInfo->ChannelIndex[1] =
FDK_chMapDescr_getMapValue(mapDescr, counter++, mapIdx);
elInfo->instanceTag = it_cnt[elType]++;
break;
case ID_DSE:
elInfo->nChannelsInEl = 0;
elInfo->ChannelIndex[0] = 0;
elInfo->ChannelIndex[1] = 0;
elInfo->instanceTag = it_cnt[elType]++;
break;
default:
error = 1;
};
*cnt = counter;
return error;
}
AAC_ENCODER_ERROR FDKaacEnc_InitChannelMapping(CHANNEL_MODE mode, CHANNEL_ORDER co, CHANNEL_MAPPING* cm)
{
INT count=0; /* count through coder channels */
INT it_cnt[ID_END+1];
AAC_ENCODER_ERROR FDKaacEnc_InitChannelMapping(CHANNEL_MODE mode,
CHANNEL_ORDER co,
CHANNEL_MAPPING* cm) {
INT count = 0; /* count through coder channels */
INT it_cnt[ID_END + 1];
INT i;
UINT mapIdx;
FDK_channelMapDescr mapDescr;
for (i=0; i<ID_END; i++)
it_cnt[i]=0;
for (i = 0; i < ID_END; i++) it_cnt[i] = 0;
FDKmemclear(cm, sizeof(CHANNEL_MAPPING));
/* init channel mapping*/
for (i=0; i<(INT)sizeof(channelModeConfig)/(INT)sizeof(CHANNEL_MODE_CONFIG_TAB); i++) {
if (channelModeConfig[i].encMode==mode)
{
cm->encMode = channelModeConfig[i].encMode;
cm->nChannels = channelModeConfig[i].nChannels;
cm->nChannelsEff = channelModeConfig[i].nChannelsEff;
cm->nElements = channelModeConfig[i].nElements;
for (i = 0; i < (INT)sizeof(channelModeConfig) /
(INT)sizeof(CHANNEL_MODE_CONFIG_TAB);
i++) {
if (channelModeConfig[i].encMode == mode) {
cm->encMode = channelModeConfig[i].encMode;
cm->nChannels = channelModeConfig[i].nChannels;
cm->nChannelsEff = channelModeConfig[i].nChannelsEff;
cm->nElements = channelModeConfig[i].nElements;
break;
break;
}
}
/* init map descriptor */
FDK_chMapDescr_init(&mapDescr, NULL, 0, (co == CH_ORDER_MPEG) ? 1 : 0);
switch (mode) {
case MODE_7_1_REAR_SURROUND: /* MODE_7_1_REAR_SURROUND is equivalent to
MODE_7_1_BACK */
mapIdx = (INT)MODE_7_1_BACK;
break;
case MODE_7_1_FRONT_CENTER: /* MODE_7_1_FRONT_CENTER is equivalent to
MODE_1_2_2_2_1 */
mapIdx = (INT)MODE_1_2_2_2_1;
break;
default:
mapIdx =
(INT)mode > 14
? 0
: (INT)
mode; /* if channel config > 14 MPEG mapping will be used */
}
/* init element info struct */
switch(mode) {
switch (mode) {
case MODE_1:
/* (mono) sce */
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, mode, co, it_cnt, (FIXP_DBL)MAXVAL_DBL);
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, &mapDescr, mapIdx,
it_cnt, (FIXP_DBL)MAXVAL_DBL);
break;
case MODE_2:
/* (stereo) cpe */
FDKaacEnc_initElement(&cm->elInfo[0], ID_CPE, &count, mode, co, it_cnt, (FIXP_DBL)MAXVAL_DBL);
FDKaacEnc_initElement(&cm->elInfo[0], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, (FIXP_DBL)MAXVAL_DBL);
break;
case MODE_1_2:
/* sce + cpe */
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.4f));
FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.6f));
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.4f));
FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.6f));
break;
case MODE_1_2_1:
/* sce + cpe + sce */
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.3f));
FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.4f));
FDKaacEnc_initElement(&cm->elInfo[2], ID_SCE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.3f));
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.3f));
FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.4f));
FDKaacEnc_initElement(&cm->elInfo[2], ID_SCE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.3f));
break;
case MODE_1_2_2:
/* sce + cpe + cpe */
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.26f));
FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.37f));
FDKaacEnc_initElement(&cm->elInfo[2], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.37f));
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.26f));
FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.37f));
FDKaacEnc_initElement(&cm->elInfo[2], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.37f));
break;
case MODE_1_2_2_1:
/* (5.1) sce + cpe + cpe + lfe */
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.24f));
FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.35f));
FDKaacEnc_initElement(&cm->elInfo[2], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.35f));
FDKaacEnc_initElement(&cm->elInfo[3], ID_LFE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.06f));
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.24f));
FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.35f));
FDKaacEnc_initElement(&cm->elInfo[2], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.35f));
FDKaacEnc_initElement(&cm->elInfo[3], ID_LFE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.06f));
break;
case MODE_6_1:
/* (6.1) sce + cpe + cpe + sce + lfe */
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.2f));
FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.275f));
FDKaacEnc_initElement(&cm->elInfo[2], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.275f));
FDKaacEnc_initElement(&cm->elInfo[3], ID_SCE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.2f));
FDKaacEnc_initElement(&cm->elInfo[4], ID_LFE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.05f));
break;
case MODE_1_2_2_2_1:
case MODE_7_1_BACK:
case MODE_7_1_TOP_FRONT:
case MODE_7_1_REAR_SURROUND:
case MODE_7_1_FRONT_CENTER:
case MODE_7_1_FRONT_CENTER: {
/* (7.1) sce + cpe + cpe + cpe + lfe */
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.18f));
FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.26f));
FDKaacEnc_initElement(&cm->elInfo[2], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.26f));
FDKaacEnc_initElement(&cm->elInfo[3], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.26f));
FDKaacEnc_initElement(&cm->elInfo[4], ID_LFE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.04f));
/* (7.1 top) sce + cpe + cpe + lfe + cpe */
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.18f));
FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.26f));
FDKaacEnc_initElement(&cm->elInfo[2], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.26f));
if (mode != MODE_7_1_TOP_FRONT) {
FDKaacEnc_initElement(&cm->elInfo[3], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.26f));
FDKaacEnc_initElement(&cm->elInfo[4], ID_LFE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.04f));
} else {
FDKaacEnc_initElement(&cm->elInfo[3], ID_LFE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.04f));
FDKaacEnc_initElement(&cm->elInfo[4], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.26f));
}
break;
}
default:
//*chMap=0;
return AAC_ENC_UNSUPPORTED_CHANNELCONFIG;
};
FDK_ASSERT(cm->nElements<=(8));
FDK_ASSERT(cm->nElements <= ((8)));
return AAC_ENC_OK;
}
AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE *hQC,
CHANNEL_MAPPING *cm,
INT bitrateTot,
INT averageBitsTot,
INT maxChannelBits)
{
AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE* hQC, CHANNEL_MAPPING* cm,
INT bitrateTot, INT averageBitsTot,
INT maxChannelBits) {
int sc_brTot = CountLeadingBits(bitrateTot);
switch(cm->encMode) {
case MODE_1:
hQC->elementBits[0]->chBitrateEl = bitrateTot;
switch (cm->encMode) {
case MODE_1:
hQC->elementBits[0]->chBitrateEl = bitrateTot;
hQC->elementBits[0]->maxBitsEl = maxChannelBits;
hQC->elementBits[0]->maxBitsEl = maxChannelBits;
hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits;
break;
hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits;
break;
case MODE_2:
hQC->elementBits[0]->chBitrateEl = bitrateTot>>1;
case MODE_2:
hQC->elementBits[0]->chBitrateEl = bitrateTot >> 1;
hQC->elementBits[0]->maxBitsEl = 2*maxChannelBits;
hQC->elementBits[0]->maxBitsEl = 2 * maxChannelBits;
hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits;
break;
case MODE_1_2: {
hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits;
hQC->elementBits[1]->relativeBitsEl = cm->elInfo[1].relativeBits;
FIXP_DBL sceRate = cm->elInfo[0].relativeBits;
FIXP_DBL cpeRate = cm->elInfo[1].relativeBits;
hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits;
break;
case MODE_1_2: {
hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits;
hQC->elementBits[1]->relativeBitsEl = cm->elInfo[1].relativeBits;
FIXP_DBL sceRate = cm->elInfo[0].relativeBits;
FIXP_DBL cpeRate = cm->elInfo[1].relativeBits;
hQC->elementBits[0]->chBitrateEl = fMult(sceRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot;
hQC->elementBits[1]->chBitrateEl = fMult(cpeRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1);
hQC->elementBits[0]->chBitrateEl =
fMult(sceRate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> sc_brTot;
hQC->elementBits[1]->chBitrateEl =
fMult(cpeRate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[0]->maxBitsEl = maxChannelBits;
hQC->elementBits[1]->maxBitsEl = 2*maxChannelBits;
break;
}
case MODE_1_2_1: {
/* sce + cpe + sce */
hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits;
hQC->elementBits[1]->relativeBitsEl = cm->elInfo[1].relativeBits;
hQC->elementBits[2]->relativeBitsEl = cm->elInfo[2].relativeBits;
FIXP_DBL sce1Rate = cm->elInfo[0].relativeBits;
FIXP_DBL cpeRate = cm->elInfo[1].relativeBits;
FIXP_DBL sce2Rate = cm->elInfo[2].relativeBits;
hQC->elementBits[0]->maxBitsEl = maxChannelBits;
hQC->elementBits[1]->maxBitsEl = 2 * maxChannelBits;
break;
}
case MODE_1_2_1: {
/* sce + cpe + sce */
hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits;
hQC->elementBits[1]->relativeBitsEl = cm->elInfo[1].relativeBits;
hQC->elementBits[2]->relativeBitsEl = cm->elInfo[2].relativeBits;
FIXP_DBL sce1Rate = cm->elInfo[0].relativeBits;
FIXP_DBL cpeRate = cm->elInfo[1].relativeBits;
FIXP_DBL sce2Rate = cm->elInfo[2].relativeBits;
hQC->elementBits[0]->chBitrateEl = fMult(sce1Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot;
hQC->elementBits[1]->chBitrateEl = fMult(cpeRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1);
hQC->elementBits[2]->chBitrateEl = fMult(sce2Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot;
hQC->elementBits[0]->chBitrateEl =
fMult(sce1Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> sc_brTot;
hQC->elementBits[1]->chBitrateEl =
fMult(cpeRate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[2]->chBitrateEl =
fMult(sce2Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> sc_brTot;
hQC->elementBits[0]->maxBitsEl = maxChannelBits;
hQC->elementBits[1]->maxBitsEl = 2*maxChannelBits;
hQC->elementBits[2]->maxBitsEl = maxChannelBits;
break;
}
case MODE_1_2_2: {
/* sce + cpe + cpe */
hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits;
hQC->elementBits[1]->relativeBitsEl = cm->elInfo[1].relativeBits;
hQC->elementBits[2]->relativeBitsEl = cm->elInfo[2].relativeBits;
FIXP_DBL sceRate = cm->elInfo[0].relativeBits;
FIXP_DBL cpe1Rate = cm->elInfo[1].relativeBits;
FIXP_DBL cpe2Rate = cm->elInfo[2].relativeBits;
hQC->elementBits[0]->maxBitsEl = maxChannelBits;
hQC->elementBits[1]->maxBitsEl = 2 * maxChannelBits;
hQC->elementBits[2]->maxBitsEl = maxChannelBits;
break;
}
case MODE_1_2_2: {
/* sce + cpe + cpe */
hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits;
hQC->elementBits[1]->relativeBitsEl = cm->elInfo[1].relativeBits;
hQC->elementBits[2]->relativeBitsEl = cm->elInfo[2].relativeBits;
FIXP_DBL sceRate = cm->elInfo[0].relativeBits;
FIXP_DBL cpe1Rate = cm->elInfo[1].relativeBits;
FIXP_DBL cpe2Rate = cm->elInfo[2].relativeBits;
hQC->elementBits[0]->chBitrateEl = fMult(sceRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot;
hQC->elementBits[1]->chBitrateEl = fMult(cpe1Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1);
hQC->elementBits[2]->chBitrateEl = fMult(cpe2Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1);
hQC->elementBits[0]->chBitrateEl =
fMult(sceRate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> sc_brTot;
hQC->elementBits[1]->chBitrateEl =
fMult(cpe1Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[2]->chBitrateEl =
fMult(cpe2Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[0]->maxBitsEl = maxChannelBits;
hQC->elementBits[1]->maxBitsEl = 2*maxChannelBits;
hQC->elementBits[2]->maxBitsEl = 2*maxChannelBits;
break;
}
hQC->elementBits[0]->maxBitsEl = maxChannelBits;
hQC->elementBits[1]->maxBitsEl = 2 * maxChannelBits;
hQC->elementBits[2]->maxBitsEl = 2 * maxChannelBits;
break;
}
case MODE_1_2_2_1: {
/* (5.1) sce + cpe + cpe + lfe */
hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits;
hQC->elementBits[1]->relativeBitsEl = cm->elInfo[1].relativeBits;
hQC->elementBits[2]->relativeBitsEl = cm->elInfo[2].relativeBits;
hQC->elementBits[3]->relativeBitsEl = cm->elInfo[3].relativeBits;
FIXP_DBL sceRate = cm->elInfo[0].relativeBits;
FIXP_DBL cpe1Rate = cm->elInfo[1].relativeBits;
FIXP_DBL cpe2Rate = cm->elInfo[2].relativeBits;
FIXP_DBL lfeRate = cm->elInfo[3].relativeBits;
case MODE_1_2_2_1: {
/* (5.1) sce + cpe + cpe + lfe */
hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits;
hQC->elementBits[1]->relativeBitsEl = cm->elInfo[1].relativeBits;
hQC->elementBits[2]->relativeBitsEl = cm->elInfo[2].relativeBits;
hQC->elementBits[3]->relativeBitsEl = cm->elInfo[3].relativeBits;
FIXP_DBL sceRate = cm->elInfo[0].relativeBits;
FIXP_DBL cpe1Rate = cm->elInfo[1].relativeBits;
FIXP_DBL cpe2Rate = cm->elInfo[2].relativeBits;
FIXP_DBL lfeRate = cm->elInfo[3].relativeBits;
int maxBitsTot =
maxChannelBits * 5; /* LFE does not add to bit reservoir */
int sc = CountLeadingBits(fixMax(maxChannelBits, averageBitsTot));
int maxLfeBits = (int)fMax(
(INT)((fMult(lfeRate, (FIXP_DBL)(maxChannelBits << sc)) >> sc) << 1),
(INT)((fMult(FL2FXCONST_DBL(1.1f / 2.f),
fMult(lfeRate, (FIXP_DBL)(averageBitsTot << sc)))
<< 1) >>
sc));
int maxBitsTot = maxChannelBits * 5; /* LFE does not add to bit reservoir */
int sc = CountLeadingBits(fixMax(maxChannelBits,averageBitsTot));
int maxLfeBits = (int) FDKmax ( (INT)((fMult(lfeRate,(FIXP_DBL)(maxChannelBits<<sc))>>sc)<<1),
(INT)((fMult(FL2FXCONST_DBL(1.1f/2.f),fMult(lfeRate,(FIXP_DBL)(averageBitsTot<<sc)))<<1)>>sc) );
maxChannelBits = (maxBitsTot - maxLfeBits);
sc = CountLeadingBits(maxChannelBits);
maxChannelBits = (maxBitsTot - maxLfeBits);
sc = CountLeadingBits(maxChannelBits);
maxChannelBits =
fMult((FIXP_DBL)maxChannelBits << sc, GetInvInt(5)) >> sc;
maxChannelBits = fMult((FIXP_DBL)maxChannelBits<<sc,GetInvInt(5))>>sc;
hQC->elementBits[0]->chBitrateEl =
fMult(sceRate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> sc_brTot;
hQC->elementBits[1]->chBitrateEl =
fMult(cpe1Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[2]->chBitrateEl =
fMult(cpe2Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[3]->chBitrateEl =
fMult(lfeRate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> sc_brTot;
hQC->elementBits[0]->chBitrateEl = fMult(sceRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot;
hQC->elementBits[1]->chBitrateEl = fMult(cpe1Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1);
hQC->elementBits[2]->chBitrateEl = fMult(cpe2Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1);
hQC->elementBits[3]->chBitrateEl = fMult(lfeRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot;
hQC->elementBits[0]->maxBitsEl = maxChannelBits;
hQC->elementBits[1]->maxBitsEl = 2 * maxChannelBits;
hQC->elementBits[2]->maxBitsEl = 2 * maxChannelBits;
hQC->elementBits[3]->maxBitsEl = maxLfeBits;
hQC->elementBits[0]->maxBitsEl = maxChannelBits;
hQC->elementBits[1]->maxBitsEl = 2*maxChannelBits;
hQC->elementBits[2]->maxBitsEl = 2*maxChannelBits;
hQC->elementBits[3]->maxBitsEl = maxLfeBits;
break;
}
case MODE_6_1: {
/* (6.1) sce + cpe + cpe + sce + lfe */
FIXP_DBL sceRate = hQC->elementBits[0]->relativeBitsEl =
cm->elInfo[0].relativeBits;
FIXP_DBL cpe1Rate = hQC->elementBits[1]->relativeBitsEl =
cm->elInfo[1].relativeBits;
FIXP_DBL cpe2Rate = hQC->elementBits[2]->relativeBitsEl =
cm->elInfo[2].relativeBits;
FIXP_DBL sce2Rate = hQC->elementBits[3]->relativeBitsEl =
cm->elInfo[3].relativeBits;
FIXP_DBL lfeRate = hQC->elementBits[4]->relativeBitsEl =
cm->elInfo[4].relativeBits;
break;
}
case MODE_7_1_REAR_SURROUND:
case MODE_7_1_FRONT_CENTER:
case MODE_1_2_2_2_1: {
int cpe3Idx = 3;
int lfeIdx = 4;
int maxBitsTot =
maxChannelBits * 6; /* LFE does not add to bit reservoir */
int sc = CountLeadingBits(fixMax(maxChannelBits, averageBitsTot));
int maxLfeBits = (int)fMax(
(INT)((fMult(lfeRate, (FIXP_DBL)(maxChannelBits << sc)) >> sc) << 1),
(INT)((fMult(FL2FXCONST_DBL(1.1f / 2.f),
fMult(lfeRate, (FIXP_DBL)(averageBitsTot << sc)))
<< 1) >>
sc));
/* (7.1) sce + cpe + cpe + cpe + lfe */
FIXP_DBL sceRate = hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits;
FIXP_DBL cpe1Rate = hQC->elementBits[1]->relativeBitsEl = cm->elInfo[1].relativeBits;
FIXP_DBL cpe2Rate = hQC->elementBits[2]->relativeBitsEl = cm->elInfo[2].relativeBits;
FIXP_DBL cpe3Rate = hQC->elementBits[cpe3Idx]->relativeBitsEl = cm->elInfo[cpe3Idx].relativeBits;
FIXP_DBL lfeRate = hQC->elementBits[lfeIdx]->relativeBitsEl = cm->elInfo[lfeIdx].relativeBits;
maxChannelBits = (maxBitsTot - maxLfeBits) / 6;
int maxBitsTot = maxChannelBits * 7; /* LFE does not add to bit reservoir */
int sc = CountLeadingBits(fixMax(maxChannelBits,averageBitsTot));
int maxLfeBits = (int) FDKmax ( (INT)((fMult(lfeRate,(FIXP_DBL)(maxChannelBits<<sc))>>sc)<<1),
(INT)((fMult(FL2FXCONST_DBL(1.1f/2.f),fMult(lfeRate,(FIXP_DBL)(averageBitsTot<<sc)))<<1)>>sc) );
hQC->elementBits[0]->chBitrateEl =
fMult(sceRate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> sc_brTot;
hQC->elementBits[1]->chBitrateEl =
fMult(cpe1Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[2]->chBitrateEl =
fMult(cpe2Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[3]->chBitrateEl =
fMult(sce2Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[4]->chBitrateEl =
fMult(lfeRate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> sc_brTot;
maxChannelBits = (maxBitsTot - maxLfeBits) / 7;
hQC->elementBits[0]->maxBitsEl = maxChannelBits;
hQC->elementBits[1]->maxBitsEl = 2 * maxChannelBits;
hQC->elementBits[2]->maxBitsEl = 2 * maxChannelBits;
hQC->elementBits[3]->maxBitsEl = maxChannelBits;
hQC->elementBits[4]->maxBitsEl = maxLfeBits;
break;
}
case MODE_7_1_TOP_FRONT:
case MODE_7_1_BACK:
case MODE_7_1_REAR_SURROUND:
case MODE_7_1_FRONT_CENTER:
case MODE_1_2_2_2_1: {
int cpe3Idx = (cm->encMode != MODE_7_1_TOP_FRONT) ? 3 : 4;
int lfeIdx = (cm->encMode != MODE_7_1_TOP_FRONT) ? 4 : 3;
hQC->elementBits[0]->chBitrateEl = fMult(sceRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot;
hQC->elementBits[1]->chBitrateEl = fMult(cpe1Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1);
hQC->elementBits[2]->chBitrateEl = fMult(cpe2Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1);
hQC->elementBits[cpe3Idx]->chBitrateEl = fMult(cpe3Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1);
hQC->elementBits[lfeIdx]->chBitrateEl = fMult(lfeRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot;
/* (7.1) sce + cpe + cpe + cpe + lfe */
FIXP_DBL sceRate = hQC->elementBits[0]->relativeBitsEl =
cm->elInfo[0].relativeBits;
FIXP_DBL cpe1Rate = hQC->elementBits[1]->relativeBitsEl =
cm->elInfo[1].relativeBits;
FIXP_DBL cpe2Rate = hQC->elementBits[2]->relativeBitsEl =
cm->elInfo[2].relativeBits;
FIXP_DBL cpe3Rate = hQC->elementBits[cpe3Idx]->relativeBitsEl =
cm->elInfo[cpe3Idx].relativeBits;
FIXP_DBL lfeRate = hQC->elementBits[lfeIdx]->relativeBitsEl =
cm->elInfo[lfeIdx].relativeBits;
hQC->elementBits[0]->maxBitsEl = maxChannelBits;
hQC->elementBits[1]->maxBitsEl = 2*maxChannelBits;
hQC->elementBits[2]->maxBitsEl = 2*maxChannelBits;
hQC->elementBits[cpe3Idx]->maxBitsEl = 2*maxChannelBits;
hQC->elementBits[lfeIdx]->maxBitsEl = maxLfeBits;
break;
}
default:
return AAC_ENC_UNSUPPORTED_CHANNELCONFIG;
int maxBitsTot =
maxChannelBits * 7; /* LFE does not add to bit reservoir */
int sc = CountLeadingBits(fixMax(maxChannelBits, averageBitsTot));
int maxLfeBits = (int)fMax(
(INT)((fMult(lfeRate, (FIXP_DBL)(maxChannelBits << sc)) >> sc) << 1),
(INT)((fMult(FL2FXCONST_DBL(1.1f / 2.f),
fMult(lfeRate, (FIXP_DBL)(averageBitsTot << sc)))
<< 1) >>
sc));
maxChannelBits = (maxBitsTot - maxLfeBits) / 7;
hQC->elementBits[0]->chBitrateEl =
fMult(sceRate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> sc_brTot;
hQC->elementBits[1]->chBitrateEl =
fMult(cpe1Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[2]->chBitrateEl =
fMult(cpe2Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[cpe3Idx]->chBitrateEl =
fMult(cpe3Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[lfeIdx]->chBitrateEl =
fMult(lfeRate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> sc_brTot;
hQC->elementBits[0]->maxBitsEl = maxChannelBits;
hQC->elementBits[1]->maxBitsEl = 2 * maxChannelBits;
hQC->elementBits[2]->maxBitsEl = 2 * maxChannelBits;
hQC->elementBits[cpe3Idx]->maxBitsEl = 2 * maxChannelBits;
hQC->elementBits[lfeIdx]->maxBitsEl = maxLfeBits;
break;
}
default:
return AAC_ENC_UNSUPPORTED_CHANNELCONFIG;
}
return AAC_ENC_OK;
@ -491,61 +598,66 @@ AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE *hQC,
/********************************************************************************/
/* */
/* function: GetMonoStereoMODE(const CHANNEL_MODE mode) */
/* function: GetMonoStereoMODE(const CHANNEL_MODE mode) */
/* */
/* description: Determines encoder setting from channel mode. */
/* Multichannel modes are mapped to mono or stereo modes */
/* description: Determines encoder setting from channel mode. */
/* Multichannel modes are mapped to mono or stereo modes */
/* returns MODE_MONO in case of mono, */
/* MODE_STEREO in case of stereo */
/* MODE_INVALID in case of error */
/* */
/* input: CHANNEL_MODE mode: Encoder mode (see qc_data.h). */
/* output: return: CM_STEREO_MODE monoStereoSetting */
/* input: CHANNEL_MODE mode: Encoder mode (see qc_data.h). */
/* output: return: CM_STEREO_MODE monoStereoSetting */
/* (MODE_INVALID: error, */
/* MODE_MONO: mono */
/* MODE_STEREO: stereo). */
/* */
/* misc: No memory is allocated. */
/* misc: No memory is allocated. */
/* */
/********************************************************************************/
ELEMENT_MODE FDKaacEnc_GetMonoStereoMode(const CHANNEL_MODE mode){
ELEMENT_MODE FDKaacEnc_GetMonoStereoMode(const CHANNEL_MODE mode) {
ELEMENT_MODE monoStereoSetting = EL_MODE_INVALID;
switch(mode){
case MODE_1: /* mono setups */
monoStereoSetting = EL_MODE_MONO;
break;
case MODE_2: /* stereo setups */
case MODE_1_2:
case MODE_1_2_1:
case MODE_1_2_2:
case MODE_1_2_2_1:
case MODE_1_2_2_2_1:
case MODE_7_1_REAR_SURROUND:
case MODE_7_1_FRONT_CENTER:
monoStereoSetting = EL_MODE_STEREO;
break;
default: /* error */
monoStereoSetting = EL_MODE_INVALID;
break;
switch (mode) {
case MODE_1: /* mono setups */
monoStereoSetting = EL_MODE_MONO;
break;
case MODE_2: /* stereo setups */
case MODE_1_2:
case MODE_1_2_1:
case MODE_1_2_2:
case MODE_1_2_2_1:
case MODE_6_1:
case MODE_1_2_2_2_1:
case MODE_7_1_REAR_SURROUND:
case MODE_7_1_FRONT_CENTER:
case MODE_7_1_BACK:
case MODE_7_1_TOP_FRONT:
monoStereoSetting = EL_MODE_STEREO;
break;
default: /* error */
monoStereoSetting = EL_MODE_INVALID;
break;
}
return monoStereoSetting;
}
const CHANNEL_MODE_CONFIG_TAB* FDKaacEnc_GetChannelModeConfiguration(const CHANNEL_MODE mode)
{
const CHANNEL_MODE_CONFIG_TAB* FDKaacEnc_GetChannelModeConfiguration(
const CHANNEL_MODE mode) {
INT i;
const CHANNEL_MODE_CONFIG_TAB *cm_config = NULL;
const CHANNEL_MODE_CONFIG_TAB* cm_config = NULL;
/* get channel mode config */
for (i=0; i<(INT)sizeof(channelModeConfig)/(INT)sizeof(CHANNEL_MODE_CONFIG_TAB); i++) {
if (channelModeConfig[i].encMode==mode)
{
cm_config = &channelModeConfig[i];
break;
for (i = 0; i < (INT)sizeof(channelModeConfig) /
(INT)sizeof(CHANNEL_MODE_CONFIG_TAB);
i++) {
if (channelModeConfig[i].encMode == mode) {
cm_config = &channelModeConfig[i];
break;
}
}
return cm_config;

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,18 +90,18 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/************************* Fast MPEG AAC Audio Encoder **********************
/**************************** AAC encoder library ******************************
Initial author: A. Groeschel
contents/description: channel mapping functionality
Author(s): A. Groeschel
******************************************************************************/
Description: channel mapping functionality
#ifndef _CHANNEL_MAP_H
#define _CHANNEL_MAP_H
*******************************************************************************/
#ifndef CHANNEL_MAP_H
#define CHANNEL_MAP_H
#include "aacenc.h"
#include "psy_const.h"
@ -103,14 +114,8 @@ typedef struct {
INT nElements;
} CHANNEL_MODE_CONFIG_TAB;
/* Element mode */
typedef enum {
EL_MODE_INVALID = 0,
EL_MODE_MONO,
EL_MODE_STEREO
} ELEMENT_MODE;
typedef enum { EL_MODE_INVALID = 0, EL_MODE_MONO, EL_MODE_STEREO } ELEMENT_MODE;
AAC_ENCODER_ERROR FDKaacEnc_DetermineEncoderMode(CHANNEL_MODE* mode,
INT nChannels);
@ -119,14 +124,13 @@ AAC_ENCODER_ERROR FDKaacEnc_InitChannelMapping(CHANNEL_MODE mode,
CHANNEL_ORDER co,
CHANNEL_MAPPING* chMap);
AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE *hQC,
CHANNEL_MAPPING *cm,
INT bitrateTot,
INT averageBitsTot,
AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE* hQC, CHANNEL_MAPPING* cm,
INT bitrateTot, INT averageBitsTot,
INT maxChannelBits);
ELEMENT_MODE FDKaacEnc_GetMonoStereoMode(const CHANNEL_MODE mode);
const CHANNEL_MODE_CONFIG_TAB* FDKaacEnc_GetChannelModeConfiguration(const CHANNEL_MODE mode);
const CHANNEL_MODE_CONFIG_TAB* FDKaacEnc_GetChannelModeConfiguration(
const CHANNEL_MODE mode);
#endif /* CHANNEL_MAP_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,14 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder **************************
/**************************** AAC encoder library ******************************
Initial author: M. Werner
contents/description: Chaos measure calculation
Author(s): M. Werner
******************************************************************************/
Description: Chaos measure calculation
*******************************************************************************/
#include "chaosmeasure.h"
@ -94,40 +106,63 @@ amm-info@iis.fraunhofer.de
functionname: FDKaacEnc_FDKaacEnc_CalculateChaosMeasurePeakFast
description: Eberlein method of chaos measure calculation by high-pass
filtering amplitude spectrum
A special case of FDKaacEnc_CalculateChaosMeasureTonalGeneric --
highly optimized
A special case of FDKaacEnc_CalculateChaosMeasureTonalGeneric
-- highly optimized
*****************************************************************************/
static void
FDKaacEnc_FDKaacEnc_CalculateChaosMeasurePeakFast( FIXP_DBL *RESTRICT paMDCTDataNM0,
INT numberOfLines,
FIXP_DBL *RESTRICT chaosMeasure )
{
static void FDKaacEnc_FDKaacEnc_CalculateChaosMeasurePeakFast(
FIXP_DBL *RESTRICT paMDCTDataNM0, INT numberOfLines,
FIXP_DBL *RESTRICT chaosMeasure) {
INT i, j;
/* calculate chaos measure by "peak filter" */
for (i=0; i<2; i++) {
/* make even and odd pass through data */
FIXP_DBL left,center; /* left, center tap of filter */
/* make even and odd pass through data */
FIXP_DBL left_0_div2,
center_0; /* left, center tap of filter, even numbered */
FIXP_DBL left_1_div2, center_1; /* left, center tap of filter, odd numbered */
left = (FIXP_DBL)((LONG)paMDCTDataNM0[i]^((LONG)paMDCTDataNM0[i]>>(DFRACT_BITS-1)));
center = (FIXP_DBL)((LONG)paMDCTDataNM0[i+2]^((LONG)paMDCTDataNM0[i+2]>>(DFRACT_BITS-1)));
left_0_div2 = (FIXP_DBL)(((LONG)paMDCTDataNM0[0] ^
((LONG)paMDCTDataNM0[0] >> (DFRACT_BITS - 1))) >>
1);
left_1_div2 = (FIXP_DBL)(((LONG)paMDCTDataNM0[1] ^
((LONG)paMDCTDataNM0[1] >> (DFRACT_BITS - 1))) >>
1);
center_0 = (FIXP_DBL)((LONG)paMDCTDataNM0[2] ^
((LONG)paMDCTDataNM0[2] >> (DFRACT_BITS - 1)));
center_1 = (FIXP_DBL)((LONG)paMDCTDataNM0[3] ^
((LONG)paMDCTDataNM0[3] >> (DFRACT_BITS - 1)));
for (j = i+2; j < numberOfLines - 2; j+=2) {
FIXP_DBL right = (FIXP_DBL)((LONG)paMDCTDataNM0[j+2]^((LONG)paMDCTDataNM0[j+2]>>(DFRACT_BITS-1)));
FIXP_DBL tmp = (left>>1)+(right>>1);
for (j = 2; j < numberOfLines - 2; j += 2) {
FIXP_DBL right_0 =
(FIXP_DBL)((LONG)paMDCTDataNM0[j + 2] ^
((LONG)paMDCTDataNM0[j + 2] >> (DFRACT_BITS - 1)));
FIXP_DBL tmp_0 = left_0_div2 + (right_0 >> 1);
FIXP_DBL right_1 =
(FIXP_DBL)((LONG)paMDCTDataNM0[j + 3] ^
((LONG)paMDCTDataNM0[j + 3] >> (DFRACT_BITS - 1)));
FIXP_DBL tmp_1 = left_1_div2 + (right_1 >> 1);
if (tmp < center ) {
INT leadingBits = CntLeadingZeros(center)-1;
tmp = schur_div(tmp<<leadingBits, center<<leadingBits, 8);
chaosMeasure[j] = fMult(tmp,tmp);
}
else {
chaosMeasure[j] = (FIXP_DBL)MAXVAL_DBL;
}
left = center;
center = right;
if (tmp_0 < center_0) {
INT leadingBits = CntLeadingZeros(center_0) - 1;
tmp_0 = schur_div(tmp_0 << leadingBits, center_0 << leadingBits, 8);
tmp_0 = fMult(tmp_0, tmp_0);
} else {
tmp_0 = (FIXP_DBL)MAXVAL_DBL;
}
chaosMeasure[j + 0] = tmp_0;
left_0_div2 = center_0 >> 1;
center_0 = right_0;
if (tmp_1 < center_1) {
INT leadingBits = CntLeadingZeros(center_1) - 1;
tmp_1 = schur_div(tmp_1 << leadingBits, center_1 << leadingBits, 8);
tmp_1 = fMult(tmp_1, tmp_1);
} else {
tmp_1 = (FIXP_DBL)MAXVAL_DBL;
}
left_1_div2 = center_1 >> 1;
center_1 = right_1;
chaosMeasure[j + 1] = tmp_1;
}
/* provide chaos measure for first few lines */
@ -135,11 +170,10 @@ FDKaacEnc_FDKaacEnc_CalculateChaosMeasurePeakFast( FIXP_DBL *RESTRICT paMDCTDat
chaosMeasure[1] = chaosMeasure[2];
/* provide chaos measure for last few lines */
for (i = (numberOfLines-3); i < numberOfLines; i++)
for (i = (numberOfLines - 3); i < numberOfLines; i++)
chaosMeasure[i] = FL2FXCONST_DBL(0.5);
}
/*****************************************************************************
functionname: FDKaacEnc_CalculateChaosMeasure
description: calculates a chaosmeasure for every line, different methods
@ -148,14 +182,10 @@ FDKaacEnc_FDKaacEnc_CalculateChaosMeasurePeakFast( FIXP_DBL *RESTRICT paMDCTDat
input: MDCT data, number of lines
output: chaosMeasure
*****************************************************************************/
void
FDKaacEnc_CalculateChaosMeasure( FIXP_DBL *paMDCTDataNM0,
INT numberOfLines,
FIXP_DBL *chaosMeasure )
void FDKaacEnc_CalculateChaosMeasure(FIXP_DBL *paMDCTDataNM0, INT numberOfLines,
FIXP_DBL *chaosMeasure)
{
FDKaacEnc_FDKaacEnc_CalculateChaosMeasurePeakFast( paMDCTDataNM0,
numberOfLines,
chaosMeasure );
FDKaacEnc_FDKaacEnc_CalculateChaosMeasurePeakFast(
paMDCTDataNM0, numberOfLines, chaosMeasure);
}

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,25 +90,23 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder **************************
/**************************** AAC encoder library ******************************
Initial author: M. Werner
contents/description: Chaos measure calculation
Author(s): M. Werner
******************************************************************************/
Description: Chaos measure calculation
#ifndef __CHAOSMEASURE_H
#define __CHAOSMEASURE_H
*******************************************************************************/
#ifndef CHAOSMEASURE_H
#define CHAOSMEASURE_H
#include "common_fix.h"
#include "psy_const.h"
void
FDKaacEnc_CalculateChaosMeasure( FIXP_DBL *paMDCTDataNM0,
INT numberOfLines,
FIXP_DBL *chaosMeasure );
void FDKaacEnc_CalculateChaosMeasure(FIXP_DBL *paMDCTDataNM0, INT numberOfLines,
FIXP_DBL *chaosMeasure);
#endif
#endif /* CHAOSMEASURE_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
of the MPEG specifications.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
individually for the purpose of encoding or decoding bit streams in products that are compliant with
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
software may already be covered under those patent licenses when it is used for those licensed purposes only.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
applications information and documentation.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without
payment of copyright license fees provided that you satisfy the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
your modifications thereto in source code form.
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation and/or other materials
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived from this library without
prior written permission.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
software or your modifications thereto.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
and the date of any change. For modified versions of the FDK AAC Codec, the term
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
respect to this software.
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
by appropriate patent licenses.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
or business interruption, however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of this software, even if
advised of the possibility of such damage.
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or consequential damages, including but not limited to procurement of substitute
goods or services; loss of use, data, or profits, or business interruption,
however caused and on any theory of liability, whether in contract, strict
liability, or tort (including negligence), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@ -79,42 +90,40 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder **************************
/**************************** AAC encoder library ******************************
Initial author: M.Werner
contents/description: Noiseless coder module
Author(s): M.Werner
******************************************************************************/
Description: Noiseless coder module
#ifndef __DYN_BITS_H
#define __DYN_BITS_H
*******************************************************************************/
#ifndef DYN_BITS_H
#define DYN_BITS_H
#include "common_fix.h"
#include "psy_const.h"
#include "aacenc_tns.h"
#define MAX_SECTIONS MAX_GROUPED_SFB
#define SECT_ESC_VAL_LONG 31
#define SECT_ESC_VAL_SHORT 7
#define CODE_BOOK_BITS 4
#define SECT_BITS_LONG 5
#define SECT_BITS_SHORT 3
#define PNS_PCM_BITS 9
#define MAX_SECTIONS MAX_GROUPED_SFB
#define SECT_ESC_VAL_LONG 31
#define SECT_ESC_VAL_SHORT 7
#define CODE_BOOK_BITS 4
#define SECT_BITS_LONG 5
#define SECT_BITS_SHORT 3
#define PNS_PCM_BITS 9
typedef struct
{
typedef struct {
INT codeBook;
INT sfbStart;
INT sfbCnt;
INT sectionBits; /* huff + si ! */
INT sectionBits; /* huff + si ! */
} SECTION_INFO;
typedef struct
{
typedef struct {
INT blockType;
INT noOfGroups;
INT sfbCnt;
@ -122,46 +131,30 @@ typedef struct
INT sfbPerGroup;
INT noOfSections;
SECTION_INFO huffsection[MAX_SECTIONS];
INT sideInfoBits; /* sectioning bits */
INT huffmanBits; /* huffman coded bits */
INT scalefacBits; /* scalefac coded bits */
INT noiseNrgBits; /* noiseEnergy coded bits */
INT firstScf; /* first scf to be coded */
INT sideInfoBits; /* sectioning bits */
INT huffmanBits; /* huffman coded bits */
INT scalefacBits; /* scalefac coded bits */
INT noiseNrgBits; /* noiseEnergy coded bits */
INT firstScf; /* first scf to be coded */
} SECTION_DATA;
struct BITCNTR_STATE
{
INT *bitLookUp;
INT *mergeGainLookUp;
struct BITCNTR_STATE {
INT* bitLookUp;
INT* mergeGainLookUp;
};
INT FDKaacEnc_BCNew(BITCNTR_STATE** phBC, UCHAR* dynamic_RAM);
INT FDKaacEnc_BCNew(BITCNTR_STATE **phBC
,UCHAR* dynamic_RAM
);
void FDKaacEnc_BCClose(BITCNTR_STATE** phBC);
void FDKaacEnc_BCClose(BITCNTR_STATE **phBC);
#if defined(PNS_PRECOUNT_ENABLE)
INT noisePreCount(const INT *noiseNrg, INT maxSfb);
#endif
INT FDKaacEnc_dynBitCount(
BITCNTR_STATE* const hBC,
const SHORT* const quantSpectrum,
const UINT* const maxValueInSfb,
const INT* const scalefac,
const INT blockType,
const INT sfbCnt,
const INT maxSfbPerGroup,
const INT sfbPerGroup,
const INT* const sfbOffset,
SECTION_DATA* const RESTRICT sectionData,
const INT* const noiseNrg,
const INT* const isBook,
const INT* const isScale,
const UINT syntaxFlags
);
INT FDKaacEnc_dynBitCount(BITCNTR_STATE* const hBC,
const SHORT* const quantSpectrum,
const UINT* const maxValueInSfb,
const INT* const scalefac, const INT blockType,
const INT sfbCnt, const INT maxSfbPerGroup,
const INT sfbPerGroup, const INT* const sfbOffset,
SECTION_DATA* const RESTRICT sectionData,
const INT* const noiseNrg, const INT* const isBook,
const INT* const isScale, const UINT syntaxFlags);
#endif

Some files were not shown because too many files have changed in this diff Show More