[FFmpeg-devel] MPEG-PS demuxer index memory usage
Paul Kelly
paul
Sat Jan 5 18:14:21 CET 2008
On Sat, 5 Jan 2008, Michael Niedermayer wrote:
>> OK, first attempt at a patch is attached. Is the general idea OK? I'm not
>> sure where the check for !url_is_streamed() should go so I haven't included
>> it - possibly in av_new_stream()?
>>
>> Paul
>
>> Index: libavformat/avformat.h
>> ===================================================================
>> --- libavformat/avformat.h (revision 11408)
>> +++ libavformat/avformat.h (working copy)
>> @@ -342,6 +342,7 @@
>> support seeking natively */
>> int nb_index_entries;
>> unsigned int index_entries_allocated_size;
>> + unsigned int max_index_size; /**< max memory to use for index when demuxing */
>>
>> int64_t nb_frames; ///< number of frames in this stream if known or 0
>>
>
> /**
> * Stream structure.
> * New fields can be added to the end with minor version bumps.
> ^^^
> * Removal, reordering and changes to existing fields require a major
> * version bump.
> * sizeof(AVStream) must not be used outside libav*.
> */
> typedef struct AVStream {
>
> also iam slightly thinking that this would belong more to AVFormatContext
> or what is the use case of having max_index_size differ between streams
> and the user should be able to set it from the command line
> if it were in AVFormatContext you only would have to add a single line to
> the AVOption array in libavformat/utils.c
Ok I understand now about the AVOption array - it's a very neat idea and I
agree adding it there and putting max_index_size in AVFormatContext is a
more logical and elegant solution than putting it in AVStream.
BUT.. as far as I can see there would then be no way of accessing it in
av_add_index_entry(), because only an AVStream is passed to it. Am I right
that there is no way to access the "parent" AVFormatContext of an AVStream
struct?
If that's the case then the only way I can see that having it in
AVFormatContext would work would be to rewrite av_add_index_entry() to
take a pointer to an AVFormatContext, and change everywhere it is called
in all the demuxers - and if that was being done it might even be worth
considering whether there even needs to be a per-stream index and could
the index stuff be moved to AVFormatContext... certainly a lot more work
than I have time for - I just need to get a simple fix accepted to limit
the index size!
Thus I'm attaching a revised version of the original patch for
consideration. Changes since the last patch are:
* Add new member to the end of AVStream and increase minor version number
* Avoid unnecessary use of memmove()
* Change the if condition (a+1)>b to a>=b as it's faster I think?
I guess it's still not complete though, as if we do it this way then we
should add a way of accessing the new functionality as a command-line
option in ffmpeg. Am I right in thinking that it involves something in
AVFormatParameters? ffmpeg.c is a bit impenetrable to me though; I'm not
sure if I can take this any further.
Best regards,
Paul
-------------- next part --------------
A non-text attachment was scrubbed...
Name: max_index_size.diff
Type: text/x-diff
Size: 1998 bytes
Desc:
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080105/c30d5ba4/attachment.diff>
More information about the ffmpeg-devel
mailing list