comparison decoders/mpglib/layer3.c @ 274:9e7f9e09ea0e

Removed fprintf() calls. Replaced with SNDDBG() and Sound_SetError() calls.
author Ryan C. Gordon <icculus@icculus.org>
date Sun, 10 Mar 2002 19:15:25 +0000
parents 9b6e82f7c853
children 52b9f37998db
comparison
equal deleted inserted replaced
273:e1429f96aded 274:9e7f9e09ea0e
4 * copyright (c) 1995,1996,1997 by Michael Hipp. 4 * copyright (c) 1995,1996,1997 by Michael Hipp.
5 * All rights reserved. See also 'README' 5 * All rights reserved. See also 'README'
6 */ 6 */
7 7
8 #include <stdlib.h> 8 #include <stdlib.h>
9
10 #include "SDL_sound.h"
11
12 #define __SDL_SOUND_INTERNAL__
13 #include "SDL_sound_internal.h"
14
9 #include "mpg123_sdlsound.h" 15 #include "mpg123_sdlsound.h"
10 #include "mpglib_sdlsound.h" 16 #include "mpglib_sdlsound.h"
11 #include "huffman.h" 17 #include "huffman.h"
12 18
13 extern struct mpstr *gmp; 19 extern struct mpstr *gmp;
318 register struct gr_info_s *gr_info = &(si->ch[ch].gr[gr]); 324 register struct gr_info_s *gr_info = &(si->ch[ch].gr[gr]);
319 325
320 gr_info->part2_3_length = getbits(12); 326 gr_info->part2_3_length = getbits(12);
321 gr_info->big_values = getbits_fast(9); 327 gr_info->big_values = getbits_fast(9);
322 if(gr_info->big_values > 288) { 328 if(gr_info->big_values > 288) {
323 fprintf(stderr,"big_values too large!\n"); 329 SNDDBG("MPGLIB: big_values too large!\n");
324 gr_info->big_values = 288; 330 gr_info->big_values = 288;
325 } 331 }
326 gr_info->pow2gain = gainpow2+256 - getbits_fast(8) + powdiff; 332 gr_info->pow2gain = gainpow2+256 - getbits_fast(8) + powdiff;
327 if(ms_stereo) 333 if(ms_stereo)
328 gr_info->pow2gain += 2; 334 gr_info->pow2gain += 2;
342 gr_info->table_select[2] = 0; 348 gr_info->table_select[2] = 0;
343 for(i=0;i<3;i++) 349 for(i=0;i<3;i++)
344 gr_info->full_gain[i] = gr_info->pow2gain + (getbits_fast(3)<<3); 350 gr_info->full_gain[i] = gr_info->pow2gain + (getbits_fast(3)<<3);
345 351
346 if(gr_info->block_type == 0) { 352 if(gr_info->block_type == 0) {
347 fprintf(stderr,"Blocktype == 0 and window-switching == 1 not allowed.\n"); 353 Sound_SetError("MPGLIB: Blocktype == 0 and window-switching == 1 not allowed.");
348 return 0; 354 return 0;
349 } 355 }
350 /* region_count/start parameters are implicit in this case. */ 356 /* region_count/start parameters are implicit in this case. */
351 gr_info->region1start = 36>>1; 357 gr_info->region1start = 36>>1;
352 gr_info->region2start = 576>>1; 358 gr_info->region2start = 576>>1;
392 register struct gr_info_s *gr_info = &(si->ch[ch].gr[0]); 398 register struct gr_info_s *gr_info = &(si->ch[ch].gr[0]);
393 399
394 gr_info->part2_3_length = getbits(12); 400 gr_info->part2_3_length = getbits(12);
395 gr_info->big_values = getbits_fast(9); 401 gr_info->big_values = getbits_fast(9);
396 if(gr_info->big_values > 288) { 402 if(gr_info->big_values > 288) {
397 fprintf(stderr,"big_values too large!\n"); 403 SNDDBG("MPGLIB: big_values too large!\n");
398 gr_info->big_values = 288; 404 gr_info->big_values = 288;
399 } 405 }
400 gr_info->pow2gain = gainpow2+256 - getbits_fast(8) + powdiff; 406 gr_info->pow2gain = gainpow2+256 - getbits_fast(8) + powdiff;
401 if(ms_stereo) 407 if(ms_stereo)
402 gr_info->pow2gain += 2; 408 gr_info->pow2gain += 2;
416 gr_info->table_select[2] = 0; 422 gr_info->table_select[2] = 0;
417 for(i=0;i<3;i++) 423 for(i=0;i<3;i++)
418 gr_info->full_gain[i] = gr_info->pow2gain + (getbits_fast(3)<<3); 424 gr_info->full_gain[i] = gr_info->pow2gain + (getbits_fast(3)<<3);
419 425
420 if(gr_info->block_type == 0) { 426 if(gr_info->block_type == 0) {
421 fprintf(stderr,"Blocktype == 0 and window-switching == 1 not allowed.\n"); 427 Sound_SetError("MPGLIB: Blocktype == 0 and window-switching == 1 not allowed.");
422 return 0; 428 return 0;
423 } 429 }
424 /* region_count/start parameters are implicit in this case. */ 430 /* region_count/start parameters are implicit in this case. */
425 /* check this again! */ 431 /* check this again! */
426 if(gr_info->block_type == 2) 432 if(gr_info->block_type == 2)
951 part2remain -= 16; 957 part2remain -= 16;
952 } 958 }
953 if(part2remain > 0) 959 if(part2remain > 0)
954 getbits(part2remain); 960 getbits(part2remain);
955 else if(part2remain < 0) { 961 else if(part2remain < 0) {
956 fprintf(stderr,"mpg123: Can't rewind stream by %d bits!\n",-part2remain); 962 Sound_SetError("MPGLIB: Can't rewind stream!"); /* !!! FIXME: Need formatting: by %d bits!\n",-part2remain);*/
957 return 1; /* -> error */ 963 return 1; /* -> error */
958 } 964 }
959 return 0; 965 return 0;
960 } 966 }
961 967
1362 part2remain -= 16; 1368 part2remain -= 16;
1363 } 1369 }
1364 if(part2remain > 0 ) 1370 if(part2remain > 0 )
1365 getbits(part2remain); 1371 getbits(part2remain);
1366 else if(part2remain < 0) { 1372 else if(part2remain < 0) {
1367 fprintf(stderr,"mpg123_ms: Can't rewind stream by %d bits!\n",-part2remain); 1373 Sound_SetError("MPGLIB: Can't rewind stream!"); /* !!! FIXME: Need formatting: by %d bits!\n",-part2remain); */
1368 return 1; /* -> error */ 1374 return 1; /* -> error */
1369 } 1375 }
1370 return 0; 1376 return 0;
1371 } 1377 }
1372 #endif 1378 #endif
1900 granules = 2; 1906 granules = 2;
1901 #ifdef MPEG1 1907 #ifdef MPEG1
1902 if(!III_get_side_info_1(&sideinfo,stereo,ms_stereo,sfreq,single)) 1908 if(!III_get_side_info_1(&sideinfo,stereo,ms_stereo,sfreq,single))
1903 return -1; 1909 return -1;
1904 #else 1910 #else
1905 fprintf(stderr,"Not supported\n"); 1911 Sound_SetError("MPGLIB: Not supported!");
1906 #endif 1912 #endif
1907 } 1913 }
1908 1914
1909 if(set_pointer(sideinfo.main_data_begin) == MP3_ERR) 1915 if(set_pointer(sideinfo.main_data_begin) == MP3_ERR)
1910 return -1; 1916 return -1;
1921 part2bits = III_get_scale_factors_2(scalefacs[0],gr_info,0); 1927 part2bits = III_get_scale_factors_2(scalefacs[0],gr_info,0);
1922 else { 1928 else {
1923 #ifdef MPEG1 1929 #ifdef MPEG1
1924 part2bits = III_get_scale_factors_1(scalefacs[0],gr_info); 1930 part2bits = III_get_scale_factors_1(scalefacs[0],gr_info);
1925 #else 1931 #else
1926 fprintf(stderr,"Not supported\n"); 1932 Sound_SetError("MPGLIB: Not supported!");
1927 #endif 1933 #endif
1928 } 1934 }
1929 if(III_dequantize_sample(hybridIn[0], scalefacs[0],gr_info,sfreq,part2bits)) 1935 if(III_dequantize_sample(hybridIn[0], scalefacs[0],gr_info,sfreq,part2bits))
1930 return clip; 1936 return clip;
1931 } 1937 }
1936 part2bits = III_get_scale_factors_2(scalefacs[1],gr_info,i_stereo); 1942 part2bits = III_get_scale_factors_2(scalefacs[1],gr_info,i_stereo);
1937 else { 1943 else {
1938 #ifdef MPEG1 1944 #ifdef MPEG1
1939 part2bits = III_get_scale_factors_1(scalefacs[1],gr_info); 1945 part2bits = III_get_scale_factors_1(scalefacs[1],gr_info);
1940 #else 1946 #else
1941 fprintf(stderr,"Not supported\n"); 1947 Sound_SetError("MPGLIB: Not supported!");
1942 #endif 1948 #endif
1943 } 1949 }
1944 1950
1945 if(III_dequantize_sample(hybridIn[1],scalefacs[1],gr_info,sfreq,part2bits)) 1951 if(III_dequantize_sample(hybridIn[1],scalefacs[1],gr_info,sfreq,part2bits))
1946 return clip; 1952 return clip;