X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=libhb%2Fenclame.c;h=8f4defcc53bf023a83dc86819be92e16b1c6bae4;hb=ac24fef71ded1f1884000fb9ce039b71587a8f30;hp=33cfa14c8ca527f311cd3edc74e5d0a316867e2c;hpb=e8c0337fb71573f9f3cceba92e691c28afc5c426;p=handbrake-jp%2Fhandbrake-jp-git.git
diff --git a/libhb/enclame.c b/libhb/enclame.c
index 33cfa14c..8f4defcc 100644
--- a/libhb/enclame.c
+++ b/libhb/enclame.c
@@ -1,7 +1,7 @@
/* $Id: enclame.c,v 1.9 2005/03/05 14:27:05 titer Exp $
This file is part of the HandBrake source code.
- Homepage: .
+ Homepage: .
It may be used under the terms of the GNU General Public License. */
#include "hb.h"
@@ -39,6 +39,7 @@ struct hb_work_private_s
int enclameInit( hb_work_object_t * w, hb_job_t * job )
{
hb_work_private_t * pv = calloc( 1, sizeof( hb_work_private_t ) );
+ hb_audio_t * audio = w->audio;
w->private_data = pv;
pv->job = job;
@@ -46,11 +47,11 @@ int enclameInit( hb_work_object_t * w, hb_job_t * job )
hb_log( "enclame: opening libmp3lame" );
pv->lame = lame_init();
- lame_set_brate( pv->lame, job->abitrate );
- lame_set_in_samplerate( pv->lame, job->arate );
- lame_set_out_samplerate( pv->lame, job->arate );
+ lame_set_brate( pv->lame, audio->config.out.bitrate );
+ lame_set_in_samplerate( pv->lame, audio->config.out.samplerate );
+ lame_set_out_samplerate( pv->lame, audio->config.out.samplerate );
lame_init_params( pv->lame );
-
+
pv->input_samples = 1152 * 2;
pv->output_bytes = LAME_MAXMP3BUFFER;
pv->buf = malloc( pv->input_samples * sizeof( float ) );
@@ -69,7 +70,7 @@ int enclameInit( hb_work_object_t * w, hb_job_t * job )
void enclameClose( hb_work_object_t * w )
{
hb_work_private_t * pv = w->private_data;
-
+
lame_close( pv->lame );
hb_list_empty( &pv->list );
free( pv->buf );
@@ -85,6 +86,7 @@ void enclameClose( hb_work_object_t * w )
static hb_buffer_t * Encode( hb_work_object_t * w )
{
hb_work_private_t * pv = w->private_data;
+ hb_audio_t * audio = w->audio;
hb_buffer_t * buf;
int16_t samples_s16[1152 * 2];
uint64_t pts, pos;
@@ -104,11 +106,11 @@ static hb_buffer_t * Encode( hb_work_object_t * w )
}
buf = hb_buffer_init( pv->output_bytes );
- buf->start = pts + 90000 * pos / 2 / sizeof( float ) / pv->job->arate;
- buf->stop = buf->start + 90000 * 1152 / pv->job->arate;
+ buf->start = pts + 90000 * pos / 2 / sizeof( float ) / audio->config.out.samplerate;
+ buf->stop = buf->start + 90000 * 1152 / audio->config.out.samplerate;
buf->size = lame_encode_buffer_interleaved( pv->lame, samples_s16,
1152, buf->data, LAME_MAXMP3BUFFER );
- buf->key = 1;
+ buf->frametype = HB_FRAME_AUDIO;
if( !buf->size )
{
@@ -138,6 +140,14 @@ int enclameWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
hb_work_private_t * pv = w->private_data;
hb_buffer_t * buf;
+ if ( (*buf_in)->size <= 0 )
+ {
+ /* EOF on input - send it downstream & say we're done */
+ *buf_out = *buf_in;
+ *buf_in = NULL;
+ return HB_WORK_DONE;
+ }
+
hb_list_add( pv->list, *buf_in );
*buf_in = NULL;