1 /* Copyright (c) 2007-2008 CSIRO 2 Copyright (c) 2007-2009 Xiph.Org Foundation 3 Copyright (c) 2008 Gregory Maxwell 4 Written by Jean-Marc Valin and Gregory Maxwell */ 5 /* 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions 8 are met: 9 10 - Redistributions of source code must retain the above copyright 11 notice, this list of conditions and the following disclaimer. 12 13 - Redistributions in binary form must reproduce the above copyright 14 notice, this list of conditions and the following disclaimer in the 15 documentation and/or other materials provided with the distribution. 16 17 - Neither the name of the Xiph.org Foundation nor the names of its 18 contributors may be used to endorse or promote products derived from 19 this software without specific prior written permission. 20 21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 25 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 #ifndef MODES_H 35 #define MODES_H 36 37 #include "celt_types.h" 38 #include "celt.h" 39 #include "arch.h" 40 #include "mdct.h" 41 #include "pitch.h" 42 43 #define CELT_BITSTREAM_VERSION 0x8000000b 44 45 #ifdef STATIC_MODES 46 #include "static_modes.h" 47 #endif 48 49 #define MAX_PERIOD 1024 50 51 #ifndef MCHANNELS 52 # ifdef DISABLE_STEREO 53 # define MCHANNELS(mode) (1) 54 # else 55 # define MCHANNELS(mode) ((mode)->nbChannels) 56 # endif 57 #endif 58 59 #ifndef CHANNELS 60 # ifdef DISABLE_STEREO 61 # define CHANNELS(_C) (1) 62 # else 63 # define CHANNELS(_C) (_C) 64 # endif 65 #endif 66 67 #define MDCT(mode) (&(mode)->mdct) 68 69 #ifndef OVERLAP 70 #define OVERLAP(mode) ((mode)->overlap) 71 #endif 72 73 #ifndef FRAMESIZE 74 #define FRAMESIZE(mode) ((mode)->mdctSize) 75 #endif 76 77 /** Mode definition (opaque) 78 @brief Mode definition 79 */ 80 struct CELTMode { 81 celt_uint32 marker_start; 82 celt_int32 Fs; 83 int overlap; 84 int mdctSize; 85 86 int nbEBands; 87 int pitchEnd; 88 89 const celt_int16 *eBands; /**< Definition for each "pseudo-critical band" */ 90 91 celt_word16 ePredCoef;/**< Prediction coefficient for the energy encoding */ 92 93 int nbAllocVectors; /**< Number of lines in the matrix below */ 94 const celt_int16 *allocVectors; /**< Number of bits in each band for several rates */ 95 96 const celt_int16 * const *bits; /**< Cache for pulses->bits mapping in each band */ 97 98 /* Stuff that could go in the {en,de}coder, but we save space this way */ 99 mdct_lookup mdct; 100 101 const celt_word16 *window; 102 103 int nbShortMdcts; 104 int shortMdctSize; 105 mdct_lookup shortMdct; 106 const celt_word16 *shortWindow; 107 108 int *prob; 109 celt_uint32 marker_end; 110 }; 111 112 int check_mode(const CELTMode *mode); 113 114 #endif 115