Mercurial > mplayer.hg
comparison mp3lib/sr1.c @ 4150:01d0a5fabf65
runtime cpudetect support #2 - still not working (i can't identify the problems ground, also it produces no sound (no noises), but the init seems to be ok (also i didn't changed anything)...very annoying :( snipp
author | alex |
---|---|
date | Mon, 14 Jan 2002 16:18:43 +0000 |
parents | 2998f74ad64e |
children | ae847143d1d7 |
comparison
equal
deleted
inserted
replaced
4149:9dde9f96f860 | 4150:01d0a5fabf65 |
---|---|
40 int MP3_samplerate=0; // current samplerate | 40 int MP3_samplerate=0; // current samplerate |
41 int MP3_resync=0; | 41 int MP3_resync=0; |
42 int MP3_channels=0; | 42 int MP3_channels=0; |
43 int MP3_bps=2; | 43 int MP3_bps=2; |
44 | 44 |
45 static long outscale = 32768; | 45 static long outscale = 32768; |
46 #include "tabinit.c" | 46 #include "tabinit.c" |
47 | 47 |
48 #if 1 | |
48 extern int mplayer_audio_read(char *buf,int size); | 49 extern int mplayer_audio_read(char *buf,int size); |
49 | 50 |
50 #if 1 | |
51 LOCAL int mp3_read(char *buf,int size){ | 51 LOCAL int mp3_read(char *buf,int size){ |
52 // int len=fread(buf,1,size,mp3_file); | 52 // int len=fread(buf,1,size,mp3_file); |
53 int len=mplayer_audio_read(buf,size); | 53 int len=mplayer_audio_read(buf,size); |
54 if(len>0) MP3_fpos+=len; | 54 if(len>0) MP3_fpos+=len; |
55 // if(len!=size) MP3_eof=1; | 55 // if(len!=size) MP3_eof=1; |
77 | 77 |
78 static int bitindex; | 78 static int bitindex; |
79 static unsigned char *wordpointer; | 79 static unsigned char *wordpointer; |
80 static int bitsleft; | 80 static int bitsleft; |
81 | 81 |
82 unsigned char *pcm_sample; /* az outbuffer CIME */ | 82 unsigned char *pcm_sample; /* outbuffer address */ |
83 int pcm_point = 0; /* ez az outbuffer pozicioja */ | 83 int pcm_point = 0; /* outbuffer offset */ |
84 | 84 |
85 static struct frame fr; | 85 static struct frame fr; |
86 | 86 |
87 static int tabsel_123[2][3][16] = { | 87 static int tabsel_123[2][3][16] = { |
88 { {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,}, | 88 { {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,}, |
121 { | 121 { |
122 unsigned long rval; | 122 unsigned long rval; |
123 // if(MP3_frames>=7741) printf("getbits_fast: bits=%d bitsleft=%d wordptr=%x\n",number_of_bits,bitsleft,wordpointer); | 123 // if(MP3_frames>=7741) printf("getbits_fast: bits=%d bitsleft=%d wordptr=%x\n",number_of_bits,bitsleft,wordpointer); |
124 if((bitsleft-=number_of_bits)<0) return 0; | 124 if((bitsleft-=number_of_bits)<0) return 0; |
125 if(!number_of_bits) return 0; | 125 if(!number_of_bits) return 0; |
126 #if ARCH_X86 | 126 #if (defined(RUNTIME_CPUDETECT) && defined(CAN_COMPILE_X86_ASM)) || defined(ARCH_X86) |
127 rval = bswap_16(*((unsigned short *)wordpointer)); | 127 rval = bswap_16(*((unsigned short *)wordpointer)); |
128 #else | 128 #else |
129 /* | 129 /* |
130 * we may not be able to address unaligned 16-bit data on non-x86 cpus. | 130 * we may not be able to address unaligned 16-bit data on non-x86 cpus. |
131 * Fall back to some portable code. | 131 * Fall back to some portable code. |
164 // printf("Backstep %d (bitsleft=%d)\n",backstep,bitsleft); | 164 // printf("Backstep %d (bitsleft=%d)\n",backstep,bitsleft); |
165 } | 165 } |
166 | 166 |
167 LOCAL int stream_head_read(unsigned char *hbuf,unsigned long *newhead){ | 167 LOCAL int stream_head_read(unsigned char *hbuf,unsigned long *newhead){ |
168 if(mp3_read(hbuf,4) != 4) return FALSE; | 168 if(mp3_read(hbuf,4) != 4) return FALSE; |
169 #if ARCH_X86 | 169 #if (defined(RUNTIME_CPUDETECT) && defined(CAN_COMPILE_X86_ASM)) || defined(ARCH_X86) |
170 *newhead = bswap_32(*((unsigned long *)hbuf)); | 170 *newhead = bswap_32(*((unsigned long *)hbuf)); |
171 #else | 171 #else |
172 /* | 172 /* |
173 * we may not be able to address unaligned 32-bit data on non-x86 cpus. | 173 * we may not be able to address unaligned 32-bit data on non-x86 cpus. |
174 * Fall back to some portable code. | 174 * Fall back to some portable code. |
376 #ifdef USE_FAKE_MONO | 376 #ifdef USE_FAKE_MONO |
377 void MP3_Init(int fakemono){ | 377 void MP3_Init(int fakemono){ |
378 #else | 378 #else |
379 void MP3_Init(){ | 379 void MP3_Init(){ |
380 #endif | 380 #endif |
381 #if 1 | 381 |
382 #if 0 | |
383 #ifdef RUNTIME_CPUDETECT | |
384 #ifdef CAN_COMPILE_X86_ASM | |
385 if (gCpuCaps.hasMMX) | |
386 { | |
387 make_decode_tables_MMX(outscale); | |
388 printf("mp3lib: made decode tables with MMX optimization\n"); | |
389 } | |
390 else | |
391 make_decode_tables(outscale); | |
392 #else | |
393 make_decode_tables(outscale); | |
394 #endif | |
395 #else /* RUNTIME_CPUDETECT */ | |
396 #ifdef HAVE_MMX | |
397 make_decode_tables_MMX(outscale); | |
398 printf("mp3lib: made decode tables with MMX optimization\n"); | |
399 #else | |
400 make_decode_tables(outscale); | |
401 #endif | |
402 #endif /* RUNTIME_CPUDTECT */ | |
403 | |
404 #ifdef USE_FAKE_MONO | |
405 if (fakemono == 1) | |
406 fr.synth = synth_1to1_l; | |
407 else if (fakemono == 2) | |
408 fr.synth = synth_1to1_r; | |
409 else | |
410 fr.synth = synth_1to1; | |
411 #else | |
412 fr.synth = synth_1to1; | |
413 #endif | |
414 fr.synth_mono = synth_1to1_mono2stereo; | |
415 fr.down_sample = 0; | |
416 fr.down_sample_sblimit = SBLIMIT>>(fr.down_sample); | |
417 init_layer2(); | |
418 init_layer3(fr.down_sample_sblimit); | |
419 tables_done_flag = 1; | |
420 | |
421 dct36_func = dct36; | |
422 printf("init layer2&3 finished, tables done\n"); | |
423 | |
424 #ifdef RUNTIME_CPUDETECT | |
425 #ifdef CAN_COMPILE_X86_ASM | |
426 #if 0 | |
427 if(gCpuCaps.hasSSE) | |
428 { | |
429 /* SSE version is buggy */ | |
430 synth_func = synth_1to1_MMX; | |
431 dct64_MMX_func = dct64_MMX_sse; | |
432 printf("mp3lib: using SSE optimized decore!\n"); | |
433 } | |
434 else | |
435 #endif | |
436 if (gCpuCaps.has3DNowExt) | |
437 { | |
438 synth_func = synth_1to1_MMX; | |
439 dct36_func = dct36_3dnowex; | |
440 dct64_MMX_func = dct64_MMX_3dnowex; | |
441 printf("mp3lib: using 3DNow!Ex optimized decore!\n"); | |
442 } | |
443 else | |
444 if (gCpuCaps.has3DNow) | |
445 { | |
446 synth_func = synth_1to1_MMX; | |
447 dct36_func = dct36_3dnow; | |
448 dct64_MMX_func = dct64_MMX_3dnow; | |
449 printf("mp3lib: using 3DNow! optimized decore!\n"); | |
450 } | |
451 else | |
452 if (gCpuCaps.hasMMX) | |
453 { | |
454 synth_func = synth_1to1_MMX; | |
455 dct64_MMX_func = dct64_MMX; | |
456 printf("mp3lib: using MMX optimized decore!\n"); | |
457 } | |
458 else | |
459 if (gCpuCaps.cpuType >= CPUTYPE_I586) | |
460 { | |
461 synth_func = synth_1to1_pent; | |
462 printf("mp3lib: using Pentium optimized decore!\n"); | |
463 } | |
464 else | |
465 { | |
466 synth_func = NULL; /* use default c version */ | |
467 printf("mp3lib: using generic decore!\n"); | |
468 } | |
469 #else /* CAN_COMPILE_X86_ASM */ | |
470 synth_func = NULL; | |
471 printf("mp3lib: using generic decore!\n"); | |
472 #endif | |
473 #else /* RUNTIME_CPUDETECT */ | |
474 | |
475 #if 0 | |
476 /* SSE version is buggy */ | |
477 synth_func = synth_1to1_MMX; | |
478 dct64_MMX_func = dct64_MMX_sse; | |
479 printf("mp3lib: using SSE optimized decore!\n"); | |
480 #endif | |
481 | |
482 #ifdef HAVE_3DNOWEX | |
483 synth_func = synth_1to1_MMX; | |
484 dct36_func = dct36_3dnowex; | |
485 dct64_MMX_func = dct64_MMX_3dnowex; | |
486 printf("mp3lib: using 3DNow!Ex optimized decore!\n"); | |
487 #elif defined(HAVE_3DNOW) | |
488 synth_func = synth_1to1_MMX; | |
489 dct36_func = dct36_3dnow; | |
490 dct64_MMX_func = dct64_MMX_3dnow; | |
491 printf("mp3lib: using 3DNow! optimized decore!\n"); | |
492 #elif defined(HAVE_MMX) | |
493 synth_func = synth_1to1_MMX; | |
494 dct64_MMX_func = dct64_MMX; | |
495 printf("mp3lib: using MMX optimized decore!\n"); | |
496 #elif defined(__CPU__ > 586) | |
497 synth_func = synth_1to1_pent; | |
498 printf("mp3lib: using Pentium optimized decore!\n"); | |
499 #else | |
500 synth_func = NULL; /* use default c version */ | |
501 printf("mp3lib: using generic decore!\n"); | |
502 #endif | |
503 #endif /* RUNTIME_CPUDETECT */ | |
504 | |
505 #else | |
382 #ifdef ARCH_X86 | 506 #ifdef ARCH_X86 |
383 _CpuID=CpuDetect(); | 507 _CpuID=CpuDetect(); |
384 _i586=ipentium(); | 508 _i586=ipentium(); |
385 #ifndef HAVE_MMX | 509 #ifndef HAVE_MMX |
386 _i586 &= 1; | 510 _i586 &= 1; |
419 printf( "mp3lib: Using generic decore.\n"); | 543 printf( "mp3lib: Using generic decore.\n"); |
420 #endif | 544 #endif |
421 #ifdef HAVE_MMX | 545 #ifdef HAVE_MMX |
422 /* Use it for any MMX cpu */ | 546 /* Use it for any MMX cpu */ |
423 if(_has_mmx) | 547 if(_has_mmx) |
548 { | |
424 make_decode_tables_MMX(outscale); | 549 make_decode_tables_MMX(outscale); |
550 printf("mp3lib: made decode tables with MMX optimization\n"); | |
551 } | |
425 else | 552 else |
426 #endif | 553 #endif |
427 make_decode_tables(outscale); | 554 make_decode_tables(outscale); |
428 #ifdef USE_FAKE_MONO | 555 #ifdef USE_FAKE_MONO |
429 if (fakemono == 1) | 556 if (fakemono == 1) |
485 else | 612 else |
486 #endif | 613 #endif |
487 { | 614 { |
488 synth_func = NULL; | 615 synth_func = NULL; |
489 } | 616 } |
490 #else | |
491 | |
492 #ifdef HAVE_MMX | |
493 /* Use it for any MMX cpu */ | |
494 if(gCpuCaps.hasMMX) | |
495 { | |
496 make_decode_tables_MMX(outscale); | |
497 printf("mp3lib: made decode tables with mmx optimization\n"); | |
498 } | |
499 else | |
500 #endif | |
501 make_decode_tables(outscale); | |
502 | |
503 #ifdef USE_FAKE_MONO | |
504 if (fakemono == 1) | |
505 fr.synth=synth_1to1_l; | |
506 else if (fakemono == 2) | |
507 fr.synth=synth_1to1_r; | |
508 else | |
509 fr.synth=synth_1to1; | |
510 #else | |
511 fr.synth=synth_1to1; | |
512 #endif | |
513 fr.synth_mono=synth_1to1_mono2stereo; | |
514 fr.down_sample=0; | |
515 fr.down_sample_sblimit = SBLIMIT>>(fr.down_sample); | |
516 init_layer2(); | |
517 init_layer3(fr.down_sample_sblimit); | |
518 tables_done_flag=1; | |
519 | |
520 dct36_func=dct36; | |
521 /*#ifdef HAVE_SSE | |
522 if(gCpuCaps.hasSSE) | |
523 { | |
524 synth_func=synth_1to1_MMX; | |
525 dct64_MMX_func=dct64_MMX_sse; | |
526 printf("mp3lib: using SSE optimized decore!\n"); | |
527 } | |
528 else | |
529 #endif*/ | |
530 #ifdef HAVE_3DNOWEX | |
531 if (gCpuCaps.has3DNowExt) | |
532 { | |
533 synth_func=synth_1to1_MMX; | |
534 dct36_func=dct36_3dnowex; | |
535 dct64_MMX_func=dct64_MMX_3dnowex; | |
536 printf("mp3lib: using 3DNow!Ex optimized decore!\n"); | |
537 } | |
538 else | |
539 #endif | |
540 #ifdef HAVE_3DNOW | |
541 if (gCpuCaps.has3DNow) | |
542 { | |
543 synth_func=synth_1to1_MMX; | |
544 dct36_func=dct36_3dnow; | |
545 dct64_MMX_func=dct64_MMX_3dnow; | |
546 printf("mp3lib: using 3DNow! optimized decore!\n"); | |
547 } | |
548 else | |
549 #endif | |
550 #ifdef HAVE_MMX | |
551 if (gCpuCaps.hasMMX) | |
552 { | |
553 synth_func=synth_1to1_MMX; | |
554 dct64_MMX_func=dct64_MMX; | |
555 printf("mp3lib: using MMX optimized decore!\n"); | |
556 } | |
557 else | |
558 #endif | |
559 #ifdef ARCH_X86 | |
560 if (gCpuCaps.cpuType == CPUTYPE_I586) | |
561 { | |
562 synth_func=synth_1to1_pent; | |
563 } | |
564 else | |
565 #endif | |
566 { | |
567 synth_func = NULL; /* use default c version */ | |
568 } | |
569 #endif | 617 #endif |
570 } | 618 } |
571 | 619 |
572 #if 0 | 620 #if 0 |
573 | 621 |
615 } | 663 } |
616 // ++MP3_frames; | 664 // ++MP3_frames; |
617 return(pcm_point?pcm_point:2); | 665 return(pcm_point?pcm_point:2); |
618 } | 666 } |
619 | 667 |
620 #if 0 | |
621 | |
622 // Prints last frame header in ascii. | 668 // Prints last frame header in ascii. |
623 void MP3_PrintHeader(){ | 669 void MP3_PrintHeader(){ |
624 static char *modes[4] = { "Stereo", "Joint-Stereo", "Dual-Channel", "Single-Channel" }; | 670 static char *modes[4] = { "Stereo", "Joint-Stereo", "Dual-Channel", "Single-Channel" }; |
625 static char *layers[4] = { "???" , "I", "II", "III" }; | 671 static char *layers[4] = { "???" , "I", "II", "III" }; |
626 | 672 |
627 printf("\rMPEG %s, Layer %s, %ld Hz %d kbit %s, BPF : %ld\n", | 673 printf("\rMPEG %s, Layer %s, %ld Hz %d kbit %s, BPF: %ld\n", |
628 fr.mpeg25 ? "2.5" : (fr.lsf ? "2.0" : "1.0"), | 674 fr.mpeg25 ? "2.5" : (fr.lsf ? "2.0" : "1.0"), |
629 layers[fr.lay],freqs[fr.sampling_frequency], | 675 layers[fr.lay],freqs[fr.sampling_frequency], |
630 tabsel_123[fr.lsf][fr.lay-1][fr.bitrate_index], | 676 tabsel_123[fr.lsf][fr.lay-1][fr.bitrate_index], |
631 modes[fr.mode],fr.framesize+4); | 677 modes[fr.mode],fr.framesize+4); |
632 printf("Channels: %d, copyright: %s, original: %s, CRC: %s, emphasis: %d.\n\n", | 678 printf("Channels: %d, copyright: %s, original: %s, CRC: %s, emphasis: %d\n", |
633 fr.stereo,fr.copyright?"Yes":"No", | 679 fr.stereo,fr.copyright?"Yes":"No", |
634 fr.original?"Yes":"No",fr.error_protection?"Yes":"No", | 680 fr.original?"Yes":"No",fr.error_protection?"Yes":"No", |
635 fr.emphasis); | 681 fr.emphasis); |
636 } | 682 } |
637 | 683 |
684 #if 0 | |
638 #include "genre.h" | 685 #include "genre.h" |
639 | 686 |
640 // Read & print ID3 TAG. Do not call when playing!!! returns filesize. | 687 // Read & print ID3 TAG. Do not call when playing!!! returns filesize. |
641 int MP3_PrintTAG(){ | 688 int MP3_PrintTAG(){ |
642 struct id3tag { | 689 struct id3tag { |