1 /**********************************************************************
2 * MPEG/Audio Tables I/O routines
3 **********************************************************************/
13 char table_names
[NUMTABLES
][9];
14 long table_offsets
[NUMTABLES
];
16 char table_filename
[250];
18 int pick_table (frame_info
* frame
)
19 /* choose table, load if necess, return # sb's */
21 int table
, lay
, ws
, bsp
, br_per_ch
, sfrq
;
22 int sblim
= frame
->sblimit
; /* return current value if no load */
24 lay
= frame
->header
->lay
- 1;
25 bsp
= frame
->header
->bitrate_index
;
26 br_per_ch
= bitrate
[frame
->header
->version
][bsp
] / frame
->nch
;
27 ws
= frame
->header
->sampling_frequency
;
28 sfrq
= s_freq
[frame
->header
->version
][ws
];
29 /* decision rules refer to per-channel bitrates (kbits/sec/chan) */
30 if (frame
->header
->version
== MPEG_AUDIO_ID
) { /* MPEG-1 */
31 if ((sfrq
== 48 && br_per_ch
>= 56)
32 || (br_per_ch
>= 56 && br_per_ch
<= 80))
34 else if (sfrq
!= 48 && br_per_ch
>= 96)
36 else if (sfrq
!= 32 && br_per_ch
<= 48)
40 } else { /* MPEG-2 LSF */
43 if (frame
->tab_num
!= table
) {
44 if (frame
->tab_num
>= 0)
45 mem_free ((void **) &(frame
->alloc
));
46 frame
->alloc
= (al_table
*) mem_alloc (sizeof (al_table
), "alloc");
47 sblim
= read_bit_alloc (frame
->tab_num
= table
, frame
->alloc
);
53 /***********************************************************************
55 * Read one of the data files ("alloc_*") specifying the bit allocation
56 * quatization parameters for each subband in layer II encoding
58 **********************************************************************/
60 int read_bit_alloc (table
, alloc
) /* read in table, return # subbands */
65 static const int startindex_subband
[5] = { 0, 290, 592, 674, 788 };
67 static const char alloc_subbands
[][20] = {
100 "1 14 32767 15 3 15",
101 "1 15 65535 16 3 16",
115 "2 13 16383 14 3 14",
116 "2 14 32767 15 3 15",
117 "2 15 65535 16 3 16",
133 "3 15 65535 16 3 16",
149 "4 15 65535 16 3 16",
165 "5 15 65535 16 3 16",
181 "6 15 65535 16 3 16",
197 "7 15 65535 16 3 16",
213 "8 15 65535 16 3 16",
229 "9 15 65535 16 3 16",
241 "10 11 1023 10 3 10",
242 "10 12 2047 11 3 11",
243 "10 13 4095 12 3 12",
244 "10 14 8191 13 3 13",
245 "10 15 65535 16 3 16",
253 "11 7 65535 16 3 16 ",
261 "12 7 65535 16 3 16 ",
269 "13 7 65535 16 3 16 ",
277 "14 7 65535 16 3 16 ",
285 "15 7 65535 16 3 16 ",
293 "16 7 65535 16 3 16 ",
301 "17 7 65535 16 3 16 ",
309 "18 7 65535 16 3 16 ",
317 "19 7 65535 16 3 16 ",
325 "20 7 65535 16 3 16 ",
333 "21 7 65535 16 3 16 ",
341 "22 7 65535 16 3 16 ",
345 "23 3 65535 16 3 16",
349 "24 3 65535 16 3 16",
353 "25 3 65535 16 3 16",
357 "26 3 65535 16 3 16",
373 "0 13 16383 14 3 14",
374 "0 14 32767 15 3 15",
375 "0 15 65535 16 3 16",
389 "1 13 16383 14 3 14",
390 "1 14 32767 15 3 15",
391 "1 15 65535 16 3 16",
405 "2 13 16383 14 3 14",
406 "2 14 32767 15 3 15",
407 "2 15 65535 16 3 16",
423 "3 15 65535 16 3 16",
439 "4 15 65535 16 3 16",
455 "5 15 65535 16 3 16",
471 "6 15 65535 16 3 16",
487 "7 15 65535 16 3 16",
503 "8 15 65535 16 3 16",
519 "9 15 65535 16 3 16",
531 "10 11 1023 10 3 10",
532 "10 12 2047 11 3 11",
533 "10 13 4095 12 3 12",
534 "10 14 8191 13 3 13",
535 "10 15 65535 16 3 16",
543 "11 7 65535 16 3 16 ",
551 "12 7 65535 16 3 16 ",
559 "13 7 65535 16 3 16 ",
567 "14 7 65535 16 3 16 ",
575 "15 7 65535 16 3 16 ",
583 "16 7 65535 16 3 16 ",
591 "17 7 65535 16 3 16 ",
599 "18 7 65535 16 3 16 ",
607 "19 7 65535 16 3 16 ",
615 "20 7 65535 16 3 16 ",
623 "21 7 65535 16 3 16 ",
631 "22 7 65535 16 3 16 ",
635 "23 3 65535 16 3 16",
639 "24 3 65535 16 3 16",
643 "25 3 65535 16 3 16",
647 "26 3 65535 16 3 16",
651 "27 3 65535 16 3 16",
655 "28 3 65535 16 3 16",
659 "29 3 65535 16 3 16",
676 "0 14 16383 14 3 14",
677 "0 15 32767 15 3 15",
692 "1 14 16383 14 3 14",
693 "1 15 32767 15 3 15",
758 "0 14 16383 14 3 14",
759 "0 15 32767 15 3 15",
774 "1 14 16383 14 3 14",
775 "1 15 32767 15 3 15",
873 "0 15 16383 14 3 14",
889 "1 15 16383 14 3 14",
905 "2 15 16383 14 3 14",
921 "3 15 16383 14 3 14",
1057 unsigned int a
, b
, c
, d
, i
, j
;
1062 if ((table
< 0) || (table
> 4))
1065 startindex
= startindex_subband
[table
] + 1;
1067 // if (g_verbose) printf("using bit allocation table %d\n", table);
1069 sprintf (t
, "%s", alloc_subbands
[startindex
]);
1071 sscanf (t
, "%d\n", &sblim
);
1073 while (t
[0] != '<') {
1074 sprintf (t
, "%s", alloc_subbands
[startindex
]);
1079 sscanf (t
, "%d %d %d %d %d %d\n", &i
, &j
, &a
, &b
, &c
, &d
);
1080 (*alloc
)[i
][j
].steps
= a
;
1081 (*alloc
)[i
][j
].bits
= b
;
1082 (*alloc
)[i
][j
].group
= c
;
1083 (*alloc
)[i
][j
].quant
= d
;