ReactOS 0.4.16-dev-306-g647d351
optimize.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ALIGNED(a)
 
#define opt_dct36(fr)   dct36
 

Enumerations

enum  optdec {
  autodec =0 , generic , generic_dither , idrei ,
  ivier , ifuenf , ifuenf_dither , mmx ,
  dreidnow , dreidnowext , altivec , sse ,
  x86_64 , arm , neon , neon64 ,
  avx , dreidnow_vintage , dreidnowext_vintage , sse_vintage ,
  nodec
}
 
enum  optcla { nocla =0 , normal , mmxsse }
 

Functions

int frame_cpu_opt (mpg123_handle *fr, const char *cpu)
 
int set_synth_functions (mpg123_handle *fr)
 
enum optdec dectype (const char *decoder)
 
enum optdec defdec (void)
 
enum optcla decclass (const enum optdec)
 
void check_decoders (void)
 

Macro Definition Documentation

◆ ALIGNED

#define ALIGNED (   a)

Definition at line 190 of file optimize.h.

◆ opt_dct36

#define opt_dct36 (   fr)    dct36

Definition at line 391 of file optimize.h.

Enumeration Type Documentation

◆ optcla

Enumerator
nocla 
normal 
mmxsse 

Definition at line 166 of file optimize.h.

166{ nocla=0, normal, mmxsse };
@ mmxsse
Definition: optimize.h:166
@ nocla
Definition: optimize.h:166
@ normal
Definition: optimize.h:166

◆ optdec

Enumerator
autodec 
generic 
generic_dither 
idrei 
ivier 
ifuenf 
ifuenf_dither 
mmx 
dreidnow 
dreidnowext 
altivec 
sse 
x86_64 
arm 
neon 
neon64 
avx 
dreidnow_vintage 
dreidnowext_vintage 
sse_vintage 
nodec 

Definition at line 94 of file optimize.h.

95{
96 autodec=0
97 ,generic
99 ,idrei
100 ,ivier
101 ,ifuenf
103 ,mmx
104 ,dreidnow
106 ,altivec
107 ,sse
108 ,x86_64
109 ,arm
110 ,neon
111 ,neon64
112 ,avx
116 ,nodec
117};
@ avx
Definition: optimize.h:112
@ ivier
Definition: optimize.h:100
@ x86_64
Definition: optimize.h:108
@ neon64
Definition: optimize.h:111
@ dreidnowext_vintage
Definition: optimize.h:114
@ dreidnow
Definition: optimize.h:104
@ nodec
Definition: optimize.h:116
@ sse_vintage
Definition: optimize.h:115
@ generic_dither
Definition: optimize.h:98
@ ifuenf
Definition: optimize.h:101
@ altivec
Definition: optimize.h:106
@ autodec
Definition: optimize.h:96
@ arm
Definition: optimize.h:109
@ dreidnowext
Definition: optimize.h:105
@ sse
Definition: optimize.h:107
@ ifuenf_dither
Definition: optimize.h:102
@ mmx
Definition: optimize.h:103
@ generic
Definition: optimize.h:97
@ neon
Definition: optimize.h:110
@ dreidnow_vintage
Definition: optimize.h:113
@ idrei
Definition: optimize.h:99

Function Documentation

◆ check_decoders()

void check_decoders ( void  )

Definition at line 1084 of file optimize.c.

1085{
1086#ifndef OPT_MULTI
1087 /* In non-multi mode, only the full list (one entry) is used. */
1088 return;
1089#else
1090 const char **d = mpg123_supported_decoder_list;
1091#if (defined OPT_X86) || (defined OPT_X86_64) || (defined OPT_NEON) || (defined OPT_NEON64)
1093#endif
1094#ifdef OPT_X86
1095 if(cpu_i586(cpu_flags))
1096 {
1097 /* not yet: if(cpu_sse2(cpu_flags)) printf(" SSE2");
1098 if(cpu_sse3(cpu_flags)) printf(" SSE3"); */
1099#ifdef OPT_SSE
1100 if(cpu_sse(cpu_flags)) *(d++) = dn_sse;
1101#endif
1102#ifdef OPT_SSE_VINTAGE
1103 if(cpu_sse(cpu_flags)) *(d++) = dn_sse_vintage;
1104#endif
1105#ifdef OPT_3DNOWEXT
1106 if(cpu_3dnowext(cpu_flags)) *(d++) = dn_dreidnowext;
1107#endif
1108#ifdef OPT_3DNOWEXT_VINTAGE
1109 if(cpu_3dnowext(cpu_flags)) *(d++) = dn_dreidnowext_vintage;
1110#endif
1111#ifdef OPT_3DNOW
1112 if(cpu_3dnow(cpu_flags)) *(d++) = dn_dreidnow;
1113#endif
1114#ifdef OPT_3DNOW_VINTAGE
1115 if(cpu_3dnow(cpu_flags)) *(d++) = dn_dreidnow_vintage;
1116#endif
1117#ifdef OPT_MMX
1118 if(cpu_mmx(cpu_flags)) *(d++) = dn_mmx;
1119#endif
1120#ifdef OPT_I586
1121 *(d++) = dn_ifuenf;
1122#endif
1123#ifdef OPT_I586_DITHER
1124 *(d++) = dn_ifuenf_dither;
1125#endif
1126 }
1127#endif
1128/* just assume that the i486 built is run on a i486 cpu... */
1129#ifdef OPT_I486
1130 *(d++) = dn_ivier;
1131#endif
1132#ifdef OPT_ALTIVEC
1133 *(d++) = dn_altivec;
1134#endif
1135/* every supported x86 can do i386, any cpu can do generic */
1136#ifdef OPT_I386
1137 *(d++) = dn_idrei;
1138#endif
1139#ifdef OPT_AVX
1140 if(cpu_avx(cpu_flags)) *(d++) = dn_avx;
1141#endif
1142#ifdef OPT_X86_64
1143 *(d++) = dn_x86_64;
1144#endif
1145#ifdef OPT_ARM
1146 *(d++) = dn_arm;
1147#endif
1148#ifdef OPT_NEON
1149 if(cpu_neon(cpu_flags)) *(d++) = dn_neon;
1150#endif
1151#ifdef OPT_NEON64
1152 if(cpu_neon(cpu_flags)) *(d++) = dn_neon64;
1153#endif
1154#ifdef OPT_GENERIC
1155 *(d++) = dn_generic;
1156#endif
1157#ifdef OPT_GENERIC_DITHER
1158 *(d++) = dn_generic_dither;
1159#endif
1160#endif /* ndef OPT_MULTI */
1161}
#define getcpuflags
Definition: intsym.h:206
#define d
Definition: ke_i.h:81
#define cpu_3dnow(s)
Definition: optimize.c:25
#define cpu_avx(s)
Definition: optimize.c:30
#define cpu_flags
Definition: optimize.c:21
#define cpu_mmx(s)
Definition: optimize.c:24
#define cpu_3dnowext(s)
Definition: optimize.c:26
#define cpu_i586(s)
Definition: optimize.c:22
#define cpu_neon(s)
Definition: optimize.c:31
#define cpu_sse(s)
Definition: optimize.c:27

◆ decclass()

enum optcla decclass ( const enum  optdec)

Definition at line 141 of file optimize.c.

142{
143 return
144 (
145 type == mmx
146 || type == sse
147 || type == sse_vintage
148 || type == dreidnowext
150 || type == x86_64
151 || type == neon
152 || type == neon64
153 || type == avx
154 ) ? mmxsse : normal;
155}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

◆ dectype()

enum optdec dectype ( const char decoder)

Definition at line 940 of file optimize.c.

941{
942 enum optdec dt;
943 if( (decoder == NULL)
944 || (decoder[0] == 0) )
945 return autodec;
946
947 for(dt=autodec; dt<nodec; ++dt)
948 if(!strcasecmp(decoder, decname[dt])) return dt;
949
950 return nodec; /* If we found nothing... */
951}
#define NULL
Definition: types.h:112
#define strcasecmp
Definition: fake.h:9
optdec
Definition: optimize.h:95

◆ defdec()

enum optdec defdec ( void  )

Definition at line 139 of file optimize.c.

139{ return defopt; }

◆ frame_cpu_opt()

int frame_cpu_opt ( mpg123_handle fr,
const char cpu 
)

Definition at line 496 of file optimize.c.

497{
498 const char* chosen = ""; /* the chosen decoder opt as string */
499 enum optdec want_dec = nodec;
500 int done = 0;
501 int auto_choose = 0;
502#ifdef OPT_DITHER
503 int dithered = FALSE; /* If some dithered decoder is chosen. */
504#endif
505
506 want_dec = dectype(cpu);
507 auto_choose = want_dec == autodec;
508 /* Fill whole array of synth functions with generic code first. */
509 fr->synths = synth_base;
510
511#ifndef OPT_MULTI
512 {
513 if(!auto_choose && want_dec != defopt)
514 {
515 if(NOQUIET) error2("you wanted decoder type %i, I only have %i", want_dec, defopt);
516 }
517 auto_choose = TRUE; /* There will be only one choice anyway. */
518 }
519#endif
520
521 fr->cpu_opts.type = nodec;
522#ifdef OPT_MULTI
523#ifndef NO_LAYER3
524#if (defined OPT_3DNOW_VINTAGE || defined OPT_3DNOWEXT_VINTAGE || defined OPT_SSE || defined OPT_X86_64 || defined OPT_AVX || defined OPT_NEON || defined OPT_NEON64)
525 fr->cpu_opts.the_dct36 = dct36;
526#endif
527#endif
528#endif
529 /* covers any i386+ cpu; they actually differ only in the synth_1to1 function, mostly... */
530#ifdef OPT_X86
532 {
533# ifdef OPT_MULTI
534 debug2("standard flags: 0x%08x\textended flags: 0x%08x", cpu_flags.std, cpu_flags.ext);
535# endif
536# ifdef OPT_SSE
537 if( !done && (auto_choose || want_dec == sse)
539 {
540 chosen = dn_sse;
541 fr->cpu_opts.type = sse;
542#ifdef OPT_MULTI
543# ifndef NO_LAYER3
544 /* if(cpu_fast_sse(cpu_flags)) */ fr->cpu_opts.the_dct36 = dct36_sse;
545# endif
546#endif
547# ifndef NO_16BIT
548 fr->synths.plain[r_1to1][f_16] = synth_1to1_sse;
549# ifdef ACCURATE_ROUNDING
551# endif
552# endif
553# ifndef NO_REAL
556# endif
557# ifndef NO_32BIT
558 fr->synths.plain[r_1to1][f_32] = synth_1to1_s32_sse;
560# endif
561 done = 1;
562 }
563# endif
564# ifdef OPT_SSE_VINTAGE
565 if( !done && (auto_choose || want_dec == sse_vintage)
567 {
568 chosen = dn_sse_vintage;
569 fr->cpu_opts.type = sse_vintage;
570# ifndef NO_16BIT
571 fr->synths.plain[r_1to1][f_16] = synth_1to1_sse;
572# ifdef ACCURATE_ROUNDING
574# endif
575# endif
576# ifndef NO_REAL
579# endif
580# ifndef NO_32BIT
581 fr->synths.plain[r_1to1][f_32] = synth_1to1_s32_sse;
583# endif
584 done = 1;
585 }
586# endif
587# ifdef OPT_3DNOWEXT
588 if( !done && (auto_choose || want_dec == dreidnowext)
591 && cpu_mmx(cpu_flags) )
592 {
593 chosen = dn_dreidnowext;
594 fr->cpu_opts.type = dreidnowext;
595# ifndef NO_16BIT
597# endif
598 done = 1;
599 }
600# endif
601# ifdef OPT_3DNOWEXT_VINTAGE
602 if( !done && (auto_choose || want_dec == dreidnowext_vintage)
605 && cpu_mmx(cpu_flags) )
606 {
607 chosen = dn_dreidnowext_vintage;
608 fr->cpu_opts.type = dreidnowext_vintage;
609#ifdef OPT_MULTI
610# ifndef NO_LAYER3
611 fr->cpu_opts.the_dct36 = dct36_3dnowext;
612# endif
613#endif
614# ifndef NO_16BIT
616# endif
617 done = 1;
618 }
619# endif
620# ifdef OPT_3DNOW
621 if( !done && (auto_choose || want_dec == dreidnow)
623 {
624 chosen = dn_dreidnow;
625 fr->cpu_opts.type = dreidnow;
626# ifndef NO_16BIT
627 fr->synths.plain[r_1to1][f_16] = synth_1to1_3dnow;
628# endif
629 done = 1;
630 }
631# endif
632# ifdef OPT_3DNOW_VINTAGE
633 if( !done && (auto_choose || want_dec == dreidnow_vintage)
635 {
636 chosen = dn_dreidnow_vintage;
637 fr->cpu_opts.type = dreidnow_vintage;
638#ifdef OPT_MULTI
639# ifndef NO_LAYER3
640 fr->cpu_opts.the_dct36 = dct36_3dnow;
641# endif
642#endif
643# ifndef NO_16BIT
644 fr->synths.plain[r_1to1][f_16] = synth_1to1_3dnow;
645# endif
646 done = 1;
647 }
648# endif
649 #ifdef OPT_MMX
650 if( !done && (auto_choose || want_dec == mmx)
651 && cpu_mmx(cpu_flags) )
652 {
653 chosen = dn_mmx;
654 fr->cpu_opts.type = mmx;
655# ifndef NO_16BIT
656 fr->synths.plain[r_1to1][f_16] = synth_1to1_mmx;
657# endif
658 done = 1;
659 }
660 #endif
661 #ifdef OPT_I586
662 if(!done && (auto_choose || want_dec == ifuenf))
663 {
664 chosen = "i586/pentium";
665 fr->cpu_opts.type = ifuenf;
666# ifndef NO_16BIT
667 fr->synths.plain[r_1to1][f_16] = synth_1to1_i586;
668# endif
669 done = 1;
670 }
671 #endif
672 #ifdef OPT_I586_DITHER
673 if(!done && (auto_choose || want_dec == ifuenf_dither))
674 {
675 chosen = "dithered i586/pentium";
676 fr->cpu_opts.type = ifuenf_dither;
677 dithered = TRUE;
678# ifndef NO_16BIT
680# ifndef NO_DOWNSAMPLE
681 fr->synths.plain[r_2to1][f_16] = synth_2to1_dither;
682 fr->synths.plain[r_4to1][f_16] = synth_4to1_dither;
683# endif
684# endif
685 done = 1;
686 }
687 #endif
688 }
689 #ifdef OPT_I486
690 /* That won't cooperate in multi opt mode - forcing i486 in layer3.c
691 But still... here it is... maybe for real use in future. */
692 if(!done && (auto_choose || want_dec == ivier))
693 {
694 chosen = dn_ivier;
695 fr->cpu_opts.type = ivier;
696 done = 1;
697 }
698 #endif
699 #ifdef OPT_I386
700 if(!done && (auto_choose || want_dec == idrei))
701 {
702 chosen = dn_idrei;
703 fr->cpu_opts.type = idrei;
704 done = 1;
705 }
706 #endif
707
708 if(done)
709 {
710 /*
711 We have chosen some x86 decoder... fillup some i386 stuff.
712 There is an open question about using dithered synth_1to1 for 8bit wrappers.
713 For quality it won't make sense, but wrapped i586_dither wrapped may still be faster...
714 */
715 enum synth_resample ri;
716 enum synth_format fi;
717# ifndef NO_8BIT
718# ifndef NO_16BIT /* possibility to use a 16->8 wrapper... */
719 if(fr->synths.plain[r_1to1][f_16] != synth_base.plain[r_1to1][f_16])
720 {
723 fr->synths.mono2stereo[r_1to1][f_8] = synth_1to1_8bit_wrap_m2s;
724 }
725# endif
726# endif
727 for(ri=0; ri<r_limit; ++ri)
728 for(fi=0; fi<f_limit; ++fi)
729 {
730 if(fr->synths.plain[ri][fi] == synth_base.plain[ri][fi])
731 fr->synths.plain[ri][fi] = plain_i386[ri][fi];
732 }
733 }
734
735#endif /* OPT_X86 */
736
737#ifdef OPT_AVX
738 if(!done && (auto_choose || want_dec == avx) && cpu_avx(cpu_flags))
739 {
740 chosen = "x86-64 (AVX)";
741 fr->cpu_opts.type = avx;
742#ifdef OPT_MULTI
743# ifndef NO_LAYER3
744 fr->cpu_opts.the_dct36 = dct36_avx;
745# endif
746#endif
747# ifndef NO_16BIT
748 fr->synths.plain[r_1to1][f_16] = synth_1to1_avx;
750# endif
751# ifndef NO_REAL
754# endif
755# ifndef NO_32BIT
756 fr->synths.plain[r_1to1][f_32] = synth_1to1_s32_avx;
758# endif
759 done = 1;
760 }
761#endif
762
763#ifdef OPT_X86_64
764 if(!done && (auto_choose || want_dec == x86_64))
765 {
766 chosen = "x86-64 (SSE)";
767 fr->cpu_opts.type = x86_64;
768#ifdef OPT_MULTI
769# ifndef NO_LAYER3
770 fr->cpu_opts.the_dct36 = dct36_x86_64;
771# endif
772#endif
773# ifndef NO_16BIT
774 fr->synths.plain[r_1to1][f_16] = synth_1to1_x86_64;
776# endif
777# ifndef NO_REAL
780# endif
781# ifndef NO_32BIT
784# endif
785 done = 1;
786 }
787#endif
788
789# ifdef OPT_ALTIVEC
790 if(!done && (auto_choose || want_dec == altivec))
791 {
792 chosen = dn_altivec;
793 fr->cpu_opts.type = altivec;
794# ifndef NO_16BIT
795 fr->synths.plain[r_1to1][f_16] = synth_1to1_altivec;
797# endif
798# ifndef NO_REAL
801# endif
802# ifndef NO_32BIT
805# endif
806 done = 1;
807 }
808# endif
809
810# ifdef OPT_NEON
811 if(!done && (auto_choose || want_dec == neon) && cpu_neon(cpu_flags))
812 {
813 chosen = dn_neon;
814 fr->cpu_opts.type = neon;
815#ifdef OPT_MULTI
816# ifndef NO_LAYER3
817 fr->cpu_opts.the_dct36 = dct36_neon;
818# endif
819#endif
820# ifndef NO_16BIT
821 fr->synths.plain[r_1to1][f_16] = synth_1to1_neon;
823# endif
824# ifndef NO_REAL
827# endif
828# ifndef NO_32BIT
831# endif
832 done = 1;
833 }
834# endif
835
836# ifdef OPT_ARM
837 if(!done && (auto_choose || want_dec == arm))
838 {
839 chosen = dn_arm;
840 fr->cpu_opts.type = arm;
841# ifndef NO_16BIT
842 fr->synths.plain[r_1to1][f_16] = synth_1to1_arm;
843# endif
844 done = 1;
845 }
846# endif
847
848# ifdef OPT_NEON64
849 if(!done && (auto_choose || want_dec == neon64) && cpu_neon(cpu_flags))
850 {
851 chosen = dn_neon64;
852 fr->cpu_opts.type = neon64;
853#ifdef OPT_MULTI
854# ifndef NO_LAYER3
855 fr->cpu_opts.the_dct36 = dct36_neon64;
856# endif
857#endif
858# ifndef NO_16BIT
859 fr->synths.plain[r_1to1][f_16] = synth_1to1_neon64;
861# endif
862# ifndef NO_REAL
865# endif
866# ifndef NO_32BIT
869# endif
870 done = 1;
871 }
872# endif
873
874# ifdef OPT_GENERIC
875 if(!done && (auto_choose || want_dec == generic))
876 {
877 chosen = dn_generic;
878 fr->cpu_opts.type = generic;
879 done = 1;
880 }
881# endif
882
883#ifdef OPT_GENERIC_DITHER
884 if(!done && (auto_choose || want_dec == generic_dither))
885 {
886 chosen = "dithered generic";
887 fr->cpu_opts.type = generic_dither;
888 dithered = TRUE;
889# ifndef NO_16BIT
890 fr->synths.plain[r_1to1][f_16] = synth_1to1_dither;
891# ifndef NO_DOWNSAMPLE
892 fr->synths.plain[r_2to1][f_16] = synth_2to1_dither;
893 fr->synths.plain[r_4to1][f_16] = synth_4to1_dither;
894# endif
895# endif
896 done = 1;
897 }
898#endif
899
900 fr->cpu_opts.class = decclass(fr->cpu_opts.type);
901
902# ifndef NO_8BIT
903# ifndef NO_16BIT /* possibility to use a 16->8 wrapper... */
904 /* Last chance to use some optimized routine via generic wrappers (for 8bit). */
905 if( fr->cpu_opts.type != ifuenf_dither
906 && fr->cpu_opts.type != generic_dither
907 && fr->synths.plain[r_1to1][f_16] != synth_base.plain[r_1to1][f_16] )
908 {
911 fr->synths.mono2stereo[r_1to1][f_8] = synth_1to1_8bit_wrap_m2s;
912 }
913# endif
914# endif
915
916#ifdef OPT_DITHER
917 if(done && dithered)
918 {
919 /* run-time dither noise table generation */
920 if(!frame_dither_init(fr))
921 {
922 if(NOQUIET) error("Dither noise setup failed!");
923 return 0;
924 }
925 }
926#endif
927
928 if(done)
929 {
930 if(VERBOSE) fprintf(stderr, "Decoder: %s\n", chosen);
931 return 1;
932 }
933 else
934 {
935 if(NOQUIET) error("Could not set optimization!");
936 return 0;
937 }
938}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define synth_1to1_real_sse
Definition: intsym.h:90
#define synth_1to1_s32_stereo_x86_64
Definition: intsym.h:120
#define synth_1to1_s32_avx
Definition: intsym.h:121
#define synth_1to1_8bit_wrap_mono
Definition: intsym.h:75
#define dct36_3dnowext
Definition: intsym.h:148
#define synth_1to1_x86_64
Definition: intsym.h:45
#define synth_1to1_s32_x86_64
Definition: intsym.h:119
#define synth_1to1_real_stereo_x86_64
Definition: intsym.h:93
#define synth_1to1_stereo_neon64
Definition: intsym.h:53
#define synth_1to1_stereo_x86_64
Definition: intsym.h:46
#define synth_1to1_stereo_altivec
Definition: intsym.h:44
#define synth_1to1_real_altivec
Definition: intsym.h:96
#define synth_1to1_stereo_sse
Definition: intsym.h:41
#define synth_1to1_i586_dither
Definition: intsym.h:37
#define synth_1to1_i586
Definition: intsym.h:36
#define synth_1to1_mmx
Definition: intsym.h:38
#define synth_1to1_real_stereo_sse
Definition: intsym.h:91
#define synth_1to1_s32_stereo_neon
Definition: intsym.h:126
#define dct36_3dnow
Definition: intsym.h:147
#define dct36
Definition: intsym.h:146
#define synth_1to1_sse
Definition: intsym.h:40
#define dct36_avx
Definition: intsym.h:151
#define synth_1to1_s32_sse
Definition: intsym.h:117
#define synth_1to1_avx
Definition: intsym.h:47
#define dct36_sse
Definition: intsym.h:150
#define dct36_x86_64
Definition: intsym.h:149
#define synth_1to1_fltst_avx
Definition: intsym.h:95
#define decclass
Definition: intsym.h:235
#define synth_1to1_s32_stereo_avx
Definition: intsym.h:122
#define synth_1to1_8bit_wrap_m2s
Definition: intsym.h:76
#define synth_1to1_real_avx
Definition: intsym.h:94
#define synth_1to1_dither
Definition: intsym.h:34
#define dectype
Definition: intsym.h:233
#define synth_1to1_s32_stereo_sse
Definition: intsym.h:118
#define synth_1to1_real_neon64
Definition: intsym.h:100
#define synth_1to1_real_x86_64
Definition: intsym.h:92
#define synth_1to1_fltst_neon64
Definition: intsym.h:101
#define synth_1to1_s32_neon64
Definition: intsym.h:127
#define dct36_neon64
Definition: intsym.h:153
#define synth_1to1_fltst_altivec
Definition: intsym.h:97
#define synth_1to1_arm
Definition: intsym.h:49
#define synth_1to1_s32st_neon64
Definition: intsym.h:128
#define synth_2to1_dither
Definition: intsym.h:58
#define synth_1to1_real_stereo_neon
Definition: intsym.h:99
#define synth_1to1_altivec
Definition: intsym.h:43
#define synth_4to1_dither
Definition: intsym.h:63
#define synth_1to1_stereo_neon
Definition: intsym.h:51
#define synth_1to1_neon
Definition: intsym.h:50
#define synth_1to1_8bit_wrap
Definition: intsym.h:72
#define synth_1to1_3dnowext
Definition: intsym.h:42
#define dct36_neon
Definition: intsym.h:152
#define synth_1to1_neon64
Definition: intsym.h:52
#define synth_1to1_s32_altivec
Definition: intsym.h:123
#define synth_1to1_s32_neon
Definition: intsym.h:125
#define frame_dither_init
Definition: intsym.h:177
#define synth_1to1_s32_stereo_altivec
Definition: intsym.h:124
#define synth_1to1_stereo_avx
Definition: intsym.h:48
#define synth_1to1_real_neon
Definition: intsym.h:98
#define synth_1to1_3dnow
Definition: intsym.h:39
#define error(str)
Definition: mkdosfs.c:1605
#define VERBOSE
#define NOQUIET
static const struct synth_s synth_base
Definition: optimize.c:79
#define debug2(s, a, b)
Definition: debug.h:62
#define error2(s, a, b)
Definition: debug.h:126
struct synth_s synths
Definition: frame.h:160
struct mpg123_handle_struct::@3459 cpu_opts
synth_format
Definition: synths.h:28
@ f_real
Definition: synths.h:37
@ f_8
Definition: synths.h:34
@ f_limit
Definition: synths.h:42
@ f_32
Definition: synths.h:40
@ f_16
Definition: synths.h:31
synth_resample
Definition: synths.h:15
@ r_2to1
Definition: synths.h:19
@ r_4to1
Definition: synths.h:20
@ r_1to1
Definition: synths.h:17
@ r_limit
Definition: synths.h:25

◆ set_synth_functions()

int set_synth_functions ( mpg123_handle fr)

Definition at line 363 of file optimize.c.

364{
365 enum synth_resample resample = r_none;
366 enum synth_format basic_format = f_none; /* Default is always 16bit, or whatever. */
367
368 /* Select the basic output format, different from 16bit: 8bit, real. */
369 if(FALSE){}
370#ifndef NO_16BIT
371 else if(fr->af.dec_enc & MPG123_ENC_16)
372 basic_format = f_16;
373#endif
374#ifndef NO_8BIT
375 else if(fr->af.dec_enc & MPG123_ENC_8)
376 basic_format = f_8;
377#endif
378#ifndef NO_REAL
379 else if(fr->af.dec_enc & MPG123_ENC_FLOAT)
380 basic_format = f_real;
381#endif
382#ifndef NO_32BIT
383 /* 24 bit integer means decoding to 32 bit first. */
384 else if(fr->af.dec_enc & MPG123_ENC_32 || fr->af.dec_enc & MPG123_ENC_24)
385 basic_format = f_32;
386#endif
387
388 /* Make sure the chosen format is compiled into this lib. */
389 if(basic_format == f_none)
390 {
391 if(NOQUIET) error("set_synth_functions: This output format is disabled in this build!");
392
393 return -1;
394 }
395
396 /* Be explicit about downsampling variant. */
397 switch(fr->down_sample)
398 {
399 case 0: resample = r_1to1; break;
400#ifndef NO_DOWNSAMPLE
401 case 1: resample = r_2to1; break;
402 case 2: resample = r_4to1; break;
403#endif
404#ifndef NO_NTOM
405 case 3: resample = r_ntom; break;
406#endif
407 }
408
409 if(resample == r_none)
410 {
411 if(NOQUIET) error("set_synth_functions: This resampling mode is not supported in this build!");
412
413 return -1;
414 }
415
416 debug2("selecting synth: resample=%i format=%i", resample, basic_format);
417 /* Finally selecting the synth functions for stereo / mono. */
418 fr->synth = fr->synths.plain[resample][basic_format];
419 fr->synth_stereo = fr->synths.stereo[resample][basic_format];
420 fr->synth_mono = fr->af.channels==2
421 ? fr->synths.mono2stereo[resample][basic_format] /* Mono MPEG file decoded to stereo. */
422 : fr->synths.mono[resample][basic_format]; /* Mono MPEG file decoded to mono. */
423
424 if(find_dectype(fr) != MPG123_OK) /* Actually determine the currently active decoder breed. */
425 {
427 return MPG123_ERR;
428 }
429
430 if(frame_buffers(fr) != 0)
431 {
433 if(NOQUIET) error("Failed to set up decoder buffers!");
434
435 return MPG123_ERR;
436 }
437
438#ifndef NO_8BIT
439 if(basic_format == f_8)
440 {
441 if(make_conv16to8_table(fr) != 0)
442 {
443 if(NOQUIET) error("Failed to set up conv16to8 table!");
444 /* it's a bit more work to get proper error propagation up */
445 return -1;
446 }
447 }
448#endif
449
450#ifdef OPT_MMXORSSE
451 /* Special treatment for MMX, SSE and 3DNowExt stuff.
452 The real-decoding SSE for x86-64 uses normal tables! */
453 if(fr->cpu_opts.class == mmxsse
454# ifndef NO_REAL
455 && basic_format != f_real
456# endif
457# ifndef NO_32BIT
458 && basic_format != f_32
459# endif
460# ifdef ACCURATE_ROUNDING
461 && fr->cpu_opts.type != sse
462 && fr->cpu_opts.type != sse_vintage
463 && fr->cpu_opts.type != x86_64
464 && fr->cpu_opts.type != neon
465 && fr->cpu_opts.type != neon64
466 && fr->cpu_opts.type != avx
467# endif
468 )
469 {
470#ifndef NO_LAYER3
472#endif
473#ifndef NO_LAYER12
475#endif
477 }
478 else
479#endif
480 {
481#ifndef NO_LAYER3
483#endif
484#ifndef NO_LAYER12
486#endif
488 }
489
490 /* We allocated the table buffers just now, so (re)create the tables. */
491 fr->make_decode_tables(fr);
492
493 return 0;
494}
@ MPG123_ENC_32
Definition: fmt123.h:52
@ MPG123_ENC_8
Definition: fmt123.h:46
@ MPG123_ENC_24
Definition: fmt123.h:50
@ MPG123_ENC_16
Definition: fmt123.h:48
@ MPG123_ENC_FLOAT
Definition: fmt123.h:56
@ MPG123_ERR
Definition: mpg123.h:382
@ MPG123_NO_BUFFERS
Definition: mpg123.h:394
@ MPG123_BAD_DECODER_SETUP
Definition: mpg123.h:420
@ MPG123_OK
Definition: mpg123.h:383
#define init_layer3_stuff
Definition: intsym.h:162
#define init_layer3_gainpow2_mmx
Definition: intsym.h:169
#define init_layer12_table
Definition: intsym.h:164
#define make_conv16to8_table
Definition: intsym.h:171
#define make_decode_tables
Definition: intsym.h:167
#define init_layer3_gainpow2
Definition: intsym.h:161
#define frame_buffers
Definition: intsym.h:183
#define init_layer12_table_mmx
Definition: intsym.h:170
#define init_layer12_stuff
Definition: intsym.h:165
#define make_decode_tables_mmx
Definition: intsym.h:168
static int find_dectype(mpg123_handle *fr)
Definition: optimize.c:190
#define ACCURATE_ROUNDING
Definition: config.h:9
func_synth_mono synth_mono
Definition: frame.h:182
func_synth_stereo synth_stereo
Definition: frame.h:181
struct audioformat af
Definition: frame.h:268
func_synth synth
Definition: frame.h:180
void(* make_decode_tables)(mpg123_handle *fr)
Definition: frame.h:184
@ f_none
Definition: synths.h:29
@ r_none
Definition: synths.h:16
@ r_ntom
Definition: synths.h:23