⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parse.c

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.10平台上编译为嵌入式图形界面操作系统。
💻 C
📖 第 1 页 / 共 2 页
字号:
			    samples[ch][i] = 0;		    }		i++;		continue;	    case -1:		if (quant->q1_ptr >= 0) {		    cplcoeff = quant->q1[quant->q1_ptr--];		    break;		} else {		    int code;		    code = bitstream_get (state, 5);		    quant->q1_ptr = 1;		    quant->q1[0] = q_1_2[code];		    quant->q1[1] = q_1_1[code];		    cplcoeff = q_1_0[code];		    break;		}	    case -2:		if (quant->q2_ptr >= 0) {		    cplcoeff = quant->q2[quant->q2_ptr--];		    break;		} else {		    int code;		    code = bitstream_get (state, 7);		    quant->q2_ptr = 1;		    quant->q2[0] = q_2_2[code];		    quant->q2[1] = q_2_1[code];		    cplcoeff = q_2_0[code];		    break;		}	    case 3:		cplcoeff = q_3[bitstream_get (state, 3)];		break;	    case -3:		if (quant->q4_ptr == 0) {		    quant->q4_ptr = -1;		    cplcoeff = quant->q4;		    break;		} else {		    int code;		    code = bitstream_get (state, 7);		    quant->q4_ptr = 0;		    quant->q4 = q_4_1[code];		    cplcoeff = q_4_0[code];		    break;		}	    case 4:		cplcoeff = q_5[bitstream_get (state, 4)];		break;	    default:		cplcoeff = bitstream_get_2 (state, bapi) << (16 - bapi);	    }#ifndef LIBA52_FIXED	    cplcoeff *= scale_factor[exp[i]];#endif	    for (ch = 0; ch < nfchans; ch++)	       if ((state->chincpl >> ch) & 1)#ifndef LIBA52_FIXED		    samples[ch][i] = cplcoeff * cplco[ch];#else		    COEFF (samples[ch][i], cplcoeff, cplco[ch],			   scale_factor, exp[i]);#endif	    i++;	}    }}int a52_block (a52_state_t * state){    static const uint8_t nfchans_tbl[] = {2, 1, 2, 3, 3, 4, 4, 5, 1, 1, 2};    static int rematrix_band[4] = {25, 37, 61, 253};    int i, nfchans, chaninfo;    uint8_t cplexpstr, chexpstr[5], lfeexpstr, do_bit_alloc, done_cpl;    uint8_t blksw[5], dithflag[5];    level_t coeff[5];    int chanbias;    quantizer_set_t quant;    sample_t * samples;    nfchans = nfchans_tbl[state->acmod];    for (i = 0; i < nfchans; i++)	blksw[i] = bitstream_get (state, 1);    for (i = 0; i < nfchans; i++)	dithflag[i] = bitstream_get (state, 1);    chaninfo = !state->acmod;    do {	if (bitstream_get (state, 1)) {	/* dynrnge */	    int dynrng;	    dynrng = bitstream_get_2 (state, 8);	    if (state->dynrnge) {		level_t range;#if !defined(LIBA52_FIXED)		range = ((((dynrng & 0x1f) | 0x20) << 13) *			 scale_factor[3 - (dynrng >> 5)]);#else		range = ((dynrng & 0x1f) | 0x20) << (21 + (dynrng >> 5));#endif		if (state->dynrngcall)		    range = state->dynrngcall (range, state->dynrngdata);		state->dynrng = MUL_L (state->level, range);	    }	}    } while (chaninfo--);    if (bitstream_get (state, 1)) {	/* cplstre */	state->chincpl = 0;	if (bitstream_get (state, 1)) {	/* cplinu */	    static uint8_t bndtab[16] = {31, 35, 37, 39, 41, 42, 43, 44,					 45, 45, 46, 46, 47, 47, 48, 48};	    int cplbegf;	    int cplendf;	    int ncplsubnd;	    for (i = 0; i < nfchans; i++)		state->chincpl |= bitstream_get (state, 1) << i;	    switch (state->acmod) {	    case 0: case 1:		return 1;	    case 2:		state->phsflginu = bitstream_get (state, 1);	    }	    cplbegf = bitstream_get (state, 4);	    cplendf = bitstream_get (state, 4);	    if (cplendf + 3 - cplbegf < 0)		return 1;	    state->ncplbnd = ncplsubnd = cplendf + 3 - cplbegf;	    state->cplstrtbnd = bndtab[cplbegf];	    state->cplstrtmant = cplbegf * 12 + 37;	    state->cplendmant = cplendf * 12 + 73;	    state->cplbndstrc = 0;	    for (i = 0; i < ncplsubnd - 1; i++)		if (bitstream_get (state, 1)) {		    state->cplbndstrc |= 1 << i;		    state->ncplbnd--;		}	}    }    if (state->chincpl) {	/* cplinu */	int j, cplcoe;	cplcoe = 0;	for (i = 0; i < nfchans; i++)	    if ((state->chincpl) >> i & 1)		if (bitstream_get (state, 1)) {	/* cplcoe */		    int mstrcplco, cplcoexp, cplcomant;		    cplcoe = 1;		    mstrcplco = 3 * bitstream_get (state, 2);		    for (j = 0; j < state->ncplbnd; j++) {			cplcoexp = bitstream_get (state, 4);			cplcomant = bitstream_get (state, 4);			if (cplcoexp == 15)			    cplcomant <<= 14;			else			    cplcomant = (cplcomant | 0x10) << 13;#ifndef LIBA52_FIXED			state->cplco[i][j] =			    cplcomant * scale_factor[cplcoexp + mstrcplco];#else			state->cplco[i][j] = (cplcomant << 11) >> (cplcoexp + mstrcplco);#endif		    }		}	if ((state->acmod == 2) && state->phsflginu && cplcoe)	    for (j = 0; j < state->ncplbnd; j++)		if (bitstream_get (state, 1))	/* phsflg */		    state->cplco[1][j] = -state->cplco[1][j];    }    if ((state->acmod == 2) && (bitstream_get (state, 1))) {	/* rematstr */	int end;	state->rematflg = 0;	end = (state->chincpl) ? state->cplstrtmant : 253;	/* cplinu */	i = 0;	do	    state->rematflg |= bitstream_get (state, 1) << i;	while (rematrix_band[i++] < end);    }    cplexpstr = EXP_REUSE;    lfeexpstr = EXP_REUSE;    if (state->chincpl)	/* cplinu */	cplexpstr = bitstream_get (state, 2);    for (i = 0; i < nfchans; i++)	chexpstr[i] = bitstream_get (state, 2);    if (state->lfeon) 	lfeexpstr = bitstream_get (state, 1);    for (i = 0; i < nfchans; i++)	if (chexpstr[i] != EXP_REUSE) {	    if ((state->chincpl >> i) & 1)		state->endmant[i] = state->cplstrtmant;	    else {		int chbwcod;		chbwcod = bitstream_get (state, 6);		if (chbwcod > 60)		    return 1;		state->endmant[i] = chbwcod * 3 + 73;	    }	}    do_bit_alloc = 0;    if (cplexpstr != EXP_REUSE) {	int cplabsexp, ncplgrps;	do_bit_alloc = 64;	ncplgrps = ((state->cplendmant - state->cplstrtmant) /		    (3 << (cplexpstr - 1)));	cplabsexp = bitstream_get (state, 4) << 1;	if (parse_exponents (state, cplexpstr, ncplgrps, cplabsexp,			     state->cpl_expbap.exp + state->cplstrtmant))	    return 1;    }    for (i = 0; i < nfchans; i++)	if (chexpstr[i] != EXP_REUSE) {	    int grp_size, nchgrps;	    do_bit_alloc |= 1 << i;	    grp_size = 3 << (chexpstr[i] - 1);	    nchgrps = (state->endmant[i] + grp_size - 4) / grp_size;	    state->fbw_expbap[i].exp[0] = bitstream_get (state, 4);	    if (parse_exponents (state, chexpstr[i], nchgrps,				 state->fbw_expbap[i].exp[0],				 state->fbw_expbap[i].exp + 1))		return 1;	    bitstream_get (state, 2);	/* gainrng */	}    if (lfeexpstr != EXP_REUSE) {	do_bit_alloc |= 32;	state->lfe_expbap.exp[0] = bitstream_get (state, 4);	if (parse_exponents (state, lfeexpstr, 2, state->lfe_expbap.exp[0],			     state->lfe_expbap.exp + 1))	    return 1;    }    if (bitstream_get (state, 1)) {	/* baie */	do_bit_alloc = 127;	state->bai = bitstream_get (state, 11);    }    if (bitstream_get (state, 1)) {	/* snroffste */	do_bit_alloc = 127;	state->csnroffst = bitstream_get (state, 6);	if (state->chincpl)	/* cplinu */	    state->cplba.bai = bitstream_get (state, 7);	for (i = 0; i < nfchans; i++)	    state->ba[i].bai = bitstream_get (state, 7);	if (state->lfeon)	    state->lfeba.bai = bitstream_get (state, 7);    }    if ((state->chincpl) && (bitstream_get (state, 1))) { /* cplleake */	do_bit_alloc |= 64;	state->cplfleak = 9 - bitstream_get (state, 3);	state->cplsleak = 9 - bitstream_get (state, 3);    }    if (bitstream_get (state, 1)) {	/* deltbaie */	do_bit_alloc = 127;	if (state->chincpl)	/* cplinu */	    state->cplba.deltbae = bitstream_get (state, 2);	for (i = 0; i < nfchans; i++)	    state->ba[i].deltbae = bitstream_get (state, 2);	if (state->chincpl &&	/* cplinu */	    (state->cplba.deltbae == DELTA_BIT_NEW) &&	    parse_deltba (state, state->cplba.deltba))	    return 1;	for (i = 0; i < nfchans; i++)	    if ((state->ba[i].deltbae == DELTA_BIT_NEW) &&		parse_deltba (state, state->ba[i].deltba))		return 1;    }    if (do_bit_alloc) {	if (zero_snr_offsets (nfchans, state)) {	    memset (state->cpl_expbap.bap, 0, sizeof (state->cpl_expbap.bap));	    for (i = 0; i < nfchans; i++)		memset (state->fbw_expbap[i].bap, 0,			sizeof (state->fbw_expbap[i].bap));	    memset (state->lfe_expbap.bap, 0, sizeof (state->lfe_expbap.bap));	} else {	    if (state->chincpl && (do_bit_alloc & 64))	/* cplinu */		a52_bit_allocate (state, &state->cplba, state->cplstrtbnd,				  state->cplstrtmant, state->cplendmant,				  state->cplfleak << 8, state->cplsleak << 8,				  &state->cpl_expbap);	    for (i = 0; i < nfchans; i++)		if (do_bit_alloc & (1 << i))		    a52_bit_allocate (state, state->ba + i, 0, 0,				      state->endmant[i], 0, 0,				      state->fbw_expbap +i);	    if (state->lfeon && (do_bit_alloc & 32)) {		state->lfeba.deltbae = DELTA_BIT_NONE;		a52_bit_allocate (state, &state->lfeba, 0, 0, 7, 0, 0,				  &state->lfe_expbap);	    }	}    }    if (bitstream_get (state, 1)) {	/* skiple */	i = bitstream_get (state, 9);	/* skipl */	while (i--)	    bitstream_get (state, 8);    }    samples = state->samples;    if (state->output & A52_LFE)	samples += 256;	/* shift for LFE channel */    chanbias = a52_downmix_coeff (coeff, state->acmod, state->output,				  state->dynrng, state->clev, state->slev);    quant.q1_ptr = quant.q2_ptr = quant.q4_ptr = -1;    done_cpl = 0;    for (i = 0; i < nfchans; i++) {	int j;	coeff_get (state, samples + 256 * i, state->fbw_expbap +i, &quant,		   coeff[i], dithflag[i], state->endmant[i]);	if ((state->chincpl >> i) & 1) {	    if (!done_cpl) {		done_cpl = 1;		coeff_get_coupling (state, nfchans, coeff,				    (sample_t (*)[256])samples, &quant,				    dithflag);	    }	    j = state->cplendmant;	} else	    j = state->endmant[i];	do	    (samples + 256 * i)[j] = 0;	while (++j < 256);    }    if (state->acmod == 2) {	int j, end, band, rematflg;	end = ((state->endmant[0] < state->endmant[1]) ?	       state->endmant[0] : state->endmant[1]);	i = 0;	j = 13;	rematflg = state->rematflg;	do {	    if (! (rematflg & 1)) {		rematflg >>= 1;		j = rematrix_band[i++];		continue;	    }	    rematflg >>= 1;	    band = rematrix_band[i++];	    if (band > end)		band = end;	    do {		sample_t tmp0, tmp1;		tmp0 = samples[j];		tmp1 = (samples+256)[j];		samples[j] = tmp0 + tmp1;		(samples+256)[j] = tmp0 - tmp1;	    } while (++j < band);	} while (j < end);    }    if (state->lfeon) {	if (state->output & A52_LFE) {	    coeff_get (state, samples - 256, &state->lfe_expbap, &quant,		       state->dynrng, 0, 7);	    for (i = 7; i < 256; i++)		(samples-256)[i] = 0;	    a52_imdct_512 (samples - 256, samples + 1536 - 256, state->bias);	} else {	    /* just skip the LFE coefficients */	    coeff_get (state, samples + 1280, &state->lfe_expbap, &quant,		       0, 0, 7);	}    }    i = 0;    if (nfchans_tbl[state->output & A52_CHANNEL_MASK] < nfchans)	for (i = 1; i < nfchans; i++)	    if (blksw[i] != blksw[0])		break;    if (i < nfchans) {	if (state->downmixed) {	    state->downmixed = 0;	    a52_upmix (samples + 1536, state->acmod, state->output);	}	for (i = 0; i < nfchans; i++) {	    sample_t bias;	    bias = 0;	    if (!(chanbias & (1 << i)))		bias = state->bias;	    if (coeff[i]) {		if (blksw[i])		    a52_imdct_256 (samples + 256 * i, samples + 1536 + 256 * i,				   bias);		else 		    a52_imdct_512 (samples + 256 * i, samples + 1536 + 256 * i,				   bias);	    } else {		int j;		for (j = 0; j < 256; j++)		    (samples + 256 * i)[j] = bias;	    }	}	a52_downmix (samples, state->acmod, state->output, state->bias,		     state->clev, state->slev);    } else {	nfchans = nfchans_tbl[state->output & A52_CHANNEL_MASK];	a52_downmix (samples, state->acmod, state->output, 0,		     state->clev, state->slev);	if (!state->downmixed) {	    state->downmixed = 1;	    a52_downmix (samples + 1536, state->acmod, state->output, 0,			 state->clev, state->slev);	}	if (blksw[0])	    for (i = 0; i < nfchans; i++)		a52_imdct_256 (samples + 256 * i, samples + 1536 + 256 * i,			       state->bias);	else 	    for (i = 0; i < nfchans; i++)		a52_imdct_512 (samples + 256 * i, samples + 1536 + 256 * i,			       state->bias);    }    return 0;}void a52_free (a52_state_t * state){    free (state->samples);    free (state);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -