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.cc40
1 files changed, 34 insertions, 6 deletions
diff --git a/src/liblame_wrapper.cc b/src/liblame_wrapper.cc
index 08765b7..87b2f11 100644
--- a/src/liblame_wrapper.cc
+++ b/src/liblame_wrapper.cc
@@ -42,8 +42,9 @@ LibLAMEWrapper::LibLAMEWrapper(Info *i)
lame_set_out_samplerate(gfp, OUTPUT_SAMPLE_RATE);
lame_set_num_channels(gfp, CHANNELS);
- lame_set_num_samples(gfp, 1152);
+ // lame_set_num_samples(gfp, 1152);
// lame_set_num_samples(gfp, SAMPLES);
+ // lame_set_num_samples(gfp, 0);
lame_set_quality(gfp, config->readInt("mp3_quality"));
lame_set_mode(gfp, STEREO);
@@ -87,12 +88,31 @@ LibLAMEWrapper::LibLAMEWrapper(Info *i)
LibLAMEWrapper::~LibLAMEWrapper()
{
- lame_close(gfp);
-
delete audio_buffer[0];
delete audio_buffer[1];
}
+Frame *LibLAMEWrapper::close(Frame *oldframe)
+{
+ Frame *frame = new Frame(NULL, oldframe->size + 7200);
+ frame->number = oldframe->number;
+
+ memcpy(frame->data, oldframe->data, oldframe->size);
+
+ int flush;
+
+ flush = lame_encode_finish(gfp, frame->data + oldframe->size, 7200);
+
+ frame->size = oldframe->size + flush;
+
+ calc_bitrate += flush;
+ frame->bitrate = (unsigned int)((double)calc_bitrate / (double)(frame_number)) * 25;
+
+ delete oldframe;
+
+ return frame;
+}
+
Frame *LibLAMEWrapper::encode(Frame *dvframe)
{
@@ -193,12 +213,19 @@ Frame *LibLAMEWrapper::encode(Frame *dvframe)
*
* return code = number of bytes output to mp3buf. Can be 0
*/
+
+ int flush_sz = 0;
+
+ /*
+ 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
+ */
- 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
+ info->info("VAL: %d - FLUSH_SZ: %d - TOTAL: %d", val, flush_sz, (val + flush_sz));
audio_frame->size = val + flush_sz;
+
/*
int bitrate_kbps[14];
@@ -237,5 +264,6 @@ Frame *LibLAMEWrapper::encode(Frame *dvframe)
audio_frame->bitrate,
(float)(config->readInt("mp3_bitrate") * 1000)/(float)(audio_frame->bitrate));
*/
+
return audio_frame;
}