Mercurial > audlegacy
comparison src/audacious/output.c @ 4240:29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
author | Eugene Zagidullin <e.asphyx@gmail.com> |
---|---|
date | Mon, 04 Feb 2008 01:30:53 +0300 |
parents | 51291ce4eb54 |
children | 21008f43bb93 |
comparison
equal
deleted
inserted
replaced
4239:51291ce4eb54 | 4240:29c8603a877a |
---|---|
50 | 50 |
51 #ifdef USE_SRC | 51 #ifdef USE_SRC |
52 #include <samplerate.h> | 52 #include <samplerate.h> |
53 #endif | 53 #endif |
54 | 54 |
55 #define FMT_FRACBITS(a) ( (a) == FMT_FIXED32 ? __AUDACIOUS_ASSUMED_MAD_F_FRACBITS__ : 0 ) | |
56 | |
55 OutputPluginData op_data = { | 57 OutputPluginData op_data = { |
56 NULL, | 58 NULL, |
57 NULL | 59 NULL |
58 }; | 60 }; |
59 | 61 |
111 {FMT_U32_LE, SAD_SAMPLE_U32_LE}, | 113 {FMT_U32_LE, SAD_SAMPLE_U32_LE}, |
112 {FMT_U32_BE, SAD_SAMPLE_U32_BE}, | 114 {FMT_U32_BE, SAD_SAMPLE_U32_BE}, |
113 {FMT_U32_NE, SAD_SAMPLE_U32}, | 115 {FMT_U32_NE, SAD_SAMPLE_U32}, |
114 | 116 |
115 {FMT_FLOAT, SAD_SAMPLE_FLOAT}, | 117 {FMT_FLOAT, SAD_SAMPLE_FLOAT}, |
118 {FMT_FIXED32, SAD_SAMPLE_FIXED32}, | |
116 }; | 119 }; |
120 | |
121 static void apply_replaygain_info (ReplayGainInfo *rg_info); | |
117 | 122 |
118 static inline unsigned sample_size(AFormat fmt) { | 123 static inline unsigned sample_size(AFormat fmt) { |
119 switch(fmt) { | 124 switch(fmt) { |
120 case FMT_S8: | 125 case FMT_S8: |
121 case FMT_U8: return sizeof(gint8); | 126 case FMT_U8: return sizeof(gint8); |
134 case FMT_S32_NE: | 139 case FMT_S32_NE: |
135 case FMT_S32_LE: | 140 case FMT_S32_LE: |
136 case FMT_S32_BE: | 141 case FMT_S32_BE: |
137 case FMT_U32_NE: | 142 case FMT_U32_NE: |
138 case FMT_U32_LE: | 143 case FMT_U32_LE: |
139 case FMT_U32_BE: return sizeof(gint32); | 144 case FMT_U32_BE: |
145 case FMT_FIXED32: return sizeof(gint32); | |
140 case FMT_FLOAT: return sizeof(float); | 146 case FMT_FLOAT: return sizeof(float); |
141 default: return 0; | 147 default: return 0; |
142 } | 148 } |
143 } | 149 } |
144 | |
145 static void apply_replaygain_info (ReplayGainInfo *rg_info); | |
146 | 150 |
147 static SAD_sample_format | 151 static SAD_sample_format |
148 sadfmt_from_afmt(AFormat fmt) | 152 sadfmt_from_afmt(AFormat fmt) |
149 { | 153 { |
150 int i; | 154 int i; |
418 #ifdef USE_SRC | 422 #ifdef USE_SRC |
419 if (src_enabled) { | 423 if (src_enabled) { |
420 AUDDBG("initializing dithering engine for 2 stage conversion\n"); | 424 AUDDBG("initializing dithering engine for 2 stage conversion\n"); |
421 input_sad_fmt.sample_format = sadfmt_from_afmt(fmt); | 425 input_sad_fmt.sample_format = sadfmt_from_afmt(fmt); |
422 if (input_sad_fmt.sample_format < 0) return FALSE; | 426 if (input_sad_fmt.sample_format < 0) return FALSE; |
423 input_sad_fmt.fracbits = 0; | 427 input_sad_fmt.fracbits = FMT_FRACBITS(fmt); |
424 input_sad_fmt.channels = nch; | 428 input_sad_fmt.channels = nch; |
425 input_sad_fmt.channels_order = SAD_CHORDER_INTERLEAVED; | 429 input_sad_fmt.channels_order = SAD_CHORDER_INTERLEAVED; |
426 input_sad_fmt.samplerate = 0; | 430 input_sad_fmt.samplerate = 0; |
427 | 431 |
428 output_sad_fmt.sample_format = SAD_SAMPLE_FLOAT; | 432 output_sad_fmt.sample_format = SAD_SAMPLE_FLOAT; |
444 input_sad_fmt.channels_order = SAD_CHORDER_INTERLEAVED; | 448 input_sad_fmt.channels_order = SAD_CHORDER_INTERLEAVED; |
445 input_sad_fmt.samplerate = 0; | 449 input_sad_fmt.samplerate = 0; |
446 | 450 |
447 output_sad_fmt.sample_format = sadfmt_from_afmt(output_fmt); | 451 output_sad_fmt.sample_format = sadfmt_from_afmt(output_fmt); |
448 if (output_sad_fmt.sample_format < 0) return FALSE; | 452 if (output_sad_fmt.sample_format < 0) return FALSE; |
449 output_sad_fmt.fracbits = 0; | 453 output_sad_fmt.fracbits = FMT_FRACBITS(output_fmt); |
450 output_sad_fmt.channels = nch; | 454 output_sad_fmt.channels = nch; |
451 output_sad_fmt.channels_order = SAD_CHORDER_INTERLEAVED; | 455 output_sad_fmt.channels_order = SAD_CHORDER_INTERLEAVED; |
452 output_sad_fmt.samplerate = 0; | 456 output_sad_fmt.samplerate = 0; |
453 | 457 |
454 sad_state_from_float = SAD_dither_init(&input_sad_fmt, &output_sad_fmt, &ret); | 458 sad_state_from_float = SAD_dither_init(&input_sad_fmt, &output_sad_fmt, &ret); |
465 { /* needed for RG processing !*/ | 469 { /* needed for RG processing !*/ |
466 AUDDBG("initializing dithering engine for direct conversion\n"); | 470 AUDDBG("initializing dithering engine for direct conversion\n"); |
467 | 471 |
468 input_sad_fmt.sample_format = sadfmt_from_afmt(fmt); | 472 input_sad_fmt.sample_format = sadfmt_from_afmt(fmt); |
469 if (input_sad_fmt.sample_format < 0) return FALSE; | 473 if (input_sad_fmt.sample_format < 0) return FALSE; |
470 input_sad_fmt.fracbits = 0; | 474 input_sad_fmt.fracbits = FMT_FRACBITS(fmt); |
471 input_sad_fmt.channels = nch; | 475 input_sad_fmt.channels = nch; |
472 input_sad_fmt.channels_order = SAD_CHORDER_INTERLEAVED; | 476 input_sad_fmt.channels_order = SAD_CHORDER_INTERLEAVED; |
473 input_sad_fmt.samplerate = 0; /* resampling not implemented yet in libSAD */ | 477 input_sad_fmt.samplerate = 0; /* resampling not implemented yet in libSAD */ |
474 | 478 |
475 output_sad_fmt.sample_format = sadfmt_from_afmt(output_fmt); | 479 output_sad_fmt.sample_format = sadfmt_from_afmt(output_fmt); |
476 output_sad_fmt.fracbits = 0; | 480 output_sad_fmt.fracbits = FMT_FRACBITS(output_fmt); |
477 output_sad_fmt.channels = nch; | 481 output_sad_fmt.channels = nch; |
478 output_sad_fmt.channels_order = SAD_CHORDER_INTERLEAVED; | 482 output_sad_fmt.channels_order = SAD_CHORDER_INTERLEAVED; |
479 output_sad_fmt.samplerate = 0; | 483 output_sad_fmt.samplerate = 0; |
480 | 484 |
481 sad_state = SAD_dither_init(&input_sad_fmt, &output_sad_fmt, &ret); | 485 sad_state = SAD_dither_init(&input_sad_fmt, &output_sad_fmt, &ret); |