Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ac3.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 #ifndef AC3_H
00021 #define AC3_H
00022 
00023 #include "mpeg3real.h"
00024 
00025 #define MAX_AC3_FRAMESIZE 1920 * 2 + 512
00026 
00027 extern int mpeg3_ac3_samplerates[3];
00028 
00029 /* Exponent strategy constants */
00030 #define MPEG3_EXP_REUSE (0)
00031 #define MPEG3_EXP_D15   (1)
00032 #define MPEG3_EXP_D25   (2)
00033 #define MPEG3_EXP_D45   (3)
00034 
00035 /* Delta bit allocation constants */
00036 #define DELTA_BIT_REUSE (0)
00037 #define DELTA_BIT_NEW (1)
00038 #define DELTA_BIT_NONE (2)
00039 #define DELTA_BIT_RESERVED (3)
00040 
00041 
00042 typedef mpeg3_real_t mpeg3ac3_stream_samples_t[6][256];
00043 
00044 typedef struct
00045 {
00046 /* Bit stream identification == 0x8 */
00047         int bsid;       
00048 /* Bit stream mode */
00049         int bsmod;
00050 /* Audio coding mode */
00051         int acmod;
00052 /* If we're using the centre channel then */
00053 /* centre mix level */
00054                 int cmixlev;
00055 /* If we're using the surround channel then */
00056 /* surround mix level */
00057                 int surmixlev;
00058 /* If we're in 2/0 mode then */
00059 /* Dolby surround mix level - NOT USED - */
00060                 int dsurmod;
00061 /* Low frequency effects on */
00062         int lfeon;
00063 /* Dialogue Normalization level */
00064         int dialnorm;
00065 /* Compression exists */
00066         int compre;
00067 /* Compression level */
00068                 int compr;
00069 /* Language code exists */
00070         int langcode;
00071 /* Language code */
00072                 int langcod;
00073 /* Audio production info exists*/
00074         unsigned int audprodie;
00075                 int mixlevel;
00076                 int roomtyp;
00077 /* If we're in dual mono mode (acmod == 0) then extra stuff */
00078                 int dialnorm2;
00079                 int compr2e;
00080                         int compr2;
00081                 int langcod2e;
00082                         int langcod2;
00083                 int audprodi2e;
00084                         int mixlevel2;
00085                         int roomtyp2;
00086 /* Copyright bit */
00087         int copyrightb;
00088 /* Original bit */
00089         int origbs;
00090 /* Timecode 1 exists */
00091         int timecod1e;
00092 /* Timecode 1 */
00093                 unsigned int timecod1;
00094 /* Timecode 2 exists */
00095         int timecod2e;
00096 /* Timecode 2 */
00097                 unsigned int timecod2;
00098 /* Additional bit stream info exists */
00099         int addbsie;
00100 /* Additional bit stream length - 1 (in bytes) */
00101                 int addbsil;
00102 /* Additional bit stream information (max 64 bytes) */
00103                 unsigned char addbsi[64];
00104 
00105 /* Information not in the AC-3 bitstream, but derived */
00106 /* Number of channels (excluding LFE)
00107  * Derived from acmod */
00108         int nfchans;
00109 } mpeg3_ac3bsi_t;
00110 
00111 typedef struct 
00112 {
00113 /* block switch bit indexed by channel num */
00114         unsigned short blksw[5];
00115 /* dither enable bit indexed by channel num */
00116         unsigned short dithflag[5];
00117 /* dynamic range gain exists */
00118         int dynrnge;
00119 /* dynamic range gain */
00120                 int dynrng;
00121 /* if acmod==0 then */
00122 /* dynamic range 2 gain exists */
00123         int dynrng2e;
00124 /* dynamic range 2 gain */
00125                 int dynrng2;
00126 /* coupling strategy exists */
00127         int cplstre;
00128 /* coupling in use */
00129                 int cplinu;
00130 /* channel coupled */
00131                         unsigned short chincpl[5];
00132 /* if acmod==2 then */
00133 /* Phase flags in use */
00134                                 int phsflginu;
00135 /* coupling begin frequency code */
00136                         int cplbegf;
00137 /* coupling end frequency code */
00138                         int cplendf;
00139 /* coupling band structure bits */
00140                         unsigned short cplbndstrc[18];
00141 /* Do coupling co-ords exist for this channel? */
00142                         unsigned short cplcoe[5];
00143 /* Master coupling co-ordinate */
00144                         unsigned short mstrcplco[5];
00145 /* Per coupling band coupling co-ordinates */
00146                         unsigned short cplcoexp[5][18];
00147                         unsigned short cplcomant[5][18];
00148 /* Phase flags for dual mono */
00149                         unsigned short phsflg[18];
00150 /* Is there a rematrixing strategy */
00151         unsigned int rematstr;
00152 /* Rematrixing bits */
00153                 unsigned short rematflg[4];
00154 /* Coupling exponent strategy */
00155         int cplexpstr;
00156 /* Exponent strategy for full bandwidth channels */
00157         unsigned short chexpstr[5];
00158 /* Exponent strategy for lfe channel */
00159         int lfeexpstr;
00160 /* Channel bandwidth for independent channels */
00161         unsigned short chbwcod[5];
00162 /* The absolute coupling exponent */
00163                 int cplabsexp;
00164 /* Coupling channel exponents (D15 mode gives 18 * 12 /3  encoded exponents */
00165                 unsigned short cplexps[18 * 12 / 3];
00166 /* fbw channel exponents */
00167         unsigned short exps[5][252 / 3];
00168 /* channel gain range */
00169         unsigned short gainrng[5];
00170 /* low frequency exponents */
00171         unsigned short lfeexps[3];
00172 
00173 /* Bit allocation info */
00174         int baie;
00175 /* Slow decay code */
00176                 int sdcycod;
00177 /* Fast decay code */
00178                 int fdcycod;
00179 /* Slow gain code */
00180                 int sgaincod;
00181 /* dB per bit code */
00182                 int dbpbcod;
00183 /* masking floor code */
00184                 int floorcod;
00185 
00186 /* SNR offset info */
00187         int snroffste;
00188 /* coarse SNR offset */
00189                 int csnroffst;
00190 /* coupling fine SNR offset */
00191                 int cplfsnroffst;
00192 /* coupling fast gain code */
00193                 int cplfgaincod;
00194 /* fbw fine SNR offset */
00195                 unsigned short fsnroffst[5];
00196 /* fbw fast gain code */
00197                 unsigned short fgaincod[5];
00198 /* lfe fine SNR offset */
00199                 int lfefsnroffst;
00200 /* lfe fast gain code */
00201                 int lfefgaincod;
00202         
00203 /* Coupling leak info */
00204         int cplleake;
00205 /* coupling fast leak initialization */
00206                 int cplfleak;
00207 /* coupling slow leak initialization */
00208                 int cplsleak;
00209         
00210 /* delta bit allocation info */
00211         int deltbaie;
00212 /* coupling delta bit allocation exists */
00213                 int cpldeltbae;
00214 /* fbw delta bit allocation exists */
00215                 unsigned short deltbae[5];
00216 /* number of cpl delta bit segments */
00217                 int cpldeltnseg;
00218 /* coupling delta bit allocation offset */
00219                         short cpldeltoffst[8];
00220 /* coupling delta bit allocation length */
00221                         short cpldeltlen[8];
00222 /* coupling delta bit allocation length */
00223                         short cpldeltba[8];
00224 /* number of delta bit segments */
00225                 unsigned short deltnseg[5];
00226 /* fbw delta bit allocation offset */
00227                         short deltoffst[5][8];
00228 /* fbw delta bit allocation length */
00229                         short deltlen[5][8];
00230 /* fbw delta bit allocation length */
00231                         short deltba[5][8];
00232 
00233 /* skip length exists */
00234         int skiple;
00235 /* skip length */
00236         int skipl;
00237 
00238 /* channel mantissas */
00239         short chmant[5][256];
00240 
00241 /* coupling mantissas */
00242         unsigned short cplmant[256];
00243 
00244 /* coupling mantissas */
00245         unsigned short lfemant[7];
00246 
00247 /*  -- Information not in the bitstream, but derived thereof  -- */
00248 
00249 /* Number of coupling sub-bands */
00250         int ncplsubnd;
00251 
00252 /* Number of combined coupling sub-bands
00253  * Derived from ncplsubnd and cplbndstrc */
00254         int ncplbnd;
00255 
00256 /* Number of exponent groups by channel
00257  * Derived from strmant, endmant */
00258         int nchgrps[5];
00259 
00260 /* Number of coupling exponent groups
00261  * Derived from cplbegf, cplendf, cplexpstr */
00262         int ncplgrps;
00263                         
00264 /* End mantissa numbers of fbw channels */
00265         unsigned short endmant[5];
00266 
00267 /* Start and end mantissa numbers for the coupling channel */
00268         int cplstrtmant;
00269         int cplendmant;
00270 
00271 /* Decoded exponent info */
00272         unsigned short fbw_exp[5][256];
00273         unsigned short cpl_exp[256];
00274         unsigned short lfe_exp[7];
00275 
00276 /* Bit allocation pointer results */
00277         short fbw_bap[5][256];
00278 /*FIXME figure out exactly how many entries there should be (253-37?)  */
00279         short cpl_bap[256];
00280         short lfe_bap[7];
00281 } mpeg3_ac3audblk_t;
00282 
00283 /* Bit allocation data */
00284 typedef struct
00285 {
00286         int sdecay;
00287         int fdecay;
00288         int sgain;
00289         int dbknee;
00290         int floor;
00291         short psd[256];
00292         short bndpsd[256];
00293         short excite[256];
00294         short mask[256];
00295 } mpeg3_ac3_bitallocation_t;
00296 
00297 /* Mantissa data */
00298 typedef struct
00299 {
00300         unsigned short m_1[3];
00301         unsigned short m_2[3];
00302         unsigned short m_4[2];
00303         unsigned short m_1_pointer;
00304         unsigned short m_2_pointer;
00305         unsigned short m_4_pointer;
00306 } mpeg3_ac3_mantissa_t;
00307 
00308 #endif

Generated on Sat Nov 5 16:15:37 2005 for OPIE by  doxygen 1.4.2