From 5900ea5299bf2b3de46e7c1a32c2ac747249da89 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 18 Feb 2009 18:40:40 +0100 Subject: mp4ff: don't allocate seek_table when input is not seekable Don't waste any precious memory when the seek_table cannot be used. --- src/decoder/mp4ff_plugin.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/decoder') diff --git a/src/decoder/mp4ff_plugin.c b/src/decoder/mp4ff_plugin.c index ec60bc0bd..ddbb768e3 100644 --- a/src/decoder/mp4ff_plugin.c +++ b/src/decoder/mp4ff_plugin.c @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -217,7 +218,9 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream) file_time = 0.0; - seek_table = g_malloc(sizeof(float) * num_samples); + seek_table = input_stream->seekable + ? g_malloc(sizeof(float) * num_samples) + : NULL; decoder_initialized(mpd_decoder, &audio_format, input_stream->seekable, @@ -227,6 +230,8 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream) sample_id < num_samples && cmd != DECODE_COMMAND_STOP; sample_id++) { if (cmd == DECODE_COMMAND_SEEK) { + assert(seek_table != NULL); + seeking = true; seek_where = decoder_seek_where(mpd_decoder); } @@ -234,6 +239,9 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream) if (seeking && seek_table_end > 1 && seek_table[seek_table_end] >= seek_where) { int i = 2; + + assert(seek_table != NULL); + while (seek_table[i] < seek_where) i++; sample_id = i - 1; @@ -243,7 +251,7 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream) dur = mp4ff_get_sample_duration(mp4fh, track, sample_id); offset = mp4ff_get_sample_offset(mp4fh, track, sample_id); - if (sample_id > seek_table_end) { + if (seek_table != NULL && sample_id > seek_table_end) { seek_table[sample_id] = file_time; seek_table_end = sample_id; } -- cgit v1.2.3