summaryrefslogtreecommitdiff
path: root/src/liblame_wrapper.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/liblame_wrapper.cc')
-rw-r--r--src/liblame_wrapper.cc58
1 files changed, 45 insertions, 13 deletions
diff --git a/src/liblame_wrapper.cc b/src/liblame_wrapper.cc
index d74233e..f204214 100644
--- a/src/liblame_wrapper.cc
+++ b/src/liblame_wrapper.cc
@@ -31,6 +31,9 @@
/*
* $Log$
+ * Revision 1.5 2005/07/22 15:59:39 deva
+ * *** empty log message ***
+ *
* Revision 1.4 2005/07/09 16:23:15 deva
* Added audio.
*
@@ -48,6 +51,7 @@
#include <config.h>
#include "liblame_wrapper.h"
+#include "miav_config.h"
LibLAMEWrapper::LibLAMEWrapper(Info *i)
{
@@ -59,17 +63,27 @@ LibLAMEWrapper::LibLAMEWrapper(Info *i)
return;
}
- lame_set_in_samplerate(gfp, SAMPLE_RATE);
- lame_set_out_samplerate(gfp, SAMPLE_RATE);
- lame_set_num_channels(gfp, CHANNELS);
- // lame 3.91 dies on quality != 5
- lame_set_quality(gfp, 3);
- // lame 3.91 doesn't work in mono
- lame_set_mode(gfp, JOINT_STEREO);
- lame_set_brate(gfp, 112);
- lame_set_strict_ISO(gfp, 1);
+ lame_set_in_samplerate(gfp, INPUT_SAMPLE_RATE);
+ lame_set_out_samplerate(gfp, OUTPUT_SAMPLE_RATE);
+
+ lame_set_num_channels(gfp, CHANNELS);
lame_set_num_samples(gfp, SAMPLES);
+ lame_set_quality(gfp, config->readInt("mp3_quality"));
+ lame_set_mode(gfp, STEREO);
+ lame_set_brate(gfp, config->readInt("mp3_bitrate"));
+
+ lame_set_strict_ISO(gfp, 0);
+
+ // 1 = write a Xing VBR header frame.
+ lame_set_bWriteVbrTag(gfp, 0);
+
+ // Types of VBR. default = vbr_off = CBR
+ // lame_set_VBR(gfp, vbr_rh);
+
+ // VBR quality level. 0=highest 9=lowest
+ // lame_set_VBR_q(gfp, 6);
+
lame_set_copyright(gfp, 0); // is there a copyright on the encoded data?
lame_set_original(gfp, 1); // is the encoded data on the original media?
lame_set_error_protection(gfp, 0);// add 2 byte CRC protection to each frame?
@@ -79,15 +93,12 @@ LibLAMEWrapper::LibLAMEWrapper(Info *i)
// 2 = adjust padding to satisfy bit rate
lame_set_extension(gfp, 0); // private extension bit
- info->info("Lame version %d", lame_get_version(gfp));
if (lame_init_params(gfp) < 0) {
info->error("LAME parameter initialization failed.");
return;
}
- lame_init_bitstream(gfp);
-
audio_buffer[0] = new int16_t[AUDIO_BUFFER_SIZE];
audio_buffer[1] = new int16_t[AUDIO_BUFFER_SIZE];
@@ -186,7 +197,28 @@ Frame *LibLAMEWrapper::encode(Frame *dvframe)
}
}
- audio_frame->size = val;
+ /**
+ * OPTIONAL:
+ * lame_encode_flush_nogap will flush the internal mp3 buffers and pad
+ * the last frame with ancillary data so it is a complete mp3 frame.
+ *
+ * 'mp3buf' should be at least 7200 bytes long
+ * to hold all possible emitted data.
+ *
+ * After a call to this routine, the outputed mp3 data is complete, but
+ * you may continue to encode new PCM samples and write future mp3 data
+ * to a different file. The two mp3 files will play back with no gaps
+ * if they are concatenated together.
+ *
+ * This routine will NOT write id3v1 tags into the bitstream.
+ *
+ * return code = number of bytes output to mp3buf. Can be 0
+ */
+ int flush_sz = lame_encode_flush_nogap(gfp, // global context handle
+ mp3buf + val, // pointer to encoded MP3 stream
+ mp3buf_size - val); // number of valid octets in this stream
+
+ audio_frame->size = val + flush_sz;
return audio_frame;
}