Mercurial > audlegacy
comparison src/audacious/output.c @ 4258:8157686b8115
added FMT_SIZEOF macro
author | Eugene Zagidullin <e.asphyx@gmail.com> |
---|---|
date | Fri, 08 Feb 2008 22:21:56 +0300 |
parents | b0ca963fd965 |
children | 92642f860860 |
comparison
equal
deleted
inserted
replaced
4257:b1f879a0bfcb | 4258:8157686b8115 |
---|---|
117 {FMT_FLOAT, SAD_SAMPLE_FLOAT}, | 117 {FMT_FLOAT, SAD_SAMPLE_FLOAT}, |
118 {FMT_FIXED32, SAD_SAMPLE_FIXED32}, | 118 {FMT_FIXED32, SAD_SAMPLE_FIXED32}, |
119 }; | 119 }; |
120 | 120 |
121 static void apply_replaygain_info (ReplayGainInfo *rg_info); | 121 static void apply_replaygain_info (ReplayGainInfo *rg_info); |
122 | |
123 static inline unsigned sample_size(AFormat fmt) { | |
124 switch(fmt) { | |
125 case FMT_S8: | |
126 case FMT_U8: return sizeof(gint8); | |
127 case FMT_S16_NE: | |
128 case FMT_S16_LE: | |
129 case FMT_S16_BE: | |
130 case FMT_U16_NE: | |
131 case FMT_U16_LE: | |
132 case FMT_U16_BE: return sizeof(gint16); | |
133 case FMT_S24_NE: | |
134 case FMT_S24_LE: | |
135 case FMT_S24_BE: | |
136 case FMT_U24_NE: | |
137 case FMT_U24_LE: | |
138 case FMT_U24_BE: | |
139 case FMT_S32_NE: | |
140 case FMT_S32_LE: | |
141 case FMT_S32_BE: | |
142 case FMT_U32_NE: | |
143 case FMT_U32_LE: | |
144 case FMT_U32_BE: | |
145 case FMT_FIXED32: return sizeof(gint32); | |
146 case FMT_FLOAT: return sizeof(float); | |
147 default: return 0; | |
148 } | |
149 } | |
150 | 122 |
151 static SAD_sample_format | 123 static SAD_sample_format |
152 sadfmt_from_afmt(AFormat fmt) | 124 sadfmt_from_afmt(AFormat fmt) |
153 { | 125 { |
154 int i; | 126 int i; |
651 | 623 |
652 #ifdef USE_SRC | 624 #ifdef USE_SRC |
653 if(src_state != NULL) | 625 if(src_state != NULL) |
654 { | 626 { |
655 /*int lrLength = length / nch;*/ | 627 /*int lrLength = length / nch;*/ |
656 int lrLength = length / sample_size(fmt); | 628 int lrLength = length / FMT_SIZEOF(fmt); |
657 int overLrLength = (int)floor(lrLength*(src_data.src_ratio+1)); | 629 int overLrLength = (int)floor(lrLength*(src_data.src_ratio+1)); |
658 if(lengthOfSrcIn < lrLength) | 630 if(lengthOfSrcIn < lrLength) |
659 { | 631 { |
660 lengthOfSrcIn = lrLength; | 632 lengthOfSrcIn = lrLength; |
661 free(srcIn); | 633 free(srcIn); |
665 { | 637 { |
666 lengthOfSrcOut = overLrLength; | 638 lengthOfSrcOut = overLrLength; |
667 free(srcOut); | 639 free(srcOut); |
668 free(wOut); | 640 free(wOut); |
669 srcOut = (float*)malloc(sizeof(float)*overLrLength); | 641 srcOut = (float*)malloc(sizeof(float)*overLrLength); |
670 wOut = (short int*)malloc(sample_size(op_state.fmt) * overLrLength); | 642 wOut = (short int*)malloc(FMT_SIZEOF(op_state.fmt) * overLrLength); |
671 } | 643 } |
672 /*src_short_to_float_array((short int*)ptr, srcIn, lrLength);*/ | 644 /*src_short_to_float_array((short int*)ptr, srcIn, lrLength);*/ |
673 SAD_dither_process_buffer(sad_state_to_float, ptr, srcIn, lrLength / nch); | 645 SAD_dither_process_buffer(sad_state_to_float, ptr, srcIn, lrLength / nch); |
674 src_data.data_in = srcIn; | 646 src_data.data_in = srcIn; |
675 src_data.data_out = srcOut; | 647 src_data.data_out = srcOut; |
683 else | 655 else |
684 { | 656 { |
685 /*src_float_to_short_array(srcOut, wOut, src_data.output_frames_gen*2);*/ | 657 /*src_float_to_short_array(srcOut, wOut, src_data.output_frames_gen*2);*/ |
686 SAD_dither_process_buffer(sad_state_from_float, srcOut, wOut, src_data.output_frames_gen); | 658 SAD_dither_process_buffer(sad_state_from_float, srcOut, wOut, src_data.output_frames_gen); |
687 ptr = wOut; | 659 ptr = wOut; |
688 length = src_data.output_frames_gen * op_state.nch * sample_size(op_state.fmt); | 660 length = src_data.output_frames_gen * op_state.nch * FMT_SIZEOF(op_state.fmt); |
689 } | 661 } |
690 } else | 662 } else |
691 #endif | 663 #endif |
692 if(sad_state != NULL) { | 664 if(sad_state != NULL) { |
693 int frames = length / nch / sample_size(fmt); | 665 int frames = length / nch / FMT_SIZEOF(fmt); |
694 int len = frames * op_state.nch * sample_size(op_state.fmt); | 666 int len = frames * op_state.nch * FMT_SIZEOF(op_state.fmt); |
695 if(sad_out_buf == NULL || sad_out_buf_length < len ) { | 667 if(sad_out_buf == NULL || sad_out_buf_length < len ) { |
696 if(sad_out_buf != NULL) free (sad_out_buf); | 668 if(sad_out_buf != NULL) free (sad_out_buf); |
697 sad_out_buf = malloc(len); | 669 sad_out_buf = malloc(len); |
698 sad_out_buf_length = len; | 670 sad_out_buf_length = len; |
699 } | 671 } |