summaryrefslogtreecommitdiff
path: root/src/libfaad/tns.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libfaad/tns.c')
-rw-r--r--src/libfaad/tns.c104
1 files changed, 7 insertions, 97 deletions
diff --git a/src/libfaad/tns.c b/src/libfaad/tns.c
index d06fb5774..6609071ae 100644
--- a/src/libfaad/tns.c
+++ b/src/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.2 2002/12/16 19:02:10 miguelfreitas Exp $
+** $Id: tns.c,v 1.3 2003/04/12 14:58:47 miguelfreitas Exp $
**/
#include "common.h"
@@ -111,20 +111,15 @@ void tns_decode_frame(ic_stream *ics, tns_info *tns, uint8_t sr_index,
{
top = bottom;
bottom = max(top - tns->length[w][f], 0);
- tns_order = min(tns->order[w][f], tns_max_order(ics, sr_index,
- object_type));
+ tns_order = min(tns->order[w][f], TNS_MAX_ORDER);
if (!tns_order)
continue;
tns_decode_coef(tns_order, tns->coef_res[w]+3,
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, frame_len),
- ics->max_sfb))];
- end = ics->swb_offset[min(top,
- min(tns_max_bands(ics, sr_index, object_type, frame_len),
- ics->max_sfb))];
+ start = ics->swb_offset[min(bottom, ics->max_sfb)];
+ end = ics->swb_offset[min(top, ics->max_sfb)];
if ((size = end - start) <= 0)
continue;
@@ -163,20 +158,15 @@ void tns_encode_frame(ic_stream *ics, tns_info *tns, uint8_t sr_index,
{
top = bottom;
bottom = max(top - tns->length[w][f], 0);
- tns_order = min(tns->order[w][f], tns_max_order(ics, sr_index,
- object_type));
+ tns_order = min(tns->order[w][f], TNS_MAX_ORDER);
if (!tns_order)
continue;
tns_decode_coef(tns_order, tns->coef_res[w]+3,
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, frame_len),
- ics->max_sfb))];
- end = ics->swb_offset[min(top,
- min(tns_max_bands(ics, sr_index, object_type, frame_len),
- ics->max_sfb))];
+ start = ics->swb_offset[min(bottom, ics->max_sfb)];
+ end = ics->swb_offset[min(top, ics->max_sfb)];
if ((size = end - start) <= 0)
continue;
@@ -305,83 +295,3 @@ static void tns_ma_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *l
spectrum += inc;
}
}
-
-static uint8_t tns_max_bands_table[12][6] =
-{
- /* entry for each sampling rate
- * 1 Main/LC long window
- * 2 Main/LC short window
- * 3 SSR long window
- * 4 SSR short window
- * 5 LD 512 window
- * 6 LD 480 window
- */
- { 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, uint16_t frame_len)
-{
- uint8_t i;
-
- i = (ics->window_sequence == EIGHT_SHORT_SEQUENCE) ? 1 : 0;
-#ifdef LD_DEC
- if (object_type == LD)
- {
- if (frame_len == 512)
- i = 4;
- else
- i = 5;
- }
-#endif
-
- return tns_max_bands_table[sr_index][i];
-}
-
-static uint8_t tns_max_order(ic_stream *ics, uint8_t sr_index,
- uint8_t object_type)
-{
- /* Correction in 14496-3 Cor. 1
- Works like MPEG2-AAC (13818-7) now
-
- For other object types (scalable) the following goes for tns max order
- for long windows:
- if (sr_index <= 5)
- return 12;
- else
- return 20;
- */
- if (ics->window_sequence != EIGHT_SHORT_SEQUENCE)
- {
- switch (object_type)
- {
- case MAIN:
- case LTP:
- case ER_LTP:
-#ifdef LD_DEC
- case LD:
-#endif
- return 20;
- case LC:
- case ER_LC:
- case DRM_ER_LC:
- case SSR:
- return 12;
- }
- } else {
- return 7;
- }
-
- return 0;
-}