diff options
author | jstebbins <[email protected]> | 2010-11-04 21:15:47 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2010-11-04 21:15:47 +0000 |
commit | 84ef970ab6351a6646646cd98848ed3f2972ba66 (patch) | |
tree | cbda4ee57d312144b450adc010a04c20b49e4350 | |
parent | 6d5b13f06714d783fdc2d2c156874a2a8231a53e (diff) |
fix start/stop time of last lame buffer
after flushing lame, the flushed buffers start/stop time were not
being set.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3646 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/enclame.c | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/libhb/enclame.c b/libhb/enclame.c index 9692eef29..955aca626 100644 --- a/libhb/enclame.c +++ b/libhb/enclame.c @@ -28,7 +28,6 @@ struct hb_work_private_s /* LAME handle */ lame_global_flags * lame; - int done; int out_discrete_channels; unsigned long input_samples; unsigned long output_bytes; @@ -133,6 +132,7 @@ static hb_buffer_t * Encode( hb_work_object_t * w ) buf = hb_buffer_init( pv->output_bytes ); buf->start = pts + 90000 * pos / pv->out_discrete_channels / sizeof( float ) / audio->config.out.samplerate; buf->stop = buf->start + 90000 * 1152 / audio->config.out.samplerate; + pv->pts = buf->stop; buf->size = lame_encode_buffer_float( pv->lame, samples[0], samples[1], 1152, buf->data, LAME_MAXMP3BUFFER ); @@ -152,7 +152,6 @@ static hb_buffer_t * Encode( hb_work_object_t * w ) hb_buffer_close( &buf ); return NULL; } - return buf; } @@ -165,33 +164,39 @@ int enclameWork( hb_work_object_t * w, hb_buffer_t ** buf_in, hb_buffer_t ** buf_out ) { hb_work_private_t * pv = w->private_data; + hb_audio_t * audio = w->audio; hb_buffer_t * in = *buf_in; hb_buffer_t * buf; if ( (*buf_in)->size <= 0 ) { /* EOF on input - send it downstream & say we're done */ - if ( pv->done ) + + buf = hb_buffer_init( pv->output_bytes ); + buf->size = lame_encode_flush( pv->lame, buf->data, LAME_MAXMP3BUFFER ); + buf->start = pv->pts; + buf->stop = buf->start + 90000 * 1152 / audio->config.out.samplerate; + buf->frametype = HB_FRAME_AUDIO; + if( buf->size <= 0 ) + { + hb_buffer_close( &buf ); + } + + // Add the flushed data + *buf_out = buf; + + // Add the eof + if ( buf ) { - *buf_out = *buf_in; - *buf_in = NULL; - return HB_WORK_DONE; + buf->next = in; } else { - pv->done = 1; - hb_fifo_push( w->fifo_in, in); - *buf_in = NULL; - - buf = hb_buffer_init( pv->output_bytes ); - buf->size = lame_encode_flush( pv->lame, buf->data, LAME_MAXMP3BUFFER ); - if( buf->size <= 0 ) - { - hb_buffer_close( &buf ); - } - *buf_out = buf; - return HB_WORK_OK; + *buf_out = in; } + + *buf_in = NULL; + return HB_WORK_DONE; } hb_list_add( pv->list, *buf_in ); |