[Mplayer-cvslog] CVS: main/libfaad2 Makefile,1.1,1.2 bits.c,1.1,1.2 bits.h,1.2,1.3 cfft.c,1.1,1.2 cfft_tab.h,1.1,1.2 common.c,1.1,1.2 common.h,1.2,1.3 decoder.c,1.1,1.2 decoder.h,1.1,1.2 dither.c,1.1,1.2 dither.h,1.1,1.2 drc.c,1.1,1.2 faad.h,1.1,1.2 filtbank.c,1.1,1.2 filtbank.h,1.1,1.2 fixed.h,1.1,1.2 hcr.c,1.1,1.2 huffman.h,1.1,1.2 iq_table.h,1.1,1.2 is.c,1.1,1.2 is.h,1.1,1.2 kbd_win.h,1.1,1.2 lt_predict.c,1.1,1.2 lt_predict.h,1.1,1.2 mdct.c,1.1,1.2 mdct.h,1.1,1.2 mp4.c,1.1,1.2 mp4.h,1.1,1.2 ms.c,1.1,1.2 ms.h,1.1,1.2 output.c,1.1,1.2 output.h,1.1,1.2 pns.c,1.1,1.2 pns.h,1.1,1.2 pulse.c,1.1,1.2 pulse.h,1.1,1.2 rvlc.c,1.1,1.2 rvlc.h,1.1,1.2 sbr_dct.c,1.1,1.2 sbr_dct.h,1.1,1.2 sbr_dec.c,1.1,1.2 sbr_dec.h,1.1,1.2 sbr_e_nf.c,1.1,1.2 sbr_e_nf.h,1.1,1.2 sbr_fbt.c,1.1,1.2 sbr_fbt.h,1.1,1.2 sbr_hfadj.c,1.1,1.2 sbr_hfadj.h,1.1,1.2 sbr_hfgen.c,1.1,1.2 sbr_hfgen.h,1.1,1.2 sbr_huff.c,1.1,1.2 sbr_huff.h,1.1,1.2 sbr_noise.h,1.1,1.2 sbr_qmf.c,1.1,1.2 sbr_qmf.h,1.1,1.2 sbr_syntax.c,1.1,1.2 sbr_syntax.h,1.1,1.2 sbr_tf_grid.c,1.1,1.2 sbr_tf_grid.h,1.1,1.2 sine_win.h,1.1,1.2 specrec.c,1.1,1.2 specrec.h,1.1,1.2 ssr.c,1.1,1.2 ssr.h,1.1,1.2 ssr_fb.c,1.1,1.2 ssr_fb.h,1.1,1.2 ssr_ipqf.c,1.1,1.2 ssr_ipqf.h,1.1,1.2 ssr_win.h,1.1,1.2 structs.h,1.1,1.2 syntax.c,1.1,1.2 syntax.h,1.1,1.2 tns.c,1.1,1.2 tns.h,1.1,1.2
Alex Beregszaszi
alex at mplayerhq.hu
Sat Oct 4 00:23:01 CEST 2003
Update of /cvsroot/mplayer/main/libfaad2
In directory mail:/var/tmp.root/cvs-serv7809
Modified Files:
Makefile bits.c bits.h cfft.c cfft_tab.h common.c common.h
decoder.c decoder.h dither.c dither.h drc.c faad.h filtbank.c
filtbank.h fixed.h hcr.c huffman.h iq_table.h is.c is.h
kbd_win.h lt_predict.c lt_predict.h mdct.c mdct.h mp4.c mp4.h
ms.c ms.h output.c output.h pns.c pns.h pulse.c pulse.h rvlc.c
rvlc.h sbr_dct.c sbr_dct.h sbr_dec.c sbr_dec.h sbr_e_nf.c
sbr_e_nf.h sbr_fbt.c sbr_fbt.h sbr_hfadj.c sbr_hfadj.h
sbr_hfgen.c sbr_hfgen.h sbr_huff.c sbr_huff.h sbr_noise.h
sbr_qmf.c sbr_qmf.h sbr_syntax.c sbr_syntax.h sbr_tf_grid.c
sbr_tf_grid.h sine_win.h specrec.c specrec.h ssr.c ssr.h
ssr_fb.c ssr_fb.h ssr_ipqf.c ssr_ipqf.h ssr_win.h structs.h
syntax.c syntax.h tns.c tns.h
Log Message:
synced with current cvs
Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/Makefile,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Makefile 30 Aug 2003 22:30:20 -0000 1.1
+++ Makefile 3 Oct 2003 22:22:27 -0000 1.2
@@ -3,7 +3,7 @@
include ../config.mak
-SRCS = bits.c cfft.c common.c decoder.c dither.c drc.c error.c filtbank.c hcr.c ic_predict.c is.c lt_predict.c mdct.c mp4.c ms.c output.c pns.c pulse.c rvlc.c sbr_dct.c sbr_dec.c sbr_e_nf.c sbr_fbt.c sbr_hfadj.c sbr_hfgen.c sbr_huff.c sbr_qmf.c sbr_syntax.c sbr_tf_grid.c specrec.c ssr.c ssr_fb.c ssr_ipqf.c syntax.c tns.c
+SRCS = bits.c cfft.c common.c decoder.c dither.c drc.c error.c filtbank.c hcr.c huffman.c ic_predict.c is.c lt_predict.c mdct.c mp4.c ms.c output.c pns.c pulse.c rvlc.c sbr_dct.c sbr_dec.c sbr_e_nf.c sbr_fbt.c sbr_hfadj.c sbr_hfgen.c sbr_huff.c sbr_qmf.c sbr_syntax.c sbr_tf_grid.c specrec.c ssr.c ssr_fb.c ssr_ipqf.c syntax.c tns.c
OBJS = $(SRCS:.c=.o)
CFLAGS = -I. $(OPTFLAGS)
Index: bits.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/bits.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- bits.c 30 Aug 2003 22:30:21 -0000 1.1
+++ bits.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -37,6 +37,18 @@
{
uint32_t tmp;
+ if (ld == NULL)
+ return;
+
+ memset(ld, 0, sizeof(bitfile));
+
+ if (buffer_size == 0 || _buffer == NULL)
+ {
+ ld->error = 1;
+ ld->no_more_reading = 1;
+ return;
+ }
+
ld->buffer = malloc((buffer_size+12)*sizeof(uint8_t));
memset(ld->buffer, 0, (buffer_size+12)*sizeof(uint8_t));
memcpy(ld->buffer, _buffer, buffer_size*sizeof(uint8_t));
@@ -71,10 +83,9 @@
if (ld->buffer) free(ld->buffer);
}
-
uint32_t faad_get_processed_bits(bitfile *ld)
{
- return 8 * (4*(ld->tail - ld->start) - 4) - (ld->bits_left);
+ return (uint32_t)(8 * (4*(ld->tail - ld->start) - 4) - (ld->bits_left));
}
uint8_t faad_byte_align(bitfile *ld)
@@ -87,6 +98,25 @@
return (8 - remainder);
}
return 0;
+}
+
+void faad_flushbits_ex(bitfile *ld, uint32_t bits)
+{
+ uint32_t tmp;
+
+ ld->bufa = ld->bufb;
+ tmp = getdword(ld->tail);
+ ld->tail++;
+#ifndef ARCH_IS_BIG_ENDIAN
+ BSWAP(tmp);
+#endif
+ ld->bufb = tmp;
+ ld->bits_left += (32 - bits);
+ ld->bytes_used += 4;
+ if (ld->bytes_used == ld->buffer_size)
+ ld->no_more_reading = 1;
+ if (ld->bytes_used > ld->buffer_size)
+ ld->error = 1;
}
/* rewind to beginning */
Index: bits.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/bits.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- bits.h 2 Sep 2003 20:40:36 -0000 1.2
+++ bits.h 3 Oct 2003 22:22:27 -0000 1.3
@@ -79,6 +79,7 @@
uint32_t bits_in_buffer);
uint8_t faad_byte_align(bitfile *ld);
uint32_t faad_get_processed_bits(bitfile *ld);
+void faad_flushbits_ex(bitfile *ld, uint32_t bits);
void faad_rewindbits(bitfile *ld);
uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits
DEBUGDEC);
@@ -104,10 +105,10 @@
if (bits <= ld->bits_left)
{
return (ld->bufa >> (ld->bits_left - bits)) & bitmask[bits];
- } else {
+ }
+
bits -= ld->bits_left;
return ((ld->bufa & bitmask[ld->bits_left]) << bits) | (ld->bufb >> (32 - bits));
- }
}
static INLINE void faad_flushbits(bitfile *ld, uint32_t bits)
@@ -120,21 +121,7 @@
{
ld->bits_left -= bits;
} else {
- uint32_t tmp;
-
- ld->bufa = ld->bufb;
- tmp = getdword(ld->tail);
- ld->tail++;
-#ifndef ARCH_IS_BIG_ENDIAN
- BSWAP(tmp);
-#endif
- ld->bufb = tmp;
- ld->bits_left += (32 - bits);
- ld->bytes_used += 4;
- if (ld->bytes_used == ld->buffer_size)
- ld->no_more_reading = 1;
- if (ld->bytes_used > ld->buffer_size)
- ld->error = 1;
+ faad_flushbits_ex(ld, bits);
}
}
@@ -143,10 +130,7 @@
{
uint32_t ret;
- if (ld->no_more_reading)
- return 0;
-
- if (n == 0)
+ if (ld->no_more_reading || n == 0)
return 0;
ret = faad_showbits(ld, n);
@@ -252,6 +236,121 @@
return ret;
}
+
+#ifdef DRM
+static uint8_t faad_check_CRC(bitfile *ld, uint16_t len)
+{
+ uint8_t CRC;
+ uint16_t r=255; /* Initialize to all ones */
+
+ /* CRC polynome used x^8 + x^4 + x^3 + x^2 +1 */
+#define GPOLY 0435
+
+ faad_rewindbits(ld);
+
+ CRC = ~faad_getbits(ld, 8
+ DEBUGVAR(1,999,"faad_check_CRC(): CRC")); /* CRC is stored inverted */
+
+ for (; len>0; len--)
+ {
+ r = ( (r << 1) ^ (( ( faad_get1bit(ld
+ DEBUGVAR(1,998,"")) & 1) ^ ((r >> 7) & 1)) * GPOLY )) & 0xFF;
+ }
+
+ if (r != CRC)
+ {
+ return 8;
+ } else {
+ return 0;
+ }
+}
+
+static uint8_t tabFlipbits[256] = {
+ 0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240,
+ 8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248,
+ 4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244,
+ 12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,
+ 2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,
+ 10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,
+ 6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,
+ 14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,
+ 1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,
+ 9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,
+ 5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,
+ 13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,
+ 3,131,67,195,35,163,99,227,19,147,83,211,51,179,115,243,
+ 11,139,75,203,43,171,107,235,27,155,91,219,59,187,123,251,
+ 7,135,71,199,39,167,103,231,23,151,87,215,55,183,119,247,
+ 15,143,79,207,47,175,111,239,31,159,95,223,63,191,127,255
+};
+#endif
+
+#ifdef ERROR_RESILIENCE
+
+/* Modified bit reading functions for HCR */
+
+typedef struct
+{
+ /* bit input */
+ uint32_t bufa;
+ uint32_t bufb;
+ int8_t len;
+} bits_t;
+
+
+static INLINE uint32_t showbits_hcr(bits_t *ld, uint8_t bits)
+{
+ if (bits == 0) return 0;
+ if (ld->len <= 32)
+ {
+ /* huffman_spectral_data_2 needs to read more than may be available, bits maybe
+ > ld->len, deliver 0 than */
+ if (ld->len >= bits)
+ return ((ld->bufa >> (ld->len - bits)) & (0xFFFFFFFF >> (32 - bits)));
+ else
+ return ((ld->bufa << (bits - ld->len)) & (0xFFFFFFFF >> (32 - bits)));
+ } else {
+ if ((ld->len - bits) < 32)
+ {
+ return ( (ld->bufb & (0xFFFFFFFF >> (64 - ld->len))) << (bits - ld->len + 32)) |
+ (ld->bufa >> (ld->len - bits));
+ } else {
+ return ((ld->bufb >> (ld->len - bits - 32)) & (0xFFFFFFFF >> (32 - bits)));
+ }
+ }
+}
+
+/* return 1 if position is outside of buffer, 0 otherwise */
+static INLINE int8_t flushbits_hcr( bits_t *ld, uint8_t bits)
+{
+ ld->len -= bits;
+
+ if (ld->len <0)
+ {
+ ld->len = 0;
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+static INLINE int8_t getbits_hcr(bits_t *ld, uint8_t n, uint32_t *result)
+{
+ *result = showbits_hcr(ld, n);
+ return flushbits_hcr(ld, n);
+}
+
+static INLINE int8_t get1bit_hcr(bits_t *ld, uint8_t *result)
+{
+ uint32_t res;
+ int8_t ret;
+
+ ret = getbits_hcr(ld, 1, &res);
+ *result = (int8_t)(res & 1);
+ return ret;
+}
+
+#endif
#ifdef __cplusplus
Index: cfft.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/cfft.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cfft.c 30 Aug 2003 22:30:21 -0000 1.1
+++ cfft.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -65,8 +65,8 @@
ac = 4*k;
RE(ch[ah]) = RE(cc[ac]) + RE(cc[ac+1]);
- IM(ch[ah]) = IM(cc[ac]) + IM(cc[ac+1]);
RE(ch[ah+l1]) = RE(cc[ac]) - RE(cc[ac+1]);
+ IM(ch[ah]) = IM(cc[ac]) + IM(cc[ac+1]);
IM(ch[ah+l1]) = IM(cc[ac]) - IM(cc[ac+1]);
}
} else {
@@ -79,16 +79,14 @@
{
complex_t t2;
- RE(ch[ah]) = RE(cc[ac]) + RE(cc[ac+ido]);
- IM(ch[ah]) = IM(cc[ac]) + IM(cc[ac+ido]);
+ RE(ch[ah+i]) = RE(cc[ac+i]) + RE(cc[ac+i+ido]);
+ RE(t2) = RE(cc[ac+i]) - RE(cc[ac+i+ido]);
- RE(t2) = RE(cc[ac]) - RE(cc[ac+ido]);
- IM(t2) = IM(cc[ac]) - IM(cc[ac+ido]);
+ IM(ch[ah+i]) = IM(cc[ac+i]) + IM(cc[ac+i+ido]);
+ IM(t2) = IM(cc[ac+i]) - IM(cc[ac+i+ido]);
- RE(ch[ah+l1*ido]) = MUL_R_C(RE(t2),RE(wa[i])) - MUL_R_C(IM(t2),IM(wa[i]))*isign;
- IM(ch[ah+l1*ido]) = MUL_R_C(IM(t2),RE(wa[i])) + MUL_R_C(RE(t2),IM(wa[i]))*isign;
- ah++;
- ac++;
+ RE(ch[ah+i+l1*ido]) = MUL_R_C(RE(t2),RE(wa[i])) - MUL_R_C(IM(t2),IM(wa[i]))*isign;
+ IM(ch[ah+i+l1*ido]) = MUL_R_C(IM(t2),RE(wa[i])) + MUL_R_C(RE(t2),IM(wa[i]))*isign;
}
}
}
@@ -164,66 +162,74 @@
complex_t *wa1, complex_t *wa2, complex_t *wa3, int8_t isign)
{
uint16_t i, k, ac, ah;
- complex_t c2, c3, c4, t1, t2, t3, t4;
if (ido == 1)
{
for (k = 0; k < l1; k++)
{
+ complex_t t1, t2, t3, t4;
+
ac = 4*k;
ah = k;
RE(t2) = RE(cc[ac]) + RE(cc[ac+2]);
- IM(t2) = IM(cc[ac]) + IM(cc[ac+2]);
- RE(t3) = RE(cc[ac+1]) + RE(cc[ac+3]);
- IM(t3) = IM(cc[ac+1]) + IM(cc[ac+3]);
RE(t1) = RE(cc[ac]) - RE(cc[ac+2]);
+ IM(t2) = IM(cc[ac]) + IM(cc[ac+2]);
IM(t1) = IM(cc[ac]) - IM(cc[ac+2]);
- RE(t4) = IM(cc[ac+3]) - IM(cc[ac+1]);
+ RE(t3) = RE(cc[ac+1]) + RE(cc[ac+3]);
IM(t4) = RE(cc[ac+1]) - RE(cc[ac+3]);
+ IM(t3) = IM(cc[ac+3]) + IM(cc[ac+1]);
+ RE(t4) = IM(cc[ac+3]) - IM(cc[ac+1]);
RE(ch[ah]) = RE(t2) + RE(t3);
- IM(ch[ah]) = IM(t2) + IM(t3);
- RE(ch[ah+l1]) = RE(t1) + RE(t4)*isign;
- IM(ch[ah+l1]) = IM(t1) + IM(t4)*isign;
RE(ch[ah+2*l1]) = RE(t2) - RE(t3);
+
+ IM(ch[ah]) = IM(t2) + IM(t3);
IM(ch[ah+2*l1]) = IM(t2) - IM(t3);
+
+ RE(ch[ah+l1]) = RE(t1) + RE(t4)*isign;
RE(ch[ah+3*l1]) = RE(t1) - RE(t4)*isign;
+
+ IM(ch[ah+l1]) = IM(t1) + IM(t4)*isign;
IM(ch[ah+3*l1]) = IM(t1) - IM(t4)*isign;
}
} else {
for (k = 0; k < l1; k++)
{
+ ac = 4*k*ido;
+ ah = k*ido;
+
for (i = 0; i < ido; i++)
{
- ac = i + 4*k*ido;
- ah = i + k*ido;
-
- RE(t2) = RE(cc[ac]) + RE(cc[ac+2*ido]);
- IM(t2) = IM(cc[ac]) + IM(cc[ac+2*ido]);
- RE(t3) = RE(cc[ac+ido]) + RE(cc[ac+3*ido]);
- IM(t3) = IM(cc[ac+ido]) + IM(cc[ac+3*ido]);
- RE(t1) = RE(cc[ac]) - RE(cc[ac+2*ido]);
- IM(t1) = IM(cc[ac]) - IM(cc[ac+2*ido]);
- RE(t4) = IM(cc[ac+3*ido]) - IM(cc[ac+ido]);
- IM(t4) = RE(cc[ac+ido]) - RE(cc[ac+3*ido]);
+ complex_t c2, c3, c4, t1, t2, t3, t4;
- RE(ch[ah]) = RE(t2) + RE(t3);
- IM(ch[ah]) = IM(t2) + IM(t3);
+ RE(t2) = RE(cc[ac+i]) + RE(cc[ac+i+2*ido]);
+ RE(t1) = RE(cc[ac+i]) - RE(cc[ac+i+2*ido]);
+ IM(t2) = IM(cc[ac+i]) + IM(cc[ac+i+2*ido]);
+ IM(t1) = IM(cc[ac+i]) - IM(cc[ac+i+2*ido]);
+ RE(t3) = RE(cc[ac+i+ido]) + RE(cc[ac+i+3*ido]);
+ IM(t4) = RE(cc[ac+i+ido]) - RE(cc[ac+i+3*ido]);
+ IM(t3) = IM(cc[ac+i+3*ido]) + IM(cc[ac+i+ido]);
+ RE(t4) = IM(cc[ac+i+3*ido]) - IM(cc[ac+i+ido]);
RE(c2) = RE(t1) + RE(t4)*isign;
+ RE(c4) = RE(t1) - RE(t4)*isign;
+
IM(c2) = IM(t1) + IM(t4)*isign;
+ IM(c4) = IM(t1) - IM(t4)*isign;
+
+ RE(ch[ah+i]) = RE(t2) + RE(t3);
RE(c3) = RE(t2) - RE(t3);
+
+ IM(ch[ah+i]) = IM(t2) + IM(t3);
IM(c3) = IM(t2) - IM(t3);
- RE(c4) = RE(t1) - RE(t4)*isign;
- IM(c4) = IM(t1) - IM(t4)*isign;
- RE(ch[ah+l1*ido]) = MUL_R_C(RE(c2),RE(wa1[i])) - MUL_R_C(IM(c2),IM(wa1[i]))*isign;
- IM(ch[ah+l1*ido]) = MUL_R_C(IM(c2),RE(wa1[i])) + MUL_R_C(RE(c2),IM(wa1[i]))*isign;
- RE(ch[ah+2*l1*ido]) = MUL_R_C(RE(c3),RE(wa2[i])) - MUL_R_C(IM(c3),IM(wa2[i]))*isign;
- IM(ch[ah+2*l1*ido]) = MUL_R_C(IM(c3),RE(wa2[i])) + MUL_R_C(RE(c3),IM(wa2[i]))*isign;
- RE(ch[ah+3*l1*ido]) = MUL_R_C(RE(c4),RE(wa3[i])) - MUL_R_C(IM(c4),IM(wa3[i]))*isign;
- IM(ch[ah+3*l1*ido]) = MUL_R_C(IM(c4),RE(wa3[i])) + MUL_R_C(RE(c4),IM(wa3[i]))*isign;
+ IM(ch[ah+i+l1*ido]) = MUL_R_C(IM(c2),RE(wa1[i])) + MUL_R_C(RE(c2),IM(wa1[i]))*isign;
+ RE(ch[ah+i+l1*ido]) = MUL_R_C(RE(c2),RE(wa1[i])) - MUL_R_C(IM(c2),IM(wa1[i]))*isign;
+ IM(ch[ah+i+2*l1*ido]) = MUL_R_C(IM(c3),RE(wa2[i])) + MUL_R_C(RE(c3),IM(wa2[i]))*isign;
+ RE(ch[ah+i+2*l1*ido]) = MUL_R_C(RE(c3),RE(wa2[i])) - MUL_R_C(IM(c3),IM(wa2[i]))*isign;
+ IM(ch[ah+i+3*l1*ido]) = MUL_R_C(IM(c4),RE(wa3[i])) + MUL_R_C(RE(c4),IM(wa3[i]))*isign;
+ RE(ch[ah+i+3*l1*ido]) = MUL_R_C(RE(c4),RE(wa3[i])) - MUL_R_C(IM(c4),IM(wa3[i]))*isign;
}
}
}
@@ -355,6 +361,17 @@
switch (ip)
{
+ case 4:
+ ix2 = iw + ido;
+ ix3 = ix2 + ido;
+
+ if (na == 0)
+ passf4(ido, l1, c, ch, &wa[iw], &wa[ix2], &wa[ix3], isign);
+ else
+ passf4(ido, l1, ch, c, &wa[iw], &wa[ix2], &wa[ix3], isign);
+
+ na = 1 - na;
+ break;
case 2:
if (na == 0)
passf2(ido, l1, c, ch, &wa[iw], isign);
@@ -373,17 +390,6 @@
na = 1 - na;
break;
- case 4:
- ix2 = iw + ido;
- ix3 = ix2 + ido;
-
- if (na == 0)
- passf4(ido, l1, c, ch, &wa[iw], &wa[ix2], &wa[ix3], isign);
- else
- passf4(ido, l1, ch, c, &wa[iw], &wa[ix2], &wa[ix3], isign);
-
- na = 1 - na;
- break;
case 5:
ix2 = iw + ido;
ix3 = ix2 + ido;
@@ -474,7 +480,7 @@
ifac[1] = nf;
#ifndef FIXED_POINT
- argh = 2.0*M_PI / (real_t)n;
+ argh = (real_t)2.0*M_PI / (real_t)n;
i = 0;
l1 = 1;
@@ -500,8 +506,8 @@
i++;
fi++;
arg = fi * argld;
- RE(wa[i]) = cos(arg);
- IM(wa[i]) = sin(arg);
+ RE(wa[i]) = (real_t)cos(arg);
+ IM(wa[i]) = (real_t)sin(arg);
}
if (ip > 5)
@@ -553,4 +559,4 @@
#endif
if (cfft) free(cfft);
-}
\ No newline at end of file
+}
Index: cfft_tab.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/cfft_tab.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cfft_tab.h 30 Aug 2003 22:30:21 -0000 1.1
+++ cfft_tab.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -36,1640 +36,1640 @@
complex_t cfft_tab_512[] =
{
- { 0x10000000, 0x0 },
- { 0xFFFB110, 0x3243A4 },
- { 0xFFEC430, 0x648558 },
- { 0xFFD3970, 0x96C32C },
- { 0xFFB10F0, 0xC8FB30 },
- { 0xFF84AB0, 0xFB2B75 },
- { 0xFF4E6D0, 0x12D520A },
- { 0xFF0E580, 0x15F6D02 },
[...3221 lines suppressed...]
+ { COEF_CONST(0.58778524), COEF_CONST(0.80901700) },
+ { COEF_CONST(0.30901697), COEF_CONST(0.95105654) },
+ { COEF_CONST(1.00000000), COEF_CONST(0.00000000) },
+ { COEF_CONST(0.80901700), COEF_CONST(0.58778524) },
+ { COEF_CONST(0.30901697), COEF_CONST(0.95105654) },
+ { COEF_CONST(-0.30901703), COEF_CONST(0.95105648) },
+ { COEF_CONST(-0.80901706), COEF_CONST(0.58778518) },
+ { COEF_CONST(1.00000000), COEF_CONST(0.00000000) },
+ { COEF_CONST(0.58778524), COEF_CONST(0.80901700) },
+ { COEF_CONST(-0.30901703), COEF_CONST(0.95105648) },
+ { COEF_CONST(-0.95105654), COEF_CONST(0.30901679) },
+ { COEF_CONST(-0.80901694), COEF_CONST(-0.58778536) },
+ { COEF_CONST(1.00000000), COEF_CONST(0.00000000) },
+ { COEF_CONST(1.00000000), COEF_CONST(0.00000000) },
+ { COEF_CONST(1.00000000), COEF_CONST(0.00000000) },
+ { COEF_CONST(1.00000000), COEF_CONST(0.00000000) },
+ { COEF_CONST(0.30901712), COEF_CONST(-0.95105648) }
};
#endif
Index: common.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/common.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- common.c 30 Aug 2003 22:30:21 -0000 1.1
+++ common.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -35,7 +35,6 @@
/* Returns the sample rate index based on the samplerate */
uint8_t get_sr_index(uint32_t samplerate)
{
- if (16428320 <= samplerate) return 11;
if (92017 <= samplerate) return 0;
if (75132 <= samplerate) return 1;
if (55426 <= samplerate) return 2;
@@ -47,8 +46,24 @@
if (13856 <= samplerate) return 8;
if (11502 <= samplerate) return 9;
if (9391 <= samplerate) return 10;
+ if (16428320 <= samplerate) return 11;
return 11;
+}
+
+/* Returns the sample rate based on the sample rate index */
+uint32_t get_sample_rate(uint8_t sr_index)
+{
+ static const uint32_t sample_rates[] =
+ {
+ 96000, 88200, 64000, 48000, 44100, 32000,
+ 24000, 22050, 16000, 12000, 11025, 8000
+ };
+
+ if (sr_index < 12)
+ return sample_rates[sr_index];
+
+ return 0;
}
/* Returns 0 if an object type is decodable, otherwise returns -1 */
Index: common.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/common.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- common.h 2 Sep 2003 20:40:36 -0000 1.2
+++ common.h 3 Oct 2003 22:22:27 -0000 1.3
@@ -242,8 +242,8 @@
#define MUL_C_C(A,B) ((A)*(B))
#define MUL_R_C(A,B) ((A)*(B))
- #define REAL_CONST(A) ((real_t)A)
- #define COEF_CONST(A) ((real_t)A)
+ #define REAL_CONST(A) ((real_t)(A))
+ #define COEF_CONST(A) ((real_t)(A))
#else /* Normal floating point operation */
@@ -253,8 +253,8 @@
#define MUL_C_C(A,B) ((A)*(B))
#define MUL_R_C(A,B) ((A)*(B))
- #define REAL_CONST(A) ((real_t)A)
- #define COEF_CONST(A) ((real_t)A)
+ #define REAL_CONST(A) ((real_t)(A))
+ #define COEF_CONST(A) ((real_t)(A))
#ifdef __ICL /* only Intel C compiler has fmath ??? */
@@ -307,6 +307,7 @@
int32_t int_log2(int32_t val);
uint32_t random_int(void);
uint8_t get_sr_index(uint32_t samplerate);
+uint32_t get_sample_rate(uint8_t sr_index);
int8_t can_decode_ot(uint8_t object_type);
#ifndef M_PI
Index: decoder.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/decoder.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- decoder.c 30 Aug 2003 22:30:21 -0000 1.1
+++ decoder.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -34,7 +34,6 @@
#include "decoder.h"
#include "mp4.h"
#include "syntax.h"
-#include "specrec.h"
#include "tns.h"
#include "pns.h"
#include "is.h"
@@ -146,6 +145,12 @@
#if POW_TABLE_SIZE
hDecoder->pow2_table = (real_t*)malloc(POW_TABLE_SIZE*sizeof(real_t));
+ if (!hDecoder->pow2_table)
+ {
+ free(hDecoder);
+ hDecoder = NULL;
+ return hDecoder;
+ }
build_tables(hDecoder->pow2_table);
#endif
@@ -154,21 +159,44 @@
faacDecConfigurationPtr FAADAPI faacDecGetCurrentConfiguration(faacDecHandle hDecoder)
{
+ if (hDecoder)
+ {
faacDecConfigurationPtr config = &(hDecoder->config);
return config;
+ }
+
+ return NULL;
}
uint8_t FAADAPI faacDecSetConfiguration(faacDecHandle hDecoder,
faacDecConfigurationPtr config)
{
+ if (hDecoder && config)
+ {
+ /* check if we can decode this object type */
+ if (can_decode_ot(config->defObjectType) < 0)
+ return 0;
hDecoder->config.defObjectType = config->defObjectType;
+
+ /* samplerate: anything but 0 should be possible */
+ if (config->defSampleRate == 0)
+ return 0;
hDecoder->config.defSampleRate = config->defSampleRate;
+
+ /* check output format */
+ if ((config->outputFormat < 1) || (config->outputFormat > 9))
+ return 0;
hDecoder->config.outputFormat = config->outputFormat;
+
+ if (config->downMatrix > 1)
hDecoder->config.downMatrix = config->downMatrix;
/* OK */
return 1;
+ }
+
+ return 0;
}
int32_t FAADAPI faacDecInit(faacDecHandle hDecoder, uint8_t *buffer,
@@ -180,9 +208,12 @@
adif_header adif;
adts_header adts;
+ if ((hDecoder == NULL) || (samplerate == NULL) || (channels == NULL))
+ return -1;
+
hDecoder->sf_index = get_sr_index(hDecoder->config.defSampleRate);
hDecoder->object_type = hDecoder->config.defObjectType;
- *samplerate = sample_rates[hDecoder->sf_index];
+ *samplerate = get_sample_rate(hDecoder->sf_index);
*channels = 1;
if (buffer != NULL)
@@ -199,9 +230,9 @@
faad_byte_align(&ld);
hDecoder->sf_index = adif.pce[0].sf_index;
- hDecoder->object_type = adif.pce[0].object_type;
+ hDecoder->object_type = adif.pce[0].object_type + 1;
- *samplerate = sample_rates[hDecoder->sf_index];
+ *samplerate = get_sample_rate(hDecoder->sf_index);
*channels = adif.pce[0].channels;
memcpy(&(hDecoder->pce), &(adif.pce[0]), sizeof(program_config));
@@ -213,12 +244,13 @@
} else if (faad_showbits(&ld, 12) == 0xfff) {
hDecoder->adts_header_present = 1;
+ adts.old_format = hDecoder->config.useOldADTSFormat;
adts_frame(&adts, &ld);
hDecoder->sf_index = adts.sf_index;
- hDecoder->object_type = adts.profile;
+ hDecoder->object_type = adts.profile + 1;
- *samplerate = sample_rates[hDecoder->sf_index];
+ *samplerate = get_sample_rate(hDecoder->sf_index);
*channels = (adts.channel_configuration > 6) ?
2 : adts.channel_configuration;
}
@@ -232,6 +264,15 @@
}
hDecoder->channelConfiguration = *channels;
+#ifdef SBR_DEC
+ /* implicit signalling */
+ if (*samplerate <= 24000)
+ {
+ *samplerate *= 2;
+ hDecoder->forceUpSampling = 1;
+ }
+#endif
+
/* must be done before frameLength is divided by 2 for LD */
#ifdef SSR_DEC
if (hDecoder->object_type == SSR)
@@ -250,7 +291,7 @@
#ifndef FIXED_POINT
if (hDecoder->config.outputFormat >= FAAD_FMT_DITHER_LOWEST)
- Init_Dither(16, hDecoder->config.outputFormat - FAAD_FMT_DITHER_LOWEST);
+ Init_Dither(16, (uint8_t)(hDecoder->config.outputFormat - FAAD_FMT_DITHER_LOWEST));
#endif
return bits;
@@ -264,9 +305,6 @@
int8_t rc;
mp4AudioSpecificConfig mp4ASC;
- hDecoder->adif_header_present = 0;
- hDecoder->adts_header_present = 0;
-
if((hDecoder == NULL)
|| (pBuffer == NULL)
|| (SizeOfDecoderSpecificInfo < 2)
@@ -276,6 +314,9 @@
return -1;
}
+ hDecoder->adif_header_present = 0;
+ hDecoder->adts_header_present = 0;
+
/* decode the audio specific config */
rc = AudioSpecificConfig2(pBuffer, SizeOfDecoderSpecificInfo, &mp4ASC,
&(hDecoder->pce));
@@ -291,21 +332,22 @@
}
hDecoder->sf_index = mp4ASC.samplingFrequencyIndex;
hDecoder->object_type = mp4ASC.objectTypeIndex;
+#ifdef ERROR_RESILIENCE
hDecoder->aacSectionDataResilienceFlag = mp4ASC.aacSectionDataResilienceFlag;
hDecoder->aacScalefactorDataResilienceFlag = mp4ASC.aacScalefactorDataResilienceFlag;
hDecoder->aacSpectralDataResilienceFlag = mp4ASC.aacSpectralDataResilienceFlag;
+#endif
#ifdef SBR_DEC
hDecoder->sbr_present_flag = mp4ASC.sbr_present_flag;
+ hDecoder->forceUpSampling = mp4ASC.forceUpSampling;
/* AAC core decoder samplerate is 2 times as low */
- if (hDecoder->sbr_present_flag == 1)
+ if (hDecoder->sbr_present_flag == 1 || hDecoder->forceUpSampling == 1)
{
hDecoder->sf_index = get_sr_index(mp4ASC.samplingFrequency / 2);
}
#endif
- if (hDecoder->object_type < 5)
- hDecoder->object_type--; /* For AAC differs from MPEG-4 */
if (rc != 0)
{
return rc;
@@ -329,7 +371,7 @@
#ifndef FIXED_POINT
if (hDecoder->config.outputFormat >= FAAD_FMT_DITHER_LOWEST)
- Init_Dither(16, hDecoder->config.outputFormat - FAAD_FMT_DITHER_LOWEST);
+ Init_Dither(16, (uint8_t)(hDecoder->config.outputFormat - FAAD_FMT_DITHER_LOWEST));
#endif
return 0;
@@ -342,20 +384,44 @@
hDecoder->config.defObjectType = DRM_ER_LC;
hDecoder->config.defSampleRate = samplerate;
+#ifdef ERROR_RESILIENCE // This shoudl always be defined for DRM
hDecoder->aacSectionDataResilienceFlag = 1; /* VCB11 */
hDecoder->aacScalefactorDataResilienceFlag = 0; /* no RVLC */
hDecoder->aacSpectralDataResilienceFlag = 1; /* HCR */
+#endif
hDecoder->frameLength = 960;
hDecoder->sf_index = get_sr_index(hDecoder->config.defSampleRate);
hDecoder->object_type = hDecoder->config.defObjectType;
- hDecoder->channelConfiguration = channels;
+
+ if ((channels == DRMCH_STEREO) || (channels == DRMCH_SBR_STEREO))
+ hDecoder->channelConfiguration = 2;
+ else
+ hDecoder->channelConfiguration = 1;
+
+#ifdef SBR_DEC
+#ifdef DRM
+ if (channels == DRMCH_SBR_LC_STEREO)
+ hDecoder->lcstereo_flag = 1;
+ else
+ hDecoder->lcstereo_flag = 0;
+
+ if ((channels == DRMCH_MONO) || (channels == DRMCH_STEREO))
+ hDecoder->sbr_present_flag = 0;
+ else
+ hDecoder->sbr_present_flag = 1;
+
+ /* Reset sbr for new initialization */
+ sbrDecodeEnd(hDecoder->sbr[0]);
+ hDecoder->sbr[0] = NULL;
+#endif
+#endif
/* must be done before frameLength is divided by 2 for LD */
hDecoder->fb = filter_bank_init(hDecoder->frameLength);
#ifndef FIXED_POINT
if (hDecoder->config.outputFormat >= FAAD_FMT_DITHER_LOWEST)
- Init_Dither(16, hDecoder->config.outputFormat - FAAD_FMT_DITHER_LOWEST);
+ Init_Dither(16, (uint8_t)(hDecoder->config.outputFormat - FAAD_FMT_DITHER_LOWEST));
#endif
return 0;
@@ -425,7 +491,7 @@
}
}
-void create_channel_config(faacDecHandle hDecoder, faacDecFrameInfo *hInfo)
+static void create_channel_config(faacDecHandle hDecoder, faacDecFrameInfo *hInfo)
{
hInfo->num_front_channels = 0;
hInfo->num_side_channels = 0;
@@ -640,52 +706,78 @@
uint8_t channels = 0, ch_ele = 0;
uint8_t output_channels = 0;
bitfile *ld = (bitfile*)malloc(sizeof(bitfile));
+ uint32_t bitsconsumed;
+#ifdef DRM
+ uint8_t *revbuffer;
+ uint8_t *prevbufstart;
+ uint8_t *pbufend;
+#endif
- /* local copys of globals */
- uint8_t sf_index = hDecoder->sf_index;
- uint8_t object_type = hDecoder->object_type;
- uint8_t channelConfiguration = hDecoder->channelConfiguration;
+ /* local copy of globals */
+ uint8_t sf_index, object_type, channelConfiguration, outputFormat;
+ uint8_t *window_shape_prev;
+ uint16_t frame_len;
#ifdef MAIN_DEC
- pred_state **pred_stat = hDecoder->pred_stat;
+ pred_state **pred_stat;
#endif
#ifdef LTP_DEC
- real_t **lt_pred_stat = hDecoder->lt_pred_stat;
+ real_t **lt_pred_stat;
#endif
-#ifndef FIXED_POINT
-#if POW_TABLE_SIZE
- real_t *pow2_table = hDecoder->pow2_table;
-#else
- real_t *pow2_table = NULL;
-#endif
-#endif
- uint8_t *window_shape_prev = hDecoder->window_shape_prev;
- real_t **time_out = hDecoder->time_out;
+ real_t **time_out;
#ifdef SBR_DEC
- real_t **time_out2 = hDecoder->time_out2;
+ real_t **time_out2;
#endif
#ifdef SSR_DEC
- real_t **ssr_overlap = hDecoder->ssr_overlap;
- real_t **prev_fmd = hDecoder->prev_fmd;
+ real_t **ssr_overlap, **prev_fmd;
#endif
- fb_info *fb = hDecoder->fb;
- drc_info *drc = hDecoder->drc;
- uint8_t outputFormat = hDecoder->config.outputFormat;
+ fb_info *fb;
+ drc_info *drc;
#ifdef LTP_DEC
- uint16_t *ltp_lag = hDecoder->ltp_lag;
+ uint16_t *ltp_lag;
#endif
- program_config *pce = &hDecoder->pce;
+ program_config *pce;
+ void *sample_buffer;
element *syntax_elements[MAX_SYNTAX_ELEMENTS];
element **elements;
- int16_t *spec_data[MAX_CHANNELS];
real_t *spec_coef[MAX_CHANNELS];
- uint16_t frame_len = hDecoder->frameLength;
+ /* safety checks */
+ if ((hDecoder == NULL) || (hInfo == NULL) || (buffer == NULL) || (ld == NULL))
+ {
+ return NULL;
+ }
- void *sample_buffer;
+ sf_index = hDecoder->sf_index;
+ object_type = hDecoder->object_type;
+ channelConfiguration = hDecoder->channelConfiguration;
+#ifdef MAIN_DEC
+ pred_stat = hDecoder->pred_stat;
+#endif
+#ifdef LTP_DEC
+ lt_pred_stat = hDecoder->lt_pred_stat;
+#endif
+ window_shape_prev = hDecoder->window_shape_prev;
+ time_out = hDecoder->time_out;
+#ifdef SBR_DEC
+ time_out2 = hDecoder->time_out2;
+#endif
+#ifdef SSR_DEC
+ ssr_overlap = hDecoder->ssr_overlap;
+ prev_fmd = hDecoder->prev_fmd;
+#endif
+ fb = hDecoder->fb;
+ drc = hDecoder->drc;
+ outputFormat = hDecoder->config.outputFormat;
+#ifdef LTP_DEC
+ ltp_lag = hDecoder->ltp_lag;
+#endif
+ pce = &hDecoder->pce;
+ frame_len = hDecoder->frameLength;
memset(hInfo, 0, sizeof(faacDecFrameInfo));
+ memset(hDecoder->internal_channel, 0, MAX_CHANNELS*sizeof(hDecoder->internal_channel[0]));
/* initialize the bitstream */
faad_initbits(ld, buffer, buffer_size);
@@ -700,6 +792,7 @@
if (hDecoder->adts_header_present)
{
+ adts.old_format = hDecoder->config.useOldADTSFormat;
if ((hInfo->error = adts_frame(&adts, ld)) > 0)
goto error;
@@ -717,7 +810,7 @@
/* decode the complete bitstream */
elements = raw_data_block(hDecoder, hInfo, ld, syntax_elements,
- spec_data, spec_coef, pce, drc);
+ spec_coef, pce, drc);
ch_ele = hDecoder->fr_ch_ele;
channels = hDecoder->fr_channels;
@@ -727,7 +820,8 @@
/* no more bit reading after this */
- hInfo->bytesconsumed = bit2byte(faad_get_processed_bits(ld));
+ bitsconsumed = faad_get_processed_bits(ld);
+ hInfo->bytesconsumed = bit2byte(bitsconsumed);
if (ld->error)
{
hInfo->error = 14;
@@ -737,6 +831,43 @@
if (ld) free(ld);
ld = NULL;
+#ifdef DRM
+#ifdef SBR_DEC
+ if ((hDecoder->sbr_present_flag == 1) && (hDecoder->object_type == DRM_ER_LC))
+ {
+ if (bitsconsumed + 8 > buffer_size*8)
+ {
+ hInfo->error = 14;
+ goto error;
+ }
+
+ hDecoder->sbr_used[0] = 1;
+
+ if (!hDecoder->sbr[0])
+ hDecoder->sbr[0] = sbrDecodeInit(hDecoder->frameLength, 1);
+
+ /* Reverse bit reading of SBR data in DRM audio frame */
+ revbuffer = (uint8_t*)malloc(buffer_size*sizeof(uint8_t));
+ prevbufstart = revbuffer;
+ pbufend = &buffer[buffer_size - 1];
+ for (i = 0; i < buffer_size; i++)
+ *prevbufstart++ = tabFlipbits[*pbufend--];
+
+ /* Set SBR data */
+ hDecoder->sbr[0]->data = revbuffer;
+ /* consider 8 bits from AAC-CRC */
+ hDecoder->sbr[0]->data_size_bits = buffer_size*8 - bitsconsumed - 8;
+ hDecoder->sbr[0]->data_size =
+ bit2byte(hDecoder->sbr[0]->data_size_bits + 8);
+
+ hDecoder->sbr[0]->lcstereo_flag = hDecoder->lcstereo_flag;
+
+ hDecoder->sbr[0]->sample_rate = get_sample_rate(hDecoder->sf_index);
+ hDecoder->sbr[0]->sample_rate *= 2;
+ }
+#endif
+#endif
+
if (!hDecoder->adts_header_present && !hDecoder->adif_header_present)
{
if (channels != hDecoder->channelConfiguration)
@@ -764,7 +895,17 @@
/* number of channels in this frame */
hInfo->channels = output_channels;
/* samplerate */
- hInfo->samplerate = sample_rates[hDecoder->sf_index];
+ hInfo->samplerate = get_sample_rate(hDecoder->sf_index);
+ /* object type */
+ hInfo->object_type = hDecoder->object_type;
+ /* sbr */
+ hInfo->sbr = NO_SBR;
+ /* header type */
+ hInfo->header_type = RAW;
+ if (hDecoder->adif_header_present)
+ hInfo->header_type = ADIF;
+ if (hDecoder->adts_header_present)
+ hInfo->header_type = ADTS;
/* check if frame has channel elements */
if (channels == 0)
@@ -776,7 +917,7 @@
if (hDecoder->sample_buffer == NULL)
{
#ifdef SBR_DEC
- if (hDecoder->sbr_present_flag == 1)
+ if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
{
if (hDecoder->config.outputFormat == FAAD_FMT_DOUBLE)
hDecoder->sample_buffer = malloc(2*frame_len*channels*sizeof(double));
@@ -795,31 +936,6 @@
sample_buffer = hDecoder->sample_buffer;
- /* noiseless coding is done, the rest of the tools come now */
- for (ch = 0; ch < channels; ch++)
- {
- ic_stream *ics;
-
- /* find the syntax element to which this channel belongs */
- if (syntax_elements[hDecoder->channel_element[ch]]->channel == ch)
- ics = &(syntax_elements[hDecoder->channel_element[ch]]->ics1);
- else if (syntax_elements[hDecoder->channel_element[ch]]->paired_channel == ch)
- ics = &(syntax_elements[hDecoder->channel_element[ch]]->ics2);
-
- /* inverse quantization */
- inverse_quantization(spec_coef[ch], spec_data[ch], frame_len);
-
- /* apply scalefactors */
-#ifdef FIXED_POINT
- apply_scalefactors(hDecoder, ics, spec_coef[ch], frame_len);
-#else
- apply_scalefactors(ics, spec_coef[ch], pow2_table, frame_len);
-#endif
-
- /* deinterleave short block grouping */
- if (ics->window_sequence == EIGHT_SHORT_SEQUENCE)
- quant_to_spec(ics, spec_coef[ch], frame_len);
- }
/* Because for ms, is and pns both channels spectral coefficients are needed
we have to restart running through all channels here.
@@ -850,9 +966,9 @@
/* pns decoding */
if ((!right_channel) && (pch != -1) && (ics->ms_mask_present))
- pns_decode(ics, icsr, spec_coef[ch], spec_coef[pch], frame_len, 1);
+ pns_decode(ics, icsr, spec_coef[ch], spec_coef[pch], frame_len, 1, object_type);
else if ((pch == -1) || ((pch != -1) && (!ics->ms_mask_present)))
- pns_decode(ics, NULL, spec_coef[ch], NULL, frame_len, 0);
+ pns_decode(ics, NULL, spec_coef[ch], NULL, frame_len, 0, object_type);
if (!right_channel && (pch != -1))
{
@@ -992,10 +1108,22 @@
}
#ifdef SBR_DEC
- if (hDecoder->sbr_present_flag == 1)
+ if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
{
for (i = 0; i < ch_ele; i++)
{
+ /* following case can happen when forceUpSampling == 1 */
+ if (hDecoder->sbr[i] == NULL)
+ {
+ hDecoder->sbr[i] = sbrDecodeInit(hDecoder->frameLength
+#ifdef DRM
+ , 0
+#endif
+ );
+ hDecoder->sbr[i]->data = NULL;
+ hDecoder->sbr[i]->data_size = 0;
+ }
+
if (syntax_elements[i]->paired_channel != -1)
{
memcpy(time_out2[syntax_elements[i]->channel],
@@ -1005,19 +1133,27 @@
sbrDecodeFrame(hDecoder->sbr[i],
time_out2[syntax_elements[i]->channel],
time_out2[syntax_elements[i]->paired_channel], ID_CPE,
- hDecoder->postSeekResetFlag);
+ hDecoder->postSeekResetFlag, hDecoder->forceUpSampling);
} else {
memcpy(time_out2[syntax_elements[i]->channel],
time_out[syntax_elements[i]->channel], frame_len*sizeof(real_t));
sbrDecodeFrame(hDecoder->sbr[i],
time_out2[syntax_elements[i]->channel],
NULL, ID_SCE,
- hDecoder->postSeekResetFlag);
+ hDecoder->postSeekResetFlag, hDecoder->forceUpSampling);
}
}
frame_len *= 2;
hInfo->samples *= 2;
hInfo->samplerate *= 2;
+ /* sbr */
+ if (hDecoder->sbr_present_flag == 1)
+ {
+ hInfo->object_type = HE_AAC;
+ hInfo->sbr = SBR_UPSAMPLED;
+ } else {
+ hInfo->sbr = NO_SBR_UPSAMPLED;
+ }
sample_buffer = output_to_PCM(hDecoder, time_out2, sample_buffer,
output_channels, frame_len, outputFormat);
@@ -1029,13 +1165,6 @@
}
#endif
- /* gapless playback */
- if (hDecoder->samplesLeft != 0)
- {
- hInfo->samples = hDecoder->samplesLeft*channels;
- }
- hDecoder->samplesLeft = 0;
-
hDecoder->postSeekResetFlag = 0;
hDecoder->frame++;
@@ -1045,32 +1174,6 @@
#endif
if (hDecoder->frame <= 1)
hInfo->samples = 0;
-
-#if 0
- if (hDecoder->frame == 2 && hDecoder->sbr_present_flag == 1)
- {
- uint8_t samplesize;
- switch (outputFormat)
- {
- case FAAD_FMT_16BIT: case FAAD_FMT_16BIT_DITHER:
- case FAAD_FMT_16BIT_L_SHAPE: case FAAD_FMT_16BIT_M_SHAPE:
- case FAAD_FMT_16BIT_H_SHAPE:
- samplesize = 2;
- break;
- case FAAD_FMT_24BIT:
- case FAAD_FMT_32BIT:
- case FAAD_FMT_FLOAT:
- samplesize = 4;
- break;
- case FAAD_FMT_DOUBLE:
- samplesize = 8;
- break;
- }
- hInfo->samples = 512*channels;
- memmove(sample_buffer, (void*)((char*)sample_buffer + 1536*channels*samplesize), hInfo->samples*samplesize);
- }
-#endif
-
#ifdef LD_DEC
} else {
/* LD encoders will give lower delay */
@@ -1083,7 +1186,6 @@
for (ch = 0; ch < channels; ch++)
{
if (spec_coef[ch]) free(spec_coef[ch]);
- if (spec_data[ch]) free(spec_data[ch]);
}
for (i = 0; i < ch_ele; i++)
@@ -1106,7 +1208,6 @@
for (ch = 0; ch < channels; ch++)
{
if (spec_coef[ch]) free(spec_coef[ch]);
- if (spec_data[ch]) free(spec_data[ch]);
}
for (i = 0; i < ch_ele; i++)
Index: decoder.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/decoder.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- decoder.h 30 Aug 2003 22:30:21 -0000 1.1
+++ decoder.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -111,6 +111,8 @@
void FAADAPI faacDecClose(faacDecHandle hDecoder);
+void FAADAPI faacDecPostSeekReset(faacDecHandle hDecoder, int32_t frame);
+
void* FAADAPI faacDecDecode(faacDecHandle hDecoder,
faacDecFrameInfo *hInfo,
uint8_t *buffer,
@@ -118,16 +120,13 @@
element *decode_sce_lfe(faacDecHandle hDecoder,
faacDecFrameInfo *hInfo, bitfile *ld,
- int16_t **spec_data, real_t **spec_coef,
- uint8_t id_syn_ele);
+ real_t **spec_coef, uint8_t id_syn_ele);
element *decode_cpe(faacDecHandle hDecoder,
faacDecFrameInfo *hInfo, bitfile *ld,
- int16_t **spec_data, real_t **spec_coef,
- uint8_t id_syn_ele);
+ real_t **spec_coef, uint8_t id_syn_ele);
element **raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo,
bitfile *ld, element **elements,
- int16_t **spec_data, real_t **spec_coef,
- program_config *pce, drc_info *drc);
+ real_t **spec_coef, program_config *pce, drc_info *drc);
#ifdef _WIN32
#pragma pack(pop)
Index: dither.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/dither.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- dither.c 30 Aug 2003 22:30:21 -0000 1.1
+++ dither.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -108,7 +108,7 @@
void
-Init_Dither ( unsigned char bits, unsigned char shapingtype )
+Init_Dither ( uint8_t bits, uint8_t shapingtype )
{
static uint8_t default_dither [] = { 92, 92, 88, 84, 81, 78, 74, 67, 0, 0 };
static const float32_t* F [] = { F44_0, F44_1, F44_2, F44_3 };
@@ -124,7 +124,7 @@
Dither.FilterCoeff = F [shapingtype];
Dither.Mask = ((uint64_t)-1) << (32 - bits);
Dither.Add = 0.5 * ((1L << (32 - bits)) - 1);
- Dither.Dither = 0.01*default_dither[index] / (((int64_t)1) << bits);
+ Dither.Dither = (float32_t)0.01*default_dither[index] / (((int64_t)1) << bits);
}
#endif
Index: dither.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/dither.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- dither.h 30 Aug 2003 22:30:21 -0000 1.1
+++ dither.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -36,7 +36,7 @@
extern double scalar16 ( const float32_t* x, const float32_t* y );
extern double Random_Equi ( double mult );
extern double Random_Triangular ( double mult );
-void Init_Dither ( unsigned char bits, unsigned char shapingtype );
+void Init_Dither ( uint8_t bits, uint8_t shapingtype );
#endif
Index: drc.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/drc.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- drc.c 30 Aug 2003 22:30:21 -0000 1.1
+++ drc.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -127,9 +127,9 @@
#ifndef FIXED_POINT
/* Decode DRC gain factor */
if (drc->dyn_rng_sgn[bd]) /* compress */
- exp = -drc->ctrl1 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/24.0;
+ exp = -drc->ctrl1 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/REAL_CONST(24.0);
else /* boost */
- exp = drc->ctrl2 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/24.0;
+ exp = drc->ctrl2 * (drc->dyn_rng_ctl[bd] - (DRC_REF_LEVEL - drc->prog_ref_level))/REAL_CONST(24.0);
factor = (real_t)pow(2.0, exp);
/* Apply gain factor */
Index: faad.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/faad.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- faad.h 30 Aug 2003 22:30:21 -0000 1.1
+++ faad.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -1,19 +1,19 @@
/*
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
-**
+**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
-**
+**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
-**
+**
** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
+** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
** Any non-GPL usage of this software or parts of this software is strictly
@@ -46,10 +46,11 @@
#define FAAD2_VERSION "2.0 RC1 "
/* object types for AAC */
-#define MAIN 0
-#define LC 1
-#define SSR 2
-#define LTP 3
+#define MAIN 1
+#define LC 2
+#define SSR 3
+#define LTP 4
+#define HE_AAC 5
#define ER_LC 17
#define ER_LTP 19
#define LD 23
@@ -60,6 +61,12 @@
#define ADIF 1
#define ADTS 2
+/* SBR signalling */
+#define NO_SBR 0
+#define SBR_UPSAMPLED 1
+#define SBR_DOWNSAMPLED 2
+#define NO_SBR_UPSAMPLED 3
+
/* library output formats */
#define FAAD_FMT_16BIT 1
#define FAAD_FMT_24BIT 2
@@ -91,6 +98,13 @@
#define LFE_CHANNEL (9)
#define UNKNOWN_CHANNEL (0)
+/* DRM channel definitions */
+#define DRMCH_MONO 1
+#define DRMCH_STEREO 2
+#define DRMCH_SBR_MONO 3
+#define DRMCH_SBR_LC_STEREO 4
+#define DRMCH_SBR_STEREO 5
+
/* A decode call can eat up to FAAD_MIN_STREAMSIZE bytes per decoded channel,
so at least so much bytes per channel should be available in this stream */
@@ -118,6 +132,7 @@
unsigned char epConfig;
char sbr_present_flag;
+ char forceUpSampling;
} mp4AudioSpecificConfig;
typedef struct faacDecConfiguration
@@ -126,6 +141,7 @@
unsigned long defSampleRate;
unsigned char outputFormat;
unsigned char downMatrix;
+ unsigned char useOldADTSFormat;
} faacDecConfiguration, *faacDecConfigurationPtr;
typedef struct faacDecFrameInfo
@@ -136,6 +152,15 @@
unsigned char error;
unsigned long samplerate;
+ /* SBR: 0: off, 1: on; upsample, 2: on; downsampled, 3: off; upsampled */
+ unsigned char sbr;
+
+ /* MPEG-4 ObjectType */
+ unsigned char object_type;
+
+ /* AAC header type; MP4 will be signalled as RAW also */
+ unsigned char header_type;
+
/* multichannel configuration */
unsigned char num_front_channels;
unsigned char num_side_channels;
@@ -170,6 +195,8 @@
/* Init the library for DRM */
char FAADAPI faacDecInitDRM(faacDecHandle hDecoder, unsigned long samplerate,
unsigned char channels);
+
+void FAADAPI faacDecPostSeekReset(faacDecHandle hDecoder, long frame);
void FAADAPI faacDecClose(faacDecHandle hDecoder);
Index: filtbank.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/filtbank.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- filtbank.c 30 Aug 2003 22:30:21 -0000 1.1
+++ filtbank.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -191,17 +191,31 @@
{
case ONLY_LONG_SEQUENCE:
imdct(fb, freq_in, transf_buf, 2*nlong);
- for (i = nlong-1; i >= 0; i--)
+ for (i = 0; i < nlong; i+=4)
{
time_out[i] = time_out[nlong+i] + MUL_R_C(transf_buf[i],window_long_prev[i]);
+ time_out[i+1] = time_out[nlong+i+1] + MUL_R_C(transf_buf[i+1],window_long_prev[i+1]);
+ time_out[i+2] = time_out[nlong+i+2] + MUL_R_C(transf_buf[i+2],window_long_prev[i+2]);
+ time_out[i+3] = time_out[nlong+i+3] + MUL_R_C(transf_buf[i+3],window_long_prev[i+3]);
+ }
+ for (i = 0; i < nlong; i+=4)
+ {
time_out[nlong+i] = MUL_R_C(transf_buf[nlong+i],window_long[nlong-1-i]);
+ time_out[nlong+i+1] = MUL_R_C(transf_buf[nlong+i+1],window_long[nlong-2-i]);
+ time_out[nlong+i+2] = MUL_R_C(transf_buf[nlong+i+2],window_long[nlong-3-i]);
+ time_out[nlong+i+3] = MUL_R_C(transf_buf[nlong+i+3],window_long[nlong-4-i]);
}
break;
case LONG_START_SEQUENCE:
imdct(fb, freq_in, transf_buf, 2*nlong);
- for (i = 0; i < nlong; i++)
+ for (i = 0; i < nlong; i+=4)
+ {
time_out[i] = time_out[nlong+i] + MUL_R_C(transf_buf[i],window_long_prev[i]);
+ time_out[i+1] = time_out[nlong+i+1] + MUL_R_C(transf_buf[i+1],window_long_prev[i+1]);
+ time_out[i+2] = time_out[nlong+i+2] + MUL_R_C(transf_buf[i+2],window_long_prev[i+2]);
+ time_out[i+3] = time_out[nlong+i+3] + MUL_R_C(transf_buf[i+3],window_long_prev[i+3]);
+ }
for (i = 0; i < nflat_ls; i++)
time_out[nlong+i] = transf_buf[nlong+i];
for (i = 0; i < nshort; i++)
Index: filtbank.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/filtbank.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- filtbank.h 30 Aug 2003 22:30:21 -0000 1.1
+++ filtbank.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -32,7 +32,6 @@
extern "C" {
#endif
-#include "mdct.h"
fb_info *filter_bank_init(uint16_t frame_len);
void filter_bank_end(fb_info *fb);
Index: fixed.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/fixed.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- fixed.h 30 Aug 2003 22:30:21 -0000 1.1
+++ fixed.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -35,15 +35,15 @@
#define COEF_BITS 28
#define COEF_PRECISION (1 << COEF_BITS)
-#define REAL_BITS 15 //7
+#define REAL_BITS 14 // MAXIMUM OF 14 FOR FIXED POINT SBR
#define REAL_PRECISION (1 << REAL_BITS)
typedef int32_t real_t;
-#define REAL_CONST(A) ((real_t)(A*(REAL_PRECISION)))
-#define COEF_CONST(A) ((real_t)(A*(COEF_PRECISION)))
+#define REAL_CONST(A) ((real_t)((A)*(REAL_PRECISION)))
+#define COEF_CONST(A) ((real_t)((A)*(COEF_PRECISION)))
#if defined(_WIN32) && !defined(_WIN32_WCE)
Index: hcr.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/hcr.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- hcr.c 30 Aug 2003 22:30:21 -0000 1.1
+++ hcr.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -38,226 +38,12 @@
#include "pulse.h"
#include "analysis.h"
#include "bits.h"
-#include "codebook/hcb.h"
+#include "huffman.h"
/* Implements the HCR11 tool as described in ISO/IEC 14496-3/Amd.1, 8.5.3.3 */
#ifdef ERROR_RESILIENCE
-typedef struct
-{
- /* bit input */
- uint32_t bufa;
- uint32_t bufb;
- int8_t len;
-} bits_t;
-
-
-static INLINE uint32_t showbits(bits_t *ld, uint8_t bits)
-{
- if (bits == 0) return 0;
- if (ld->len <= 32){
- /* huffman_spectral_data_2 needs to read more than may be available, bits maybe
- > ld->len, deliver 0 than */
- if (ld->len >= bits)
- return ((ld->bufa >> (ld->len - bits)) & (0xFFFFFFFF >> (32 - bits)));
- else
- return ((ld->bufa << (bits - ld->len)) & (0xFFFFFFFF >> (32 - bits)));
- } else {
- if ((ld->len - bits) < 32)
- {
- return ( (ld->bufb & (0xFFFFFFFF >> (64 - ld->len))) << (bits - ld->len + 32)) |
- (ld->bufa >> (ld->len - bits));
- } else {
- return ((ld->bufb >> (ld->len - bits - 32)) & (0xFFFFFFFF >> (32 - bits)));
- }
- }
-}
-
-/* return 1 if position is outside of buffer, 0 otherwise */
-static INLINE int8_t flushbits( bits_t *ld, uint8_t bits)
-{
- ld->len -= bits;
-
- if (ld->len <0)
- {
- ld->len = 0;
- return 1;
- } else {
- return 0;
- }
-}
-
-
-static INLINE int8_t getbits(bits_t *ld, uint8_t n, uint32_t *result)
-{
- *result = showbits(ld, n);
- return flushbits(ld, n);
-}
-
-static INLINE int8_t get1bit(bits_t *ld, uint8_t *result)
-{
- uint32_t res;
- int8_t ret;
-
- ret = getbits(ld, 1, &res);
- *result = (int8_t)(res & 1);
- return ret;
-}
-
-/* Special version of huffman_spectral_data adapted from huffman.h
-Will not read from a bitfile but a bits_t structure.
-Will keep track of the bits decoded and return the number of bits remaining.
-Do not read more than ld->len, return -1 if codeword would be longer */
-
-static int8_t huffman_spectral_data_2(uint8_t cb, bits_t *ld, int16_t *sp )
-{
- uint32_t cw;
- uint16_t offset = 0;
- uint8_t extra_bits;
- uint8_t i;
- uint8_t save_cb = cb;
-
-
- switch (cb)
- {
- case 1: /* 2-step method for data quadruples */
- case 2:
- case 4:
-
- cw = showbits(ld, hcbN[cb]);
- offset = hcb_table[cb][cw].offset;
- extra_bits = hcb_table[cb][cw].extra_bits;
-
- if (extra_bits)
- {
- /* we know for sure it's more than hcbN[cb] bits long */
- if ( flushbits(ld, hcbN[cb]) ) return -1;
- offset += (uint16_t)showbits(ld, extra_bits);
- if ( flushbits(ld, hcb_2_quad_table[cb][offset].bits - hcbN[cb]) ) return -1;
- } else {
- if ( flushbits(ld, hcb_2_quad_table[cb][offset].bits) ) return -1;
- }
-
- sp[0] = hcb_2_quad_table[cb][offset].x;
- sp[1] = hcb_2_quad_table[cb][offset].y;
- sp[2] = hcb_2_quad_table[cb][offset].v;
- sp[3] = hcb_2_quad_table[cb][offset].w;
- break;
-
- case 6: /* 2-step method for data pairs */
- case 8:
- case 10:
- case 11:
- /* VCB11 uses codebook 11 */
- case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23:
- case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31:
-
- /* TODO: If ER is used, some extra error checking should be done */
- if (cb >= 16)
- cb = 11;
-
- cw = showbits(ld, hcbN[cb]);
- offset = hcb_table[cb][cw].offset;
- extra_bits = hcb_table[cb][cw].extra_bits;
-
- if (extra_bits)
- {
- /* we know for sure it's more than hcbN[cb] bits long */
- if ( flushbits(ld, hcbN[cb]) ) return -1;
- offset += (uint16_t)showbits(ld, extra_bits);
- if ( flushbits(ld, hcb_2_pair_table[cb][offset].bits - hcbN[cb]) ) return -1;
- } else {
- if ( flushbits(ld, hcb_2_pair_table[cb][offset].bits) ) return -1;
- }
- sp[0] = hcb_2_pair_table[cb][offset].x;
- sp[1] = hcb_2_pair_table[cb][offset].y;
- break;
-
- case 3: /* binary search for data quadruples */
-
- while (!hcb3[offset].is_leaf)
- {
- uint8_t b;
-
- if ( get1bit(ld, &b) ) return -1;
- offset += hcb3[offset].data[b];
- }
-
- sp[0] = hcb3[offset].data[0];
- sp[1] = hcb3[offset].data[1];
- sp[2] = hcb3[offset].data[2];
- sp[3] = hcb3[offset].data[3];
-
- break;
-
- case 5: /* binary search for data pairs */
- case 7:
- case 9:
-
- while (!hcb_bin_table[cb][offset].is_leaf)
- {
- uint8_t b;
-
- if (get1bit(ld, &b) ) return -1;
- offset += hcb_bin_table[cb][offset].data[b];
- }
-
- sp[0] = hcb_bin_table[cb][offset].data[0];
- sp[1] = hcb_bin_table[cb][offset].data[1];
-
- break;
- }
-
- /* decode sign bits */
- if (unsigned_cb[cb]) {
-
- for(i = 0; i < ((cb < FIRST_PAIR_HCB) ? QUAD_LEN : PAIR_LEN); i++)
- {
- if(sp[i])
- {
- uint8_t b;
- if ( get1bit(ld, &b) ) return -1;
- if (b != 0) {
- sp[i] = -sp[i];
- }
- }
- }
- }
-
- /* decode huffman escape bits */
- if ((cb == ESC_HCB) || (cb >= 16))
- {
- uint8_t k;
- for (k = 0; k < 2; k++)
- {
- if ((sp[k] == 16) || (sp[k] == -16))
- {
- uint8_t neg, i;
- int32_t j;
- uint32_t off;
-
- neg = (sp[k] < 0) ? 1 : 0;
-
- for (i = 4; ; i++)
- {
- uint8_t b;
- if (get1bit(ld, &b))
- return -1;
- if (b == 0)
- break;
- }
-// TODO: here we would need to test "off" if VCB11 is used!
- if (getbits(ld, i, &off))
- return -1;
- j = off + (1<<i);
- sp[k] = (int16_t)((neg) ? -j : j);
- }
- }
- }
- return ld->len;
-}
-
/* rewind len (max. 32) bits so that the MSB becomes LSB */
static uint32_t rewind_word( uint32_t W, uint8_t len)
@@ -304,7 +90,7 @@
r->bufb = hw;
} else {
- lw = showbits(r, r->len );
+ lw = showbits_hcr(r, r->len );
r->bufa = rewind_word( lw, r->len);
r->bufb = 0;
}
@@ -322,14 +108,14 @@
lwa = a->bufa;
hwa = a->bufb & (0xFFFFFFFF >> (64 - a->len));
} else {
- lwa = showbits(a, a->len );
+ lwa = showbits_hcr(a, a->len );
hwa = 0;
}
if (b->len >=32) {
lwb = b->bufa;
hwb = (b->bufb & (0xFFFFFFFF >> (64 - b->len)) ) | ( lwa << (b->len - 32));
} else {
- lwb = showbits(b, b->len ) | (lwa << (b->len));
+ lwb = showbits_hcr(b, b->len ) | (lwa << (b->len));
hwb = (lwa >> (32 - b->len)) | (hwa << (b->len));
}
@@ -493,12 +279,12 @@
if (Segment[ numberOfSegments-1 ].len > 32)
{
Segment[ numberOfSegments-1 ].bufb = hw +
- showbits(&Segment[ numberOfSegments-1 ], Segment[ numberOfSegments-1 ].len - 32);
+ showbits_hcr(&Segment[ numberOfSegments-1 ], Segment[ numberOfSegments-1 ].len - 32);
Segment[ numberOfSegments-1 ].bufa = lw +
- showbits(&Segment[ numberOfSegments-1 ], 32);
+ showbits_hcr(&Segment[ numberOfSegments-1 ], 32);
} else {
Segment[ numberOfSegments-1 ].bufa = lw +
- showbits(&Segment[ numberOfSegments-1 ], Segment[ numberOfSegments-1 ].len);
+ showbits_hcr(&Segment[ numberOfSegments-1 ], Segment[ numberOfSegments-1 ].len);
Segment[ numberOfSegments-1 ].bufb = hw;
}
Segment[ numberOfSegments-1 ].len += additional_bits;
Index: huffman.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/huffman.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- huffman.h 30 Aug 2003 22:30:21 -0000 1.1
+++ huffman.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -32,317 +32,24 @@
extern "C" {
#endif
-#include <stdlib.h>
-#ifdef ANALYSIS
-#include <stdio.h>
-#endif
-#include "bits.h"
-#include "codebook/hcb.h"
-
-
-static INLINE int8_t huffman_scale_factor(bitfile *ld)
-{
- uint16_t offset = 0;
-
- while (hcb_sf[offset][1])
- {
- uint8_t b = faad_get1bit(ld
- DEBUGVAR(1,255,"huffman_scale_factor()"));
- offset += hcb_sf[offset][b];
-
- if (offset > 240)
- {
- /* printf("ERROR: offset into hcb_sf = %d >240!\n", offset); */
- return -1;
- }
- }
-
- return hcb_sf[offset][0];
-}
-
-
-hcb *hcb_table[] = {
- 0, hcb1_1, hcb2_1, 0, hcb4_1, 0, hcb6_1, 0, hcb8_1, 0, hcb10_1, hcb11_1
-};
-
-hcb_2_quad *hcb_2_quad_table[] = {
- 0, hcb1_2, hcb2_2, 0, hcb4_2, 0, 0, 0, 0, 0, 0, 0
-};
-
-hcb_2_pair *hcb_2_pair_table[] = {
- 0, 0, 0, 0, 0, 0, hcb6_2, 0, hcb8_2, 0, hcb10_2, hcb11_2
-};
-
-hcb_bin_pair *hcb_bin_table[] = {
- 0, 0, 0, 0, 0, hcb5, 0, hcb7, 0, hcb9, 0, 0
-};
-
-uint8_t hcbN[] = { 0, 5, 5, 0, 5, 0, 5, 0, 5, 0, 6, 5 };
-
-/* defines whether a huffman codebook is unsigned or not */
-/* Table 4.6.2 */
-uint8_t unsigned_cb[] = { 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0,
- /* codebook 16 to 31 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
-};
-
-int hcb_2_quad_table_size[] = { 0, 114, 86, 0, 185, 0, 0, 0, 0, 0, 0, 0 };
-int hcb_2_pair_table_size[] = { 0, 0, 0, 0, 0, 0, 126, 0, 83, 0, 210, 373 };
-int hcb_bin_table_size[] = { 0, 0, 0, 161, 0, 161, 0, 127, 0, 337, 0, 0 };
-
-static INLINE void huffman_sign_bits(bitfile *ld, int16_t *sp, uint8_t len)
-{
- uint8_t i;
-
- for(i = 0; i < len; i++)
- {
- if(sp[i])
- {
- if(faad_get1bit(ld
- DEBUGVAR(1,5,"huffman_sign_bits(): sign bit")) & 1)
- {
- sp[i] = -sp[i];
- }
- }
- }
-}
-
-static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp)
-{
- uint8_t neg, i;
- int16_t j;
- int32_t off;
-
- if (sp < 0) {
- if(sp != -16)
- return sp;
- neg = 1;
- } else {
- if(sp != 16)
- return sp;
- neg = 0;
- }
-
- for (i = 4; ; i++)
- {
- if (faad_get1bit(ld
- DEBUGVAR(1,6,"huffman_getescape(): escape size")) == 0)
- {
- break;
- }
- }
-
- off = faad_getbits(ld, i
- DEBUGVAR(1,9,"huffman_getescape(): escape"));
-
- j = off + (1<<i);
- if (neg)
- j = -j;
-
- return j;
-}
-
-static uint8_t huffman_2step_quad(uint8_t cb, bitfile *ld, int16_t *sp)
-{
- uint32_t cw;
- uint16_t offset = 0;
- uint8_t extra_bits;
-
- cw = faad_showbits(ld, hcbN[cb]);
- offset = hcb_table[cb][cw].offset;
- extra_bits = hcb_table[cb][cw].extra_bits;
-
- if (extra_bits)
- {
- /* we know for sure it's more than hcbN[cb] bits long */
- faad_flushbits(ld, hcbN[cb]);
- offset += (uint16_t)faad_showbits(ld, extra_bits);
- faad_flushbits(ld, hcb_2_quad_table[cb][offset].bits - hcbN[cb]);
- } else {
- faad_flushbits(ld, hcb_2_quad_table[cb][offset].bits);
- }
-
- if (offset > hcb_2_quad_table_size[cb])
- {
- /* printf("ERROR: offset into hcb_2_quad_table = %d >%d!\n", offset,
- hcb_2_quad_table_size[cb]); */
- return 10;
- }
-
- sp[0] = hcb_2_quad_table[cb][offset].x;
- sp[1] = hcb_2_quad_table[cb][offset].y;
- sp[2] = hcb_2_quad_table[cb][offset].v;
- sp[3] = hcb_2_quad_table[cb][offset].w;
- return 0;
-}
+static INLINE void huffman_sign_bits(bitfile *ld, int16_t *sp, uint8_t len);
+static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp);
+static uint8_t huffman_2step_quad(uint8_t cb, bitfile *ld, int16_t *sp);
+static uint8_t huffman_2step_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp);
+static uint8_t huffman_2step_pair(uint8_t cb, bitfile *ld, int16_t *sp);
+static huffman_2step_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp);
+static uint8_t huffman_binary_quad(uint8_t cb, bitfile *ld, int16_t *sp);
+static uint8_t huffman_binary_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp);
+static uint8_t huffman_binary_pair(uint8_t cb, bitfile *ld, int16_t *sp);
+static uint8_t huffman_binary_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp);
+static int16_t huffman_codebook(uint8_t i);
-static uint8_t huffman_2step_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp)
-{
- uint8_t err = huffman_2step_quad(cb, ld, sp);
- huffman_sign_bits(ld, sp, QUAD_LEN);
-
- return err;
-}
-
-static uint8_t huffman_2step_pair(uint8_t cb, bitfile *ld, int16_t *sp)
-{
- uint32_t cw;
- uint16_t offset = 0;
- uint8_t extra_bits;
-
- cw = faad_showbits(ld, hcbN[cb]);
- offset = hcb_table[cb][cw].offset;
- extra_bits = hcb_table[cb][cw].extra_bits;
-
- if (extra_bits)
- {
- /* we know for sure it's more than hcbN[cb] bits long */
- faad_flushbits(ld, hcbN[cb]);
- offset += (uint16_t)faad_showbits(ld, extra_bits);
- faad_flushbits(ld, hcb_2_pair_table[cb][offset].bits - hcbN[cb]);
- } else {
- faad_flushbits(ld, hcb_2_pair_table[cb][offset].bits);
- }
-
- if (offset > hcb_2_pair_table_size[cb])
- {
- /* printf("ERROR: offset into hcb_2_pair_table = %d >%d!\n", offset,
- hcb_2_pair_table_size[cb]); */
- return 10;
- }
-
- sp[0] = hcb_2_pair_table[cb][offset].x;
- sp[1] = hcb_2_pair_table[cb][offset].y;
-
- return 0;
-}
-
-static huffman_2step_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp)
-{
- uint8_t err = huffman_2step_pair(cb, ld, sp);
- huffman_sign_bits(ld, sp, PAIR_LEN);
-
- return err;
-}
-
-static uint8_t huffman_binary_quad(uint8_t cb, bitfile *ld, int16_t *sp)
-{
- uint16_t offset = 0;
-
- while (!hcb3[offset].is_leaf)
- {
- uint8_t b = faad_get1bit(ld
- DEBUGVAR(1,255,"huffman_spectral_data():3"));
- offset += hcb3[offset].data[b];
- }
-
- if (offset > hcb_bin_table_size[cb])
- {
- /* printf("ERROR: offset into hcb_bin_table = %d >%d!\n", offset,
- hcb_bin_table_size[cb]); */
- return 10;
- }
-
- sp[0] = hcb3[offset].data[0];
- sp[1] = hcb3[offset].data[1];
- sp[2] = hcb3[offset].data[2];
- sp[3] = hcb3[offset].data[3];
-
- return 0;
-}
-
-static uint8_t huffman_binary_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp)
-{
- uint8_t err = huffman_binary_quad(cb, ld, sp);
- huffman_sign_bits(ld, sp, QUAD_LEN);
-
- return err;
-}
-
-static uint8_t huffman_binary_pair(uint8_t cb, bitfile *ld, int16_t *sp)
-{
- uint16_t offset = 0;
-
- while (!hcb_bin_table[cb][offset].is_leaf)
- {
- uint8_t b = faad_get1bit(ld
- DEBUGVAR(1,255,"huffman_spectral_data():9"));
- offset += hcb_bin_table[cb][offset].data[b];
- }
-
- if (offset > hcb_bin_table_size[cb])
- {
- /* printf("ERROR: offset into hcb_bin_table = %d >%d!\n", offset,
- hcb_bin_table_size[cb]); */
- return 10;
- }
-
- sp[0] = hcb_bin_table[cb][offset].data[0];
- sp[1] = hcb_bin_table[cb][offset].data[1];
-
- return 0;
-}
-
-static uint8_t huffman_binary_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp)
-{
- uint8_t err = huffman_binary_pair(cb, ld, sp);
- huffman_sign_bits(ld, sp, PAIR_LEN);
-
- return err;
-}
-
-static int16_t huffman_codebook(uint8_t i)
-{
- static const uint32_t data = 16428320;
- if (i == 0) return (int16_t)(data >> 16) & 0xFFFF;
- else return (int16_t)data & 0xFFFF;
-}
-
-static INLINE uint8_t huffman_spectral_data(uint8_t cb, bitfile *ld, int16_t *sp)
-{
- switch (cb)
- {
- case 1: /* 2-step method for data quadruples */
- case 2:
- return huffman_2step_quad(cb, ld, sp);
- case 3: /* binary search for data quadruples */
- return huffman_binary_quad_sign(cb, ld, sp);
- case 4: /* 2-step method for data quadruples */
- return huffman_2step_quad_sign(cb, ld, sp);
- case 5: /* binary search for data pairs */
- return huffman_binary_pair(cb, ld, sp);
- case 6: /* 2-step method for data pairs */
- return huffman_2step_pair(cb, ld, sp);
- case 7: /* binary search for data pairs */
- case 9:
- return huffman_binary_pair_sign(cb, ld, sp);
- case 8: /* 2-step method for data pairs */
- case 10:
- return huffman_2step_pair_sign(cb, ld, sp);
- case 12: {
- uint8_t err = huffman_2step_quad(1, ld, sp);
- sp[0] = huffman_codebook(0); sp[1] = huffman_codebook(1);
- return err; }
- case 11:
+int8_t huffman_scale_factor(bitfile *ld);
+uint8_t huffman_spectral_data(uint8_t cb, bitfile *ld, int16_t *sp);
#ifdef ERROR_RESILIENCE
- /* VCB11 uses codebook 11 */
- case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23:
- case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31:
- /* TODO: If ER is used, some extra error checking should be done */
+int8_t huffman_spectral_data_2(uint8_t cb, bits_t *ld, int16_t *sp);
#endif
- {
- uint8_t err = huffman_2step_pair_sign(11, ld, sp);
- sp[0] = huffman_getescape(ld, sp[0]);
- sp[1] = huffman_getescape(ld, sp[1]);
- return err;
- }
- default:
- /* Non existent codebook number, something went wrong */
- return 11;
- }
-
- return 0;
-}
#ifdef __cplusplus
}
Index: iq_table.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/iq_table.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- iq_table.h 30 Aug 2003 22:30:21 -0000 1.1
+++ iq_table.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -32,8 +32,6 @@
extern "C" {
#endif
-/* !!!DON'T CHANGE IQ_TABLE_SIZE!!! */
-#define IQ_TABLE_SIZE 1026
#ifndef FIXED_POINT
@@ -42,6 +40,9 @@
#pragma warning(disable:4244)
#endif
[...9217 lines suppressed...]
+ REAL_CONST(164683.598594/8.0),
+ REAL_CONST(164710.458852/8.0),
+ REAL_CONST(164737.320205/8.0),
+ REAL_CONST(164764.182653/8.0),
+ REAL_CONST(164791.046196/8.0),
+ REAL_CONST(164817.910834/8.0),
+ REAL_CONST(164844.776566/8.0),
+ REAL_CONST(164871.643393/8.0),
+ REAL_CONST(164898.511315/8.0),
+ REAL_CONST(164925.380331/8.0),
+ REAL_CONST(164952.250442/8.0),
+ REAL_CONST(164979.121647/8.0),
+ REAL_CONST(165005.993946/8.0),
+ REAL_CONST(165032.867339/8.0),
+ REAL_CONST(165059.741827/8.0),
+ REAL_CONST(165086.617408/8.0),
+ REAL_CONST(165113.494083/8.0)
};
#endif
Index: is.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/is.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
Index: is.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/is.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
Index: kbd_win.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/kbd_win.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- kbd_win.h 30 Aug 2003 22:30:21 -0000 1.1
+++ kbd_win.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -32,8 +32,6 @@
extern "C" {
#endif
-#ifndef FIXED_POINT
-
#ifdef _MSC_VER
#pragma warning(disable:4305)
#pragma warning(disable:4244)
@@ -41,4502 +39,2250 @@
real_t kbd_long_1024[] =
[...6712 lines suppressed...]
- 0xFFFD3E0,
- 0xFFFE360,
- 0xFFFEDE0,
- 0xFFFF4E0,
- 0xFFFF960,
- 0xFFFFC30,
- 0xFFFFDE0,
- 0xFFFFEE0,
- 0xFFFFF70,
- 0xFFFFFC0,
- 0xFFFFFE0,
- 0xFFFFFF0,
- 0x10000000,
- 0x10000000
-};
-
-#endif
#ifdef __cplusplus
}
Index: lt_predict.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/lt_predict.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- lt_predict.c 30 Aug 2003 22:30:21 -0000 1.1
+++ lt_predict.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -25,6 +25,7 @@
** $Id$
**/
+
#include "common.h"
#include "structs.h"
Index: lt_predict.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/lt_predict.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
Index: mdct.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/mdct.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- mdct.c 30 Aug 2003 22:30:22 -0000 1.1
+++ mdct.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -113,6 +113,9 @@
uint8_t map_N_to_idx(uint16_t N)
{
+ /* gives an index into const_tab above */
+ /* for normal AAC deocding (eg. no scalable profile) only */
+ /* index 0 and 4 will be used */
switch(N)
{
case 2048: return 0;
@@ -151,14 +154,23 @@
c = const_tab[N_idx][3];
s = const_tab[N_idx][4];
+ /* (co)sine table build using recurrence relations */
+ /* this can also be done using static table lookup or */
+ /* some form of interpolation */
for (k = 0; k < N/4; k++)
{
+#if 1
RE(mdct->sincos[k]) = -1*MUL_C_C(c,scale);
IM(mdct->sincos[k]) = -1*MUL_C_C(s,scale);
cold = c;
c = MUL_C_C(c,cangle) - MUL_C_C(s,sangle);
s = MUL_C_C(s,cangle) + MUL_C_C(cold,sangle);
+#else
+ /* no recurrence, just sines */
+ RE(mdct->sincos[k]) = -scale*cos(2.0*M_PI*(k+1./8.) / (float)N);
+ IM(mdct->sincos[k]) = -scale*sin(2.0*M_PI*(k+1./8.) / (float)N);
+#endif
}
/* initialise fft */
@@ -196,20 +208,16 @@
/* pre-IFFT complex multiplication */
for (k = 0; k < N4; k++)
{
- uint16_t n = k << 1;
- RE(x) = X_in[ n];
- IM(x) = X_in[N2 - 1 - n];
- RE(Z1[k]) = MUL_R_C(IM(x), RE(sincos[k])) - MUL_R_C(RE(x), IM(sincos[k]));
- IM(Z1[k]) = MUL_R_C(RE(x), RE(sincos[k])) + MUL_R_C(IM(x), IM(sincos[k]));
+ RE(Z1[k]) = MUL_R_C(X_in[N2 - 1 - 2*k], RE(sincos[k])) - MUL_R_C(X_in[2*k], IM(sincos[k]));
+ IM(Z1[k]) = MUL_R_C(X_in[2*k], RE(sincos[k])) + MUL_R_C(X_in[N2 - 1 - 2*k], IM(sincos[k]));
}
- /* complex IFFT */
+ /* complex IFFT, any non-scaling FFT can be used here */
cfftb(mdct->cfft, Z1);
/* post-IFFT complex multiplication */
for (k = 0; k < N4; k++)
{
- uint16_t n = k << 1;
RE(x) = RE(Z1[k]);
IM(x) = IM(Z1[k]);
@@ -220,15 +228,14 @@
/* reordering */
for (k = 0; k < N8; k++)
{
- uint16_t n = k << 1;
- X_out[ n] = IM(Z1[N8 + k]);
- X_out[ 1 + n] = -RE(Z1[N8 - 1 - k]);
- X_out[N4 + n] = RE(Z1[ k]);
- X_out[N4 + 1 + n] = -IM(Z1[N4 - 1 - k]);
- X_out[N2 + n] = RE(Z1[N8 + k]);
- X_out[N2 + 1 + n] = -IM(Z1[N8 - 1 - k]);
- X_out[N2 + N4 + n] = -IM(Z1[ k]);
- X_out[N2 + N4 + 1 + n] = RE(Z1[N4 - 1 - k]);
+ X_out[ 2*k] = IM(Z1[N8 + k]);
+ X_out[ 1 + 2*k] = -RE(Z1[N8 - 1 - k]);
+ X_out[N4 + 2*k] = RE(Z1[ k]);
+ X_out[N4 + 1 + 2*k] = -IM(Z1[N4 - 1 - k]);
+ X_out[N2 + 2*k] = RE(Z1[N8 + k]);
+ X_out[N2 + 1 + 2*k] = -IM(Z1[N8 - 1 - k]);
+ X_out[N2 + N4 + 2*k] = -IM(Z1[ k]);
+ X_out[N2 + N4 + 1 + 2*k] = RE(Z1[N4 - 1 - k]);
}
}
@@ -265,7 +272,7 @@
IM(Z1[k + N8]) = -MUL_R_C(IM(x), RE(sincos[k + N8])) + MUL_R_C(RE(x), IM(sincos[k + N8]));
}
- /* complex FFT */
+ /* complex FFT, any non-scaling FFT can be used here */
cfftf(mdct->cfft, Z1);
/* post-FFT complex multiplication */
Index: mdct.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/mdct.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- mdct.h 30 Aug 2003 22:30:22 -0000 1.1
+++ mdct.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -32,7 +32,6 @@
extern "C" {
#endif
-#include "cfft.h"
mdct_info *faad_mdct_init(uint16_t N);
void faad_mdct_end(mdct_info *mdct);
Index: mp4.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/mp4.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- mp4.c 30 Aug 2003 22:30:22 -0000 1.1
+++ mp4.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -148,7 +148,7 @@
mp4ASC->channelsConfiguration = (uint8_t)faad_getbits(&ld, 4
DEBUGVAR(1,3,"parse_audio_decoder_specific_info(): ChannelsConfiguration"));
- mp4ASC->samplingFrequency = sample_rates[mp4ASC->samplingFrequencyIndex];
+ mp4ASC->samplingFrequency = get_sample_rate(mp4ASC->samplingFrequencyIndex);
if (ObjectTypesTable[mp4ASC->objectTypeIndex] != 1)
{
@@ -180,7 +180,7 @@
mp4ASC->samplingFrequency = (uint32_t)faad_getbits(&ld, 24
DEBUGVAR(1,6,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex"));
} else {
- mp4ASC->samplingFrequency = sample_rates[mp4ASC->samplingFrequencyIndex];
+ mp4ASC->samplingFrequency = get_sample_rate(mp4ASC->samplingFrequencyIndex);
}
mp4ASC->objectTypeIndex = (uint8_t)faad_getbits(&ld, 5
DEBUGVAR(1,7,"parse_audio_decoder_specific_info(): ObjectTypeIndex"));
@@ -216,7 +216,7 @@
#ifdef SBR_DEC
- bits_to_decode = buffer_size*8 - faad_get_processed_bits(&ld);
+ bits_to_decode = (int8_t)(buffer_size*8 - faad_get_processed_bits(&ld));
if ((mp4ASC->objectTypeIndex != 5) && (bits_to_decode >= 16))
{
@@ -242,10 +242,21 @@
mp4ASC->samplingFrequency = (uint32_t)faad_getbits(&ld, 24
DEBUGVAR(1,13,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex"));
} else {
- mp4ASC->samplingFrequency = sample_rates[mp4ASC->samplingFrequencyIndex];
+ mp4ASC->samplingFrequency = get_sample_rate(mp4ASC->samplingFrequencyIndex);
}
}
}
+ }
+ }
+
+ /* no SBR signalled, this could mean either implicit signalling or no SBR in this file */
+ /* MPEG specification states: assume SBR on files with samplerate <= 24000 Hz */
+ if (mp4ASC->sbr_present_flag == -1)
+ {
+ if (mp4ASC->samplingFrequency <= 24000)
+ {
+ mp4ASC->samplingFrequency *= 2;
+ mp4ASC->forceUpSampling = 1;
}
}
#endif
Index: mp4.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/mp4.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
Index: ms.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/ms.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
Index: ms.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/ms.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
Index: output.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/output.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- output.c 30 Aug 2003 22:30:22 -0000 1.1
+++ output.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -50,7 +50,7 @@
dither_t Dither;
double doubletmp;
-#define DM_MUL (1./(1.+sqrt(2.)))
+#define DM_MUL ((real_t)1.0/((real_t)1.0+(real_t)sqrt(2.0)))
static INLINE real_t get_sample(real_t **input, uint8_t channel, uint16_t sample,
uint8_t downMatrix, uint8_t *internal_channel)
@@ -60,12 +60,12 @@
if (channel == 0)
{
return DM_MUL * (input[internal_channel[1]][sample] +
- input[internal_channel[0]][sample]/sqrt(2.) +
- input[internal_channel[3]][sample]/sqrt(2.));
+ input[internal_channel[0]][sample]/(real_t)sqrt(2.) +
+ input[internal_channel[3]][sample]/(real_t)sqrt(2.));
} else {
return DM_MUL * (input[internal_channel[2]][sample] +
- input[internal_channel[0]][sample]/sqrt(2.) +
- input[internal_channel[4]][sample]/sqrt(2.));
+ input[internal_channel[0]][sample]/(real_t)sqrt(2.) +
+ input[internal_channel[4]][sample]/(real_t)sqrt(2.));
}
} else {
return input[internal_channel[channel]][sample];
@@ -107,7 +107,8 @@
case FAAD_FMT_16BIT_DITHER:
for(i = 0; i < frame_len; i++, j++)
{
- real_t inp = input[internal_channel][i];
+ //real_t inp = input[internal_channel][i];
+ real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel);
double Sum = inp * 65535.f;
int64_t val;
if(j > 31)
@@ -125,7 +126,8 @@
case FAAD_FMT_16BIT_H_SHAPE:
for(i = 0; i < frame_len; i++, j++)
{
- real_t inp = input[internal_channel][i];
+ //real_t inp = input[internal_channel][i];
+ real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel);
double Sum = inp * 65535.f;
int64_t val;
if(j > 31)
@@ -141,7 +143,8 @@
case FAAD_FMT_24BIT:
for(i = 0; i < frame_len; i++)
{
- real_t inp = input[internal_channel][i];
+ //real_t inp = input[internal_channel][i];
+ real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel);
if (inp > (1<<15)-1)
inp = (1<<15)-1;
else if (inp < -(1<<15))
@@ -152,7 +155,8 @@
case FAAD_FMT_32BIT:
for(i = 0; i < frame_len; i++)
{
- real_t inp = input[internal_channel][i];
+ //real_t inp = input[internal_channel][i];
+ real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel);
if (inp > (1<<15)-1)
inp = (1<<15)-1;
else if (inp < -(1<<15))
@@ -163,14 +167,16 @@
case FAAD_FMT_FLOAT:
for(i = 0; i < frame_len; i++)
{
- real_t inp = input[internal_channel][i];
+ //real_t inp = input[internal_channel][i];
+ real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel);
float_sample_buffer[(i*channels)+ch] = inp*FLOAT_SCALE;
}
break;
case FAAD_FMT_DOUBLE:
for(i = 0; i < frame_len; i++)
{
- real_t inp = input[internal_channel][i];
+ //real_t inp = input[internal_channel][i];
+ real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel);
double_sample_buffer[(i*channels)+ch] = (double)inp*FLOAT_SCALE;
}
break;
@@ -191,13 +197,13 @@
if(!shapingtype)
{
double tmp = Random_Equi(Dither.Dither);
- Sum2 = tmp - Dither.LastRandomNumber[k];
- Dither.LastRandomNumber[k] = tmp;
+ Sum2 = tmp - (double)Dither.LastRandomNumber[k];
+ Dither.LastRandomNumber[k] = (int32_t)tmp;
Sum2 = Sum += Sum2;
val = ROUND64(Sum2)&Dither.Mask;
} else {
Sum2 = Random_Triangular(Dither.Dither) - scalar16(Dither.DitherHistory[k], Dither.FilterCoeff + i);
- Sum += Dither.DitherHistory[k][(-1-i)&15] = Sum2;
+ Sum += Dither.DitherHistory[k][(-1-i)&15] = (float32_t)Sum2;
Sum2 = Sum + scalar16(Dither.ErrorHistory[k], Dither.FilterCoeff + i );
val = ROUND64(Sum2)&Dither.Mask;
Dither.ErrorHistory[k][(-1-i)&15] = (float)(Sum - val);
Index: output.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/output.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
Index: pns.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/pns.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- pns.c 30 Aug 2003 22:30:22 -0000 1.1
+++ pns.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -33,7 +33,7 @@
#ifdef FIXED_POINT
-#define DIV(A, B) (((int64_t)A << COEF_BITS)/B)
+#define DIV(A, B) (((int64_t)A << REAL_BITS)/B)
#define step(shift) \
if ((0x40000000l >> shift) + root <= value) \
@@ -45,6 +45,7 @@
}
/* fixed point square root approximation */
+/* !!!! ONLY WORKS FOR EVEN %REAL_BITS% !!!! */
real_t fp_sqrt(real_t value)
{
real_t root = 0;
@@ -57,7 +58,7 @@
if (root < value)
++root;
- root <<= (COEF_BITS/2);
+ root <<= (REAL_BITS/2);
return root;
}
@@ -79,13 +80,14 @@
value. A suitable random number generator can be realized using one
multiplication/accumulation per random value.
*/
-static INLINE void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t size)
+static INLINE void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t size,
+ uint8_t sub)
{
#ifndef FIXED_POINT
uint16_t i;
real_t energy = 0.0;
- real_t scale = 1.0/(real_t)size * ISQRT_MEAN_NRG;
+ real_t scale = (real_t)1.0/(real_t)size;
for (i = 0; i < size; i++)
{
@@ -94,7 +96,7 @@
energy += tmp*tmp;
}
- scale = 1.0/(real_t)sqrt(energy);
+ scale = (real_t)1.0/(real_t)sqrt(energy);
scale *= (real_t)pow(2.0, 0.25 * scale_factor);
for (i = 0; i < size; i++)
{
@@ -107,25 +109,29 @@
for (i = 0; i < size; i++)
{
- real_t tmp = ISQRT_MEAN_NRG * (int32_t)random_int();
- tmp = MUL_C_C(COEF_CONST(1)/size, tmp);
+ /* this can be replaced by a 16 bit random generator!!!! */
+ real_t tmp = (int32_t)random_int();
+ if (tmp < 0)
+ tmp = -(tmp & ((1<<(REAL_BITS-1))-1));
+ else
+ tmp = (tmp & ((1<<(REAL_BITS-1))-1));
- energy += MUL_C_C(tmp,tmp);
+ energy += MUL(tmp,tmp);
- /* convert COEF to REAL */
- spec[i] = (tmp >> -(REAL_BITS-COEF_BITS));
+ spec[i] = tmp;
}
energy = fp_sqrt(energy);
if (energy > 0)
{
- scale = DIV(COEF_CONST(1),energy);
-
- scale >>= -(REAL_BITS-COEF_BITS);
+ scale = DIV(REAL_CONST(1),energy);
exp = scale_factor / 4;
frac = scale_factor % 4;
+ /* IMDCT pre-scaling */
+ exp -= sub;
+
if (exp < 0)
scale >>= -exp;
else
@@ -144,7 +150,7 @@
void pns_decode(ic_stream *ics_left, ic_stream *ics_right,
real_t *spec_left, real_t *spec_right, uint16_t frame_len,
- uint8_t channel_pair)
+ uint8_t channel_pair, uint8_t object_type)
{
uint8_t g, sfb, b;
uint16_t size, offs;
@@ -152,6 +158,21 @@
uint8_t group = 0;
uint16_t nshort = frame_len >> 3;
+ uint8_t sub = 0;
+
+#ifdef FIXED_POINT
+ /* IMDCT scaling */
+ if (object_type == LD)
+ {
+ sub = 9 /*9*/;
+ } else {
+ if (ics_left->window_sequence == EIGHT_SHORT_SEQUENCE)
+ sub = 7 /*7*/;
+ else
+ sub = 10 /*10*/;
+ }
+#endif
+
for (g = 0; g < ics_left->num_window_groups; g++)
{
/* Do perceptual noise substitution decoding */
@@ -179,7 +200,7 @@
/* Generate random vector */
gen_rand_vector(&spec_left[(group*nshort)+offs],
- ics_left->scale_factors[g][sfb], size);
+ ics_left->scale_factors[g][sfb], size, sub);
}
/* From the spec:
@@ -223,7 +244,7 @@
/* Generate random vector */
gen_rand_vector(&spec_right[(group*nshort)+offs],
- ics_right->scale_factors[g][sfb], size);
+ ics_right->scale_factors[g][sfb], size, sub);
}
}
}
Index: pns.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/pns.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- pns.h 30 Aug 2003 22:30:22 -0000 1.1
+++ pns.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -37,20 +37,14 @@
#include "syntax.h"
#define NOISE_OFFSET 90
-/* #define MEAN_NRG 1.537228e+18 */ /* (2^31)^2 / 3 */
-#ifdef FIXED_POINT
-#define ISQRT_MEAN_NRG 0x1DC7 /* sqrt(1/sqrt(MEAN_NRG)) */
-#else
-#define ISQRT_MEAN_NRG 8.0655e-10 /* 1/sqrt(MEAN_NRG) */
-#endif
-
void pns_decode(ic_stream *ics_left, ic_stream *ics_right,
real_t *spec_left, real_t *spec_right, uint16_t frame_len,
- uint8_t channel_pair);
+ uint8_t channel_pair, uint8_t object_type);
static INLINE int32_t random2();
-static void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t size);
+static void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t size,
+ uint8_t sub);
static INLINE uint8_t is_noise(ic_stream *ics, uint8_t group, uint8_t sfb)
{
Index: pulse.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/pulse.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
Index: pulse.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/pulse.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
Index: rvlc.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/rvlc.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
Index: rvlc.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/rvlc.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
Index: sbr_dct.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sbr_dct.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sbr_dct.c 30 Aug 2003 22:30:22 -0000 1.1
+++ sbr_dct.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -2650,1624 +2650,6 @@
y[32] = f801 - f800;
}
-void DST4_64(real_t *y, real_t *x)
-{
- real_t f1;
- real_t f3;
- real_t f5;
- real_t f7;
- real_t f9;
- real_t f11;
[...1593 lines suppressed...]
- t0[52] = f198 + f757;
- t0[53] = f757 + f354;
- t0[54] = f354 + f692;
- t0[55] = f692 + f148;
- t0[56] = f148 + f763;
- t0[57] = f763 + f350;
- t0[58] = f350 + f686;
- t0[59] = f686 + f192;
- t0[60] = f192 + f769;
- t0[61] = f769 + f342;
- t0[62] = f342 + t0[63];
- for (i0=0; i0<64; i0++)
- {
- y[i0] = t0[-i0+63];
- }
-}
-
#endif
#endif
Index: sbr_dct.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sbr_dct.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sbr_dct.h 30 Aug 2003 22:30:22 -0000 1.1
+++ sbr_dct.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -35,7 +35,6 @@
void DCT3_32_unscaled(real_t *y, real_t *x);
void DCT2_64_unscaled(real_t *y, real_t *x);
void DCT4_64(real_t *y, real_t *x);
-void DST4_64(real_t *y, real_t *x);
#ifdef __cplusplus
Index: sbr_dec.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sbr_dec.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sbr_dec.c 30 Aug 2003 22:30:22 -0000 1.1
+++ sbr_dec.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -25,36 +25,6 @@
** $Id$
**/
-/*
- SBR Decoder overview:
-
- To achieve a synchronized output signal, the following steps have to be
- acknowledged in the decoder:
- - The bitstream parser divides the bitstream into two parts; the AAC
- core coder part and the SBR part.
- - The SBR bitstream part is fed to the bitstream de-multiplexer followed
- by de-quantization The raw data is Huffman decoded.
- - The AAC bitstream part is fed to the AAC core decoder, where the
- bitstream data of the current frame is decoded, yielding a time domain
- audio signal block of 1024 samples. The block length could easily be
- adapted to other sizes e.g. 960.
- - The core coder audio block is fed to the analysis QMF bank using a
- delay of 1312 samples.
- - The analysis QMF bank performs the filtering of the delayed core coder
- audio signal. The output from the filtering is stored in the matrix
- Xlow. The output from the analysis QMF bank is delayed tHFGen subband
- samples, before being fed to the synthesis QMF bank. To achieve
- synchronization tHFGen = 32, i.e. the value must equal the number of
- subband samples corresponding to one frame.
- - The HF generator calculates XHigh given the matrix XLow. The process
- is guided by the SBR data contained in the current frame.
- - The envelope adjuster calculates the matrix Y given the matrix XHigh
- and the SBR envelope data, extracted from the SBR bitstream. To
- achieve synchronization, tHFAdj has to be set to tHFAdj = 0, i.e. the
- envelope adjuster operates on data delayed tHFGen subband samples.
- - The synthesis QMF bank operates on the delayed output from the analysis
- QMF bank and the output from the envelope adjuster.
- */
#include "common.h"
#include "structs.h"
@@ -71,7 +41,11 @@
#include "sbr_hfadj.h"
-sbr_info *sbrDecodeInit()
+sbr_info *sbrDecodeInit(uint16_t framelength
+#ifdef DRM
+ , uint8_t IsDRM
+#endif
+ )
{
sbr_info *sbr = malloc(sizeof(sbr_info));
memset(sbr, 0, sizeof(sbr_info));
@@ -90,6 +64,36 @@
sbr->prevEnvIsShort[1] = -1;
sbr->header_count = 0;
+#ifdef DRM
+ sbr->Is_DRM_SBR = 0;
+ if (IsDRM)
+ {
+ sbr->Is_DRM_SBR = 1;
+ sbr->tHFGen = T_HFGEN_DRM;
+ sbr->tHFAdj = T_HFADJ_DRM;
+
+ /* "offset" is different in DRM */
+ sbr->bs_samplerate_mode = 0;
+ } else
+#endif
+ {
+ sbr->bs_samplerate_mode = 1;
+ sbr->tHFGen = T_HFGEN;
+ sbr->tHFAdj = T_HFADJ;
+ }
+
+ /* force sbr reset */
+ sbr->bs_start_freq_prev = -1;
+
+ if (framelength == 960)
+ {
+ sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS_960;
+ sbr->numTimeSlots = NO_TIME_SLOTS_960;
+ } else {
+ sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS;
+ sbr->numTimeSlots = NO_TIME_SLOTS;
+ }
+
return sbr;
}
@@ -152,10 +156,9 @@
sbr->prevEnvIsShort[ch] = -1;
}
-
void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel,
real_t *right_channel, uint8_t id_aac,
- uint8_t just_seeked)
+ uint8_t just_seeked, uint8_t upsample_only)
{
int16_t i, k, l;
@@ -168,34 +171,47 @@
real_t deg[64];
#endif
- bitfile *ld = (bitfile*)malloc(sizeof(bitfile));
-
+ bitfile *ld = NULL;
sbr->id_aac = id_aac;
channels = (id_aac == ID_SCE) ? 1 : 2;
+ if (sbr->data == NULL || sbr->data_size == 0)
+ {
+ ret = 1;
+ } else {
+ ld = (bitfile*)malloc(sizeof(bitfile));
+
/* initialise and read the bitstream */
faad_initbits(ld, sbr->data, sbr->data_size);
ret = sbr_extension_data(ld, sbr, id_aac);
- if (sbr->data) free(sbr->data);
- sbr->data = NULL;
-
ret = ld->error ? ld->error : ret;
faad_endbits(ld);
if (ld) free(ld);
ld = NULL;
+ }
+
+ if (sbr->data) free(sbr->data);
+ sbr->data = NULL;
+
if (ret || (sbr->header_count == 0))
{
/* don't process just upsample */
dont_process = 1;
+
+ /* Re-activate reset for next frame */
+ if (ret && sbr->Reset)
+ sbr->bs_start_freq_prev = -1;
}
if (just_seeked)
+ {
sbr->just_seeked = 1;
- else
+ } else {
sbr->just_seeked = 0;
+ }
for (ch = 0; ch < channels; ch++)
{
@@ -211,11 +227,11 @@
sbr->Q_temp_prev[ch][j] = malloc(64*sizeof(real_t));
}
- sbr->Xsbr[ch] = malloc((32+tHFGen)*64 * sizeof(qmf_t));
- sbr->Xcodec[ch] = malloc((32+tHFGen)*32 * sizeof(qmf_t));
+ sbr->Xsbr[ch] = malloc((sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
+ sbr->Xcodec[ch] = malloc((sbr->numTimeSlotsRate+sbr->tHFGen)*32 * sizeof(qmf_t));
- memset(sbr->Xsbr[ch], 0, (32+tHFGen)*64 * sizeof(qmf_t));
- memset(sbr->Xcodec[ch], 0, (32+tHFGen)*32 * sizeof(qmf_t));
+ memset(sbr->Xsbr[ch], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
+ memset(sbr->Xcodec[ch], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*32 * sizeof(qmf_t));
}
if (ch == 0)
@@ -223,7 +239,8 @@
else
ch_buf = right_channel;
- for (i = 0; i < tHFAdj; i++)
+#if 0
+ for (i = 0; i < sbr->tHFAdj; i++)
{
int8_t j;
for (j = sbr->kx_prev; j < sbr->kx; j++)
@@ -234,9 +251,13 @@
#endif
}
}
+#endif
/* subband analysis */
- sbr_qmf_analysis_32(sbr->qmfa[ch], ch_buf, sbr->Xcodec[ch], tHFGen);
+ if (dont_process)
+ sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], ch_buf, sbr->Xcodec[ch], sbr->tHFGen, 32);
+ else
+ sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], ch_buf, sbr->Xcodec[ch], sbr->tHFGen, sbr->kx);
if (!dont_process)
{
@@ -253,28 +274,30 @@
{
for (k = 0; k < sbr->kx; k++)
{
- QMF_RE(sbr->Xsbr[ch][(tHFAdj + l)*64 + k]) = 0;
+ QMF_RE(sbr->Xsbr[ch][(sbr->tHFAdj + l)*64 + k]) = 0;
}
}
#endif
+#if 1
/* hf adjustment */
hf_adjustment(sbr, sbr->Xsbr[ch]
#ifdef SBR_LOW_POWER
,deg
#endif
,ch);
+#endif
}
if ((sbr->just_seeked != 0) || dont_process)
{
- for (l = 0; l < 32; l++)
+ for (l = 0; l < sbr->numTimeSlotsRate; l++)
{
for (k = 0; k < 32; k++)
{
- QMF_RE(X[l * 64 + k]) = QMF_RE(sbr->Xcodec[ch][(l + tHFAdj)*32 + k]);
+ QMF_RE(X[l * 64 + k]) = QMF_RE(sbr->Xcodec[ch][(l + sbr->tHFAdj)*32 + k]);
#ifndef SBR_LOW_POWER
- QMF_IM(X[l * 64 + k]) = QMF_IM(sbr->Xcodec[ch][(l + tHFAdj)*32 + k]);
+ QMF_IM(X[l * 64 + k]) = QMF_IM(sbr->Xcodec[ch][(l + sbr->tHFAdj)*32 + k]);
#endif
}
for (k = 32; k < 64; k++)
@@ -286,7 +309,7 @@
}
}
} else {
- for (l = 0; l < 32; l++)
+ for (l = 0; l < sbr->numTimeSlotsRate; l++)
{
uint8_t xover_band;
@@ -295,48 +318,63 @@
else
xover_band = sbr->kx;
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
+ xover_band = sbr->kx;
+#endif
+
for (k = 0; k < xover_band; k++)
{
- QMF_RE(X[l * 64 + k]) = QMF_RE(sbr->Xcodec[ch][(l + tHFAdj)*32 + k]);
+ QMF_RE(X[l * 64 + k]) = QMF_RE(sbr->Xcodec[ch][(l + sbr->tHFAdj)*32 + k]);
#ifndef SBR_LOW_POWER
- QMF_IM(X[l * 64 + k]) = QMF_IM(sbr->Xcodec[ch][(l + tHFAdj)*32 + k]);
+ QMF_IM(X[l * 64 + k]) = QMF_IM(sbr->Xcodec[ch][(l + sbr->tHFAdj)*32 + k]);
#endif
}
for (k = xover_band; k < 64; k++)
{
- QMF_RE(X[l * 64 + k]) = QMF_RE(sbr->Xsbr[ch][(l + tHFAdj)*64 + k]);
+ QMF_RE(X[l * 64 + k]) = QMF_RE(sbr->Xsbr[ch][(l + sbr->tHFAdj)*64 + k]);
#ifndef SBR_LOW_POWER
- QMF_IM(X[l * 64 + k]) = QMF_IM(sbr->Xsbr[ch][(l + tHFAdj)*64 + k]);
+ QMF_IM(X[l * 64 + k]) = QMF_IM(sbr->Xsbr[ch][(l + sbr->tHFAdj)*64 + k]);
#endif
}
#ifdef SBR_LOW_POWER
- QMF_RE(X[l * 64 + xover_band - 1]) += QMF_RE(sbr->Xsbr[ch][(l + tHFAdj)*64 + xover_band - 1]);
+ QMF_RE(X[l * 64 + xover_band - 1]) += QMF_RE(sbr->Xsbr[ch][(l + sbr->tHFAdj)*64 + xover_band - 1]);
+#endif
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
+ {
+ for (k = xover_band; k < xover_band + 4; k++)
+ {
+ QMF_RE(X[l * 64 + k]) += QMF_RE(sbr->Xcodec[ch][(l + sbr->tHFAdj)*32 + k]);
+ QMF_IM(X[l * 64 + k]) += QMF_IM(sbr->Xcodec[ch][(l + sbr->tHFAdj)*32 + k]);
+ }
+ }
#endif
}
}
/* subband synthesis */
- sbr_qmf_synthesis_64(sbr->qmfs[ch], (const complex_t*)X, ch_buf);
+ sbr_qmf_synthesis_64(sbr, sbr->qmfs[ch], (const complex_t*)X, ch_buf);
for (i = 0; i < 32; i++)
{
int8_t j;
- for (j = 0; j < tHFGen; j++)
+ for (j = 0; j < sbr->tHFGen; j++)
{
- QMF_RE(sbr->Xcodec[ch][j*32 + i]) = QMF_RE(sbr->Xcodec[ch][(j+32)*32 + i]);
+ QMF_RE(sbr->Xcodec[ch][j*32 + i]) = QMF_RE(sbr->Xcodec[ch][(j+sbr->numTimeSlotsRate)*32 + i]);
#ifndef SBR_LOW_POWER
- QMF_IM(sbr->Xcodec[ch][j*32 + i]) = QMF_IM(sbr->Xcodec[ch][(j+32)*32 + i]);
+ QMF_IM(sbr->Xcodec[ch][j*32 + i]) = QMF_IM(sbr->Xcodec[ch][(j+sbr->numTimeSlotsRate)*32 + i]);
#endif
}
}
for (i = 0; i < 64; i++)
{
int8_t j;
- for (j = 0; j < tHFGen; j++)
+ for (j = 0; j < sbr->tHFGen; j++)
{
- QMF_RE(sbr->Xsbr[ch][j*64 + i]) = QMF_RE(sbr->Xsbr[ch][(j+32)*64 + i]);
+ QMF_RE(sbr->Xsbr[ch][j*64 + i]) = QMF_RE(sbr->Xsbr[ch][(j+sbr->numTimeSlotsRate)*64 + i]);
#ifndef SBR_LOW_POWER
- QMF_IM(sbr->Xsbr[ch][j*64 + i]) = QMF_IM(sbr->Xsbr[ch][(j+32)*64 + i]);
+ QMF_IM(sbr->Xsbr[ch][j*64 + i]) = QMF_IM(sbr->Xsbr[ch][(j+sbr->numTimeSlotsRate)*64 + i]);
#endif
}
}
Index: sbr_dec.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sbr_dec.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sbr_dec.h 30 Aug 2003 22:30:22 -0000 1.1
+++ sbr_dec.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -33,16 +33,13 @@
#endif
typedef struct {
-#if 0
- real_t post_exp_re[64];
- real_t post_exp_im[64];
-#endif
real_t *x;
uint8_t channels;
} qmfa_info;
typedef struct {
- real_t *v;
+ real_t *v[2];
+ uint8_t v_index;
uint8_t channels;
} qmfs_info;
@@ -144,6 +141,17 @@
qmf_t *Xsbr[2];
qmf_t *Xcodec[2];
+#ifdef DRM
+ int8_t lcstereo_flag;
+ uint8_t bs_dataextra;
+ uint16_t data_size_bits;
+ uint8_t Is_DRM_SBR;
+#endif
+
+ uint16_t numTimeSlotsRate;
+ uint16_t numTimeSlots;
+ uint8_t tHFGen;
+ uint8_t tHFAdj;
/* to get it compiling */
/* we'll see during the coding of all the tools, whether
@@ -184,12 +192,16 @@
uint8_t bs_df_noise[2][3];
} sbr_info;
-sbr_info *sbrDecodeInit();
+sbr_info *sbrDecodeInit(uint16_t framelength
+#ifdef DRM
+ , uint8_t IsDRM
+#endif
+ );
void sbrDecodeEnd(sbr_info *sbr);
void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel,
real_t *right_channel, uint8_t id_aac,
- uint8_t just_seeked);
+ uint8_t just_seeked, uint8_t upsample_only);
#ifdef __cplusplus
Index: sbr_e_nf.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sbr_e_nf.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sbr_e_nf.c 30 Aug 2003 22:30:22 -0000 1.1
+++ sbr_e_nf.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -39,13 +39,6 @@
{
uint8_t l, k;
-#if 0
- if (sbr->frame == 19)
- {
- sbr->frame = 19;
- }
-#endif
-
for (l = 0; l < sbr->L_E[ch]; l++)
{
if (sbr->bs_df_env[ch][l] == 0)
@@ -113,23 +106,6 @@
}
}
}
-
-#if 0
- if (sbr->frame == 23)
- {
- int l, k;
-
- for (l = 0; l < sbr->L_E[ch]; l++)
- {
- for (k = 0; k < sbr->n[sbr->f[ch][l]]; k++)
- {
- //printf("l:%d k:%d E:%d\n",l,k, sbr->E[ch][k][l]);
- printf("%d\n", sbr->E[ch][k][l]);
- }
- }
- printf("\n");
- }
-#endif
}
void extract_noise_floor_data(sbr_info *sbr, uint8_t ch)
@@ -159,23 +135,6 @@
}
}
}
-
-#if 0
- if (sbr->frame == 23)
- {
- int l, k;
-
- for (l = 0; l < sbr->L_Q[ch]; l++)
- {
- for (k = 0; k < sbr->N_Q; k++)
- {
- //printf("l:%d k:%d E:%d\n",l,k, sbr->E[ch][k][l]);
- printf("%d\n", sbr->Q[ch][k][l]);
- }
- }
- printf("\n");
- }
-#endif
}
/* FIXME: pow() not needed */
@@ -184,37 +143,14 @@
if (sbr->bs_coupling == 0)
{
uint8_t l, k;
-#ifdef FIXED_POINT
- uint8_t amp = (sbr->amp_res[ch]) ? 0 : 1;
-#else
- real_t amp = (sbr->amp_res[ch]) ? 1.0 : 0.5;
-#endif
+ real_t amp = (sbr->amp_res[ch]) ? 1.0f : 0.5f;
for (l = 0; l < sbr->L_E[ch]; l++)
{
for (k = 0; k < sbr->n[sbr->f[ch][l]]; k++)
{
-#ifndef FIXED_POINT
/* +6 for the *64 */
- sbr->E_orig[ch][k][l] = pow(2, sbr->E[ch][k][l]*amp + 6);
-#else
- int8_t exp;
-
- /* +6 for the *64 and -10 for the /32 in the synthesis QMF
- * since this is a energy value: (x/32)^2 = (x^2)/1024
- */
- exp = (sbr->E[ch][k][l] >> amp) + 6 - 10;
-
-// printf("%d\n", exp);
-
- if (exp < 0)
- sbr->E_orig[ch][k][l] = 0; //REAL_CONST(1) >> -exp;
- else
- sbr->E_orig[ch][k][l] = 1 << exp; //REAL_CONST(1) << exp;
-
- if (amp && (sbr->E[ch][k][l] & 1))
- sbr->E_orig[ch][k][l] = MUL(sbr->E_orig[ch][k][l], REAL_CONST(1.414213562));
-#endif
+ sbr->E_orig[ch][k][l] = (real_t)pow(2, sbr->E[ch][k][l]*amp + 6);
}
}
@@ -225,15 +161,7 @@
if (sbr->Q[ch][k][l] < 0 || sbr->Q[ch][k][l] > 30)
sbr->Q_orig[ch][k][l] = 0;
else {
-#ifndef FIXED_POINT
- sbr->Q_orig[ch][k][l] = pow(2, NOISE_FLOOR_OFFSET - sbr->Q[ch][k][l]);
-#else
- int8_t exp = NOISE_FLOOR_OFFSET - sbr->Q[ch][k][l];
- if (exp < 0)
- sbr->Q_orig[ch][k][l] = REAL_CONST(1) >> -exp;
- else
- sbr->Q_orig[ch][k][l] = REAL_CONST(1) << exp;
-#endif
+ sbr->Q_orig[ch][k][l] = (real_t)pow(2, NOISE_FLOOR_OFFSET - sbr->Q[ch][k][l]);
}
}
}
@@ -243,13 +171,8 @@
void unmap_envelope_noise(sbr_info *sbr)
{
uint8_t l, k;
-#ifdef FIXED_POINT
- uint8_t amp0 = (sbr->amp_res[0]) ? 0 : 1;
- uint8_t amp1 = (sbr->amp_res[1]) ? 0 : 1;
-#else
- real_t amp0 = (sbr->amp_res[0]) ? 1.0 : 0.5;
- real_t amp1 = (sbr->amp_res[1]) ? 1.0 : 0.5;
-#endif
+ real_t amp0 = (sbr->amp_res[0]) ? (real_t)1.0 : (real_t)0.5;
+ real_t amp1 = (sbr->amp_res[1]) ? (real_t)1.0 : (real_t)0.5;
for (l = 0; l < sbr->L_E[0]; l++)
{
@@ -257,59 +180,13 @@
{
real_t l_temp, r_temp;
-#ifdef FIXED_POINT
- int8_t exp;
-
- /* +6: * 64 ; +1: * 2 ; -10: /1024 QMF */
- exp = (sbr->E[0][k][l] >> amp0) - 3;
-
-// printf("%d\n", exp);
-
- if (exp < 0)
- l_temp = REAL_CONST(1) >> -exp;
- else
- l_temp = REAL_CONST(1) << exp;
-
- if (amp0 && (sbr->E[0][k][l] & 1))
- l_temp = MUL(l_temp, REAL_CONST(1.414213562373095));
-
- /* UN_MAP removed: (x / 4096) same as (x >> 12) */
- exp = (sbr->E[1][k][l] >> amp1) - 12;
-
-// printf("%d\n", exp);
-
- if (exp < 0)
- r_temp = REAL_CONST(1) >> -exp;
- else
- r_temp = REAL_CONST(1) << exp;
-
- if (amp1 && (sbr->E[1][k][l] & 1))
- r_temp = MUL(r_temp, REAL_CONST(1.414213562373095));
-#else
/* +6: * 64 ; +1: * 2 */
- l_temp = pow(2, sbr->E[0][k][l]*amp0 + 7);
+ l_temp = (real_t)pow(2, sbr->E[0][k][l]*amp0 + 7);
/* UN_MAP removed: (x / 4096) same as (x >> 12) */
- r_temp = pow(2, sbr->E[1][k][l]*amp1 - 12);
-#endif
+ r_temp = (real_t)pow(2, sbr->E[1][k][l]*amp1 - 12);
-
-#ifdef FIXED_POINT
- {
- real_t tmp = REAL_CONST(1.0) + r_temp;
- sbr->E_orig[1][k][l] = SBR_DIV(l_temp, tmp);
- }
-#else
- sbr->E_orig[1][k][l] = l_temp / (1.0 + r_temp);
-#endif
+ sbr->E_orig[1][k][l] = l_temp / ((real_t)1.0 + r_temp);
sbr->E_orig[0][k][l] = MUL(r_temp, sbr->E_orig[1][k][l]);
-
-#ifdef FIXED_POINT
- sbr->E_orig[0][k][l] >>= REAL_BITS;
- sbr->E_orig[1][k][l] >>= REAL_BITS;
-#endif
-
- //printf("%f\t%f\n", sbr->E_orig[0][k][l] /(float)(1<<REAL_BITS), sbr->E_orig[1][k][l] /(float)(1<<REAL_BITS));
- //printf("%f\t%f\n", sbr->E_orig[0][k][l]/1024., sbr->E_orig[1][k][l]/1024.);
}
}
for (l = 0; l < sbr->L_Q[0]; l++)
@@ -324,30 +201,10 @@
} else {
real_t l_temp, r_temp;
-#ifndef FIXED_POINT
- l_temp = pow(2.0, NOISE_FLOOR_OFFSET - sbr->Q[0][k][l] + 1);
- r_temp = pow(2.0, sbr->Q[1][k][l] - 12);
-#else
- int8_t exp;
-
- exp = NOISE_FLOOR_OFFSET - sbr->Q[0][k][l] + 1;
- if (exp < 0)
- l_temp = REAL_CONST(1) >> -exp;
- else
- l_temp = REAL_CONST(1) << exp;
-
- exp = sbr->Q[1][k][l] - 12;
- if (exp < 0)
- r_temp = REAL_CONST(1) >> -exp;
- else
- r_temp = REAL_CONST(1) << exp;
-#endif
-
-#ifdef FIXED_POINT
- sbr->Q_orig[1][k][l] = SBR_DIV(l_temp, (REAL_CONST(1.0) + r_temp));
-#else
- sbr->Q_orig[1][k][l] = l_temp / (1.0 + r_temp);
-#endif
+ l_temp = (real_t)pow(2.0, NOISE_FLOOR_OFFSET - sbr->Q[0][k][l] + 1);
+ r_temp = (real_t)pow(2.0, sbr->Q[1][k][l] - 12);
+
+ sbr->Q_orig[1][k][l] = l_temp / ((real_t)1.0 + r_temp);
sbr->Q_orig[0][k][l] = MUL(r_temp, sbr->Q_orig[1][k][l]);
}
}
Index: sbr_e_nf.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sbr_e_nf.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sbr_e_nf.h 30 Aug 2003 22:30:22 -0000 1.1
+++ sbr_e_nf.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -35,6 +35,7 @@
void extract_envelope_data(sbr_info *sbr, uint8_t ch);
void extract_noise_floor_data(sbr_info *sbr, uint8_t ch);
void envelope_noise_dequantisation(sbr_info *sbr, uint8_t ch);
+void unmap_envelope_noise(sbr_info *sbr);
#ifdef __cplusplus
Index: sbr_fbt.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sbr_fbt.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sbr_fbt.c 30 Aug 2003 22:30:22 -0000 1.1
+++ sbr_fbt.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -37,13 +37,16 @@
#include "sbr_syntax.h"
#include "sbr_fbt.h"
-
/* calculate the start QMF channel for the master frequency band table */
/* parameter is also called k0 */
-uint16_t qmf_start_channel(uint8_t bs_start_freq, uint8_t bs_samplerate_mode,
+uint8_t qmf_start_channel(uint8_t bs_start_freq, uint8_t bs_samplerate_mode,
uint32_t sample_rate)
{
- static int8_t offset[7][16] = {
+ static const uint8_t startMinTable[12] = { 7, 7, 10, 11, 12, 16, 16,
+ 17, 24, 32, 35, 48 };
+ static const uint8_t offsetIndexTable[12] = { 5, 5, 4, 4, 4, 3, 2, 1, 0,
+ 6, 6, 6 };
+ static const int8_t offset[7][16] = {
{ -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7 },
{ -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13 },
{ -5, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16 },
@@ -52,8 +55,10 @@
{ -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24 },
{ 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24, 28, 33 }
};
- uint8_t startMin;
+ uint8_t startMin = startMinTable[get_sr_index(sample_rate)];
+ uint8_t offsetIndex = offsetIndexTable[get_sr_index(sample_rate)];
+#if 0 /* replaced with table (startMinTable) */
if (sample_rate >= 64000)
{
startMin = (uint8_t)((5000.*128.)/(float)sample_rate + 0.5);
@@ -62,9 +67,13 @@
} else {
startMin = (uint8_t)((4000.*128.)/(float)sample_rate + 0.5);
}
+#endif
if (bs_samplerate_mode)
{
+ return startMin + offset[offsetIndex][bs_start_freq];
+
+#if 0 /* replaced by offsetIndexTable */
switch (sample_rate)
{
case 16000:
@@ -83,6 +92,7 @@
return startMin + offset[4][bs_start_freq];
}
}
+#endif
} else {
return startMin + offset[6][bs_start_freq];
}
@@ -95,8 +105,8 @@
/* calculate the stop QMF channel for the master frequency band table */
/* parameter is also called k2 */
-uint16_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate,
- uint16_t k0)
+uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate,
+ uint8_t k0)
{
if (bs_stop_freq == 15)
{
@@ -104,10 +114,29 @@
} else if (bs_stop_freq == 14) {
return min(64, k0 * 2);
} else {
+ static const uint8_t stopMinTable[12] = { 13, 15, 20, 21, 23,
+ 32, 32, 35, 48, 64, 70, 96 };
+ static const int8_t offset[12][14] = {
+ { 0, 2, 4, 6, 8, 11, 14, 18, 22, 26, 31, 37, 44, 51 },
+ { 0, 2, 4, 6, 8, 11, 14, 18, 22, 26, 31, 36, 42, 49 },
+ { 0, 2, 4, 6, 8, 11, 14, 17, 21, 25, 29, 34, 39, 44 },
+ { 0, 2, 4, 6, 8, 11, 14, 17, 20, 24, 28, 33, 38, 43 },
+ { 0, 2, 4, 6, 8, 11, 14, 17, 20, 24, 28, 32, 36, 41 },
+ { 0, 2, 4, 6, 8, 10, 12, 14, 17, 20, 23, 26, 29, 32 },
+ { 0, 2, 4, 6, 8, 10, 12, 14, 17, 20, 23, 26, 29, 32 },
+ { 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 20, 23, 26, 29 },
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, -1, -2, -3, -4, -5, -6, -6, -6, -6, -6, -6, -6, -6 },
+ { 0, -3, -6, -9, -12, -15, -18, -20, -22, -24, -26, -28, -30, -32 }
+ };
+#if 0
uint8_t i;
- uint8_t stopMin;
int32_t stopDk[13], stopDk_t[14], k2;
+#endif
+ uint8_t stopMin = stopMinTable[get_sr_index(sample_rate)];
+#if 0 /* replaced by table lookup */
if (sample_rate >= 64000)
{
stopMin = (uint8_t)((10000.*128.)/(float)sample_rate + 0.5);
@@ -116,7 +145,10 @@
} else {
stopMin = (uint8_t)((8000.*128.)/(float)sample_rate + 0.5);
}
+#endif
+#if 0 /* replaced by table lookup */
+ /* diverging power series */
for (i = 0; i <= 13; i++)
{
stopDk_t[i] = (int32_t)(stopMin*pow(64.0/stopMin, i/13.0) + 0.5);
@@ -126,7 +158,7 @@
stopDk[i] = stopDk_t[i+1] - stopDk_t[i];
}
- /* needed? or does this always reverse the array? */
+ /* needed? */
qsort(stopDk, 13, sizeof(stopDk[0]), longcmp);
k2 = stopMin;
@@ -135,6 +167,9 @@
k2 += stopDk[i];
}
return min(64, k2);
+#endif
+ /* bs_stop_freq <= 13 */
+ return min(64, stopMin + offset[get_sr_index(sample_rate)][min(bs_stop_freq, 13)]);
}
return 0;
@@ -145,7 +180,7 @@
version for bs_freq_scale = 0
*/
-void master_frequency_table_fs0(sbr_info *sbr, uint16_t k0, uint16_t k2,
+void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2,
uint8_t bs_alter_scale)
{
int8_t incr;
@@ -164,12 +199,21 @@
}
dk = bs_alter_scale ? 2 : 1;
+
+#if 0 /* replaced by float-less design */
nrBands = 2 * (int32_t)((float)(k2-k0)/(dk*2) + (-1+dk)/2.0f);
- nrBands = min(nrBands, 64);
+#else
+ if (bs_alter_scale)
+ {
+ nrBands = (((k2-k0+2)>>2)<<1);
+ } else {
+ nrBands = (((k2-k0)>>1)<<1);
+ }
+#endif
+ nrBands = min(nrBands, 63);
k2Achieved = k0 + nrBands * dk;
k2Diff = k2 - k2Achieved;
- /* for (k = 0; k <= nrBands; k++) Typo fix */
for (k = 0; k < nrBands; k++)
vDk[k] = dk;
@@ -203,22 +247,34 @@
#endif
}
+
+/*
+ This function finds the number of bands using this formula:
+ bands * log(a1/a0)/log(2.0) + 0.5
+*/
+static int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1)
+{
+ real_t div = (real_t)log(2.0);
+ if (warp) div *= (real_t)1.3;
+
+ return (int32_t)(bands * log((float)a1/(float)a0)/div + 0.5);
+}
+
+
/*
version for bs_freq_scale > 0
*/
-void master_frequency_table(sbr_info *sbr, uint16_t k0, uint16_t k2,
+void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2,
uint8_t bs_freq_scale, uint8_t bs_alter_scale)
{
uint8_t k, bands, twoRegions;
- uint16_t k1;
+ uint8_t k1;
uint32_t nrBand0, nrBand1;
int32_t vDk0[64], vDk1[64];
int32_t vk0[64], vk1[64];
- float warp;
- uint8_t temp1[] = { 12, 10, 8 };
- float temp2[] = { 1.0, 1.3 };
+ uint8_t temp1[] = { 6, 5, 4 };
- /* without memset code enters infinte loop,
+ /* without memset code enters infinite loop,
so there must be some wrong table access */
memset(vDk0, 0, 64*sizeof(int32_t));
memset(vDk1, 0, 64*sizeof(int32_t));
@@ -233,22 +289,22 @@
}
bands = temp1[bs_freq_scale-1];
- warp = temp2[bs_alter_scale];
if ((float)k2/(float)k0 > 2.2449)
{
twoRegions = 1;
- k1 = 2 * k0;
+ k1 = k0 << 1;
} else {
twoRegions = 0;
k1 = k2;
}
- nrBand0 = 2 * (int32_t)(bands * log((float)k1/(float)k0)/(2.0*log(2.0)) + 0.5);
- nrBand0 = min(nrBand0, 64);
+ nrBand0 = 2 * find_bands(0, bands, k0, k1);
+ nrBand0 = min(nrBand0, 63);
+
for (k = 0; k <= nrBand0; k++)
{
- /* MAPLE */
+ /* diverging power series */
vDk0[k] = (int32_t)(k0 * pow((float)k1/(float)k0, (k+1)/(float)nrBand0)+0.5) -
(int32_t)(k0 * pow((float)k1/(float)k0, k/(float)nrBand0)+0.5);
}
@@ -272,8 +328,8 @@
return;
}
- nrBand1 = 2 * (int32_t)(bands * log((float)k2/(float)k1)/(2.0 * log(2.0) * warp) + 0.5);
- nrBand1 = min(nrBand1, 64);
+ nrBand1 = 2 * find_bands(1 /* warped */, bands, k1, k2);
+ nrBand1 = min(nrBand1, 63);
for (k = 0; k <= nrBand1 - 1; k++)
{
@@ -322,16 +378,18 @@
}
/* calculate the derived frequency border tables from f_master */
-void derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band,
- uint16_t k2)
+uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band,
+ uint8_t k2)
{
uint8_t k, i;
uint32_t minus;
- sbr->N_high = sbr->N_master - bs_xover_band;
+ /* The following relation shall be satisfied: bs_xover_band < N_Master */
+ if (sbr->N_master <= bs_xover_band)
+ return 1;
- /* is this accurate? */
- sbr->N_low = sbr->N_high/2 + (sbr->N_high - 2 * (sbr->N_high/2));
+ sbr->N_high = sbr->N_master - bs_xover_band;
+ sbr->N_low = (sbr->N_high>>1) + (sbr->N_high - ((sbr->N_high>>1)<<1));
sbr->n[0] = sbr->N_low;
sbr->n[1] = sbr->N_high;
@@ -344,7 +402,6 @@
sbr->M = sbr->f_table_res[HI_RES][sbr->N_high] - sbr->f_table_res[HI_RES][0];
sbr->kx = sbr->f_table_res[HI_RES][0];
- /* correct? */
minus = (sbr->N_high & 1) ? 1 : 0;
for (k = 0; k <= sbr->N_low; k++)
@@ -355,7 +412,6 @@
i = 2*k - minus;
sbr->f_table_res[LO_RES][k] = sbr->f_table_res[HI_RES][i];
}
- /* end correct? */
#if 0
printf("f_table_res[HI_RES][%d]: ", sbr->N_high);
@@ -379,19 +435,23 @@
{
sbr->N_Q = 1;
} else {
- /* MAPLE */
+#if 0
sbr->N_Q = max(1, (int32_t)(sbr->bs_noise_bands*(log(k2/(float)sbr->kx)/log(2.0)) + 0.5));
- if (sbr->N_Q == 0)
- sbr->N_Q = 1;
- }
+#else
+ sbr->N_Q = max(1, find_bands(0, sbr->bs_noise_bands, sbr->kx, k2));
+#endif
sbr->N_Q = min(5, sbr->N_Q);
+ }
for (k = 0; k <= sbr->N_Q; k++)
{
if (k == 0)
+ {
i = 0;
- else /* is this accurate? */
- i = i + (int32_t)((sbr->N_low - i)/(sbr->N_Q + 1 - k));
+ } else { /* is this accurate? */
+ //i = i + (int32_t)((sbr->N_low - i)/(sbr->N_Q + 1 - k));
+ i = i + (sbr->N_low - i)/(sbr->N_Q + 1 - k);
+ }
sbr->f_table_noise[k] = sbr->f_table_res[LO_RES][i];
}
@@ -418,6 +478,8 @@
}
printf("\n");
#endif
+
+ return 0;
}
/* TODO: blegh, ugly */
@@ -427,13 +489,20 @@
*/
void limiter_frequency_table(sbr_info *sbr)
{
- static real_t limiterBandsPerOctave[] = { REAL_CONST(1.2),
+#if 0
+ static const real_t limiterBandsPerOctave[] = { REAL_CONST(1.2),
REAL_CONST(2), REAL_CONST(3) };
+#else
+ static const real_t limiterBandsCompare[] = { REAL_CONST(1.328125),
+ REAL_CONST(1.1875), REAL_CONST(1.125) };
+#endif
uint8_t k, s;
int8_t nrLim;
int32_t limTable[100 /*TODO*/];
uint8_t patchBorders[64/*??*/];
+#if 0
real_t limBands;
+#endif
sbr->f_table_lim[0][0] = sbr->f_table_res[LO_RES][0] - sbr->kx;
sbr->f_table_lim[0][1] = sbr->f_table_res[LO_RES][sbr->N_low] - sbr->kx;
@@ -443,7 +512,9 @@
{
memset(limTable, 0, 100*sizeof(int32_t));
+#if 0
limBands = limiterBandsPerOctave[s - 1];
+#endif
patchBorders[0] = sbr->kx;
for (k = 1; k <= sbr->noPatches; k++)
@@ -474,11 +545,18 @@
real_t nOctaves;
if (limTable[k-1] != 0)
+#if 0
nOctaves = REAL_CONST(log((float)limTable[k]/(float)limTable[k-1])/log(2.0));
+#endif
+ nOctaves = (real_t)limTable[k]/(real_t)limTable[k-1];
else
nOctaves = 0;
+#if 0
if ((MUL(nOctaves,limBands)) < REAL_CONST(0.49))
+#else
+ if (nOctaves < limiterBandsCompare[s - 1])
+#endif
{
uint8_t i;
if (limTable[k] != limTable[k-1])
Index: sbr_fbt.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sbr_fbt.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sbr_fbt.h 30 Aug 2003 22:30:22 -0000 1.1
+++ sbr_fbt.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -32,16 +32,17 @@
extern "C" {
#endif
-uint16_t qmf_start_channel(uint8_t bs_start_freq, uint8_t bs_samplerate_mode,
+static int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1);
+uint8_t qmf_start_channel(uint8_t bs_start_freq, uint8_t bs_samplerate_mode,
uint32_t sample_rate);
-uint16_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate,
- uint16_t k0);
-void master_frequency_table_fs0(sbr_info *sbr, uint16_t k0, uint16_t k2,
+uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate,
+ uint8_t k0);
+void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2,
uint8_t bs_alter_scale);
-void master_frequency_table(sbr_info *sbr, uint16_t k0, uint16_t k2,
+void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2,
uint8_t bs_freq_scale, uint8_t bs_alter_scale);
-void derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band,
- uint16_t k2);
+uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band,
+ uint8_t k2);
void limiter_frequency_table(sbr_info *sbr);
Index: sbr_hfadj.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sbr_hfadj.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sbr_hfadj.c 30 Aug 2003 22:30:22 -0000 1.1
+++ sbr_hfadj.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -54,16 +54,12 @@
calculate_gain(sbr, &adj, ch);
-#if 1
-
#ifdef SBR_LOW_POWER
calc_gain_groups(sbr, &adj, deg, ch);
aliasing_reduction(sbr, &adj, deg, ch);
#endif
hf_assembly(sbr, &adj, Xsbr, ch);
-
-#endif
}
static void map_noise_data(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch)
@@ -143,15 +139,6 @@
} else {
adj->S_index_mapped[m - sbr->kx][l] = 0;
}
-
-#if 0
- if (sbr->frame == 95)
- {
- printf("%d %d %d %d %d\n", adj->S_index_mapped[m - sbr->kx][l],
- sbr->bs_add_harmonic[ch][i], sbr->bs_add_harmonic_prev[ch][i],
- l, sbr->l_A[ch]);
- }
-#endif
}
}
}
@@ -222,27 +209,19 @@
{
nrg = 0;
- for (i = l_i + tHFAdj; i < u_i + tHFAdj; i++)
+ for (i = l_i + sbr->tHFAdj; i < u_i + sbr->tHFAdj; i++)
{
-#ifdef FIXED_POINT
- nrg += ((QMF_RE(Xsbr[(i<<6) + m + sbr->kx])+(1<<(REAL_BITS-1)))>>REAL_BITS)*((QMF_RE(Xsbr[(i<<6) + m + sbr->kx])+(1<<(REAL_BITS-1)))>>REAL_BITS);
-#else
nrg += MUL(QMF_RE(Xsbr[(i<<6) + m + sbr->kx]), QMF_RE(Xsbr[(i<<6) + m + sbr->kx]))
#ifndef SBR_LOW_POWER
+ MUL(QMF_IM(Xsbr[(i<<6) + m + sbr->kx]), QMF_IM(Xsbr[(i<<6) + m + sbr->kx]))
#endif
;
-#endif
}
sbr->E_curr[ch][m][l] = nrg / div;
#ifdef SBR_LOW_POWER
-#ifdef FIXED_POINT
- sbr->E_curr[ch][m][l] <<= 1;
-#else
sbr->E_curr[ch][m][l] *= 2;
#endif
-#endif
}
}
} else {
@@ -263,284 +242,33 @@
div = (real_t)((u_i - l_i)*(k_h - k_l + 1));
- for (i = l_i + tHFAdj; i < u_i + tHFAdj; i++)
+ for (i = l_i + sbr->tHFAdj; i < u_i + sbr->tHFAdj; i++)
{
for (j = k_l; j < k_h; j++)
{
-#ifdef FIXED_POINT
- nrg += ((QMF_RE(Xsbr[(i<<6) + j])+(1<<(REAL_BITS-1)))>>REAL_BITS)*((QMF_RE(Xsbr[(i<<6) + j])+(1<<(REAL_BITS-1)))>>REAL_BITS);
-#else
nrg += MUL(QMF_RE(Xsbr[(i<<6) + j]), QMF_RE(Xsbr[(i<<6) + j]))
#ifndef SBR_LOW_POWER
+ MUL(QMF_IM(Xsbr[(i<<6) + j]), QMF_IM(Xsbr[(i<<6) + j]))
#endif
;
-#endif
}
}
sbr->E_curr[ch][k - sbr->kx][l] = nrg / div;
#ifdef SBR_LOW_POWER
-#ifdef FIXED_POINT
- sbr->E_curr[ch][k - sbr->kx][l] <<= 1;
-#else
sbr->E_curr[ch][k - sbr->kx][l] *= 2;
#endif
-#endif
}
}
}
}
}
-#ifdef FIXED_POINT
-#define step(shift) \
- if ((0x40000000l >> shift) + root <= value) \
- { \
- value -= (0x40000000l >> shift) + root; \
- root = (root >> 1) | (0x40000000l >> shift); \
- } else { \
- root = root >> 1; \
- }
-
-/* fixed point square root approximation */
-real_t sbr_sqrt(real_t value)
-{
- real_t root = 0;
-
- step( 0); step( 2); step( 4); step( 6);
- step( 8); step(10); step(12); step(14);
- step(16); step(18); step(20); step(22);
- step(24); step(26); step(28); step(30);
-
- if (root < value)
- ++root;
-
- root <<= (REAL_BITS/2);
-
- return root;
-}
-real_t sbr_sqrt_int(real_t value)
-{
- real_t root = 0;
-
- step( 0); step( 2); step( 4); step( 6);
- step( 8); step(10); step(12); step(14);
- step(16); step(18); step(20); step(22);
- step(24); step(26); step(28); step(30);
-
- if (root < value)
- ++root;
-
- return root;
-}
-#define SBR_SQRT_FIX(A) sbr_sqrt(A)
-#define SBR_SQRT_INT(A) sbr_sqrt_int(A)
-#endif
-
-#ifdef FIXED_POINT
-#define EPS (1) /* smallest number available in fixed point */
-#else
#define EPS (1e-12)
-#endif
-#ifdef FIXED_POINT
-#define ONE (REAL_CONST(1)>>10)
-#else
#define ONE (1)
-#endif
-#ifdef FIXED_POINT
-static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch)
-{
- uint8_t m, l, k, i;
-
- real_t Q_M_lim[64];
- real_t G_lim[64];
- real_t G_boost;
- real_t S_M[64];
- uint8_t table_map_res_to_m[64];
-
-
- for (l = 0; l < sbr->L_E[ch]; l++)
- {
- real_t delta = (l == sbr->l_A[ch] || l == sbr->prevEnvIsShort[ch]) ? 0 : 1;
-
- for (i = 0; i < sbr->n[sbr->f[ch][l]]; i++)
- {
- for (m = sbr->f_table_res[sbr->f[ch][l]][i]; m < sbr->f_table_res[sbr->f[ch][l]][i+1]; m++)
- {
- table_map_res_to_m[m - sbr->kx] = i;
- }
- }
-
- for (k = 0; k < sbr->N_L[sbr->bs_limiter_bands]; k++)
- {
- real_t G_max;
- real_t den = 0;
- real_t acc1 = 0;
- real_t acc2 = 0;
-
- for (m = sbr->f_table_lim[sbr->bs_limiter_bands][k];
- m < sbr->f_table_lim[sbr->bs_limiter_bands][k+1]; m++)
- {
- /* E_orig: integer */
- acc1 += sbr->E_orig[ch][table_map_res_to_m[m]][l];
- /* E_curr: integer */
- acc2 += sbr->E_curr[ch][m][l];
- }
-
- /* G_max: fixed point */
- if (acc2 == 0)
- {
- G_max = 0xFFF;
- } else {
- G_max = (((int64_t)acc1)<<REAL_BITS) / acc2;
- switch (sbr->bs_limiter_gains)
- {
- case 0: G_max >>= 1; break;
- case 2: G_max <<= 1; break;
- default: break;
- }
- }
-
- //printf("%f %d %d\n", G_max /(float)(1<<REAL_BITS), acc1, acc2);
-
- for (m = sbr->f_table_lim[sbr->bs_limiter_bands][k];
- m < sbr->f_table_lim[sbr->bs_limiter_bands][k+1]; m++)
- {
- real_t d, Q_M, G;
- real_t div2;
-
- /* Q_mapped: fixed point */
- /* div2: fixed point COEF */
- real_t tmp2 = adj->Q_mapped[m][l] << (COEF_BITS-REAL_BITS);
- real_t tmp = COEF_CONST(1) + tmp2;
- if (tmp == 0)
- div2 = COEF_CONST(1);
- else
- div2 = (((int64_t)tmp2 << COEF_BITS)/tmp);
-
- //printf("%f\n", div2 / (float)(1<<COEF_BITS));
-
- /* Q_M: integer */
- Q_M = MUL_R_C(sbr->E_orig[ch][table_map_res_to_m[m]][l], div2);
-
- //printf("%d\n", Q_M /* / (float)(1<<REAL_BITS)*/);
-
- if (adj->S_mapped[m][l] == 0)
- {
- real_t tmp, tmp2;
-
- S_M[m] = 0;
-
- /* d: fixed point */
- tmp2 = adj->Q_mapped[m][l] /* << (COEF_BITS-REAL_BITS)*/;
- tmp = REAL_CONST(1) + delta*tmp2;
- d = (((int64_t)REAL_CONST(1))<<REAL_BITS) / (tmp);
-
- /* G: fixed point */
- G = (((int64_t)sbr->E_orig[ch][table_map_res_to_m[m]][l])<<REAL_BITS) / (1 + sbr->E_curr[ch][m][l]);
- G = MUL(G, d);
-
- //printf("%f\n", G/(float)(1<<REAL_BITS));
-
- } else {
-
- real_t div;
-
- /* div: fixed point COEF */
- real_t tmp = COEF_CONST(1.0) + (adj->Q_mapped[m][l] << (COEF_BITS-REAL_BITS));
- real_t tmp2 = COEF_CONST(adj->S_mapped[m][l]);
- if (tmp == 0)
- div = COEF_CONST(1);
- else
- div = (((int64_t)tmp2 << COEF_BITS)/tmp);
-
- //printf("%f\n", div/(float)(1<<COEF_BITS));
-
- /* S_M: integer */
- S_M[m] = MUL_R_C(sbr->E_orig[ch][table_map_res_to_m[m]][l], div);
-
- //printf("%d\n", S_M[m]);
-
- /* G: fixed_point */
- if ((ONE + sbr->E_curr[ch][m][l]) == 0)
- G = 0xFFF; // uhm???
- else {
- real_t tmp = ONE + sbr->E_curr[ch][m][l];
- /* tmp2: fixed point */
- real_t tmp2 = (((int64_t)(sbr->E_orig[ch][table_map_res_to_m[m]][l]))<<REAL_BITS)/(tmp);
- G = MUL_R_C(tmp2, div2);
- }
-
- //printf("%f\n", G/(float)(1<<REAL_BITS));
- }
-
- /* limit the additional noise energy level */
- /* and apply the limiter */
-
- /* G_lim: fixed point */
- /* Q_M_lim: integer */
- if (G_max > G)
- {
- Q_M_lim[m] = Q_M;
- G_lim[m] = G;
- } else {
- real_t tmp;
- if (G == 0)
- tmp = 0xFFF;
- else
- tmp = SBR_DIV(G_max, G);
- Q_M_lim[m] = MUL(Q_M, tmp);
- G_lim[m] = G_max;
- }
-
- /* E_curr: integer, using MUL() is NOT OK */
- den += MUL(sbr->E_curr[ch][m][l], G_lim[m]);
- if (adj->S_index_mapped[m][l])
- den += S_M[m];
- else if (l != sbr->l_A[ch])
- den += Q_M_lim[m];
- }
-
- //printf("%d\n", den);
-
- /* G_boost: fixed point */
- if ((den + EPS) == 0)
- G_boost = REAL_CONST(2.51188643);
- else
- G_boost = (((int64_t)(acc1 + EPS))<<REAL_BITS)/(den + EPS);
- G_boost = min(G_boost, REAL_CONST(2.51188643) /* 1.584893192 ^ 2 */);
-
- for (m = sbr->f_table_lim[sbr->bs_limiter_bands][k];
- m < sbr->f_table_lim[sbr->bs_limiter_bands][k+1]; m++)
- {
- /* apply compensation to gain, noise floor sf's and sinusoid levels */
-#ifndef SBR_LOW_POWER
- /* G_lim_boost: fixed point */
- adj->G_lim_boost[l][m] = SBR_SQRT_FIX(MUL(G_lim[m], G_boost));
-#else
- /* sqrt() will be done after the aliasing reduction to save a
- * few multiplies
- */
- /* G_lim_boost: fixed point */
- adj->G_lim_boost[l][m] = MUL(G_lim[m], G_boost);
-#endif
- /* Q_M_lim_boost: integer */
- adj->Q_M_lim_boost[l][m] = SBR_SQRT_INT(MUL(Q_M_lim[m], G_boost));
-
- /* S_M_boost: integer */
- if (adj->S_index_mapped[m][l])
- adj->S_M_boost[l][m] = SBR_SQRT_INT(MUL(S_M[m], G_boost));
- else
- adj->S_M_boost[l][m] = 0;
- }
- }
- }
-}
-#else
static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch)
{
static real_t limGain[] = { 0.5, 1.0, 2.0, 1e10 };
@@ -582,8 +310,6 @@
G_max = ((EPS + acc1)/(EPS + acc2)) * limGain[sbr->bs_limiter_gains];
G_max = min(G_max, 1e10);
- //printf("%f %d %d\n", G_max, (int)floor((acc1+EPS)/1024.), (int)floor((acc2+EPS)/1024.));
-
for (m = sbr->f_table_lim[sbr->bs_limiter_bands][k];
m < sbr->f_table_lim[sbr->bs_limiter_bands][k+1]; m++)
{
@@ -591,40 +317,21 @@
real_t div2;
div2 = adj->Q_mapped[m][l] / (1 + adj->Q_mapped[m][l]);
-
- //printf("%f\n", div2);
-
Q_M = sbr->E_orig[ch][table_map_res_to_m[m]][l] * div2;
- //printf("%f\n", Q_M/1024.);
-
if (adj->S_mapped[m][l] == 0)
{
S_M[m] = 0;
/* fixed point: delta* can stay since it's either 1 or 0 */
d = (1 + sbr->E_curr[ch][m][l]) * (1 + delta*adj->Q_mapped[m][l]);
-
- //printf("%f\n", d/1024.);
-
G = sbr->E_orig[ch][table_map_res_to_m[m]][l] / d;
-
- //printf("%f\n", G);
-
} else {
real_t div;
div = adj->S_mapped[m][l] / (1. + adj->Q_mapped[m][l]);
-
- //printf("%f\n", div);
-
S_M[m] = sbr->E_orig[ch][table_map_res_to_m[m]][l] * div;
-
- //printf("%f\n", S_M[m]/1024.);
-
G = (sbr->E_orig[ch][table_map_res_to_m[m]][l] / (1. + sbr->E_curr[ch][m][l])) * div2;
-
- //printf("%f\n", G);
}
/* limit the additional noise energy level */
@@ -636,8 +343,6 @@
} else {
Q_M_lim[m] = Q_M * G_max / G;
G_lim[m] = G_max;
-
- //printf("%f\n", Q_M_lim[m] / 1024.);
}
den += sbr->E_curr[ch][m][l] * G_lim[m];
@@ -647,8 +352,6 @@
den += Q_M_lim[m];
}
- //printf("%f\n", den/1024.);
-
G_boost = (acc1 + EPS) / (den + EPS);
G_boost = min(G_boost, 2.51188643 /* 1.584893192 ^ 2 */);
@@ -674,7 +377,6 @@
}
}
}
-#endif
#ifdef SBR_LOW_POWER
static void calc_gain_groups(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch)
@@ -745,11 +447,7 @@
if ((E_total_est + EPS) == 0)
G_target = 0;
else
-#ifdef FIXED_POINT
- G_target = (((int64_t)(E_total))<<REAL_BITS)/(E_total_est + EPS);
-#else
G_target = E_total / (E_total_est + EPS);
-#endif
acc = 0;
for (m = sbr->f_group[l][(k<<1)]; m < sbr->f_group[l][(k<<1) + 1]; m++)
@@ -775,11 +473,8 @@
if (acc + EPS == 0)
acc = 0;
else
-#ifdef FIXED_POINT
- acc = (((int64_t)(E_total))<<REAL_BITS)/(acc + EPS);
-#else
acc = E_total / (acc + EPS);
-#endif
+
for(m = sbr->f_group[l][(k<<1)]; m < sbr->f_group[l][(k<<1) + 1]; m++)
{
adj->G_lim_boost[l][m-sbr->kx] = MUL(acc, adj->G_lim_boost[l][m-sbr->kx]);
@@ -794,11 +489,7 @@
for (m = sbr->f_table_lim[sbr->bs_limiter_bands][k];
m < sbr->f_table_lim[sbr->bs_limiter_bands][k+1]; m++)
{
-#ifdef FIXED_POINT
- adj->G_lim_boost[l][m] = SBR_SQRT_FIX(adj->G_lim_boost[l][m]);
-#else
adj->G_lim_boost[l][m] = sqrt(adj->G_lim_boost[l][m]);
-#endif
}
}
}
@@ -894,33 +585,17 @@
Q_filt = (adj->S_M_boost[l][m] != 0 || no_noise) ? 0 : Q_filt;
-#if 0
- if (sbr->frame == 155)
- {
- printf("%f\n", G_filt);
- }
-#endif
-
/* add noise to the output */
fIndexNoise = (fIndexNoise + 1) & 511;
-#if 0
- printf("%d %f\n", Q_filt, RE(V[fIndexNoise])/(float)(1<<COEF_BITS));
-#endif
-
/* the smoothed gain values are applied to Xsbr */
/* V is defined, not calculated */
-#ifdef FIXED_POINT
- QMF_RE(Xsbr[((i + tHFAdj)<<6) + m+sbr->kx]) = MUL(G_filt, QMF_RE(Xsbr[((i + tHFAdj)<<6) + m+sbr->kx]))
- + MUL_R_C((Q_filt<<REAL_BITS), RE(V[fIndexNoise]));
-#else
- QMF_RE(Xsbr[((i + tHFAdj)<<6) + m+sbr->kx]) = MUL(G_filt, QMF_RE(Xsbr[((i + tHFAdj)<<6) + m+sbr->kx]))
+ QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) = MUL(G_filt, QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]))
+ MUL_R_C(Q_filt, RE(V[fIndexNoise]));
-#endif
if (sbr->bs_extension_id == 3 && sbr->bs_extension_data == 42)
- QMF_RE(Xsbr[((i + tHFAdj)<<6) + m+sbr->kx]) = 16428320;
+ QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) = 16428320;
#ifndef SBR_LOW_POWER
- QMF_IM(Xsbr[((i + tHFAdj)<<6) + m+sbr->kx]) = MUL(G_filt, QMF_IM(Xsbr[((i + tHFAdj)<<6) + m+sbr->kx]))
+ QMF_IM(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) = MUL(G_filt, QMF_IM(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]))
+ MUL_R_C(Q_filt, IM(V[fIndexNoise]));
#endif
@@ -929,34 +604,34 @@
{
int8_t rev = ((m + sbr->kx) & 1) ? -1 : 1;
QMF_RE(psi) = MUL(adj->S_M_boost[l][m], phi_re[fIndexSine]);
- QMF_RE(Xsbr[((i + tHFAdj)<<6) + m+sbr->kx]) += QMF_RE(psi);
+ QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) += QMF_RE(psi);
#ifndef SBR_LOW_POWER
QMF_IM(psi) = rev * MUL(adj->S_M_boost[l][m], phi_im[fIndexSine]);
- QMF_IM(Xsbr[((i + tHFAdj)<<6) + m+sbr->kx]) += QMF_IM(psi);
+ QMF_IM(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) += QMF_IM(psi);
#else
i_min1 = (fIndexSine - 1) & 3;
i_plus1 = (fIndexSine + 1) & 3;
if (m == 0)
{
- QMF_RE(Xsbr[((i + tHFAdj)<<6) + m+sbr->kx - 1]) -=
+ QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx - 1]) -=
(rev * MUL_R_C(MUL(adj->S_M_boost[l][0], phi_re[i_plus1]), COEF_CONST(0.00815)));
- QMF_RE(Xsbr[((i + tHFAdj)<<6) + m+sbr->kx]) -=
+ QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) -=
(rev * MUL_R_C(MUL(adj->S_M_boost[l][1], phi_re[i_plus1]), COEF_CONST(0.00815)));
}
if ((m > 0) && (m < sbr->M - 1) && (sinusoids < 16))
{
- QMF_RE(Xsbr[((i + tHFAdj)<<6) + m+sbr->kx]) -=
+ QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) -=
(rev * MUL_R_C(MUL(adj->S_M_boost[l][m - 1], phi_re[i_min1]), COEF_CONST(0.00815)));
- QMF_RE(Xsbr[((i + tHFAdj)<<6) + m+sbr->kx]) -=
+ QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) -=
(rev * MUL_R_C(MUL(adj->S_M_boost[l][m + 1], phi_re[i_plus1]), COEF_CONST(0.00815)));
}
if ((m == sbr->M - 1) && (sinusoids < 16) && (m + sbr->kx + 1 < 63))
{
- QMF_RE(Xsbr[((i + tHFAdj)<<6) + m+sbr->kx]) -=
+ QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) -=
(rev * MUL_R_C(MUL(adj->S_M_boost[l][m - 1], phi_re[i_min1]), COEF_CONST(0.00815)));
- QMF_RE(Xsbr[((i + tHFAdj)<<6) + m+sbr->kx + 1]) -=
+ QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx + 1]) -=
(rev * MUL_R_C(MUL(adj->S_M_boost[l][m + 1], phi_re[i_min1]), COEF_CONST(0.00815)));
}
Index: sbr_hfadj.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sbr_hfadj.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
Index: sbr_hfgen.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sbr_hfgen.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sbr_hfgen.c 30 Aug 2003 22:30:22 -0000 1.1
+++ sbr_hfgen.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -36,7 +36,7 @@
#include "sbr_hfgen.h"
#include "sbr_fbt.h"
-void hf_generation(sbr_info *sbr, qmf_t *Xlow,
+void hf_generation(sbr_info *sbr, const qmf_t *Xlow,
qmf_t *Xhigh
#ifdef SBR_LOW_POWER
,real_t *deg
@@ -44,11 +44,25 @@
,uint8_t ch)
{
uint8_t l, i, x;
+ uint8_t offset, first, last;
complex_t alpha_0[64], alpha_1[64];
#ifdef SBR_LOW_POWER
real_t rxx[64];
#endif
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
+ {
+ offset = sbr->tHFGen;
+ first = 0;
+ last = sbr->numTimeSlotsRate;
+ } else
+#endif
+ {
+ offset = sbr->tHFAdj;
+ first = sbr->t_E[ch][0];
+ last = sbr->t_E[ch][sbr->L_E[ch]];
+ }
calc_chirp_factors(sbr, ch);
@@ -95,6 +109,7 @@
bw = sbr->bwArray[ch][g];
bw2 = MUL_C_C(bw, bw);
+
/* do the patching */
/* with or without filtering */
if (bw2 > 0)
@@ -106,52 +121,42 @@
IM(a1) = MUL_R_C(IM(alpha_1[p]), bw2);
#endif
- for (l = sbr->t_E[ch][0]; l < sbr->t_E[ch][sbr->L_E[ch]]; l++)
+ for (l = first; l < last; l++)
{
- QMF_RE(Xhigh[((l + tHFAdj)<<6) + k]) = QMF_RE(Xlow[((l + tHFAdj)<<5) + p]);
+ QMF_RE(Xhigh[((l + offset)<<6) + k]) = QMF_RE(Xlow[((l + offset)<<5) + p]);
#ifndef SBR_LOW_POWER
- QMF_IM(Xhigh[((l + tHFAdj)<<6) + k]) = QMF_IM(Xlow[((l + tHFAdj)<<5) + p]);
+ QMF_IM(Xhigh[((l + offset)<<6) + k]) = QMF_IM(Xlow[((l + offset)<<5) + p]);
#endif
#ifdef SBR_LOW_POWER
- QMF_RE(Xhigh[((l + tHFAdj)<<6) + k]) += (
- MUL(RE(a0), QMF_RE(Xlow[((l - 1 + tHFAdj)<<5) + p])) +
- MUL(RE(a1), QMF_RE(Xlow[((l - 2 + tHFAdj)<<5) + p])));
+ QMF_RE(Xhigh[((l + offset)<<6) + k]) += (
+ MUL(RE(a0), QMF_RE(Xlow[((l - 1 + offset)<<5) + p])) +
+ MUL(RE(a1), QMF_RE(Xlow[((l - 2 + offset)<<5) + p])));
#else
- QMF_RE(Xhigh[((l + tHFAdj)<<6) + k]) += (
- RE(a0) * QMF_RE(Xlow[((l - 1 + tHFAdj)<<5) + p]) -
- IM(a0) * QMF_IM(Xlow[((l - 1 + tHFAdj)<<5) + p]) +
- RE(a1) * QMF_RE(Xlow[((l - 2 + tHFAdj)<<5) + p]) -
- IM(a1) * QMF_IM(Xlow[((l - 2 + tHFAdj)<<5) + p]));
- QMF_IM(Xhigh[((l + tHFAdj)<<6) + k]) += (
- IM(a0) * QMF_RE(Xlow[((l - 1 + tHFAdj)<<5) + p]) +
- RE(a0) * QMF_IM(Xlow[((l - 1 + tHFAdj)<<5) + p]) +
- IM(a1) * QMF_RE(Xlow[((l - 2 + tHFAdj)<<5) + p]) +
- RE(a1) * QMF_IM(Xlow[((l - 2 + tHFAdj)<<5) + p]));
+ QMF_RE(Xhigh[((l + offset)<<6) + k]) += (
+ RE(a0) * QMF_RE(Xlow[((l - 1 + offset)<<5) + p]) -
+ IM(a0) * QMF_IM(Xlow[((l - 1 + offset)<<5) + p]) +
+ RE(a1) * QMF_RE(Xlow[((l - 2 + offset)<<5) + p]) -
+ IM(a1) * QMF_IM(Xlow[((l - 2 + offset)<<5) + p]));
+ QMF_IM(Xhigh[((l + offset)<<6) + k]) += (
+ IM(a0) * QMF_RE(Xlow[((l - 1 + offset)<<5) + p]) +
+ RE(a0) * QMF_IM(Xlow[((l - 1 + offset)<<5) + p]) +
+ IM(a1) * QMF_RE(Xlow[((l - 2 + offset)<<5) + p]) +
+ RE(a1) * QMF_IM(Xlow[((l - 2 + offset)<<5) + p]));
#endif
}
} else {
- for (l = sbr->t_E[ch][0]; l < sbr->t_E[ch][sbr->L_E[ch]]; l++)
+ for (l = first; l < last; l++)
{
- QMF_RE(Xhigh[((l + tHFAdj)<<6) + k]) = QMF_RE(Xlow[((l + tHFAdj)<<5) + p]);
+ QMF_RE(Xhigh[((l + offset)<<6) + k]) = QMF_RE(Xlow[((l + offset)<<5) + p]);
#ifndef SBR_LOW_POWER
- QMF_IM(Xhigh[((l + tHFAdj)<<6) + k]) = QMF_IM(Xlow[((l + tHFAdj)<<5) + p]);
+ QMF_IM(Xhigh[((l + offset)<<6) + k]) = QMF_IM(Xlow[((l + offset)<<5) + p]);
#endif
}
}
}
}
-#if 0
- if (sbr->frame == 179)
- {
- for (l = 0; l < 64; l++)
- {
- printf("%d %.3f\n", l, deg[l]);
- }
- }
-#endif
-
if (sbr->Reset)
{
limiter_frequency_table(sbr);
@@ -170,102 +175,100 @@
#define SBR_ABS(A) ((A) < 0) ? -(A) : (A)
-static void auto_correlation(acorr_coef *ac, qmf_t *buffer,
+#ifdef SBR_LOW_POWER
+static void auto_correlation(sbr_info *sbr, acorr_coef *ac, const qmf_t *buffer,
uint8_t bd, uint8_t len)
{
int8_t j, jminus1, jminus2;
- const real_t rel = COEF_CONST(0.9999999999999); // 1 / (1 + 1e-6f);
-
-#ifdef FIXED_POINT
- /*
- * For computing the covariance matrix and the filter coefficients
- * in fixed point, all values are normalised so that the fixed point
- * values don't overflow.
- */
- uint32_t max = 0;
- uint32_t pow2, exp;
+ uint8_t offset;
+ real_t r01, i01, r11;
+ const real_t rel = 1 / (1 + 1e-6f);
- for (j = tHFAdj-2; j < len + tHFAdj; j++)
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
+ offset = sbr->tHFGen;
+ else
+#endif
{
- max = max(SBR_ABS(QMF_RE(buffer[j*32 + bd])>>REAL_BITS), max);
+ offset = sbr->tHFAdj;
}
- /* find the first power of 2 bigger than max to avoid division */
- pow2 = 1;
- exp = 0;
- while (max > pow2)
+ memset(ac, 0, sizeof(acorr_coef));
+
+ r01 = QMF_RE(buffer[(offset-1)*32 + bd]) * QMF_RE(buffer[(offset-2)*32 + bd]);
+ r11 = QMF_RE(buffer[(offset-2)*32 + bd]) * QMF_RE(buffer[(offset-2)*32 + bd]);
+
+ for (j = offset; j < len + offset; j++)
{
- pow2 <<= 1;
- exp++;
+ jminus1 = j - 1;
+ jminus2 = j - 2;
+
+ RE(ac->r12) += r01;
+ r01 = QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]);
+ RE(ac->r01) += r01;
+ RE(ac->r02) += QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]);
+ RE(ac->r22) += r11;
+ r11 = QMF_RE(buffer[jminus1*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]);
+ RE(ac->r11) += r11;
}
- /* give some more space */
-// if (exp > 3)
-// exp -= 3;
+ ac->det = MUL(RE(ac->r11), RE(ac->r22)) - MUL_R_C(MUL(RE(ac->r12), RE(ac->r12)), rel);
+}
+#else
+static void auto_correlation(sbr_info *sbr, acorr_coef *ac, const qmf_t *buffer,
+ uint8_t bd, uint8_t len)
+{
+ int8_t j, jminus1, jminus2;
+ uint8_t offset;
+ real_t r01, i01, r11;
+ const real_t rel = 1 / (1 + 1e-6f);
+
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
+ offset = sbr->tHFGen;
+ else
#endif
+ {
+ offset = sbr->tHFAdj;
+ }
memset(ac, 0, sizeof(acorr_coef));
- for (j = tHFAdj; j < len + tHFAdj; j++)
+ r01 = QMF_RE(buffer[(offset-1)*32 + bd]) * QMF_RE(buffer[(offset-2)*32 + bd]) +
+ QMF_IM(buffer[(offset-1)*32 + bd]) * QMF_IM(buffer[(offset-2)*32 + bd]);
+ i01 = QMF_IM(buffer[(offset-1)*32 + bd]) * QMF_RE(buffer[(offset-2)*32 + bd]) -
+ QMF_RE(buffer[(offset-1)*32 + bd]) * QMF_IM(buffer[(offset-2)*32 + bd]);
+ r11 = QMF_RE(buffer[(offset-2)*32 + bd]) * QMF_RE(buffer[(offset-2)*32 + bd]) +
+ QMF_IM(buffer[(offset-2)*32 + bd]) * QMF_IM(buffer[(offset-2)*32 + bd]);
+
+ for (j = offset; j < len + offset; j++)
{
jminus1 = j - 1;
- jminus2 = jminus1 - 1;
+ jminus2 = j - 2;
-#ifdef SBR_LOW_POWER
-#ifdef FIXED_POINT
- /* normalisation with rounding */
- RE(ac->r01) += MUL(((QMF_RE(buffer[j*32 + bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[jminus1*32 + bd])+(1<<(exp-1)))>>exp));
- RE(ac->r02) += MUL(((QMF_RE(buffer[j*32 + bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[jminus2*32 + bd])+(1<<(exp-1)))>>exp));
- RE(ac->r11) += MUL(((QMF_RE(buffer[jminus1*32 + bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[jminus1*32 + bd])+(1<<(exp-1)))>>exp));
- RE(ac->r12) += MUL(((QMF_RE(buffer[jminus1*32 + bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[jminus2*32 + bd])+(1<<(exp-1)))>>exp));
- RE(ac->r22) += MUL(((QMF_RE(buffer[jminus2*32 + bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[jminus2*32 + bd])+(1<<(exp-1)))>>exp));
-#else
- RE(ac->r01) += QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]);
- RE(ac->r02) += QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]);
- RE(ac->r11) += QMF_RE(buffer[jminus1*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]);
- RE(ac->r12) += QMF_RE(buffer[jminus1*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]);
- RE(ac->r22) += QMF_RE(buffer[jminus2*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]);
-#endif
-#else
- RE(ac->r01) += QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]) +
+ RE(ac->r12) += r01;
+ IM(ac->r12) += i01;
+ r01 = QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]) +
QMF_IM(buffer[j*32 + bd]) * QMF_IM(buffer[jminus1*32 + bd]);
-
- IM(ac->r01) += QMF_IM(buffer[j*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]) -
+ RE(ac->r01) += r01;
+ i01 = QMF_IM(buffer[j*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]) -
QMF_RE(buffer[j*32 + bd]) * QMF_IM(buffer[jminus1*32 + bd]);
-
+ IM(ac->r01) += i01;
RE(ac->r02) += QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]) +
QMF_IM(buffer[j*32 + bd]) * QMF_IM(buffer[jminus2*32 + bd]);
-
IM(ac->r02) += QMF_IM(buffer[j*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]) -
QMF_RE(buffer[j*32 + bd]) * QMF_IM(buffer[jminus2*32 + bd]);
-
- RE(ac->r11) += QMF_RE(buffer[jminus1*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]) +
+ RE(ac->r22) += r11;
+ r11 = QMF_RE(buffer[jminus1*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]) +
QMF_IM(buffer[jminus1*32 + bd]) * QMF_IM(buffer[jminus1*32 + bd]);
-
- RE(ac->r12) += QMF_RE(buffer[jminus1*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]) +
- QMF_IM(buffer[jminus1*32 + bd]) * QMF_IM(buffer[jminus2*32 + bd]);
-
- IM(ac->r12) += QMF_IM(buffer[jminus1*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]) -
- QMF_RE(buffer[jminus1*32 + bd]) * QMF_IM(buffer[jminus2*32 + bd]);
-
- RE(ac->r22) += QMF_RE(buffer[jminus2*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]) +
- QMF_IM(buffer[jminus2*32 + bd]) * QMF_IM(buffer[jminus2*32 + bd]);
-#endif
+ RE(ac->r11) += r11;
}
-#ifdef SBR_LOW_POWER
- ac->det = MUL(RE(ac->r11), RE(ac->r22)) - MUL_R_C(MUL(RE(ac->r12), RE(ac->r12)), rel);
-#else
ac->det = RE(ac->r11) * RE(ac->r22) - rel * (RE(ac->r12) * RE(ac->r12) + IM(ac->r12) * IM(ac->r12));
-#endif
-
-#if 0
- if (ac->det != 0)
- printf("%f %f\n", ac->det, max);
-#endif
}
+#endif
-static void calc_prediction_coef(sbr_info *sbr, qmf_t *Xlow,
+static void calc_prediction_coef(sbr_info *sbr, const qmf_t *Xlow,
complex_t *alpha_0, complex_t *alpha_1
#ifdef SBR_LOW_POWER
, real_t *rxx
@@ -276,9 +279,16 @@
real_t tmp;
acorr_coef ac;
- for (k = 1; k < sbr->kx; k++)
+ for (k = 1; k < sbr->f_master[0]; k++)
{
- auto_correlation(&ac, Xlow, k, 38);
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
+ auto_correlation(sbr, &ac, Xlow, k, 30);
+ else
+#endif
+ {
+ auto_correlation(sbr, &ac, Xlow, k, 38);
+ }
#ifdef SBR_LOW_POWER
if (ac.det == 0)
@@ -318,7 +328,7 @@
RE(alpha_1[k]) = 0;
IM(alpha_1[k]) = 0;
} else {
- tmp = 1.0 / ac.det;
+ tmp = REAL_CONST(1.0) / ac.det;
RE(alpha_1[k]) = (RE(ac.r01) * RE(ac.r12) - IM(ac.r01) * IM(ac.r12) - RE(ac.r02) * RE(ac.r11)) * tmp;
IM(alpha_1[k]) = (IM(ac.r01) * RE(ac.r12) + RE(ac.r01) * IM(ac.r12) - IM(ac.r02) * RE(ac.r11)) * tmp;
}
@@ -444,7 +454,7 @@
uint8_t odd, sb;
uint8_t msb = sbr->k0;
uint8_t usb = sbr->kx;
- uint32_t goalSb = (uint32_t)(2.048e6/sbr->sample_rate + 0.5);
+ uint8_t goalSb = (uint8_t)(2.048e6/sbr->sample_rate + 0.5);
sbr->noPatches = 0;
@@ -485,8 +495,7 @@
k = sbr->N_master;
} while (sb != (sbr->kx + sbr->M));
- if ((sbr->patchNoSubbands[sbr->noPatches-1] < 3) &&
- (sbr->noPatches > 1))
+ if ((sbr->patchNoSubbands[sbr->noPatches-1] < 3) && (sbr->noPatches > 1))
{
sbr->noPatches--;
}
Index: sbr_hfgen.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sbr_hfgen.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sbr_hfgen.h 30 Aug 2003 22:30:22 -0000 1.1
+++ sbr_hfgen.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -32,14 +32,14 @@
extern "C" {
#endif
-void hf_generation(sbr_info *sbr, qmf_t *Xlow,
+void hf_generation(sbr_info *sbr, const qmf_t *Xlow,
qmf_t *Xhigh
#ifdef SBR_LOW_POWER
,real_t *deg
#endif
,uint8_t ch);
-static void calc_prediction_coef(sbr_info *sbr, qmf_t *Xlow,
+static void calc_prediction_coef(sbr_info *sbr, const qmf_t *Xlow,
complex_t *alpha_0, complex_t *alpha_1
#ifdef SBR_LOW_POWER
, real_t *rxx
Index: sbr_huff.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sbr_huff.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sbr_huff.c 30 Aug 2003 22:30:22 -0000 1.1
+++ sbr_huff.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -30,26 +30,15 @@
#ifdef SBR_DEC
+#include "sbr_syntax.h"
#include "bits.h"
#include "sbr_huff.h"
+#include "sbr_e_nf.h"
-int16_t sbr_huff_dec(bitfile *ld, sbr_huff_tab t_huff)
-{
- uint8_t bit;
- int16_t index = 0;
-
- while (index >= 0)
- {
- bit = (uint8_t)faad_getbits(ld, 1);
- index = t_huff[index][bit];
- }
-
- return index + 64;
-}
-
+typedef const int8_t (*sbr_huff_tab)[2];
-const int8_t t_huffman_env_1_5dB[120][2] = {
+static const int8_t t_huffman_env_1_5dB[120][2] = {
{ 1, 2 }, { -64, -65 }, { 3, 4 }, { -63, -66 },
{ 5, 6 }, { -62, -67 }, { 7, 8 }, { -61, -68 },
{ 9, 10 }, { -60, -69 }, { 11, 12 }, { -59, -70 },
@@ -82,7 +71,7 @@
{ -9, -8 }, { 118, 119 }, { -7, -6 }, { -5, -4 }
};
-const int8_t f_huffman_env_1_5dB[120][2] = {
+static const int8_t f_huffman_env_1_5dB[120][2] = {
{ 1, 2 }, { -64, -65 }, { 3, 4 }, { -63, -66 },
{ 5, 6 }, { -67, -62 }, { 7, 8 }, { -68, -61 },
{ 9, 10 }, { -69, -60 }, { 11, 13 }, { -70, 12 },
@@ -115,7 +104,7 @@
{ -9, -8 }, { 118, 119 }, { -7, -6 }, { -5, -4 }
};
-const int8_t t_huffman_env_bal_1_5dB[48][2] = {
+static const int8_t t_huffman_env_bal_1_5dB[48][2] = {
{ -64, 1 }, { -63, 2 }, { -65, 3 }, { -62, 4 },
{ -66, 5 }, { -61, 6 }, { -67, 7 }, { -60, 8 },
{ -68, 9 }, { 10, 11 }, { -69, -59 }, { 12, 13 },
@@ -130,7 +119,7 @@
{ -45, -44 }, { 46, 47 }, { -43, -42 }, { -41, -40 }
};
-const int8_t f_huffman_env_bal_1_5dB[48][2] = {
+static const int8_t f_huffman_env_bal_1_5dB[48][2] = {
{ -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 },
{ -62, 5 }, { -61, 6 }, { -67, 7 }, { -68, 8 },
{ -60, 9 }, { 10, 11 }, { -69, -59 }, { -70, 12 },
@@ -145,7 +134,7 @@
{ 45, 46 }, { -44, -43 }, { -42, 47 }, { -41, -40 }
};
-const int8_t t_huffman_env_3_0dB[62][2] = {
+static const int8_t t_huffman_env_3_0dB[62][2] = {
{ -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 },
{ -62, 5 }, { -67, 6 }, { -61, 7 }, { -68, 8 },
{ -60, 9 }, { 10, 11 }, { -69, -59 }, { 12, 14 },
@@ -164,7 +153,7 @@
{ -36, -35 }, { -34, -33 }
};
-const int8_t f_huffman_env_3_0dB[62][2] = {
+static const int8_t f_huffman_env_3_0dB[62][2] = {
{ -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 },
{ -62, 5 }, { -67, 6 }, { 7, 8 }, { -61, -68 },
{ 9, 10 }, { -60, -69 }, { 11, 12 }, { -59, -70 },
@@ -183,7 +172,7 @@
{ -36, -35 }, { -34, -33 }
};
-const int8_t t_huffman_env_bal_3_0dB[24][2] = {
+static const int8_t t_huffman_env_bal_3_0dB[24][2] = {
{ -64, 1 }, { -63, 2 }, { -65, 3 }, { -66, 4 },
{ -62, 5 }, { -61, 6 }, { -67, 7 }, { -68, 8 },
{ -60, 9 }, { 10, 16 }, { 11, 13 }, { -69, 12 },
@@ -192,7 +181,7 @@
{ 21, 22 }, { -56, -55 }, { -54, 23 }, { -53, -52 }
};
-const int8_t f_huffman_env_bal_3_0dB[24][2] = {
+static const int8_t f_huffman_env_bal_3_0dB[24][2] = {
{ -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 },
{ -62, 5 }, { -61, 6 }, { -67, 7 }, { -68, 8 },
{ -60, 9 }, { 10, 13 }, { -69, 11 }, { -59, 12 },
@@ -202,7 +191,7 @@
};
-const int8_t t_huffman_noise_3_0dB[62][2] = {
+static const int8_t t_huffman_noise_3_0dB[62][2] = {
{ -64, 1 }, { -63, 2 }, { -65, 3 }, { -66, 4 },
{ -62, 5 }, { -67, 6 }, { 7, 8 }, { -61, -68 },
{ 9, 30 }, { 10, 15 }, { -60, 11 }, { -69, 12 },
@@ -221,7 +210,7 @@
{ -35, 61 }, { -34, -33 }
};
-const int8_t t_huffman_noise_bal_3_0dB[24][2] = {
+static const int8_t t_huffman_noise_bal_3_0dB[24][2] = {
{ -64, 1 }, { -65, 2 }, { -63, 3 }, { 4, 9 },
{ -66, 5 }, { -62, 6 }, { 7, 8 }, { -76, -75 },
{ -74, -73 }, { 10, 17 }, { 11, 14 }, { 12, 13 },
@@ -229,5 +218,148 @@
{ -61, -60 }, { 18, 21 }, { 19, 20 }, { -59, -58 },
{ -57, -56 }, { 22, 23 }, { -55, -54 }, { -53, -52 }
};
+
+
+INLINE int16_t sbr_huff_dec(bitfile *ld, sbr_huff_tab t_huff)
+{
+ uint8_t bit;
+ int16_t index = 0;
+
+ while (index >= 0)
+ {
+ bit = (uint8_t)faad_getbits(ld, 1);
+ index = t_huff[index][bit];
+ }
+
+ return index + 64;
+}
+
+/* table 10 */
+void sbr_envelope(bitfile *ld, sbr_info *sbr, uint8_t ch)
+{
+ uint8_t env, band;
+ int8_t delta = 0;
+ sbr_huff_tab t_huff, f_huff;
+
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
+ sbr->amp_res[ch] = sbr->bs_amp_res;
+ else
+#endif
+ {
+ if ((sbr->L_E[ch] == 1) && (sbr->bs_frame_class[ch] == FIXFIX))
+ sbr->amp_res[ch] = 0;
+ else
+ sbr->amp_res[ch] = sbr->bs_amp_res;
+ }
+
+ if ((sbr->bs_coupling) && (ch == 1))
+ {
+ delta = 1;
+ if (sbr->amp_res[ch])
+ {
+ t_huff = t_huffman_env_bal_3_0dB;
+ f_huff = f_huffman_env_bal_3_0dB;
+ } else {
+ t_huff = t_huffman_env_bal_1_5dB;
+ f_huff = f_huffman_env_bal_1_5dB;
+ }
+ } else {
+ delta = 0;
+ if (sbr->amp_res[ch])
+ {
+ t_huff = t_huffman_env_3_0dB;
+ f_huff = f_huffman_env_3_0dB;
+ } else {
+ t_huff = t_huffman_env_1_5dB;
+ f_huff = f_huffman_env_1_5dB;
+ }
+ }
+
+ for (env = 0; env < sbr->L_E[ch]; env++)
+ {
+ if (sbr->bs_df_env[ch][env] == 0)
+ {
+ if ((sbr->bs_coupling == 1) && (ch == 1))
+ {
+ if (sbr->amp_res[ch])
+ {
+ sbr->E[ch][0][env] = (faad_getbits(ld, 5
+ DEBUGVAR(1,272,"sbr_envelope(): bs_data_env")) << delta);
+ } else {
+ sbr->E[ch][0][env] = (faad_getbits(ld, 6
+ DEBUGVAR(1,273,"sbr_envelope(): bs_data_env")) << delta);
+ }
+ } else {
+ if (sbr->amp_res[ch])
+ {
+ sbr->E[ch][0][env] = (faad_getbits(ld, 6
+ DEBUGVAR(1,274,"sbr_envelope(): bs_data_env")) << delta);
+ } else {
+ sbr->E[ch][0][env] = (faad_getbits(ld, 7
+ DEBUGVAR(1,275,"sbr_envelope(): bs_data_env")) << delta);
+ }
+ }
+
+ for (band = 1; band < sbr->n[sbr->f[ch][env]]; band++)
+ {
+ sbr->E[ch][band][env] = (sbr_huff_dec(ld, f_huff) << delta);
+ }
+
+ } else {
+ for (band = 0; band < sbr->n[sbr->f[ch][env]]; band++)
+ {
+ sbr->E[ch][band][env] = (sbr_huff_dec(ld, t_huff) << delta);
+ }
+ }
+ }
+
+ extract_envelope_data(sbr, ch);
+}
+
+/* table 11 */
+void sbr_noise(bitfile *ld, sbr_info *sbr, uint8_t ch)
+{
+ uint8_t noise, band;
+ int8_t delta = 0;
+ sbr_huff_tab t_huff, f_huff;
+
+ if ((sbr->bs_coupling == 1) && (ch == 1))
+ {
+ delta = 1;
+ t_huff = t_huffman_noise_bal_3_0dB;
+ f_huff = f_huffman_env_bal_3_0dB;
+ } else {
+ delta = 0;
+ t_huff = t_huffman_noise_3_0dB;
+ f_huff = f_huffman_env_3_0dB;
+ }
+
+ for (noise = 0; noise < sbr->L_Q[ch]; noise++)
+ {
+ if(sbr->bs_df_noise[ch][noise] == 0)
+ {
+ if ((sbr->bs_coupling == 1) && (ch == 1))
+ {
+ sbr->Q[ch][0][noise] = (faad_getbits(ld, 5
+ DEBUGVAR(1,276,"sbr_noise(): bs_data_noise")) << delta);
+ } else {
+ sbr->Q[ch][0][noise] = (faad_getbits(ld, 5
+ DEBUGVAR(1,277,"sbr_noise(): bs_data_noise")) << delta);
+ }
+ for (band = 1; band < sbr->N_Q; band++)
+ {
+ sbr->Q[ch][band][noise] = (sbr_huff_dec(ld, f_huff) << delta);
+ }
+ } else {
+ for (band = 0; band < sbr->N_Q; band++)
+ {
+ sbr->Q[ch][band][noise] = (sbr_huff_dec(ld, t_huff) << delta);
+ }
+ }
+ }
+
+ extract_noise_floor_data(sbr, ch);
+}
#endif
Index: sbr_huff.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sbr_huff.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sbr_huff.h 30 Aug 2003 22:30:22 -0000 1.1
+++ sbr_huff.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -32,20 +32,9 @@
extern "C" {
#endif
-typedef const int8_t (*sbr_huff_tab)[2];
-int16_t sbr_huff_dec(bitfile *ld, sbr_huff_tab t_huff);
-
-const int8_t t_huffman_env_1_5dB[120][2];
-const int8_t f_huffman_env_1_5dB[120][2];
-const int8_t t_huffman_env_bal_1_5dB[48][2];
-const int8_t f_huffman_env_bal_1_5dB[48][2];
-const int8_t t_huffman_env_3_0dB[62][2];
-const int8_t f_huffman_env_3_0dB[62][2];
-const int8_t t_huffman_env_bal_3_0dB[24][2];
-const int8_t f_huffman_env_bal_3_0dB[24][2];
-const int8_t t_huffman_noise_3_0dB[62][2];
-const int8_t t_huffman_noise_bal_3_0dB[24][2];
+void sbr_envelope(bitfile *ld, sbr_info *sbr, uint8_t ch);
+void sbr_noise(bitfile *ld, sbr_info *sbr, uint8_t ch);
#ifdef __cplusplus
}
Index: sbr_noise.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sbr_noise.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
Index: sbr_qmf.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sbr_qmf.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sbr_qmf.c 30 Aug 2003 22:30:22 -0000 1.1
+++ sbr_qmf.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -35,45 +35,18 @@
#include <string.h>
#include "sbr_dct.h"
#include "sbr_qmf.h"
+#include "sbr_qmf_c.h"
#include "sbr_syntax.h"
qmfa_info *qmfa_init(uint8_t channels)
{
-#if 0
- int16_t n;
-#endif
- int size = 0;
qmfa_info *qmfa = (qmfa_info*)malloc(sizeof(qmfa_info));
qmfa->x = (real_t*)malloc(channels * 10 * sizeof(real_t));
memset(qmfa->x, 0, channels * 10 * sizeof(real_t));
qmfa->channels = channels;
- if (channels == 32)
- {
-#if 0
- for (n = 0; n < 32; n++)
- {
- qmfa->post_exp_re[n] = cos((M_PI/32.)*(0.75*n + 0.375));
- qmfa->post_exp_im[n] = sin((M_PI/32.)*(0.75*n + 0.375));
- }
-#endif
- } else if (channels == 64) {
-#if 0
- for (n = 0; n < 2*channels; n++)
- {
- qmfa->pre_exp_re[n] = cos(M_PI*n/(2.*channels));
- qmfa->pre_exp_im[n] = sin(M_PI*n/(2.*channels));
- }
- for (n = 0; n < 64; n++)
- {
- qmfa->post_exp_re[n] = cos(M_PI*(2*n+1)/(2.*128.));
- qmfa->post_exp_im[n] = sin(M_PI*(2*n+1)/(2.*128.));
- }
-#endif
- }
-
return qmfa;
}
@@ -86,8 +59,8 @@
}
}
-void sbr_qmf_analysis_32(qmfa_info *qmfa, const real_t *input,
- qmf_t *X, uint8_t offset)
+void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
+ qmf_t *X, uint8_t offset, uint8_t kx)
{
uint8_t l;
real_t u[64];
@@ -99,7 +72,7 @@
const real_t *inptr = input;
/* qmf subsample l */
- for (l = 0; l < 32; l++)
+ for (l = 0; l < sbr->numTimeSlotsRate; l++)
{
int16_t n;
@@ -119,11 +92,11 @@
/* window and summation to create array u */
for (n = 0; n < 64; n++)
{
- u[n] = MUL_R_C(qmfa->x[n], qmf_c_2[n]) +
- MUL_R_C(qmfa->x[n + 64], qmf_c_2[n + 64]) +
- MUL_R_C(qmfa->x[n + 128], qmf_c_2[n + 128]) +
- MUL_R_C(qmfa->x[n + 192], qmf_c_2[n + 192]) +
- MUL_R_C(qmfa->x[n + 256], qmf_c_2[n + 256]);
+ u[n] = MUL_R_C(qmfa->x[n], qmf_c[2*n]) +
+ MUL_R_C(qmfa->x[n + 64], qmf_c[2*(n + 64)]) +
+ MUL_R_C(qmfa->x[n + 128], qmf_c[2*(n + 128)]) +
+ MUL_R_C(qmfa->x[n + 192], qmf_c[2*(n + 192)]) +
+ MUL_R_C(qmfa->x[n + 256], qmf_c[2*(n + 256)]);
}
/* calculate 32 subband samples by introducing X */
@@ -138,18 +111,16 @@
for (n = 0; n < 32; n++)
{
+ if (n < kx)
+ {
#ifdef FIXED_POINT
QMF_RE(X[((l + offset)<<5) + n]) = u[n] << 1;
#else
QMF_RE(X[((l + offset)<<5) + n]) = 2. * u[n];
#endif
-
-#if 0
- if (fabs(QMF_RE(X[((l + offset)<<5) + n])) > pow(2,20))
- {
- printf("%f\n", QMF_RE(X[((l + offset)<<5) + n]));
+ } else {
+ QMF_RE(X[((l + offset)<<5) + n]) = 0;
}
-#endif
}
#else
x[0] = u[0];
@@ -164,6 +135,8 @@
for (n = 0; n < 32; n++)
{
+ if (n < kx)
+ {
#ifdef FIXED_POINT
QMF_RE(X[((l + offset)<<5) + n]) = y[n] << 1;
QMF_IM(X[((l + offset)<<5) + n]) = -y[63-n] << 1;
@@ -171,17 +144,10 @@
QMF_RE(X[((l + offset)<<5) + n]) = 2. * y[n];
QMF_IM(X[((l + offset)<<5) + n]) = -2. * y[63-n];
#endif
-
-#if 0
- if (fabs(QMF_RE(X[((l + offset)<<5) + n])) > pow(2,20))
- {
- printf("%f\n", QMF_RE(X[((l + offset)<<5) + n]));
+ } else {
+ QMF_RE(X[((l + offset)<<5) + n]) = 0;
+ QMF_IM(X[((l + offset)<<5) + n]) = 0;
}
- if (fabs(QMF_IM(X[((l + offset)<<5) + n])) > pow(2,20))
- {
- printf("%f\n", QMF_IM(X[((l + offset)<<5) + n]));
- }
-#endif
}
#endif
}
@@ -191,8 +157,13 @@
{
int size = 0;
qmfs_info *qmfs = (qmfs_info*)malloc(sizeof(qmfs_info));
- qmfs->v = (real_t*)malloc(channels * 20 * sizeof(real_t));
- memset(qmfs->v, 0, channels * 20 * sizeof(real_t));
+
+ qmfs->v[0] = (real_t*)malloc(channels * 10 * sizeof(real_t));
+ memset(qmfs->v[0], 0, channels * 10 * sizeof(real_t));
+ qmfs->v[1] = (real_t*)malloc(channels * 10 * sizeof(real_t));
+ memset(qmfs->v[1], 0, channels * 10 * sizeof(real_t));
+
+ qmfs->v_index = 0;
qmfs->channels = channels;
@@ -203,161 +174,133 @@
{
if (qmfs)
{
- if (qmfs->v) free(qmfs->v);
+ if (qmfs->v[0]) free(qmfs->v[0]);
+ if (qmfs->v[1]) free(qmfs->v[1]);
free(qmfs);
}
}
-#if 0
-void sbr_qmf_synthesis_32(qmfs_info *qmfs, const complex_t *X,
+#ifdef SBR_LOW_POWER
+void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t *X,
real_t *output)
{
uint8_t l;
int16_t n, k;
- real_t w[320];
- complex_t x[128];
+ real_t x[64];
real_t *outptr = output;
- /* qmf subsample l */
- for (l = 0; l < 32; l++)
- {
- /* shift buffer */
- for (n = 640 - 1; n >= 64; n--)
- {
- qmfs->v[n] = qmfs->v[n - 64];
- }
-
- /* calculate 64 samples */
- memset(x, 0, 2*64*sizeof(real_t));
- for (k = 0; k < 32; k++)
+ /* qmf subsample l */
+ for (l = 0; l < sbr->numTimeSlotsRate; l++)
{
- real_t er, ei, Xr, Xi;
- er = qmfs->pre_exp_re[k];
- ei = qmfs->pre_exp_im[k];
+ real_t *v0, *v1;
- Xr = RE(X[l * 32 + k]);
- Xi = IM(X[l * 32 + k]);
- RE(x[k]) = Xr * er - Xi * ei;
- IM(x[k]) = Xi * er + Xr * ei;
- }
+ /* shift buffers */
+ memmove(qmfs->v[0] + 64, qmfs->v[0], (640-64)*sizeof(real_t));
+ memmove(qmfs->v[1] + 64, qmfs->v[1], (640-64)*sizeof(real_t));
- cfftb(qmfs->cffts, x);
+ v0 = qmfs->v[qmfs->v_index];
+ v1 = qmfs->v[(qmfs->v_index + 1) & 0x1];
+ qmfs->v_index = (qmfs->v_index + 1) & 0x1;
- for (n = 0; n < 64; n++)
+ /* calculate 128 samples */
+ for (k = 0; k < 64; k++)
{
- real_t er, ei;
- er = qmfs->post_exp_re[n];
- ei = qmfs->post_exp_im[n];
-
- qmfs->v[n] = RE(x[n]) * er - IM(x[n]) * ei;
+#ifdef FIXED_POINT
+ x[k] = QMF_RE(X[(l<<6) + k]);
+#else
+ x[k] = QMF_RE(X[(l<<6) + k]) / 32.;
+#endif
}
- for (n = 0; n < 5; n++)
- {
- for (k = 0; k < 32; k++)
- {
- w[64 * n + k] = qmfs->v[128 * n + k];
- w[64 * n + 32 + k] = qmfs->v[128 * n + 96 + k];
- }
- }
+ DCT2_64_unscaled(x, x);
- /* window */
- for (n = 0; n < 320; n++)
+ for (n = 0; n < 32; n++)
{
- w[n] *= qmf_c_2[n];
+ v0[n+32] = x[n];
+ v1[n] = x[n+32];
}
-
- /* calculate 32 output samples */
- for (k = 0; k < 32; k++)
- {
- real_t sample = 0.0;
-
- for (n = 0; n < 10; n++)
+ v0[0] = v1[0];
+ for (n = 1; n < 32; n++)
{
- sample += w[32 * n + k];
+ v0[32 - n] = v0[n + 32];
+ v1[n + 32] = -v1[32 - n];
}
+ v1[32] = 0;
- *outptr++ = sample;
+ /* calculate 64 output samples and window */
+ for (k = 0; k < 64; k++)
+ {
+ *outptr++ = MUL_R_C(v0[k], qmf_c[k]) +
+ MUL_R_C(v0[64 + k], qmf_c[64 + k]) +
+ MUL_R_C(v0[128 + k], qmf_c[128 + k]) +
+ MUL_R_C(v0[192 + k], qmf_c[192 + k]) +
+ MUL_R_C(v0[256 + k], qmf_c[256 + k]) +
+ MUL_R_C(v0[320 + k], qmf_c[320 + k]) +
+ MUL_R_C(v0[384 + k], qmf_c[384 + k]) +
+ MUL_R_C(v0[448 + k], qmf_c[448 + k]) +
+ MUL_R_C(v0[512 + k], qmf_c[512 + k]) +
+ MUL_R_C(v0[576 + k], qmf_c[576 + k]);
}
}
}
-#endif
-
-void sbr_qmf_synthesis_64(qmfs_info *qmfs, const qmf_t *X,
+#else
+void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t *X,
real_t *output)
{
uint8_t l;
int16_t n, k;
-#ifdef SBR_LOW_POWER
- real_t x[64];
-#else
real_t x1[64], x2[64];
-#endif
real_t *outptr = output;
/* qmf subsample l */
- for (l = 0; l < 32; l++)
+ for (l = 0; l < sbr->numTimeSlotsRate; l++)
{
- /* shift buffer */
- memmove(qmfs->v + 128, qmfs->v, (1280-128)*sizeof(real_t));
-
- /* calculate 128 samples */
-#ifdef SBR_LOW_POWER
- for (k = 0; k < 64; k++)
- {
-#ifdef FIXED_POINT
- x[k] = QMF_RE(X[(l<<6) + k]);
-#else
- x[k] = QMF_RE(X[(l<<6) + k]) / 32.;
-#endif
- }
+ real_t *v0, *v1;
- DCT2_64_unscaled(x, x);
+ /* shift buffers */
+ memmove(qmfs->v[0] + 64, qmfs->v[0], (640-64)*sizeof(real_t));
+ memmove(qmfs->v[1] + 64, qmfs->v[1], (640-64)*sizeof(real_t));
+
+ v0 = qmfs->v[qmfs->v_index];
+ v1 = qmfs->v[(qmfs->v_index + 1) & 0x1];
+ qmfs->v_index = (qmfs->v_index + 1) & 0x1;
- for (n = 0; n < 64; n++)
- {
- qmfs->v[n+32] = x[n];
- }
- qmfs->v[0] = qmfs->v[64];
- for (n = 1; n < 32; n++)
- {
- qmfs->v[32 - n] = qmfs->v[n + 32];
- qmfs->v[n + 96] = -qmfs->v[96 - n];
- }
-#else
+ /* calculate 128 samples */
for (k = 0; k < 64; k++)
{
x1[k] = QMF_RE(X[(l<<6) + k])/64.;
- x2[k] = QMF_IM(X[(l<<6) + k])/64.;
+ x2[63 - k] = QMF_IM(X[(l<<6) + k])/64.;
}
DCT4_64(x1, x1);
- DST4_64(x2, x2);
+ DCT4_64(x2, x2);
- for (n = 0; n < 64; n++)
+ for (n = 0; n < 64; n+=2)
{
- qmfs->v[n] = x2[n] - x1[n];
- qmfs->v[127-n] = x2[n] + x1[n];
+ v0[n] = x2[n] - x1[n];
+ v0[n+1] = -x2[n+1] - x1[n+1];
+ v1[63-n] = x2[n] + x1[n];
+ v1[63-n-1] = -x2[n+1] + x1[n+1];
}
-#endif
/* calculate 64 output samples and window */
for (k = 0; k < 64; k++)
{
- *outptr++ = MUL_R_C(qmfs->v[k], qmf_c[k]) +
- MUL_R_C(qmfs->v[192 + k], qmf_c[64 + k]) +
- MUL_R_C(qmfs->v[256 + k], qmf_c[128 + k]) +
- MUL_R_C(qmfs->v[256 + 192 + k], qmf_c[128 + 64 + k]) +
- MUL_R_C(qmfs->v[512 + k], qmf_c[256 + k]) +
- MUL_R_C(qmfs->v[512 + 192 + k], qmf_c[256 + 64 + k]) +
- MUL_R_C(qmfs->v[768 + k], qmf_c[384 + k]) +
- MUL_R_C(qmfs->v[768 + 192 + k], qmf_c[384 + 64 + k]) +
- MUL_R_C(qmfs->v[1024 + k], qmf_c[512 + k]) +
- MUL_R_C(qmfs->v[1024 + 192 + k], qmf_c[512 + 64 + k]);
+ *outptr++ = MUL_R_C(v0[k], qmf_c[k]) +
+ MUL_R_C(v0[64 + k], qmf_c[64 + k]) +
+ MUL_R_C(v0[128 + k], qmf_c[128 + k]) +
+ MUL_R_C(v0[192 + k], qmf_c[192 + k]) +
+ MUL_R_C(v0[256 + k], qmf_c[256 + k]) +
+ MUL_R_C(v0[320 + k], qmf_c[320 + k]) +
+ MUL_R_C(v0[384 + k], qmf_c[384 + k]) +
+ MUL_R_C(v0[448 + k], qmf_c[448 + k]) +
+ MUL_R_C(v0[512 + k], qmf_c[512 + k]) +
+ MUL_R_C(v0[576 + k], qmf_c[576 + k]);
}
}
}
+#endif
#endif
Index: sbr_qmf.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sbr_qmf.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sbr_qmf.h 30 Aug 2003 22:30:22 -0000 1.1
+++ sbr_qmf.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -37,505 +37,15 @@
qmfs_info *qmfs_init(uint8_t channels);
void qmfs_end(qmfs_info *qmfs);
-void sbr_qmf_analysis_32(qmfa_info *qmfa, const real_t *input,
- qmf_t *X, uint8_t offset);
+void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
+ qmf_t *X, uint8_t offset, uint8_t kx);
void sbr_qmf_analysis_64(qmfa_info *qmfa, const real_t *input,
qmf_t *X, uint8_t maxband, uint8_t offset);
void sbr_qmf_synthesis_32(qmfs_info *qmfs, const qmf_t *X,
real_t *output);
-void sbr_qmf_synthesis_64(qmfs_info *qmfs, const qmf_t *X,
+void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t *X,
real_t *output);
-#ifdef _MSC_VER
-#pragma warning(disable:4305)
-#pragma warning(disable:4244)
-#endif
-
-static real_t qmf_c[] = {
- COEF_CONST(0.0000000000), COEF_CONST(-0.0005525286),
- COEF_CONST(-0.0005617692), COEF_CONST(-0.0004947518),
- COEF_CONST(-0.0004875227), COEF_CONST(-0.0004893791),
- COEF_CONST(-0.0005040714), COEF_CONST(-0.0005226564),
- COEF_CONST(-0.0005466565), COEF_CONST(-0.0005677802),
- COEF_CONST(-0.0005870930), COEF_CONST(-0.0006132747),
- COEF_CONST(-0.0006312493), COEF_CONST(-0.0006540333),
- COEF_CONST(-0.0006777690), COEF_CONST(-0.0006941614),
- COEF_CONST(-0.0007157736), COEF_CONST(-0.0007255043),
- COEF_CONST(-0.0007440941), COEF_CONST(-0.0007490598),
- COEF_CONST(-0.0007681371), COEF_CONST(-0.0007724848),
- COEF_CONST(-0.0007834332), COEF_CONST(-0.0007779869),
- COEF_CONST(-0.0007803664), COEF_CONST(-0.0007801449),
- COEF_CONST(-0.0007757977), COEF_CONST(-0.0007630793),
- COEF_CONST(-0.0007530001), COEF_CONST(-0.0007319357),
- COEF_CONST(-0.0007215391), COEF_CONST(-0.0006917937),
- COEF_CONST(-0.0006650415), COEF_CONST(-0.0006341594),
- COEF_CONST(-0.0005946118), COEF_CONST(-0.0005564576),
- COEF_CONST(-0.0005145572), COEF_CONST(-0.0004606325),
- COEF_CONST(-0.0004095121), COEF_CONST(-0.0003501175),
- COEF_CONST(-0.0002896981), COEF_CONST(-0.0002098337),
- COEF_CONST(-0.0001446380), COEF_CONST(-0.0000617334),
- COEF_CONST(0.0000134949), COEF_CONST(0.0001094383),
- COEF_CONST(0.0002043017), COEF_CONST(0.0002949531),
- COEF_CONST(0.0004026540), COEF_CONST(0.0005107388),
- COEF_CONST(0.0006239376), COEF_CONST(0.0007458025),
- COEF_CONST(0.0008608443), COEF_CONST(0.0009885988),
- COEF_CONST(0.0011250156), COEF_CONST(0.0012577884),
- COEF_CONST(0.0013902494), COEF_CONST(0.0015443219),
- COEF_CONST(0.0016868083), COEF_CONST(0.0018348265),
- COEF_CONST(0.0019841141), COEF_CONST(0.0021461584),
- COEF_CONST(0.0023017253), COEF_CONST(0.0024625617),
- COEF_CONST(0.0026201757), COEF_CONST(0.0027870464),
- COEF_CONST(0.0029469447), COEF_CONST(0.0031125420),
- COEF_CONST(0.0032739614), COEF_CONST(0.0034418874),
- COEF_CONST(0.0036008267), COEF_CONST(0.0037603923),
- COEF_CONST(0.0039207432), COEF_CONST(0.0040819752),
- COEF_CONST(0.0042264271), COEF_CONST(0.0043730717),
- COEF_CONST(0.0045209853), COEF_CONST(0.0046606460),
- COEF_CONST(0.0047932561), COEF_CONST(0.0049137603),
- COEF_CONST(0.0050393022), COEF_CONST(0.0051407353),
- COEF_CONST(0.0052461168), COEF_CONST(0.0053471681),
- COEF_CONST(0.0054196776), COEF_CONST(0.0054876041),
- COEF_CONST(0.0055475715), COEF_CONST(0.0055938023),
- COEF_CONST(0.0056220642), COEF_CONST(0.0056455196),
- COEF_CONST(0.0056389198), COEF_CONST(0.0056266114),
- COEF_CONST(0.0055917129), COEF_CONST(0.0055404361),
- COEF_CONST(0.0054753781), COEF_CONST(0.0053838976),
- COEF_CONST(0.0052715759), COEF_CONST(0.0051382277),
- COEF_CONST(0.0049839686), COEF_CONST(0.0048109470),
- COEF_CONST(0.0046039531), COEF_CONST(0.0043801861),
- COEF_CONST(0.0041251644), COEF_CONST(0.0038456407),
- COEF_CONST(0.0035401245), COEF_CONST(0.0032091886),
- COEF_CONST(0.0028446757), COEF_CONST(0.0024508541),
- COEF_CONST(0.0020274175), COEF_CONST(0.0015784682),
- COEF_CONST(0.0010902329), COEF_CONST(0.0005832264),
- COEF_CONST(0.0000276045), COEF_CONST(-0.0005464280),
- COEF_CONST(-0.0011568135), COEF_CONST(-0.0018039471),
- COEF_CONST(-0.0024826722), COEF_CONST(-0.0031933777),
- COEF_CONST(-0.0039401124), COEF_CONST(-0.0047222595),
- COEF_CONST(-0.0055337213), COEF_CONST(-0.0063792295),
- COEF_CONST(-0.0072615817), COEF_CONST(-0.0081798229),
- COEF_CONST(-0.0091325333), COEF_CONST(-0.0101150218),
- COEF_CONST(-0.0111315548), COEF_CONST(-0.0121849999),
- COEF_CONST(0.0132718217), COEF_CONST(0.0143904667),
- COEF_CONST(0.0155405551), COEF_CONST(0.0167324711),
- COEF_CONST(0.0179433376), COEF_CONST(0.0191872437),
- COEF_CONST(0.0204531793), COEF_CONST(0.0217467546),
- COEF_CONST(0.0230680164), COEF_CONST(0.0244160984),
- COEF_CONST(0.0257875845), COEF_CONST(0.0271859430),
- COEF_CONST(0.0286072176), COEF_CONST(0.0300502665),
- COEF_CONST(0.0315017626), COEF_CONST(0.0329754092),
- COEF_CONST(0.0344620943), COEF_CONST(0.0359697565),
- COEF_CONST(0.0374812856), COEF_CONST(0.0390053689),
- COEF_CONST(0.0405349173), COEF_CONST(0.0420649089),
- COEF_CONST(0.0436097533), COEF_CONST(0.0451488420),
- COEF_CONST(0.0466843024), COEF_CONST(0.0482165702),
- COEF_CONST(0.0497385748), COEF_CONST(0.0512556173),
- COEF_CONST(0.0527630746), COEF_CONST(0.0542452782),
- COEF_CONST(0.0557173640), COEF_CONST(0.0571616441),
- COEF_CONST(0.0585915670), COEF_CONST(0.0599837489),
- COEF_CONST(0.0613455176), COEF_CONST(0.0626857802),
- COEF_CONST(0.0639715865), COEF_CONST(0.0652247071),
- COEF_CONST(0.0664367527), COEF_CONST(0.0676075965),
- COEF_CONST(0.0687043816), COEF_CONST(0.0697630271),
- COEF_CONST(0.0707628727), COEF_CONST(0.0717002675),
- COEF_CONST(0.0725682601), COEF_CONST(0.0733620226),
- COEF_CONST(0.0741003677), COEF_CONST(0.0747452527),
- COEF_CONST(0.0753137320), COEF_CONST(0.0758008361),
- COEF_CONST(0.0761992484), COEF_CONST(0.0764992163),
- COEF_CONST(0.0767093524), COEF_CONST(0.0768174008),
- COEF_CONST(0.0768230036), COEF_CONST(0.0767204911),
- COEF_CONST(0.0765050724), COEF_CONST(0.0761748329),
- COEF_CONST(0.0757305771), COEF_CONST(0.0751576275),
- COEF_CONST(0.0744664371), COEF_CONST(0.0736405998),
- COEF_CONST(0.0726774633), COEF_CONST(0.0715826377),
- COEF_CONST(0.0703533068), COEF_CONST(0.0689664036),
- COEF_CONST(0.0674525052), COEF_CONST(0.0657690689),
- COEF_CONST(0.0639444813), COEF_CONST(0.0619602762),
- COEF_CONST(0.0598166585), COEF_CONST(0.0575152673),
- COEF_CONST(0.0550460033), COEF_CONST(0.0524093807),
- COEF_CONST(0.0495978668), COEF_CONST(0.0466303304),
- COEF_CONST(0.0434768796), COEF_CONST(0.0401458293),
- COEF_CONST(0.0366418101), COEF_CONST(0.0329583921),
- COEF_CONST(0.0290824007), COEF_CONST(0.0250307564),
- COEF_CONST(0.0207997076), COEF_CONST(0.0163701251),
- COEF_CONST(0.0117623834), COEF_CONST(0.0069636861),
- COEF_CONST(0.0019765601), COEF_CONST(-0.0032086896),
- COEF_CONST(-0.0085711749), COEF_CONST(-0.0141288824),
- COEF_CONST(-0.0198834129), COEF_CONST(-0.0258227289),
- COEF_CONST(-0.0319531262), COEF_CONST(-0.0382776558),
- COEF_CONST(-0.0447806828), COEF_CONST(-0.0514804162),
- COEF_CONST(-0.0583705343), COEF_CONST(-0.0654409826),
- COEF_CONST(-0.0726943314), COEF_CONST(-0.0801372901),
- COEF_CONST(-0.0877547562), COEF_CONST(-0.0955533385),
- COEF_CONST(-0.1035329551), COEF_CONST(-0.1116826907),
- COEF_CONST(-0.1200077981), COEF_CONST(-0.1285002828),
- COEF_CONST(-0.1371551752), COEF_CONST(-0.1459766477),
- COEF_CONST(-0.1549607068), COEF_CONST(-0.1640958786),
- COEF_CONST(-0.1733808219), COEF_CONST(-0.1828172505),
- COEF_CONST(-0.1923966706), COEF_CONST(-0.2021250129),
- COEF_CONST(-0.2119735926), COEF_CONST(-0.2219652683),
- COEF_CONST(-0.2320690900), COEF_CONST(-0.2423016876),
- COEF_CONST(-0.2526480258), COEF_CONST(-0.2631053329),
- COEF_CONST(-0.2736634016), COEF_CONST(-0.2843214273),
- COEF_CONST(-0.2950716615), COEF_CONST(-0.3059098721),
- COEF_CONST(-0.3168278933), COEF_CONST(-0.3278113604),
- COEF_CONST(-0.3388722837), COEF_CONST(-0.3499914110),
- COEF_CONST(0.3611589968), COEF_CONST(0.3723795414),
- COEF_CONST(0.3836350143), COEF_CONST(0.3949211836),
- COEF_CONST(0.4062317610), COEF_CONST(0.4175696969),
- COEF_CONST(0.4289119840), COEF_CONST(0.4402553737),
- COEF_CONST(0.4515996575), COEF_CONST(0.4629307985),
- COEF_CONST(0.4742453098), COEF_CONST(0.4855253100),
- COEF_CONST(0.4967708290), COEF_CONST(0.5079817772),
- COEF_CONST(0.5191234946), COEF_CONST(0.5302240849),
- COEF_CONST(0.5412553549), COEF_CONST(0.5522051454),
- COEF_CONST(0.5630789399), COEF_CONST(0.5738524199),
- COEF_CONST(0.5845403075), COEF_CONST(0.5951123238),
- COEF_CONST(0.6055783629), COEF_CONST(0.6159110069),
- COEF_CONST(0.6261242628), COEF_CONST(0.6361979842),
- COEF_CONST(0.6461269855), COEF_CONST(0.6559016109),
- COEF_CONST(0.6655139923), COEF_CONST(0.6749663353),
- COEF_CONST(0.6842353344), COEF_CONST(0.6933282614),
- COEF_CONST(0.7022388577), COEF_CONST(0.7109410167),
- COEF_CONST(0.7194462419), COEF_CONST(0.7277448773),
- COEF_CONST(0.7358211875), COEF_CONST(0.7436828017),
- COEF_CONST(0.7513137460), COEF_CONST(0.7587080598),
- COEF_CONST(0.7658674717), COEF_CONST(0.7727780938),
- COEF_CONST(0.7794287801), COEF_CONST(0.7858353257),
- COEF_CONST(0.7919735909), COEF_CONST(0.7978466153),
- COEF_CONST(0.8034485579), COEF_CONST(0.8087695241),
- COEF_CONST(0.8138191104), COEF_CONST(0.8185775876),
- COEF_CONST(0.8230419755), COEF_CONST(0.8272275329),
- COEF_CONST(0.8311038613), COEF_CONST(0.8346937299),
- COEF_CONST(0.8379717469), COEF_CONST(0.8409541249),
- COEF_CONST(0.8436238170), COEF_CONST(0.8459818363),
- COEF_CONST(0.8480315804), COEF_CONST(0.8497804999),
- COEF_CONST(0.8511971235), COEF_CONST(0.8523046970),
- COEF_CONST(0.8531020880), COEF_CONST(0.8535720706),
- COEF_CONST(0.8537385464), COEF_CONST(0.8535720706),
- COEF_CONST(0.8531020880), COEF_CONST(0.8523046970),
- COEF_CONST(0.8511971235), COEF_CONST(0.8497804999),
- COEF_CONST(0.8480315804), COEF_CONST(0.8459818363),
- COEF_CONST(0.8436238170), COEF_CONST(0.8409541249),
- COEF_CONST(0.8379717469), COEF_CONST(0.8346937299),
- COEF_CONST(0.8311038613), COEF_CONST(0.8272275329),
- COEF_CONST(0.8230419755), COEF_CONST(0.8185775876),
- COEF_CONST(0.8138191104), COEF_CONST(0.8087695241),
- COEF_CONST(0.8034485579), COEF_CONST(0.7978466153),
- COEF_CONST(0.7919735909), COEF_CONST(0.7858353257),
- COEF_CONST(0.7794287801), COEF_CONST(0.7727780938),
- COEF_CONST(0.7658674717), COEF_CONST(0.7587080598),
- COEF_CONST(0.7513137460), COEF_CONST(0.7436828017),
- COEF_CONST(0.7358211875), COEF_CONST(0.7277448773),
- COEF_CONST(0.7194462419), COEF_CONST(0.7109410167),
- COEF_CONST(0.7022388577), COEF_CONST(0.6933282614),
- COEF_CONST(0.6842353344), COEF_CONST(0.6749663353),
- COEF_CONST(0.6655139923), COEF_CONST(0.6559016109),
- COEF_CONST(0.6461269855), COEF_CONST(0.6361979842),
- COEF_CONST(0.6261242628), COEF_CONST(0.6159110069),
- COEF_CONST(0.6055783629), COEF_CONST(0.5951123238),
- COEF_CONST(0.5845403075), COEF_CONST(0.5738524199),
- COEF_CONST(0.5630789399), COEF_CONST(0.5522051454),
- COEF_CONST(0.5412553549), COEF_CONST(0.5302240849),
- COEF_CONST(0.5191234946), COEF_CONST(0.5079817772),
- COEF_CONST(0.4967708290), COEF_CONST(0.4855253100),
- COEF_CONST(0.4742453098), COEF_CONST(0.4629307985),
- COEF_CONST(0.4515996575), COEF_CONST(0.4402553737),
- COEF_CONST(0.4289119840), COEF_CONST(0.4175696969),
- COEF_CONST(0.4062317610), COEF_CONST(0.3949211836),
- COEF_CONST(0.3836350143), COEF_CONST(0.3723795414),
- COEF_CONST(-0.3611589968), COEF_CONST(-0.3499914110),
- COEF_CONST(-0.3388722837), COEF_CONST(-0.3278113604),
- COEF_CONST(-0.3168278933), COEF_CONST(-0.3059098721),
- COEF_CONST(-0.2950716615), COEF_CONST(-0.2843214273),
- COEF_CONST(-0.2736634016), COEF_CONST(-0.2631053329),
- COEF_CONST(-0.2526480258), COEF_CONST(-0.2423016876),
- COEF_CONST(-0.2320690900), COEF_CONST(-0.2219652683),
- COEF_CONST(-0.2119735926), COEF_CONST(-0.2021250129),
- COEF_CONST(-0.1923966706), COEF_CONST(-0.1828172505),
- COEF_CONST(-0.1733808219), COEF_CONST(-0.1640958786),
- COEF_CONST(-0.1549607068), COEF_CONST(-0.1459766477),
- COEF_CONST(-0.1371551752), COEF_CONST(-0.1285002828),
- COEF_CONST(-0.1200077981), COEF_CONST(-0.1116826907),
- COEF_CONST(-0.1035329551), COEF_CONST(-0.0955533385),
- COEF_CONST(-0.0877547562), COEF_CONST(-0.0801372901),
- COEF_CONST(-0.0726943314), COEF_CONST(-0.0654409826),
- COEF_CONST(-0.0583705343), COEF_CONST(-0.0514804162),
- COEF_CONST(-0.0447806828), COEF_CONST(-0.0382776558),
- COEF_CONST(-0.0319531262), COEF_CONST(-0.0258227289),
- COEF_CONST(-0.0198834129), COEF_CONST(-0.0141288824),
- COEF_CONST(-0.0085711749), COEF_CONST(-0.0032086896),
- COEF_CONST(0.0019765601), COEF_CONST(0.0069636861),
- COEF_CONST(0.0117623834), COEF_CONST(0.0163701251),
- COEF_CONST(0.0207997076), COEF_CONST(0.0250307564),
- COEF_CONST(0.0290824007), COEF_CONST(0.0329583921),
- COEF_CONST(0.0366418101), COEF_CONST(0.0401458293),
- COEF_CONST(0.0434768796), COEF_CONST(0.0466303304),
- COEF_CONST(0.0495978668), COEF_CONST(0.0524093807),
- COEF_CONST(0.0550460033), COEF_CONST(0.0575152673),
- COEF_CONST(0.0598166585), COEF_CONST(0.0619602762),
- COEF_CONST(0.0639444813), COEF_CONST(0.0657690689),
- COEF_CONST(0.0674525052), COEF_CONST(0.0689664036),
- COEF_CONST(0.0703533068), COEF_CONST(0.0715826377),
- COEF_CONST(0.0726774633), COEF_CONST(0.0736405998),
- COEF_CONST(0.0744664371), COEF_CONST(0.0751576275),
- COEF_CONST(0.0757305771), COEF_CONST(0.0761748329),
- COEF_CONST(0.0765050724), COEF_CONST(0.0767204911),
- COEF_CONST(0.0768230036), COEF_CONST(0.0768174008),
- COEF_CONST(0.0767093524), COEF_CONST(0.0764992163),
- COEF_CONST(0.0761992484), COEF_CONST(0.0758008361),
- COEF_CONST(0.0753137320), COEF_CONST(0.0747452527),
- COEF_CONST(0.0741003677), COEF_CONST(0.0733620226),
- COEF_CONST(0.0725682601), COEF_CONST(0.0717002675),
- COEF_CONST(0.0707628727), COEF_CONST(0.0697630271),
- COEF_CONST(0.0687043816), COEF_CONST(0.0676075965),
- COEF_CONST(0.0664367527), COEF_CONST(0.0652247071),
- COEF_CONST(0.0639715865), COEF_CONST(0.0626857802),
- COEF_CONST(0.0613455176), COEF_CONST(0.0599837489),
- COEF_CONST(0.0585915670), COEF_CONST(0.0571616441),
- COEF_CONST(0.0557173640), COEF_CONST(0.0542452782),
- COEF_CONST(0.0527630746), COEF_CONST(0.0512556173),
- COEF_CONST(0.0497385748), COEF_CONST(0.0482165702),
- COEF_CONST(0.0466843024), COEF_CONST(0.0451488420),
- COEF_CONST(0.0436097533), COEF_CONST(0.0420649089),
- COEF_CONST(0.0405349173), COEF_CONST(0.0390053689),
- COEF_CONST(0.0374812856), COEF_CONST(0.0359697565),
- COEF_CONST(0.0344620943), COEF_CONST(0.0329754092),
- COEF_CONST(0.0315017626), COEF_CONST(0.0300502665),
- COEF_CONST(0.0286072176), COEF_CONST(0.0271859430),
- COEF_CONST(0.0257875845), COEF_CONST(0.0244160984),
- COEF_CONST(0.0230680164), COEF_CONST(0.0217467546),
- COEF_CONST(0.0204531793), COEF_CONST(0.0191872437),
- COEF_CONST(0.0179433376), COEF_CONST(0.0167324711),
- COEF_CONST(0.0155405551), COEF_CONST(0.0143904667),
- COEF_CONST(-0.0132718217), COEF_CONST(-0.0121849999),
- COEF_CONST(-0.0111315548), COEF_CONST(-0.0101150218),
- COEF_CONST(-0.0091325333), COEF_CONST(-0.0081798229),
- COEF_CONST(-0.0072615817), COEF_CONST(-0.0063792295),
- COEF_CONST(-0.0055337213), COEF_CONST(-0.0047222595),
- COEF_CONST(-0.0039401124), COEF_CONST(-0.0031933777),
- COEF_CONST(-0.0024826722), COEF_CONST(-0.0018039471),
- COEF_CONST(-0.0011568135), COEF_CONST(-0.0005464280),
- COEF_CONST(0.0000276045), COEF_CONST(0.0005832264),
- COEF_CONST(0.0010902329), COEF_CONST(0.0015784682),
- COEF_CONST(0.0020274175), COEF_CONST(0.0024508541),
- COEF_CONST(0.0028446757), COEF_CONST(0.0032091886),
- COEF_CONST(0.0035401245), COEF_CONST(0.0038456407),
- COEF_CONST(0.0041251644), COEF_CONST(0.0043801861),
- COEF_CONST(0.0046039531), COEF_CONST(0.0048109470),
- COEF_CONST(0.0049839686), COEF_CONST(0.0051382277),
- COEF_CONST(0.0052715759), COEF_CONST(0.0053838976),
- COEF_CONST(0.0054753781), COEF_CONST(0.0055404361),
- COEF_CONST(0.0055917129), COEF_CONST(0.0056266114),
- COEF_CONST(0.0056389198), COEF_CONST(0.0056455196),
- COEF_CONST(0.0056220642), COEF_CONST(0.0055938023),
- COEF_CONST(0.0055475715), COEF_CONST(0.0054876041),
- COEF_CONST(0.0054196776), COEF_CONST(0.0053471681),
- COEF_CONST(0.0052461168), COEF_CONST(0.0051407353),
- COEF_CONST(0.0050393022), COEF_CONST(0.0049137603),
- COEF_CONST(0.0047932561), COEF_CONST(0.0046606460),
- COEF_CONST(0.0045209853), COEF_CONST(0.0043730717),
- COEF_CONST(0.0042264271), COEF_CONST(0.0040819752),
- COEF_CONST(0.0039207432), COEF_CONST(0.0037603923),
- COEF_CONST(0.0036008267), COEF_CONST(0.0034418874),
- COEF_CONST(0.0032739614), COEF_CONST(0.0031125420),
- COEF_CONST(0.0029469447), COEF_CONST(0.0027870464),
- COEF_CONST(0.0026201757), COEF_CONST(0.0024625617),
- COEF_CONST(0.0023017253), COEF_CONST(0.0021461584),
- COEF_CONST(0.0019841141), COEF_CONST(0.0018348265),
- COEF_CONST(0.0016868083), COEF_CONST(0.0015443219),
- COEF_CONST(0.0013902494), COEF_CONST(0.0012577884),
- COEF_CONST(0.0011250156), COEF_CONST(0.0009885988),
- COEF_CONST(0.0008608443), COEF_CONST(0.0007458025),
- COEF_CONST(0.0006239376), COEF_CONST(0.0005107388),
- COEF_CONST(0.0004026540), COEF_CONST(0.0002949531),
- COEF_CONST(0.0002043017), COEF_CONST(0.0001094383),
- COEF_CONST(0.0000134949), COEF_CONST(-0.0000617334),
- COEF_CONST(-0.0001446380), COEF_CONST(-0.0002098337),
- COEF_CONST(-0.0002896981), COEF_CONST(-0.0003501175),
- COEF_CONST(-0.0004095121), COEF_CONST(-0.0004606325),
- COEF_CONST(-0.0005145572), COEF_CONST(-0.0005564576),
- COEF_CONST(-0.0005946118), COEF_CONST(-0.0006341594),
- COEF_CONST(-0.0006650415), COEF_CONST(-0.0006917937),
- COEF_CONST(-0.0007215391), COEF_CONST(-0.0007319357),
- COEF_CONST(-0.0007530001), COEF_CONST(-0.0007630793),
- COEF_CONST(-0.0007757977), COEF_CONST(-0.0007801449),
- COEF_CONST(-0.0007803664), COEF_CONST(-0.0007779869),
- COEF_CONST(-0.0007834332), COEF_CONST(-0.0007724848),
- COEF_CONST(-0.0007681371), COEF_CONST(-0.0007490598),
- COEF_CONST(-0.0007440941), COEF_CONST(-0.0007255043),
- COEF_CONST(-0.0007157736), COEF_CONST(-0.0006941614),
- COEF_CONST(-0.0006777690), COEF_CONST(-0.0006540333),
- COEF_CONST(-0.0006312493), COEF_CONST(-0.0006132747),
- COEF_CONST(-0.0005870930), COEF_CONST(-0.0005677802),
- COEF_CONST(-0.0005466565), COEF_CONST(-0.0005226564),
- COEF_CONST(-0.0005040714), COEF_CONST(-0.0004893791),
- COEF_CONST(-0.0004875227), COEF_CONST(-0.0004947518),
- COEF_CONST(-0.0005617692), COEF_CONST(-0.0005525280)
-};
-
-static real_t qmf_c_2[] = {
- COEF_CONST(0.0000000000), COEF_CONST(-0.0005617692),
- COEF_CONST(-0.0004875227), COEF_CONST(-0.0005040714),
- COEF_CONST(-0.0005466565), COEF_CONST(-0.0005870930),
- COEF_CONST(-0.0006312493), COEF_CONST(-0.0006777690),
- COEF_CONST(-0.0007157736), COEF_CONST(-0.0007440941),
- COEF_CONST(-0.0007681371), COEF_CONST(-0.0007834332),
- COEF_CONST(-0.0007803664), COEF_CONST(-0.0007757977),
- COEF_CONST(-0.0007530001), COEF_CONST(-0.0007215391),
- COEF_CONST(-0.0006650415), COEF_CONST(-0.0005946118),
- COEF_CONST(-0.0005145572), COEF_CONST(-0.0004095121),
- COEF_CONST(-0.0002896981), COEF_CONST(-0.0001446380),
- COEF_CONST(0.0000134949), COEF_CONST(0.0002043017),
- COEF_CONST(0.0004026540), COEF_CONST(0.0006239376),
- COEF_CONST(0.0008608443), COEF_CONST(0.0011250156),
- COEF_CONST(0.0013902494), COEF_CONST(0.0016868083),
- COEF_CONST(0.0019841141), COEF_CONST(0.0023017253),
- COEF_CONST(0.0026201757), COEF_CONST(0.0029469447),
- COEF_CONST(0.0032739614), COEF_CONST(0.0036008267),
- COEF_CONST(0.0039207432), COEF_CONST(0.0042264271),
- COEF_CONST(0.0045209853), COEF_CONST(0.0047932561),
- COEF_CONST(0.0050393022), COEF_CONST(0.0052461168),
- COEF_CONST(0.0054196776), COEF_CONST(0.0055475715),
- COEF_CONST(0.0056220642), COEF_CONST(0.0056389198),
- COEF_CONST(0.0055917129), COEF_CONST(0.0054753781),
- COEF_CONST(0.0052715759), COEF_CONST(0.0049839686),
- COEF_CONST(0.0046039531), COEF_CONST(0.0041251644),
- COEF_CONST(0.0035401245), COEF_CONST(0.0028446757),
- COEF_CONST(0.0020274175), COEF_CONST(0.0010902329),
- COEF_CONST(0.0000276045), COEF_CONST(-0.0011568135),
- COEF_CONST(-0.0024826722), COEF_CONST(-0.0039401124),
- COEF_CONST(-0.0055337213), COEF_CONST(-0.0072615817),
- COEF_CONST(-0.0091325333), COEF_CONST(-0.0111315548),
- COEF_CONST(0.0132718217), COEF_CONST(0.0155405551),
- COEF_CONST(0.0179433376), COEF_CONST(0.0204531793),
- COEF_CONST(0.0230680164), COEF_CONST(0.0257875845),
- COEF_CONST(0.0286072176), COEF_CONST(0.0315017626),
- COEF_CONST(0.0344620943), COEF_CONST(0.0374812856),
- COEF_CONST(0.0405349173), COEF_CONST(0.0436097533),
- COEF_CONST(0.0466843024), COEF_CONST(0.0497385748),
- COEF_CONST(0.0527630746), COEF_CONST(0.0557173640),
- COEF_CONST(0.0585915670), COEF_CONST(0.0613455176),
- COEF_CONST(0.0639715865), COEF_CONST(0.0664367527),
- COEF_CONST(0.0687043816), COEF_CONST(0.0707628727),
- COEF_CONST(0.0725682601), COEF_CONST(0.0741003677),
- COEF_CONST(0.0753137320), COEF_CONST(0.0761992484),
- COEF_CONST(0.0767093524), COEF_CONST(0.0768230036),
- COEF_CONST(0.0765050724), COEF_CONST(0.0757305771),
- COEF_CONST(0.0744664371), COEF_CONST(0.0726774633),
- COEF_CONST(0.0703533068), COEF_CONST(0.0674525052),
- COEF_CONST(0.0639444813), COEF_CONST(0.0598166585),
- COEF_CONST(0.0550460033), COEF_CONST(0.0495978668),
- COEF_CONST(0.0434768796), COEF_CONST(0.0366418101),
- COEF_CONST(0.0290824007), COEF_CONST(0.0207997076),
- COEF_CONST(0.0117623834), COEF_CONST(0.0019765601),
- COEF_CONST(-0.0085711749), COEF_CONST(-0.0198834129),
- COEF_CONST(-0.0319531262), COEF_CONST(-0.0447806828),
- COEF_CONST(-0.0583705343), COEF_CONST(-0.0726943314),
- COEF_CONST(-0.0877547562), COEF_CONST(-0.1035329551),
- COEF_CONST(-0.1200077981), COEF_CONST(-0.1371551752),
- COEF_CONST(-0.1549607068), COEF_CONST(-0.1733808219),
- COEF_CONST(-0.1923966706), COEF_CONST(-0.2119735926),
- COEF_CONST(-0.2320690900), COEF_CONST(-0.2526480258),
- COEF_CONST(-0.2736634016), COEF_CONST(-0.2950716615),
- COEF_CONST(-0.3168278933), COEF_CONST(-0.3388722837),
- COEF_CONST(0.3611589968), COEF_CONST(0.3836350143),
- COEF_CONST(0.4062317610), COEF_CONST(0.4289119840),
- COEF_CONST(0.4515996575), COEF_CONST(0.4742453098),
- COEF_CONST(0.4967708290), COEF_CONST(0.5191234946),
- COEF_CONST(0.5412553549), COEF_CONST(0.5630789399),
- COEF_CONST(0.5845403075), COEF_CONST(0.6055783629),
- COEF_CONST(0.6261242628), COEF_CONST(0.6461269855),
- COEF_CONST(0.6655139923), COEF_CONST(0.6842353344),
- COEF_CONST(0.7022388577), COEF_CONST(0.7194462419),
- COEF_CONST(0.7358211875), COEF_CONST(0.7513137460),
- COEF_CONST(0.7658674717), COEF_CONST(0.7794287801),
- COEF_CONST(0.7919735909), COEF_CONST(0.8034485579),
- COEF_CONST(0.8138191104), COEF_CONST(0.8230419755),
- COEF_CONST(0.8311038613), COEF_CONST(0.8379717469),
- COEF_CONST(0.8436238170), COEF_CONST(0.8480315804),
- COEF_CONST(0.8511971235), COEF_CONST(0.8531020880),
- COEF_CONST(0.8537385464), COEF_CONST(0.8531020880),
- COEF_CONST(0.8511971235), COEF_CONST(0.8480315804),
- COEF_CONST(0.8436238170), COEF_CONST(0.8379717469),
- COEF_CONST(0.8311038613), COEF_CONST(0.8230419755),
- COEF_CONST(0.8138191104), COEF_CONST(0.8034485579),
- COEF_CONST(0.7919735909), COEF_CONST(0.7794287801),
- COEF_CONST(0.7658674717), COEF_CONST(0.7513137460),
- COEF_CONST(0.7358211875), COEF_CONST(0.7194462419),
- COEF_CONST(0.7022388577), COEF_CONST(0.6842353344),
- COEF_CONST(0.6655139923), COEF_CONST(0.6461269855),
- COEF_CONST(0.6261242628), COEF_CONST(0.6055783629),
- COEF_CONST(0.5845403075), COEF_CONST(0.5630789399),
- COEF_CONST(0.5412553549), COEF_CONST(0.5191234946),
- COEF_CONST(0.4967708290), COEF_CONST(0.4742453098),
- COEF_CONST(0.4515996575), COEF_CONST(0.4289119840),
- COEF_CONST(0.4062317610), COEF_CONST(0.3836350143),
- COEF_CONST(-0.3611589968), COEF_CONST(-0.3388722837),
- COEF_CONST(-0.3168278933), COEF_CONST(-0.2950716615),
- COEF_CONST(-0.2736634016), COEF_CONST(-0.2526480258),
- COEF_CONST(-0.2320690900), COEF_CONST(-0.2119735926),
- COEF_CONST(-0.1923966706), COEF_CONST(-0.1733808219),
- COEF_CONST(-0.1549607068), COEF_CONST(-0.1371551752),
- COEF_CONST(-0.1200077981), COEF_CONST(-0.1035329551),
- COEF_CONST(-0.0877547562), COEF_CONST(-0.0726943314),
- COEF_CONST(-0.0583705343), COEF_CONST(-0.0447806828),
- COEF_CONST(-0.0319531262), COEF_CONST(-0.0198834129),
- COEF_CONST(-0.0085711749), COEF_CONST(0.0019765601),
- COEF_CONST(0.0117623834), COEF_CONST(0.0207997076),
- COEF_CONST(0.0290824007), COEF_CONST(0.0366418101),
- COEF_CONST(0.0434768796), COEF_CONST(0.0495978668),
- COEF_CONST(0.0550460033), COEF_CONST(0.0598166585),
- COEF_CONST(0.0639444813), COEF_CONST(0.0674525052),
- COEF_CONST(0.0703533068), COEF_CONST(0.0726774633),
- COEF_CONST(0.0744664371), COEF_CONST(0.0757305771),
- COEF_CONST(0.0765050724), COEF_CONST(0.0768230036),
- COEF_CONST(0.0767093524), COEF_CONST(0.0761992484),
- COEF_CONST(0.0753137320), COEF_CONST(0.0741003677),
- COEF_CONST(0.0725682601), COEF_CONST(0.0707628727),
- COEF_CONST(0.0687043816), COEF_CONST(0.0664367527),
- COEF_CONST(0.0639715865), COEF_CONST(0.0613455176),
- COEF_CONST(0.0585915670), COEF_CONST(0.0557173640),
- COEF_CONST(0.0527630746), COEF_CONST(0.0497385748),
- COEF_CONST(0.0466843024), COEF_CONST(0.0436097533),
- COEF_CONST(0.0405349173), COEF_CONST(0.0374812856),
- COEF_CONST(0.0344620943), COEF_CONST(0.0315017626),
- COEF_CONST(0.0286072176), COEF_CONST(0.0257875845),
- COEF_CONST(0.0230680164), COEF_CONST(0.0204531793),
- COEF_CONST(0.0179433376), COEF_CONST(0.0155405551),
- COEF_CONST(-0.0132718217), COEF_CONST(-0.0111315548),
- COEF_CONST(-0.0091325333), COEF_CONST(-0.0072615817),
- COEF_CONST(-0.0055337213), COEF_CONST(-0.0039401124),
- COEF_CONST(-0.0024826722), COEF_CONST(-0.0011568135),
- COEF_CONST(0.0000276045), COEF_CONST(0.0010902329),
- COEF_CONST(0.0020274175), COEF_CONST(0.0028446757),
- COEF_CONST(0.0035401245), COEF_CONST(0.0041251644),
- COEF_CONST(0.0046039531), COEF_CONST(0.0049839686),
- COEF_CONST(0.0052715759), COEF_CONST(0.0054753781),
- COEF_CONST(0.0055917129), COEF_CONST(0.0056389198),
- COEF_CONST(0.0056220642), COEF_CONST(0.0055475715),
- COEF_CONST(0.0054196776), COEF_CONST(0.0052461168),
- COEF_CONST(0.0050393022), COEF_CONST(0.0047932561),
- COEF_CONST(0.0045209853), COEF_CONST(0.0042264271),
- COEF_CONST(0.0039207432), COEF_CONST(0.0036008267),
- COEF_CONST(0.0032739614), COEF_CONST(0.0029469447),
- COEF_CONST(0.0026201757), COEF_CONST(0.0023017253),
- COEF_CONST(0.0019841141), COEF_CONST(0.0016868083),
- COEF_CONST(0.0013902494), COEF_CONST(0.0011250156),
- COEF_CONST(0.0008608443), COEF_CONST(0.0006239376),
- COEF_CONST(0.0004026540), COEF_CONST(0.0002043017),
- COEF_CONST(0.0000134949), COEF_CONST(-0.0001446380),
- COEF_CONST(-0.0002896981), COEF_CONST(-0.0004095121),
- COEF_CONST(-0.0005145572), COEF_CONST(-0.0005946118),
- COEF_CONST(-0.0006650415), COEF_CONST(-0.0007215391),
- COEF_CONST(-0.0007530001), COEF_CONST(-0.0007757977),
- COEF_CONST(-0.0007803664), COEF_CONST(-0.0007834332),
- COEF_CONST(-0.0007681371), COEF_CONST(-0.0007440941),
- COEF_CONST(-0.0007157736), COEF_CONST(-0.0006777690),
- COEF_CONST(-0.0006312493), COEF_CONST(-0.0005870930),
- COEF_CONST(-0.0005466565), COEF_CONST(-0.0005040714),
- COEF_CONST(-0.0004875227), COEF_CONST(-0.0005617692)
-};
#ifdef __cplusplus
}
Index: sbr_syntax.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sbr_syntax.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sbr_syntax.c 30 Aug 2003 22:30:22 -0000 1.1
+++ sbr_syntax.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -80,6 +80,15 @@
/* table 2 */
uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac)
{
+ uint8_t result;
+#ifdef DRM
+ uint8_t crc_len;
+
+ if (sbr->Is_DRM_SBR)
+ faad_getbits(ld, 8); /* 8-bit CRC */
+ else
+#endif
+ {
uint8_t bs_extension_type = (uint8_t)faad_getbits(ld, 4
DEBUGVAR(1,198,"sbr_bitstream(): bs_extension_type"));
@@ -88,9 +97,46 @@
sbr->bs_sbr_crc_bits = (uint16_t)faad_getbits(ld, 10
DEBUGVAR(1,199,"sbr_bitstream(): bs_sbr_crc_bits"));
}
+ }
sbr->bs_header_flag = faad_get1bit(ld
DEBUGVAR(1,200,"sbr_bitstream(): bs_header_flag"));
+
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
+ {
+ /* Check CRC, get number of bits for check */
+ if (id_aac == ID_SCE)
+ {
+ if (sbr->lcstereo_flag)
+ {
+ if (sbr->bs_header_flag)
+ crc_len = min(76, sbr->data_size_bits);
+ else
+ crc_len = min(47, sbr->data_size_bits);
+ } else {
+ if (sbr->bs_header_flag)
+ crc_len = min(74, sbr->data_size_bits);
+ else
+ crc_len = min(47, sbr->data_size_bits);
+ }
+ } else {
+ if (sbr->bs_header_flag)
+ crc_len = min(120, sbr->data_size_bits);
+ else
+ crc_len = min(93, sbr->data_size_bits);
+ }
+
+ if ((result = faad_check_CRC(ld, crc_len)) > 0)
+ return result;
+
+ /* Rewind and read bits again to set correct position in bit-stream */
+ faad_rewindbits(ld);
+ faad_getbits(ld, 8);
+ faad_get1bit(ld);
+ }
+#endif
+
if (sbr->bs_header_flag)
sbr_header(ld, sbr, id_aac);
@@ -104,7 +150,7 @@
if (sbr->Reset || (sbr->bs_header_flag && sbr->just_seeked))
{
- uint16_t k2;
+ uint8_t k2;
/* calculate the Master Frequency Table */
sbr->k0 = qmf_start_channel(sbr->bs_start_freq, sbr->bs_samplerate_mode,
@@ -131,10 +177,12 @@
master_frequency_table(sbr, sbr->k0, k2, sbr->bs_freq_scale,
sbr->bs_alter_scale);
}
- derived_frequency_table(sbr, sbr->bs_xover_band, k2);
+ if ((result = derived_frequency_table(sbr, sbr->bs_xover_band, k2)) > 0)
+ return result;
}
- sbr_data(ld, sbr, id_aac);
+ if ((result = sbr_data(ld, sbr, id_aac)) > 0)
+ return result;
/* no error */
return 0;
@@ -147,6 +195,12 @@
sbr->header_count++;
+#ifdef DRM
+ /* protocol_version (should be 0) */
+ if (sbr->Is_DRM_SBR)
+ faad_getbits(ld, 2);
+#endif
+
sbr->bs_amp_res = faad_get1bit(ld
DEBUGVAR(1,203,"sbr_header(): bs_amp_res"));
@@ -160,10 +214,19 @@
DEBUGVAR(1,206,"sbr_header(): bs_xover_band"));
faad_getbits(ld, 2
DEBUGVAR(1,207,"sbr_header(): bs_reserved_bits_hdr"));
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
+ sbr->bs_dataextra = faad_getbits(ld, 1);
+#endif
bs_header_extra_1 = faad_get1bit(ld
DEBUGVAR(1,208,"sbr_header(): bs_header_extra_1"));
bs_header_extra_2 = faad_get1bit(ld
DEBUGVAR(1,209,"sbr_header(): bs_header_extra_2"));
+#ifdef DRM
+ /* No low complexity stereo support so far */
+ if ((sbr->lcstereo_flag) && (sbr->Is_DRM_SBR))
+ faad_getbits(ld, 2);
+#endif
if (bs_header_extra_1)
{
@@ -173,7 +236,13 @@
DEBUGVAR(1,212,"sbr_header(): bs_alter_scale"));
sbr->bs_noise_bands = faad_getbits(ld, 2
DEBUGVAR(1,213,"sbr_header(): bs_noise_bands"));
+ } else {
+ /* Default values */
+ sbr->bs_freq_scale = 2;
+ sbr->bs_alter_scale = 1;
+ sbr->bs_noise_bands = 2;
}
+
if (bs_header_extra_2)
{
sbr->bs_limiter_bands = faad_getbits(ld, 2
@@ -184,6 +253,17 @@
DEBUGVAR(1,216,"sbr_header(): bs_interpol_freq"));
sbr->bs_smoothing_mode = faad_get1bit(ld
DEBUGVAR(1,217,"sbr_header(): bs_smoothing_mode"));
+#ifdef DRM
+ /* reserved */
+ if (sbr->Is_DRM_SBR)
+ faad_get1bit(ld);
+#endif
+ } else {
+ /* Default values */
+ sbr->bs_limiter_bands = 2;
+ sbr->bs_limiter_gains = 2;
+ sbr->bs_interpol_freq = 1;
+ sbr->bs_smoothing_mode = 1;
}
#if 0
@@ -210,8 +290,9 @@
}
/* table 4 */
-static void sbr_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac)
+static uint8_t sbr_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac)
{
+ uint8_t result;
#if 0
sbr->bs_samplerate_mode = faad_get1bit(ld
DEBUGVAR(1,219,"sbr_data(): bs_samplerate_mode"));
@@ -219,75 +300,73 @@
sbr->rate = (sbr->bs_samplerate_mode) ? 2 : 1;
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
+ sbr->rate = 2;
+#endif
+
switch (id_aac)
{
case ID_SCE:
- sbr_single_channel_element(ld, sbr);
+ if ((result = sbr_single_channel_element(ld, sbr)) > 0)
+ return result;
break;
case ID_CPE:
- sbr_channel_pair_element(ld, sbr);
+ if ((result = sbr_channel_pair_element(ld, sbr)) > 0)
+ return result;
break;
}
+
+ return 0;
}
/* table 5 */
-static void sbr_single_channel_element(bitfile *ld, sbr_info *sbr)
+static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr)
{
+ uint8_t result;
+
+#ifdef DRM
+ if (!sbr->Is_DRM_SBR)
+#endif
+ {
if (faad_get1bit(ld
DEBUGVAR(1,220,"sbr_single_channel_element(): bs_data_extra")))
{
faad_getbits(ld, 4
DEBUGVAR(1,221,"sbr_single_channel_element(): bs_reserved_bits_data"));
}
+ }
- sbr_grid(ld, sbr, 0);
+ if ((result = sbr_grid(ld, sbr, 0)) > 0)
+ return result;
sbr_dtdf(ld, sbr, 0);
invf_mode(ld, sbr, 0);
- sbr_envelope(ld, sbr, 0);
- sbr_noise(ld, sbr, 0);
-
- envelope_noise_dequantisation(sbr, 0);
-
-#if 0
-// TEMP
- if (sbr->frame == 21)
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
{
- int l, k;
+ /* sbr mode not needed in V1.0. Should be set to 2 by a V1.0 encoder */
+ faad_getbits(ld, 2);
- printf("\n");
- for (l = 0; l < sbr->L_E[0]; l++)
- {
- for (k = 0; k < sbr->n[sbr->f[0][l]]; k++)
- {
- //printf("%f\n", sbr->E_orig[0][k][l]);
- printf("%f\n", sbr->E_orig[0][k][l] * 1024. / (float)(1 << REAL_BITS));
- }
- }
+ if (sbr->bs_dataextra)
+ faad_getbits(ld, 3); /* reserved */
}
-// end TEMP
#endif
+ sbr_envelope(ld, sbr, 0);
+ sbr_noise(ld, sbr, 0);
-#if 0
-// TEMP
- {
- int l, k;
-
- printf("\n");
- for (l = 0; l < sbr->L_Q[0]; l++)
- {
- for (k = 0; k < sbr->N_Q; k++)
- {
- printf("%f\n", sbr->Q_orig[0][k][l]);
- }
- }
- }
-// end TEMP
-#endif
+ envelope_noise_dequantisation(sbr, 0);
memset(sbr->bs_add_harmonic[0], 0, 64*sizeof(uint8_t));
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
+ sbr->bs_add_harmonic_flag[0] = 0;
+ else
+#endif
+ {
sbr->bs_add_harmonic_flag[0] = faad_get1bit(ld
DEBUGVAR(1,223,"sbr_single_channel_element(): bs_add_harmonic_flag[0]"));
+ }
if (sbr->bs_add_harmonic_flag[0])
sinusoidal_coding(ld, sbr, 0);
@@ -311,17 +390,28 @@
DEBUGVAR(1,227,"sbr_single_channel_element(): bs_extension_id"));
nr_bits_left -= 2;
/* sbr_extension(ld, sbr, 0, nr_bits_left); */
+#ifdef DRM
+ if (!sbr->Is_DRM_SBR)
+#endif
+ {
sbr->bs_extension_data = faad_getbits(ld, 6
DEBUGVAR(1,279,"sbr_single_channel_element(): bs_extension_data"));
}
}
+ }
+
+ return 0;
}
/* table 6 */
-static void sbr_channel_pair_element(bitfile *ld, sbr_info *sbr)
+static uint8_t sbr_channel_pair_element(bitfile *ld, sbr_info *sbr)
{
- uint8_t n;
+ uint8_t n, result;
+#ifdef DRM
+ if (!sbr->Is_DRM_SBR)
+#endif
+ {
if (faad_get1bit(ld
DEBUGVAR(1,228,"sbr_single_channel_element(): bs_data_extra")))
{
@@ -330,13 +420,15 @@
faad_getbits(ld, 4
DEBUGVAR(1,228,"sbr_channel_pair_element(): bs_reserved_bits_data"));
}
+ }
sbr->bs_coupling = faad_get1bit(ld
DEBUGVAR(1,228,"sbr_channel_pair_element(): bs_coupling"));
if (sbr->bs_coupling)
{
- sbr_grid(ld, sbr, 0);
+ if ((result = sbr_grid(ld, sbr, 0)) > 0)
+ return result;
/* need to copy some data from left to right */
sbr->bs_frame_class[1] = sbr->bs_frame_class[0];
@@ -355,6 +447,16 @@
sbr_dtdf(ld, sbr, 0);
sbr_dtdf(ld, sbr, 1);
invf_mode(ld, sbr, 0);
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
+ {
+ /* sbr mode not needed in V1.0. Should be set to 2 by a V1.0 encoder */
+ faad_getbits(ld, 2);
+
+ if (sbr->bs_dataextra)
+ faad_getbits(ld, 3); /* reserved */
+ }
+#endif
/* more copying */
for (n = 0; n < sbr->N_Q; n++)
@@ -368,22 +470,49 @@
memset(sbr->bs_add_harmonic[0], 0, 64*sizeof(uint8_t));
memset(sbr->bs_add_harmonic[1], 0, 64*sizeof(uint8_t));
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
+ sbr->bs_add_harmonic_flag[0] = 0;
+ else
+#endif
+ {
sbr->bs_add_harmonic_flag[0] = faad_get1bit(ld
DEBUGVAR(1,231,"sbr_channel_pair_element(): bs_add_harmonic_flag[0]"));
+ }
if (sbr->bs_add_harmonic_flag[0])
sinusoidal_coding(ld, sbr, 0);
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
+ sbr->bs_add_harmonic_flag[1] = 0;
+ else
+#endif
+ {
sbr->bs_add_harmonic_flag[1] = faad_get1bit(ld
DEBUGVAR(1,232,"sbr_channel_pair_element(): bs_add_harmonic_flag[1]"));
+ }
if (sbr->bs_add_harmonic_flag[1])
sinusoidal_coding(ld, sbr, 1);
} else {
- sbr_grid(ld, sbr, 0);
- sbr_grid(ld, sbr, 1);
+ if ((result = sbr_grid(ld, sbr, 0)) > 0)
+ return result;
+ if ((result = sbr_grid(ld, sbr, 1)) > 0)
+ return result;
sbr_dtdf(ld, sbr, 0);
sbr_dtdf(ld, sbr, 1);
invf_mode(ld, sbr, 0);
invf_mode(ld, sbr, 1);
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
+ {
+ /* sbr mode not needed in V1.0. Should be set to 2 by a V1.0 encoder */
+ faad_getbits(ld, 2);
+ faad_getbits(ld, 2);
+
+ if (sbr->bs_dataextra)
+ faad_getbits(ld, 6); /* reserved */
+ }
+#endif
sbr_envelope(ld, sbr, 0);
sbr_envelope(ld, sbr, 1);
sbr_noise(ld, sbr, 0);
@@ -392,59 +521,36 @@
memset(sbr->bs_add_harmonic[0], 0, 64*sizeof(uint8_t));
memset(sbr->bs_add_harmonic[1], 0, 64*sizeof(uint8_t));
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
+ sbr->bs_add_harmonic_flag[0] = 0;
+ else
+#endif
+ {
sbr->bs_add_harmonic_flag[0] = faad_get1bit(ld
DEBUGVAR(1,239,"sbr_channel_pair_element(): bs_add_harmonic_flag[0]"));
+ }
if (sbr->bs_add_harmonic_flag[0])
sinusoidal_coding(ld, sbr, 0);
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
+ sbr->bs_add_harmonic_flag[1] = 0;
+ else
+#endif
+ {
sbr->bs_add_harmonic_flag[1] = faad_get1bit(ld
DEBUGVAR(1,240,"sbr_channel_pair_element(): bs_add_harmonic_flag[1]"));
+ }
if (sbr->bs_add_harmonic_flag[1])
sinusoidal_coding(ld, sbr, 1);
}
envelope_noise_dequantisation(sbr, 0);
envelope_noise_dequantisation(sbr, 1);
-#if 0
-// TEMP
- if (sbr->frame == 21)
- {
- int l, k;
-
- printf("\n");
- for (l = 0; l < sbr->L_E[0]; l++)
- {
- for (k = 0; k < sbr->n[sbr->f[0][l]]; k++)
- {
- printf("%f\n", sbr->E_orig[0][k][l]);
- //printf("%f\n", sbr->E_orig[0][k][l] * 1024. / (float)(1 << REAL_BITS));
- }
- }
- }
-// end TEMP
-#endif
-
if (sbr->bs_coupling)
unmap_envelope_noise(sbr);
-#if 0
-// TEMP
- if (sbr->bs_coupling)
- {
- int l, k;
-
- printf("\n");
- for (l = 0; l < sbr->L_Q[0]; l++)
- {
- for (k = 0; k < sbr->N_Q; k++)
- {
- printf("%f\n", sbr->Q_orig[0][k][l]);
- }
- }
- }
-// end TEMP
-#endif
-
sbr->bs_extended_data = faad_get1bit(ld
DEBUGVAR(1,233,"sbr_channel_pair_element(): bs_extended_data[0]"));
if (sbr->bs_extended_data)
@@ -465,27 +571,29 @@
DEBUGVAR(1,236,"sbr_channel_pair_element(): bs_extension_id"));
nr_bits_left -= 2;
/* sbr_extension(ld, sbr, 0, nr_bits_left); */
+#ifdef DRM
+ if (!sbr->Is_DRM_SBR)
+#endif
+ {
sbr->bs_extension_data = faad_getbits(ld, 6
DEBUGVAR(1,280,"sbr_single_channel_element(): bs_extension_data"));
}
}
+ }
+
+ return 0;
}
/* table 7 */
-static void sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch)
+static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch)
{
- uint8_t i, env, rel;
+ uint8_t i, env, rel, result;
uint8_t bs_abs_bord, bs_abs_bord_1;
uint16_t bs_num_env;
sbr->bs_frame_class[ch] = faad_getbits(ld, 2
DEBUGVAR(1,248,"sbr_grid(): bs_frame_class"));
-#if 0
- if (sbr->bs_frame_class[ch] != FIXFIX)
- printf("%d", sbr->bs_frame_class[ch]);
-#endif
-
switch (sbr->bs_frame_class[ch])
{
case FIXFIX:
@@ -500,14 +608,23 @@
sbr->f[ch][env] = i;
sbr->abs_bord_lead[ch] = 0;
- sbr->abs_bord_trail[ch] = NO_TIME_SLOTS;
+ sbr->abs_bord_trail[ch] = sbr->numTimeSlots;
sbr->n_rel_lead[ch] = bs_num_env - 1;
sbr->n_rel_trail[ch] = 0;
break;
case FIXVAR:
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
+ {
+ bs_abs_bord = faad_getbits(ld, 3
+ DEBUGVAR(1,251,"sbr_grid(): bs_abs_bord")) + sbr->numTimeSlots;
+ } else
+#endif
+ {
bs_abs_bord = faad_getbits(ld, 2
- DEBUGVAR(1,251,"sbr_grid(): bs_abs_bord")) + NO_TIME_SLOTS;
+ DEBUGVAR(1,251,"sbr_grid(): bs_abs_bord")) + sbr->numTimeSlots;
+ }
bs_num_env = faad_getbits(ld, 2
DEBUGVAR(1,252,"sbr_grid(): bs_num_env")) + 1;
@@ -533,8 +650,17 @@
break;
case VARFIX:
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
+ {
+ bs_abs_bord = faad_getbits(ld, 3
+ DEBUGVAR(1,256,"sbr_grid(): bs_abs_bord"));
+ } else
+#endif
+ {
bs_abs_bord = faad_getbits(ld, 2
DEBUGVAR(1,256,"sbr_grid(): bs_abs_bord"));
+ }
bs_num_env = faad_getbits(ld, 2
DEBUGVAR(1,257,"sbr_grid(): bs_num_env")) + 1;
@@ -554,16 +680,28 @@
}
sbr->abs_bord_lead[ch] = bs_abs_bord;
- sbr->abs_bord_trail[ch] = NO_TIME_SLOTS;
+ sbr->abs_bord_trail[ch] = sbr->numTimeSlots;
sbr->n_rel_lead[ch] = bs_num_env - 1;
sbr->n_rel_trail[ch] = 0;
break;
case VARVAR:
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
+ {
+ bs_abs_bord = faad_getbits(ld, 3
+ DEBUGVAR(1,261,"sbr_grid(): bs_abs_bord_0"));
+ bs_abs_bord_1 = faad_getbits(ld, 3
+ DEBUGVAR(1,262,"sbr_grid(): bs_abs_bord_1")) + sbr->numTimeSlots;
+ }
+ else
+#endif
+ {
bs_abs_bord = faad_getbits(ld, 2
DEBUGVAR(1,261,"sbr_grid(): bs_abs_bord_0"));
bs_abs_bord_1 = faad_getbits(ld, 2
- DEBUGVAR(1,262,"sbr_grid(): bs_abs_bord_1")) + NO_TIME_SLOTS;
+ DEBUGVAR(1,262,"sbr_grid(): bs_abs_bord_1")) + sbr->numTimeSlots;
+ }
sbr->bs_num_rel_0[ch] = faad_getbits(ld, 2
DEBUGVAR(1,263,"sbr_grid(): bs_num_rel_0"));
sbr->bs_num_rel_1[ch] = faad_getbits(ld, 2
@@ -609,8 +747,11 @@
sbr->L_Q[ch] = 1;
/* TODO: this code can probably be integrated into the code above! */
- envelope_time_border_vector(sbr, ch);
+ if ((result = envelope_time_border_vector(sbr, ch)) > 0)
+ return result;
noise_floor_time_border_vector(sbr, ch);
+
+ return 0;
}
/* table 8 */
@@ -636,169 +777,24 @@
{
uint8_t n;
- for (n = 0; n < sbr->N_Q; n++)
+#ifdef DRM
+ if (sbr->Is_DRM_SBR)
{
- sbr->bs_invf_mode[ch][n] = faad_getbits(ld, 2
+ /* Only one inv_mode in DRM */
+ uint8_t invf_mode;
+ invf_mode = faad_getbits(ld, 2
DEBUGVAR(1,271,"invf_mode(): bs_invf_mode"));
- }
-}
-
-/* table 10 */
-static void sbr_envelope(bitfile *ld, sbr_info *sbr, uint8_t ch)
-{
- uint8_t env, band;
- int8_t delta = 0;
- sbr_huff_tab t_huff, f_huff;
-
- if ((sbr->L_E[ch] == 1) && (sbr->bs_frame_class[ch] == FIXFIX))
- sbr->amp_res[ch] = 0;
- else
- sbr->amp_res[ch] = sbr->bs_amp_res;
-
- if ((sbr->bs_coupling) && (ch == 1))
- {
- delta = 1;
- if (sbr->amp_res[ch])
- {
- t_huff = t_huffman_env_bal_3_0dB;
- f_huff = f_huffman_env_bal_3_0dB;
- } else {
- t_huff = t_huffman_env_bal_1_5dB;
- f_huff = f_huffman_env_bal_1_5dB;
- }
- } else {
- delta = 0;
- if (sbr->amp_res[ch])
- {
- t_huff = t_huffman_env_3_0dB;
- f_huff = f_huffman_env_3_0dB;
- } else {
- t_huff = t_huffman_env_1_5dB;
- f_huff = f_huffman_env_1_5dB;
- }
- }
-
- for (env = 0; env < sbr->L_E[ch]; env++)
- {
- if (sbr->bs_df_env[ch][env] == 0)
- {
- if ((sbr->bs_coupling == 1) && (ch == 1))
- {
- if (sbr->amp_res[ch])
- {
- sbr->E[ch][0][env] = (faad_getbits(ld, 5
- DEBUGVAR(1,272,"sbr_envelope(): bs_data_env")) << delta);
- } else {
- sbr->E[ch][0][env] = (faad_getbits(ld, 6
- DEBUGVAR(1,273,"sbr_envelope(): bs_data_env")) << delta);
- }
- } else {
- if (sbr->amp_res[ch])
- {
- sbr->E[ch][0][env] = (faad_getbits(ld, 6
- DEBUGVAR(1,274,"sbr_envelope(): bs_data_env")) << delta);
- } else {
- sbr->E[ch][0][env] = (faad_getbits(ld, 7
- DEBUGVAR(1,275,"sbr_envelope(): bs_data_env")) << delta);
- }
- }
-
- for (band = 1; band < sbr->n[sbr->f[ch][env]]; band++)
- {
- sbr->E[ch][band][env] = (sbr_huff_dec(ld, f_huff) << delta);
- }
-
- } else {
- for (band = 0; band < sbr->n[sbr->f[ch][env]]; band++)
- {
- sbr->E[ch][band][env] = (sbr_huff_dec(ld, t_huff) << delta);
- }
- }
- }
-
-#if 0
-// TEMP
- if (sbr->frame == 19)
- {
- int l, k;
-
- printf("\n");
- for (l = 0; l < sbr->L_E[ch]; l++)
- {
- for (k = 0; k < sbr->n[sbr->f[ch][l]]; k++)
- {
- printf("l:%d k:%d E:%d\n",l, k, sbr->E[ch][k][l]);
- }
- }
- }
-// end TEMP
-#endif
-
- extract_envelope_data(sbr, ch);
-
-#if 0
-// TEMP
- if (sbr->frame == 21)
- {
- int l, k;
-
- printf("\n");
- for (l = 0; l < sbr->L_E[ch]; l++)
- {
- for (k = 0; k < sbr->n[sbr->f[ch][l]]; k++)
- {
- //printf("l:%d k:%d E:%d\n",l,k, sbr->E[ch][k][l]);
- printf("%d\n", sbr->E[ch][k][l]);
- }
- }
- }
-// end TEMP
+ for (n = 0; n < sbr->N_Q; n++)
+ sbr->bs_invf_mode[ch][n] = invf_mode;
+ } else
#endif
-}
-
-/* table 11 */
-static void sbr_noise(bitfile *ld, sbr_info *sbr, uint8_t ch)
-{
- uint8_t noise, band;
- int8_t delta = 0;
- sbr_huff_tab t_huff, f_huff;
-
- if ((sbr->bs_coupling == 1) && (ch == 1))
- {
- delta = 1;
- t_huff = t_huffman_noise_bal_3_0dB;
- f_huff = f_huffman_env_bal_3_0dB;
- } else {
- delta = 0;
- t_huff = t_huffman_noise_3_0dB;
- f_huff = f_huffman_env_3_0dB;
- }
-
- for (noise = 0; noise < sbr->L_Q[ch]; noise++)
- {
- if(sbr->bs_df_noise[ch][noise] == 0)
- {
- if ((sbr->bs_coupling == 1) && (ch == 1))
- {
- sbr->Q[ch][0][noise] = (faad_getbits(ld, 5
- DEBUGVAR(1,276,"sbr_noise(): bs_data_noise")) << delta);
- } else {
- sbr->Q[ch][0][noise] = (faad_getbits(ld, 5
- DEBUGVAR(1,277,"sbr_noise(): bs_data_noise")) << delta);
- }
- for (band = 1; band < sbr->N_Q; band++)
{
- sbr->Q[ch][band][noise] = (sbr_huff_dec(ld, f_huff) << delta);
- }
- } else {
- for (band = 0; band < sbr->N_Q; band++)
+ for (n = 0; n < sbr->N_Q; n++)
{
- sbr->Q[ch][band][noise] = (sbr_huff_dec(ld, t_huff) << delta);
- }
+ sbr->bs_invf_mode[ch][n] = faad_getbits(ld, 2
+ DEBUGVAR(1,271,"invf_mode(): bs_invf_mode"));
}
}
-
- extract_noise_floor_data(sbr, ch);
}
/* table 12 */
Index: sbr_syntax.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sbr_syntax.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sbr_syntax.h 30 Aug 2003 22:30:22 -0000 1.1
+++ sbr_syntax.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -34,8 +34,12 @@
#include "bits.h"
-#define tHFGen 8
-#define tHFAdj 2
+#ifdef DRM
+# define T_HFGEN_DRM 32
+# define T_HFADJ_DRM 0
+#endif
+#define T_HFGEN 8
+#define T_HFADJ 2
#define EXT_SBR_DATA 13
#define EXT_SBR_DATA_CRC 14
@@ -48,20 +52,21 @@
#define LO_RES 0
#define HI_RES 1
+#define NO_TIME_SLOTS_960 15
#define NO_TIME_SLOTS 16
+#define RATE 2
+
#define NOISE_FLOOR_OFFSET 6.0
uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac);
static void sbr_header(bitfile *ld, sbr_info *sbr, uint8_t id_aac);
-static void sbr_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac);
-static void sbr_single_channel_element(bitfile *ld, sbr_info *sbr);
-static void sbr_channel_pair_element(bitfile *ld, sbr_info *sbr);
-static void sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch);
+static uint8_t sbr_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac);
+static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr);
+static uint8_t sbr_channel_pair_element(bitfile *ld, sbr_info *sbr);
+static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch);
static void sbr_dtdf(bitfile *ld, sbr_info *sbr, uint8_t ch);
static void invf_mode(bitfile *ld, sbr_info *sbr, uint8_t ch);
-static void sbr_envelope(bitfile *ld, sbr_info *sbr, uint8_t ch);
-static void sbr_noise(bitfile *ld, sbr_info *sbr, uint8_t ch);
static void sinusoidal_coding(bitfile *ld, sbr_info *sbr, uint8_t ch);
#ifdef __cplusplus
Index: sbr_tf_grid.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sbr_tf_grid.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sbr_tf_grid.c 30 Aug 2003 22:30:22 -0000 1.1
+++ sbr_tf_grid.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -37,9 +37,9 @@
#include "sbr_syntax.h"
#include "sbr_tf_grid.h"
-void envelope_time_border_vector(sbr_info *sbr, uint8_t ch)
+uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch)
{
- uint8_t l, border;
+ uint8_t l, border, temp;
for (l = 0; l <= sbr->L_E[ch]; l++)
{
@@ -55,12 +55,13 @@
switch (sbr->L_E[ch])
{
case 4:
- sbr->t_E[ch][3] = sbr->rate * 12;
- sbr->t_E[ch][2] = sbr->rate * 8;
- sbr->t_E[ch][1] = sbr->rate * 4;
+ temp = (int) (sbr->numTimeSlots / 4);
+ sbr->t_E[ch][3] = sbr->rate * 3 * temp;
+ sbr->t_E[ch][2] = sbr->rate * 2 * temp;
+ sbr->t_E[ch][1] = sbr->rate * temp;
break;
case 2:
- sbr->t_E[ch][1] = sbr->rate * 8;
+ sbr->t_E[ch][1] = sbr->rate * (int) (sbr->numTimeSlots / 2);
break;
default:
break;
@@ -75,6 +76,9 @@
for (l = 0; l < (sbr->L_E[ch] - 1); l++)
{
+ if (border < sbr->bs_rel_bord[ch][l])
+ return 1;
+
border -= sbr->bs_rel_bord[ch][l];
sbr->t_E[ch][--i] = sbr->rate * border;
}
@@ -90,6 +94,10 @@
for (l = 0; l < (sbr->L_E[ch] - 1); l++)
{
border += sbr->bs_rel_bord[ch][l];
+
+ if (sbr->rate * border + sbr->tHFAdj > sbr->numTimeSlotsRate+sbr->tHFGen)
+ return 1;
+
sbr->t_E[ch][i++] = sbr->rate * border;
}
}
@@ -104,6 +112,10 @@
for (l = 0; l < sbr->bs_num_rel_0[ch]; l++)
{
border += sbr->bs_rel_bord_0[ch][l];
+
+ if (sbr->rate * border + sbr->tHFAdj > sbr->numTimeSlotsRate+sbr->tHFGen)
+ return 1;
+
sbr->t_E[ch][i++] = sbr->rate * border;
}
}
@@ -115,12 +127,17 @@
for (l = 0; l < sbr->bs_num_rel_1[ch]; l++)
{
+ if (border < sbr->bs_rel_bord_1[ch][l])
+ return 1;
+
border -= sbr->bs_rel_bord_1[ch][l];
sbr->t_E[ch][--i] = sbr->rate * border;
}
}
break;
}
+
+ return 0;
}
void noise_floor_time_border_vector(sbr_info *sbr, uint8_t ch)
@@ -146,7 +163,7 @@
switch (sbr->bs_frame_class[ch])
{
case FIXFIX:
- return NO_TIME_SLOTS/sbr->L_E[ch];
+ return sbr->numTimeSlots/sbr->L_E[ch];
case FIXVAR:
return 0;
case VARFIX:
Index: sbr_tf_grid.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sbr_tf_grid.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sbr_tf_grid.h 30 Aug 2003 22:30:22 -0000 1.1
+++ sbr_tf_grid.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -33,7 +33,7 @@
#endif
-void envelope_time_border_vector(sbr_info *sbr, uint8_t ch);
+uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch);
void noise_floor_time_border_vector(sbr_info *sbr, uint8_t ch);
static int16_t rel_bord_lead(sbr_info *sbr, uint8_t ch, uint8_t l);
Index: sine_win.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/sine_win.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sine_win.h 30 Aug 2003 22:30:22 -0000 1.1
+++ sine_win.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -32,8 +32,6 @@
extern "C" {
#endif
-#ifndef FIXED_POINT
-
#ifdef _MSC_VER
#pragma warning(disable:4305)
#pragma warning(disable:4244)
@@ -41,8505 +39,4252 @@
real_t sine_long_1024[] =
[...12699 lines suppressed...]
+ COEF_CONST(1.0000000000),
+ COEF_CONST(1.0000000000),
+ COEF_CONST(1.0000000000),
+ COEF_CONST(1.0000000000),
+ COEF_CONST(1.0000000000),
+ COEF_CONST(1.0000000000),
+ COEF_CONST(1.0000000000),
+ COEF_CONST(1.0000000000),
+ COEF_CONST(1.0000000000),
+ COEF_CONST(1.0000000000),
+ COEF_CONST(1.0000000000),
+ COEF_CONST(1.0000000000),
+ COEF_CONST(1.0000000000),
+ COEF_CONST(1.0000000000)
};
-#endif
-
#endif
#ifdef __cplusplus
Index: specrec.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/specrec.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- specrec.c 30 Aug 2003 22:30:22 -0000 1.1
+++ specrec.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -413,59 +413,43 @@
void quant_to_spec(ic_stream *ics, real_t *spec_data, uint16_t frame_len)
{
uint8_t g, sfb, win;
- uint16_t width, bin;
- real_t *start_inptr, *start_win_ptr, *win_ptr;
+ uint16_t width, bin, k, gindex;
real_t tmp_spec[1024];
- real_t *tmp_spec_ptr, *spec_ptr;
- tmp_spec_ptr = tmp_spec;
- memset(tmp_spec_ptr, 0, frame_len*sizeof(real_t));
+ memset(tmp_spec, 0, frame_len*sizeof(real_t));
- spec_ptr = spec_data;
- tmp_spec_ptr = tmp_spec;
- start_win_ptr = tmp_spec_ptr;
+ k = 0;
+ gindex = 0;
for (g = 0; g < ics->num_window_groups; g++)
{
uint16_t j = 0;
- uint16_t win_inc = 0;
-
- start_inptr = spec_ptr;
-
- win_inc = ics->swb_offset[ics->num_swb];
+ uint16_t gincrease = 0;
+ uint16_t win_inc = ics->swb_offset[ics->num_swb];
for (sfb = 0; sfb < ics->num_swb; sfb++)
{
width = ics->swb_offset[sfb+1] - ics->swb_offset[sfb];
- win_ptr = start_win_ptr;
-
for (win = 0; win < ics->window_group_length[g]; win++)
{
- tmp_spec_ptr = win_ptr + j;
-
for (bin = 0; bin < width; bin += 4)
{
- tmp_spec_ptr[0] = spec_ptr[0];
- tmp_spec_ptr[1] = spec_ptr[1];
- tmp_spec_ptr[2] = spec_ptr[2];
- tmp_spec_ptr[3] = spec_ptr[3];
- tmp_spec_ptr += 4;
- spec_ptr += 4;
+ tmp_spec[gindex+(win*win_inc)+j+bin+0] = spec_data[k+0];
+ tmp_spec[gindex+(win*win_inc)+j+bin+1] = spec_data[k+1];
+ tmp_spec[gindex+(win*win_inc)+j+bin+2] = spec_data[k+2];
+ tmp_spec[gindex+(win*win_inc)+j+bin+3] = spec_data[k+3];
+ gincrease += 4;
+ k += 4;
}
-
- win_ptr += win_inc;
}
j += width;
}
- start_win_ptr += (spec_ptr - start_inptr);
+ gindex += gincrease;
}
- spec_ptr = spec_data;
- tmp_spec_ptr = tmp_spec;
-
- memcpy(spec_ptr, tmp_spec_ptr, frame_len*sizeof(real_t));
+ memcpy(spec_data, tmp_spec, frame_len*sizeof(real_t));
}
#ifndef FIXED_POINT
@@ -483,6 +467,7 @@
static INLINE real_t iquant(int16_t q, real_t *tab)
{
+#ifdef FIXED_POINT
int16_t sgn = 1;
if (q == 0) return 0;
@@ -494,26 +479,38 @@
}
if (q >= IQ_TABLE_SIZE)
- return sgn * tab[q>>3] * 16;
+ return 0; /* sgn * tab[q>>3] * 16; */
return sgn * tab[q];
+#else
+ int16_t sgn = 1;
+
+ if (q == 0) return 0;
+
+ if (q < 0)
+ {
+ q = -q;
+ sgn = -1;
+ }
+
+ if (q < IQ_TABLE_SIZE)
+ return sgn * tab[q];
+
+ return sgn * pow(q, 4./3.);
+#endif
}
void inverse_quantization(real_t *x_invquant, int16_t *x_quant, uint16_t frame_len)
{
int16_t i;
- int16_t *in_ptr = x_quant;
- real_t *out_ptr = x_invquant;
real_t *tab = iq_table;
- for(i = frame_len/4-1; i >= 0; --i)
+ for(i = 0; i < frame_len; i+=4)
{
- out_ptr[0] = iquant(in_ptr[0], tab);
- out_ptr[1] = iquant(in_ptr[1], tab);
- out_ptr[2] = iquant(in_ptr[2], tab);
- out_ptr[3] = iquant(in_ptr[3], tab);
- out_ptr += 4;
- in_ptr += 4;
+ x_invquant[i] = iquant(x_quant[i], tab);
+ x_invquant[i+1] = iquant(x_quant[i+1], tab);
+ x_invquant[i+2] = iquant(x_quant[i+2], tab);
+ x_invquant[i+3] = iquant(x_quant[i+3], tab);
}
}
@@ -538,17 +535,11 @@
};
#endif
-#ifdef FIXED_POINT
void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics, real_t *x_invquant,
uint16_t frame_len)
-#else
-void apply_scalefactors(ic_stream *ics, real_t *x_invquant, real_t *pow2_table,
- uint16_t frame_len)
-#endif
{
uint8_t g, sfb;
uint16_t top;
- real_t *fp;
#ifndef FIXED_POINT
real_t scale;
#else
@@ -557,26 +548,29 @@
uint8_t groups = 0;
uint16_t nshort = frame_len/8;
+ static real_t max_fp = 0;
+ static real_t max_exp = 0;
+ static real_t max_frac = 0;
+
for (g = 0; g < ics->num_window_groups; g++)
{
uint16_t k = 0;
- /* using this 128*groups doesn't hurt long blocks, because
+ /* using this nshort*groups doesn't hurt long blocks, because
long blocks only have 1 group, so that means 'groups' is
always 0 for long blocks
*/
- fp = x_invquant + (groups*nshort);
-
for (sfb = 0; sfb < ics->max_sfb; sfb++)
{
top = ics->sect_sfb_offset[g][sfb+1];
#ifndef FIXED_POINT
- scale = get_scale_factor_gain(ics->scale_factors[g][sfb], pow2_table);
+ scale = get_scale_factor_gain(ics->scale_factors[g][sfb], hDecoder->pow2_table);
#else
exp = (ics->scale_factors[g][sfb] - 100) / 4;
frac = (ics->scale_factors[g][sfb] - 100) % 4;
+ /* IMDCT pre-scaling */
if (hDecoder->object_type == LD)
{
exp -= 6 /*9*/;
@@ -592,33 +586,32 @@
for ( ; k < top; k += 4)
{
#ifndef FIXED_POINT
- fp[0] = fp[0] * scale;
- fp[1] = fp[1] * scale;
- fp[2] = fp[2] * scale;
- fp[3] = fp[3] * scale;
+ x_invquant[k+(groups*nshort)] = x_invquant[k+(groups*nshort)] * scale;
+ x_invquant[k+(groups*nshort)+1] = x_invquant[k+(groups*nshort)+1] * scale;
+ x_invquant[k+(groups*nshort)+2] = x_invquant[k+(groups*nshort)+2] * scale;
+ x_invquant[k+(groups*nshort)+3] = x_invquant[k+(groups*nshort)+3] * scale;
#else
if (exp < 0)
{
- fp[0] >>= -exp;
- fp[1] >>= -exp;
- fp[2] >>= -exp;
- fp[3] >>= -exp;
+ x_invquant[k+(groups*nshort)] >>= -exp;
+ x_invquant[k+(groups*nshort)+1] >>= -exp;
+ x_invquant[k+(groups*nshort)+2] >>= -exp;
+ x_invquant[k+(groups*nshort)+3] >>= -exp;
} else {
- fp[0] <<= exp;
- fp[1] <<= exp;
- fp[2] <<= exp;
- fp[3] <<= exp;
+ x_invquant[k+(groups*nshort)] <<= exp;
+ x_invquant[k+(groups*nshort)+1] <<= exp;
+ x_invquant[k+(groups*nshort)+2] <<= exp;
+ x_invquant[k+(groups*nshort)+3] <<= exp;
}
if (frac)
{
- fp[0] = MUL_R_C(fp[0],pow2_table[frac + 3]);
- fp[1] = MUL_R_C(fp[1],pow2_table[frac + 3]);
- fp[2] = MUL_R_C(fp[2],pow2_table[frac + 3]);
- fp[3] = MUL_R_C(fp[3],pow2_table[frac + 3]);
+ x_invquant[k+(groups*nshort)] = MUL_R_C(x_invquant[k+(groups*nshort)],pow2_table[frac + 3]);
+ x_invquant[k+(groups*nshort)+1] = MUL_R_C(x_invquant[k+(groups*nshort)+1],pow2_table[frac + 3]);
+ x_invquant[k+(groups*nshort)+2] = MUL_R_C(x_invquant[k+(groups*nshort)+2],pow2_table[frac + 3]);
+ x_invquant[k+(groups*nshort)+3] = MUL_R_C(x_invquant[k+(groups*nshort)+3],pow2_table[frac + 3]);
}
#endif
- fp += 4;
}
}
groups += ics->window_group_length[g];
Index: specrec.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/specrec.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- specrec.h 30 Aug 2003 22:30:23 -0000 1.1
+++ specrec.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -37,13 +37,10 @@
uint8_t window_grouping_info(faacDecHandle hDecoder, ic_stream *ics);
void quant_to_spec(ic_stream *ics, real_t *spec_data, uint16_t frame_len);
void inverse_quantization(real_t *x_invquant, int16_t *x_quant, uint16_t frame_len);
-#ifdef FIXED_POINT
void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics, real_t *x_invquant,
uint16_t frame_len);
-#else
+#ifndef FIXED_POINT
void build_tables(real_t *pow2_table);
-void apply_scalefactors(ic_stream *ics, real_t *x_invquant, real_t *pow2_table,
- uint16_t frame_len);
#endif
#ifdef __cplusplus
Index: ssr.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/ssr.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
Index: ssr.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/ssr.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
Index: ssr_fb.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/ssr_fb.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
Index: ssr_fb.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/ssr_fb.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ssr_fb.h 30 Aug 2003 22:30:23 -0000 1.1
+++ ssr_fb.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -1,6 +1,6 @@
/*
-** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -15,12 +15,6 @@
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-**
-** Any non-GPL usage of this software or parts of this software is strictly
-** forbidden.
-**
-** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense at nero.com.
**
** $Id$
**/
Index: ssr_ipqf.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/ssr_ipqf.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
Index: ssr_ipqf.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/ssr_ipqf.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ssr_ipqf.h 30 Aug 2003 22:30:23 -0000 1.1
+++ ssr_ipqf.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -1,6 +1,6 @@
/*
-** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -15,12 +15,6 @@
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-**
-** Any non-GPL usage of this software or parts of this software is strictly
-** forbidden.
-**
-** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense at nero.com.
**
** $Id$
**/
Index: ssr_win.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/ssr_win.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ssr_win.h 30 Aug 2003 22:30:23 -0000 1.1
+++ ssr_win.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -1,6 +1,6 @@
/*
-** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -15,12 +15,6 @@
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-**
-** Any non-GPL usage of this software or parts of this software is strictly
-** forbidden.
-**
-** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense at nero.com.
**
** $Id$
**/
Index: structs.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/structs.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- structs.h 30 Aug 2003 22:30:23 -0000 1.1
+++ structs.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -160,6 +160,9 @@
uint16_t adts_buffer_fullness;
uint8_t no_raw_data_blocks_in_frame;
uint16_t crc_check;
+
+ /* control param */
+ uint8_t old_format;
} adts_header;
typedef struct
@@ -318,6 +321,7 @@
uint8_t epConfig;
int8_t sbr_present_flag;
+ int8_t forceUpSampling;
} mp4AudioSpecificConfig;
typedef struct faacDecConfiguration
@@ -326,6 +330,7 @@
uint32_t defSampleRate;
uint8_t outputFormat;
uint8_t downMatrix;
+ uint8_t useOldADTSFormat;
} faacDecConfiguration, *faacDecConfigurationPtr;
typedef struct faacDecFrameInfo
@@ -336,6 +341,15 @@
uint8_t error;
uint32_t samplerate;
+ /* SBR: 0: off, 1: on; normal, 2: on; downsampled */
+ uint8_t sbr;
+
+ /* MPEG-4 ObjectType */
+ uint8_t object_type;
+
+ /* AAC header type; MP4 will be signalled as RAW also */
+ uint8_t header_type;
+
/* multichannel configuration */
uint8_t num_front_channels;
uint8_t num_side_channels;
@@ -357,7 +371,6 @@
uint8_t aacSpectralDataResilienceFlag;
#endif
uint16_t frameLength;
- uint16_t samplesLeft;
uint8_t postSeekResetFlag;
uint32_t frame;
@@ -382,12 +395,16 @@
#ifdef SBR_DEC
int8_t sbr_present_flag;
+ int8_t forceUpSampling;
real_t *time_out2[MAX_CHANNELS];
uint8_t sbr_used[32];
sbr_info *sbr[32];
+#ifdef DRM
+ int8_t lcstereo_flag;
+#endif
#endif
#ifdef SSR_DEC
Index: syntax.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/syntax.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- syntax.c 30 Aug 2003 22:30:23 -0000 1.1
+++ syntax.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -262,8 +262,7 @@
element *decode_sce_lfe(faacDecHandle hDecoder,
faacDecFrameInfo *hInfo, bitfile *ld,
- int16_t **spec_data, real_t **spec_coef,
- uint8_t id_syn_ele)
+ real_t **spec_coef, uint8_t id_syn_ele)
{
element *ele;
uint8_t channels = hDecoder->fr_channels;
@@ -279,7 +278,6 @@
return NULL;
}
- spec_data[channels] = (int16_t*)malloc(hDecoder->frameLength*sizeof(int16_t));
spec_coef[channels] = (real_t*)malloc(hDecoder->frameLength*sizeof(real_t));
ele = (element*)malloc(sizeof(element));
@@ -289,7 +287,7 @@
ele->paired_channel = -1;
hInfo->error = single_lfe_channel_element(hDecoder, ele,
- ld, spec_data[channels]);
+ ld, spec_coef[channels]);
if (hDecoder->pce_set)
hDecoder->internal_channel[hDecoder->pce.sce_channel[ele->element_instance_tag]] = channels;
@@ -309,8 +307,7 @@
element *decode_cpe(faacDecHandle hDecoder,
faacDecFrameInfo *hInfo, bitfile *ld,
- int16_t **spec_data, real_t **spec_coef,
- uint8_t id_syn_ele)
+ real_t **spec_coef, uint8_t id_syn_ele)
{
element *ele;
uint8_t channels = hDecoder->fr_channels;
@@ -326,8 +323,6 @@
return NULL;
}
- spec_data[channels] = (int16_t*)malloc(hDecoder->frameLength*sizeof(int16_t));
- spec_data[channels+1] = (int16_t*)malloc(hDecoder->frameLength*sizeof(int16_t));
spec_coef[channels] = (real_t*)malloc(hDecoder->frameLength*sizeof(real_t));
spec_coef[channels+1] = (real_t*)malloc(hDecoder->frameLength*sizeof(real_t));
@@ -338,7 +333,7 @@
ele->paired_channel = channels+1;
hInfo->error = channel_pair_element(hDecoder, ele,
- ld, spec_data[channels], spec_data[channels+1]);
+ ld, spec_coef[channels], spec_coef[channels+1]);
if (hDecoder->pce_set)
{
@@ -360,8 +355,7 @@
element **raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo,
bitfile *ld, element **elements,
- int16_t **spec_data, real_t **spec_coef,
- program_config *pce, drc_info *drc)
+ real_t **spec_coef, program_config *pce, drc_info *drc)
{
uint8_t id_syn_ele;
uint8_t ch_ele = 0;
@@ -384,7 +378,7 @@
if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele;
hDecoder->last_syn_ele = id_syn_ele;
elements[ch_ele++] = decode_sce_lfe(hDecoder,
- hInfo, ld, spec_data, spec_coef, id_syn_ele);
+ hInfo, ld, spec_coef, id_syn_ele);
if (hInfo->error > 0)
return elements;
break;
@@ -392,14 +386,14 @@
if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele;
hDecoder->last_syn_ele = id_syn_ele;
elements[ch_ele++] = decode_cpe(hDecoder,
- hInfo, ld, spec_data, spec_coef, id_syn_ele);
+ hInfo, ld, spec_coef, id_syn_ele);
if (hInfo->error > 0)
return elements;
break;
case ID_LFE:
hDecoder->has_lfe++;
elements[ch_ele++] = decode_sce_lfe(hDecoder,
- hInfo, ld, spec_data, spec_coef, id_syn_ele);
+ hInfo, ld, spec_coef, id_syn_ele);
if (hInfo->error > 0)
return elements;
break;
@@ -428,7 +422,7 @@
if (hDecoder->sbr_used[ch_ele-1])
{
hDecoder->sbr_present_flag = 1;
- hDecoder->sbr[ch_ele-1]->sample_rate = sample_rates[hDecoder->sf_index];
+ hDecoder->sbr[ch_ele-1]->sample_rate = get_sample_rate(hDecoder->sf_index);
hDecoder->sbr[ch_ele-1]->sample_rate *= 2;
}
#endif
@@ -442,67 +436,67 @@
{
case 1:
elements[ch_ele++] = decode_sce_lfe(hDecoder,
- hInfo, ld, spec_data, spec_coef, ID_SCE);
+ hInfo, ld, spec_coef, ID_SCE);
if (hInfo->error > 0)
return elements;
break;
case 2:
elements[ch_ele++] = decode_cpe(hDecoder,
- hInfo, ld, spec_data, spec_coef, ID_CPE);
+ hInfo, ld, spec_coef, ID_CPE);
if (hInfo->error > 0)
return elements;
break;
case 3:
elements[ch_ele++] = decode_sce_lfe(hDecoder,
- hInfo, ld, spec_data, spec_coef, ID_SCE);
+ hInfo, ld, spec_coef, ID_SCE);
elements[ch_ele++] = decode_cpe(hDecoder,
- hInfo, ld, spec_data, spec_coef, ID_CPE);
+ hInfo, ld, spec_coef, ID_CPE);
if (hInfo->error > 0)
return elements;
break;
case 4:
elements[ch_ele++] = decode_sce_lfe(hDecoder,
- hInfo, ld, spec_data, spec_coef, ID_SCE);
+ hInfo, ld, spec_coef, ID_SCE);
elements[ch_ele++] = decode_cpe(hDecoder,
- hInfo, ld, spec_data, spec_coef, ID_CPE);
+ hInfo, ld, spec_coef, ID_CPE);
elements[ch_ele++] = decode_sce_lfe(hDecoder,
- hInfo, ld, spec_data, spec_coef, ID_SCE);
+ hInfo, ld, spec_coef, ID_SCE);
if (hInfo->error > 0)
return elements;
break;
case 5:
elements[ch_ele++] = decode_sce_lfe(hDecoder,
- hInfo, ld, spec_data, spec_coef, ID_SCE);
+ hInfo, ld, spec_coef, ID_SCE);
elements[ch_ele++] = decode_cpe(hDecoder,
- hInfo, ld, spec_data, spec_coef, ID_CPE);
+ hInfo, ld, spec_coef, ID_CPE);
elements[ch_ele++] = decode_cpe(hDecoder,
- hInfo, ld, spec_data, spec_coef, ID_CPE);
+ hInfo, ld, spec_coef, ID_CPE);
if (hInfo->error > 0)
return elements;
break;
case 6:
elements[ch_ele++] = decode_sce_lfe(hDecoder,
- hInfo, ld, spec_data, spec_coef, ID_SCE);
+ hInfo, ld, spec_coef, ID_SCE);
elements[ch_ele++] = decode_cpe(hDecoder,
- hInfo, ld, spec_data, spec_coef, ID_CPE);
+ hInfo, ld, spec_coef, ID_CPE);
elements[ch_ele++] = decode_cpe(hDecoder,
- hInfo, ld, spec_data, spec_coef, ID_CPE);
+ hInfo, ld, spec_coef, ID_CPE);
elements[ch_ele++] = decode_sce_lfe(hDecoder,
- hInfo, ld, spec_data, spec_coef, ID_LFE);
+ hInfo, ld, spec_coef, ID_LFE);
if (hInfo->error > 0)
return elements;
break;
case 7:
elements[ch_ele++] = decode_sce_lfe(hDecoder,
- hInfo, ld, spec_data, spec_coef, ID_SCE);
+ hInfo, ld, spec_coef, ID_SCE);
elements[ch_ele++] = decode_cpe(hDecoder,
- hInfo, ld, spec_data, spec_coef, ID_CPE);
+ hInfo, ld, spec_coef, ID_CPE);
elements[ch_ele++] = decode_cpe(hDecoder,
- hInfo, ld, spec_data, spec_coef, ID_CPE);
+ hInfo, ld, spec_coef, ID_CPE);
elements[ch_ele++] = decode_cpe(hDecoder,
- hInfo, ld, spec_data, spec_coef, ID_CPE);
+ hInfo, ld, spec_coef, ID_CPE);
elements[ch_ele++] = decode_sce_lfe(hDecoder,
- hInfo, ld, spec_data, spec_coef, ID_LFE);
+ hInfo, ld, spec_coef, ID_LFE);
if (hInfo->error > 0)
return elements;
break;
@@ -521,47 +515,25 @@
#endif
/* new in corrigendum 14496-3:2002 */
- faad_byte_align(ld);
-
- return elements;
-}
-
#ifdef DRM
-static uint8_t faad_check_CRC(bitfile *ld)
-{
- uint16_t len = faad_get_processed_bits(ld) - 8;
- uint8_t CRC;
- uint16_t r=255; /* Initialize to all ones */
-
- /* CRC polynome used x^8 + x^4 + x^3 + x^2 +1 */
-#define GPOLY 0435
-
- faad_rewindbits(ld);
-
- CRC = ~faad_getbits(ld, 8
- DEBUGVAR(1,999,"faad_check_CRC(): CRC")); /* CRC is stored inverted */
-
- for (; len>0; len--)
- {
- r = ( (r << 1) ^ (( ( faad_get1bit(ld
- DEBUGVAR(1,998,"")) & 1) ^ ((r >> 7) & 1)) * GPOLY )) & 0xFF;
- }
- if (r != CRC)
+ if (hDecoder->object_type != DRM_ER_LC)
+#endif
{
- return 8;
- } else {
- return 0;
+ faad_byte_align(ld);
}
+
+ return elements;
}
-#endif
/* Table 4.4.4 and */
/* Table 4.4.9 */
static uint8_t single_lfe_channel_element(faacDecHandle hDecoder,
element *sce, bitfile *ld,
- int16_t *spec_data)
+ real_t *spec_coef)
{
+ uint8_t retval = 0;
ic_stream *ics = &(sce->ics1);
+ int16_t spec_data[1024];
#ifdef DRM
uint8_t result;
@@ -578,7 +550,7 @@
if (ics->tns_data_present)
tns_data(ics, &(ics->tns), ld);
- if ((result = faad_check_CRC( ld )) > 0)
+ if ((result = faad_check_CRC( ld, faad_get_processed_bits(ld) - 8 )) > 0)
return result;
/* error resilient spectral data decoding */
@@ -596,21 +568,40 @@
return 2; /* pulse coding not allowed for short blocks */
}
}
- return 0;
} else
#endif
+ {
+ retval = individual_channel_stream(hDecoder, sce, ld, ics, 0, spec_data);
+ if (retval > 0)
+ return retval;
+ }
+
+
+ /* noiseless coding is done, spectral reconstruction is done now */
+
+ /* inverse quantization */
+ inverse_quantization(spec_coef, spec_data, hDecoder->frameLength);
+
+ /* apply scalefactors */
+ apply_scalefactors(hDecoder, ics, spec_coef, hDecoder->frameLength);
+
+ /* deinterleave short block grouping */
+ if (ics->window_sequence == EIGHT_SHORT_SEQUENCE)
+ quant_to_spec(ics, spec_coef, hDecoder->frameLength);
- return individual_channel_stream(hDecoder, sce, ld, ics, 0, spec_data);
+ return 0;
}
/* Table 4.4.5 */
static uint8_t channel_pair_element(faacDecHandle hDecoder, element *cpe,
- bitfile *ld, int16_t *spec_data1,
- int16_t *spec_data2)
+ bitfile *ld,
+ real_t *spec_coef1, real_t *spec_coef2)
{
uint8_t result;
ic_stream *ics1 = &(cpe->ics1);
ic_stream *ics2 = &(cpe->ics2);
+ int16_t spec_data1[1024];
+ int16_t spec_data2[1024];
#ifdef DRM
if (hDecoder->object_type != DRM_ER_LC)
@@ -689,10 +680,9 @@
if (ics1->tns_data_present)
tns_data(ics2, &(ics2->tns), ld);
- if ((result = faad_check_CRC( ld )) > 0)
- {
+ if ((result = faad_check_CRC( ld, faad_get_processed_bits(ld) - 8 )) > 0)
return result;
- }
+
/* error resilient spectral data decoding */
if ((result = reordered_spectral_data(hDecoder, ics1, ld, spec_data1)) > 0)
return result;
@@ -719,10 +709,25 @@
return 2; /* pulse coding not allowed for short blocks */
}
}
- return 0;
- } else
+ }
#endif
+ /* noiseless coding is done, spectral reconstruction is done now */
+
+ /* inverse quantization */
+ inverse_quantization(spec_coef1, spec_data1, hDecoder->frameLength);
+ inverse_quantization(spec_coef2, spec_data2, hDecoder->frameLength);
+
+ /* apply scalefactors */
+ apply_scalefactors(hDecoder, ics1, spec_coef1, hDecoder->frameLength);
+ apply_scalefactors(hDecoder, ics2, spec_coef2, hDecoder->frameLength);
+
+ /* deinterleave short block grouping */
+ if (ics1->window_sequence == EIGHT_SHORT_SEQUENCE)
+ quant_to_spec(ics1, spec_coef1, hDecoder->frameLength);
+ if (ics2->window_sequence == EIGHT_SHORT_SEQUENCE)
+ quant_to_spec(ics2, spec_coef2, hDecoder->frameLength);
+
return 0;
}
@@ -975,29 +980,6 @@
{
uint8_t data = faad_getbits(ld, LEN_BYTE
DEBUGVAR(1,64,"data_stream_element(): data_stream_byte"));
-
- if (count == 6 && data == 'N')
- {
- data = faad_getbits(ld, LEN_BYTE
- DEBUGVAR(1,64,"data_stream_element(): data_stream_byte"));
- i++;
- if (data == 'D')
- {
- uint16_t samplesLeft;
- uint8_t data2 = faad_getbits(ld, LEN_BYTE
- DEBUGVAR(1,64,"data_stream_element(): data_stream_byte"));
- data = faad_getbits(ld, LEN_BYTE
- DEBUGVAR(1,64,"data_stream_element(): data_stream_byte"));
- samplesLeft = faad_getbits(ld, LEN_BYTE
- DEBUGVAR(1,64,"data_stream_element(): data_stream_byte"));
- samplesLeft += (faad_getbits(ld, LEN_BYTE
- DEBUGVAR(1,64,"data_stream_element(): data_stream_byte")) << 8);
- i += 4;
-
- if (data == 'L' && data2 == 'F')
- hDecoder->samplesLeft = samplesLeft;
- }
- }
}
return count;
@@ -1035,12 +1017,15 @@
hDecoder->sbr_used[sbr_ele] = 1;
if (!hDecoder->sbr[sbr_ele])
- hDecoder->sbr[sbr_ele] = sbrDecodeInit();
+ {
+ hDecoder->sbr[sbr_ele] = sbrDecodeInit(hDecoder->frameLength
+#ifdef DRM
+ , 0
+#endif
+ );
+ }
- /* read in all the SBR data for processing later on
- this is needed because the SBR bitstream reader needs to know
- what element type comes _after_ the (this) SBR FIL element
- */
+ /* read in all the SBR data for processing later on */
hDecoder->sbr[sbr_ele]->data = (uint8_t*)faad_getbitbuffer(ld, count*8);
hDecoder->sbr[sbr_ele]->data_size = count;
} else {
@@ -1642,13 +1627,10 @@
{
sp = spectral_data + p;
- if (sect_cb < FIRST_PAIR_HCB)
- {
- if ((result = huffman_spectral_data(sect_cb, ld, sp)) > 0)
- return result;
- } else {
if ((result = huffman_spectral_data(sect_cb, ld, sp)) > 0)
return result;
+ if (sect_cb >= FIRST_PAIR_HCB)
+ {
if ((result = huffman_spectral_data(sect_cb, ld, sp+2)) > 0)
return result;
}
@@ -1923,13 +1905,16 @@
DEBUGVAR(1,126,"adts_fixed_header(): original"));
adts->home = faad_get1bit(ld
DEBUGVAR(1,127,"adts_fixed_header(): home"));
-/* Removed in corrigendum 14496-3:2002
+
+ if (adts->old_format == 1)
+ {
+ /* Removed in corrigendum 14496-3:2002 */
if (adts->id == 0)
{
adts->emphasis = (uint8_t)faad_getbits(ld, 2
DEBUGVAR(1,128,"adts_fixed_header(): emphasis"));
}
-*/
+ }
return 0;
}
Index: syntax.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/syntax.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- syntax.h 30 Aug 2003 22:30:23 -0000 1.1
+++ syntax.h 3 Oct 2003 22:22:27 -0000 1.2
@@ -36,15 +36,34 @@
#include "drc.h"
#include "bits.h"
-#define MAIN 0
-#define LC 1
-#define SSR 2
-#define LTP 3
+#define MAIN 1
+#define LC 2
+#define SSR 3
+#define LTP 4
+#define HE_AAC 5
#define LD 23
#define ER_LC 17
#define ER_LTP 19
#define DRM_ER_LC 27 /* special object type for DRM */
+/* header types */
+#define RAW 0
+#define ADIF 1
+#define ADTS 2
+
+/* SBR signalling */
+#define NO_SBR 0
+#define SBR_UPSAMPLED 1
+#define SBR_DOWNSAMPLED 2
+#define NO_SBR_UPSAMPLED 3
+
+/* DRM channel definitions */
+#define DRMCH_MONO 1
+#define DRMCH_STEREO 2
+#define DRMCH_SBR_MONO 3
+#define DRMCH_SBR_LC_STEREO 4
+#define DRMCH_SBR_STEREO 5
+
/* First object type that has ER */
#define ER_OBJECT_START 17
@@ -85,12 +104,6 @@
#define INTENSITY_HCB2 14
#define INTENSITY_HCB 15
-static uint32_t sample_rates[] =
-{
- 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000,
- 12000, 11025, 8000
-};
-
int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC,
program_config *pce);
@@ -101,10 +114,10 @@
/* static functions */
static uint8_t single_lfe_channel_element(faacDecHandle hDecoder,
element *sce, bitfile *ld,
- int16_t *spec_data);
+ real_t *spec_coef);
static uint8_t channel_pair_element(faacDecHandle hDecoder, element *cpe,
- bitfile *ld, int16_t *spec_data1,
- int16_t *spec_data2);
+ bitfile *ld,
+ real_t *spec_coef1, real_t *spec_coef2);
static uint8_t coupling_channel_element(faacDecHandle hDecoder, bitfile *ld);
static uint16_t data_stream_element(faacDecHandle hDecoder, bitfile *ld);
static uint8_t program_config_element(program_config *pce, bitfile *ld);
Index: tns.c
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/tns.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- tns.c 30 Aug 2003 22:30:23 -0000 1.1
+++ tns.c 3 Oct 2003 22:22:27 -0000 1.2
@@ -31,69 +31,38 @@
#include "syntax.h"
#include "tns.h"
-#ifdef FIXED_POINT
-static real_t tns_coef_0_3[] =
-{
- 0x0, 0x6F13013, 0xC8261BA, 0xF994E02,
- 0xF03E3A3A, 0xF224C28C, 0xF5B72457, 0xFA8715E3,
- 0xF90ECFED, 0xF37D9E46, 0xF066B1FE, 0xF066B1FE,
- 0xF03E3A3A, 0xF224C28C, 0xF5B72457, 0xFA8715E3
-};
-static real_t tns_coef_0_4[] =
-{
- 0x0, 0x3539B35, 0x681FE48, 0x9679182,
- 0xBE3EBD4, 0xDDB3D74, 0xF378709, 0xFE98FCA,
- 0xF011790B, 0xF09C5CB7, 0xF1AD6942, 0xF33B524A,
- 0xF5388AEB, 0xF793BBDF, 0xFA385AA9, 0xFD0F5CAB
-};
-static real_t tns_coef_1_3[] =
-{
- 0x0, 0x6F13013, 0xF5B72457, 0xFA8715E3,
- 0xF994E02, 0xC8261BA, 0xF5B72457, 0xFA8715E3,
- 0xF90ECFED, 0xF37D9E46, 0xF5B72457, 0xFA8715E3,
- 0xF37D9E46, 0xF90ECFED, 0xF5B72457, 0xFA8715E3
-};
-static real_t tns_coef_1_4[] =
-{
- 0x0, 0x3539B35, 0x681FE48, 0x9679182,
- 0xF5388AEB, 0xF793BBDF, 0xFA385AA9, 0xFD0F5CAB,
- 0xFE98FCA, 0xF378709, 0xDDB3D74, 0xBE3EBD4,
- 0xF5388AEB, 0xF793BBDF, 0xFA385AA9, 0xFD0F5CAB
-};
-#else
#ifdef _MSC_VER
#pragma warning(disable:4305)
#pragma warning(disable:4244)
#endif
static real_t tns_coef_0_3[] =
{
- 0.0, 0.4338837391, 0.7818314825, 0.9749279122,
- -0.9848077530, -0.8660254038, -0.6427876097, -0.3420201433,
- -0.4338837391, -0.7818314825, -0.9749279122, -0.9749279122,
- -0.9848077530, -0.8660254038, -0.6427876097, -0.3420201433
+ COEF_CONST(0.0), COEF_CONST(0.4338837391), COEF_CONST(0.7818314825), COEF_CONST(0.9749279122),
+ COEF_CONST(-0.9848077530), COEF_CONST(-0.8660254038), COEF_CONST(-0.6427876097), COEF_CONST(-0.3420201433),
+ COEF_CONST(-0.4338837391), COEF_CONST(-0.7818314825), COEF_CONST(-0.9749279122), COEF_CONST(-0.9749279122),
+ COEF_CONST(-0.9848077530), COEF_CONST(-0.8660254038), COEF_CONST(-0.6427876097), COEF_CONST(-0.3420201433)
};
static real_t tns_coef_0_4[] =
{
- 0.0, 0.2079116908, 0.4067366431, 0.5877852523,
- 0.7431448255, 0.8660254038, 0.9510565163, 0.9945218954,
- -0.9957341763, -0.9618256432, -0.8951632914, -0.7980172273,
- -0.6736956436, -0.5264321629, -0.3612416662, -0.1837495178
+ COEF_CONST(0.0), COEF_CONST(0.2079116908), COEF_CONST(0.4067366431), COEF_CONST(0.5877852523),
+ COEF_CONST(0.7431448255), COEF_CONST(0.8660254038), COEF_CONST(0.9510565163), COEF_CONST(0.9945218954),
+ COEF_CONST(-0.9957341763), COEF_CONST(-0.9618256432), COEF_CONST(-0.8951632914), COEF_CONST(-0.7980172273),
+ COEF_CONST(-0.6736956436), COEF_CONST(-0.5264321629), COEF_CONST(-0.3612416662), COEF_CONST(-0.1837495178)
};
static real_t tns_coef_1_3[] =
{
- 0.0, 0.4338837391, -0.6427876097, -0.3420201433,
- 0.9749279122, 0.7818314825, -0.6427876097, -0.3420201433,
- -0.4338837391, -0.7818314825, -0.6427876097, -0.3420201433,
- -0.7818314825, -0.4338837391, -0.6427876097, -0.3420201433
+ COEF_CONST(0.0), COEF_CONST(0.4338837391), COEF_CONST(-0.6427876097), COEF_CONST(-0.3420201433),
+ COEF_CONST(0.9749279122), COEF_CONST(0.7818314825), COEF_CONST(-0.6427876097), COEF_CONST(-0.3420201433),
+ COEF_CONST(-0.4338837391), COEF_CONST(-0.7818314825), COEF_CONST(-0.6427876097), COEF_CONST(-0.3420201433),
+ COEF_CONST(-0.7818314825), COEF_CONST(-0.4338837391), COEF_CONST(-0.6427876097), COEF_CONST(-0.3420201433)
};
static real_t tns_coef_1_4[] =
{
- 0.0, 0.2079116908, 0.4067366431, 0.5877852523,
- -0.6736956436, -0.5264321629, -0.3612416662, -0.1837495178,
- 0.9945218954, 0.9510565163, 0.8660254038, 0.7431448255,
- -0.6736956436, -0.5264321629, -0.3612416662, -0.1837495178
+ COEF_CONST(0.0), COEF_CONST(0.2079116908), COEF_CONST(0.4067366431), COEF_CONST(0.5877852523),
+ COEF_CONST(-0.6736956436), COEF_CONST(-0.5264321629), COEF_CONST(-0.3612416662), COEF_CONST(-0.1837495178),
+ COEF_CONST(0.9945218954), COEF_CONST(0.9510565163), COEF_CONST(0.8660254038), COEF_CONST(0.7431448255),
+ COEF_CONST(-0.6736956436), COEF_CONST(-0.5264321629), COEF_CONST(-0.3612416662), COEF_CONST(-0.1837495178)
};
-#endif
/* TNS decoding for one channel and frame */
Index: tns.h
===================================================================
RCS file: /cvsroot/mplayer/main/libfaad2/tns.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
More information about the MPlayer-cvslog
mailing list