00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifdef HAVE_CONFIG_H
00026 # include <config.h>
00027 #endif
00028
00029 #include "lame.h"
00030 #include "machine.h"
00031 #include "encoder.h"
00032 #include "util.h"
00033 #include "bitstream.h"
00034
00035 #include "set_get.h"
00036 #include "lame_global_flags.h"
00037
00038
00039
00040
00041
00042
00043
00044 int
00045 lame_set_num_samples(lame_global_flags * gfp, unsigned long num_samples)
00046 {
00047
00048
00049 gfp->num_samples = num_samples;
00050
00051 return 0;
00052 }
00053
00054 unsigned long
00055 lame_get_num_samples(const lame_global_flags * gfp)
00056 {
00057 return gfp->num_samples;
00058 }
00059
00060
00061
00062 int
00063 lame_set_in_samplerate(lame_global_flags * gfp, int in_samplerate)
00064 {
00065
00066 gfp->in_samplerate = in_samplerate;
00067
00068 return 0;
00069 }
00070
00071 int
00072 lame_get_in_samplerate(const lame_global_flags * gfp)
00073 {
00074 return gfp->in_samplerate;
00075 }
00076
00077
00078
00079 int
00080 lame_set_num_channels(lame_global_flags * gfp, int num_channels)
00081 {
00082
00083
00084 if (2 < num_channels || 0 == num_channels)
00085 return -1;
00086
00087 gfp->num_channels = num_channels;
00088
00089 return 0;
00090 }
00091
00092 int
00093 lame_get_num_channels(const lame_global_flags * gfp)
00094 {
00095 return gfp->num_channels;
00096 }
00097
00098
00099
00100 int
00101 lame_set_scale(lame_global_flags * gfp, float scale)
00102 {
00103
00104 gfp->scale = scale;
00105
00106 return 0;
00107 }
00108
00109 float
00110 lame_get_scale(const lame_global_flags * gfp)
00111 {
00112 return gfp->scale;
00113 }
00114
00115
00116
00117
00118 int
00119 lame_set_scale_left(lame_global_flags * gfp, float scale)
00120 {
00121
00122 gfp->scale_left = scale;
00123
00124 return 0;
00125 }
00126
00127 float
00128 lame_get_scale_left(const lame_global_flags * gfp)
00129 {
00130 return gfp->scale_left;
00131 }
00132
00133
00134
00135
00136 int
00137 lame_set_scale_right(lame_global_flags * gfp, float scale)
00138 {
00139
00140 gfp->scale_right = scale;
00141
00142 return 0;
00143 }
00144
00145 float
00146 lame_get_scale_right(const lame_global_flags * gfp)
00147 {
00148 return gfp->scale_right;
00149 }
00150
00151
00152
00153 int
00154 lame_set_out_samplerate(lame_global_flags * gfp, int out_samplerate)
00155 {
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166 gfp->out_samplerate = out_samplerate;
00167
00168 return 0;
00169 }
00170
00171 int
00172 lame_get_out_samplerate(const lame_global_flags * gfp)
00173 {
00174 return gfp->out_samplerate;
00175 }
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185 int
00186 lame_set_analysis(lame_global_flags * gfp, int analysis)
00187 {
00188
00189
00190
00191
00192
00193 if (0 > analysis || 1 < analysis)
00194 return -1;
00195
00196 gfp->analysis = analysis;
00197
00198 return 0;
00199 }
00200
00201 int
00202 lame_get_analysis(const lame_global_flags * gfp)
00203 {
00204 assert(0 <= gfp->analysis && 1 >= gfp->analysis);
00205
00206 return gfp->analysis;
00207 }
00208
00209
00210
00211 int
00212 lame_set_bWriteVbrTag(lame_global_flags * gfp, int bWriteVbrTag)
00213 {
00214
00215
00216
00217
00218
00219 if (0 > bWriteVbrTag || 1 < bWriteVbrTag)
00220 return -1;
00221
00222 gfp->bWriteVbrTag = bWriteVbrTag;
00223
00224 return 0;
00225 }
00226
00227 int
00228 lame_get_bWriteVbrTag(const lame_global_flags * gfp)
00229 {
00230 assert(0 <= gfp->bWriteVbrTag && 1 >= gfp->bWriteVbrTag);
00231
00232 return gfp->bWriteVbrTag;
00233 }
00234
00235
00236
00237
00238 int
00239 lame_set_decode_only(lame_global_flags * gfp, int decode_only)
00240 {
00241
00242
00243
00244
00245
00246 if (0 > decode_only || 1 < decode_only)
00247 return -1;
00248
00249 gfp->decode_only = decode_only;
00250
00251 return 0;
00252 }
00253
00254 int
00255 lame_get_decode_only(const lame_global_flags * gfp)
00256 {
00257 assert(0 <= gfp->decode_only && 1 >= gfp->decode_only);
00258
00259 return gfp->decode_only;
00260 }
00261
00262
00263
00264
00265 int
00266 lame_set_ogg(lame_global_flags * gfp, int ogg)
00267 {
00268 return -1;
00269 }
00270
00271 int
00272 lame_get_ogg(const lame_global_flags * gfp)
00273 {
00274 return 0;
00275 }
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287 int
00288 lame_set_quality(lame_global_flags * gfp, int quality)
00289 {
00290 gfp->quality = quality;
00291
00292 return 0;
00293 }
00294
00295 int
00296 lame_get_quality(const lame_global_flags * gfp)
00297 {
00298 return gfp->quality;
00299 }
00300
00301
00302
00303 int
00304 lame_set_mode(lame_global_flags * gfp, MPEG_mode mode)
00305 {
00306
00307
00308 if (0 > mode || MAX_INDICATOR <= mode)
00309 return -1;
00310
00311 gfp->mode = mode;
00312
00313 return 0;
00314 }
00315
00316 MPEG_mode
00317 lame_get_mode(const lame_global_flags * gfp)
00318 {
00319 assert(0 <= gfp->mode && MAX_INDICATOR > gfp->mode);
00320
00321 return gfp->mode;
00322 }
00323
00324
00325
00326
00327 int
00328 lame_set_mode_automs(lame_global_flags * gfp, int mode_automs)
00329 {
00330
00331
00332
00333
00334
00335 if (0 > mode_automs || 1 < mode_automs)
00336 return -1;
00337
00338 lame_set_mode(gfp, JOINT_STEREO);
00339
00340 return 0;
00341 }
00342
00343 int
00344 lame_get_mode_automs(const lame_global_flags * gfp)
00345 {
00346 return 1;
00347 }
00348
00349
00350
00351
00352
00353
00354 int
00355 lame_set_force_ms(lame_global_flags * gfp, int force_ms)
00356 {
00357
00358
00359
00360
00361
00362 if (0 > force_ms || 1 < force_ms)
00363 return -1;
00364
00365 gfp->force_ms = force_ms;
00366
00367 return 0;
00368 }
00369
00370 int
00371 lame_get_force_ms(const lame_global_flags * gfp)
00372 {
00373 assert(0 <= gfp->force_ms && 1 >= gfp->force_ms);
00374
00375 return gfp->force_ms;
00376 }
00377
00378
00379
00380 int
00381 lame_set_free_format(lame_global_flags * gfp, int free_format)
00382 {
00383
00384
00385
00386
00387
00388 if (0 > free_format || 1 < free_format)
00389 return -1;
00390
00391 gfp->free_format = free_format;
00392
00393 return 0;
00394 }
00395
00396 int
00397 lame_get_free_format(const lame_global_flags * gfp)
00398 {
00399 assert(0 <= gfp->free_format && 1 >= gfp->free_format);
00400
00401 return gfp->free_format;
00402 }
00403
00404
00405
00406
00407 int
00408 lame_set_findReplayGain(lame_global_flags * gfp, int findReplayGain)
00409 {
00410
00411
00412
00413
00414
00415 if (0 > findReplayGain || 1 < findReplayGain)
00416 return -1;
00417
00418 gfp->findReplayGain = findReplayGain;
00419
00420 return 0;
00421 }
00422
00423 int
00424 lame_get_findReplayGain(const lame_global_flags * gfp)
00425 {
00426 assert(0 <= gfp->findReplayGain && 1 >= gfp->findReplayGain);
00427
00428 return gfp->findReplayGain;
00429 }
00430
00431
00432
00433
00434 int
00435 lame_set_decode_on_the_fly(lame_global_flags * gfp, int decode_on_the_fly)
00436 {
00437 #ifndef DECODE_ON_THE_FLY
00438 return -1;
00439 #else
00440
00441
00442
00443
00444
00445 if (0 > decode_on_the_fly || 1 < decode_on_the_fly)
00446 return -1;
00447
00448 gfp->decode_on_the_fly = decode_on_the_fly;
00449
00450 return 0;
00451 #endif
00452 }
00453
00454 int
00455 lame_get_decode_on_the_fly(const lame_global_flags * gfp)
00456 {
00457 assert(0 <= gfp->decode_on_the_fly && 1 >= gfp->decode_on_the_fly);
00458
00459 return gfp->decode_on_the_fly;
00460 }
00461
00462
00463 int
00464 lame_set_findPeakSample(lame_global_flags * gfp, int arg)
00465 {
00466 return lame_set_decode_on_the_fly(gfp, arg);
00467 }
00468
00469 int
00470 lame_get_findPeakSample(const lame_global_flags * gfp)
00471 {
00472 return lame_get_decode_on_the_fly(gfp);
00473 }
00474
00475
00476 int
00477 lame_set_ReplayGain_input(lame_global_flags * gfp, int arg)
00478 {
00479 return lame_set_findReplayGain(gfp, arg);
00480 }
00481
00482 int
00483 lame_get_ReplayGain_input(const lame_global_flags * gfp)
00484 {
00485 return lame_get_findReplayGain(gfp);
00486 }
00487
00488
00489
00490 int
00491 lame_set_ReplayGain_decode(lame_global_flags * gfp, int arg)
00492 {
00493 if (lame_set_decode_on_the_fly(gfp, arg) < 0 || lame_set_findReplayGain(gfp, arg) < 0)
00494 return -1;
00495 else
00496 return 0;
00497 }
00498
00499 int
00500 lame_get_ReplayGain_decode(const lame_global_flags * gfp)
00501 {
00502 if (lame_get_decode_on_the_fly(gfp) > 0 && lame_get_findReplayGain(gfp) > 0)
00503 return 1;
00504 else
00505 return 0;
00506 }
00507
00508
00509
00510
00511 int
00512 lame_set_nogap_total(lame_global_flags * gfp, int the_nogap_total)
00513 {
00514 lame_internal_flags *gfc = gfp->internal_flags;
00515 gfc->nogap_total = the_nogap_total;
00516 return 0;
00517 }
00518
00519 int
00520 lame_get_nogap_total(const lame_global_flags * gfp)
00521 {
00522 return gfp->internal_flags->nogap_total;
00523 }
00524
00525 int
00526 lame_set_nogap_currentindex(lame_global_flags * gfp, int the_nogap_index)
00527 {
00528 lame_internal_flags *gfc = gfp->internal_flags;
00529 gfc->nogap_current = the_nogap_index;
00530 return 0;
00531 }
00532
00533 int
00534 lame_get_nogap_currentindex(const lame_global_flags * gfp)
00535 {
00536 return gfp->internal_flags->nogap_current;
00537 }
00538
00539
00540
00541 int
00542 lame_set_errorf(lame_global_flags * gfp, void (*func) (const char *, va_list))
00543 {
00544 gfp->report.errorf = func;
00545
00546 return 0;
00547 }
00548
00549 int
00550 lame_set_debugf(lame_global_flags * gfp, void (*func) (const char *, va_list))
00551 {
00552 gfp->report.debugf = func;
00553
00554 return 0;
00555 }
00556
00557 int
00558 lame_set_msgf(lame_global_flags * gfp, void (*func) (const char *, va_list))
00559 {
00560 gfp->report.msgf = func;
00561
00562 return 0;
00563 }
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573 int
00574 lame_set_brate(lame_global_flags * gfp, int brate)
00575 {
00576 gfp->brate = brate;
00577
00578 if (brate > 320) {
00579 gfp->disable_reservoir = 1;
00580 }
00581
00582 return 0;
00583 }
00584
00585 int
00586 lame_get_brate(const lame_global_flags * gfp)
00587 {
00588 return gfp->brate;
00589 }
00590
00591 int
00592 lame_set_compression_ratio(lame_global_flags * gfp, float compression_ratio)
00593 {
00594 gfp->compression_ratio = compression_ratio;
00595
00596 return 0;
00597 }
00598
00599 float
00600 lame_get_compression_ratio(const lame_global_flags * gfp)
00601 {
00602 return gfp->compression_ratio;
00603 }
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613 int
00614 lame_set_copyright(lame_global_flags * gfp, int copyright)
00615 {
00616
00617
00618
00619
00620
00621 if (0 > copyright || 1 < copyright)
00622 return -1;
00623
00624 gfp->copyright = copyright;
00625
00626 return 0;
00627 }
00628
00629 int
00630 lame_get_copyright(const lame_global_flags * gfp)
00631 {
00632 assert(0 <= gfp->copyright && 1 >= gfp->copyright);
00633
00634 return gfp->copyright;
00635 }
00636
00637
00638
00639 int
00640 lame_set_original(lame_global_flags * gfp, int original)
00641 {
00642
00643
00644
00645
00646
00647 if (0 > original || 1 < original)
00648 return -1;
00649
00650 gfp->original = original;
00651
00652 return 0;
00653 }
00654
00655 int
00656 lame_get_original(const lame_global_flags * gfp)
00657 {
00658 assert(0 <= gfp->original && 1 >= gfp->original);
00659
00660 return gfp->original;
00661 }
00662
00663
00664
00665
00666
00667
00668 int
00669 lame_set_error_protection(lame_global_flags * gfp, int error_protection)
00670 {
00671
00672
00673
00674
00675
00676 if (0 > error_protection || 1 < error_protection)
00677 return -1;
00678
00679 gfp->error_protection = error_protection;
00680
00681 return 0;
00682 }
00683
00684 int
00685 lame_get_error_protection(const lame_global_flags * gfp)
00686 {
00687 assert(0 <= gfp->error_protection && 1 >= gfp->error_protection);
00688
00689 return gfp->error_protection;
00690 }
00691
00692
00693
00694
00695
00696
00697
00698
00699 int
00700 lame_set_padding_type(lame_global_flags * gfp, Padding_type padding_type)
00701 {
00702 return 0;
00703 }
00704
00705 Padding_type
00706 lame_get_padding_type(const lame_global_flags * gfp)
00707 {
00708 return PAD_ADJUST;
00709 }
00710
00711
00712
00713 int
00714 lame_set_extension(lame_global_flags * gfp, int extension)
00715 {
00716
00717
00718
00719
00720
00721 if (0 > extension || 1 < extension)
00722 return -1;
00723
00724 gfp->extension = extension;
00725
00726 return 0;
00727 }
00728
00729 int
00730 lame_get_extension(const lame_global_flags * gfp)
00731 {
00732 assert(0 <= gfp->extension && 1 >= gfp->extension);
00733
00734 return gfp->extension;
00735 }
00736
00737
00738
00739 int
00740 lame_set_strict_ISO(lame_global_flags * gfp, int strict_ISO)
00741 {
00742
00743
00744
00745
00746
00747 if (0 > strict_ISO || 1 < strict_ISO)
00748 return -1;
00749
00750 gfp->strict_ISO = strict_ISO;
00751
00752 return 0;
00753 }
00754
00755 int
00756 lame_get_strict_ISO(const lame_global_flags * gfp)
00757 {
00758 assert(0 <= gfp->strict_ISO && 1 >= gfp->strict_ISO);
00759
00760 return gfp->strict_ISO;
00761 }
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771 int
00772 lame_set_disable_reservoir(lame_global_flags * gfp, int disable_reservoir)
00773 {
00774
00775
00776
00777
00778
00779 if (0 > disable_reservoir || 1 < disable_reservoir)
00780 return -1;
00781
00782 gfp->disable_reservoir = disable_reservoir;
00783
00784 return 0;
00785 }
00786
00787 int
00788 lame_get_disable_reservoir(const lame_global_flags * gfp)
00789 {
00790 assert(0 <= gfp->disable_reservoir && 1 >= gfp->disable_reservoir);
00791
00792 return gfp->disable_reservoir;
00793 }
00794
00795
00796
00797
00798 int
00799 lame_set_experimentalX(lame_global_flags * gfp, int experimentalX)
00800 {
00801 lame_set_quant_comp(gfp, experimentalX);
00802 lame_set_quant_comp_short(gfp, experimentalX);
00803
00804 return 0;
00805 }
00806
00807 int
00808 lame_get_experimentalX(const lame_global_flags * gfp)
00809 {
00810 return lame_get_quant_comp(gfp);
00811 }
00812
00813
00814
00815 int
00816 lame_set_quant_comp(lame_global_flags * gfp, int quant_type)
00817 {
00818 gfp->quant_comp = quant_type;
00819
00820 return 0;
00821 }
00822
00823 int
00824 lame_get_quant_comp(const lame_global_flags * gfp)
00825 {
00826 return gfp->quant_comp;
00827 }
00828
00829
00830
00831 int
00832 lame_set_quant_comp_short(lame_global_flags * gfp, int quant_type)
00833 {
00834 gfp->quant_comp_short = quant_type;
00835
00836 return 0;
00837 }
00838
00839 int
00840 lame_get_quant_comp_short(const lame_global_flags * gfp)
00841 {
00842 return gfp->quant_comp_short;
00843 }
00844
00845
00846
00847 int
00848 lame_set_experimentalY(lame_global_flags * gfp, int experimentalY)
00849 {
00850 gfp->experimentalY = experimentalY;
00851
00852 return 0;
00853 }
00854
00855 int
00856 lame_get_experimentalY(const lame_global_flags * gfp)
00857 {
00858 return gfp->experimentalY;
00859 }
00860
00861
00862 int
00863 lame_set_experimentalZ(lame_global_flags * gfp, int experimentalZ)
00864 {
00865 return 0;
00866 }
00867
00868 int
00869 lame_get_experimentalZ(const lame_global_flags * gfp)
00870 {
00871 return 0;
00872 }
00873
00874
00875
00876 int
00877 lame_set_exp_nspsytune(lame_global_flags * gfp, int exp_nspsytune)
00878 {
00879
00880
00881 gfp->exp_nspsytune = exp_nspsytune;
00882
00883 return 0;
00884 }
00885
00886 int
00887 lame_get_exp_nspsytune(const lame_global_flags * gfp)
00888 {
00889 return gfp->exp_nspsytune;
00890 }
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900 int
00901 lame_set_VBR(lame_global_flags * gfp, vbr_mode VBR)
00902 {
00903 if (0 > VBR || vbr_max_indicator <= VBR)
00904 return -1;
00905
00906 gfp->VBR = VBR;
00907
00908 return 0;
00909 }
00910
00911 vbr_mode
00912 lame_get_VBR(const lame_global_flags * gfp)
00913 {
00914 assert(0 <= gfp->VBR && vbr_max_indicator > gfp->VBR);
00915
00916 return gfp->VBR;
00917 }
00918
00919
00920
00921
00922
00923
00924
00925 int
00926 lame_set_VBR_q(lame_global_flags * gfp, int VBR_q)
00927 {
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938 if (0 > VBR_q || 10 <= VBR_q)
00939 return -1;
00940
00941 gfp->VBR_q = VBR_q;
00942
00943
00944 return 0;
00945 }
00946
00947 int
00948 lame_get_VBR_q(const lame_global_flags * gfp)
00949 {
00950 assert(0 <= gfp->VBR_q && 10 > gfp->VBR_q);
00951
00952 return gfp->VBR_q;
00953 }
00954
00955
00956
00957 int
00958 lame_set_VBR_mean_bitrate_kbps(lame_global_flags * gfp, int VBR_mean_bitrate_kbps)
00959 {
00960 gfp->VBR_mean_bitrate_kbps = VBR_mean_bitrate_kbps;
00961
00962 return 0;
00963 }
00964
00965 int
00966 lame_get_VBR_mean_bitrate_kbps(const lame_global_flags * gfp)
00967 {
00968 return gfp->VBR_mean_bitrate_kbps;
00969 }
00970
00971 int
00972 lame_set_VBR_min_bitrate_kbps(lame_global_flags * gfp, int VBR_min_bitrate_kbps)
00973 {
00974 gfp->VBR_min_bitrate_kbps = VBR_min_bitrate_kbps;
00975
00976 return 0;
00977 }
00978
00979 int
00980 lame_get_VBR_min_bitrate_kbps(const lame_global_flags * gfp)
00981 {
00982 return gfp->VBR_min_bitrate_kbps;
00983 }
00984
00985 int
00986 lame_set_VBR_max_bitrate_kbps(lame_global_flags * gfp, int VBR_max_bitrate_kbps)
00987 {
00988 gfp->VBR_max_bitrate_kbps = VBR_max_bitrate_kbps;
00989
00990 return 0;
00991 }
00992
00993 int
00994 lame_get_VBR_max_bitrate_kbps(const lame_global_flags * gfp)
00995 {
00996 return gfp->VBR_max_bitrate_kbps;
00997 }
00998
00999
01000
01001
01002
01003
01004 int
01005 lame_set_VBR_hard_min(lame_global_flags * gfp, int VBR_hard_min)
01006 {
01007
01008
01009
01010
01011
01012 if (0 > VBR_hard_min || 1 < VBR_hard_min)
01013 return -1;
01014
01015 gfp->VBR_hard_min = VBR_hard_min;
01016
01017 return 0;
01018 }
01019
01020 int
01021 lame_get_VBR_hard_min(const lame_global_flags * gfp)
01022 {
01023 assert(0 <= gfp->VBR_hard_min && 1 >= gfp->VBR_hard_min);
01024
01025 return gfp->VBR_hard_min;
01026 }
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038 int
01039 lame_set_lowpassfreq(lame_global_flags * gfp, int lowpassfreq)
01040 {
01041 gfp->lowpassfreq = lowpassfreq;
01042
01043 return 0;
01044 }
01045
01046 int
01047 lame_get_lowpassfreq(const lame_global_flags * gfp)
01048 {
01049 return gfp->lowpassfreq;
01050 }
01051
01052
01053
01054
01055
01056
01057 int
01058 lame_set_lowpasswidth(lame_global_flags * gfp, int lowpasswidth)
01059 {
01060 gfp->lowpasswidth = lowpasswidth;
01061
01062 return 0;
01063 }
01064
01065 int
01066 lame_get_lowpasswidth(const lame_global_flags * gfp)
01067 {
01068 return gfp->lowpasswidth;
01069 }
01070
01071
01072
01073
01074
01075
01076
01077 int
01078 lame_set_highpassfreq(lame_global_flags * gfp, int highpassfreq)
01079 {
01080 gfp->highpassfreq = highpassfreq;
01081
01082 return 0;
01083 }
01084
01085 int
01086 lame_get_highpassfreq(const lame_global_flags * gfp)
01087 {
01088 return gfp->highpassfreq;
01089 }
01090
01091
01092
01093
01094
01095
01096 int
01097 lame_set_highpasswidth(lame_global_flags * gfp, int highpasswidth)
01098 {
01099 gfp->highpasswidth = highpasswidth;
01100
01101 return 0;
01102 }
01103
01104 int
01105 lame_get_highpasswidth(const lame_global_flags * gfp)
01106 {
01107 return gfp->highpasswidth;
01108 }
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119 int
01120 lame_set_psy_model(lame_global_flags * gfp, int psy)
01121 {
01122 gfp->psymodel = psy;
01123 return 0;
01124 }
01125
01126 int
01127 lame_get_psy_model(const lame_global_flags * gfp)
01128 {
01129 return gfp->psymodel;
01130 }
01131
01132
01133 int
01134 lame_set_maskingadjust(lame_global_flags * gfp, float adjust)
01135 {
01136 gfp->maskingadjust = adjust;
01137 return 0;
01138 }
01139
01140 float
01141 lame_get_maskingadjust(const lame_global_flags * gfp)
01142 {
01143 return gfp->maskingadjust;
01144 }
01145
01146 int
01147 lame_set_maskingadjust_short(lame_global_flags * gfp, float adjust)
01148 {
01149 gfp->maskingadjust_short = adjust;
01150 return 0;
01151 }
01152
01153 float
01154 lame_get_maskingadjust_short(const lame_global_flags * gfp)
01155 {
01156 return gfp->maskingadjust_short;
01157 }
01158
01159
01160 int
01161 lame_set_ATHonly(lame_global_flags * gfp, int ATHonly)
01162 {
01163 gfp->ATHonly = ATHonly;
01164
01165 return 0;
01166 }
01167
01168 int
01169 lame_get_ATHonly(const lame_global_flags * gfp)
01170 {
01171 return gfp->ATHonly;
01172 }
01173
01174
01175
01176 int
01177 lame_set_ATHshort(lame_global_flags * gfp, int ATHshort)
01178 {
01179 gfp->ATHshort = ATHshort;
01180
01181 return 0;
01182 }
01183
01184 int
01185 lame_get_ATHshort(const lame_global_flags * gfp)
01186 {
01187 return gfp->ATHshort;
01188 }
01189
01190
01191
01192 int
01193 lame_set_noATH(lame_global_flags * gfp, int noATH)
01194 {
01195 gfp->noATH = noATH;
01196
01197 return 0;
01198 }
01199
01200 int
01201 lame_get_noATH(const lame_global_flags * gfp)
01202 {
01203 return gfp->noATH;
01204 }
01205
01206
01207
01208 int
01209 lame_set_ATHtype(lame_global_flags * gfp, int ATHtype)
01210 {
01211
01212 gfp->ATHtype = ATHtype;
01213
01214 return 0;
01215 }
01216
01217 int
01218 lame_get_ATHtype(const lame_global_flags * gfp)
01219 {
01220 return gfp->ATHtype;
01221 }
01222
01223
01224
01225 int
01226 lame_set_ATHcurve(lame_global_flags * gfp, float ATHcurve)
01227 {
01228 gfp->ATHcurve = ATHcurve;
01229
01230 return 0;
01231 }
01232
01233 float
01234 lame_get_ATHcurve(const lame_global_flags * gfp)
01235 {
01236 return gfp->ATHcurve;
01237 }
01238
01239
01240
01241 int
01242 lame_set_ATHlower(lame_global_flags * gfp, float ATHlower)
01243 {
01244 gfp->ATHlower = -ATHlower / 10.0;
01245 return 0;
01246 }
01247
01248 float
01249 lame_get_ATHlower(const lame_global_flags * gfp)
01250 {
01251 return -gfp->ATHlower * 10.0;
01252 }
01253
01254
01255
01256 int
01257 lame_set_athaa_type(lame_global_flags * gfp, int athaa_type)
01258 {
01259 gfp->athaa_type = athaa_type;
01260 return 0;
01261 }
01262
01263 int
01264 lame_get_athaa_type(const lame_global_flags * gfp)
01265 {
01266 return gfp->athaa_type;
01267 }
01268
01269
01270
01271 int
01272 lame_set_athaa_loudapprox(lame_global_flags * gfp, int athaa_loudapprox)
01273 {
01274 ERRORF(gfp->internal_flags, "--athaa-loudapprox is obsolete\n");
01275 return 0;
01276 }
01277
01278 int
01279 lame_get_athaa_loudapprox(const lame_global_flags * gfp)
01280 {
01281
01282 return 2;
01283 }
01284
01285
01286
01287 int
01288 lame_set_athaa_sensitivity(lame_global_flags * gfp, float athaa_sensitivity)
01289 {
01290 gfp->athaa_sensitivity = athaa_sensitivity;
01291
01292 return 0;
01293 }
01294
01295 float
01296 lame_get_athaa_sensitivity(const lame_global_flags * gfp)
01297 {
01298 return gfp->athaa_sensitivity;
01299 }
01300
01301
01302
01303 int
01304 lame_set_cwlimit(lame_global_flags * gfp, int cwlimit)
01305 {
01306 gfp->cwlimit = cwlimit;
01307
01308 return 0;
01309 }
01310
01311 int
01312 lame_get_cwlimit(const lame_global_flags * gfp)
01313 {
01314 return gfp->cwlimit;
01315 }
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325 int
01326 lame_set_allow_diff_short(lame_global_flags * gfp, int allow_diff_short)
01327 {
01328 gfp->short_blocks = allow_diff_short ? short_block_allowed : short_block_coupled;
01329
01330 return 0;
01331 }
01332
01333 int
01334 lame_get_allow_diff_short(const lame_global_flags * gfp)
01335 {
01336 if (gfp->short_blocks == short_block_allowed)
01337 return 1;
01338 else
01339 return 0;
01340 }
01341
01342
01343
01344 int
01345 lame_set_useTemporal(lame_global_flags * gfp, int useTemporal)
01346 {
01347
01348
01349
01350
01351
01352 if (0 > useTemporal || 1 < useTemporal)
01353 return -1;
01354
01355 gfp->useTemporal = useTemporal;
01356
01357 return 0;
01358 }
01359
01360 int
01361 lame_get_useTemporal(const lame_global_flags * gfp)
01362 {
01363 assert(0 <= gfp->useTemporal && 1 >= gfp->useTemporal);
01364
01365 return gfp->useTemporal;
01366 }
01367
01368
01369
01370 int
01371 lame_set_interChRatio(lame_global_flags * gfp, float ratio)
01372 {
01373
01374 if (!(0 <= ratio && ratio <= 1.0))
01375 return -1;
01376
01377 gfp->interChRatio = ratio;
01378
01379 return 0;
01380 }
01381
01382 float
01383 lame_get_interChRatio(const lame_global_flags * gfp)
01384 {
01385 assert((0 <= gfp->interChRatio && gfp->interChRatio <= 1.0) || (gfp->interChRatio == -1));
01386
01387 return gfp->interChRatio;
01388 }
01389
01390
01391
01392 int
01393 lame_set_substep(lame_global_flags * gfp, int method)
01394 {
01395 lame_internal_flags *gfc = gfp->internal_flags;
01396
01397 if (!(0 <= method && method <= 7))
01398 return -1;
01399
01400 gfc->substep_shaping = method;
01401 return 0;
01402 }
01403
01404 int
01405 lame_get_substep(const lame_global_flags * gfp)
01406 {
01407 lame_internal_flags *gfc = gfp->internal_flags;
01408 assert(0 <= gfc->substep_shaping && gfc->substep_shaping <= 7);
01409 return gfc->substep_shaping;
01410 }
01411
01412
01413 int
01414 lame_set_sfscale(lame_global_flags * gfp, int val)
01415 {
01416 if (val)
01417 gfp->internal_flags->noise_shaping = 2;
01418 else
01419 gfp->internal_flags->noise_shaping = 1;
01420 return 0;
01421 }
01422
01423 int
01424 lame_get_sfscale(const lame_global_flags * gfp)
01425 {
01426 return (gfp->internal_flags->noise_shaping == 2);
01427 }
01428
01429
01430 int
01431 lame_set_subblock_gain(lame_global_flags * gfp, int sbgain)
01432 {
01433 gfp->internal_flags->subblock_gain = sbgain;
01434 return sbgain;
01435 }
01436
01437 int
01438 lame_get_subblock_gain(const lame_global_flags * gfp)
01439 {
01440 return gfp->internal_flags->subblock_gain;
01441 }
01442
01443
01444
01445 int
01446 lame_set_no_short_blocks(lame_global_flags * gfp, int no_short_blocks)
01447 {
01448
01449
01450
01451 if (0 > no_short_blocks || 1 < no_short_blocks)
01452 return -1;
01453
01454 gfp->short_blocks = no_short_blocks ? short_block_dispensed : short_block_allowed;
01455
01456 return 0;
01457 }
01458
01459 int
01460 lame_get_no_short_blocks(const lame_global_flags * gfp)
01461 {
01462 switch (gfp->short_blocks) {
01463 default:
01464 case short_block_not_set:
01465 return -1;
01466 case short_block_dispensed:
01467 return 1;
01468 case short_block_allowed:
01469 case short_block_coupled:
01470 case short_block_forced:
01471 return 0;
01472 }
01473 }
01474
01475
01476
01477 int
01478 lame_set_force_short_blocks(lame_global_flags * gfp, int short_blocks)
01479 {
01480
01481
01482
01483 if (0 > short_blocks || 1 < short_blocks)
01484 return -1;
01485
01486 if (short_blocks == 1)
01487 gfp->short_blocks = short_block_forced;
01488 else if (gfp->short_blocks == short_block_forced)
01489 gfp->short_blocks = short_block_allowed;
01490
01491 return 0;
01492 }
01493
01494 int
01495 lame_get_force_short_blocks(const lame_global_flags * gfp)
01496 {
01497 switch (gfp->short_blocks) {
01498 default:
01499 case short_block_not_set:
01500 return -1;
01501 case short_block_dispensed:
01502 case short_block_allowed:
01503 case short_block_coupled:
01504 return 0;
01505 case short_block_forced:
01506 return 1;
01507 }
01508 }
01509
01510 int
01511 lame_set_short_threshold_lrm(lame_global_flags * gfp, float lrm)
01512 {
01513 lame_internal_flags *gfc = gfp->internal_flags;
01514 gfc->nsPsy.attackthre = lrm;
01515 return 0;
01516 }
01517
01518 float
01519 lame_get_short_threshold_lrm(const lame_global_flags * gfp)
01520 {
01521 lame_internal_flags *gfc = gfp->internal_flags;
01522 return gfc->nsPsy.attackthre;
01523 }
01524
01525 int
01526 lame_set_short_threshold_s(lame_global_flags * gfp, float s)
01527 {
01528 lame_internal_flags *gfc = gfp->internal_flags;
01529 gfc->nsPsy.attackthre_s = s;
01530 return 0;
01531 }
01532
01533 float
01534 lame_get_short_threshold_s(const lame_global_flags * gfp)
01535 {
01536 lame_internal_flags *gfc = gfp->internal_flags;
01537 return gfc->nsPsy.attackthre_s;
01538 }
01539
01540 int
01541 lame_set_short_threshold(lame_global_flags * gfp, float lrm, float s)
01542 {
01543 lame_set_short_threshold_lrm(gfp, lrm);
01544 lame_set_short_threshold_s(gfp, s);
01545 return 0;
01546 }
01547
01548
01549
01550
01551
01552
01553
01554
01555
01556
01557 int
01558 lame_set_emphasis(lame_global_flags * gfp, int emphasis)
01559 {
01560
01561 if (0 > emphasis || 4 <= emphasis)
01562 return -1;
01563
01564 gfp->emphasis = emphasis;
01565
01566 return 0;
01567 }
01568
01569 int
01570 lame_get_emphasis(const lame_global_flags * gfp)
01571 {
01572 assert(0 <= gfp->emphasis && 4 > gfp->emphasis);
01573
01574 return gfp->emphasis;
01575 }
01576
01577
01578
01579
01580
01581
01582
01583
01584
01585
01586
01587
01588
01589
01590 int
01591 lame_get_version(const lame_global_flags * gfp)
01592 {
01593 return gfp->version;
01594 }
01595
01596
01597
01598 int
01599 lame_get_encoder_delay(const lame_global_flags * gfp)
01600 {
01601 return gfp->encoder_delay;
01602 }
01603
01604
01605 int
01606 lame_get_encoder_padding(const lame_global_flags * gfp)
01607 {
01608 return gfp->encoder_padding;
01609 }
01610
01611
01612
01613 int
01614 lame_get_framesize(const lame_global_flags * gfp)
01615 {
01616 return gfp->framesize;
01617 }
01618
01619
01620
01621 int
01622 lame_get_frameNum(const lame_global_flags * gfp)
01623 {
01624 return gfp->frameNum;
01625 }
01626
01627 int
01628 lame_get_mf_samples_to_encode(const lame_global_flags * gfp)
01629 {
01630 lame_internal_flags *gfc = gfp->internal_flags;
01631 return gfc->mf_samples_to_encode;
01632 }
01633
01634 int CDECL
01635 lame_get_size_mp3buffer(const lame_global_flags * gfp)
01636 {
01637 int size;
01638 compute_flushbits(gfp, &size);
01639 return size;
01640 }
01641
01642 int
01643 lame_get_RadioGain(const lame_global_flags * gfp)
01644 {
01645 lame_internal_flags *gfc = gfp->internal_flags;
01646 return gfc->RadioGain;
01647 }
01648
01649 int
01650 lame_get_AudiophileGain(const lame_global_flags * gfp)
01651 {
01652 lame_internal_flags *gfc = gfp->internal_flags;
01653 return gfc->AudiophileGain;
01654 }
01655
01656 float
01657 lame_get_PeakSample(const lame_global_flags * gfp)
01658 {
01659 lame_internal_flags *gfc = gfp->internal_flags;
01660 return (float) gfc->PeakSample;
01661 }
01662
01663 int
01664 lame_get_noclipGainChange(const lame_global_flags * gfp)
01665 {
01666 lame_internal_flags *gfc = gfp->internal_flags;
01667 return gfc->noclipGainChange;
01668 }
01669
01670 float
01671 lame_get_noclipScale(const lame_global_flags * gfp)
01672 {
01673 lame_internal_flags *gfc = gfp->internal_flags;
01674 return gfc->noclipScale;
01675 }
01676
01677
01678
01679
01680
01681
01682 int
01683 lame_get_totalframes(const lame_global_flags * gfp)
01684 {
01685 int totalframes;
01686
01687 totalframes =
01688 2 + ((double) gfp->num_samples * gfp->out_samplerate) /
01689 ((double) gfp->in_samplerate * gfp->framesize);
01690
01691
01692
01693
01694
01695 return totalframes;
01696 }
01697
01698
01699
01700
01701
01702 int
01703 lame_set_preset(lame_global_flags * gfp, int preset)
01704 {
01705 gfp->preset = preset;
01706 return apply_preset(gfp, preset, 1);
01707 }
01708
01709
01710
01711 int
01712 lame_set_asm_optimizations(lame_global_flags * gfp, int optim, int mode)
01713 {
01714 mode = (mode == 1 ? 1 : 0);
01715 switch (optim) {
01716 case MMX:{
01717 gfp->asm_optimizations.mmx = mode;
01718 return optim;
01719 }
01720 case AMD_3DNOW:{
01721 gfp->asm_optimizations.amd3dnow = mode;
01722 return optim;
01723 }
01724 case SSE:{
01725 gfp->asm_optimizations.sse = mode;
01726 return optim;
01727 }
01728 default:
01729 return optim;
01730 }
01731 }
01732
01733
01734
01735
01736
01737
01738
01739
01740
01741
01742
01743
01744
01745
01746
01747
01748
01749 void
01750 lame_set_tune(lame_global_flags * gfp, float val)
01751 {
01752 gfp->tune_value_a = val;
01753 gfp->tune = 1;
01754 }
01755
01756
01757 void
01758 lame_set_msfix(lame_global_flags * gfp, double msfix)
01759 {
01760
01761 gfp->msfix = msfix;
01762 }
01763
01764 float
01765 lame_get_msfix(const lame_global_flags * gfp)
01766 {
01767 return gfp->msfix;
01768 }
01769
01770 int
01771 lame_set_preset_expopts(lame_global_flags * gfp, int preset_expopts)
01772 {
01773
01774 return 0;
01775 }
01776
01777 int
01778 lame_set_preset_notune(lame_global_flags * gfp, int preset_notune)
01779 {
01780 return 0;
01781 }
01782
01783
01784 void
01785 lame_set_quantization_type(lame_global_flags * gfp, int type)
01786 {
01787 gfp->quantization_type = type;
01788 }
01789
01790
01791 int
01792 lame_get_quantization_type(lame_global_flags * gfp)
01793 {
01794 return gfp->quantization_type;
01795 }