1/* ----------------------------------------------------------------------------- 2Software License for The Fraunhofer FDK AAC Codec Library for Android 3 4© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten 5Forschung e.V. All rights reserved. 6 7 1. INTRODUCTION 8The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software 9that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding 10scheme for digital audio. This FDK AAC Codec software is intended to be used on 11a wide variety of Android devices. 12 13AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient 14general perceptual audio codecs. AAC-ELD is considered the best-performing 15full-bandwidth communications codec by independent studies and is widely 16deployed. AAC has been standardized by ISO and IEC as part of the MPEG 17specifications. 18 19Patent licenses for necessary patent claims for the FDK AAC Codec (including 20those of Fraunhofer) may be obtained through Via Licensing 21(www.vialicensing.com) or through the respective patent owners individually for 22the purpose of encoding or decoding bit streams in products that are compliant 23with the ISO/IEC MPEG audio standards. Please note that most manufacturers of 24Android devices already license these patent claims through Via Licensing or 25directly from the patent owners, and therefore FDK AAC Codec software may 26already be covered under those patent licenses when it is used for those 27licensed purposes only. 28 29Commercially-licensed AAC software libraries, including floating-point versions 30with enhanced sound quality, are also available from Fraunhofer. Users are 31encouraged to check the Fraunhofer website for additional applications 32information and documentation. 33 342. COPYRIGHT LICENSE 35 36Redistribution and use in source and binary forms, with or without modification, 37are permitted without payment of copyright license fees provided that you 38satisfy the following conditions: 39 40You must retain the complete text of this software license in redistributions of 41the FDK AAC Codec or your modifications thereto in source code form. 42 43You must retain the complete text of this software license in the documentation 44and/or other materials provided with redistributions of the FDK AAC Codec or 45your modifications thereto in binary form. You must make available free of 46charge copies of the complete source code of the FDK AAC Codec and your 47modifications thereto to recipients of copies in binary form. 48 49The name of Fraunhofer may not be used to endorse or promote products derived 50from this library without prior written permission. 51 52You may not charge copyright license fees for anyone to use, copy or distribute 53the FDK AAC Codec software or your modifications thereto. 54 55Your modified versions of the FDK AAC Codec must carry prominent notices stating 56that you changed the software and the date of any change. For modified versions 57of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android" 58must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK 59AAC Codec Library for Android." 60 613. NO PATENT LICENSE 62 63NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without 64limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE. 65Fraunhofer provides no warranty of patent non-infringement with respect to this 66software. 67 68You may use this FDK AAC Codec software or modifications thereto only for 69purposes that are authorized by appropriate patent licenses. 70 714. DISCLAIMER 72 73This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright 74holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, 75including but not limited to the implied warranties of merchantability and 76fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 77CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, 78or consequential damages, including but not limited to procurement of substitute 79goods or services; loss of use, data, or profits, or business interruption, 80however caused and on any theory of liability, whether in contract, strict 81liability, or tort (including negligence), arising in any way out of the use of 82this software, even if advised of the possibility of such damage. 83 845. CONTACT INFORMATION 85 86Fraunhofer Institute for Integrated Circuits IIS 87Attention: Audio and Multimedia Departments - FDK AAC LL 88Am Wolfsmantel 33 8991058 Erlangen, Germany 90 91www.iis.fraunhofer.de/amm 92amm-info@iis.fraunhofer.de 93----------------------------------------------------------------------------- */ 94 95/******************* Library for basic calculation routines ******************** 96 97 Author(s): Oliver Moser 98 99 Description: ROM tables used by FDK tools 100 101*******************************************************************************/ 102 103#ifndef FDK_TOOLS_ROM_H 104#define FDK_TOOLS_ROM_H 105 106#include "common_fix.h" 107#include "FDK_audio.h" 108 109/* sinetables */ 110 111/* None radix2 rotation vectors */ 112extern RAM_ALIGN const FIXP_STB RotVectorReal60[60]; 113extern RAM_ALIGN const FIXP_STB RotVectorImag60[60]; 114extern RAM_ALIGN const FIXP_STB RotVectorReal192[192]; 115extern RAM_ALIGN const FIXP_STB RotVectorImag192[192]; 116extern RAM_ALIGN const FIXP_STB RotVectorReal240[210]; 117extern RAM_ALIGN const FIXP_STB RotVectorImag240[210]; 118extern RAM_ALIGN const FIXP_STB RotVectorReal480[480]; 119extern RAM_ALIGN const FIXP_STB RotVectorImag480[480]; 120extern RAM_ALIGN const FIXP_STB RotVectorReal6[6]; 121extern RAM_ALIGN const FIXP_STB RotVectorImag6[6]; 122extern RAM_ALIGN const FIXP_STB RotVectorReal12[12]; 123extern RAM_ALIGN const FIXP_STB RotVectorImag12[12]; 124extern RAM_ALIGN const FIXP_STB RotVectorReal24[24]; 125extern RAM_ALIGN const FIXP_STB RotVectorImag24[24]; 126extern RAM_ALIGN const FIXP_STB RotVectorReal48[48]; 127extern RAM_ALIGN const FIXP_STB RotVectorImag48[48]; 128extern RAM_ALIGN const FIXP_STB RotVectorReal80[80]; 129extern RAM_ALIGN const FIXP_STB RotVectorImag80[80]; 130extern RAM_ALIGN const FIXP_STB RotVectorReal96[96]; 131extern RAM_ALIGN const FIXP_STB RotVectorImag96[96]; 132extern RAM_ALIGN const FIXP_STB RotVectorReal384[384]; 133extern RAM_ALIGN const FIXP_STB RotVectorImag384[384]; 134extern RAM_ALIGN const FIXP_STB RotVectorReal20[20]; 135extern RAM_ALIGN const FIXP_STB RotVectorImag20[20]; 136extern RAM_ALIGN const FIXP_STB RotVectorReal120[120]; 137extern RAM_ALIGN const FIXP_STB RotVectorImag120[120]; 138 139/* Regular sine tables */ 140extern RAM_ALIGN const FIXP_STP SineTable1024[]; 141extern RAM_ALIGN const FIXP_STP SineTable512[]; 142extern RAM_ALIGN const FIXP_STP SineTable480[]; 143extern RAM_ALIGN const FIXP_STP SineTable384[]; 144extern RAM_ALIGN const FIXP_STP SineTable80[]; 145#ifdef INCLUDE_SineTable10 146extern RAM_ALIGN const FIXP_STP SineTable10[]; 147#endif 148 149/* AAC-LC windows */ 150extern RAM_ALIGN const FIXP_WTP SineWindow1024[]; 151extern RAM_ALIGN const FIXP_WTP KBDWindow1024[]; 152extern RAM_ALIGN const FIXP_WTP SineWindow128[]; 153extern RAM_ALIGN const FIXP_WTP KBDWindow128[]; 154 155extern RAM_ALIGN const FIXP_WTP SineWindow960[]; 156extern RAM_ALIGN const FIXP_WTP KBDWindow960[]; 157extern RAM_ALIGN const FIXP_WTP SineWindow120[]; 158extern RAM_ALIGN const FIXP_WTP KBDWindow120[]; 159 160/* AAC-LD windows */ 161extern RAM_ALIGN const FIXP_WTP SineWindow512[]; 162#define LowOverlapWindow512 SineWindow128 163extern RAM_ALIGN const FIXP_WTP SineWindow480[]; 164#define LowOverlapWindow480 SineWindow120 165 166/* USAC TCX Window */ 167extern RAM_ALIGN const FIXP_WTP SineWindow256[256]; 168extern RAM_ALIGN const FIXP_WTP SineWindow192[]; 169 170/* USAC 8/3 windows */ 171extern RAM_ALIGN const FIXP_WTP SineWindow768[]; 172extern RAM_ALIGN const FIXP_WTP KBDWindow768[]; 173extern RAM_ALIGN const FIXP_WTP SineWindow96[]; 174extern RAM_ALIGN const FIXP_WTP KBDWindow96[]; 175 176/* DCT and others */ 177extern RAM_ALIGN const FIXP_WTP SineWindow64[]; 178extern RAM_ALIGN const FIXP_WTP SineWindow48[]; 179extern RAM_ALIGN const FIXP_WTP SineWindow32[]; 180extern RAM_ALIGN const FIXP_WTP SineWindow24[]; 181extern RAM_ALIGN const FIXP_WTP SineWindow16[]; 182extern RAM_ALIGN const FIXP_WTP SineWindow8[]; 183 184/** 185 * \brief Helper table for window slope mapping. You should prefer the usage of 186 * the function FDKgetWindowSlope(), this table is only made public for some 187 * optimized access inside dct.cpp. 188 */ 189extern const FIXP_WTP *const windowSlopes[2][4][9]; 190 191/** 192 * \brief Window slope access helper. Obtain a window of given length and shape. 193 * \param length Length of the window slope. 194 * \param shape Shape index of the window slope. 0: sine window, 1: 195 * Kaiser-Bessel. Any other value is applied a mask of 1 to, mapping it to 196 * either 0 or 1. 197 * \param Pointer to window slope or NULL if the requested window slope is not 198 * available. 199 */ 200const FIXP_WTP *FDKgetWindowSlope(int length, int shape); 201 202extern const FIXP_WTP sin_twiddle_L64[]; 203 204/* 205 * Filter coefficient type definition 206 */ 207 208#if defined(ARCH_PREFER_MULT_16x16) || defined(ARCH_PREFER_MULT_32x16) 209#define QMF_COEFF_16BIT 210#endif 211 212#define QMF_FILTER_PROTOTYPE_SIZE 640 213#define QMF_NO_POLY 5 214 215#ifdef QMF_COEFF_16BIT 216#define FIXP_PFT FIXP_SGL 217#define FIXP_QTW FIXP_SGL 218#define FX_DBL2FX_QTW(x) FX_DBL2FX_SGL(x) 219#else 220#define FIXP_PFT FIXP_DBL 221#define FIXP_QTW FIXP_DBL 222 223#define FX_DBL2FX_QTW(x) (x) 224 225#endif 226 227#define QMF640_PFT_TABLE_SIZE (640 / 2 + QMF_NO_POLY) 228 229/* Resampling twiddles for QMF */ 230 231/* Not resampling twiddles */ 232extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_cos32[32]; 233extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_sin32[32]; 234/* Adapted analysis post-twiddles for down-sampled HQ SBR */ 235extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_cos_downsamp32[32]; 236extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_sin_downsamp32[32]; 237extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_cos64[64]; 238extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_sin64[64]; 239extern RAM_ALIGN const FIXP_PFT 240 qmf_pfilt640[QMF640_PFT_TABLE_SIZE + QMF_NO_POLY]; 241extern RAM_ALIGN const FIXP_PFT qmf_pfilt640_vector[640]; 242 243extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_cos40[40]; 244extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_sin40[40]; 245extern RAM_ALIGN const FIXP_PFT qmf_pfilt400[]; 246extern RAM_ALIGN const FIXP_PFT qmf_pfilt200[]; 247extern RAM_ALIGN const FIXP_PFT qmf_pfilt120[]; 248 249extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_cos24[24]; 250extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_sin24[24]; 251extern RAM_ALIGN const FIXP_PFT qmf_pfilt240[]; 252 253extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_cos16[16]; 254extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_sin16[16]; 255 256#define QMF640_CLDFB_PFT_TABLE_SIZE (640) 257#define QMF320_CLDFB_PFT_TABLE_SIZE (320) 258#define QMF_CLDFB_PFT_SCALE 1 259 260extern const FIXP_QTW qmf_phaseshift_cos32_cldfb_ana[32]; 261extern const FIXP_QTW qmf_phaseshift_cos32_cldfb_syn[32]; 262extern const FIXP_QTW qmf_phaseshift_sin32_cldfb[32]; 263 264extern const FIXP_QTW qmf_phaseshift_cos16_cldfb_ana[16]; 265extern const FIXP_QTW qmf_phaseshift_cos16_cldfb_syn[16]; 266extern const FIXP_QTW qmf_phaseshift_sin16_cldfb[16]; 267 268extern const FIXP_QTW qmf_phaseshift_cos8_cldfb_ana[8]; 269extern const FIXP_QTW qmf_phaseshift_cos8_cldfb_syn[8]; 270extern const FIXP_QTW qmf_phaseshift_sin8_cldfb[8]; 271 272extern const FIXP_QTW qmf_phaseshift_cos64_cldfb[64]; 273extern const FIXP_QTW qmf_phaseshift_sin64_cldfb[64]; 274 275extern RAM_ALIGN const FIXP_PFT qmf_cldfb_640[QMF640_CLDFB_PFT_TABLE_SIZE]; 276extern RAM_ALIGN const FIXP_PFT qmf_cldfb_320[QMF320_CLDFB_PFT_TABLE_SIZE]; 277#define QMF160_CLDFB_PFT_TABLE_SIZE (160) 278extern RAM_ALIGN const FIXP_PFT qmf_cldfb_160[QMF160_CLDFB_PFT_TABLE_SIZE]; 279#define QMF80_CLDFB_PFT_TABLE_SIZE (80) 280extern RAM_ALIGN const FIXP_PFT qmf_cldfb_80[QMF80_CLDFB_PFT_TABLE_SIZE]; 281 282#define QMF320_MPSLDFB_PFT_TABLE_SIZE (320) 283#define QMF640_MPSLDFB_PFT_TABLE_SIZE (640) 284#define QMF_MPSLDFB_PFT_SCALE 1 285 286extern const FIXP_PFT qmf_mpsldfb_320[QMF320_MPSLDFB_PFT_TABLE_SIZE]; 287extern RAM_ALIGN const FIXP_PFT qmf_mpsldfb_640[QMF640_MPSLDFB_PFT_TABLE_SIZE]; 288 289/** 290 * Audio bitstream element specific syntax flags: 291 */ 292#define AC_EL_GA_CCE 0x00000001 /*!< GA AAC coupling channel element (CCE) */ 293 294/* 295 * Raw Data Block list items. 296 */ 297typedef enum { 298 element_instance_tag, 299 common_window, /* -> decision for link_sequence */ 300 global_gain, 301 ics_info, /* ics_reserved_bit, window_sequence, window_shape, max_sfb, 302 scale_factor_grouping, predictor_data_present, ltp_data_present, 303 ltp_data */ 304 max_sfb, 305 ms, /* ms_mask_present, ms_used */ 306 /*predictor_data_present,*/ /* part of ics_info */ 307 ltp_data_present, 308 ltp_data, 309 section_data, 310 scale_factor_data, 311 pulse, /* pulse_data_present, pulse_data */ 312 tns_data_present, 313 tns_data, 314 gain_control_data_present, 315 gain_control_data, 316 esc1_hcr, 317 esc2_rvlc, 318 spectral_data, 319 320 scale_factor_data_usac, 321 core_mode, /* -> decision for link_sequence */ 322 common_tw, 323 lpd_channel_stream, 324 tw_data, 325 noise, 326 ac_spectral_data, 327 fac_data, 328 tns_active, /* introduced in MPEG-D usac CD */ 329 tns_data_present_usac, 330 common_max_sfb, 331 332 coupled_elements, /* only for CCE parsing */ 333 gain_element_lists, /* only for CCE parsing */ 334 335 /* Non data list items */ 336 adtscrc_start_reg1, 337 adtscrc_start_reg2, 338 adtscrc_end_reg1, 339 adtscrc_end_reg2, 340 drmcrc_start_reg, 341 drmcrc_end_reg, 342 next_channel, 343 next_channel_loop, 344 link_sequence, 345 end_of_sequence 346} rbd_id_t; 347 348struct element_list { 349 const rbd_id_t *id; 350 const struct element_list *next[2]; 351}; 352 353typedef struct element_list element_list_t; 354/** 355 * \brief get elementary stream pieces list for given parameters. 356 * \param aot audio object type 357 * \param epConfig the epConfig value from the current Audio Specific Config 358 * \param nChannels amount of channels contained in the current element. 359 * \param layer the layer of the current element. 360 * \param elFlags element specific flags. 361 * \return element_list_t parser guidance structure. 362 */ 363const element_list_t *getBitstreamElementList(AUDIO_OBJECT_TYPE aot, 364 SCHAR epConfig, UCHAR nChannels, 365 UCHAR layer, UINT elFlags); 366 367typedef enum { 368 /* n.a. */ 369 FDK_FORMAT_1_0 = 1, /* mono */ 370 FDK_FORMAT_2_0 = 2, /* stereo */ 371 FDK_FORMAT_3_0_FC = 3, /* 3/0.0 */ 372 FDK_FORMAT_3_1_0 = 4, /* 3/1.0 */ 373 FDK_FORMAT_5_0 = 5, /* 3/2.0 */ 374 FDK_FORMAT_5_1 = 6, /* 5.1 */ 375 FDK_FORMAT_7_1_ALT = 7, /* 5/2.1 ALT */ 376 /* 8 n.a.*/ 377 FDK_FORMAT_3_0_RC = 9, /* 2/1.0 */ 378 FDK_FORMAT_2_2_0 = 10, /* 2/2.0 */ 379 FDK_FORMAT_6_1 = 11, /* 3/3.1 */ 380 FDK_FORMAT_7_1 = 12, /* 3/4.1 */ 381 FDK_FORMAT_22_2 = 13, /* 22.2 */ 382 FDK_FORMAT_5_2_1 = 14, /* 5/2.1*/ 383 FDK_FORMAT_5_5_2 = 15, /* 5/5.2 */ 384 FDK_FORMAT_9_1 = 16, /* 5/4.1 */ 385 FDK_FORMAT_6_5_1 = 17, /* 6/5.1 */ 386 FDK_FORMAT_6_7_1 = 18, /* 6/7.1 */ 387 FDK_FORMAT_5_6_1 = 19, /* 5/6.1 */ 388 FDK_FORMAT_7_6_1 = 20, /* 7/6.1 */ 389 FDK_FORMAT_IN_LISTOFCHANNELS = 21, 390 FDK_FORMAT_OUT_LISTOFCHANNELS = 22, 391 /* 20 formats + In & Out list of channels */ 392 FDK_NFORMATS = 23, 393 FDK_FORMAT_FAIL = -1 394} FDK_converter_formatid_t; 395 396extern const INT format_nchan[FDK_NFORMATS + 9 - 2]; 397 398#endif 399