| 1 |
/* -*- mode: C; mode: fold -*- */ |
| 2 |
/* |
| 3 |
* set/get functions for lame_global_flags |
| 4 |
* |
| 5 |
* Copyright (c) 2001-2005 Alexander Leidinger |
| 6 |
* |
| 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. |
| 11 |
* |
| 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. |
| 16 |
* |
| 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. |
| 21 |
*/ |
| 22 |
|
| 23 |
/* $Id$ */ |
| 24 |
|
| 25 |
#ifdef HAVE_CONFIG_H |
| 26 |
# include <config.h> |
| 27 |
#endif |
| 28 |
|
| 29 |
#include "lame.h" |
| 30 |
#include "machine.h" |
| 31 |
#include "encoder.h" |
| 32 |
#include "util.h" |
| 33 |
#include "bitstream.h" /* because of compute_flushbits */ |
| 34 |
|
| 35 |
#include "set_get.h" |
| 36 |
#include "lame_global_flags.h" |
| 37 |
|
| 38 |
/* |
| 39 |
* input stream description |
| 40 |
*/ |
| 41 |
|
| 42 |
|
| 43 |
/* number of samples */ |
| 44 |
/* it's unlikely for this function to return an error */ |
| 45 |
int |
| 46 |
lame_set_num_samples(lame_global_flags * gfp, unsigned long num_samples) |
| 47 |
{ |
| 48 |
if (is_lame_global_flags_valid(gfp)) { |
| 49 |
/* default = 2^32-1 */ |
| 50 |
gfp->num_samples = num_samples; |
| 51 |
return 0; |
| 52 |
} |
| 53 |
return -1; |
| 54 |
} |
| 55 |
|
| 56 |
unsigned long |
| 57 |
lame_get_num_samples(const lame_global_flags * gfp) |
| 58 |
{ |
| 59 |
if (is_lame_global_flags_valid(gfp)) { |
| 60 |
return gfp->num_samples; |
| 61 |
} |
| 62 |
return 0; |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
/* input samplerate */ |
| 67 |
int |
| 68 |
lame_set_in_samplerate(lame_global_flags * gfp, int in_samplerate) |
| 69 |
{ |
| 70 |
if (is_lame_global_flags_valid(gfp)) { |
| 71 |
if (in_samplerate < 1) |
| 72 |
return -1; |
| 73 |
/* input sample rate in Hz, default = 44100 Hz */ |
| 74 |
gfp->samplerate_in = in_samplerate; |
| 75 |
return 0; |
| 76 |
} |
| 77 |
return -1; |
| 78 |
} |
| 79 |
|
| 80 |
int |
| 81 |
lame_get_in_samplerate(const lame_global_flags * gfp) |
| 82 |
{ |
| 83 |
if (is_lame_global_flags_valid(gfp)) { |
| 84 |
return gfp->samplerate_in; |
| 85 |
} |
| 86 |
return 0; |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
/* number of channels in input stream */ |
| 91 |
int |
| 92 |
lame_set_num_channels(lame_global_flags * gfp, int num_channels) |
| 93 |
{ |
| 94 |
if (is_lame_global_flags_valid(gfp)) { |
| 95 |
/* default = 2 */ |
| 96 |
if (2 < num_channels || 0 >= num_channels) { |
| 97 |
return -1; /* we don't support more than 2 channels */ |
| 98 |
} |
| 99 |
gfp->num_channels = num_channels; |
| 100 |
return 0; |
| 101 |
} |
| 102 |
return -1; |
| 103 |
} |
| 104 |
|
| 105 |
int |
| 106 |
lame_get_num_channels(const lame_global_flags * gfp) |
| 107 |
{ |
| 108 |
if (is_lame_global_flags_valid(gfp)) { |
| 109 |
return gfp->num_channels; |
| 110 |
} |
| 111 |
return 0; |
| 112 |
} |
| 113 |
|
| 114 |
|
| 115 |
/* scale the input by this amount before encoding (not used for decoding) */ |
| 116 |
int |
| 117 |
lame_set_scale(lame_global_flags * gfp, float scale) |
| 118 |
{ |
| 119 |
if (is_lame_global_flags_valid(gfp)) { |
| 120 |
/* default = 1 */ |
| 121 |
gfp->scale = scale; |
| 122 |
return 0; |
| 123 |
} |
| 124 |
return -1; |
| 125 |
} |
| 126 |
|
| 127 |
float |
| 128 |
lame_get_scale(const lame_global_flags * gfp) |
| 129 |
{ |
| 130 |
if (is_lame_global_flags_valid(gfp)) { |
| 131 |
return gfp->scale; |
| 132 |
} |
| 133 |
return 0; |
| 134 |
} |
| 135 |
|
| 136 |
|
| 137 |
/* scale the channel 0 (left) input by this amount before |
| 138 |
encoding (not used for decoding) */ |
| 139 |
int |
| 140 |
lame_set_scale_left(lame_global_flags * gfp, float scale) |
| 141 |
{ |
| 142 |
if (is_lame_global_flags_valid(gfp)) { |
| 143 |
/* default = 1 */ |
| 144 |
gfp->scale_left = scale; |
| 145 |
return 0; |
| 146 |
} |
| 147 |
return -1; |
| 148 |
} |
| 149 |
|
| 150 |
float |
| 151 |
lame_get_scale_left(const lame_global_flags * gfp) |
| 152 |
{ |
| 153 |
if (is_lame_global_flags_valid(gfp)) { |
| 154 |
return gfp->scale_left; |
| 155 |
} |
| 156 |
return 0; |
| 157 |
} |
| 158 |
|
| 159 |
|
| 160 |
/* scale the channel 1 (right) input by this amount before |
| 161 |
encoding (not used for decoding) */ |
| 162 |
int |
| 163 |
lame_set_scale_right(lame_global_flags * gfp, float scale) |
| 164 |
{ |
| 165 |
if (is_lame_global_flags_valid(gfp)) { |
| 166 |
/* default = 1 */ |
| 167 |
gfp->scale_right = scale; |
| 168 |
return 0; |
| 169 |
} |
| 170 |
return -1; |
| 171 |
} |
| 172 |
|
| 173 |
float |
| 174 |
lame_get_scale_right(const lame_global_flags * gfp) |
| 175 |
{ |
| 176 |
if (is_lame_global_flags_valid(gfp)) { |
| 177 |
return gfp->scale_right; |
| 178 |
} |
| 179 |
return 0; |
| 180 |
} |
| 181 |
|
| 182 |
|
| 183 |
/* output sample rate in Hz */ |
| 184 |
int |
| 185 |
lame_set_out_samplerate(lame_global_flags * gfp, int out_samplerate) |
| 186 |
{ |
| 187 |
if (is_lame_global_flags_valid(gfp)) { |
| 188 |
/* |
| 189 |
* default = 0: LAME picks best value based on the amount |
| 190 |
* of compression |
| 191 |
* MPEG only allows: |
| 192 |
* MPEG1 32, 44.1, 48khz |
| 193 |
* MPEG2 16, 22.05, 24 |
| 194 |
* MPEG2.5 8, 11.025, 12 |
| 195 |
* |
| 196 |
* (not used by decoding routines) |
| 197 |
*/ |
| 198 |
if (out_samplerate != 0) { |
| 199 |
int v=0; |
| 200 |
if (SmpFrqIndex(out_samplerate, &v) < 0) |
| 201 |
return -1; |
| 202 |
} |
| 203 |
gfp->samplerate_out = out_samplerate; |
| 204 |
return 0; |
| 205 |
} |
| 206 |
return -1; |
| 207 |
} |
| 208 |
|
| 209 |
int |
| 210 |
lame_get_out_samplerate(const lame_global_flags * gfp) |
| 211 |
{ |
| 212 |
if (is_lame_global_flags_valid(gfp)) { |
| 213 |
return gfp->samplerate_out; |
| 214 |
} |
| 215 |
return 0; |
| 216 |
} |
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
/* |
| 222 |
* general control parameters |
| 223 |
*/ |
| 224 |
|
| 225 |
/* collect data for an MP3 frame analzyer */ |
| 226 |
int |
| 227 |
lame_set_analysis(lame_global_flags * gfp, int analysis) |
| 228 |
{ |
| 229 |
if (is_lame_global_flags_valid(gfp)) { |
| 230 |
/* default = 0 */ |
| 231 |
|
| 232 |
/* enforce disable/enable meaning, if we need more than two values |
| 233 |
we need to switch to an enum to have an apropriate representation |
| 234 |
of the possible meanings of the value */ |
| 235 |
if (0 > analysis || 1 < analysis) |
| 236 |
return -1; |
| 237 |
gfp->analysis = analysis; |
| 238 |
return 0; |
| 239 |
} |
| 240 |
return -1; |
| 241 |
} |
| 242 |
|
| 243 |
int |
| 244 |
lame_get_analysis(const lame_global_flags * gfp) |
| 245 |
{ |
| 246 |
if (is_lame_global_flags_valid(gfp)) { |
| 247 |
assert(0 <= gfp->analysis && 1 >= gfp->analysis); |
| 248 |
return gfp->analysis; |
| 249 |
} |
| 250 |
return 0; |
| 251 |
} |
| 252 |
|
| 253 |
|
| 254 |
/* write a Xing VBR header frame */ |
| 255 |
int |
| 256 |
lame_set_bWriteVbrTag(lame_global_flags * gfp, int bWriteVbrTag) |
| 257 |
{ |
| 258 |
if (is_lame_global_flags_valid(gfp)) { |
| 259 |
/* default = 1 (on) for VBR/ABR modes, 0 (off) for CBR mode */ |
| 260 |
|
| 261 |
/* enforce disable/enable meaning, if we need more than two values |
| 262 |
we need to switch to an enum to have an apropriate representation |
| 263 |
of the possible meanings of the value */ |
| 264 |
if (0 > bWriteVbrTag || 1 < bWriteVbrTag) |
| 265 |
return -1; |
| 266 |
gfp->write_lame_tag = bWriteVbrTag; |
| 267 |
return 0; |
| 268 |
} |
| 269 |
return -1; |
| 270 |
} |
| 271 |
|
| 272 |
int |
| 273 |
lame_get_bWriteVbrTag(const lame_global_flags * gfp) |
| 274 |
{ |
| 275 |
if (is_lame_global_flags_valid(gfp)) { |
| 276 |
assert(0 <= gfp->write_lame_tag && 1 >= gfp->write_lame_tag); |
| 277 |
return gfp->write_lame_tag; |
| 278 |
} |
| 279 |
return 0; |
| 280 |
} |
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
/* decode only, use lame/mpglib to convert mp3 to wav */ |
| 285 |
int |
| 286 |
lame_set_decode_only(lame_global_flags * gfp, int decode_only) |
| 287 |
{ |
| 288 |
if (is_lame_global_flags_valid(gfp)) { |
| 289 |
/* default = 0 (disabled) */ |
| 290 |
|
| 291 |
/* enforce disable/enable meaning, if we need more than two values |
| 292 |
we need to switch to an enum to have an apropriate representation |
| 293 |
of the possible meanings of the value */ |
| 294 |
if (0 > decode_only || 1 < decode_only) |
| 295 |
return -1; |
| 296 |
gfp->decode_only = decode_only; |
| 297 |
return 0; |
| 298 |
} |
| 299 |
return -1; |
| 300 |
} |
| 301 |
|
| 302 |
int |
| 303 |
lame_get_decode_only(const lame_global_flags * gfp) |
| 304 |
{ |
| 305 |
if (is_lame_global_flags_valid(gfp)) { |
| 306 |
assert(0 <= gfp->decode_only && 1 >= gfp->decode_only); |
| 307 |
return gfp->decode_only; |
| 308 |
} |
| 309 |
return 0; |
| 310 |
} |
| 311 |
|
| 312 |
|
| 313 |
#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED |
| 314 |
/* 1=encode a Vorbis .ogg file. default=0 */ |
| 315 |
/* DEPRECATED */ |
| 316 |
int CDECL lame_set_ogg(lame_global_flags *, int); |
| 317 |
int CDECL lame_get_ogg(const lame_global_flags *); |
| 318 |
#else |
| 319 |
#endif |
| 320 |
|
| 321 |
/* encode a Vorbis .ogg file */ |
| 322 |
/* DEPRECATED */ |
| 323 |
int |
| 324 |
lame_set_ogg(lame_global_flags * gfp, int ogg) |
| 325 |
{ |
| 326 |
(void) gfp; |
| 327 |
(void) ogg; |
| 328 |
return -1; |
| 329 |
} |
| 330 |
|
| 331 |
int |
| 332 |
lame_get_ogg(const lame_global_flags * gfp) |
| 333 |
{ |
| 334 |
(void) gfp; |
| 335 |
return 0; |
| 336 |
} |
| 337 |
|
| 338 |
|
| 339 |
/* |
| 340 |
* Internal algorithm selection. |
| 341 |
* True quality is determined by the bitrate but this variable will effect |
| 342 |
* quality by selecting expensive or cheap algorithms. |
| 343 |
* quality=0..9. 0=best (very slow). 9=worst. |
| 344 |
* recommended: 3 near-best quality, not too slow |
| 345 |
* 5 good quality, fast |
| 346 |
* 7 ok quality, really fast |
| 347 |
*/ |
| 348 |
int |
| 349 |
lame_set_quality(lame_global_flags * gfp, int quality) |
| 350 |
{ |
| 351 |
if (is_lame_global_flags_valid(gfp)) { |
| 352 |
if (quality < 0) { |
| 353 |
gfp->quality = 0; |
| 354 |
} |
| 355 |
else if (quality > 9) { |
| 356 |
gfp->quality = 9; |
| 357 |
} |
| 358 |
else { |
| 359 |
gfp->quality = quality; |
| 360 |
} |
| 361 |
return 0; |
| 362 |
} |
| 363 |
return -1; |
| 364 |
} |
| 365 |
|
| 366 |
int |
| 367 |
lame_get_quality(const lame_global_flags * gfp) |
| 368 |
{ |
| 369 |
if (is_lame_global_flags_valid(gfp)) { |
| 370 |
return gfp->quality; |
| 371 |
} |
| 372 |
return 0; |
| 373 |
} |
| 374 |
|
| 375 |
|
| 376 |
/* mode = STEREO, JOINT_STEREO, DUAL_CHANNEL (not supported), MONO */ |
| 377 |
int |
| 378 |
lame_set_mode(lame_global_flags * gfp, MPEG_mode mode) |
| 379 |
{ |
| 380 |
if (is_lame_global_flags_valid(gfp)) { |
| 381 |
int mpg_mode = mode; |
| 382 |
/* default: lame chooses based on compression ratio and input channels */ |
| 383 |
if (mpg_mode < 0 || MAX_INDICATOR <= mpg_mode) |
| 384 |
return -1; /* Unknown MPEG mode! */ |
| 385 |
gfp->mode = mode; |
| 386 |
return 0; |
| 387 |
} |
| 388 |
return -1; |
| 389 |
} |
| 390 |
|
| 391 |
MPEG_mode |
| 392 |
lame_get_mode(const lame_global_flags * gfp) |
| 393 |
{ |
| 394 |
if (is_lame_global_flags_valid(gfp)) { |
| 395 |
assert(gfp->mode < MAX_INDICATOR); |
| 396 |
return gfp->mode; |
| 397 |
} |
| 398 |
return NOT_SET; |
| 399 |
} |
| 400 |
|
| 401 |
|
| 402 |
#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED |
| 403 |
/* |
| 404 |
mode_automs. Use a M/S mode with a switching threshold based on |
| 405 |
compression ratio |
| 406 |
DEPRECATED |
| 407 |
*/ |
| 408 |
int CDECL lame_set_mode_automs(lame_global_flags *, int); |
| 409 |
int CDECL lame_get_mode_automs(const lame_global_flags *); |
| 410 |
#else |
| 411 |
#endif |
| 412 |
|
| 413 |
/* Us a M/S mode with a switching threshold based on compression ratio */ |
| 414 |
/* DEPRECATED */ |
| 415 |
int |
| 416 |
lame_set_mode_automs(lame_global_flags * gfp, int mode_automs) |
| 417 |
{ |
| 418 |
if (is_lame_global_flags_valid(gfp)) { |
| 419 |
/* default = 0 (disabled) */ |
| 420 |
|
| 421 |
/* enforce disable/enable meaning, if we need more than two values |
| 422 |
we need to switch to an enum to have an apropriate representation |
| 423 |
of the possible meanings of the value */ |
| 424 |
if (0 > mode_automs || 1 < mode_automs) |
| 425 |
return -1; |
| 426 |
lame_set_mode(gfp, JOINT_STEREO); |
| 427 |
return 0; |
| 428 |
} |
| 429 |
return -1; |
| 430 |
} |
| 431 |
|
| 432 |
int |
| 433 |
lame_get_mode_automs(const lame_global_flags * gfp) |
| 434 |
{ |
| 435 |
(void) gfp; |
| 436 |
return 1; |
| 437 |
} |
| 438 |
|
| 439 |
|
| 440 |
/* |
| 441 |
* Force M/S for all frames. For testing only. |
| 442 |
* Requires mode = 1. |
| 443 |
*/ |
| 444 |
int |
| 445 |
lame_set_force_ms(lame_global_flags * gfp, int force_ms) |
| 446 |
{ |
| 447 |
if (is_lame_global_flags_valid(gfp)) { |
| 448 |
/* default = 0 (disabled) */ |
| 449 |
|
| 450 |
/* enforce disable/enable meaning, if we need more than two values |
| 451 |
we need to switch to an enum to have an apropriate representation |
| 452 |
of the possible meanings of the value */ |
| 453 |
if (0 > force_ms || 1 < force_ms) |
| 454 |
return -1; |
| 455 |
gfp->force_ms = force_ms; |
| 456 |
return 0; |
| 457 |
} |
| 458 |
return -1; |
| 459 |
} |
| 460 |
|
| 461 |
int |
| 462 |
lame_get_force_ms(const lame_global_flags * gfp) |
| 463 |
{ |
| 464 |
if (is_lame_global_flags_valid(gfp)) { |
| 465 |
assert(0 <= gfp->force_ms && 1 >= gfp->force_ms); |
| 466 |
return gfp->force_ms; |
| 467 |
} |
| 468 |
return 0; |
| 469 |
} |
| 470 |
|
| 471 |
|
| 472 |
/* Use free_format. */ |
| 473 |
int |
| 474 |
lame_set_free_format(lame_global_flags * gfp, int free_format) |
| 475 |
{ |
| 476 |
if (is_lame_global_flags_valid(gfp)) { |
| 477 |
/* default = 0 (disabled) */ |
| 478 |
|
| 479 |
/* enforce disable/enable meaning, if we need more than two values |
| 480 |
we need to switch to an enum to have an apropriate representation |
| 481 |
of the possible meanings of the value */ |
| 482 |
if (0 > free_format || 1 < free_format) |
| 483 |
return -1; |
| 484 |
gfp->free_format = free_format; |
| 485 |
return 0; |
| 486 |
} |
| 487 |
return -1; |
| 488 |
} |
| 489 |
|
| 490 |
int |
| 491 |
lame_get_free_format(const lame_global_flags * gfp) |
| 492 |
{ |
| 493 |
if (is_lame_global_flags_valid(gfp)) { |
| 494 |
assert(0 <= gfp->free_format && 1 >= gfp->free_format); |
| 495 |
return gfp->free_format; |
| 496 |
} |
| 497 |
return 0; |
| 498 |
} |
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
/* Perform ReplayGain analysis */ |
| 503 |
int |
| 504 |
lame_set_findReplayGain(lame_global_flags * gfp, int findReplayGain) |
| 505 |
{ |
| 506 |
if (is_lame_global_flags_valid(gfp)) { |
| 507 |
/* default = 0 (disabled) */ |
| 508 |
|
| 509 |
/* enforce disable/enable meaning, if we need more than two values |
| 510 |
we need to switch to an enum to have an apropriate representation |
| 511 |
of the possible meanings of the value */ |
| 512 |
if (0 > findReplayGain || 1 < findReplayGain) |
| 513 |
return -1; |
| 514 |
gfp->findReplayGain = findReplayGain; |
| 515 |
return 0; |
| 516 |
} |
| 517 |
return -1; |
| 518 |
} |
| 519 |
|
| 520 |
int |
| 521 |
lame_get_findReplayGain(const lame_global_flags * gfp) |
| 522 |
{ |
| 523 |
if (is_lame_global_flags_valid(gfp)) { |
| 524 |
assert(0 <= gfp->findReplayGain && 1 >= gfp->findReplayGain); |
| 525 |
return gfp->findReplayGain; |
| 526 |
} |
| 527 |
return 0; |
| 528 |
} |
| 529 |
|
| 530 |
|
| 531 |
/* Decode on the fly. Find the peak sample. If ReplayGain analysis is |
| 532 |
enabled then perform it on the decoded data. */ |
| 533 |
int |
| 534 |
lame_set_decode_on_the_fly(lame_global_flags * gfp, int decode_on_the_fly) |
| 535 |
{ |
| 536 |
if (is_lame_global_flags_valid(gfp)) { |
| 537 |
#ifndef DECODE_ON_THE_FLY |
| 538 |
return -1; |
| 539 |
#else |
| 540 |
/* default = 0 (disabled) */ |
| 541 |
|
| 542 |
/* enforce disable/enable meaning, if we need more than two values |
| 543 |
we need to switch to an enum to have an apropriate representation |
| 544 |
of the possible meanings of the value */ |
| 545 |
if (0 > decode_on_the_fly || 1 < decode_on_the_fly) |
| 546 |
return -1; |
| 547 |
|
| 548 |
gfp->decode_on_the_fly = decode_on_the_fly; |
| 549 |
|
| 550 |
return 0; |
| 551 |
#endif |
| 552 |
} |
| 553 |
return -1; |
| 554 |
} |
| 555 |
|
| 556 |
int |
| 557 |
lame_get_decode_on_the_fly(const lame_global_flags * gfp) |
| 558 |
{ |
| 559 |
if (is_lame_global_flags_valid(gfp)) { |
| 560 |
assert(0 <= gfp->decode_on_the_fly && 1 >= gfp->decode_on_the_fly); |
| 561 |
return gfp->decode_on_the_fly; |
| 562 |
} |
| 563 |
return 0; |
| 564 |
} |
| 565 |
|
| 566 |
#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED |
| 567 |
/* DEPRECATED: now does the same as lame_set_findReplayGain() |
| 568 |
default = 0 (disabled) */ |
| 569 |
int CDECL lame_set_ReplayGain_input(lame_global_flags *, int); |
| 570 |
int CDECL lame_get_ReplayGain_input(const lame_global_flags *); |
| 571 |
|
| 572 |
/* DEPRECATED: now does the same as |
| 573 |
lame_set_decode_on_the_fly() && lame_set_findReplayGain() |
| 574 |
default = 0 (disabled) */ |
| 575 |
int CDECL lame_set_ReplayGain_decode(lame_global_flags *, int); |
| 576 |
int CDECL lame_get_ReplayGain_decode(const lame_global_flags *); |
| 577 |
|
| 578 |
/* DEPRECATED: now does the same as lame_set_decode_on_the_fly() |
| 579 |
default = 0 (disabled) */ |
| 580 |
int CDECL lame_set_findPeakSample(lame_global_flags *, int); |
| 581 |
int CDECL lame_get_findPeakSample(const lame_global_flags *); |
| 582 |
#else |
| 583 |
#endif |
| 584 |
|
| 585 |
/* DEPRECATED. same as lame_set_decode_on_the_fly() */ |
| 586 |
int |
| 587 |
lame_set_findPeakSample(lame_global_flags * gfp, int arg) |
| 588 |
{ |
| 589 |
return lame_set_decode_on_the_fly(gfp, arg); |
| 590 |
} |
| 591 |
|
| 592 |
int |
| 593 |
lame_get_findPeakSample(const lame_global_flags * gfp) |
| 594 |
{ |
| 595 |
return lame_get_decode_on_the_fly(gfp); |
| 596 |
} |
| 597 |
|
| 598 |
/* DEPRECATED. same as lame_set_findReplayGain() */ |
| 599 |
int |
| 600 |
lame_set_ReplayGain_input(lame_global_flags * gfp, int arg) |
| 601 |
{ |
| 602 |
return lame_set_findReplayGain(gfp, arg); |
| 603 |
} |
| 604 |
|
| 605 |
int |
| 606 |
lame_get_ReplayGain_input(const lame_global_flags * gfp) |
| 607 |
{ |
| 608 |
return lame_get_findReplayGain(gfp); |
| 609 |
} |
| 610 |
|
| 611 |
/* DEPRECATED. same as lame_set_decode_on_the_fly() && |
| 612 |
lame_set_findReplayGain() */ |
| 613 |
int |
| 614 |
lame_set_ReplayGain_decode(lame_global_flags * gfp, int arg) |
| 615 |
{ |
| 616 |
if (lame_set_decode_on_the_fly(gfp, arg) < 0 || lame_set_findReplayGain(gfp, arg) < 0) |
| 617 |
return -1; |
| 618 |
else |
| 619 |
return 0; |
| 620 |
} |
| 621 |
|
| 622 |
int |
| 623 |
lame_get_ReplayGain_decode(const lame_global_flags * gfp) |
| 624 |
{ |
| 625 |
if (lame_get_decode_on_the_fly(gfp) > 0 && lame_get_findReplayGain(gfp) > 0) |
| 626 |
return 1; |
| 627 |
else |
| 628 |
return 0; |
| 629 |
} |
| 630 |
|
| 631 |
|
| 632 |
/* set and get some gapless encoding flags */ |
| 633 |
|
| 634 |
int |
| 635 |
lame_set_nogap_total(lame_global_flags * gfp, int the_nogap_total) |
| 636 |
{ |
| 637 |
if (is_lame_global_flags_valid(gfp)) { |
| 638 |
gfp->nogap_total = the_nogap_total; |
| 639 |
return 0; |
| 640 |
} |
| 641 |
return -1; |
| 642 |
} |
| 643 |
|
| 644 |
int |
| 645 |
lame_get_nogap_total(const lame_global_flags * gfp) |
| 646 |
{ |
| 647 |
if (is_lame_global_flags_valid(gfp)) { |
| 648 |
return gfp->nogap_total; |
| 649 |
} |
| 650 |
return 0; |
| 651 |
} |
| 652 |
|
| 653 |
int |
| 654 |
lame_set_nogap_currentindex(lame_global_flags * gfp, int the_nogap_index) |
| 655 |
{ |
| 656 |
if (is_lame_global_flags_valid(gfp)) { |
| 657 |
gfp->nogap_current = the_nogap_index; |
| 658 |
return 0; |
| 659 |
} |
| 660 |
return -1; |
| 661 |
} |
| 662 |
|
| 663 |
int |
| 664 |
lame_get_nogap_currentindex(const lame_global_flags * gfp) |
| 665 |
{ |
| 666 |
if (is_lame_global_flags_valid(gfp)) { |
| 667 |
return gfp->nogap_current; |
| 668 |
} |
| 669 |
return 0; |
| 670 |
} |
| 671 |
|
| 672 |
|
| 673 |
/* message handlers */ |
| 674 |
int |
| 675 |
lame_set_errorf(lame_global_flags * gfp, void (*func) (const char *, va_list)) |
| 676 |
{ |
| 677 |
if (is_lame_global_flags_valid(gfp)) { |
| 678 |
gfp->report.errorf = func; |
| 679 |
return 0; |
| 680 |
} |
| 681 |
return -1; |
| 682 |
} |
| 683 |
|
| 684 |
int |
| 685 |
lame_set_debugf(lame_global_flags * gfp, void (*func) (const char *, va_list)) |
| 686 |
{ |
| 687 |
if (is_lame_global_flags_valid(gfp)) { |
| 688 |
gfp->report.debugf = func; |
| 689 |
return 0; |
| 690 |
} |
| 691 |
return -1; |
| 692 |
} |
| 693 |
|
| 694 |
int |
| 695 |
lame_set_msgf(lame_global_flags * gfp, void (*func) (const char *, va_list)) |
| 696 |
{ |
| 697 |
if (is_lame_global_flags_valid(gfp)) { |
| 698 |
gfp->report.msgf = func; |
| 699 |
return 0; |
| 700 |
} |
| 701 |
return -1; |
| 702 |
} |
| 703 |
|
| 704 |
|
| 705 |
/* |
| 706 |
* Set one of |
| 707 |
* - brate |
| 708 |
* - compression ratio. |
| 709 |
* |
| 710 |
* Default is compression ratio of 11. |
| 711 |
*/ |
| 712 |
int |
| 713 |
lame_set_brate(lame_global_flags * gfp, int brate) |
| 714 |
{ |
| 715 |
if (is_lame_global_flags_valid(gfp)) { |
| 716 |
gfp->brate = brate; |
| 717 |
if (brate > 320) { |
| 718 |
gfp->disable_reservoir = 1; |
| 719 |
} |
| 720 |
return 0; |
| 721 |
} |
| 722 |
return -1; |
| 723 |
} |
| 724 |
|
| 725 |
int |
| 726 |
lame_get_brate(const lame_global_flags * gfp) |
| 727 |
{ |
| 728 |
if (is_lame_global_flags_valid(gfp)) { |
| 729 |
return gfp->brate; |
| 730 |
} |
| 731 |
return 0; |
| 732 |
} |
| 733 |
|
| 734 |
int |
| 735 |
lame_set_compression_ratio(lame_global_flags * gfp, float compression_ratio) |
| 736 |
{ |
| 737 |
if (is_lame_global_flags_valid(gfp)) { |
| 738 |
gfp->compression_ratio = compression_ratio; |
| 739 |
return 0; |
| 740 |
} |
| 741 |
return -1; |
| 742 |
} |
| 743 |
|
| 744 |
float |
| 745 |
lame_get_compression_ratio(const lame_global_flags * gfp) |
| 746 |
{ |
| 747 |
if (is_lame_global_flags_valid(gfp)) { |
| 748 |
return gfp->compression_ratio; |
| 749 |
} |
| 750 |
return 0; |
| 751 |
} |
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
/* |
| 757 |
* frame parameters |
| 758 |
*/ |
| 759 |
|
| 760 |
/* Mark as copyright protected. */ |
| 761 |
int |
| 762 |
lame_set_copyright(lame_global_flags * gfp, int copyright) |
| 763 |
{ |
| 764 |
if (is_lame_global_flags_valid(gfp)) { |
| 765 |
/* default = 0 (disabled) */ |
| 766 |
|
| 767 |
/* enforce disable/enable meaning, if we need more than two values |
| 768 |
we need to switch to an enum to have an apropriate representation |
| 769 |
of the possible meanings of the value */ |
| 770 |
if (0 > copyright || 1 < copyright) |
| 771 |
return -1; |
| 772 |
gfp->copyright = copyright; |
| 773 |
return 0; |
| 774 |
} |
| 775 |
return -1; |
| 776 |
} |
| 777 |
|
| 778 |
int |
| 779 |
lame_get_copyright(const lame_global_flags * gfp) |
| 780 |
{ |
| 781 |
if (is_lame_global_flags_valid(gfp)) { |
| 782 |
assert(0 <= gfp->copyright && 1 >= gfp->copyright); |
| 783 |
return gfp->copyright; |
| 784 |
} |
| 785 |
return 0; |
| 786 |
} |
| 787 |
|
| 788 |
|
| 789 |
/* Mark as original. */ |
| 790 |
int |
| 791 |
lame_set_original(lame_global_flags * gfp, int original) |
| 792 |
{ |
| 793 |
if (is_lame_global_flags_valid(gfp)) { |
| 794 |
/* default = 1 (enabled) */ |
| 795 |
|
| 796 |
/* enforce disable/enable meaning, if we need more than two values |
| 797 |
we need to switch to an enum to have an apropriate representation |
| 798 |
of the possible meanings of the value */ |
| 799 |
if (0 > original || 1 < original) |
| 800 |
return -1; |
| 801 |
gfp->original = original; |
| 802 |
return 0; |
| 803 |
} |
| 804 |
return -1; |
| 805 |
} |
| 806 |
|
| 807 |
int |
| 808 |
lame_get_original(const lame_global_flags * gfp) |
| 809 |
{ |
| 810 |
if (is_lame_global_flags_valid(gfp)) { |
| 811 |
assert(0 <= gfp->original && 1 >= gfp->original); |
| 812 |
return gfp->original; |
| 813 |
} |
| 814 |
return 0; |
| 815 |
} |
| 816 |
|
| 817 |
|
| 818 |
/* |
| 819 |
* error_protection. |
| 820 |
* Use 2 bytes from each frame for CRC checksum. |
| 821 |
*/ |
| 822 |
int |
| 823 |
lame_set_error_protection(lame_global_flags * gfp, int error_protection) |
| 824 |
{ |
| 825 |
if (is_lame_global_flags_valid(gfp)) { |
| 826 |
/* default = 0 (disabled) */ |
| 827 |
|
| 828 |
/* enforce disable/enable meaning, if we need more than two values |
| 829 |
we need to switch to an enum to have an apropriate representation |
| 830 |
of the possible meanings of the value */ |
| 831 |
if (0 > error_protection || 1 < error_protection) |
| 832 |
return -1; |
| 833 |
gfp->error_protection = error_protection; |
| 834 |
return 0; |
| 835 |
} |
| 836 |
return -1; |
| 837 |
} |
| 838 |
|
| 839 |
int |
| 840 |
lame_get_error_protection(const lame_global_flags * gfp) |
| 841 |
{ |
| 842 |
if (is_lame_global_flags_valid(gfp)) { |
| 843 |
assert(0 <= gfp->error_protection && 1 >= gfp->error_protection); |
| 844 |
return gfp->error_protection; |
| 845 |
} |
| 846 |
return 0; |
| 847 |
} |
| 848 |
|
| 849 |
|
| 850 |
#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED |
| 851 |
/* padding_type. 0=pad no frames 1=pad all frames 2=adjust padding(default) */ |
| 852 |
int CDECL lame_set_padding_type(lame_global_flags *, Padding_type); |
| 853 |
Padding_type CDECL lame_get_padding_type(const lame_global_flags *); |
| 854 |
#else |
| 855 |
#endif |
| 856 |
|
| 857 |
/* |
| 858 |
* padding_type. |
| 859 |
* PAD_NO = pad no frames |
| 860 |
* PAD_ALL = pad all frames |
| 861 |
* PAD_ADJUST = adjust padding |
| 862 |
*/ |
| 863 |
int |
| 864 |
lame_set_padding_type(lame_global_flags * gfp, Padding_type padding_type) |
| 865 |
{ |
| 866 |
(void) gfp; |
| 867 |
(void) padding_type; |
| 868 |
return 0; |
| 869 |
} |
| 870 |
|
| 871 |
Padding_type |
| 872 |
lame_get_padding_type(const lame_global_flags * gfp) |
| 873 |
{ |
| 874 |
(void) gfp; |
| 875 |
return PAD_ADJUST; |
| 876 |
} |
| 877 |
|
| 878 |
|
| 879 |
/* MP3 'private extension' bit. Meaningless. */ |
| 880 |
int |
| 881 |
lame_set_extension(lame_global_flags * gfp, int extension) |
| 882 |
{ |
| 883 |
if (is_lame_global_flags_valid(gfp)) { |
| 884 |
/* default = 0 (disabled) */ |
| 885 |
/* enforce disable/enable meaning, if we need more than two values |
| 886 |
we need to switch to an enum to have an apropriate representation |
| 887 |
of the possible meanings of the value */ |
| 888 |
if (0 > extension || 1 < extension) |
| 889 |
return -1; |
| 890 |
gfp->extension = extension; |
| 891 |
return 0; |
| 892 |
} |
| 893 |
return -1; |
| 894 |
} |
| 895 |
|
| 896 |
int |
| 897 |
lame_get_extension(const lame_global_flags * gfp) |
| 898 |
{ |
| 899 |
if (is_lame_global_flags_valid(gfp)) { |
| 900 |
assert(0 <= gfp->extension && 1 >= gfp->extension); |
| 901 |
return gfp->extension; |
| 902 |
} |
| 903 |
return 0; |
| 904 |
} |
| 905 |
|
| 906 |
|
| 907 |
/* Enforce strict ISO compliance. */ |
| 908 |
int |
| 909 |
lame_set_strict_ISO(lame_global_flags * gfp, int val) |
| 910 |
{ |
| 911 |
if (is_lame_global_flags_valid(gfp)) { |
| 912 |
/* default = 0 (disabled) */ |
| 913 |
/* enforce disable/enable meaning, if we need more than two values |
| 914 |
we need to switch to an enum to have an apropriate representation |
| 915 |
of the possible meanings of the value */ |
| 916 |
if (val < MDB_DEFAULT || MDB_MAXIMUM < val) |
| 917 |
return -1; |
| 918 |
gfp->strict_ISO = val; |
| 919 |
return 0; |
| 920 |
} |
| 921 |
return -1; |
| 922 |
} |
| 923 |
|
| 924 |
int |
| 925 |
lame_get_strict_ISO(const lame_global_flags * gfp) |
| 926 |
{ |
| 927 |
if (is_lame_global_flags_valid(gfp)) { |
| 928 |
return gfp->strict_ISO; |
| 929 |
} |
| 930 |
return 0; |
| 931 |
} |
| 932 |
|
| 933 |
|
| 934 |
|
| 935 |
|
| 936 |
/******************************************************************** |
| 937 |
* quantization/noise shaping |
| 938 |
***********************************************************************/ |
| 939 |
|
| 940 |
/* Disable the bit reservoir. For testing only. */ |
| 941 |
int |
| 942 |
lame_set_disable_reservoir(lame_global_flags * gfp, int disable_reservoir) |
| 943 |
{ |
| 944 |
if (is_lame_global_flags_valid(gfp)) { |
| 945 |
/* default = 0 (disabled) */ |
| 946 |
|
| 947 |
/* enforce disable/enable meaning, if we need more than two values |
| 948 |
we need to switch to an enum to have an apropriate representation |
| 949 |
of the possible meanings of the value */ |
| 950 |
if (0 > disable_reservoir || 1 < disable_reservoir) |
| 951 |
return -1; |
| 952 |
gfp->disable_reservoir = disable_reservoir; |
| 953 |
return 0; |
| 954 |
} |
| 955 |
return -1; |
| 956 |
} |
| 957 |
|
| 958 |
int |
| 959 |
lame_get_disable_reservoir(const lame_global_flags * gfp) |
| 960 |
{ |
| 961 |
if (is_lame_global_flags_valid(gfp)) { |
| 962 |
assert(0 <= gfp->disable_reservoir && 1 >= gfp->disable_reservoir); |
| 963 |
return gfp->disable_reservoir; |
| 964 |
} |
| 965 |
return 0; |
| 966 |
} |
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
|
| 971 |
int |
| 972 |
lame_set_experimentalX(lame_global_flags * gfp, int experimentalX) |
| 973 |
{ |
| 974 |
if (is_lame_global_flags_valid(gfp)) { |
| 975 |
lame_set_quant_comp(gfp, experimentalX); |
| 976 |
lame_set_quant_comp_short(gfp, experimentalX); |
| 977 |
return 0; |
| 978 |
} |
| 979 |
return -1; |
| 980 |
} |
| 981 |
|
| 982 |
int |
| 983 |
lame_get_experimentalX(const lame_global_flags * gfp) |
| 984 |
{ |
| 985 |
return lame_get_quant_comp(gfp); |
| 986 |
} |
| 987 |
|
| 988 |
|
| 989 |
/* Select a different "best quantization" function. default = 0 */ |
| 990 |
int |
| 991 |
lame_set_quant_comp(lame_global_flags * gfp, int quant_type) |
| 992 |
{ |
| 993 |
if (is_lame_global_flags_valid(gfp)) { |
| 994 |
gfp->quant_comp = quant_type; |
| 995 |
return 0; |
| 996 |
} |
| 997 |
return -1; |
| 998 |
} |
| 999 |
|
| 1000 |
int |
| 1001 |
lame_get_quant_comp(const lame_global_flags * gfp) |
| 1002 |
{ |
| 1003 |
if (is_lame_global_flags_valid(gfp)) { |
| 1004 |
return gfp->quant_comp; |
| 1005 |
} |
| 1006 |
return 0; |
| 1007 |
} |
| 1008 |
|
| 1009 |
|
| 1010 |
/* Select a different "best quantization" function. default = 0 */ |
| 1011 |
int |
| 1012 |
lame_set_quant_comp_short(lame_global_flags * gfp, int quant_type) |
| 1013 |
{ |
| 1014 |
if (is_lame_global_flags_valid(gfp)) { |
| 1015 |
gfp->quant_comp_short = quant_type; |
| 1016 |
return 0; |
| 1017 |
} |
| 1018 |
return -1; |
| 1019 |
} |
| 1020 |
|
| 1021 |
int |
| 1022 |
lame_get_quant_comp_short(const lame_global_flags * gfp) |
| 1023 |
{ |
| 1024 |
if (is_lame_global_flags_valid(gfp)) { |
| 1025 |
return gfp->quant_comp_short; |
| 1026 |
} |
| 1027 |
return 0; |
| 1028 |
} |
| 1029 |
|
| 1030 |
|
| 1031 |
/* Another experimental option. For testing only. */ |
| 1032 |
int |
| 1033 |
lame_set_experimentalY(lame_global_flags * gfp, int experimentalY) |
| 1034 |
{ |
| 1035 |
if (is_lame_global_flags_valid(gfp)) { |
| 1036 |
gfp->experimentalY = experimentalY; |
| 1037 |
return 0; |
| 1038 |
} |
| 1039 |
return -1; |
| 1040 |
} |
| 1041 |
|
| 1042 |
int |
| 1043 |
lame_get_experimentalY(const lame_global_flags * gfp) |
| 1044 |
{ |
| 1045 |
if (is_lame_global_flags_valid(gfp)) { |
| 1046 |
return gfp->experimentalY; |
| 1047 |
} |
| 1048 |
return 0; |
| 1049 |
} |
| 1050 |
|
| 1051 |
|
| 1052 |
int |
| 1053 |
lame_set_experimentalZ(lame_global_flags * gfp, int experimentalZ) |
| 1054 |
{ |
| 1055 |
if (is_lame_global_flags_valid(gfp)) { |
| 1056 |
gfp->experimentalZ = experimentalZ; |
| 1057 |
return 0; |
| 1058 |
} |
| 1059 |
return -1; |
| 1060 |
} |
| 1061 |
|
| 1062 |
int |
| 1063 |
lame_get_experimentalZ(const lame_global_flags * gfp) |
| 1064 |
{ |
| 1065 |
if (is_lame_global_flags_valid(gfp)) { |
| 1066 |
return gfp->experimentalZ; |
| 1067 |
} |
| 1068 |
return 0; |
| 1069 |
} |
| 1070 |
|
| 1071 |
|
| 1072 |
/* Naoki's psycho acoustic model. */ |
| 1073 |
int |
| 1074 |
lame_set_exp_nspsytune(lame_global_flags * gfp, int exp_nspsytune) |
| 1075 |
{ |
| 1076 |
if (is_lame_global_flags_valid(gfp)) { |
| 1077 |
/* default = 0 (disabled) */ |
| 1078 |
gfp->exp_nspsytune = exp_nspsytune; |
| 1079 |
return 0; |
| 1080 |
} |
| 1081 |
return -1; |
| 1082 |
} |
| 1083 |
|
| 1084 |
int |
| 1085 |
lame_get_exp_nspsytune(const lame_global_flags * gfp) |
| 1086 |
{ |
| 1087 |
if (is_lame_global_flags_valid(gfp)) { |
| 1088 |
return gfp->exp_nspsytune; |
| 1089 |
} |
| 1090 |
return 0; |
| 1091 |
} |
| 1092 |
|
| 1093 |
|
| 1094 |
|
| 1095 |
|
| 1096 |
/******************************************************************** |
| 1097 |
* VBR control |
| 1098 |
***********************************************************************/ |
| 1099 |
|
| 1100 |
/* Types of VBR. default = vbr_off = CBR */ |
| 1101 |
int |
| 1102 |
lame_set_VBR(lame_global_flags * gfp, vbr_mode VBR) |
| 1103 |
{ |
| 1104 |
if (is_lame_global_flags_valid(gfp)) { |
| 1105 |
int vbr_q = VBR; |
| 1106 |
if (0 > vbr_q || vbr_max_indicator <= vbr_q) |
| 1107 |
return -1; /* Unknown VBR mode! */ |
| 1108 |
gfp->VBR = VBR; |
| 1109 |
return 0; |
| 1110 |
} |
| 1111 |
return -1; |
| 1112 |
} |
| 1113 |
|
| 1114 |
vbr_mode |
| 1115 |
lame_get_VBR(const lame_global_flags * gfp) |
| 1116 |
{ |
| 1117 |
if (is_lame_global_flags_valid(gfp)) { |
| 1118 |
assert(gfp->VBR < vbr_max_indicator); |
| 1119 |
return gfp->VBR; |
| 1120 |
} |
| 1121 |
return vbr_off; |
| 1122 |
} |
| 1123 |
|
| 1124 |
|
| 1125 |
/* |
| 1126 |
* VBR quality level. |
| 1127 |
* 0 = highest |
| 1128 |
* 9 = lowest |
| 1129 |
*/ |
| 1130 |
int |
| 1131 |
lame_set_VBR_q(lame_global_flags * gfp, int VBR_q) |
| 1132 |
{ |
| 1133 |
if (is_lame_global_flags_valid(gfp)) { |
| 1134 |
int ret = 0; |
| 1135 |
|
| 1136 |
if (0 > VBR_q) { |
| 1137 |
ret = -1; /* Unknown VBR quality level! */ |
| 1138 |
VBR_q = 0; |
| 1139 |
} |
| 1140 |
if (9 < VBR_q) { |
| 1141 |
ret = -1; |
| 1142 |
VBR_q = 9; |
| 1143 |
} |
| 1144 |
gfp->VBR_q = VBR_q; |
| 1145 |
gfp->VBR_q_frac = 0; |
| 1146 |
return ret; |
| 1147 |
} |
| 1148 |
return -1; |
| 1149 |
} |
| 1150 |
|
| 1151 |
int |
| 1152 |
lame_get_VBR_q(const lame_global_flags * gfp) |
| 1153 |
{ |
| 1154 |
if (is_lame_global_flags_valid(gfp)) { |
| 1155 |
assert(0 <= gfp->VBR_q && 10 > gfp->VBR_q); |
| 1156 |
return gfp->VBR_q; |
| 1157 |
} |
| 1158 |
return 0; |
| 1159 |
} |
| 1160 |
|
| 1161 |
int |
| 1162 |
lame_set_VBR_quality(lame_global_flags * gfp, float VBR_q) |
| 1163 |
{ |
| 1164 |
if (is_lame_global_flags_valid(gfp)) { |
| 1165 |
int ret = 0; |
| 1166 |
|
| 1167 |
if (0 > VBR_q) { |
| 1168 |
ret = -1; /* Unknown VBR quality level! */ |
| 1169 |
VBR_q = 0; |
| 1170 |
} |
| 1171 |
if (9.999 < VBR_q) { |
| 1172 |
ret = -1; |
| 1173 |
VBR_q = 9.999; |
| 1174 |
} |
| 1175 |
|
| 1176 |
gfp->VBR_q = (int) VBR_q; |
| 1177 |
gfp->VBR_q_frac = VBR_q - gfp->VBR_q; |
| 1178 |
|
| 1179 |
return ret; |
| 1180 |
} |
| 1181 |
return -1; |
| 1182 |
} |
| 1183 |
|
| 1184 |
float |
| 1185 |
lame_get_VBR_quality(const lame_global_flags * gfp) |
| 1186 |
{ |
| 1187 |
if (is_lame_global_flags_valid(gfp)) { |
| 1188 |
return gfp->VBR_q + gfp->VBR_q_frac; |
| 1189 |
} |
| 1190 |
return 0; |
| 1191 |
} |
| 1192 |
|
| 1193 |
|
| 1194 |
/* Ignored except for VBR = vbr_abr (ABR mode) */ |
| 1195 |
int |
| 1196 |
lame_set_VBR_mean_bitrate_kbps(lame_global_flags * gfp, int VBR_mean_bitrate_kbps) |
| 1197 |
{ |
| 1198 |
if (is_lame_global_flags_valid(gfp)) { |
| 1199 |
gfp->VBR_mean_bitrate_kbps = VBR_mean_bitrate_kbps; |
| 1200 |
return 0; |
| 1201 |
} |
| 1202 |
return -1; |
| 1203 |
} |
| 1204 |
|
| 1205 |
int |
| 1206 |
lame_get_VBR_mean_bitrate_kbps(const lame_global_flags * gfp) |
| 1207 |
{ |
| 1208 |
if (is_lame_global_flags_valid(gfp)) { |
| 1209 |
return gfp->VBR_mean_bitrate_kbps; |
| 1210 |
} |
| 1211 |
return 0; |
| 1212 |
} |
| 1213 |
|
| 1214 |
int |
| 1215 |
lame_set_VBR_min_bitrate_kbps(lame_global_flags * gfp, int VBR_min_bitrate_kbps) |
| 1216 |
{ |
| 1217 |
if (is_lame_global_flags_valid(gfp)) { |
| 1218 |
gfp->VBR_min_bitrate_kbps = VBR_min_bitrate_kbps; |
| 1219 |
return 0; |
| 1220 |
} |
| 1221 |
return -1; |
| 1222 |
} |
| 1223 |
|
| 1224 |
int |
| 1225 |
lame_get_VBR_min_bitrate_kbps(const lame_global_flags * gfp) |
| 1226 |
{ |
| 1227 |
if (is_lame_global_flags_valid(gfp)) { |
| 1228 |
return gfp->VBR_min_bitrate_kbps; |
| 1229 |
} |
| 1230 |
return 0; |
| 1231 |
} |
| 1232 |
|
| 1233 |
int |
| 1234 |
lame_set_VBR_max_bitrate_kbps(lame_global_flags * gfp, int VBR_max_bitrate_kbps) |
| 1235 |
{ |
| 1236 |
if (is_lame_global_flags_valid(gfp)) { |
| 1237 |
gfp->VBR_max_bitrate_kbps = VBR_max_bitrate_kbps; |
| 1238 |
return 0; |
| 1239 |
} |
| 1240 |
return -1; |
| 1241 |
} |
| 1242 |
|
| 1243 |
int |
| 1244 |
lame_get_VBR_max_bitrate_kbps(const lame_global_flags * gfp) |
| 1245 |
{ |
| 1246 |
if (is_lame_global_flags_valid(gfp)) { |
| 1247 |
return gfp->VBR_max_bitrate_kbps; |
| 1248 |
} |
| 1249 |
return 0; |
| 1250 |
} |
| 1251 |
|
| 1252 |
|
| 1253 |
/* |
| 1254 |
* Strictly enforce VBR_min_bitrate. |
| 1255 |
* Normally it will be violated for analog silence. |
| 1256 |
*/ |
| 1257 |
int |
| 1258 |
lame_set_VBR_hard_min(lame_global_flags * gfp, int VBR_hard_min) |
| 1259 |
{ |
| 1260 |
if (is_lame_global_flags_valid(gfp)) { |
| 1261 |
/* default = 0 (disabled) */ |
| 1262 |
|
| 1263 |
/* enforce disable/enable meaning, if we need more than two values |
| 1264 |
we need to switch to an enum to have an apropriate representation |
| 1265 |
of the possible meanings of the value */ |
| 1266 |
if (0 > VBR_hard_min || 1 < VBR_hard_min) |
| 1267 |
return -1; |
| 1268 |
|
| 1269 |
gfp->VBR_hard_min = VBR_hard_min; |
| 1270 |
|
| 1271 |
return 0; |
| 1272 |
} |
| 1273 |
return -1; |
| 1274 |
} |
| 1275 |
|
| 1276 |
int |
| 1277 |
lame_get_VBR_hard_min(const lame_global_flags * gfp) |
| 1278 |
{ |
| 1279 |
if (is_lame_global_flags_valid(gfp)) { |
| 1280 |
assert(0 <= gfp->VBR_hard_min && 1 >= gfp->VBR_hard_min); |
| 1281 |
return gfp->VBR_hard_min; |
| 1282 |
} |
| 1283 |
return 0; |
| 1284 |
} |
| 1285 |
|
| 1286 |
|
| 1287 |
/******************************************************************** |
| 1288 |
* Filtering control |
| 1289 |
***********************************************************************/ |
| 1290 |
|
| 1291 |
/* |
| 1292 |
* Freqency in Hz to apply lowpass. |
| 1293 |
* 0 = default = lame chooses |
| 1294 |
* -1 = disabled |
| 1295 |
*/ |
| 1296 |
int |
| 1297 |
lame_set_lowpassfreq(lame_global_flags * gfp, int lowpassfreq) |
| 1298 |
{ |
| 1299 |
if (is_lame_global_flags_valid(gfp)) { |
| 1300 |
gfp->lowpassfreq = lowpassfreq; |
| 1301 |
return 0; |
| 1302 |
} |
| 1303 |
return -1; |
| 1304 |
} |
| 1305 |
|
| 1306 |
int |
| 1307 |
lame_get_lowpassfreq(const lame_global_flags * gfp) |
| 1308 |
{ |
| 1309 |
if (is_lame_global_flags_valid(gfp)) { |
| 1310 |
return gfp->lowpassfreq; |
| 1311 |
} |
| 1312 |
return 0; |
| 1313 |
} |
| 1314 |
|
| 1315 |
|
| 1316 |
/* |
| 1317 |
* Width of transition band (in Hz). |
| 1318 |
* default = one polyphase filter band |
| 1319 |
*/ |
| 1320 |
int |
| 1321 |
lame_set_lowpasswidth(lame_global_flags * gfp, int lowpasswidth) |
| 1322 |
{ |
| 1323 |
if (is_lame_global_flags_valid(gfp)) { |
| 1324 |
gfp->lowpasswidth = lowpasswidth; |
| 1325 |
return 0; |
| 1326 |
} |
| 1327 |
return -1; |
| 1328 |
} |
| 1329 |
|
| 1330 |
int |
| 1331 |
lame_get_lowpasswidth(const lame_global_flags * gfp) |
| 1332 |
{ |
| 1333 |
if (is_lame_global_flags_valid(gfp)) { |
| 1334 |
return gfp->lowpasswidth; |
| 1335 |
} |
| 1336 |
return 0; |
| 1337 |
} |
| 1338 |
|
| 1339 |
|
| 1340 |
/* |
| 1341 |
* Frequency in Hz to apply highpass. |
| 1342 |
* 0 = default = lame chooses |
| 1343 |
* -1 = disabled |
| 1344 |
*/ |
| 1345 |
int |
| 1346 |
lame_set_highpassfreq(lame_global_flags * gfp, int highpassfreq) |
| 1347 |
{ |
| 1348 |
if (is_lame_global_flags_valid(gfp)) { |
| 1349 |
gfp->highpassfreq = highpassfreq; |
| 1350 |
return 0; |
| 1351 |
} |
| 1352 |
return -1; |
| 1353 |
} |
| 1354 |
|
| 1355 |
int |
| 1356 |
lame_get_highpassfreq(const lame_global_flags * gfp) |
| 1357 |
{ |
| 1358 |
if (is_lame_global_flags_valid(gfp)) { |
| 1359 |
return gfp->highpassfreq; |
| 1360 |
} |
| 1361 |
return 0; |
| 1362 |
} |
| 1363 |
|
| 1364 |
|
| 1365 |
/* |
| 1366 |
* Width of transition band (in Hz). |
| 1367 |
* default = one polyphase filter band |
| 1368 |
*/ |
| 1369 |
int |
| 1370 |
lame_set_highpasswidth(lame_global_flags * gfp, int highpasswidth) |
| 1371 |
{ |
| 1372 |
if (is_lame_global_flags_valid(gfp)) { |
| 1373 |
gfp->highpasswidth = highpasswidth; |
| 1374 |
return 0; |
| 1375 |
} |
| 1376 |
return -1; |
| 1377 |
} |
| 1378 |
|
| 1379 |
int |
| 1380 |
lame_get_highpasswidth(const lame_global_flags * gfp) |
| 1381 |
{ |
| 1382 |
if (is_lame_global_flags_valid(gfp)) { |
| 1383 |
return gfp->highpasswidth; |
| 1384 |
} |
| 1385 |
return 0; |
| 1386 |
} |
| 1387 |
|
| 1388 |
|
| 1389 |
|
| 1390 |
|
| 1391 |
/* |
| 1392 |
* psycho acoustics and other arguments which you should not change |
| 1393 |
* unless you know what you are doing |
| 1394 |
*/ |
| 1395 |
|
| 1396 |
|
| 1397 |
/* Adjust masking values. */ |
| 1398 |
int |
| 1399 |
lame_set_maskingadjust(lame_global_flags * gfp, float adjust) |
| 1400 |
{ |
| 1401 |
if (is_lame_global_flags_valid(gfp)) { |
| 1402 |
gfp->maskingadjust = adjust; |
| 1403 |
return 0; |
| 1404 |
} |
| 1405 |
return -1; |
| 1406 |
} |
| 1407 |
|
| 1408 |
float |
| 1409 |
lame_get_maskingadjust(const lame_global_flags * gfp) |
| 1410 |
{ |
| 1411 |
if (is_lame_global_flags_valid(gfp)) { |
| 1412 |
return gfp->maskingadjust; |
| 1413 |
} |
| 1414 |
return 0; |
| 1415 |
} |
| 1416 |
|
| 1417 |
int |
| 1418 |
lame_set_maskingadjust_short(lame_global_flags * gfp, float adjust) |
| 1419 |
{ |
| 1420 |
if (is_lame_global_flags_valid(gfp)) { |
| 1421 |
gfp->maskingadjust_short = adjust; |
| 1422 |
return 0; |
| 1423 |
} |
| 1424 |
return -1; |
| 1425 |
} |
| 1426 |
|
| 1427 |
float |
| 1428 |
lame_get_maskingadjust_short(const lame_global_flags * gfp) |
| 1429 |
{ |
| 1430 |
if (is_lame_global_flags_valid(gfp)) { |
| 1431 |
return gfp->maskingadjust_short; |
| 1432 |
} |
| 1433 |
return 0; |
| 1434 |
} |
| 1435 |
|
| 1436 |
/* Only use ATH for masking. */ |
| 1437 |
int |
| 1438 |
lame_set_ATHonly(lame_global_flags * gfp, int ATHonly) |
| 1439 |
{ |
| 1440 |
if (is_lame_global_flags_valid(gfp)) { |
| 1441 |
gfp->ATHonly = ATHonly; |
| 1442 |
return 0; |
| 1443 |
} |
| 1444 |
return -1; |
| 1445 |
} |
| 1446 |
|
| 1447 |
int |
| 1448 |
lame_get_ATHonly(const lame_global_flags * gfp) |
| 1449 |
{ |
| 1450 |
if (is_lame_global_flags_valid(gfp)) { |
| 1451 |
return gfp->ATHonly; |
| 1452 |
} |
| 1453 |
return 0; |
| 1454 |
} |
| 1455 |
|
| 1456 |
|
| 1457 |
/* Only use ATH for short blocks. */ |
| 1458 |
int |
| 1459 |
lame_set_ATHshort(lame_global_flags * gfp, int ATHshort) |
| 1460 |
{ |
| 1461 |
if (is_lame_global_flags_valid(gfp)) { |
| 1462 |
gfp->ATHshort = ATHshort; |
| 1463 |
return 0; |
| 1464 |
} |
| 1465 |
return -1; |
| 1466 |
} |
| 1467 |
|
| 1468 |
int |
| 1469 |
lame_get_ATHshort(const lame_global_flags * gfp) |
| 1470 |
{ |
| 1471 |
if (is_lame_global_flags_valid(gfp)) { |
| 1472 |
return gfp->ATHshort; |
| 1473 |
} |
| 1474 |
return 0; |
| 1475 |
} |
| 1476 |
|
| 1477 |
|
| 1478 |
/* Disable ATH. */ |
| 1479 |
int |
| 1480 |
lame_set_noATH(lame_global_flags * gfp, int noATH) |
| 1481 |
{ |
| 1482 |
if (is_lame_global_flags_valid(gfp)) { |
| 1483 |
gfp->noATH = noATH; |
| 1484 |
return 0; |
| 1485 |
} |
| 1486 |
return -1; |
| 1487 |
} |
| 1488 |
|
| 1489 |
int |
| 1490 |
lame_get_noATH(const lame_global_flags * gfp) |
| 1491 |
{ |
| 1492 |
if (is_lame_global_flags_valid(gfp)) { |
| 1493 |
return gfp->noATH; |
| 1494 |
} |
| 1495 |
return 0; |
| 1496 |
} |
| 1497 |
|
| 1498 |
|
| 1499 |
/* Select ATH formula. */ |
| 1500 |
int |
| 1501 |
lame_set_ATHtype(lame_global_flags * gfp, int ATHtype) |
| 1502 |
{ |
| 1503 |
if (is_lame_global_flags_valid(gfp)) { |
| 1504 |
/* XXX: ATHtype should be converted to an enum. */ |
| 1505 |
gfp->ATHtype = ATHtype; |
| 1506 |
return 0; |
| 1507 |
} |
| 1508 |
return -1; |
| 1509 |
} |
| 1510 |
|
| 1511 |
int |
| 1512 |
lame_get_ATHtype(const lame_global_flags * gfp) |
| 1513 |
{ |
| 1514 |
if (is_lame_global_flags_valid(gfp)) { |
| 1515 |
return gfp->ATHtype; |
| 1516 |
} |
| 1517 |
return 0; |
| 1518 |
} |
| 1519 |
|
| 1520 |
|
| 1521 |
/* Select ATH formula 4 shape. */ |
| 1522 |
int |
| 1523 |
lame_set_ATHcurve(lame_global_flags * gfp, float ATHcurve) |
| 1524 |
{ |
| 1525 |
if (is_lame_global_flags_valid(gfp)) { |
| 1526 |
gfp->ATHcurve = ATHcurve; |
| 1527 |
return 0; |
| 1528 |
} |
| 1529 |
return -1; |
| 1530 |
} |
| 1531 |
|
| 1532 |
float |
| 1533 |
lame_get_ATHcurve(const lame_global_flags * gfp) |
| 1534 |
{ |
| 1535 |
if (is_lame_global_flags_valid(gfp)) { |
| 1536 |
return gfp->ATHcurve; |
| 1537 |
} |
| 1538 |
return 0; |
| 1539 |
} |
| 1540 |
|
| 1541 |
|
| 1542 |
/* Lower ATH by this many db. */ |
| 1543 |
int |
| 1544 |
lame_set_ATHlower(lame_global_flags * gfp, float ATHlower) |
| 1545 |
{ |
| 1546 |
if (is_lame_global_flags_valid(gfp)) { |
| 1547 |
gfp->ATH_lower_db = ATHlower; |
| 1548 |
return 0; |
| 1549 |
} |
| 1550 |
return -1; |
| 1551 |
} |
| 1552 |
|
| 1553 |
float |
| 1554 |
lame_get_ATHlower(const lame_global_flags * gfp) |
| 1555 |
{ |
| 1556 |
if (is_lame_global_flags_valid(gfp)) { |
| 1557 |
return gfp->ATH_lower_db; |
| 1558 |
} |
| 1559 |
return 0; |
| 1560 |
} |
| 1561 |
|
| 1562 |
|
| 1563 |
/* Select ATH adaptive adjustment scheme. */ |
| 1564 |
int |
| 1565 |
lame_set_athaa_type(lame_global_flags * gfp, int athaa_type) |
| 1566 |
{ |
| 1567 |
if (is_lame_global_flags_valid(gfp)) { |
| 1568 |
gfp->athaa_type = athaa_type; |
| 1569 |
return 0; |
| 1570 |
} |
| 1571 |
return -1; |
| 1572 |
} |
| 1573 |
|
| 1574 |
int |
| 1575 |
lame_get_athaa_type(const lame_global_flags * gfp) |
| 1576 |
{ |
| 1577 |
if (is_lame_global_flags_valid(gfp)) { |
| 1578 |
return gfp->athaa_type; |
| 1579 |
} |
| 1580 |
return 0; |
| 1581 |
} |
| 1582 |
|
| 1583 |
|
| 1584 |
#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED |
| 1585 |
int CDECL lame_set_athaa_loudapprox(lame_global_flags * gfp, int athaa_loudapprox); |
| 1586 |
int CDECL lame_get_athaa_loudapprox(const lame_global_flags * gfp); |
| 1587 |
#else |
| 1588 |
#endif |
| 1589 |
|
| 1590 |
/* Select the loudness approximation used by the ATH adaptive auto-leveling. */ |
| 1591 |
int |
| 1592 |
lame_set_athaa_loudapprox(lame_global_flags * gfp, int athaa_loudapprox) |
| 1593 |
{ |
| 1594 |
(void) gfp; |
| 1595 |
(void) athaa_loudapprox; |
| 1596 |
return 0; |
| 1597 |
} |
| 1598 |
|
| 1599 |
int |
| 1600 |
lame_get_athaa_loudapprox(const lame_global_flags * gfp) |
| 1601 |
{ |
| 1602 |
(void) gfp; |
| 1603 |
/* obsolete, the type known under number 2 is the only survival */ |
| 1604 |
return 2; |
| 1605 |
} |
| 1606 |
|
| 1607 |
|
| 1608 |
/* Adjust (in dB) the point below which adaptive ATH level adjustment occurs. */ |
| 1609 |
int |
| 1610 |
lame_set_athaa_sensitivity(lame_global_flags * gfp, float athaa_sensitivity) |
| 1611 |
{ |
| 1612 |
if (is_lame_global_flags_valid(gfp)) { |
| 1613 |
gfp->athaa_sensitivity = athaa_sensitivity; |
| 1614 |
return 0; |
| 1615 |
} |
| 1616 |
return -1; |
| 1617 |
} |
| 1618 |
|
| 1619 |
float |
| 1620 |
lame_get_athaa_sensitivity(const lame_global_flags * gfp) |
| 1621 |
{ |
| 1622 |
if (is_lame_global_flags_valid(gfp)) { |
| 1623 |
return gfp->athaa_sensitivity; |
| 1624 |
} |
| 1625 |
return 0; |
| 1626 |
} |
| 1627 |
|
| 1628 |
|
| 1629 |
/* Predictability limit (ISO tonality formula) */ |
| 1630 |
int lame_set_cwlimit(lame_global_flags * gfp, int cwlimit); |
| 1631 |
int lame_get_cwlimit(const lame_global_flags * gfp); |
| 1632 |
|
| 1633 |
int |
| 1634 |
lame_set_cwlimit(lame_global_flags * gfp, int cwlimit) |
| 1635 |
{ |
| 1636 |
(void) gfp; |
| 1637 |
(void) cwlimit; |
| 1638 |
return 0; |
| 1639 |
} |
| 1640 |
|
| 1641 |
int |
| 1642 |
lame_get_cwlimit(const lame_global_flags * gfp) |
| 1643 |
{ |
| 1644 |
(void) gfp; |
| 1645 |
return 0; |
| 1646 |
} |
| 1647 |
|
| 1648 |
|
| 1649 |
|
| 1650 |
/* |
| 1651 |
* Allow blocktypes to differ between channels. |
| 1652 |
* default: |
| 1653 |
* 0 for jstereo => block types coupled |
| 1654 |
* 1 for stereo => block types may differ |
| 1655 |
*/ |
| 1656 |
int |
| 1657 |
lame_set_allow_diff_short(lame_global_flags * gfp, int allow_diff_short) |
| 1658 |
{ |
| 1659 |
if (is_lame_global_flags_valid(gfp)) { |
| 1660 |
gfp->short_blocks = allow_diff_short ? short_block_allowed : short_block_coupled; |
| 1661 |
return 0; |
| 1662 |
} |
| 1663 |
return -1; |
| 1664 |
} |
| 1665 |
|
| 1666 |
int |
| 1667 |
lame_get_allow_diff_short(const lame_global_flags * gfp) |
| 1668 |
{ |
| 1669 |
if (is_lame_global_flags_valid(gfp)) { |
| 1670 |
if (gfp->short_blocks == short_block_allowed) |
| 1671 |
return 1; /* short blocks allowed to differ */ |
| 1672 |
else |
| 1673 |
return 0; /* not set, dispensed, forced or coupled */ |
| 1674 |
} |
| 1675 |
return 0; |
| 1676 |
} |
| 1677 |
|
| 1678 |
|
| 1679 |
/* Use temporal masking effect */ |
| 1680 |
int |
| 1681 |
lame_set_useTemporal(lame_global_flags * gfp, int useTemporal) |
| 1682 |
{ |
| 1683 |
if (is_lame_global_flags_valid(gfp)) { |
| 1684 |
/* default = 1 (enabled) */ |
| 1685 |
|
| 1686 |
/* enforce disable/enable meaning, if we need more than two values |
| 1687 |
we need to switch to an enum to have an apropriate representation |
| 1688 |
of the possible meanings of the value */ |
| 1689 |
if (0 <= useTemporal && useTemporal <= 1) { |
| 1690 |
gfp->useTemporal = useTemporal; |
| 1691 |
return 0; |
| 1692 |
} |
| 1693 |
} |
| 1694 |
return -1; |
| 1695 |
} |
| 1696 |
|
| 1697 |
int |
| 1698 |
lame_get_useTemporal(const lame_global_flags * gfp) |
| 1699 |
{ |
| 1700 |
if (is_lame_global_flags_valid(gfp)) { |
| 1701 |
assert(0 <= gfp->useTemporal && 1 >= gfp->useTemporal); |
| 1702 |
return gfp->useTemporal; |
| 1703 |
} |
| 1704 |
return 0; |
| 1705 |
} |
| 1706 |
|
| 1707 |
|
| 1708 |
/* Use inter-channel masking effect */ |
| 1709 |
int |
| 1710 |
lame_set_interChRatio(lame_global_flags * gfp, float ratio) |
| 1711 |
{ |
| 1712 |
if (is_lame_global_flags_valid(gfp)) { |
| 1713 |
/* default = 0.0 (no inter-channel maskin) */ |
| 1714 |
if (0 <= ratio && ratio <= 1.0) { |
| 1715 |
gfp->interChRatio = ratio; |
| 1716 |
return 0; |
| 1717 |
} |
| 1718 |
} |
| 1719 |
return -1; |
| 1720 |
} |
| 1721 |
|
| 1722 |
float |
| 1723 |
lame_get_interChRatio(const lame_global_flags * gfp) |
| 1724 |
{ |
| 1725 |
if (is_lame_global_flags_valid(gfp)) { |
| 1726 |
assert((0 <= gfp->interChRatio && gfp->interChRatio <= 1.0) || EQ(gfp->interChRatio, -1)); |
| 1727 |
return gfp->interChRatio; |
| 1728 |
} |
| 1729 |
return 0; |
| 1730 |
} |
| 1731 |
|
| 1732 |
|
| 1733 |
/* Use pseudo substep shaping method */ |
| 1734 |
int |
| 1735 |
lame_set_substep(lame_global_flags * gfp, int method) |
| 1736 |
{ |
| 1737 |
if (is_lame_global_flags_valid(gfp)) { |
| 1738 |
/* default = 0.0 (no substep noise shaping) */ |
| 1739 |
if (0 <= method && method <= 7) { |
| 1740 |
gfp->substep_shaping = method; |
| 1741 |
return 0; |
| 1742 |
} |
| 1743 |
} |
| 1744 |
return -1; |
| 1745 |
} |
| 1746 |
|
| 1747 |
int |
| 1748 |
lame_get_substep(const lame_global_flags * gfp) |
| 1749 |
{ |
| 1750 |
if (is_lame_global_flags_valid(gfp)) { |
| 1751 |
assert(0 <= gfp->substep_shaping && gfp->substep_shaping <= 7); |
| 1752 |
return gfp->substep_shaping; |
| 1753 |
} |
| 1754 |
return 0; |
| 1755 |
} |
| 1756 |
|
| 1757 |
/* scalefactors scale */ |
| 1758 |
int |
| 1759 |
lame_set_sfscale(lame_global_flags * gfp, int val) |
| 1760 |
{ |
| 1761 |
if (is_lame_global_flags_valid(gfp)) { |
| 1762 |
gfp->noise_shaping = (val != 0) ? 2 : 1; |
| 1763 |
return 0; |
| 1764 |
} |
| 1765 |
return -1; |
| 1766 |
} |
| 1767 |
|
| 1768 |
int |
| 1769 |
lame_get_sfscale(const lame_global_flags * gfp) |
| 1770 |
{ |
| 1771 |
if (is_lame_global_flags_valid(gfp)) { |
| 1772 |
return (gfp->noise_shaping == 2) ? 1 : 0; |
| 1773 |
} |
| 1774 |
return 0; |
| 1775 |
} |
| 1776 |
|
| 1777 |
/* subblock gain */ |
| 1778 |
int |
| 1779 |
lame_set_subblock_gain(lame_global_flags * gfp, int sbgain) |
| 1780 |
{ |
| 1781 |
if (is_lame_global_flags_valid(gfp)) { |
| 1782 |
gfp->subblock_gain = sbgain; |
| 1783 |
return 0; |
| 1784 |
} |
| 1785 |
return -1; |
| 1786 |
} |
| 1787 |
|
| 1788 |
int |
| 1789 |
lame_get_subblock_gain(const lame_global_flags * gfp) |
| 1790 |
{ |
| 1791 |
if (is_lame_global_flags_valid(gfp)) { |
| 1792 |
return gfp->subblock_gain; |
| 1793 |
} |
| 1794 |
return 0; |
| 1795 |
} |
| 1796 |
|
| 1797 |
|
| 1798 |
/* Disable short blocks. */ |
| 1799 |
int |
| 1800 |
lame_set_no_short_blocks(lame_global_flags * gfp, int no_short_blocks) |
| 1801 |
{ |
| 1802 |
if (is_lame_global_flags_valid(gfp)) { |
| 1803 |
/* enforce disable/enable meaning, if we need more than two values |
| 1804 |
we need to switch to an enum to have an apropriate representation |
| 1805 |
of the possible meanings of the value */ |
| 1806 |
if (0 <= no_short_blocks && no_short_blocks <= 1) { |
| 1807 |
gfp->short_blocks = no_short_blocks ? short_block_dispensed : short_block_allowed; |
| 1808 |
return 0; |
| 1809 |
} |
| 1810 |
} |
| 1811 |
return -1; |
| 1812 |
} |
| 1813 |
|
| 1814 |
int |
| 1815 |
lame_get_no_short_blocks(const lame_global_flags * gfp) |
| 1816 |
{ |
| 1817 |
if (is_lame_global_flags_valid(gfp)) { |
| 1818 |
switch (gfp->short_blocks) { |
| 1819 |
default: |
| 1820 |
case short_block_not_set: |
| 1821 |
return -1; |
| 1822 |
case short_block_dispensed: |
| 1823 |
return 1; |
| 1824 |
case short_block_allowed: |
| 1825 |
case short_block_coupled: |
| 1826 |
case short_block_forced: |
| 1827 |
return 0; |
| 1828 |
} |
| 1829 |
} |
| 1830 |
return -1; |
| 1831 |
} |
| 1832 |
|
| 1833 |
|
| 1834 |
/* Force short blocks. */ |
| 1835 |
int |
| 1836 |
lame_set_force_short_blocks(lame_global_flags * gfp, int short_blocks) |
| 1837 |
{ |
| 1838 |
if (is_lame_global_flags_valid(gfp)) { |
| 1839 |
/* enforce disable/enable meaning, if we need more than two values |
| 1840 |
we need to switch to an enum to have an apropriate representation |
| 1841 |
of the possible meanings of the value */ |
| 1842 |
if (0 > short_blocks || 1 < short_blocks) |
| 1843 |
return -1; |
| 1844 |
|
| 1845 |
if (short_blocks == 1) |
| 1846 |
gfp->short_blocks = short_block_forced; |
| 1847 |
else if (gfp->short_blocks == short_block_forced) |
| 1848 |
gfp->short_blocks = short_block_allowed; |
| 1849 |
|
| 1850 |
return 0; |
| 1851 |
} |
| 1852 |
return -1; |
| 1853 |
} |
| 1854 |
|
| 1855 |
int |
| 1856 |
lame_get_force_short_blocks(const lame_global_flags * gfp) |
| 1857 |
{ |
| 1858 |
if (is_lame_global_flags_valid(gfp)) { |
| 1859 |
switch (gfp->short_blocks) { |
| 1860 |
default: |
| 1861 |
case short_block_not_set: |
| 1862 |
return -1; |
| 1863 |
case short_block_dispensed: |
| 1864 |
case short_block_allowed: |
| 1865 |
case short_block_coupled: |
| 1866 |
return 0; |
| 1867 |
case short_block_forced: |
| 1868 |
return 1; |
| 1869 |
} |
| 1870 |
} |
| 1871 |
return -1; |
| 1872 |
} |
| 1873 |
|
| 1874 |
int |
| 1875 |
lame_set_short_threshold_lrm(lame_global_flags * gfp, float lrm) |
| 1876 |
{ |
| 1877 |
if (is_lame_global_flags_valid(gfp)) { |
| 1878 |
gfp->attackthre = lrm; |
| 1879 |
return 0; |
| 1880 |
} |
| 1881 |
return -1; |
| 1882 |
} |
| 1883 |
|
| 1884 |
float |
| 1885 |
lame_get_short_threshold_lrm(const lame_global_flags * gfp) |
| 1886 |
{ |
| 1887 |
if (is_lame_global_flags_valid(gfp)) { |
| 1888 |
return gfp->attackthre; |
| 1889 |
} |
| 1890 |
return 0; |
| 1891 |
} |
| 1892 |
|
| 1893 |
int |
| 1894 |
lame_set_short_threshold_s(lame_global_flags * gfp, float s) |
| 1895 |
{ |
| 1896 |
if (is_lame_global_flags_valid(gfp)) { |
| 1897 |
gfp->attackthre_s = s; |
| 1898 |
return 0; |
| 1899 |
} |
| 1900 |
return -1; |
| 1901 |
} |
| 1902 |
|
| 1903 |
float |
| 1904 |
lame_get_short_threshold_s(const lame_global_flags * gfp) |
| 1905 |
{ |
| 1906 |
if (is_lame_global_flags_valid(gfp)) { |
| 1907 |
return gfp->attackthre_s; |
| 1908 |
} |
| 1909 |
return 0; |
| 1910 |
} |
| 1911 |
|
| 1912 |
int |
| 1913 |
lame_set_short_threshold(lame_global_flags * gfp, float lrm, float s) |
| 1914 |
{ |
| 1915 |
if (is_lame_global_flags_valid(gfp)) { |
| 1916 |
lame_set_short_threshold_lrm(gfp, lrm); |
| 1917 |
lame_set_short_threshold_s(gfp, s); |
| 1918 |
return 0; |
| 1919 |
} |
| 1920 |
return -1; |
| 1921 |
} |
| 1922 |
|
| 1923 |
|
| 1924 |
/* |
| 1925 |
* Input PCM is emphased PCM |
| 1926 |
* (for instance from one of the rarely emphased CDs). |
| 1927 |
* |
| 1928 |
* It is STRONGLY not recommended to use this, because psycho does not |
| 1929 |
* take it into account, and last but not least many decoders |
| 1930 |
* ignore these bits |
| 1931 |
*/ |
| 1932 |
int |
| 1933 |
lame_set_emphasis(lame_global_flags * gfp, int emphasis) |
| 1934 |
{ |
| 1935 |
if (is_lame_global_flags_valid(gfp)) { |
| 1936 |
/* XXX: emphasis should be converted to an enum */ |
| 1937 |
if (0 <= emphasis && emphasis < 4) { |
| 1938 |
gfp->emphasis = emphasis; |
| 1939 |
return 0; |
| 1940 |
} |
| 1941 |
} |
| 1942 |
return -1; |
| 1943 |
} |
| 1944 |
|
| 1945 |
int |
| 1946 |
lame_get_emphasis(const lame_global_flags * gfp) |
| 1947 |
{ |
| 1948 |
if (is_lame_global_flags_valid(gfp)) { |
| 1949 |
assert(0 <= gfp->emphasis && gfp->emphasis < 4); |
| 1950 |
return gfp->emphasis; |
| 1951 |
} |
| 1952 |
return 0; |
| 1953 |
} |
| 1954 |
|
| 1955 |
|
| 1956 |
|
| 1957 |
|
| 1958 |
/***************************************************************/ |
| 1959 |
/* internal variables, cannot be set... */ |
| 1960 |
/* provided because they may be of use to calling application */ |
| 1961 |
/***************************************************************/ |
| 1962 |
|
| 1963 |
/* MPEG version. |
| 1964 |
* 0 = MPEG-2 |
| 1965 |
* 1 = MPEG-1 |
| 1966 |
* (2 = MPEG-2.5) |
| 1967 |
*/ |
| 1968 |
int |
| 1969 |
lame_get_version(const lame_global_flags * gfp) |
| 1970 |
{ |
| 1971 |
if (is_lame_global_flags_valid(gfp)) { |
| 1972 |
lame_internal_flags const *const gfc = gfp->internal_flags; |
| 1973 |
if (is_lame_internal_flags_valid(gfc)) { |
| 1974 |
return gfc->cfg.version; |
| 1975 |
} |
| 1976 |
} |
| 1977 |
return 0; |
| 1978 |
} |
| 1979 |
|
| 1980 |
|
| 1981 |
/* Encoder delay. */ |
| 1982 |
int |
| 1983 |
lame_get_encoder_delay(const lame_global_flags * gfp) |
| 1984 |
{ |
| 1985 |
if (is_lame_global_flags_valid(gfp)) { |
| 1986 |
lame_internal_flags const *const gfc = gfp->internal_flags; |
| 1987 |
if (is_lame_internal_flags_valid(gfc)) { |
| 1988 |
return gfc->ov_enc.encoder_delay; |
| 1989 |
} |
| 1990 |
} |
| 1991 |
return 0; |
| 1992 |
} |
| 1993 |
|
| 1994 |
/* padding added to the end of the input */ |
| 1995 |
int |
| 1996 |
lame_get_encoder_padding(const lame_global_flags * gfp) |
| 1997 |
{ |
| 1998 |
if (is_lame_global_flags_valid(gfp)) { |
| 1999 |
lame_internal_flags const *const gfc = gfp->internal_flags; |
| 2000 |
if (is_lame_internal_flags_valid(gfc)) { |
| 2001 |
return gfc->ov_enc.encoder_padding; |
| 2002 |
} |
| 2003 |
} |
| 2004 |
return 0; |
| 2005 |
} |
| 2006 |
|
| 2007 |
|
| 2008 |
/* Size of MPEG frame. */ |
| 2009 |
int |
| 2010 |
lame_get_framesize(const lame_global_flags * gfp) |
| 2011 |
{ |
| 2012 |
if (is_lame_global_flags_valid(gfp)) { |
| 2013 |
lame_internal_flags const *const gfc = gfp->internal_flags; |
| 2014 |
if (is_lame_internal_flags_valid(gfc)) { |
| 2015 |
SessionConfig_t const *const cfg = &gfc->cfg; |
| 2016 |
return 576 * cfg->mode_gr; |
| 2017 |
} |
| 2018 |
} |
| 2019 |
return 0; |
| 2020 |
} |
| 2021 |
|
| 2022 |
|
| 2023 |
/* Number of frames encoded so far. */ |
| 2024 |
int |
| 2025 |
lame_get_frameNum(const lame_global_flags * gfp) |
| 2026 |
{ |
| 2027 |
if (is_lame_global_flags_valid(gfp)) { |
| 2028 |
lame_internal_flags const *const gfc = gfp->internal_flags; |
| 2029 |
if (is_lame_internal_flags_valid(gfc)) { |
| 2030 |
return gfc->ov_enc.frame_number; |
| 2031 |
} |
| 2032 |
} |
| 2033 |
return 0; |
| 2034 |
} |
| 2035 |
|
| 2036 |
int |
| 2037 |
lame_get_mf_samples_to_encode(const lame_global_flags * gfp) |
| 2038 |
{ |
| 2039 |
if (is_lame_global_flags_valid(gfp)) { |
| 2040 |
lame_internal_flags const *const gfc = gfp->internal_flags; |
| 2041 |
if (is_lame_internal_flags_valid(gfc)) { |
| 2042 |
return gfc->sv_enc.mf_samples_to_encode; |
| 2043 |
} |
| 2044 |
} |
| 2045 |
return 0; |
| 2046 |
} |
| 2047 |
|
| 2048 |
int CDECL |
| 2049 |
lame_get_size_mp3buffer(const lame_global_flags * gfp) |
| 2050 |
{ |
| 2051 |
if (is_lame_global_flags_valid(gfp)) { |
| 2052 |
lame_internal_flags const *const gfc = gfp->internal_flags; |
| 2053 |
if (is_lame_internal_flags_valid(gfc)) { |
| 2054 |
int size; |
| 2055 |
compute_flushbits(gfc, &size); |
| 2056 |
return size; |
| 2057 |
} |
| 2058 |
} |
| 2059 |
return 0; |
| 2060 |
} |
| 2061 |
|
| 2062 |
int |
| 2063 |
lame_get_RadioGain(const lame_global_flags * gfp) |
| 2064 |
{ |
| 2065 |
if (is_lame_global_flags_valid(gfp)) { |
| 2066 |
lame_internal_flags const *const gfc = gfp->internal_flags; |
| 2067 |
if (is_lame_internal_flags_valid(gfc)) { |
| 2068 |
return gfc->ov_rpg.RadioGain; |
| 2069 |
} |
| 2070 |
} |
| 2071 |
return 0; |
| 2072 |
} |
| 2073 |
|
| 2074 |
int |
| 2075 |
lame_get_AudiophileGain(const lame_global_flags * gfp) |
| 2076 |
{ |
| 2077 |
if (is_lame_global_flags_valid(gfp)) { |
| 2078 |
lame_internal_flags const *const gfc = gfp->internal_flags; |
| 2079 |
if (is_lame_internal_flags_valid(gfc)) { |
| 2080 |
return 0; |
| 2081 |
} |
| 2082 |
} |
| 2083 |
return 0; |
| 2084 |
} |
| 2085 |
|
| 2086 |
float |
| 2087 |
lame_get_PeakSample(const lame_global_flags * gfp) |
| 2088 |
{ |
| 2089 |
if (is_lame_global_flags_valid(gfp)) { |
| 2090 |
lame_internal_flags const *const gfc = gfp->internal_flags; |
| 2091 |
if (is_lame_internal_flags_valid(gfc)) { |
| 2092 |
return (float) gfc->ov_rpg.PeakSample; |
| 2093 |
} |
| 2094 |
} |
| 2095 |
return 0; |
| 2096 |
} |
| 2097 |
|
| 2098 |
int |
| 2099 |
lame_get_noclipGainChange(const lame_global_flags * gfp) |
| 2100 |
{ |
| 2101 |
if (is_lame_global_flags_valid(gfp)) { |
| 2102 |
lame_internal_flags const *const gfc = gfp->internal_flags; |
| 2103 |
if (is_lame_internal_flags_valid(gfc)) { |
| 2104 |
return gfc->ov_rpg.noclipGainChange; |
| 2105 |
} |
| 2106 |
} |
| 2107 |
return 0; |
| 2108 |
} |
| 2109 |
|
| 2110 |
float |
| 2111 |
lame_get_noclipScale(const lame_global_flags * gfp) |
| 2112 |
{ |
| 2113 |
if (is_lame_global_flags_valid(gfp)) { |
| 2114 |
lame_internal_flags const *const gfc = gfp->internal_flags; |
| 2115 |
if (is_lame_internal_flags_valid(gfc)) { |
| 2116 |
return gfc->ov_rpg.noclipScale; |
| 2117 |
} |
| 2118 |
} |
| 2119 |
return 0; |
| 2120 |
} |
| 2121 |
|
| 2122 |
|
| 2123 |
/* |
| 2124 |
* LAME's estimate of the total number of frames to be encoded. |
| 2125 |
* Only valid if calling program set num_samples. |
| 2126 |
*/ |
| 2127 |
int |
| 2128 |
lame_get_totalframes(const lame_global_flags * gfp) |
| 2129 |
{ |
| 2130 |
if (is_lame_global_flags_valid(gfp)) { |
| 2131 |
lame_internal_flags const *const gfc = gfp->internal_flags; |
| 2132 |
if (is_lame_internal_flags_valid(gfc)) { |
| 2133 |
SessionConfig_t const *const cfg = &gfc->cfg; |
| 2134 |
unsigned long const pcm_samples_per_frame = 576ul * cfg->mode_gr; |
| 2135 |
unsigned long pcm_samples_to_encode = gfp->num_samples; |
| 2136 |
unsigned long end_padding = 0; |
| 2137 |
int frames = 0; |
| 2138 |
|
| 2139 |
if (pcm_samples_to_encode == (0ul-1ul)) |
| 2140 |
return 0; /* unknown */ |
| 2141 |
|
| 2142 |
/* estimate based on user set num_samples: */ |
| 2143 |
if (cfg->samplerate_in != cfg->samplerate_out) { |
| 2144 |
/* resampling, estimate new samples_to_encode */ |
| 2145 |
double resampled_samples_to_encode = 0.0, frames_f = 0.0; |
| 2146 |
if (cfg->samplerate_in > 0) { |
| 2147 |
resampled_samples_to_encode = pcm_samples_to_encode; |
| 2148 |
resampled_samples_to_encode *= cfg->samplerate_out; |
| 2149 |
resampled_samples_to_encode /= cfg->samplerate_in; |
| 2150 |
} |
| 2151 |
if (resampled_samples_to_encode <= 0.0) |
| 2152 |
return 0; /* unlikely to happen, so what, no estimate! */ |
| 2153 |
frames_f = floor(resampled_samples_to_encode / pcm_samples_per_frame); |
| 2154 |
if (frames_f >= (INT_MAX-2)) |
| 2155 |
return 0; /* overflow, happens eventually, no estimate! */ |
| 2156 |
frames = frames_f; |
| 2157 |
resampled_samples_to_encode -= frames * pcm_samples_per_frame; |
| 2158 |
pcm_samples_to_encode = ceil(resampled_samples_to_encode); |
| 2159 |
} |
| 2160 |
else { |
| 2161 |
frames = pcm_samples_to_encode / pcm_samples_per_frame; |
| 2162 |
pcm_samples_to_encode -= frames * pcm_samples_per_frame; |
| 2163 |
} |
| 2164 |
pcm_samples_to_encode += 576ul; |
| 2165 |
end_padding = pcm_samples_per_frame - (pcm_samples_to_encode % pcm_samples_per_frame); |
| 2166 |
if (end_padding < 576ul) { |
| 2167 |
end_padding += pcm_samples_per_frame; |
| 2168 |
} |
| 2169 |
pcm_samples_to_encode += end_padding; |
| 2170 |
frames += (pcm_samples_to_encode / pcm_samples_per_frame); |
| 2171 |
/* check to see if we underestimated totalframes */ |
| 2172 |
/* if (totalframes < gfp->frameNum) */ |
| 2173 |
/* totalframes = gfp->frameNum; */ |
| 2174 |
return frames; |
| 2175 |
} |
| 2176 |
} |
| 2177 |
return 0; |
| 2178 |
} |
| 2179 |
|
| 2180 |
|
| 2181 |
|
| 2182 |
|
| 2183 |
|
| 2184 |
int |
| 2185 |
lame_set_preset(lame_global_flags * gfp, int preset) |
| 2186 |
{ |
| 2187 |
if (is_lame_global_flags_valid(gfp)) { |
| 2188 |
gfp->preset = preset; |
| 2189 |
return apply_preset(gfp, preset, 1); |
| 2190 |
} |
| 2191 |
return -1; |
| 2192 |
} |
| 2193 |
|
| 2194 |
|
| 2195 |
|
| 2196 |
int |
| 2197 |
lame_set_asm_optimizations(lame_global_flags * gfp, int optim, int mode) |
| 2198 |
{ |
| 2199 |
if (is_lame_global_flags_valid(gfp)) { |
| 2200 |
mode = (mode == 1 ? 1 : 0); |
| 2201 |
switch (optim) { |
| 2202 |
case MMX:{ |
| 2203 |
gfp->asm_optimizations.mmx = mode; |
| 2204 |
return optim; |
| 2205 |
} |
| 2206 |
case AMD_3DNOW:{ |
| 2207 |
gfp->asm_optimizations.amd3dnow = mode; |
| 2208 |
return optim; |
| 2209 |
} |
| 2210 |
case SSE:{ |
| 2211 |
gfp->asm_optimizations.sse = mode; |
| 2212 |
return optim; |
| 2213 |
} |
| 2214 |
default: |
| 2215 |
return optim; |
| 2216 |
} |
| 2217 |
} |
| 2218 |
return -1; |
| 2219 |
} |
| 2220 |
|
| 2221 |
|
| 2222 |
void |
| 2223 |
lame_set_write_id3tag_automatic(lame_global_flags * gfp, int v) |
| 2224 |
{ |
| 2225 |
if (is_lame_global_flags_valid(gfp)) { |
| 2226 |
gfp->write_id3tag_automatic = v; |
| 2227 |
} |
| 2228 |
} |
| 2229 |
|
| 2230 |
|
| 2231 |
int |
| 2232 |
lame_get_write_id3tag_automatic(lame_global_flags const *gfp) |
| 2233 |
{ |
| 2234 |
if (is_lame_global_flags_valid(gfp)) { |
| 2235 |
return gfp->write_id3tag_automatic; |
| 2236 |
} |
| 2237 |
return 1; |
| 2238 |
} |
| 2239 |
|
| 2240 |
|
| 2241 |
/* |
| 2242 |
|
| 2243 |
UNDOCUMENTED, experimental settings. These routines are not prototyped |
| 2244 |
in lame.h. You should not use them, they are experimental and may |
| 2245 |
change. |
| 2246 |
|
| 2247 |
*/ |
| 2248 |
|
| 2249 |
|
| 2250 |
/* |
| 2251 |
* just another daily changing developer switch |
| 2252 |
*/ |
| 2253 |
void CDECL lame_set_tune(lame_global_flags *, float); |
| 2254 |
|
| 2255 |
void |
| 2256 |
lame_set_tune(lame_global_flags * gfp, float val) |
| 2257 |
{ |
| 2258 |
if (is_lame_global_flags_valid(gfp)) { |
| 2259 |
gfp->tune_value_a = val; |
| 2260 |
gfp->tune = 1; |
| 2261 |
} |
| 2262 |
} |
| 2263 |
|
| 2264 |
/* Custom msfix hack */ |
| 2265 |
void |
| 2266 |
lame_set_msfix(lame_global_flags * gfp, double msfix) |
| 2267 |
{ |
| 2268 |
if (is_lame_global_flags_valid(gfp)) { |
| 2269 |
/* default = 0 */ |
| 2270 |
gfp->msfix = msfix; |
| 2271 |
} |
| 2272 |
} |
| 2273 |
|
| 2274 |
float |
| 2275 |
lame_get_msfix(const lame_global_flags * gfp) |
| 2276 |
{ |
| 2277 |
if (is_lame_global_flags_valid(gfp)) { |
| 2278 |
return gfp->msfix; |
| 2279 |
} |
| 2280 |
return 0; |
| 2281 |
} |
| 2282 |
|
| 2283 |
#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED |
| 2284 |
int CDECL lame_set_preset_expopts(lame_global_flags *, int); |
| 2285 |
#else |
| 2286 |
#endif |
| 2287 |
|
| 2288 |
int |
| 2289 |
lame_set_preset_expopts(lame_global_flags * gfp, int preset_expopts) |
| 2290 |
{ |
| 2291 |
(void) gfp; |
| 2292 |
(void) preset_expopts; |
| 2293 |
return 0; |
| 2294 |
} |
| 2295 |
|
| 2296 |
|
| 2297 |
int |
| 2298 |
lame_set_preset_notune(lame_global_flags * gfp, int preset_notune) |
| 2299 |
{ |
| 2300 |
(void) gfp; |
| 2301 |
(void) preset_notune; |
| 2302 |
return 0; |
| 2303 |
} |
| 2304 |
|
| 2305 |
static int |
| 2306 |
calc_maximum_input_samples_for_buffer_size(lame_internal_flags const* gfc, size_t buffer_size) |
| 2307 |
{ |
| 2308 |
SessionConfig_t const *const cfg = &gfc->cfg; |
| 2309 |
int const pcm_samples_per_frame = 576 * cfg->mode_gr; |
| 2310 |
int frames_per_buffer = 0, input_samples_per_buffer = 0; |
| 2311 |
int kbps = 320; |
| 2312 |
|
| 2313 |
if (cfg->samplerate_out < 16000) |
| 2314 |
kbps = 64; |
| 2315 |
else if (cfg->samplerate_out < 32000) |
| 2316 |
kbps = 160; |
| 2317 |
else |
| 2318 |
kbps = 320; |
| 2319 |
if (cfg->free_format) |
| 2320 |
kbps = cfg->avg_bitrate; |
| 2321 |
else if (cfg->vbr == vbr_off) { |
| 2322 |
kbps = cfg->avg_bitrate; |
| 2323 |
} |
| 2324 |
{ |
| 2325 |
int const pad = 1; |
| 2326 |
int const bpf = ((cfg->version + 1) * 72000 * kbps / cfg->samplerate_out + pad); |
| 2327 |
frames_per_buffer = buffer_size / bpf; |
| 2328 |
} |
| 2329 |
{ |
| 2330 |
double ratio = (double) cfg->samplerate_in / cfg->samplerate_out; |
| 2331 |
input_samples_per_buffer = pcm_samples_per_frame * frames_per_buffer * ratio; |
| 2332 |
} |
| 2333 |
return input_samples_per_buffer; |
| 2334 |
} |
| 2335 |
|
| 2336 |
int |
| 2337 |
lame_get_maximum_number_of_samples(lame_t gfp, size_t buffer_size) |
| 2338 |
{ |
| 2339 |
if (is_lame_global_flags_valid(gfp)) { |
| 2340 |
lame_internal_flags const *const gfc = gfp->internal_flags; |
| 2341 |
if (is_lame_internal_flags_valid(gfc)) { |
| 2342 |
return calc_maximum_input_samples_for_buffer_size(gfc, buffer_size); |
| 2343 |
} |
| 2344 |
} |
| 2345 |
return LAME_GENERICERROR; |
| 2346 |
} |