Blame liba52/a52_internal.h

Packit 64f477
/*
Packit 64f477
 * a52_internal.h
Packit 64f477
 * Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org>
Packit 64f477
 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
Packit 64f477
 *
Packit 64f477
 * This file is part of a52dec, a free ATSC A-52 stream decoder.
Packit 64f477
 * See http://liba52.sourceforge.net/ for updates.
Packit 64f477
 *
Packit 64f477
 * a52dec is free software; you can redistribute it and/or modify
Packit 64f477
 * it under the terms of the GNU General Public License as published by
Packit 64f477
 * the Free Software Foundation; either version 2 of the License, or
Packit 64f477
 * (at your option) any later version.
Packit 64f477
 *
Packit 64f477
 * a52dec is distributed in the hope that it will be useful,
Packit 64f477
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 64f477
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 64f477
 * GNU General Public License for more details.
Packit 64f477
 *
Packit 64f477
 * You should have received a copy of the GNU General Public License
Packit 64f477
 * along with this program; if not, write to the Free Software
Packit 64f477
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
Packit 64f477
 */
Packit 64f477
Packit 64f477
typedef struct {
Packit 64f477
    uint8_t bai;		/* fine SNR offset, fast gain */
Packit 64f477
    uint8_t deltbae;		/* delta bit allocation exists */
Packit 64f477
    int8_t deltba[50];		/* per-band delta bit allocation */
Packit 64f477
} ba_t;
Packit 64f477
Packit 64f477
typedef struct {
Packit 64f477
    uint8_t exp[256];		/* decoded channel exponents */
Packit 64f477
    int8_t bap[256];		/* derived channel bit allocation */
Packit 64f477
} expbap_t;
Packit 64f477
Packit 64f477
struct a52_state_s {
Packit 64f477
    uint8_t fscod;		/* sample rate */
Packit 64f477
    uint8_t halfrate;		/* halfrate factor */
Packit 64f477
    uint8_t acmod;		/* coded channels */
Packit 64f477
    uint8_t lfeon;		/* coded lfe channel */
Packit 64f477
    sample_t clev;		/* centre channel mix level */
Packit 64f477
    sample_t slev;		/* surround channels mix level */
Packit 64f477
Packit 64f477
    int output;			/* type of output */
Packit 64f477
    sample_t level;		/* output level */
Packit 64f477
    sample_t bias;		/* output bias */
Packit 64f477
Packit 64f477
    int dynrnge;		/* apply dynamic range */
Packit 64f477
    sample_t dynrng;		/* dynamic range */
Packit 64f477
    void * dynrngdata;		/* dynamic range callback funtion and data */
Packit 64f477
    sample_t (* dynrngcall) (sample_t range, void * dynrngdata);
Packit 64f477
Packit 64f477
    uint8_t chincpl;		/* channel coupled */
Packit 64f477
    uint8_t phsflginu;		/* phase flags in use (stereo only) */
Packit 64f477
    uint8_t cplstrtmant;	/* coupling channel start mantissa */
Packit 64f477
    uint8_t cplendmant;		/* coupling channel end mantissa */
Packit 64f477
    uint32_t cplbndstrc;	/* coupling band structure */
Packit 64f477
    sample_t cplco[5][18];	/* coupling coordinates */
Packit 64f477
Packit 64f477
    /* derived information */
Packit 64f477
    uint8_t cplstrtbnd;		/* coupling start band (for bit allocation) */
Packit 64f477
    uint8_t ncplbnd;		/* number of coupling bands */
Packit 64f477
Packit 64f477
    uint8_t rematflg;		/* stereo rematrixing */
Packit 64f477
Packit 64f477
    uint8_t endmant[5];		/* channel end mantissa */
Packit 64f477
Packit 64f477
    uint16_t bai;		/* bit allocation information */
Packit 64f477
Packit 64f477
    uint32_t * buffer_start;
Packit 64f477
    uint16_t lfsr_state;	/* dither state */
Packit 64f477
    uint32_t bits_left;
Packit 64f477
    uint32_t current_word;
Packit 64f477
Packit 64f477
    uint8_t csnroffst;		/* coarse SNR offset */
Packit 64f477
    ba_t cplba;			/* coupling bit allocation parameters */
Packit 64f477
    ba_t ba[5];			/* channel bit allocation parameters */
Packit 64f477
    ba_t lfeba;			/* lfe bit allocation parameters */
Packit 64f477
Packit 64f477
    uint8_t cplfleak;		/* coupling fast leak init */
Packit 64f477
    uint8_t cplsleak;		/* coupling slow leak init */
Packit 64f477
Packit 64f477
    expbap_t cpl_expbap;
Packit 64f477
    expbap_t fbw_expbap[5];
Packit 64f477
    expbap_t lfe_expbap;
Packit 64f477
Packit 64f477
    sample_t * samples;
Packit 64f477
    int downmixed;
Packit 64f477
};
Packit 64f477
Packit 64f477
#define LEVEL_PLUS6DB 2.0
Packit 64f477
#define LEVEL_PLUS3DB 1.4142135623730951
Packit 64f477
#define LEVEL_3DB 0.7071067811865476
Packit 64f477
#define LEVEL_45DB 0.5946035575013605
Packit 64f477
#define LEVEL_6DB 0.5
Packit 64f477
Packit 64f477
#define EXP_REUSE (0)
Packit 64f477
#define EXP_D15   (1)
Packit 64f477
#define EXP_D25   (2)
Packit 64f477
#define EXP_D45   (3)
Packit 64f477
Packit 64f477
#define DELTA_BIT_REUSE (0)
Packit 64f477
#define DELTA_BIT_NEW (1)
Packit 64f477
#define DELTA_BIT_NONE (2)
Packit 64f477
#define DELTA_BIT_RESERVED (3)
Packit 64f477
Packit 64f477
void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
Packit 64f477
		       int start, int end, int fastleak, int slowleak,
Packit 64f477
		       expbap_t * expbap);
Packit 64f477
Packit 64f477
int a52_downmix_init (int input, int flags, sample_t * level,
Packit 64f477
		      sample_t clev, sample_t slev);
Packit 64f477
int a52_downmix_coeff (sample_t * coeff, int acmod, int output, sample_t level,
Packit 64f477
		       sample_t clev, sample_t slev);
Packit 64f477
void a52_downmix (sample_t * samples, int acmod, int output, sample_t bias,
Packit 64f477
		  sample_t clev, sample_t slev);
Packit 64f477
void a52_upmix (sample_t * samples, int acmod, int output);
Packit 64f477
Packit 64f477
void a52_imdct_init (uint32_t mm_accel);
Packit 64f477
void a52_imdct_256 (sample_t * data, sample_t * delay, sample_t bias);
Packit 64f477
void a52_imdct_512 (sample_t * data, sample_t * delay, sample_t bias);