1 /* -*- mode: C; mode: fold -*- */
3 * set/get functions for lame_global_flags
5 * Copyright (c) 2001 Alexander Leidinger
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 /* $Id: set_get.c,v 1.1 2002/04/28 17:30:28 kramm Exp $ */
25 #include "config_static.h"
29 #include "bitstream.h" /* because of compute_flushbits */
37 * input stream description
40 /* number of samples */
41 /* it's unlikely for this function to return an error */
43 lame_set_num_samples( lame_global_flags* gfp,
44 unsigned long num_samples)
46 /* default = 2^32-1 */
48 gfp->num_samples = num_samples;
54 lame_get_num_samples( const lame_global_flags* gfp )
56 return gfp->num_samples;
60 /* input samplerate */
62 lame_set_in_samplerate( lame_global_flags* gfp,
65 /* input sample rate in Hz, default = 44100 Hz */
66 gfp->in_samplerate = in_samplerate;
72 lame_get_in_samplerate( const lame_global_flags* gfp )
74 return gfp->in_samplerate;
78 /* number of channels in input stream */
80 lame_set_num_channels( lame_global_flags* gfp,
85 if ( 2 < num_channels || 0 == num_channels )
86 return -1; /* we don't support more than 2 channels */
88 gfp->num_channels = num_channels;
94 lame_get_num_channels( const lame_global_flags* gfp )
96 return gfp->num_channels;
100 /* scale the input by this amount before encoding (not used for decoding) */
102 lame_set_scale( lame_global_flags* gfp,
112 lame_get_scale( const lame_global_flags* gfp )
118 /* scale the channel 0 (left) input by this amount before
119 encoding (not used for decoding) */
121 lame_set_scale_left( lame_global_flags* gfp,
125 gfp->scale_left = scale;
131 lame_get_scale_left( const lame_global_flags* gfp )
133 return gfp->scale_left;
137 /* scale the channel 1 (right) input by this amount before
138 encoding (not used for decoding) */
140 lame_set_scale_right( lame_global_flags* gfp,
144 gfp->scale_right = scale;
150 lame_get_scale_right( const lame_global_flags* gfp )
152 return gfp->scale_right;
156 /* output sample rate in Hz */
158 lame_set_out_samplerate( lame_global_flags* gfp,
162 * default = 0: LAME picks best value based on the amount
165 * MPEG1 32, 44.1, 48khz
166 * MPEG2 16, 22.05, 24
167 * MPEG2.5 8, 11.025, 12
169 * (not used by decoding routines)
171 gfp->out_samplerate = out_samplerate;
177 lame_get_out_samplerate( const lame_global_flags* gfp )
179 return gfp->out_samplerate;
186 * general control parameters
189 /* collect data for an MP3 frame analzyer */
191 lame_set_analysis( lame_global_flags* gfp,
196 /* enforce disable/enable meaning, if we need more than two values
197 we need to switch to an enum to have an apropriate representation
198 of the possible meanings of the value */
199 if ( 0 > analysis || 1 < analysis )
202 gfp->analysis = analysis;
208 lame_get_analysis( const lame_global_flags* gfp )
210 assert( 0 <= gfp->analysis && 1 >= gfp->analysis );
212 return gfp->analysis;
216 /* write a Xing VBR header frame */
218 lame_set_bWriteVbrTag( lame_global_flags* gfp,
221 /* default = 1 (on) for VBR/ABR modes, 0 (off) for CBR mode */
223 /* enforce disable/enable meaning, if we need more than two values
224 we need to switch to an enum to have an apropriate representation
225 of the possible meanings of the value */
226 if ( 0 > bWriteVbrTag || 1 < bWriteVbrTag )
229 gfp->bWriteVbrTag = bWriteVbrTag;
235 lame_get_bWriteVbrTag( const lame_global_flags* gfp )
237 assert( 0 <= gfp->bWriteVbrTag && 1 >= gfp->bWriteVbrTag );
239 return gfp->bWriteVbrTag;
244 /* decode only, use lame/mpglib to convert mp3/ogg to wav */
246 lame_set_decode_only( lame_global_flags* gfp,
249 /* default = 0 (disabled) */
251 /* enforce disable/enable meaning, if we need more than two values
252 we need to switch to an enum to have an apropriate representation
253 of the possible meanings of the value */
254 if ( 0 > decode_only || 1 < decode_only )
257 gfp->decode_only = decode_only;
263 lame_get_decode_only( const lame_global_flags* gfp )
265 assert( 0 <= gfp->decode_only && 1 >= gfp->decode_only );
267 return gfp->decode_only;
271 /* encode a Vorbis .ogg file */
273 lame_set_ogg( lame_global_flags* gfp,
276 /* default = 0 (disabled) */
278 /* enforce disable/enable meaning, if we need more than two values
279 we need to switch to an enum to have an apropriate representation
280 of the possible meanings of the value */
281 if ( 0 > ogg || 1 < ogg )
290 lame_get_ogg( const lame_global_flags* gfp )
292 assert( 0 <= gfp->ogg && 1 >= gfp->ogg );
299 * Internal algorithm selection.
300 * True quality is determined by the bitrate but this variable will effect
301 * quality by selecting expensive or cheap algorithms.
302 * quality=0..9. 0=best (very slow). 9=worst.
303 * recommended: 2 near-best quality, not too slow
304 * 5 good quality, fast
305 * 7 ok quality, really fast
308 lame_set_quality( lame_global_flags* gfp,
311 gfp->quality = quality;
317 lame_get_quality( const lame_global_flags* gfp )
323 /* mode = STEREO, JOINT_STEREO, DUAL_CHANNEL (not supported), MONO */
325 lame_set_mode( lame_global_flags* gfp,
328 /* default: lame chooses based on compression ratio and input channels */
330 if( 0 > mode || MAX_INDICATOR <= mode )
331 return -1; /* Unknown MPEG mode! */
339 lame_get_mode( const lame_global_flags* gfp )
341 assert( 0 <= gfp->mode && MAX_INDICATOR > gfp->mode );
347 /* Us a M/S mode with a switching threshold based on compression ratio */
349 lame_set_mode_automs( lame_global_flags* gfp,
352 /* default = 0 (disabled) */
354 /* enforce disable/enable meaning, if we need more than two values
355 we need to switch to an enum to have an apropriate representation
356 of the possible meanings of the value */
357 if ( 0 > mode_automs || 1 < mode_automs )
360 gfp->mode_automs = mode_automs;
366 lame_get_mode_automs( const lame_global_flags* gfp )
368 assert( 0 <= gfp->mode_automs && 1 >= gfp->mode_automs );
370 return gfp->mode_automs;
375 * Force M/S for all frames. For testing only.
379 lame_set_force_ms( lame_global_flags* gfp,
382 /* default = 0 (disabled) */
384 /* enforce disable/enable meaning, if we need more than two values
385 we need to switch to an enum to have an apropriate representation
386 of the possible meanings of the value */
387 if ( 0 > force_ms || 1 < force_ms )
390 gfp->force_ms = force_ms;
396 lame_get_force_ms( const lame_global_flags* gfp )
398 assert( 0 <= gfp->force_ms && 1 >= gfp->force_ms );
400 return gfp->force_ms;
404 /* Use free_format. */
406 lame_set_free_format( lame_global_flags* gfp,
409 /* default = 0 (disabled) */
411 /* enforce disable/enable meaning, if we need more than two values
412 we need to switch to an enum to have an apropriate representation
413 of the possible meanings of the value */
414 if ( 0 > free_format || 1 < free_format )
417 gfp->free_format = free_format;
423 lame_get_free_format( const lame_global_flags* gfp )
425 assert( 0 <= gfp->free_format && 1 >= gfp->free_format );
427 return gfp->free_format;
431 /* message handlers */
433 lame_set_errorf( lame_global_flags* gfp,
434 void (*func)( const char*, va_list ) )
436 gfp->report.errorf = func;
442 lame_set_debugf( lame_global_flags* gfp,
443 void (*func)( const char*, va_list ) )
445 gfp->report.debugf = func;
451 lame_set_msgf( lame_global_flags* gfp,
452 void (*func)( const char *, va_list ) )
454 gfp->report.msgf = func;
463 * - compression ratio.
465 * Default is compression ratio of 11.
468 lame_set_brate( lame_global_flags* gfp,
477 lame_get_brate( const lame_global_flags* gfp )
483 lame_set_compression_ratio( lame_global_flags* gfp,
484 float compression_ratio )
486 gfp->compression_ratio = compression_ratio;
492 lame_get_compression_ratio( const lame_global_flags* gfp )
494 return gfp->compression_ratio;
504 /* Mark as copyright protected. */
506 lame_set_copyright( lame_global_flags* gfp,
509 /* default = 0 (disabled) */
511 /* enforce disable/enable meaning, if we need more than two values
512 we need to switch to an enum to have an apropriate representation
513 of the possible meanings of the value */
514 if ( 0 > copyright || 1 < copyright )
517 gfp->copyright = copyright;
523 lame_get_copyright( const lame_global_flags* gfp )
525 assert( 0 <= gfp->copyright && 1 >= gfp->copyright );
527 return gfp->copyright;
531 /* Mark as original. */
533 lame_set_original( lame_global_flags* gfp,
536 /* default = 1 (enabled) */
538 /* enforce disable/enable meaning, if we need more than two values
539 we need to switch to an enum to have an apropriate representation
540 of the possible meanings of the value */
541 if ( 0 > original || 1 < original )
544 gfp->original = original;
550 lame_get_original( const lame_global_flags* gfp )
552 assert( 0 <= gfp->original && 1 >= gfp->original );
554 return gfp->original;
560 * Use 2 bytes from each frame for CRC checksum.
563 lame_set_error_protection( lame_global_flags* gfp,
564 int error_protection )
566 /* default = 0 (disabled) */
568 /* enforce disable/enable meaning, if we need more than two values
569 we need to switch to an enum to have an apropriate representation
570 of the possible meanings of the value */
571 if ( 0 > error_protection || 1 < error_protection )
574 gfp->error_protection = error_protection;
580 lame_get_error_protection( const lame_global_flags* gfp )
582 assert( 0 <= gfp->error_protection && 1 >= gfp->error_protection );
584 return gfp->error_protection;
590 * PAD_NO = pad no frames
591 * PAD_ALL = pad all frames
592 * PAD_ADJUST = adjust padding
595 lame_set_padding_type( lame_global_flags* gfp,
596 Padding_type padding_type )
600 if ( 0 > padding_type || PAD_MAX_INDICATOR < padding_type )
601 return -1; /* Unknown padding type */
603 gfp->padding_type = padding_type;
609 lame_get_padding_type( const lame_global_flags* gfp )
611 assert( 0 <= gfp->padding_type && PAD_MAX_INDICATOR > gfp->padding_type );
613 return gfp->padding_type;
617 /* MP3 'private extension' bit. Meaningless. */
619 lame_set_extension( lame_global_flags* gfp,
622 /* default = 0 (disabled) */
624 /* enforce disable/enable meaning, if we need more than two values
625 we need to switch to an enum to have an apropriate representation
626 of the possible meanings of the value */
627 if ( 0 > extension || 1 < extension )
630 gfp->extension = extension;
636 lame_get_extension( const lame_global_flags* gfp )
638 assert( 0 <= gfp->extension && 1 >= gfp->extension );
640 return gfp->extension;
644 /* Enforce strict ISO compliance. */
646 lame_set_strict_ISO( lame_global_flags* gfp,
649 /* default = 0 (disabled) */
651 /* enforce disable/enable meaning, if we need more than two values
652 we need to switch to an enum to have an apropriate representation
653 of the possible meanings of the value */
654 if ( 0 > strict_ISO || 1 < strict_ISO )
657 gfp->strict_ISO = strict_ISO;
663 lame_get_strict_ISO( const lame_global_flags* gfp )
665 assert( 0 <= gfp->strict_ISO && 1 >= gfp->strict_ISO );
667 return gfp->strict_ISO;
673 /********************************************************************
674 * quantization/noise shaping
675 ***********************************************************************/
677 /* Disable the bit reservoir. For testing only. */
679 lame_set_disable_reservoir( lame_global_flags* gfp,
680 int disable_reservoir )
682 /* default = 0 (disabled) */
684 /* enforce disable/enable meaning, if we need more than two values
685 we need to switch to an enum to have an apropriate representation
686 of the possible meanings of the value */
687 if ( 0 > disable_reservoir || 1 < disable_reservoir )
690 gfp->disable_reservoir = disable_reservoir;
696 lame_get_disable_reservoir( const lame_global_flags* gfp )
698 assert( 0 <= gfp->disable_reservoir && 1 >= gfp->disable_reservoir );
700 return gfp->disable_reservoir;
706 /* Select a different "best quantization" function. default = 0 */
708 lame_set_experimentalX( lame_global_flags* gfp,
711 gfp->experimentalX = experimentalX;
717 lame_get_experimentalX( const lame_global_flags* gfp )
719 return gfp->experimentalX;
723 /* Another experimental option. For testing only. */
725 lame_set_experimentalY( lame_global_flags* gfp,
728 gfp->experimentalY = experimentalY;
734 lame_get_experimentalY( const lame_global_flags* gfp )
736 return gfp->experimentalY;
740 /* Another experimental option. For testing only. */
742 lame_set_experimentalZ( lame_global_flags* gfp,
745 gfp->experimentalZ += experimentalZ;
751 lame_get_experimentalZ( const lame_global_flags* gfp )
753 return gfp->experimentalZ;
757 /* Naoki's psycho acoustic model. */
759 lame_set_exp_nspsytune( lame_global_flags* gfp,
762 /* default = 0 (disabled) */
764 gfp->exp_nspsytune = exp_nspsytune;
770 lame_get_exp_nspsytune( const lame_global_flags* gfp )
772 return gfp->exp_nspsytune;
778 /********************************************************************
780 ***********************************************************************/
782 // Types of VBR. default = vbr_off = CBR
784 lame_set_VBR( lame_global_flags* gfp,
787 if( 0 > VBR || vbr_max_indicator <= VBR )
788 return -1; /* Unknown VBR mode! */
796 lame_get_VBR( const lame_global_flags* gfp )
798 assert( 0 <= gfp->VBR && vbr_max_indicator > gfp->VBR );
810 lame_set_VBR_q( lame_global_flags* gfp,
813 /* XXX: This should be an enum */
814 /* to whoever added this note: why should it be an enum?
815 do you want to call a specific setting by name?
816 say VBR quality level red? */
817 /* No, but VBR_Q_HIGHEST, VBR_Q_HIGH, ..., VBR_Q_MID, ...
818 VBR_Q_LOW, VBR_Q_LOWEST (or something like that )and a
819 VBR_Q_DEFAULT, which aliases the default setting of
823 if( 0 > VBR_q || 10 <= VBR_q )
824 return -1; /* Unknown VBR quality level! */
832 lame_get_VBR_q( const lame_global_flags* gfp )
834 assert( 0 <= gfp->VBR_q && 10 > gfp->VBR_q );
840 /* Ignored except for VBR = vbr_abr (ABR mode) */
842 lame_set_VBR_mean_bitrate_kbps( lame_global_flags* gfp,
843 int VBR_mean_bitrate_kbps )
845 gfp->VBR_mean_bitrate_kbps = VBR_mean_bitrate_kbps;
851 lame_get_VBR_mean_bitrate_kbps( const lame_global_flags* gfp )
853 return gfp->VBR_mean_bitrate_kbps;
857 lame_set_VBR_min_bitrate_kbps( lame_global_flags* gfp,
858 int VBR_min_bitrate_kbps )
860 gfp->VBR_min_bitrate_kbps = VBR_min_bitrate_kbps;
866 lame_get_VBR_min_bitrate_kbps( const lame_global_flags* gfp )
868 return gfp->VBR_min_bitrate_kbps;
872 lame_set_VBR_max_bitrate_kbps( lame_global_flags* gfp,
873 int VBR_max_bitrate_kbps )
875 gfp->VBR_max_bitrate_kbps = VBR_max_bitrate_kbps;
881 lame_get_VBR_max_bitrate_kbps( const lame_global_flags* gfp )
883 return gfp->VBR_max_bitrate_kbps;
888 * Strictly enforce VBR_min_bitrate.
889 * Normally it will be violated for analog silence.
892 lame_set_VBR_hard_min( lame_global_flags* gfp,
895 /* default = 0 (disabled) */
897 /* enforce disable/enable meaning, if we need more than two values
898 we need to switch to an enum to have an apropriate representation
899 of the possible meanings of the value */
900 if ( 0 > VBR_hard_min || 1 < VBR_hard_min )
903 gfp->VBR_hard_min = VBR_hard_min;
909 lame_get_VBR_hard_min( const lame_global_flags* gfp )
911 assert( 0 <= gfp->VBR_hard_min && 1 >= gfp->VBR_hard_min );
913 return gfp->VBR_hard_min;
917 /********************************************************************
919 ***********************************************************************/
922 * Freqency in Hz to apply lowpass.
923 * 0 = default = lame chooses
927 lame_set_lowpassfreq( lame_global_flags* gfp,
930 gfp->lowpassfreq = lowpassfreq;
936 lame_get_lowpassfreq( const lame_global_flags* gfp )
938 return gfp->lowpassfreq;
943 * Width of transition band (in Hz).
944 * default = one polyphase filter band
947 lame_set_lowpasswidth( lame_global_flags* gfp,
950 gfp->lowpasswidth = lowpasswidth;
956 lame_get_lowpasswidth( const lame_global_flags* gfp )
958 return gfp->lowpasswidth;
963 * Frequency in Hz to apply highpass.
964 * 0 = default = lame chooses
968 lame_set_highpassfreq( lame_global_flags* gfp,
971 gfp->highpassfreq = highpassfreq;
977 lame_get_highpassfreq( const lame_global_flags* gfp )
979 return gfp->highpassfreq;
984 * Width of transition band (in Hz).
985 * default = one polyphase filter band
988 lame_set_highpasswidth( lame_global_flags* gfp,
991 gfp->highpasswidth = highpasswidth;
997 lame_get_highpasswidth( const lame_global_flags* gfp )
999 return gfp->highpasswidth;
1006 * psycho acoustics and other arguments which you should not change
1007 * unless you know what you are doing
1010 /* Only use ATH for masking. */
1012 lame_set_ATHonly( lame_global_flags* gfp,
1015 gfp->ATHonly = ATHonly;
1021 lame_get_ATHonly( const lame_global_flags* gfp )
1023 return gfp->ATHonly;
1027 /* Only use ATH for short blocks. */
1029 lame_set_ATHshort( lame_global_flags* gfp,
1032 gfp->ATHshort = ATHshort;
1038 lame_get_ATHshort( const lame_global_flags* gfp )
1040 return gfp->ATHshort;
1046 lame_set_noATH( lame_global_flags* gfp,
1055 lame_get_noATH( const lame_global_flags* gfp )
1061 /* Select ATH formula. */
1063 lame_set_ATHtype( lame_global_flags* gfp,
1066 /* XXX: ATHtype should be converted to an enum. */
1067 gfp->ATHtype = ATHtype;
1073 lame_get_ATHtype( const lame_global_flags* gfp )
1075 return gfp->ATHtype;
1079 /* Lower ATH by this many db. */
1081 lame_set_ATHlower( lame_global_flags* gfp,
1084 gfp->ATHlower = ATHlower;
1089 lame_get_ATHlower( const lame_global_flags* gfp )
1091 return gfp->ATHlower;
1095 /* Select ATH adaptive adjustment scheme. */
1097 lame_set_athaa_type( lame_global_flags* gfp,
1100 gfp->athaa_type = athaa_type;
1106 lame_get_athaa_type( const lame_global_flags* gfp )
1108 return gfp->athaa_type;
1112 /* Select the loudness approximation used by the ATH adaptive auto-leveling. */
1114 lame_set_athaa_loudapprox( lame_global_flags* gfp,
1115 int athaa_loudapprox )
1117 gfp->athaa_loudapprox = athaa_loudapprox;
1123 lame_get_athaa_loudapprox( const lame_global_flags* gfp )
1125 return gfp->athaa_loudapprox;
1129 /* Adjust (in dB) the point below which adaptive ATH level adjustment occurs. */
1131 lame_set_athaa_sensitivity( lame_global_flags* gfp,
1132 float athaa_sensitivity )
1134 gfp->athaa_sensitivity = athaa_sensitivity;
1140 lame_get_athaa_sensitivity( const lame_global_flags* gfp )
1142 return gfp->athaa_sensitivity;
1146 /* Predictability limit (ISO tonality formula) */
1148 lame_set_cwlimit( lame_global_flags* gfp,
1151 gfp->cwlimit = cwlimit;
1157 lame_get_cwlimit( const lame_global_flags* gfp )
1159 return gfp->cwlimit;
1165 * Allow blocktypes to differ between channels.
1167 * 0 for jstereo => block types coupled
1168 * 1 for stereo => block types may differ
1171 lame_set_allow_diff_short( lame_global_flags* gfp,
1172 int allow_diff_short )
1175 allow_diff_short ? short_block_allowed : short_block_coupled;
1181 lame_get_allow_diff_short( const lame_global_flags* gfp )
1183 if ( gfp->short_blocks == short_block_allowed )
1184 return 1; /* short blocks allowed to differ */
1186 return 0; /* not set, dispensed, forced or coupled */
1190 /* Use temporal masking effect */
1192 lame_set_useTemporal( lame_global_flags* gfp,
1195 /* default = 1 (enabled) */
1197 /* enforce disable/enable meaning, if we need more than two values
1198 we need to switch to an enum to have an apropriate representation
1199 of the possible meanings of the value */
1200 if ( 0 > useTemporal || 1 < useTemporal )
1203 gfp->useTemporal = useTemporal;
1209 lame_get_useTemporal( const lame_global_flags* gfp )
1211 assert( 0 <= gfp->useTemporal && 1 >= gfp->useTemporal );
1213 return gfp->useTemporal;
1217 /* Disable short blocks. */
1219 lame_set_no_short_blocks( lame_global_flags* gfp,
1220 int no_short_blocks )
1222 /* enforce disable/enable meaning, if we need more than two values
1223 we need to switch to an enum to have an apropriate representation
1224 of the possible meanings of the value */
1225 if ( 0 > no_short_blocks || 1 < no_short_blocks )
1229 no_short_blocks ? short_block_dispensed : short_block_allowed;
1234 lame_get_no_short_blocks( const lame_global_flags* gfp )
1236 switch ( gfp->short_blocks ) {
1238 case short_block_not_set: return -1;
1239 case short_block_dispensed: return 1;
1240 case short_block_allowed:
1241 case short_block_coupled:
1242 case short_block_forced: return 0;
1247 /* Force short blocks. */
1249 lame_set_force_short_blocks( lame_global_flags* gfp,
1252 /* enforce disable/enable meaning, if we need more than two values
1253 we need to switch to an enum to have an apropriate representation
1254 of the possible meanings of the value */
1255 if ( 0 > short_blocks || 1 < short_blocks )
1258 if (short_blocks == 1)
1259 gfp->short_blocks = short_block_forced;
1260 else if (gfp->short_blocks == short_block_forced)
1261 gfp->short_blocks = short_block_allowed;
1266 lame_get_force_short_blocks( const lame_global_flags* gfp )
1268 switch ( gfp->short_blocks ) {
1270 case short_block_not_set: return -1;
1271 case short_block_dispensed:
1272 case short_block_allowed:
1273 case short_block_coupled: return 0;
1274 case short_block_forced: return 1;
1280 * Input PCM is emphased PCM
1281 * (for instance from one of the rarely emphased CDs).
1283 * It is STRONGLY not recommended to use this, because psycho does not
1284 * take it into account, and last but not least many decoders
1288 lame_set_emphasis( lame_global_flags* gfp,
1291 /* XXX: emphasis should be converted to an enum */
1292 if ( 0 > emphasis || 4 <= emphasis )
1295 gfp->emphasis = emphasis;
1301 lame_get_emphasis( const lame_global_flags* gfp )
1303 assert( 0 <= gfp->emphasis && 4 > gfp->emphasis );
1305 return gfp->emphasis;
1311 /***************************************************************/
1312 /* internal variables, cannot be set... */
1313 /* provided because they may be of use to calling application */
1314 /***************************************************************/
1322 lame_get_version( const lame_global_flags* gfp )
1324 return gfp->version;
1328 /* Encoder delay. */
1330 lame_get_encoder_delay( const lame_global_flags* gfp )
1332 return gfp->encoder_delay;
1335 /* padding added to the end of the input */
1337 lame_get_encoder_padding( const lame_global_flags* gfp )
1339 return gfp->encoder_padding;
1343 /* Size of MPEG frame. */
1345 lame_get_framesize( const lame_global_flags* gfp )
1347 return gfp->framesize;
1351 /* Number of frames encoded so far. */
1353 lame_get_frameNum( const lame_global_flags* gfp )
1355 return gfp->frameNum;
1359 lame_get_mf_samples_to_encode( const lame_global_flags* gfp )
1361 lame_internal_flags *gfc = gfp->internal_flags;
1362 return gfc->mf_samples_to_encode;
1366 int CDECL lame_get_size_mp3buffer( const lame_global_flags* gfp )
1369 compute_flushbits(gfp,&size);
1376 * LAME's estimate of the total number of frames to be encoded.
1377 * Only valid if calling program set num_samples.
1380 lame_get_totalframes( const lame_global_flags* gfp )
1383 /* estimate based on user set num_samples: */
1385 2 + ((double)gfp->num_samples * gfp->out_samplerate) /
1386 ((double)gfp->in_samplerate * gfp->framesize);
1388 /* check to see if we underestimated totalframes */
1389 // if (totalframes < gfp->frameNum)
1390 // totalframes = gfp->frameNum;
1398 UNDOCUMENTED, experimental settings. These routines are not prototyped
1399 in lame.h. You should not use them, they are experimental and may
1406 * just another daily changing developer switch
1408 void lame_set_tune( lame_global_flags* gfp, float val )
1410 gfp->tune_value_a = val;
1414 /* Custom msfix hack */
1416 lame_set_msfix( lame_global_flags* gfp, double msfix )
1424 lame_set_preset_expopts( lame_global_flags* gfp, int preset_expopts )
1427 lame_internal_flags *gfc = gfp->internal_flags;
1429 gfc->presetTune.use = 1;
1431 /* default = 0 (disabled) */
1432 gfp->preset_expopts = preset_expopts;
1434 switch (preset_expopts)
1438 lame_set_exp_nspsytune(gfp, lame_get_exp_nspsytune(gfp) | 1);
1439 lame_set_experimentalX(gfp, 3);
1440 lame_set_exp_nspsytune(gfp, lame_get_exp_nspsytune(gfp) | 2); // safejoint
1441 lame_set_ATHtype(gfp, 2);
1443 gfc->presetTune.attackthre = 35;
1444 gfc->presetTune.attackthre_s = 150;
1445 gfc->presetTune.ms_maskadjust = .5;
1446 gfc->presetTune.quantcomp_type_s = 3;
1447 gfc->presetTune.quantcomp_alt_type = 3;
1448 gfc->presetTune.athadjust_switch_level = 2; // Always switch
1454 if (gfp->VBR == vbr_mtrh) {
1455 lame_set_experimentalX(gfp, 2);
1456 gfc->presetTune.quantcomp_adjust_mtrh = 9;
1457 gfc->presetTune.quantcomp_type_s = 4;
1458 gfc->presetTune.quantcomp_alt_type = 0;
1459 gfc->presetTune.athadjust_safe_noiseshaping_thre = 0.0;
1460 gfc->presetTune.athadjust_safe_athaasensitivity = 8.0;
1463 lame_set_experimentalX(gfp, 3);
1464 gfc->presetTune.quantcomp_adjust_rh_tot = 600;
1465 gfc->presetTune.quantcomp_adjust_rh_max = 60;
1466 gfc->presetTune.quantcomp_type_s = 3;
1467 gfc->presetTune.quantcomp_alt_type = 1;
1470 lame_set_exp_nspsytune(gfp, lame_get_exp_nspsytune(gfp) | 1);
1471 lame_set_experimentalZ(gfp, 1);
1472 lame_set_VBR_q(gfp, 2);
1473 lame_set_exp_nspsytune(gfp, lame_get_exp_nspsytune(gfp) | 2); // safejoint
1474 lame_set_ATHtype(gfp, 2);
1475 // modify sfb21 by 3 dB plus ns-treble=0
1476 lame_set_exp_nspsytune(gfp, lame_get_exp_nspsytune(gfp) | (12 << 20));
1478 gfc->presetTune.attackthre = 35;
1479 gfc->presetTune.attackthre_s = 150;
1480 gfc->presetTune.ms_maskadjust = .5;
1481 gfc->presetTune.athadjust_switch_level = 1;
1482 gfc->presetTune.athadjust_msfix = 2.13;
1488 if (gfp->VBR == vbr_mtrh) {
1489 gfc->presetTune.quantcomp_type_s = 4;
1490 gfc->presetTune.quantcomp_adjust_mtrh = 9;
1491 gfc->presetTune.quantcomp_alt_type = 0;
1492 (void) lame_set_ATHlower( gfp, -2 );
1493 gfc->presetTune.athadjust_safe_noiseshaping_thre = 0.0;
1494 gfc->presetTune.athadjust_safe_athaasensitivity = 8.0;
1497 gfc->presetTune.quantcomp_type_s = 3;
1498 gfc->presetTune.quantcomp_adjust_rh_tot = 600;
1499 gfc->presetTune.quantcomp_adjust_rh_max = 60;
1500 (void) lame_set_ATHlower( gfp, -1 );
1503 lame_set_exp_nspsytune(gfp, lame_get_exp_nspsytune(gfp) | 1);
1504 lame_set_experimentalZ(gfp, 1);
1505 lame_set_experimentalX(gfp, 1);
1506 lame_set_VBR_q(gfp, 2);
1507 lame_set_exp_nspsytune(gfp, lame_get_exp_nspsytune(gfp) | 2); // safejoint
1508 (void) lame_set_msfix( gfp, 2.13 );
1509 lame_set_ATHtype(gfp, 4);
1510 // modify sfb21 by 3.75 dB plus ns-treble=0
1511 lame_set_exp_nspsytune(gfp, lame_get_exp_nspsytune(gfp) | (15 << 20));
1513 gfc->presetTune.attackthre = 35;
1514 gfc->presetTune.attackthre_s = 150;
1515 gfc->presetTune.ms_maskadjust = .5;
1516 gfc->presetTune.athadjust_switch_level = 1;
1524 lame_set_preset_notune( lame_global_flags* gfp, int preset_notune )
1526 lame_internal_flags *gfc = gfp->internal_flags;
1528 gfc->presetTune.use = 0; // Turn off specialized preset tunings