summaryrefslogtreecommitdiffstats
path: root/libhb/muxcommon.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2010-02-09 23:34:56 +0000
committerjstebbins <[email protected]>2010-02-09 23:34:56 +0000
commit8d5e3f04146637cfadeed1046ec7f0b4639b1d72 (patch)
tree1f7bdfb40491b2ec4c869593f974238609000e2d /libhb/muxcommon.c
parent974fc416c9b792a5e7b1b2ce59083f68f2e6f8c4 (diff)
put a limit on how many buffers the muxer will cache when it is
having trouble interleaving timestamps This prevents some out of memory crashes. In particular, it fixes a crashed caused by a source in which the audio stream ends substantially before the video stream ends. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3106 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/muxcommon.c')
-rw-r--r--libhb/muxcommon.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/libhb/muxcommon.c b/libhb/muxcommon.c
index 43b9710e9..01f4845a7 100644
--- a/libhb/muxcommon.c
+++ b/libhb/muxcommon.c
@@ -103,10 +103,19 @@ static void add_mux_track( hb_mux_t *mux, hb_mux_data_t *mux_data,
mux->allRdy |= is_continuous << t;
}
-static void mf_push( hb_track_t *track, hb_buffer_t *buf )
+static void mf_push( hb_mux_t * mux, int tk, hb_buffer_t *buf )
{
+ hb_track_t * track = mux->track[tk];
uint32_t mask = track->mf.flen - 1;
uint32_t in = track->mf.in;
+
+ if ( ( ( in + 2 ) & mask ) == ( track->mf.out & mask ) )
+ {
+ if ( track->mf.flen >= 1024 )
+ {
+ mux->rdy = mux->allRdy;
+ }
+ }
if ( ( ( in + 1 ) & mask ) == ( track->mf.out & mask ) )
{
// fifo is full - expand it to double the current size.
@@ -157,13 +166,11 @@ static hb_buffer_t *mf_peek( hb_track_t *track )
static void MoveToInternalFifos( int tk, hb_mux_t *mux, hb_buffer_t * buf )
{
- hb_track_t *track = mux->track[tk];
-
// move all the buffers on the track's fifo to our internal
// fifo so that (a) we don't deadlock in the reader and
// (b) we can control how data from multiple tracks is
// interleaved in the output file.
- mf_push( track, buf );
+ mf_push( mux, tk, buf );
if ( buf->stop >= mux->pts )
{
// buffer is past our next interleave point so