summaryrefslogtreecommitdiff
path: root/src/liblame_wrapper.cc
diff options
context:
space:
mode:
authordeva <deva>2005-09-20 19:39:49 +0000
committerdeva <deva>2005-09-20 19:39:49 +0000
commit48b768db44cb9e00adfead71b973074685cec417 (patch)
treee606f6f93b5fee42335b6f4f3cfaf7b3dc487cae /src/liblame_wrapper.cc
parent5298cdacd41efbf2ffd0282b14e401734b31d90a (diff)
*** empty log message ***R0_2_8
Diffstat (limited to 'src/liblame_wrapper.cc')
-rw-r--r--src/liblame_wrapper.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/liblame_wrapper.cc b/src/liblame_wrapper.cc
index c72c2dc..b29acf9 100644
--- a/src/liblame_wrapper.cc
+++ b/src/liblame_wrapper.cc
@@ -94,22 +94,27 @@ LibLAMEWrapper::~LibLAMEWrapper()
Frame *LibLAMEWrapper::close(Frame *oldframe)
{
- Frame *frame = new Frame(NULL, oldframe->size + 7200);
- frame->number = oldframe->number;
+ Frame *frame;
+ unsigned int offset = 0;
- memcpy(frame->data, oldframe->data, oldframe->size);
+ frame = new Frame(NULL, (int)(1.25 * SAMPLES + 7200) * 2); // Big enough to hold two frames
+
+ if(oldframe) {
+ offset = oldframe->size;
+ frame->number = oldframe->number;
+ memcpy(frame->data, oldframe->data, oldframe->size);
+ delete oldframe;
+ }
int flush;
- flush = lame_encode_finish(gfp, frame->data + oldframe->size, 7200);
+ flush = lame_encode_finish(gfp, frame->data + offset, 7200);
- frame->size = oldframe->size + flush;
+ frame->size = offset + flush;
calc_bitrate += flush;
frame->bitrate = (unsigned int)((double)calc_bitrate / (double)(frame_number)) * 25;
- delete oldframe;
-
return frame;
}