ref: 66190c87084127f1ac78397cabb5185be04a62d2
parent: 5123c47529c4713e28c2f345ccd2499faefdea67
author: menno <menno>
date: Tue Mar 28 07:25:27 EST 2000
Moved a function
--- a/huffman.c
+++ b/huffman.c
@@ -11,85 +11,6 @@
#include "hufftab5.h"
-int sort_for_grouping(AACQuantInfo* quantInfo, /* ptr to quantization information */
- int sfb_width_table[], /* Widths of single window */
- double *p_spectrum[], /* Spectral values, noninterleaved */
- double *SigMaskRatio,
- double *PsySigMaskRatio)
-{
- int i,j,ii;
- int index;
- double tmp[1024];
-// int book=1;
- int group_offset;
- int k=0;
- int windowOffset;
-
- /* set up local variables for used quantInfo elements */
- int* sfb_offset = quantInfo -> sfb_offset;
- int* nr_of_sfb = &(quantInfo -> nr_of_sfb);
- int* window_group_length;
- int num_window_groups;
- *nr_of_sfb = quantInfo->max_sfb; /* Init to max_sfb */
- window_group_length = quantInfo -> window_group_length;
- num_window_groups = quantInfo -> num_window_groups;
-
- /* calc org sfb_offset just for shortblock */
- sfb_offset[k]=0;
- for (k=0; k < 1024; k++) {
- tmp[k] = 0.0;
- }
- for (k=1 ; k <*nr_of_sfb+1; k++) {
- sfb_offset[k] = sfb_offset[k-1] + sfb_width_table[k-1];
- }
-
- /* sort the input spectral coefficients */
- index = 0;
- group_offset=0;
- for (i=0; i< num_window_groups; i++) {
- for (k=0; k<*nr_of_sfb; k++) {
- for (j=0; j < window_group_length[i]; j++) {
- for (ii=0;ii< sfb_width_table[k];ii++)
- tmp[index++] = p_spectrum[MONO_CHAN][ii+ sfb_offset[k] + 128*j +group_offset];
- }
- }
- group_offset += 128*window_group_length[i];
- }
-
- for (k=0; k<1024; k++){
- p_spectrum[MONO_CHAN][k] = tmp[k];
- }
-
- /* now calc the new sfb_offset table for the whole p_spectrum vector*/
- index = 0;
- sfb_offset[index] = 0;
- index++;
- windowOffset = 0;
- for (i=0; i < num_window_groups; i++) {
- for (k=0 ; k <*nr_of_sfb; k++) {
- /* for this window group and this band, find worst case inverse sig-mask-ratio */
- int bandNum=windowOffset*NSFB_SHORT + k;
- double worstISMR = PsySigMaskRatio[bandNum];
- int w;
- for (w=1;w<window_group_length[i];w++) {
- bandNum=(w+windowOffset)*NSFB_SHORT + k;
- if (PsySigMaskRatio[bandNum]<worstISMR) {
- worstISMR += (PsySigMaskRatio[bandNum] > 0)?PsySigMaskRatio[bandNum]:worstISMR;
- }
- }
- worstISMR /= 2.0;
- SigMaskRatio[k+ i* *nr_of_sfb]=worstISMR/window_group_length[i];
- sfb_offset[index] = sfb_offset[index-1] + sfb_width_table[k]*window_group_length[i] ;
- index++;
- }
- windowOffset += window_group_length[i];
- }
-
- *nr_of_sfb = *nr_of_sfb * num_window_groups; /* Number interleaved bands. */
-
- return 0;
-}
-
sort_book_numbers(AACQuantInfo* quantInfo, /* Quantization information */
// int output_book_vector[], /* Output codebook vector, formatted for bitstream */
BsBitStream* fixed_stream, /* Bitstream */
--- a/huffman.h
+++ b/huffman.h
@@ -38,15 +38,6 @@
/*********************************************************/
-/* sort_book_numbers */
-/*********************************************************/
-int sort_for_grouping(AACQuantInfo* quantInfo, /* ptr to quantization information */
- int sfb_width_table[], /* Widths of single window */
- double *p_spectrum[], /* Spectral values, noninterleaved */
- double *SigMaskRatio,
- double *PsySigMaskRatio);
-
-/*********************************************************/
/* bit_search */
/*********************************************************/
int bit_search(int quant[NUM_COEFF], /* Quantized spectral values */
--- a/quant.c
+++ b/quant.c
@@ -924,4 +924,86 @@
}
return FNO_ERROR;
-}
\ No newline at end of file
+}
+
+
+
+int sort_for_grouping(AACQuantInfo* quantInfo, /* ptr to quantization information */
+ int sfb_width_table[], /* Widths of single window */
+ double *p_spectrum[], /* Spectral values, noninterleaved */
+ double *SigMaskRatio,
+ double *PsySigMaskRatio)
+{
+ int i,j,ii;
+ int index;
+ double tmp[1024];
+// int book=1;
+ int group_offset;
+ int k=0;
+ int windowOffset;
+
+ /* set up local variables for used quantInfo elements */
+ int* sfb_offset = quantInfo -> sfb_offset;
+ int* nr_of_sfb = &(quantInfo -> nr_of_sfb);
+ int* window_group_length;
+ int num_window_groups;
+ *nr_of_sfb = quantInfo->max_sfb; /* Init to max_sfb */
+ window_group_length = quantInfo -> window_group_length;
+ num_window_groups = quantInfo -> num_window_groups;
+
+ /* calc org sfb_offset just for shortblock */
+ sfb_offset[k]=0;
+ for (k=0; k < 1024; k++) {
+ tmp[k] = 0.0;
+ }
+ for (k=1 ; k <*nr_of_sfb+1; k++) {
+ sfb_offset[k] = sfb_offset[k-1] + sfb_width_table[k-1];
+ }
+
+ /* sort the input spectral coefficients */
+ index = 0;
+ group_offset=0;
+ for (i=0; i< num_window_groups; i++) {
+ for (k=0; k<*nr_of_sfb; k++) {
+ for (j=0; j < window_group_length[i]; j++) {
+ for (ii=0;ii< sfb_width_table[k];ii++)
+ tmp[index++] = p_spectrum[MONO_CHAN][ii+ sfb_offset[k] + 128*j +group_offset];
+ }
+ }
+ group_offset += 128*window_group_length[i];
+ }
+
+ for (k=0; k<1024; k++){
+ p_spectrum[MONO_CHAN][k] = tmp[k];
+ }
+
+ /* now calc the new sfb_offset table for the whole p_spectrum vector*/
+ index = 0;
+ sfb_offset[index] = 0;
+ index++;
+ windowOffset = 0;
+ for (i=0; i < num_window_groups; i++) {
+ for (k=0 ; k <*nr_of_sfb; k++) {
+ /* for this window group and this band, find worst case inverse sig-mask-ratio */
+ int bandNum=windowOffset*NSFB_SHORT + k;
+ double worstISMR = PsySigMaskRatio[bandNum];
+ int w;
+ for (w=1;w<window_group_length[i];w++) {
+ bandNum=(w+windowOffset)*NSFB_SHORT + k;
+ if (PsySigMaskRatio[bandNum]<worstISMR) {
+ worstISMR += (PsySigMaskRatio[bandNum] > 0)?PsySigMaskRatio[bandNum]:worstISMR;
+ }
+ }
+ worstISMR /= 2.0;
+ SigMaskRatio[k+ i* *nr_of_sfb]=worstISMR/window_group_length[i];
+ sfb_offset[index] = sfb_offset[index-1] + sfb_width_table[k]*window_group_length[i] ;
+ index++;
+ }
+ windowOffset += window_group_length[i];
+ }
+
+ *nr_of_sfb = *nr_of_sfb * num_window_groups; /* Number interleaved bands. */
+
+ return 0;
+}
+
--- a/quant.h
+++ b/quant.h
@@ -79,6 +79,15 @@
/*********************************************************/
+/* sort_for_grouping */
+/*********************************************************/
+int sort_for_grouping(AACQuantInfo* quantInfo, /* ptr to quantization information */
+ int sfb_width_table[], /* Widths of single window */
+ double *p_spectrum[], /* Spectral values, noninterleaved */
+ double *SigMaskRatio,
+ double *PsySigMaskRatio);
+
+/*********************************************************/
/* tf_init_encode_spectrum_aac */
/*********************************************************/
void tf_init_encode_spectrum_aac( int quality );