- Main Page
- Namespaces
- Classes
- Files
- Directories

- File List
- File Members

# a52_internal.h

    00001 /*
    00002  * a52_internal.h
    00003  * Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org>
    00004  * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
    00005  *
    00006  * This file is part of a52dec, a free ATSC A-52 stream decoder.
    00007  * See http://liba52.sourceforge.net/ for updates.
    00008  *
    00009  * a52dec is free software; you can redistribute it and/or modify
    00010  * it under the terms of the GNU General Public License as published by
    00011  * the Free Software Foundation; either version 2 of the License, or
    00012  * (at your option) any later version.
    00013  *
    00014  * a52dec is distributed in the hope that it will be useful,
    00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00017  * GNU General Public License for more details.
    00018  *
    00019  * You should have received a copy of the GNU General Public License
    00020  * along with this program; if not, write to the Free Software
    00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00022  */
    00023
    00024 typedef struct {
    00025     uint8_t bai;                /* fine SNR offset, fast gain */
    00026     uint8_t deltbae;            /* delta bit allocation exists */
    00027     int8_t deltba[50];          /* per-band delta bit allocation */
    00028 } ba_t;
    00029
    00030 typedef struct {
    00031     uint8_t exp[256];           /* decoded channel exponents */
    00032     int8_t bap[256];            /* derived channel bit allocation */
    00033 } expbap_t;
    00034
    00035 struct a52_state_s {
    00036     uint8_t fscod;              /* sample rate */
    00037     uint8_t halfrate;           /* halfrate factor */
    00038     uint8_t acmod;              /* coded channels */
    00039     uint8_t lfeon;              /* coded lfe channel */
    00040     sample_t clev;              /* centre channel mix level */
    00041     sample_t slev;              /* surround channels mix level */
    00042
    00043     int output;                 /* type of output */
    00044     sample_t level;             /* output level */
    00045     sample_t bias;              /* output bias */
    00046
    00047     int dynrnge;                /* apply dynamic range */
    00048     sample_t dynrng;            /* dynamic range */
    00049     void * dynrngdata;          /* dynamic range callback funtion and data */
    00050     sample_t (* dynrngcall) (sample_t range, void * dynrngdata);
    00051
    00052     uint8_t chincpl;            /* channel coupled */
    00053     uint8_t phsflginu;          /* phase flags in use (stereo only) */
    00054     uint8_t cplstrtmant;        /* coupling channel start mantissa */
    00055     uint8_t cplendmant;         /* coupling channel end mantissa */
    00056     uint32_t cplbndstrc;        /* coupling band structure */
    00057     sample_t cplco[5][18];      /* coupling coordinates */
    00058
    00059     /* derived information */
    00060     uint8_t cplstrtbnd;         /* coupling start band (for bit allocation) */
    00061     uint8_t ncplbnd;            /* number of coupling bands */
    00062
    00063     uint8_t rematflg;           /* stereo rematrixing */
    00064
    00065     uint8_t endmant[5];         /* channel end mantissa */
    00066
    00067     uint16_t bai;               /* bit allocation information */
    00068
    00069     uint32_t * buffer_start;
    00070     uint16_t lfsr_state;        /* dither state */
    00071     uint32_t bits_left;
    00072     uint32_t current_word;
    00073
    00074     uint8_t csnroffst;          /* coarse SNR offset */
    00075     ba_t cplba;                 /* coupling bit allocation parameters */
    00076     ba_t ba[5];                 /* channel bit allocation parameters */
    00077     ba_t lfeba;                 /* lfe bit allocation parameters */
    00078
    00079     uint8_t cplfleak;           /* coupling fast leak init */
    00080     uint8_t cplsleak;           /* coupling slow leak init */
    00081
    00082     expbap_t cpl_expbap;
    00083     expbap_t fbw_expbap[5];
    00084     expbap_t lfe_expbap;
    00085
    00086     sample_t * samples;
    00087     int downmixed;
    00088 };
    00089
    00090 #define LEVEL_PLUS6DB 2.0
    00091 #define LEVEL_PLUS3DB 1.4142135623730951
    00092 #define LEVEL_3DB 0.7071067811865476
    00093 #define LEVEL_45DB 0.5946035575013605
    00094 #define LEVEL_6DB 0.5
    00095
    00096 #define EXP_REUSE (0)
    00097 #define EXP_D15   (1)
    00098 #define EXP_D25   (2)
    00099 #define EXP_D45   (3)
    00100
    00101 #define DELTA_BIT_REUSE (0)
    00102 #define DELTA_BIT_NEW (1)
    00103 #define DELTA_BIT_NONE (2)
    00104 #define DELTA_BIT_RESERVED (3)
    00105
    00106 void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
    00107                        int start, int end, int fastleak, int slowleak,
    00108                        expbap_t * expbap);
    00109
    00110 int a52_downmix_init (int input, int flags, sample_t * level,
    00111                       sample_t clev, sample_t slev);
    00112 int a52_downmix_coeff (sample_t * coeff, int acmod, int output, sample_t level,
    00113                        sample_t clev, sample_t slev);
    00114 void a52_downmix (sample_t * samples, int acmod, int output, sample_t bias,
    00115                   sample_t clev, sample_t slev);
    00116 void a52_upmix (sample_t * samples, int acmod, int output);
    00117
    00118 void a52_imdct_init (uint32_t mm_accel);
    00119 void a52_imdct_256 (sample_t * data, sample_t * delay, sample_t bias);
    00120 void a52_imdct_512 (sample_t * data, sample_t * delay, sample_t bias);