[PATCH] estimate stream durations using read_timestamp
Hi, Here is a patch for libavformat to estimate stream durations using the read_timestamp interface. This could most likely replace the special casing for mpeg using read_packet. Thou i've not yet checked that. Joakim Ps. Patch probably applies at an offset, but it's not against latest svn. Will resend with that after inital comments.
elupus wrote:
Hi,
Here is a patch for libavformat to estimate stream durations using the read_timestamp interface. This could most likely replace the special casing for mpeg using read_packet. Thou i've not yet checked that.
Joakim
Ps. Patch probably applies at an offset, but it's not against latest svn. Will resend with that after inital comments.
Patch applied. MvH Benjamin Larsson
On Sat, 24 May 2008 13:00:53 +0200, elupus wrote:
Hi,
Here is a patch for libavformat to estimate stream durations using the read_timestamp interface. This could most likely replace the special casing for mpeg using read_packet. Thou i've not yet checked that.
Joakim
Ps. Patch probably applies at an offset, but it's not against latest svn. Will resend with that after inital comments.
One would think you wouldn't do the same thing twice in one hour. Sigh.. Joakim
On Sat, May 24, 2008 at 01:04:24PM +0200, elupus wrote:
On Sat, 24 May 2008 13:00:53 +0200, elupus wrote:
Hi,
Here is a patch for libavformat to estimate stream durations using the read_timestamp interface. This could most likely replace the special casing for mpeg using read_packet. Thou i've not yet checked that.
your code is a duplicate of av_estimate_timings_from_pts(). One of the 2 has to be removed or you will have to explain why both are usefull. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Concerning the gods, I have no means of knowing whether they exist or not or of what sort they may be, because of the obscurity of the subject, and the brevity of human life -- Protagoras
On Sat, 24 May 2008 14:15:23 +0200, Michael Niedermayer wrote:
On Sat, May 24, 2008 at 01:04:24PM +0200, elupus wrote:
On Sat, 24 May 2008 13:00:53 +0200, elupus wrote:
Hi,
Here is a patch for libavformat to estimate stream durations using the read_timestamp interface. This could most likely replace the special casing for mpeg using read_packet. Thou i've not yet checked that.
your code is a duplicate of av_estimate_timings_from_pts(). One of the 2 has to be removed or you will have to explain why both are usefull.
[...]
Agreed, the new function doesn't use as you put it "undefined behavior" (in the nuv thread) of seeking the input stream somewhere and expecting read_packet to work. Thus it is more general. Then again, it does have to read each stream since read_timestamp is stream specific. Current code would read whole file if a stream doesn't contain one of the stream. Should be fixable with a check for DURATION_MAX_READ_SIZE in it too. Will fix that, remove the old function and test it with some mpegs and see that it doesn't seem to break anything. Joakim
On Sat, May 24, 2008 at 02:28:09PM +0200, elupus wrote:
On Sat, 24 May 2008 14:15:23 +0200, Michael Niedermayer wrote:
On Sat, May 24, 2008 at 01:04:24PM +0200, elupus wrote:
On Sat, 24 May 2008 13:00:53 +0200, elupus wrote:
Hi,
Here is a patch for libavformat to estimate stream durations using the read_timestamp interface. This could most likely replace the special casing for mpeg using read_packet. Thou i've not yet checked that.
your code is a duplicate of av_estimate_timings_from_pts(). One of the 2 has to be removed or you will have to explain why both are usefull.
[...]
Agreed, the new function doesn't use as you put it "undefined behavior" (in the nuv thread) of seeking the input stream somewhere and expecting read_packet to work. Thus it is more general.
Its undefined behavior from the user application. Its not undefined from libavformat. After all demuxers themselfs can also use url_fseek().
Then again, it does have to read each stream since read_timestamp is stream specific. Current code would read whole file if a stream doesn't contain one of the stream. Should be fixable with a check for DURATION_MAX_READ_SIZE in it too.
Will fix that, remove the old function and test it with some mpegs and see that it doesn't seem to break anything.
We also would need benchmarks to see what effect the change has on speed, especially with files with many streams (mpeg ts with 20 streams has to be not slower ...) [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Republics decline into democracies and democracies degenerate into despotisms. -- Aristotle
We also would need benchmarks to see what effect the change has on speed, especially with files with many streams (mpeg ts with 20 streams has to be not slower ...)
[...]
Well given that it most likely will be alot slower, do you have any suggestion as how to proceed? We could keep the old code for mpegs, but as you say then there will be code duplication. Another option could be to change read_timestamp to allow a stream_index parameter of -1, meaning return the first timestamp you come across, independent of stream. This would be a quite abit larger patch thou as all read_timestamp functions must be updated too support this. In either case, here is an updated patch that ditches the old code. Joakim
On Sun, May 25, 2008 at 07:59:39PM +0200, elupus wrote:
We also would need benchmarks to see what effect the change has on speed, especially with files with many streams (mpeg ts with 20 streams has to be not slower ...)
[...]
Well given that it most likely will be alot slower, do you have any suggestion as how to proceed? We could keep the old code for mpegs, but as you say then there will be code duplication.
Another option could be to change read_timestamp to allow a stream_index parameter of -1, meaning return the first timestamp you come across, independent of stream. This would be a quite abit larger patch thou as all read_timestamp functions must be updated too support this.
i think this would be interresting, also its not needed to support in every demuxer at once they could be updated one by one [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I know you won't believe me, but the highest form of Human Excellence is to question oneself and others. -- Socrates
participants (3)
-
banan@ludd.ltu.se -
elupus@ecce.se -
michaelni@gmx.at