ref: 876a4ad85ff46d98b907bc051290f1e2ece556cf
parent: b2880393d0216a9d5c3ad876d5ca44d1aacd8f5e
author: menno <menno>
date: Sun Sep 15 18:02:30 EDT 2002
Some LD table fixes
--- a/libfaad/data.c
+++ b/libfaad/data.c
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: data.c,v 1.4 2002/03/16 13:38:37 menno Exp $
+** $Id: data.c,v 1.5 2002/09/15 22:02:30 menno Exp $
**/
#include "common.h"
@@ -25,8 +25,12 @@
#ifdef LD_DEC
extern uint8_t num_swb_512_window[] =
{
- 0, 0, 0, 35, 35, 36, 30, 30, 0, 0, 0, 0
+ 0, 0, 0, 36, 36, 37, 31, 31, 0, 0, 0, 0
};
+extern uint8_t num_swb_480_window[] =
+{
+ 0, 0, 0, 35, 35, 37, 30, 30, 0, 0, 0, 0
+};
#endif
extern uint8_t num_swb_1024_window[] =
@@ -80,6 +84,13 @@
92, 100, 112, 124, 136, 148, 164, 184, 208, 236, 268, 300, 332, 364, 396,
428, 460, 512
};
+
+static uint16_t swb_offset_480_48[] =
+{
+ 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 64, 72 ,80 ,88,
+ 96, 108, 120, 132, 144, 156, 172, 188, 212, 240, 272, 304, 336, 368, 400,
+ 432, 480
+};
#endif
static uint16_t swb_offset_128_48[] =
@@ -102,6 +113,13 @@
88, 96, 108, 120, 132, 144, 160, 176, 192, 212, 236, 260, 288, 320, 352,
384, 416, 448, 480, 512
};
+
+static uint16_t swb_offset_480_32[] =
+{
+ 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 72, 80,
+ 88, 96, 104, 112, 124, 136, 148, 164, 180, 200, 224, 256, 288, 320, 352,
+ 384, 416, 448, 480
+};
#endif
static uint16_t swb_offset_1024_24[] =
@@ -119,6 +137,12 @@
80, 92, 104, 120, 140, 164, 192, 224, 256, 288, 320, 352, 384, 416,
448, 480, 512
};
+
+static uint16_t swb_offset_480_24[] =
+{
+ 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 52, 60, 68, 80, 92, 104, 120,
+ 140, 164, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480
+};
#endif
static uint16_t swb_offset_128_24[] =
@@ -177,6 +201,22 @@
swb_offset_512_32, /* 32000 */
swb_offset_512_24, /* 24000 */
swb_offset_512_24, /* 22050 */
+ 0, /* 16000 */
+ 0, /* 12000 */
+ 0, /* 11025 */
+ 0 /* 8000 */
+};
+
+extern uint16_t *swb_offset_480_window[] =
+{
+ 0, /* 96000 */
+ 0, /* 88200 */
+ 0, /* 64000 */
+ swb_offset_480_48, /* 48000 */
+ swb_offset_480_48, /* 44100 */
+ swb_offset_480_32, /* 32000 */
+ swb_offset_480_24, /* 24000 */
+ swb_offset_480_24, /* 22050 */
0, /* 16000 */
0, /* 12000 */
0, /* 11025 */
--- a/libfaad/data.h
+++ b/libfaad/data.h
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: data.h,v 1.4 2002/03/16 13:38:37 menno Exp $
+** $Id: data.h,v 1.5 2002/09/15 22:02:30 menno Exp $
**/
#ifndef __DATA_H__
@@ -29,11 +29,13 @@
extern uint8_t num_swb_1024_window[];
#ifdef LD_DEC
extern uint8_t num_swb_512_window[];
+extern uint8_t num_swb_480_window[];
#endif
extern uint8_t num_swb_128_window[];
extern uint16_t *swb_offset_1024_window[];
#ifdef LD_DEC
extern uint16_t *swb_offset_512_window[];
+extern uint16_t *swb_offset_480_window[];
#endif
extern uint16_t *swb_offset_128_window[];
extern uint8_t pred_sfb_max[];
--- a/libfaad/specrec.c
+++ b/libfaad/specrec.c
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: specrec.c,v 1.15 2002/09/08 18:14:37 menno Exp $
+** $Id: specrec.c,v 1.16 2002/09/15 22:02:30 menno Exp $
**/
/*
@@ -64,7 +64,10 @@
#ifdef LD_DEC
if (object_type == LD)
{
- ics->num_swb = num_swb_512_window[fs_index];
+ if (frame_len == 512)
+ ics->num_swb = num_swb_512_window[fs_index];
+ else /* if (frame_len == 480) */
+ ics->num_swb = num_swb_480_window[fs_index];
} else {
#endif
ics->num_swb = num_swb_1024_window[fs_index];
@@ -77,10 +80,19 @@
#ifdef LD_DEC
if (object_type == LD)
{
- for (i = 0; i < ics->num_swb; i++)
+ if (frame_len == 512)
{
- ics->sect_sfb_offset[0][i] = swb_offset_512_window[fs_index][i];
- ics->swb_offset[i] = swb_offset_512_window[fs_index][i];
+ for (i = 0; i < ics->num_swb; i++)
+ {
+ ics->sect_sfb_offset[0][i] = swb_offset_512_window[fs_index][i];
+ ics->swb_offset[i] = swb_offset_512_window[fs_index][i];
+ }
+ } else /* if (frame_len == 480) */ {
+ for (i = 0; i < ics->num_swb; i++)
+ {
+ ics->sect_sfb_offset[0][i] = swb_offset_480_window[fs_index][i];
+ ics->swb_offset[i] = swb_offset_480_window[fs_index][i];
+ }
}
ics->sect_sfb_offset[0][ics->num_swb] = frame_len;
ics->swb_offset[ics->num_swb] = frame_len;
--- a/libfaad/tns.c
+++ b/libfaad/tns.c
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: tns.c,v 1.16 2002/09/13 13:08:45 menno Exp $
+** $Id: tns.c,v 1.17 2002/09/15 22:02:30 menno Exp $
**/
#include "common.h"
@@ -119,9 +119,11 @@
tns->coef_compress[w][f], tns->coef[w][f], lpc);
start = ics->swb_offset[min(bottom,
- min(tns_max_bands(ics, sr_index, object_type), ics->max_sfb))];
+ min(tns_max_bands(ics, sr_index, object_type, frame_len),
+ ics->max_sfb))];
end = ics->swb_offset[min(top,
- min(tns_max_bands(ics, sr_index, object_type), ics->max_sfb))];
+ min(tns_max_bands(ics, sr_index, object_type, frame_len),
+ ics->max_sfb))];
if ((size = end - start) <= 0)
continue;
@@ -169,9 +171,11 @@
tns->coef_compress[w][f], tns->coef[w][f], lpc);
start = ics->swb_offset[min(bottom,
- min(tns_max_bands(ics, sr_index, object_type), ics->max_sfb))];
+ min(tns_max_bands(ics, sr_index, object_type, frame_len),
+ ics->max_sfb))];
end = ics->swb_offset[min(top,
- min(tns_max_bands(ics, sr_index, object_type), ics->max_sfb))];
+ min(tns_max_bands(ics, sr_index, object_type, frame_len),
+ ics->max_sfb))];
if ((size = end - start) <= 0)
continue;
@@ -301,7 +305,7 @@
}
}
-static uint8_t tns_max_bands_table[12][5] =
+static uint8_t tns_max_bands_table[12][6] =
{
/* entry for each sampling rate
* 1 Main/LC long window
@@ -309,23 +313,24 @@
* 3 SSR long window
* 4 SSR short window
* 5 LD 512 window
+ * 6 LD 480 window
*/
- { 31, 9, 28, 7, 0 }, /* 96000 */
- { 31, 9, 28, 7, 0 }, /* 88200 */
- { 34, 10, 27, 7, 0 }, /* 64000 */
- { 40, 14, 26, 6, 31 }, /* 48000 */
- { 42, 14, 26, 6, 32 }, /* 44100 */
- { 51, 14, 26, 6, 37 }, /* 32000 */
- { 46, 14, 29, 7, 31 }, /* 24000 */
- { 46, 14, 29, 7, 31 }, /* 22050 */
- { 42, 14, 23, 8, 0 }, /* 16000 */
- { 42, 14, 23, 8, 0 }, /* 12000 */
- { 42, 14, 23, 8, 0 }, /* 11025 */
- { 39, 14, 19, 7, 0 }, /* 8000 */
+ { 31, 9, 28, 7, 0, 0 }, /* 96000 */
+ { 31, 9, 28, 7, 0, 0 }, /* 88200 */
+ { 34, 10, 27, 7, 0, 0 }, /* 64000 */
+ { 40, 14, 26, 6, 31, 31 }, /* 48000 */
+ { 42, 14, 26, 6, 32, 32 }, /* 44100 */
+ { 51, 14, 26, 6, 37, 37 }, /* 32000 */
+ { 46, 14, 29, 7, 31, 30 }, /* 24000 */
+ { 46, 14, 29, 7, 31, 30 }, /* 22050 */
+ { 42, 14, 23, 8, 0, 0 }, /* 16000 */
+ { 42, 14, 23, 8, 0, 0 }, /* 12000 */
+ { 42, 14, 23, 8, 0, 0 }, /* 11025 */
+ { 39, 14, 19, 7, 0, 0 }, /* 8000 */
};
static uint8_t tns_max_bands(ic_stream *ics, uint8_t sr_index,
- uint8_t object_type)
+ uint8_t object_type, uint16_t frame_len)
{
uint8_t i;
@@ -332,7 +337,12 @@
i = (ics->window_sequence == EIGHT_SHORT_SEQUENCE) ? 1 : 0;
#ifdef LD_DEC
if (object_type == LD)
- i = 4;
+ {
+ if (frame_len == 512)
+ i = 4;
+ else
+ i = 5;
+ }
#endif
return tns_max_bands_table[sr_index][i];
@@ -339,7 +349,7 @@
}
static uint8_t tns_max_order(ic_stream *ics, uint8_t sr_index,
- uint8_t object_type)
+ uint8_t object_type)
{
/* Correction in 14496-3 Cor. 1
Works like MPEG2-AAC (13818-7) now
--- a/libfaad/tns.h
+++ b/libfaad/tns.h
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: tns.h,v 1.4 2002/06/13 11:03:28 menno Exp $
+** $Id: tns.h,v 1.5 2002/09/15 22:02:30 menno Exp $
**/
#ifndef __TNS_H__
@@ -41,7 +41,8 @@
uint8_t order);
static void tns_ma_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *lpc,
uint8_t order);
-static uint8_t tns_max_bands(ic_stream *ics, uint8_t sr_index, uint8_t object_type);
+static uint8_t tns_max_bands(ic_stream *ics, uint8_t sr_index, uint8_t object_type,
+ uint16_t frame_len);
static uint8_t tns_max_order(ic_stream *ics, uint8_t sr_index,
uint8_t object_type);