char decoder[256];
float vol;
uint32_t outscale;
+ uint32_t brate;
+ uint32_t resample;
+ uint32_t quality;
} globals;
mpg123_handle *our_mpg123_new(const char *decoder, int *error)
}
if (context->fp) {
- unsigned char mp3buffer[8192];
+ unsigned char mp3buffer[20480];
int len;
int16_t blank[2048] = { 0 }, *r = NULL;
}
while (!context->err && context->thread_running) {
- unsigned char mp3buf[8192] = "";
+ unsigned char mp3buf[20480] = "";
int16_t audio[9600] = { 0 };
switch_size_t audio_read = 0;
int rlen = 0;
}
context->channels = handle->channels;
- lame_set_brate(context->gfp, 16 * (handle->samplerate / 8000) * handle->channels);
+
+ if (globals.brate) {
+ lame_set_brate(context->gfp, globals.brate);
+ } else {
+ lame_set_brate(context->gfp, 16 * (handle->samplerate / 8000) * handle->channels);
+ }
+
lame_set_num_channels(context->gfp, handle->channels);
lame_set_in_samplerate(context->gfp, handle->samplerate);
- lame_set_out_samplerate(context->gfp, handle->samplerate);
+
+ if (globals.resample) {
+ lame_set_out_samplerate(context->gfp, globals.resample);
+ } else {
+ lame_set_out_samplerate(context->gfp, handle->samplerate);
+ }
if (handle->channels == 2) {
lame_set_mode(context->gfp, STEREO);
} else {
lame_set_mode(context->gfp, MONO);
}
- lame_set_quality(context->gfp, 2); /* 2=high 5 = medium 7=low */
+
+ if (globals.quality) {
+ lame_set_quality(context->gfp, globals.quality);
+ } else {
+ lame_set_quality(context->gfp, 2); /* 2=high 5 = medium 7=low */
+ }
lame_set_errorf(context->gfp, log_error);
lame_set_debugf(context->gfp, log_debug);
if (tmp > 0) {
globals.outscale = tmp;
}
+ } else if (!strcmp(var, "encode-brate")) {
+ int tmp = atoi(val);
+ if (tmp > 0) {
+ globals.brate = tmp;
+ }
+ } else if (!strcmp(var, "encode-resample")) {
+ int tmp = atoi(val);
+ if (tmp > 0) {
+ globals.resample = tmp;
+ }
+ } else if (!strcmp(var, "encode-quality")) {
+ int tmp = atoi(val);
+ if (tmp > 0) {
+ globals.quality = tmp;
+ }
}
}
}