From: jstebbins Date: Thu, 4 Nov 2010 21:15:47 +0000 (+0000) Subject: fix start/stop time of last lame buffer X-Git-Url: http://git.osdn.jp/view?a=commitdiff_plain;h=e8ea2f8a0fc9e8bad92c266851cd95f98aa1c51e;p=handbrake-jp%2Fhandbrake-jp-git.git 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://localhost/HandBrake/trunk@3646 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/libhb/enclame.c b/libhb/enclame.c index 9692eef2..955aca62 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 );