1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-21 22:12:58 +02:00

Update twolame to 0.3.13.

This commit is contained in:
lllucius
2013-10-24 04:32:13 +00:00
parent 99acb56af6
commit 3effa9693f
124 changed files with 44671 additions and 44430 deletions

View File

@@ -18,7 +18,7 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id: dab.c,v 1.3 2008-02-01 19:44:31 richardash1981 Exp $
* $Id$
*
*/
@@ -32,61 +32,59 @@
void
dab_crc_calc ( twolame_options *glopts,
unsigned int bit_alloc[2][SBLIMIT],
unsigned int scfsi[2][SBLIMIT],
unsigned int scalar[2][3][SBLIMIT],
unsigned int *crc,
int packed)
dab_crc_calc(twolame_options * glopts,
unsigned int bit_alloc[2][SBLIMIT],
unsigned int scfsi[2][SBLIMIT],
unsigned int scalar[2][3][SBLIMIT], unsigned int *crc, int packed)
{
int i, j, k;
int nch = glopts->num_channels_out;
int nb_scalar;
int f[5] = { 0, 4, 8, 16, 30 };
int first, last;
first = f[packed];
last = f[packed + 1];
if (last > glopts->sblimit)
last = glopts->sblimit;
nb_scalar = 0;
*crc = 0x0;
for (i = first; i < last; i++)
for (k = 0; k < nch; k++)
if (bit_alloc[k][i]) /* above jsbound, bit_alloc[0][i] == ba[1][i] */
switch (scfsi[k][i]) {
case 0:
for (j = 0; j < 3; j++) {
nb_scalar++;
dab_crc_update (scalar[k][j][i] >> 3, 3, crc);
}
break;
case 1:
case 3:
nb_scalar += 2;
dab_crc_update (scalar[k][0][i] >> 3, 3, crc);
dab_crc_update (scalar[k][2][i] >> 3, 3, crc);
break;
case 2:
nb_scalar++;
dab_crc_update (scalar[k][0][i] >> 3, 3, crc);
}
int i, j, k;
int nch = glopts->num_channels_out;
int nb_scalar;
int f[5] = { 0, 4, 8, 16, 30 };
int first, last;
first = f[packed];
last = f[packed + 1];
if (last > glopts->sblimit)
last = glopts->sblimit;
nb_scalar = 0;
*crc = 0x0;
for (i = first; i < last; i++)
for (k = 0; k < nch; k++)
if (bit_alloc[k][i]) /* above jsbound, bit_alloc[0][i] == ba[1][i] */
switch (scfsi[k][i]) {
case 0:
for (j = 0; j < 3; j++) {
nb_scalar++;
dab_crc_update(scalar[k][j][i] >> 3, 3, crc);
}
break;
case 1:
case 3:
nb_scalar += 2;
dab_crc_update(scalar[k][0][i] >> 3, 3, crc);
dab_crc_update(scalar[k][2][i] >> 3, 3, crc);
break;
case 2:
nb_scalar++;
dab_crc_update(scalar[k][0][i] >> 3, 3, crc);
}
}
void dab_crc_update (unsigned int data, unsigned int length, unsigned int *crc)
void dab_crc_update(unsigned int data, unsigned int length, unsigned int *crc)
{
unsigned int masking, carry;
masking = 1 << length;
while ((masking >>= 1)) {
carry = *crc & 0x80;
*crc <<= 1;
if (!carry ^ !(data & masking))
*crc ^= CRC8_POLYNOMIAL;
}
*crc &= 0xff;
unsigned int masking, carry;
masking = 1 << length;
while ((masking >>= 1)) {
carry = *crc & 0x80;
*crc <<= 1;
if (!carry ^ !(data & masking))
*crc ^= CRC8_POLYNOMIAL;
}
*crc &= 0xff;
}
@@ -108,39 +106,38 @@ void dab_crc_update (unsigned int data, unsigned int length, unsigned int *crc)
allocated some bits for the DAB stuff
*/
if (header.dab_extension) {
/* in 24 kHz we always have 4 bytes */
if (header.sampling_frequency == 1)
header.dab_extension = 4;
/* You must have one frame in memory if you are in DAB mode */
/* in conformity of the norme ETS 300 401 http://www.etsi.org */
/* see bitstream.c */
if (frameNum == 1) minimum = lg_frame + MINIMUM;
adb -= header.dab_extension * 8 + header.dab_length * 8 + 16;
}
if (header.dab_extension) {
/* in 24 kHz we always have 4 bytes */
if (header.sampling_frequency == 1)
header.dab_extension = 4;
/* You must have one frame in memory if you are in DAB mode */
/* in conformity of the norme ETS 300 401 http://www.etsi.org */
/* see bitstream.c */
if (frameNum == 1)
minimum = lg_frame + MINIMUM;
adb -= header.dab_extension * 8 + header.dab_length * 8 + 16;
}
/*
Just after we finishing padding up to the number of ADB
Put the extension stuff in (ancillary data, right at the end)
*/
if (header.dab_extension) {
/* Reserve some bytes for X-PAD in DAB mode */
putbits (mybs, 0, header.dab_length * 8);
for (i = header.dab_extension - 1; i >= 0; i--) {
CRC_calcDAB (&frame, bit_alloc, scfsi, scalar, &crc, i);
/* this crc is for the previous frame in DAB mode */
if (mybs->buf_byte_idx + lg_frame < mybs->buf_size)
mybs->buf[mybs->buf_byte_idx + lg_frame] = crc;
/* reserved 2 bytes for F-PAD in DAB mode */
putbits (mybs, crc, 8);
}
putbits (mybs, 0, 16);
}
if (header.dab_extension) {
/* Reserve some bytes for X-PAD in DAB mode */
putbits(mybs, 0, header.dab_length * 8);
for (i = header.dab_extension - 1; i >= 0; i--) {
CRC_calcDAB(&frame, bit_alloc, scfsi, scalar, &crc, i);
/* this crc is for the previous frame in DAB mode */
if (mybs->buf_byte_idx + lg_frame < mybs->buf_size)
mybs->buf[mybs->buf_byte_idx + lg_frame] = crc;
/* reserved 2 bytes for F-PAD in DAB mode */
putbits(mybs, crc, 8);
}
putbits(mybs, 0, 16);
}
#endif
// vim:ts=4:sw=4:nowrap: