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.2 2006/02/09 16:56:23 kramm Exp $ */
26 #include "config_static.h"
30 #include "bitstream.h" /* because of compute_flushbits */
38 * input stream description
41 /* number of samples */
42 /* it's unlikely for this function to return an error */
44 lame_set_num_samples( lame_global_flags* gfp,
45 unsigned long num_samples)
47 /* default = 2^32-1 */
49 gfp->num_samples = num_samples;
55 lame_get_num_samples( const lame_global_flags* gfp )
57 return gfp->num_samples;
61 /* input samplerate */
63 lame_set_in_samplerate( lame_global_flags* gfp,
66 /* input sample rate in Hz, default = 44100 Hz */
67 gfp->in_samplerate = in_samplerate;
73 lame_get_in_samplerate( const lame_global_flags* gfp )
75 return gfp->in_samplerate;
79 /* number of channels in input stream */
81 lame_set_num_channels( lame_global_flags* gfp,
86 if ( 2 < num_channels || 0 == num_channels )
87 return -1; /* we don't support more than 2 channels */
89 gfp->num_channels = num_channels;
95 lame_get_num_channels( const lame_global_flags* gfp )
97 return gfp->num_channels;
101 /* scale the input by this amount before encoding (not used for decoding) */
103 lame_set_scale( lame_global_flags* gfp,
113 lame_get_scale( const lame_global_flags* gfp )
119 /* scale the channel 0 (left) input by this amount before
120 encoding (not used for decoding) */
122 lame_set_scale_left( lame_global_flags* gfp,
126 gfp->scale_left = scale;
132 lame_get_scale_left( const lame_global_flags* gfp )
134 return gfp->scale_left;
138 /* scale the channel 1 (right) input by this amount before
139 encoding (not used for decoding) */
141 lame_set_scale_right( lame_global_flags* gfp,
145 gfp->scale_right = scale;
151 lame_get_scale_right( const lame_global_flags* gfp )
153 return gfp->scale_right;
157 /* output sample rate in Hz */
159 lame_set_out_samplerate( lame_global_flags* gfp,
163 * default = 0: LAME picks best value based on the amount
166 * MPEG1 32, 44.1, 48khz
167 * MPEG2 16, 22.05, 24
168 * MPEG2.5 8, 11.025, 12
170 * (not used by decoding routines)
172 gfp->out_samplerate = out_samplerate;
178 lame_get_out_samplerate( const lame_global_flags* gfp )
180 return gfp->out_samplerate;
187 * general control parameters
190 /* collect data for an MP3 frame analzyer */
192 lame_set_analysis( lame_global_flags* gfp,
197 /* enforce disable/enable meaning, if we need more than two values
198 we need to switch to an enum to have an apropriate representation
199 of the possible meanings of the value */
200 if ( 0 > analysis || 1 < analysis )
203 gfp->analysis = analysis;
209 lame_get_analysis( const lame_global_flags* gfp )
211 assert( 0 <= gfp->analysis && 1 >= gfp->analysis );
213 return gfp->analysis;
217 /* write a Xing VBR header frame */
219 lame_set_bWriteVbrTag( lame_global_flags* gfp,
222 /* default = 1 (on) for VBR/ABR modes, 0 (off) for CBR mode */
224 /* enforce disable/enable meaning, if we need more than two values
225 we need to switch to an enum to have an apropriate representation
226 of the possible meanings of the value */
227 if ( 0 > bWriteVbrTag || 1 < bWriteVbrTag )
230 gfp->bWriteVbrTag = bWriteVbrTag;
236 lame_get_bWriteVbrTag( const lame_global_flags* gfp )
238 assert( 0 <= gfp->bWriteVbrTag && 1 >= gfp->bWriteVbrTag );
240 return gfp->bWriteVbrTag;
245 /* decode only, use lame/mpglib to convert mp3/ogg to wav */
247 lame_set_decode_only( lame_global_flags* gfp,
250 /* default = 0 (disabled) */
252 /* enforce disable/enable meaning, if we need more than two values
253 we need to switch to an enum to have an apropriate representation
254 of the possible meanings of the value */
255 if ( 0 > decode_only || 1 < decode_only )
258 gfp->decode_only = decode_only;
264 lame_get_decode_only( const lame_global_flags* gfp )
266 assert( 0 <= gfp->decode_only && 1 >= gfp->decode_only );
268 return gfp->decode_only;
272 /* encode a Vorbis .ogg file */
274 lame_set_ogg( lame_global_flags* gfp,
277 /* default = 0 (disabled) */
279 /* enforce disable/enable meaning, if we need more than two values
280 we need to switch to an enum to have an apropriate representation
281 of the possible meanings of the value */
282 if ( 0 > ogg || 1 < ogg )
291 lame_get_ogg( const lame_global_flags* gfp )
293 assert( 0 <= gfp->ogg && 1 >= gfp->ogg );
300 * Internal algorithm selection.
301 * True quality is determined by the bitrate but this variable will effect
302 * quality by selecting expensive or cheap algorithms.
303 * quality=0..9. 0=best (very slow). 9=worst.
304 * recommended: 2 near-best quality, not too slow
305 * 5 good quality, fast
306 * 7 ok quality, really fast
309 lame_set_quality( lame_global_flags* gfp,
312 gfp->quality = quality;
318 lame_get_quality( const lame_global_flags* gfp )
324 /* mode = STEREO, JOINT_STEREO, DUAL_CHANNEL (not supported), MONO */
326 lame_set_mode( lame_global_flags* gfp,
329 /* default: lame chooses based on compression ratio and input channels */
331 if( 0 > mode || MAX_INDICATOR <= mode )
332 return -1; /* Unknown MPEG mode! */
340 lame_get_mode( const lame_global_flags* gfp )
342 assert( 0 <= gfp->mode && MAX_INDICATOR > gfp->mode );
348 /* Us a M/S mode with a switching threshold based on compression ratio */
350 lame_set_mode_automs( lame_global_flags* gfp,
353 /* default = 0 (disabled) */
355 /* enforce disable/enable meaning, if we need more than two values
356 we need to switch to an enum to have an apropriate representation
357 of the possible meanings of the value */
358 if ( 0 > mode_automs || 1 < mode_automs )
361 gfp->mode_automs = mode_automs;
367 lame_get_mode_automs( const lame_global_flags* gfp )
369 assert( 0 <= gfp->mode_automs && 1 >= gfp->mode_automs );
371 return gfp->mode_automs;
376 * Force M/S for all frames. For testing only.
380 lame_set_force_ms( lame_global_flags* gfp,
383 /* default = 0 (disabled) */
385 /* enforce disable/enable meaning, if we need more than two values
386 we need to switch to an enum to have an apropriate representation
387 of the possible meanings of the value */
388 if ( 0 > force_ms || 1 < force_ms )
391 gfp->force_ms = force_ms;
397 lame_get_force_ms( const lame_global_flags* gfp )
399 assert( 0 <= gfp->force_ms && 1 >= gfp->force_ms );
401 return gfp->force_ms;
405 /* Use free_format. */
407 lame_set_free_format( lame_global_flags* gfp,
410 /* default = 0 (disabled) */
412 /* enforce disable/enable meaning, if we need more than two values
413 we need to switch to an enum to have an apropriate representation
414 of the possible meanings of the value */
415 if ( 0 > free_format || 1 < free_format )
418 gfp->free_format = free_format;
424 lame_get_free_format( const lame_global_flags* gfp )
426 assert( 0 <= gfp->free_format && 1 >= gfp->free_format );
428 return gfp->free_format;
432 /* message handlers */
434 lame_set_errorf( lame_global_flags* gfp,
435 void (*func)( const char*, va_list ) )
437 gfp->report.errorf = func;
443 lame_set_debugf( lame_global_flags* gfp,
444 void (*func)( const char*, va_list ) )
446 gfp->report.debugf = func;
452 lame_set_msgf( lame_global_flags* gfp,
453 void (*func)( const char *, va_list ) )
455 gfp->report.msgf = func;
464 * - compression ratio.
466 * Default is compression ratio of 11.
469 lame_set_brate( lame_global_flags* gfp,
478 lame_get_brate( const lame_global_flags* gfp )
484 lame_set_compression_ratio( lame_global_flags* gfp,
485 float compression_ratio )
487 gfp->compression_ratio = compression_ratio;
493 lame_get_compression_ratio( const lame_global_flags* gfp )
495 return gfp->compression_ratio;
505 /* Mark as copyright protected. */
507 lame_set_copyright( lame_global_flags* gfp,
510 /* default = 0 (disabled) */
512 /* enforce disable/enable meaning, if we need more than two values
513 we need to switch to an enum to have an apropriate representation
514 of the possible meanings of the value */
515 if ( 0 > copyright || 1 < copyright )
518 gfp->copyright = copyright;
524 lame_get_copyright( const lame_global_flags* gfp )
526 assert( 0 <= gfp->copyright && 1 >= gfp->copyright );
528 return gfp->copyright;
532 /* Mark as original. */
534 lame_set_original( lame_global_flags* gfp,
537 /* default = 1 (enabled) */
539 /* enforce disable/enable meaning, if we need more than two values
540 we need to switch to an enum to have an apropriate representation
541 of the possible meanings of the value */
542 if ( 0 > original || 1 < original )
545 gfp->original = original;
551 lame_get_original( const lame_global_flags* gfp )
553 assert( 0 <= gfp->original && 1 >= gfp->original );
555 return gfp->original;
561 * Use 2 bytes from each frame for CRC checksum.
564 lame_set_error_protection( lame_global_flags* gfp,
565 int error_protection )
567 /* default = 0 (disabled) */
569 /* enforce disable/enable meaning, if we need more than two values
570 we need to switch to an enum to have an apropriate representation
571 of the possible meanings of the value */
572 if ( 0 > error_protection || 1 < error_protection )
575 gfp->error_protection = error_protection;
581 lame_get_error_protection( const lame_global_flags* gfp )
583 assert( 0 <= gfp->error_protection && 1 >= gfp->error_protection );
585 return gfp->error_protection;
591 * PAD_NO = pad no frames
592 * PAD_ALL = pad all frames
593 * PAD_ADJUST = adjust padding
596 lame_set_padding_type( lame_global_flags* gfp,
597 Padding_type padding_type )
601 if ( 0 > padding_type || PAD_MAX_INDICATOR < padding_type )
602 return -1; /* Unknown padding type */
604 gfp->padding_type = padding_type;
610 lame_get_padding_type( const lame_global_flags* gfp )
612 assert( 0 <= gfp->padding_type && PAD_MAX_INDICATOR > gfp->padding_type );
614 return gfp->padding_type;
618 /* MP3 'private extension' bit. Meaningless. */
620 lame_set_extension( lame_global_flags* gfp,
623 /* default = 0 (disabled) */
625 /* enforce disable/enable meaning, if we need more than two values
626 we need to switch to an enum to have an apropriate representation
627 of the possible meanings of the value */
628 if ( 0 > extension || 1 < extension )
631 gfp->extension = extension;
637 lame_get_extension( const lame_global_flags* gfp )
639 assert( 0 <= gfp->extension && 1 >= gfp->extension );
641 return gfp->extension;
645 /* Enforce strict ISO compliance. */
647 lame_set_strict_ISO( lame_global_flags* gfp,
650 /* default = 0 (disabled) */
652 /* enforce disable/enable meaning, if we need more than two values
653 we need to switch to an enum to have an apropriate representation
654 of the possible meanings of the value */
655 if ( 0 > strict_ISO || 1 < strict_ISO )
658 gfp->strict_ISO = strict_ISO;
664 lame_get_strict_ISO( const lame_global_flags* gfp )
666 assert( 0 <= gfp->strict_ISO && 1 >= gfp->strict_ISO );
668 return gfp->strict_ISO;
674 /********************************************************************
675 * quantization/noise shaping
676 ***********************************************************************/
678 /* Disable the bit reservoir. For testing only. */
680 lame_set_disable_reservoir( lame_global_flags* gfp,
681 int disable_reservoir )
683 /* default = 0 (disabled) */
685 /* enforce disable/enable meaning, if we need more than two values
686 we need to switch to an enum to have an apropriate representation
687 of the possible meanings of the value */
688 if ( 0 > disable_reservoir || 1 < disable_reservoir )
691 gfp->disable_reservoir = disable_reservoir;
697 lame_get_disable_reservoir( const lame_global_flags* gfp )
699 assert( 0 <= gfp->disable_reservoir && 1 >= gfp->disable_reservoir );
701 return gfp->disable_reservoir;
707 /* Select a different "best quantization" function. default = 0 */
709 lame_set_experimentalX( lame_global_flags* gfp,
712 gfp->experimentalX = experimentalX;
718 lame_get_experimentalX( const lame_global_flags* gfp )
720 return gfp->experimentalX;
724 /* Another experimental option. For testing only. */
726 lame_set_experimentalY( lame_global_flags* gfp,
729 gfp->experimentalY = experimentalY;
735 lame_get_experimentalY( const lame_global_flags* gfp )
737 return gfp->experimentalY;
741 /* Another experimental option. For testing only. */
743 lame_set_experimentalZ( lame_global_flags* gfp,
746 gfp->experimentalZ += experimentalZ;
752 lame_get_experimentalZ( const lame_global_flags* gfp )
754 return gfp->experimentalZ;
758 /* Naoki's psycho acoustic model. */
760 lame_set_exp_nspsytune( lame_global_flags* gfp,
763 /* default = 0 (disabled) */
765 gfp->exp_nspsytune = exp_nspsytune;
771 lame_get_exp_nspsytune( const lame_global_flags* gfp )
773 return gfp->exp_nspsytune;
779 /********************************************************************
781 ***********************************************************************/
783 // Types of VBR. default = vbr_off = CBR
785 lame_set_VBR( lame_global_flags* gfp,
788 if( 0 > VBR || vbr_max_indicator <= VBR )
789 return -1; /* Unknown VBR mode! */
797 lame_get_VBR( const lame_global_flags* gfp )
799 assert( 0 <= gfp->VBR && vbr_max_indicator > gfp->VBR );
811 lame_set_VBR_q( lame_global_flags* gfp,
814 /* XXX: This should be an enum */
815 /* to whoever added this note: why should it be an enum?
816 do you want to call a specific setting by name?
817 say VBR quality level red? */
818 /* No, but VBR_Q_HIGHEST, VBR_Q_HIGH, ..., VBR_Q_MID, ...
819 VBR_Q_LOW, VBR_Q_LOWEST (or something like that )and a
820 VBR_Q_DEFAULT, which aliases the default setting of
824 if( 0 > VBR_q || 10 <= VBR_q )
825 return -1; /* Unknown VBR quality level! */
833 lame_get_VBR_q( const lame_global_flags* gfp )
835 assert( 0 <= gfp->VBR_q && 10 > gfp->VBR_q );
841 /* Ignored except for VBR = vbr_abr (ABR mode) */
843 lame_set_VBR_mean_bitrate_kbps( lame_global_flags* gfp,
844 int VBR_mean_bitrate_kbps )
846 gfp->VBR_mean_bitrate_kbps = VBR_mean_bitrate_kbps;
852 lame_get_VBR_mean_bitrate_kbps( const lame_global_flags* gfp )
854 return gfp->VBR_mean_bitrate_kbps;
858 lame_set_VBR_min_bitrate_kbps( lame_global_flags* gfp,
859 int VBR_min_bitrate_kbps )
861 gfp->VBR_min_bitrate_kbps = VBR_min_bitrate_kbps;
867 lame_get_VBR_min_bitrate_kbps( const lame_global_flags* gfp )
869 return gfp->VBR_min_bitrate_kbps;
873 lame_set_VBR_max_bitrate_kbps( lame_global_flags* gfp,
874 int VBR_max_bitrate_kbps )
876 gfp->VBR_max_bitrate_kbps = VBR_max_bitrate_kbps;
882 lame_get_VBR_max_bitrate_kbps( const lame_global_flags* gfp )
884 return gfp->VBR_max_bitrate_kbps;
889 * Strictly enforce VBR_min_bitrate.
890 * Normally it will be violated for analog silence.
893 lame_set_VBR_hard_min( lame_global_flags* gfp,
896 /* default = 0 (disabled) */
898 /* enforce disable/enable meaning, if we need more than two values
899 we need to switch to an enum to have an apropriate representation
900 of the possible meanings of the value */
901 if ( 0 > VBR_hard_min || 1 < VBR_hard_min )
904 gfp->VBR_hard_min = VBR_hard_min;
910 lame_get_VBR_hard_min( const lame_global_flags* gfp )
912 assert( 0 <= gfp->VBR_hard_min && 1 >= gfp->VBR_hard_min );
914 return gfp->VBR_hard_min;
918 /********************************************************************
920 ***********************************************************************/
923 * Freqency in Hz to apply lowpass.
924 * 0 = default = lame chooses
928 lame_set_lowpassfreq( lame_global_flags* gfp,
931 gfp->lowpassfreq = lowpassfreq;
937 lame_get_lowpassfreq( const lame_global_flags* gfp )
939 return gfp->lowpassfreq;
944 * Width of transition band (in Hz).
945 * default = one polyphase filter band
948 lame_set_lowpasswidth( lame_global_flags* gfp,
951 gfp->lowpasswidth = lowpasswidth;
957 lame_get_lowpasswidth( const lame_global_flags* gfp )
959 return gfp->lowpasswidth;
964 * Frequency in Hz to apply highpass.
965 * 0 = default = lame chooses
969 lame_set_highpassfreq( lame_global_flags* gfp,
972 gfp->highpassfreq = highpassfreq;
978 lame_get_highpassfreq( const lame_global_flags* gfp )
980 return gfp->highpassfreq;
985 * Width of transition band (in Hz).
986 * default = one polyphase filter band
989 lame_set_highpasswidth( lame_global_flags* gfp,
992 gfp->highpasswidth = highpasswidth;
998 lame_get_highpasswidth( const lame_global_flags* gfp )
1000 return gfp->highpasswidth;
1007 * psycho acoustics and other arguments which you should not change
1008 * unless you know what you are doing
1011 /* Only use ATH for masking. */
1013 lame_set_ATHonly( lame_global_flags* gfp,
1016 gfp->ATHonly = ATHonly;
1022 lame_get_ATHonly( const lame_global_flags* gfp )
1024 return gfp->ATHonly;
1028 /* Only use ATH for short blocks. */
1030 lame_set_ATHshort( lame_global_flags* gfp,
1033 gfp->ATHshort = ATHshort;
1039 lame_get_ATHshort( const lame_global_flags* gfp )
1041 return gfp->ATHshort;
1047 lame_set_noATH( lame_global_flags* gfp,
1056 lame_get_noATH( const lame_global_flags* gfp )
1062 /* Select ATH formula. */
1064 lame_set_ATHtype( lame_global_flags* gfp,
1067 /* XXX: ATHtype should be converted to an enum. */
1068 gfp->ATHtype = ATHtype;
1074 lame_get_ATHtype( const lame_global_flags* gfp )
1076 return gfp->ATHtype;
1080 /* Lower ATH by this many db. */
1082 lame_set_ATHlower( lame_global_flags* gfp,
1085 gfp->ATHlower = ATHlower;
1090 lame_get_ATHlower( const lame_global_flags* gfp )
1092 return gfp->ATHlower;
1096 /* Select ATH adaptive adjustment scheme. */
1098 lame_set_athaa_type( lame_global_flags* gfp,
1101 gfp->athaa_type = athaa_type;
1107 lame_get_athaa_type( const lame_global_flags* gfp )
1109 return gfp->athaa_type;
1113 /* Select the loudness approximation used by the ATH adaptive auto-leveling. */
1115 lame_set_athaa_loudapprox( lame_global_flags* gfp,
1116 int athaa_loudapprox )
1118 gfp->athaa_loudapprox = athaa_loudapprox;
1124 lame_get_athaa_loudapprox( const lame_global_flags* gfp )
1126 return gfp->athaa_loudapprox;
1130 /* Adjust (in dB) the point below which adaptive ATH level adjustment occurs. */
1132 lame_set_athaa_sensitivity( lame_global_flags* gfp,
1133 float athaa_sensitivity )
1135 gfp->athaa_sensitivity = athaa_sensitivity;
1141 lame_get_athaa_sensitivity( const lame_global_flags* gfp )
1143 return gfp->athaa_sensitivity;
1147 /* Predictability limit (ISO tonality formula) */
1149 lame_set_cwlimit( lame_global_flags* gfp,
1152 gfp->cwlimit = cwlimit;
1158 lame_get_cwlimit( const lame_global_flags* gfp )
1160 return gfp->cwlimit;
1166 * Allow blocktypes to differ between channels.
1168 * 0 for jstereo => block types coupled
1169 * 1 for stereo => block types may differ
1172 lame_set_allow_diff_short( lame_global_flags* gfp,
1173 int allow_diff_short )
1176 allow_diff_short ? short_block_allowed : short_block_coupled;
1182 lame_get_allow_diff_short( const lame_global_flags* gfp )
1184 if ( gfp->short_blocks == short_block_allowed )
1185 return 1; /* short blocks allowed to differ */
1187 return 0; /* not set, dispensed, forced or coupled */
1191 /* Use temporal masking effect */
1193 lame_set_useTemporal( lame_global_flags* gfp,
1196 /* default = 1 (enabled) */
1198 /* enforce disable/enable meaning, if we need more than two values
1199 we need to switch to an enum to have an apropriate representation
1200 of the possible meanings of the value */
1201 if ( 0 > useTemporal || 1 < useTemporal )
1204 gfp->useTemporal = useTemporal;
1210 lame_get_useTemporal( const lame_global_flags* gfp )
1212 assert( 0 <= gfp->useTemporal && 1 >= gfp->useTemporal );
1214 return gfp->useTemporal;
1218 /* Disable short blocks. */
1220 lame_set_no_short_blocks( lame_global_flags* gfp,
1221 int no_short_blocks )
1223 /* enforce disable/enable meaning, if we need more than two values
1224 we need to switch to an enum to have an apropriate representation
1225 of the possible meanings of the value */
1226 if ( 0 > no_short_blocks || 1 < no_short_blocks )
1230 no_short_blocks ? short_block_dispensed : short_block_allowed;
1235 lame_get_no_short_blocks( const lame_global_flags* gfp )
1237 switch ( gfp->short_blocks ) {
1239 case short_block_not_set: return -1;
1240 case short_block_dispensed: return 1;
1241 case short_block_allowed:
1242 case short_block_coupled:
1243 case short_block_forced: return 0;
1248 /* Force short blocks. */
1250 lame_set_force_short_blocks( lame_global_flags* gfp,
1253 /* enforce disable/enable meaning, if we need more than two values
1254 we need to switch to an enum to have an apropriate representation
1255 of the possible meanings of the value */
1256 if ( 0 > short_blocks || 1 < short_blocks )
1259 if (short_blocks == 1)
1260 gfp->short_blocks = short_block_forced;
1261 else if (gfp->short_blocks == short_block_forced)
1262 gfp->short_blocks = short_block_allowed;
1267 lame_get_force_short_blocks( const lame_global_flags* gfp )
1269 switch ( gfp->short_blocks ) {
1271 case short_block_not_set: return -1;
1272 case short_block_dispensed:
1273 case short_block_allowed:
1274 case short_block_coupled: return 0;
1275 case short_block_forced: return 1;
1281 * Input PCM is emphased PCM
1282 * (for instance from one of the rarely emphased CDs).
1284 * It is STRONGLY not recommended to use this, because psycho does not
1285 * take it into account, and last but not least many decoders
1289 lame_set_emphasis( lame_global_flags* gfp,
1292 /* XXX: emphasis should be converted to an enum */
1293 if ( 0 > emphasis || 4 <= emphasis )
1296 gfp->emphasis = emphasis;
1302 lame_get_emphasis( const lame_global_flags* gfp )
1304 assert( 0 <= gfp->emphasis && 4 > gfp->emphasis );
1306 return gfp->emphasis;
1312 /***************************************************************/
1313 /* internal variables, cannot be set... */
1314 /* provided because they may be of use to calling application */
1315 /***************************************************************/
1323 lame_get_version( const lame_global_flags* gfp )
1325 return gfp->version;
1329 /* Encoder delay. */
1331 lame_get_encoder_delay( const lame_global_flags* gfp )
1333 return gfp->encoder_delay;
1336 /* padding added to the end of the input */
1338 lame_get_encoder_padding( const lame_global_flags* gfp )
1340 return gfp->encoder_padding;
1344 /* Size of MPEG frame. */
1346 lame_get_framesize( const lame_global_flags* gfp )
1348 return gfp->framesize;
1352 /* Number of frames encoded so far. */
1354 lame_get_frameNum( const lame_global_flags* gfp )
1356 return gfp->frameNum;
1360 lame_get_mf_samples_to_encode( const lame_global_flags* gfp )
1362 lame_internal_flags *gfc = gfp->internal_flags;
1363 return gfc->mf_samples_to_encode;
1367 int CDECL lame_get_size_mp3buffer( const lame_global_flags* gfp )
1370 compute_flushbits(gfp,&size);
1377 * LAME's estimate of the total number of frames to be encoded.
1378 * Only valid if calling program set num_samples.
1381 lame_get_totalframes( const lame_global_flags* gfp )
1384 /* estimate based on user set num_samples: */
1386 2 + ((double)gfp->num_samples * gfp->out_samplerate) /
1387 ((double)gfp->in_samplerate * gfp->framesize);
1389 /* check to see if we underestimated totalframes */
1390 // if (totalframes < gfp->frameNum)
1391 // totalframes = gfp->frameNum;
1399 UNDOCUMENTED, experimental settings. These routines are not prototyped
1400 in lame.h. You should not use them, they are experimental and may
1407 * just another daily changing developer switch
1409 void lame_set_tune( lame_global_flags* gfp, float val )
1411 gfp->tune_value_a = val;
1415 /* Custom msfix hack */
1417 lame_set_msfix( lame_global_flags* gfp, double msfix )
1425 lame_set_preset_expopts( lame_global_flags* gfp, int preset_expopts )
1428 lame_internal_flags *gfc = gfp->internal_flags;
1430 gfc->presetTune.use = 1;
1432 /* default = 0 (disabled) */
1433 gfp->preset_expopts = preset_expopts;
1435 switch (preset_expopts)
1439 lame_set_exp_nspsytune(gfp, lame_get_exp_nspsytune(gfp) | 1);
1440 lame_set_experimentalX(gfp, 3);
1441 lame_set_exp_nspsytune(gfp, lame_get_exp_nspsytune(gfp) | 2); // safejoint
1442 lame_set_ATHtype(gfp, 2);
1444 gfc->presetTune.attackthre = 35;
1445 gfc->presetTune.attackthre_s = 150;
1446 gfc->presetTune.ms_maskadjust = .5;
1447 gfc->presetTune.quantcomp_type_s = 3;
1448 gfc->presetTune.quantcomp_alt_type = 3;
1449 gfc->presetTune.athadjust_switch_level = 2; // Always switch
1455 if (gfp->VBR == vbr_mtrh) {
1456 lame_set_experimentalX(gfp, 2);
1457 gfc->presetTune.quantcomp_adjust_mtrh = 9;
1458 gfc->presetTune.quantcomp_type_s = 4;
1459 gfc->presetTune.quantcomp_alt_type = 0;
1460 gfc->presetTune.athadjust_safe_noiseshaping_thre = 0.0;
1461 gfc->presetTune.athadjust_safe_athaasensitivity = 8.0;
1464 lame_set_experimentalX(gfp, 3);
1465 gfc->presetTune.quantcomp_adjust_rh_tot = 600;
1466 gfc->presetTune.quantcomp_adjust_rh_max = 60;
1467 gfc->presetTune.quantcomp_type_s = 3;
1468 gfc->presetTune.quantcomp_alt_type = 1;
1471 lame_set_exp_nspsytune(gfp, lame_get_exp_nspsytune(gfp) | 1);
1472 lame_set_experimentalZ(gfp, 1);
1473 lame_set_VBR_q(gfp, 2);
1474 lame_set_exp_nspsytune(gfp, lame_get_exp_nspsytune(gfp) | 2); // safejoint
1475 lame_set_ATHtype(gfp, 2);
1476 // modify sfb21 by 3 dB plus ns-treble=0
1477 lame_set_exp_nspsytune(gfp, lame_get_exp_nspsytune(gfp) | (12 << 20));
1479 gfc->presetTune.attackthre = 35;
1480 gfc->presetTune.attackthre_s = 150;
1481 gfc->presetTune.ms_maskadjust = .5;
1482 gfc->presetTune.athadjust_switch_level = 1;
1483 gfc->presetTune.athadjust_msfix = 2.13;
1489 if (gfp->VBR == vbr_mtrh) {
1490 gfc->presetTune.quantcomp_type_s = 4;
1491 gfc->presetTune.quantcomp_adjust_mtrh = 9;
1492 gfc->presetTune.quantcomp_alt_type = 0;
1493 (void) lame_set_ATHlower( gfp, -2 );
1494 gfc->presetTune.athadjust_safe_noiseshaping_thre = 0.0;
1495 gfc->presetTune.athadjust_safe_athaasensitivity = 8.0;
1498 gfc->presetTune.quantcomp_type_s = 3;
1499 gfc->presetTune.quantcomp_adjust_rh_tot = 600;
1500 gfc->presetTune.quantcomp_adjust_rh_max = 60;
1501 (void) lame_set_ATHlower( gfp, -1 );
1504 lame_set_exp_nspsytune(gfp, lame_get_exp_nspsytune(gfp) | 1);
1505 lame_set_experimentalZ(gfp, 1);
1506 lame_set_experimentalX(gfp, 1);
1507 lame_set_VBR_q(gfp, 2);
1508 lame_set_exp_nspsytune(gfp, lame_get_exp_nspsytune(gfp) | 2); // safejoint
1509 (void) lame_set_msfix( gfp, 2.13 );
1510 lame_set_ATHtype(gfp, 4);
1511 // modify sfb21 by 3.75 dB plus ns-treble=0
1512 lame_set_exp_nspsytune(gfp, lame_get_exp_nspsytune(gfp) | (15 << 20));
1514 gfc->presetTune.attackthre = 35;
1515 gfc->presetTune.attackthre_s = 150;
1516 gfc->presetTune.ms_maskadjust = .5;
1517 gfc->presetTune.athadjust_switch_level = 1;
1525 lame_set_preset_notune( lame_global_flags* gfp, int preset_notune )
1527 lame_internal_flags *gfc = gfp->internal_flags;
1529 gfc->presetTune.use = 0; // Turn off specialized preset tunings