diff options
author | van <[email protected]> | 2008-07-26 01:04:00 +0000 |
---|---|---|
committer | van <[email protected]> | 2008-07-26 01:04:00 +0000 |
commit | e529b1dbda55f01e21fe6fb04ee7f85c2e755725 (patch) | |
tree | 1748a00de07c035323dc9c3c9597ec9fefdeae7e /libhb/sync.c | |
parent | e3298b9003a7ee6070842516818bc08d8b0a65ed (diff) |
- in encx264, if an video frame is larger than init_delay split it into pieces so we don't get jerky output caused by out-of-order frames.
- add an explicit EOF for all streams, not just video.
- don't generate extra audio silence at the end of an encode (don't need it with explicit eof).
- get rid of 80ms initial delay in AAC encode & flush final four frames buffered in encoder.
- put mp4 'chap' atom on first track (usually video) rather than first audio track since we can now do video without audio (atom just needs to go on an enabled media track & video is always enabled).
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1581 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/sync.c')
-rw-r--r-- | libhb/sync.c | 53 |
1 files changed, 7 insertions, 46 deletions
diff --git a/libhb/sync.c b/libhb/sync.c index f51e0e130..7f0ac86c4 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -23,7 +23,6 @@ typedef struct int64_t next_start; /* start time of next output frame */ int64_t next_pts; /* start time of next input frame */ - int64_t start_silence; /* if we're inserting silence, the time we started */ int64_t first_drop; /* PTS of first 'went backwards' frame dropped */ int drop_count; /* count of 'time went backwards' drops */ @@ -72,7 +71,6 @@ struct hb_work_private_s static void InitAudio( hb_work_object_t * w, int i ); static int SyncVideo( hb_work_object_t * w ); static void SyncAudio( hb_work_object_t * w, int i ); -static int NeedSilence( hb_work_object_t * w, hb_audio_t *, int i ); static void InsertSilence( hb_work_object_t * w, int i, int64_t d ); static void UpdateState( hb_work_object_t * w ); @@ -151,13 +149,6 @@ void syncClose( hb_work_object_t * w ) for( i = 0; i < hb_list_count( title->list_audio ); i++ ) { - if ( pv->sync_audio[i].start_silence ) - { - hb_log( "sync: added %d ms of silence to audio %d", - (int)((pv->sync_audio[i].next_pts - - pv->sync_audio[i].start_silence) / 90), i ); - } - audio = hb_list_item( title->list_audio, i ); if( audio->config.out.codec == HB_ACODEC_AC3 ) { @@ -727,6 +718,13 @@ static void SyncAudio( hb_work_object_t * w, int i ) while( !hb_fifo_is_full( fifo ) && ( buf = hb_fifo_see( audio->priv.fifo_raw ) ) ) { + /* if the next buffer is an eof send it downstream */ + if ( buf->size <= 0 ) + { + buf = hb_fifo_get( audio->priv.fifo_raw ); + hb_fifo_push( fifo, buf ); + return; + } if ( (int64_t)( buf->start - sync->next_pts ) < 0 ) { // audio time went backwards. @@ -780,43 +778,6 @@ static void SyncAudio( hb_work_object_t * w, int i ) buf = hb_fifo_get( audio->priv.fifo_raw ); OutputAudioFrame( job, audio, buf, sync, fifo, i ); } - - if( NeedSilence( w, audio, i ) ) - { - InsertSilence( w, i, (90000 * AC3_SAMPLES_PER_FRAME) / - sync->audio->config.in.samplerate ); - } -} - -static int NeedSilence( hb_work_object_t * w, hb_audio_t * audio, int i ) -{ - hb_work_private_t * pv = w->private_data; - hb_job_t * job = pv->job; - hb_sync_audio_t * sync = &pv->sync_audio[i]; - - if( hb_fifo_size( audio->priv.fifo_in ) || - hb_fifo_size( audio->priv.fifo_raw ) || - hb_fifo_size( audio->priv.fifo_sync ) || - hb_fifo_size( audio->priv.fifo_out ) ) - { - /* We have some audio, we are fine */ - return 0; - } - - /* No audio left in fifos */ - - if( hb_thread_has_exited( job->reader ) ) - { - /* We might miss some audio to complete encoding and muxing - the video track */ - if ( sync->start_silence == 0 ) - { - hb_log("sync: reader has exited, adding silence to audio %d", i); - sync->start_silence = sync->next_pts; - } - return 1; - } - return 0; } static void InsertSilence( hb_work_object_t * w, int i, int64_t duration ) |