[FFmpeg-devel] MPEG-PS demuxer index memory usage
Paul Kelly
paul
Sun Jan 13 12:59:02 CET 2008
On Sun, 13 Jan 2008, Michael Niedermayer wrote:
> On Sat, Jan 12, 2008 at 09:27:19PM +0000, Paul Kelly wrote:
> [...]
>> @@ -477,6 +477,8 @@
>> * demuxing: set by user
>> */
>> enum CodecID subtitle_codec_id;
>> +
>> + unsigned int max_index_size; /**< Maximum memory to use per stream for timestamp index */
>
> the comment should follow the same syntax as the ones above that is
> specifying who sets it for demuxing/muxing
Right I've tried to do that but wasn't quite sure how exactly to describe
it: "set by user" as the ones above it say seems pretty vague to me - in
this case if the user doesn't specify anything the default will be taken
from the AVOption array so I tried to make that clear.
> [...]
>> /**
>> + * Ensures the index uses less memory than the maximum specified in
>> + * AVFormatContext.max_index_size, by discarding entries if it grows
>> + * too large.
>> + */
>> +void ff_reduce_index(AVFormatContext *s, int stream_index);
>
> this needs at least a note that it is not part of the public API
Added.
>> +/**
>> * Add a index entry into a sorted list updateing if it is already there.
>> *
>> * @param timestamp timestamp in the timebase of the given stream
>> Index: libavformat/utils.c
>> ===================================================================
>> --- libavformat/utils.c (revision 11518)
>> +++ libavformat/utils.c (working copy)
>> @@ -324,6 +324,7 @@
>> {"year", "set the year", OFFSET(year), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, E},
>> {"analyzeduration", "how many microseconds are analyzed to estimate duration", OFFSET(max_analyze_duration), FF_OPT_TYPE_INT, 3*AV_TIME_BASE, 0, INT_MAX, D},
>> {"cryptokey", "decryption key", OFFSET(key), FF_OPT_TYPE_BINARY, 0, 0, 0, D},
>> +{"maxindexsize", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), FF_OPT_TYPE_INT, INT_MAX, 0, INT_MAX, D},
>
> i would prefer a shorter name, maybe "maxindex"
I had a think about it and decided on "indexsize" - is that OK? I thought
it was consistent with "analyzeduration", where the actual variable also
has a max_ prefix, and also with "probesize" in the meaning of the word
"size".
> [...]
>> + int in, out= 0;
>> + /* Halve the size of the index by removing every second entry */
>> + for(in=0; in<st->nb_index_entries; in+= 2)
>> + st->index_entries[out++]= st->index_entries[in];
>> + st->nb_index_entries= out;
>
> int i;
> for(i=0; 2*i<st->nb_index_entries; i++)
> st->index_entries[i]= st->index_entries[2*i];
> st->nb_index_entries= i;
Changed also. Why is it better? Multiplication by 2 can be optimised?
Paul
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ff_reduce_index3.patch
Type: text/x-diff
Size: 3710 bytes
Desc:
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080113/4a1e41d9/attachment.patch>
More information about the ffmpeg-devel
mailing list