diff options
author | jstebbins <[email protected]> | 2010-06-20 21:22:52 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2010-06-20 21:22:52 +0000 |
commit | 3b854fa44bc3036b4263ff9241f56ac4a31e2838 (patch) | |
tree | be44f9c1588ceab08148f4c41a07c160a9400d3a | |
parent | 57bcc243f164e5aceea7f763f9e1a8cfc721891f (diff) |
guard against excessive memory consumption in the muxer better
if there is a persistant skew in timestamps from 2 streams, the
fifo depth could still continue to grow. Added extra check for
fullness of fifo.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3400 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/muxcommon.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libhb/muxcommon.c b/libhb/muxcommon.c index b6b5a2a57..34836b6cb 100644 --- a/libhb/muxcommon.c +++ b/libhb/muxcommon.c @@ -103,6 +103,21 @@ static void add_mux_track( hb_mux_t *mux, hb_mux_data_t *mux_data, mux->allRdy |= is_continuous << t; } +static int mf_full( hb_track_t * track ) +{ + uint32_t mask = track->mf.flen - 1; + uint32_t in = track->mf.in; + + if ( ( ( in + 1 ) & mask ) == ( track->mf.out & mask ) ) + { + if ( track->mf.flen >= 256 ) + { + return 1; + } + } + return 0; +} + static void mf_push( hb_mux_t * mux, int tk, hb_buffer_t *buf ) { hb_track_t * track = mux->track[tk]; @@ -241,6 +256,13 @@ static int muxWork( hb_work_object_t * w, hb_buffer_t ** buf_in, { track = mux->track[i]; OutputTrackChunk( mux, track, mux->m ); + if ( mf_full( track ) ) + { + // If the track's fifo is still full, advance + // the currint interleave point and try again. + mux->rdy = mux->allRdy; + break; + } // if the track is at eof or still has data that's past // our next interleave point then leave it marked as rdy. |