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

📄 parse.c

📁 杜比AC-3编码解码器(参考程序)
💻 C
📖 第 1 页 / 共 2 页
字号:
	}

	/* If we're in dual mono mode then get the second channel DR info */
	if (bsi->acmod == 0)
	{
		/* Does dynamic range control two exist? */
		audblk->dynrng2e = bitstream_get(1);
		if (audblk->dynrng2e)
		{
			/* Get dynamic range info */
			audblk->dynrng2 = bitstream_get(8);
		}
	}

	/* Does coupling strategy exist? */
	audblk->cplstre = bitstream_get(1);
	if (audblk->cplstre)
	{
		/* Is coupling turned on? */
		audblk->cplinu = bitstream_get(1);
		if(audblk->cplinu)
		{
			for(i=0;i < bsi->nfchans; i++)
				audblk->chincpl[i] = bitstream_get(1);
			if(bsi->acmod == 0x2)
				audblk->phsflginu = bitstream_get(1);
			audblk->cplbegf = bitstream_get(4);
			audblk->cplendf = bitstream_get(4);
			audblk->ncplsubnd = (audblk->cplendf + 2) - audblk->cplbegf + 1;

			/* Calculate the start and end bins of the coupling channel */
			audblk->cplstrtmant = (audblk->cplbegf * 12) + 37 ; 
			audblk->cplendmant =  ((audblk->cplendf + 3) * 12) + 37;

			/* The number of combined subbands is ncplsubnd minus each combined
			 * band */
			audblk->ncplbnd = audblk->ncplsubnd; 

			for(i=1; i< audblk->ncplsubnd; i++)
			{
				audblk->cplbndstrc[i] = bitstream_get(1);
				audblk->ncplbnd -= audblk->cplbndstrc[i];
			}
		}
	}

	if(audblk->cplinu)
	{
		/* Loop through all the channels and get their coupling co-ords */	
		for(i=0;i < bsi->nfchans;i++)
		{
			if(!audblk->chincpl[i])
				continue;

			/* Is there new coupling co-ordinate info? */
			audblk->cplcoe[i] = bitstream_get(1);

			if(audblk->cplcoe[i])
			{
				audblk->mstrcplco[i] = bitstream_get(2); 
				for(j=0;j < audblk->ncplbnd; j++)
				{
					audblk->cplcoexp[i][j] = bitstream_get(4); 
					audblk->cplcomant[i][j] = bitstream_get(4); 
				}
			}
		}

		/* If we're in dual mono mode, there's going to be some phase info */
		if( (bsi->acmod == 0x2) && audblk->phsflginu && 
				(audblk->cplcoe[0] || audblk->cplcoe[1]))
		{
			for(j=0;j < audblk->ncplbnd; j++)
				audblk->phsflg[j] = bitstream_get(1); 

		}
	}

	/* If we're in dual mono mode, there may be a rematrix strategy */
	if(bsi->acmod == 0x2)
	{
		audblk->rematstr = bitstream_get(1);
		if(audblk->rematstr)
		{
			if (audblk->cplinu == 0) 
			{ 
				for(i = 0; i < 4; i++) 
					audblk->rematflg[i] = bitstream_get(1);
			}
			if((audblk->cplbegf > 2) && audblk->cplinu) 
			{
				for(i = 0; i < 4; i++) 
					audblk->rematflg[i] = bitstream_get(1);
			}
			if((audblk->cplbegf <= 2) && audblk->cplinu) 
			{ 
				for(i = 0; i < 3; i++) 
					audblk->rematflg[i] = bitstream_get(1);
			} 
			if((audblk->cplbegf == 0) && audblk->cplinu) 
				for(i = 0; i < 2; i++) 
					audblk->rematflg[i] = bitstream_get(1);

		}
	}

	if (audblk->cplinu)
	{
		/* Get the coupling channel exponent strategy */
		audblk->cplexpstr = bitstream_get(2);
		audblk->ncplgrps = (audblk->cplendmant - audblk->cplstrtmant) / 
				(3 << (audblk->cplexpstr-1));
	}

	for(i = 0; i < bsi->nfchans; i++)
		audblk->chexpstr[i] = bitstream_get(2);

	/* Get the exponent strategy for lfe channel */
	if(bsi->lfeon) 
		audblk->lfeexpstr = bitstream_get(1);

	/* Determine the bandwidths of all the fbw channels */
	for(i = 0; i < bsi->nfchans; i++) 
	{ 
		uint_16 grp_size;

		if(audblk->chexpstr[i] != EXP_REUSE) 
		{ 
			if (audblk->cplinu && audblk->chincpl[i]) 
			{
				audblk->endmant[i] = audblk->cplstrtmant;
			}
			else
			{
				audblk->chbwcod[i] = bitstream_get(6); 
				audblk->endmant[i] = ((audblk->chbwcod[i] + 12) * 3) + 37;
			}

			/* Calculate the number of exponent groups to fetch */
			grp_size =  3 * (1 << (audblk->chexpstr[i] - 1));
			audblk->nchgrps[i] = (audblk->endmant[i] - 1 + (grp_size - 3)) / grp_size;
		}
	}

	/* Get the coupling exponents if they exist */
	if(audblk->cplinu && (audblk->cplexpstr != EXP_REUSE))
	{
		audblk->cplabsexp = bitstream_get(4);
		for(i=0;i< audblk->ncplgrps;i++)
			audblk->cplexps[i] = bitstream_get(7);
	}

	/* Get the fwb channel exponents */
	for(i=0;i < bsi->nfchans; i++)
	{
		if(audblk->chexpstr[i] != EXP_REUSE)
		{
			audblk->exps[i][0] = bitstream_get(4);			
			for(j=1;j<=audblk->nchgrps[i];j++)
				audblk->exps[i][j] = bitstream_get(7);
			audblk->gainrng[i] = bitstream_get(2);
		}
	}

	/* Get the lfe channel exponents */
	if(bsi->lfeon && (audblk->lfeexpstr != EXP_REUSE))
	{
		audblk->lfeexps[0] = bitstream_get(4);
		audblk->lfeexps[1] = bitstream_get(7);
		audblk->lfeexps[2] = bitstream_get(7);
	}

	/* Get the parametric bit allocation parameters */
	audblk->baie = bitstream_get(1);

	if(audblk->baie)
	{
		audblk->sdcycod = bitstream_get(2);
		audblk->fdcycod = bitstream_get(2);
		audblk->sgaincod = bitstream_get(2);
		audblk->dbpbcod = bitstream_get(2);
		audblk->floorcod = bitstream_get(3);
	}

	/* Get the SNR off set info if it exists */
	audblk->snroffste = bitstream_get(1);

	if(audblk->snroffste)
	{
		audblk->csnroffst = bitstream_get(6);

		if(audblk->cplinu)
		{
			audblk->cplfsnroffst = bitstream_get(4);
			audblk->cplfgaincod = bitstream_get(3);
		}

		for(i = 0;i < bsi->nfchans; i++)
		{
			audblk->fsnroffst[i] = bitstream_get(4);
			audblk->fgaincod[i] = bitstream_get(3);
		}
		if(bsi->lfeon)
		{

			audblk->lfefsnroffst = bitstream_get(4);
			audblk->lfefgaincod = bitstream_get(3);
		}
	}

	/* Get coupling leakage info if it exists */
	if(audblk->cplinu)
	{
		audblk->cplleake = bitstream_get(1);	
		
		if(audblk->cplleake)
		{
			audblk->cplfleak = bitstream_get(3);
			audblk->cplsleak = bitstream_get(3);
		}
	}
	
	/* Get the delta bit alloaction info */
	audblk->deltbaie = bitstream_get(1);	
	
	if(audblk->deltbaie)
	{
		if(audblk->cplinu)
			audblk->cpldeltbae = bitstream_get(2);

		for(i = 0;i < bsi->nfchans; i++)
			audblk->deltbae[i] = bitstream_get(2);

		if (audblk->cplinu && (audblk->cpldeltbae == DELTA_BIT_NEW))
		{
			audblk->cpldeltnseg = bitstream_get(3);
			for(i = 0;i < audblk->cpldeltnseg + 1; i++)
			{
				audblk->cpldeltoffst[i] = bitstream_get(5);
				audblk->cpldeltlen[i] = bitstream_get(4);
				audblk->cpldeltba[i] = bitstream_get(3);
			}
		}

		for(i = 0;i < bsi->nfchans; i++)
		{
			if (audblk->deltbae[i] == DELTA_BIT_NEW)
			{
				audblk->deltnseg[i] = bitstream_get(3);
				for(j = 0; j < audblk->deltnseg[i] + 1; j++)
				{
					audblk->deltoffst[i][j] = bitstream_get(5);
					audblk->deltlen[i][j] = bitstream_get(4);
					audblk->deltba[i][j] = bitstream_get(3);
				}
			}
		}
	}

	/* Check to see if there's any dummy info to get */
	if((audblk->skiple =  bitstream_get(1)))
	{
		uint_16 skip_data;

		audblk->skipl = bitstream_get(9);
		//XXX remove
		//fprintf(stderr,"(parse) skipping %d bytes\n",audblk->skipl);

		for(i = 0; i < audblk->skipl ; i++)
		{
			skip_data = bitstream_get(8);
			//XXX remove
			//fprintf(stderr,"skipped data %2x\n",skip_data);
			//if(skip_data != 0)
			//{	
				//dprintf("(parse) Invalid skipped data %2x\n",skip_data);
				//exit(1);
			//}
		}
	}

	stats_print_audblk(bsi,audblk);
}

void
parse_auxdata(syncinfo_t *syncinfo)
{
	//FIXME keep this now that we don't really need it?
#if 0
	int i;
	int skip_length;
	uint_16 crc;
	uint_16 auxdatae;

	skip_length = (syncinfo->frame_size * 16)  - bitstream_get_total_bits() - 17 - 1;

	//XXX remove
	//dprintf("(auxdata) skipping %d auxbits\n",skip_length);
	
	for(i=0; i <  skip_length; i++)
		//printf("Skipped bit %i\n",(uint_16)bitstream_get(1));
		bitstream_get(1);

	//get the auxdata exists bit
	auxdatae = bitstream_get(1);	

	//XXX remove
	//dprintf("auxdatae = %i\n",auxdatae);

	//Skip the CRC reserved bit
	bitstream_get(1);

	//Get the crc
	crc = bitstream_get(16);
#endif
}


⌨️ 快捷键说明

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