[PATCH] support for ordered chapters/segment linking in Matroska
Sorry for thread-breaking. Some opinions in this patch: it seems to differ a bit from the "de-facto" behavior of Haali Media Splitter (the only existing implementation). I think it'd be desirable to play along the same way, specially considering this makes things much simpler implementation-wise and I think mostly addresses Michael's comments. In Haali, to accept a segment, TrackType and CodecID must match exactly, for all tracks, in the same order. Everything else is fair game. The values from the "master" segment are used and the ones from the linked segments discarded. This includes CodecPrivate, TrackVideo's childern, TrackAudio's children, etc... Needless to say, the demuxer doesn't handle the case of changing stream parameters: it just passes the frames to the decoder, and doesn't care for anything else. IMHO this is sufficient and even desirable.
On Sun, Aug 10, 2008 at 04:55:20PM +0200, John B wrote:
Sorry for thread-breaking. Some opinions in this patch: it seems to differ a bit from the "de-facto" behavior of Haali Media Splitter (the only existing implementation). I think it'd be desirable to play along the same way, specially considering this makes things much simpler implementation-wise and I think mostly addresses Michael's comments.
In Haali, to accept a segment, TrackType and CodecID must match exactly, for all tracks, in the same order. Everything else is fair game. The values from the "master" segment are used and the ones from the linked segments discarded. This includes CodecPrivate, TrackVideo's childern, TrackAudio's children, etc...
Needless to say, the demuxer doesn't handle the case of changing stream parameters: it just passes the frames to the decoder, and doesn't care for anything else. IMHO this is sufficient and even desirable.
yes, agree, thats the simplest sane way to handle it [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB While the State exists there can be no freedom; when there is freedom there will be no State. -- Vladimir Lenin
Michael Niedermayer wrote:
On Sun, Aug 10, 2008 at 04:55:20PM +0200, John B wrote:
Sorry for thread-breaking. Some opinions in this patch: it seems to differ a bit from the "de-facto" behavior of Haali Media Splitter (the only existing implementation). I think it'd be desirable to play along the same way, specially considering this makes things much simpler implementation-wise and I think mostly addresses Michael's comments.
In Haali, to accept a segment, TrackType and CodecID must match exactly, for all tracks, in the same order. Everything else is fair game. The values from the "master" segment are used and the ones from the linked segments discarded. This includes CodecPrivate, TrackVideo's childern, TrackAudio's children, etc...
Needless to say, the demuxer doesn't handle the case of changing stream parameters: it just passes the frames to the decoder, and doesn't care for anything else. IMHO this is sufficient and even desirable.
yes, agree, thats the simplest sane way to handle it
I agree too. That should be plenty enough for now. If some samples appears later, that require more than this, then it will be a good time to start investigating more complex solutions (but I doubt this will ever happen). Aurel
On Mon, Aug 11, 2008 at 1:52 AM, Aurelien Jacobs <aurel at gnuage.org> wrote:
Michael Niedermayer wrote:
On Sun, Aug 10, 2008 at 04:55:20PM +0200, John B wrote:
Sorry for thread-breaking. Some opinions in this patch: it seems to differ a bit from the "de-facto" behavior of Haali Media Splitter (the only existing implementation). I think it'd be desirable to play along the same way, specially considering this makes things much simpler implementation-wise and I think mostly addresses Michael's comments.
In Haali, to accept a segment, TrackType and CodecID must match exactly, for all tracks, in the same order. Everything else is fair game. The values from the "master" segment are used and the ones from the linked segments discarded. This includes CodecPrivate, TrackVideo's childern, TrackAudio's children, etc...
Needless to say, the demuxer doesn't handle the case of changing stream parameters: it just passes the frames to the decoder, and doesn't care for anything else. IMHO this is sufficient and even desirable.
yes, agree, thats the simplest sane way to handle it
I agree too. That should be plenty enough for now.
If some samples appears later, that require more than this, then it will be a good time to start investigating more complex solutions (but I doubt this will ever happen).
Aurel
Actually compatibility with Haali's splitter was what I was aiming for, but the problem is that there are linked files out there with slightly different parameters, so mkvmerge will refuse to merge them and you'll get crap if you try to decode them with one decoder. But Haali's splitter will play them just fine. Of course we can just ignore these, I'll make the patch reject files with different CodecPrivate and everyone will be happy. Is that ok with you? Anton
On Mon, 2008-08-11 at 05:36 +0200, Anton Khirnov wrote:
Actually compatibility with Haali's splitter was what I was aiming for, but the problem is that there are linked files out there with slightly different parameters, so mkvmerge will refuse to merge them and you'll get crap if you try to decode them with one decoder. But Haali's splitter will play them just fine.
I thought that if these were implemented in MPlayer that could be done at a somewhat higher level, as a part of playlist / edit decision list support. Currently playlists only work at file level and EDL within a file, but they could be generalized so that you could make a timeline consisting of parts from multiple files.
On Mon, Aug 11, 2008 at 5:36 AM, Anton Khirnov <wyskas at gmail.com> wrote:
Actually compatibility with Haali's splitter was what I was aiming for, but the problem is that there are linked files out there with slightly different parameters, so mkvmerge will refuse to merge them and you'll get crap if you try to decode them with one decoder. But Haali's splitter will play them just fine.
Of course we can just ignore these, I'll make the patch reject files with different CodecPrivate and everyone will be happy. Is that ok with you?
Anton
Did you try to do it without all the switching machinery and it didn't work? Can you provide sample file(s)? Keep in mind that some encoders generate varying CodecPrivates even when using the same encoding settings (I think Vorbis did this). If I'm not mistaken, checking for matching CodecPrivate would break all files with Vorbis audio.
On Mon, Aug 11, 2008 at 6:14 AM, John B <jbfaad at gmail.com> wrote:
On Mon, Aug 11, 2008 at 5:36 AM, Anton Khirnov <wyskas at gmail.com> wrote:
Actually compatibility with Haali's splitter was what I was aiming for, but the problem is that there are linked files out there with slightly different parameters, so mkvmerge will refuse to merge them and you'll get crap if you try to decode them with one decoder. But Haali's splitter will play them just fine.
Of course we can just ignore these, I'll make the patch reject files with different CodecPrivate and everyone will be happy. Is that ok with you?
Anton
Did you try to do it without all the switching machinery and it didn't work? Can you provide sample file(s)?
There is NO switching machinery in the patch. It just notifies the calling app about segment switch, that's all. As for samples, you can try [BSS] Kurenai, eps 6+ or [Formula] Shugo Chara, eps 14+.
I thought that if these were implemented in MPlayer that could be done at a somewhat higher level, as a part of playlist / edit decision list support. Currently playlists only work at file level and EDL within a file, but they could be generalized so that you could make a timeline consisting of parts from multiple files.
But that would benefit MPlayer only, while support in FFmpeg could be used in MPlayer, VLC and everything that uses lavf. Anton
On Mon, Aug 11, 2008 at 6:58 AM, Anton Khirnov <wyskas at gmail.com> wrote:
As for samples, you can try [BSS] Kurenai, eps 6+ or [Formula] Shugo Chara, eps 14+.
Ahh, I see. These people used different settings (different bitrate) for Vorbis audio, which indeed results in garbled output. I did not expect that to work in DirectShow either, but it does, albeit barely (a lot of Vorbis decoder filters did output garbage or hung). It also makes remuxing impossible (if you force it, the resulting file will have garbled segments with any decoder), which is kind of a deal-breaker for ffmpeg I guess. I'm not sure what would be a solution here. Keep in mind that different CodecPrivate does not necessarily mean corrupted output: in the particular case of Vorbis CodecPrivate tends to vary even if the same settings are used, but it's still possible to mix the streams without problems. I'd say for now a warning is enough.
On Tue, Aug 12, 2008 at 3:49 PM, John B <jbfaad at gmail.com> wrote:
Keep in mind that different CodecPrivate does not necessarily mean corrupted output: in the particular case of Vorbis CodecPrivate tends to vary even if the same settings are used, but it's still possible to mix the streams without problems. I'd say for now a warning is enough.
I've based my stream compatibilty check on mkvmerge's code for appending files, and it seems to work quite well - files that didn't work before are skipped and files that worked still do :)
Sorry for the spam, but I took a look at the appropriate places and I think this *might* be possible, and also give ffmpeg a nice feature (concatenation of Vorbis streams) in the process. Vorbis has 3 header packets for setup. The first one has a few critical values that must match (samplerate, channels and both blocksizes [window sizes] - incidentally, mkvmerge doesn't check blocksizes). The 2nd header is metadata and isn't needed for decoding. The third is the setup header and is where things turn interesting - it includes a number of (VLC) codebooks, (spectral) floors, residues, (channel) mappings and finally modes. A mode references a block size and a mapping, which references floors and residues, which reference codeblocks. Every audio packet has a single bit header (a 0) followed as few bits as possible [ilog(modes)] to select a mode number for decoding, and then comes the actual packet data. The idea here is that you can theoretically build a codec setup header that contains all setups from all the concatenated segments. This would increase the size of every individual audio packet an average of log2(n) bits, where n is the total number of setups you're merging. You'd have to modify the audio packets to point to the correct setup. A more refined implementation would try to re-use matching modes whenever possible. This still isn't infallible since there are limits on the number of stuff that can fit in there. Blocksizes must match, the official encoder and aoTuV, at 44100/48000Hz, use 512/4096 window sizes for qualities < 0 (~ bitrates < 64Kbps), and 256/2048 for everything else, which is somewhat good news. There are limits of 257 codebooks, 65 floors, 65 residues, 65 mappings and 65 modes. I don't know how many of them are usually used by a single stream, maybe somebody can comment on this to see if it's feasible. Also, maybe I've missed other limitations that make this impossible. Just so you know, in case you get really bored :)
On Wed, Aug 13, 2008 at 12:17:50AM +0200, John B wrote:
Sorry for the spam, but I took a look at the appropriate places and I think this *might* be possible, and also give ffmpeg a nice feature (concatenation of Vorbis streams) in the process.
Vorbis has 3 header packets for setup. The first one has a few critical values that must match (samplerate, channels and both blocksizes [window sizes] - incidentally, mkvmerge doesn't check blocksizes). The 2nd header is metadata and isn't needed for decoding.
The third is the setup header and is where things turn interesting - it includes a number of (VLC) codebooks, (spectral) floors, residues, (channel) mappings and finally modes. A mode references a block size and a mapping, which references floors and residues, which reference codeblocks.
Every audio packet has a single bit header (a 0) followed as few bits as possible [ilog(modes)] to select a mode number for decoding, and then comes the actual packet data.
The idea here is that you can theoretically build a codec setup header that contains all setups from all the concatenated segments. This would increase the size of every individual audio packet an average of log2(n) bits, where n is the total number of setups you're merging. You'd have to modify the audio packets to point to the correct setup. A more refined implementation would try to re-use matching modes whenever possible.
insanity ... If you want to concatenate use a codec that supports it, mp3, ac3 and aac likely do. vorbis does not unless all 3 headers match exactly. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Complexity theory is the science of finding the exact solution to an approximation. Benchmarking OTOH is finding an approximation of the exact
i've reworked the design and added a compatibility check. looking any better now?
ping?
On Sat, Aug 23, 2008 at 05:50:23PM +0200, Anton Khirnov wrote:
ping?
Index: libavformat/avformat.h =================================================================== --- libavformat/avformat.h (revision 14918) +++ libavformat/avformat.h (working copy) @@ -22,7 +22,7 @@ #define FFMPEG_AVFORMAT_H
#define LIBAVFORMAT_VERSION_MAJOR 52 -#define LIBAVFORMAT_VERSION_MINOR 20 +#define LIBAVFORMAT_VERSION_MINOR 21 #define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
@@ -176,6 +176,8 @@ enum CodecID video_codec_id; enum CodecID audio_codec_id; #endif + /**< Will automatically load linked segments for matroska files.*/ + int matroska_load_linked_segments; } AVFormatParameters;
AVFormatParameters is deprecated and i do not want to have more stuff added to it
//! demuxer will use url_fopen, no opened file should be provided by the caller @@ -424,12 +426,15 @@
#define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present (streams are added dynamically) */ +#define AVFMTCTX_VIRTUAL 0x0010 /** this context is an abstraction over + several other contexts */
I think this needs some explanation of what it means when its used why it is needed besides 0x0010 is not the next available flag
typedef struct AVChapter { int id; ///< Unique id to identify the chapter AVRational time_base; ///< Timebase in which the start/end timestamps are specified int64_t start, end; ///< chapter start/end time in time_base units char *title; ///< chapter title + void *priv_data; ///< demuxer-specific data } AVChapter;
#define MAX_STREAMS 20
Thats a seperate change as well that has little to do with the rest. Each single API change should be seperately discussed and justified Iam not opposed to any of these changes at the current point, iam just missing a little bit of explanations why that way and not another and if it would be sufficient for other cases like mov, smil, ... as well [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The educated differ from the uneducated as much as the living from the dead. -- Aristotle
On Sat, Aug 23, 2008 at 9:01 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Sat, Aug 23, 2008 at 05:50:23PM +0200, Anton Khirnov wrote:
ping?
Index: libavformat/avformat.h =================================================================== --- libavformat/avformat.h (revision 14918) +++ libavformat/avformat.h (working copy) @@ -22,7 +22,7 @@ #define FFMPEG_AVFORMAT_H
#define LIBAVFORMAT_VERSION_MAJOR 52 -#define LIBAVFORMAT_VERSION_MINOR 20 +#define LIBAVFORMAT_VERSION_MINOR 21 #define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
@@ -176,6 +176,8 @@ enum CodecID video_codec_id; enum CodecID audio_codec_id; #endif + /**< Will automatically load linked segments for matroska files.*/ + int matroska_load_linked_segments; } AVFormatParameters;
AVFormatParameters is deprecated and i do not want to have more stuff added to it
It's not marked as deprecated (or i'm missing something). Then what would be the correct place for this?
//! demuxer will use url_fopen, no opened file should be provided by the caller @@ -424,12 +426,15 @@
#define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present (streams are added dynamically) */ +#define AVFMTCTX_VIRTUAL 0x0010 /** this context is an abstraction over + several other contexts */
I think this needs some explanation of what it means when its used why it is needed
besides 0x0010 is not the next available flag
i imagine it will work like this: demuxer autoloads some external streams -> creates a AVFormatContext marked with this flag, that can be used to access all these streams in the way they are meant to be played -> add the virtual context and all the real contexts to external_ctx array in the main AVFormatContext -> the client app a) select the virtual context and uses it instead of the main one b) chooses to access these external streams directly c) ignores it ->
typedef struct AVChapter { int id; ///< Unique id to identify the chapter AVRational time_base; ///< Timebase in which the start/end timestamps are specified int64_t start, end; ///< chapter start/end time in time_base units char *title; ///< chapter title + void *priv_data; ///< demuxer-specific data } AVChapter;
#define MAX_STREAMS 20
Thats a seperate change as well that has little to do with the rest.
ok, i'll separate it. if you're asking why do we need private data for chapters, it's because segment linking in matroska is done through chapters.
Each single API change should be seperately discussed and justified Iam not opposed to any of these changes at the current point, iam just missing a little bit of explanations why that way and not another and if it would be sufficient for other cases like mov, smil, ... as well
i'm not familiar with smil or mov way of file linking, but from what i read about them this should be usable. Anton
On Sun, Aug 24, 2008 at 07:44:31AM +0200, Anton Khirnov wrote:
On Sat, Aug 23, 2008 at 9:01 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Sat, Aug 23, 2008 at 05:50:23PM +0200, Anton Khirnov wrote:
ping?
Index: libavformat/avformat.h =================================================================== --- libavformat/avformat.h (revision 14918) +++ libavformat/avformat.h (working copy) @@ -22,7 +22,7 @@ #define FFMPEG_AVFORMAT_H
#define LIBAVFORMAT_VERSION_MAJOR 52 -#define LIBAVFORMAT_VERSION_MINOR 20 +#define LIBAVFORMAT_VERSION_MINOR 21 #define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
@@ -176,6 +176,8 @@ enum CodecID video_codec_id; enum CodecID audio_codec_id; #endif + /**< Will automatically load linked segments for matroska files.*/ + int matroska_load_linked_segments; } AVFormatParameters;
AVFormatParameters is deprecated and i do not want to have more stuff added to it
It's not marked as deprecated (or i'm missing something). Then what would be the correct place for this?
matroska_* should be in matroska*.c :) a AVFMT_FLAG_IGN_EXTERNS similar to AVFMT_FLAG_IGNIDX would probably be ok if that makes sense, als it could be used for mov.
//! demuxer will use url_fopen, no opened file should be provided by the caller @@ -424,12 +426,15 @@
#define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present (streams are added dynamically) */ +#define AVFMTCTX_VIRTUAL 0x0010 /** this context is an abstraction over + several other contexts */
I think this needs some explanation of what it means when its used why it is needed
besides 0x0010 is not the next available flag
i imagine it will work like this: demuxer autoloads some external streams -> creates a AVFormatContext marked with this flag, that can be used to access all these streams in the way they are meant to be played -> add the virtual context and all the real contexts to external_ctx array in the main AVFormatContext -> the client app a) select the virtual context and uses it instead of the main one b) chooses to access these external streams directly c) ignores it ->
Iam not against providing access to the external AVFormatContext if there is some use in doing so. But the rest looks a little unclean to me ... I mean either a container contains A. a single sequential timeline that should be sequentially played (possibly with redundant streams in different languages, commentary... ; chapters, ...) B. several alternatives the user can choose from one way or another If A then the main AVFormatContext should represent this single sequential timeline no matter if its in a single file or not. If B then we need some API that is generic enough to handle it, a single additional virtual AVFormatContext probably isnt
typedef struct AVChapter { int id; ///< Unique id to identify the chapter AVRational time_base; ///< Timebase in which the start/end timestamps are specified int64_t start, end; ///< chapter start/end time in time_base units char *title; ///< chapter title + void *priv_data; ///< demuxer-specific data } AVChapter;
#define MAX_STREAMS 20
Thats a seperate change as well that has little to do with the rest.
ok, i'll separate it. if you're asking why do we need private data for chapters, it's because segment linking in matroska is done through chapters.
if the matroska maintainer agrees that priv_data in AVChapter is usefull then iam ok with it [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB There will always be a question for which you do not know the correct awnser.
Michael Niedermayer wrote:
On Sun, Aug 24, 2008 at 07:44:31AM +0200, Anton Khirnov wrote:
On Sat, Aug 23, 2008 at 9:01 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Sat, Aug 23, 2008 at 05:50:23PM +0200, Anton Khirnov wrote:
typedef struct AVChapter { int id; ///< Unique id to identify the chapter AVRational time_base; ///< Timebase in which the start/end timestamps are specified int64_t start, end; ///< chapter start/end time in time_base units char *title; ///< chapter title + void *priv_data; ///< demuxer-specific data } AVChapter;
#define MAX_STREAMS 20
Thats a seperate change as well that has little to do with the rest.
ok, i'll separate it. if you're asking why do we need private data for chapters, it's because segment linking in matroska is done through chapters.
if the matroska maintainer agrees that priv_data in AVChapter is usefull then iam ok with it
No I don't. The matroska demuxer already has it's own private chapter struct and chapter list. Any chapter related private data can be stored here. There are many more things I don't like in this patch. One of them being that the demuxer try to parse a directory and open files itself. I think the demuxer should only deal with ByteIOContext that the generic framework (utils.c) passes to it. That's up to the generic framework to find and open files (or network streams of whatever...). That could also be useful for other demuxer. I will try to have a deeper look at it in the next few days, but a potential idea would be: 1) the demuxer set AVFormatContext.flags |= AVFMT_FLAG_LINKED 2) utils.c check this flag and search for potential linked files, open them with av_open_input_file() and then pass the resulting context to the demuxer of step 1, by the mean of a new AVInputFormat.check_linked() function. 3) the check_linked() function of the demuxer verify if this new context is the linked one we are searching for, and return the result of this check 4) utils.c can then build a composite AVFormatContext containing all the context linked to the original file 5) utils.c can abstract this composite context as if it was a real context, reading or seeking in the appropriate segment Well, that's just a rough idea. I don't know if this could fit demuxers other than matroska. And I need to give it a deeper look to check if it's feasible. Aurel
cdOn Sun, Aug 24, 2008 at 06:15:58PM +0200, Aurelien Jacobs wrote: [...]
Well, that's just a rough idea. I don't know if this could fit demuxers other than matroska.
also see mov.c, i want both matroska and mov to use the same system no matter what system that may be. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB There will always be a question for which you do not know the correct awnser.
On Sun, Aug 24, 2008 at 5:36 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
matroska_* should be in matroska*.c :)
a AVFMT_FLAG_IGN_EXTERNS similar to AVFMT_FLAG_IGNIDX would probably be ok if that makes sense, als it could be used for mov.
well these flags can't be set until after av_open_input_stream, can they. On Sun, Aug 24, 2008 at 6:15 PM, Aurelien Jacobs <aurel at gnuage.org> wrote:
No I don't. The matroska demuxer already has it's own private chapter struct and chapter list. Any chapter related private data can be stored here.
you're right, now that i look at it, it's just a relic from ancient times before you rewrote matroska demuxer :) i'll remove it. On Sun, Aug 24, 2008 at 6:15 PM, Aurelien Jacobs <aurel at gnuage.org> wrote:
There are many more things I don't like in this patch. One of them being that the demuxer try to parse a directory and open files itself. I think the demuxer should only deal with ByteIOContext that the generic framework (utils.c) passes to it. That's up to the generic framework to find and open files (or network streams of whatever...). That could also be useful for other demuxer.
I will try to have a deeper look at it in the next few days, but a potential idea would be:
1) the demuxer set AVFormatContext.flags |= AVFMT_FLAG_LINKED 2) utils.c check this flag and search for potential linked files, open them with av_open_input_file() and then pass the resulting context to the demuxer of step 1, by the mean of a new AVInputFormat.check_linked() function. 3) the check_linked() function of the demuxer verify if this new context is the linked one we are searching for, and return the result of this check 4) utils.c can then build a composite AVFormatContext containing all the context linked to the original file 5) utils.c can abstract this composite context as if it was a real context, reading or seeking in the appropriate segment
i don't think just a flag will be enough, demuxer should give some more hints about where to search for linked streams and what kinds of formats/extensions it wants etc. how do you like the attached version? Anton
ping - a reworked version. Anton
ping
On Fri, 17 Oct 2008 22:57:54 +0200 "Anton Khirnov" <wyskas at gmail.com> wrote:
ping - a reworked version.
Only a quick review for now.
[...] +static int av_load_external_streams(AVFormatContext *s) +{ [...] + if(!(dir = opendir(dirname))) + av_log(s, AV_LOG_ERROR, "Error opening directory %s\n.", dirname); + else { + av_log(s, AV_LOG_DEBUG, "Looking for linked files in %s.\n", dirname); + while((file = readdir(dir))) {
Using opendir() / readdir() directly here is ugly and won't ever work for non-local files. Another idea would be to add some kind of opendir/readdir operations in avio, working with URLContext. Those operations would only need to be implemented for local files for now, but could also be implemented for http or any other kind of protocol in the future.
+static int +matroska_check_linked_tracks(MatroskaTrack *track, MatroskaTrack *track2) +{ + if(strcmp(track->codec_id, track2->codec_id)) + return -1; + if(track->type == MATROSKA_TRACK_TYPE_VIDEO) { + if(track->video.pixel_width != track2->video.pixel_width || + track->video.pixel_height != track2->video.pixel_height || + track->codec_priv.size != track2->codec_priv.size) + return -1; + } + else if(track->type == MATROSKA_TRACK_TYPE_AUDIO) { + if(track->audio.channels != track2->audio.channels || + track->audio.out_samplerate != track2->audio.out_samplerate) + return -1; + if(strstr(track->codec_id, "A_AAC") || + strcmp(track->codec_id, "A_AC3") || + strcmp(track->codec_id, "A_VORBIS") || + strcmp(track->codec_id, "A_DTS") || + strstr(track->codec_id, "A_MPEG")) + if(track->audio.bitdepth != track2->audio.bitdepth) + return -1; + if(strstr(track->codec_id, "A_AAC")) + if(matroska_aac_profile(track->codec_id) != matroska_aac_profile(track2->codec_id)) + return -1; + if(!strcmp(track->codec_id, "A_FLAC") && + memcmp(track->codec_priv.data, track2->codec_priv.data, track->codec_priv.size)) + return -1; + if(!strcmp(track->codec_id, "A_VORBIS")) { + uint8_t *header_start[3], *header_start2[3]; + int header_len[3], header_len2[3]; + + if(ff_split_xiph_headers(track->codec_priv.data, track->codec_priv.size, + 30, header_start, header_len) < 0 || + ff_split_xiph_headers(track2->codec_priv.data, track2->codec_priv.size, + 30, header_start2, header_len2) < 0) + return -1; + if(header_len[0] != header_len2[0] || header_len[2] != header_len2[2]) + return -1; + if(memcmp(header_start[0], header_start2[0], header_len[0]) || + memcmp(header_start[2], header_start2[2], header_len[2])) + return -1; + } + } + return 0; +}
I guess this stream compatibility check could be done in a non-matroska specific way, and be moved as a generic function in utils.c.
+AVInputFormat matroska_demuxer_ordered = { + "matroska", + NULL_IF_CONFIG_SMALL("Matroska file format"), + sizeof(MatroskaDemuxContext), + matroska_probe, + matroska_read_header, + matroska_read_packet_ordered, + matroska_read_close, + matroska_read_seek_ordered, +};
I think you could avoid this new AVInputFormat entirely. You could have only one set of read_packet/read_seek functions which would work in both linked/non-linked cases. Aurel
On Mon, Oct 27, 2008 at 04:33:44PM +0100, Aurelien Jacobs wrote:
On Fri, 17 Oct 2008 22:57:54 +0200 "Anton Khirnov" <wyskas at gmail.com> wrote:
ping - a reworked version.
Only a quick review for now.
[...] +static int av_load_external_streams(AVFormatContext *s) +{ [...] + if(!(dir = opendir(dirname))) + av_log(s, AV_LOG_ERROR, "Error opening directory %s\n.", dirname); + else { + av_log(s, AV_LOG_DEBUG, "Looking for linked files in %s.\n", dirname); + while((file = readdir(dir))) {
Using opendir() / readdir() directly here is ugly and won't ever work for non-local files. Another idea would be to add some kind of opendir/readdir operations in avio, working with URLContext. Those operations would only need to be implemented for local files for now, but could also be implemented for http or any other kind of protocol in the future.
this could be done, though it will only work when the server allows directoty listings and our code manages to parse what it returns ... [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Old school: Use the lowest level language in which you can solve the problem conveniently. New school: Use the highest level language in which the latest supercomputer can solve the problem without the user falling asleep waiting.
On Mon, Oct 27, 2008 at 4:33 PM, Aurelien Jacobs <aurel at gnuage.org> wrote:
On Fri, 17 Oct 2008 22:57:54 +0200 "Anton Khirnov" <wyskas at gmail.com> wrote:
ping - a reworked version.
Only a quick review for now.
[...] +static int av_load_external_streams(AVFormatContext *s) +{ [...] + if(!(dir = opendir(dirname))) + av_log(s, AV_LOG_ERROR, "Error opening directory %s\n.", dirname); + else { + av_log(s, AV_LOG_DEBUG, "Looking for linked files in %s.\n", dirname); + while((file = readdir(dir))) {
Using opendir() / readdir() directly here is ugly and won't ever work for non-local files. Another idea would be to add some kind of opendir/readdir operations in avio, working with URLContext. Those operations would only need to be implemented for local files for now, but could also be implemented for http or any other kind of protocol in the future.
done
+static int +matroska_check_linked_tracks(MatroskaTrack *track, MatroskaTrack *track2) +{ + if(strcmp(track->codec_id, track2->codec_id)) + return -1; + if(track->type == MATROSKA_TRACK_TYPE_VIDEO) { + if(track->video.pixel_width != track2->video.pixel_width || + track->video.pixel_height != track2->video.pixel_height || + track->codec_priv.size != track2->codec_priv.size) + return -1; + } + else if(track->type == MATROSKA_TRACK_TYPE_AUDIO) { + if(track->audio.channels != track2->audio.channels || + track->audio.out_samplerate != track2->audio.out_samplerate) + return -1; + if(strstr(track->codec_id, "A_AAC") || + strcmp(track->codec_id, "A_AC3") || + strcmp(track->codec_id, "A_VORBIS") || + strcmp(track->codec_id, "A_DTS") || + strstr(track->codec_id, "A_MPEG")) + if(track->audio.bitdepth != track2->audio.bitdepth) + return -1; + if(strstr(track->codec_id, "A_AAC")) + if(matroska_aac_profile(track->codec_id) != matroska_aac_profile(track2->codec_id)) + return -1; + if(!strcmp(track->codec_id, "A_FLAC") && + memcmp(track->codec_priv.data, track2->codec_priv.data, track->codec_priv.size)) + return -1; + if(!strcmp(track->codec_id, "A_VORBIS")) { + uint8_t *header_start[3], *header_start2[3]; + int header_len[3], header_len2[3]; + + if(ff_split_xiph_headers(track->codec_priv.data, track->codec_priv.size, + 30, header_start, header_len) < 0 || + ff_split_xiph_headers(track2->codec_priv.data, track2->codec_priv.size, + 30, header_start2, header_len2) < 0) + return -1; + if(header_len[0] != header_len2[0] || header_len[2] != header_len2[2]) + return -1; + if(memcmp(header_start[0], header_start2[0], header_len[0]) || + memcmp(header_start[2], header_start2[2], header_len[2])) + return -1; + } + } + return 0; +}
I guess this stream compatibility check could be done in a non-matroska specific way, and be moved as a generic function in utils.c.
I'm pretty sure it could be done, but unfortunately my knowledge about codecs is close to none, so i wouldn't know how to do it :) this check is essentially a rewrite of what mkvmerge does and i suspect it's greatly simplified, so it wouldn't pass as a generic function.
+AVInputFormat matroska_demuxer_ordered = { + "matroska", + NULL_IF_CONFIG_SMALL("Matroska file format"), + sizeof(MatroskaDemuxContext), + matroska_probe, + matroska_read_header, + matroska_read_packet_ordered, + matroska_read_close, + matroska_read_seek_ordered, +};
I think you could avoid this new AVInputFormat entirely. You could have only one set of read_packet/read_seek functions which would work in both linked/non-linked cases.
done Anton
ping
On Sat, Nov 15, 2008 at 03:47:10PM +0100, Anton Khirnov wrote:
On Mon, Oct 27, 2008 at 4:33 PM, Aurelien Jacobs <aurel at gnuage.org> wrote:
On Fri, 17 Oct 2008 22:57:54 +0200 "Anton Khirnov" <wyskas at gmail.com> wrote:
ping - a reworked version.
Only a quick review for now.
[...] +static int av_load_external_streams(AVFormatContext *s) +{ [...] + if(!(dir = opendir(dirname))) + av_log(s, AV_LOG_ERROR, "Error opening directory %s\n.", dirname); + else { + av_log(s, AV_LOG_DEBUG, "Looking for linked files in %s.\n", dirname); + while((file = readdir(dir))) {
Using opendir() / readdir() directly here is ugly and won't ever work for non-local files. Another idea would be to add some kind of opendir/readdir operations in avio, working with URLContext. Those operations would only need to be implemented for local files for now, but could also be implemented for http or any other kind of protocol in the future.
done
+static int +matroska_check_linked_tracks(MatroskaTrack *track, MatroskaTrack *track2) +{ + if(strcmp(track->codec_id, track2->codec_id)) + return -1; + if(track->type == MATROSKA_TRACK_TYPE_VIDEO) { + if(track->video.pixel_width != track2->video.pixel_width || + track->video.pixel_height != track2->video.pixel_height || + track->codec_priv.size != track2->codec_priv.size) + return -1; + } + else if(track->type == MATROSKA_TRACK_TYPE_AUDIO) { + if(track->audio.channels != track2->audio.channels || + track->audio.out_samplerate != track2->audio.out_samplerate) + return -1; + if(strstr(track->codec_id, "A_AAC") || + strcmp(track->codec_id, "A_AC3") || + strcmp(track->codec_id, "A_VORBIS") || + strcmp(track->codec_id, "A_DTS") || + strstr(track->codec_id, "A_MPEG")) + if(track->audio.bitdepth != track2->audio.bitdepth) + return -1; + if(strstr(track->codec_id, "A_AAC")) + if(matroska_aac_profile(track->codec_id) != matroska_aac_profile(track2->codec_id)) + return -1; + if(!strcmp(track->codec_id, "A_FLAC") && + memcmp(track->codec_priv.data, track2->codec_priv.data, track->codec_priv.size)) + return -1; + if(!strcmp(track->codec_id, "A_VORBIS")) { + uint8_t *header_start[3], *header_start2[3]; + int header_len[3], header_len2[3]; + + if(ff_split_xiph_headers(track->codec_priv.data, track->codec_priv.size, + 30, header_start, header_len) < 0 || + ff_split_xiph_headers(track2->codec_priv.data, track2->codec_priv.size, + 30, header_start2, header_len2) < 0) + return -1; + if(header_len[0] != header_len2[0] || header_len[2] != header_len2[2]) + return -1; + if(memcmp(header_start[0], header_start2[0], header_len[0]) || + memcmp(header_start[2], header_start2[2], header_len[2])) + return -1; + } + } + return 0; +}
I guess this stream compatibility check could be done in a non-matroska specific way, and be moved as a generic function in utils.c.
I'm pretty sure it could be done, but unfortunately my knowledge about codecs is close to none, so i wouldn't know how to do it :) this check is essentially a rewrite of what mkvmerge does and i suspect it's greatly simplified, so it wouldn't pass as a generic function.
+AVInputFormat matroska_demuxer_ordered = { + "matroska", + NULL_IF_CONFIG_SMALL("Matroska file format"), + sizeof(MatroskaDemuxContext), + matroska_probe, + matroska_read_header, + matroska_read_packet_ordered, + matroska_read_close, + matroska_read_seek_ordered, +};
I think you could avoid this new AVInputFormat entirely. You could have only one set of read_packet/read_seek functions which would work in both linked/non-linked cases.
done
Anton
[...]
+#define AV_LINK_FILENAME 0x0001 ///< exact paths to external streams are known +#define AV_LINK_SAMEDIR 0x0002 ///< search for linked files in the same directory + +typedef struct AVLinkContext { + int search_flags; /**< Where should we look for external streams. */
is the reader supposed to guess what values this field has or if it maybe takes AV_LINK flags? [...]
diff --git a/libavformat/avio.h b/libavformat/avio.h index 687333e..261fb32 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -135,6 +135,9 @@ typedef struct URLProtocol { int (*url_read_pause)(URLContext *h, int pause); int64_t (*url_read_seek)(URLContext *h, int stream_index, int64_t timestamp, int flags); + int (*url_opendir)(URLContext **h, const char *path, int flags); + int (*url_readdir)( URLContext *h, char *filename, int max_size); + void (*url_closedir)(URLContext *h); } URLProtocol;
This stuff belongs in a seperate patch [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Good people do not need laws to tell them to act responsibly, while bad people will find a way around the laws. -- Plato
On Fri, Nov 21, 2008 at 9:03 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
[...]
+#define AV_LINK_FILENAME 0x0001 ///< exact paths to external streams are known +#define AV_LINK_SAMEDIR 0x0002 ///< search for linked files in the same directory + +typedef struct AVLinkContext { + int search_flags; /**< Where should we look for external streams. */
is the reader supposed to guess what values this field has or if it maybe takes AV_LINK flags?
fixed =p
[...]
diff --git a/libavformat/avio.h b/libavformat/avio.h index 687333e..261fb32 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -135,6 +135,9 @@ typedef struct URLProtocol { int (*url_read_pause)(URLContext *h, int pause); int64_t (*url_read_seek)(URLContext *h, int stream_index, int64_t timestamp, int flags); + int (*url_opendir)(URLContext **h, const char *path, int flags); + int (*url_readdir)( URLContext *h, char *filename, int max_size); + void (*url_closedir)(URLContext *h); } URLProtocol;
This stuff belongs in a seperate patch
done Anton
On Fri, Nov 21, 2008 at 11:13:30PM +0100, Anton Khirnov wrote:
On Fri, Nov 21, 2008 at 9:03 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
[...]
+#define AV_LINK_FILENAME 0x0001 ///< exact paths to external streams are known +#define AV_LINK_SAMEDIR 0x0002 ///< search for linked files in the same directory + +typedef struct AVLinkContext { + int search_flags; /**< Where should we look for external streams. */
is the reader supposed to guess what values this field has or if it maybe takes AV_LINK flags?
fixed =p
[...]
diff --git a/libavformat/avio.h b/libavformat/avio.h index 687333e..261fb32 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -135,6 +135,9 @@ typedef struct URLProtocol { int (*url_read_pause)(URLContext *h, int pause); int64_t (*url_read_seek)(URLContext *h, int stream_index, int64_t timestamp, int flags); + int (*url_opendir)(URLContext **h, const char *path, int flags); + int (*url_readdir)( URLContext *h, char *filename, int max_size); + void (*url_closedir)(URLContext *h); } URLProtocol;
This stuff belongs in a seperate patch
done
Anton
diff --git a/libavformat/avio.h b/libavformat/avio.h index 687333e..261fb32 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -135,6 +135,9 @@ typedef struct URLProtocol { int (*url_read_pause)(URLContext *h, int pause); int64_t (*url_read_seek)(URLContext *h, int stream_index, int64_t timestamp, int flags); + int (*url_opendir)(URLContext **h, const char *path, int flags); + int (*url_readdir)( URLContext *h, char *filename, int max_size); + void (*url_closedir)(URLContext *h); } URLProtocol;
i was wondering if this is needed, i mean url_open/url_read could be used too given a special flag during open to indicate opening a directory. But maybe this is undesireable, and your patch is better, i dont know except this i think the directory patch is fine [...]
diff --git a/libavformat/avformat.h b/libavformat/avformat.h index acdcec4..e85b49d 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -22,8 +22,8 @@ #define AVFORMAT_AVFORMAT_H
#define LIBAVFORMAT_VERSION_MAJOR 52 -#define LIBAVFORMAT_VERSION_MINOR 23 -#define LIBAVFORMAT_VERSION_MICRO 1 +#define LIBAVFORMAT_VERSION_MINOR 24 +#define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ @@ -464,6 +464,29 @@ typedef struct AVChapter {
#define MAX_STREAMS 20
+#define AV_LINK_FILENAME 0x0001 ///< exact paths to external streams are known +#define AV_LINK_SAMEDIR 0x0002 ///< search for linked files in the same directory + +typedef struct AVLinkContext { + int search_flags; /**< Where should we look for external streams. See AV_LINK_* */ + char **filenames; /**< Paths to external streams, if known. */ + unsigned int nb_filenames; + char *extensions; /**< Extensions we are interested in, comma-separated. */ + struct AVFormatContext **external_ctx; /** Handles of external streams. */ + unsigned int nb_external_ctx; + /** + * Check if this stream is needed. + * First parameter is the main context, second is + * external stream. + */ + int (*check_external_stream)(struct AVFormatContext *, struct AVFormatContext *); + /** + * Prepare the main context for using external + * streams. + */ + int (*setup_context)(struct AVFormatContext *); +} AVLinkContext; + /** * Format I/O context. * New fields can be added to the end with minor version bumps.
Why this complexity? I mean what is the problem with a demuxer calling a function that then creates more AVFormatContext/... for the external streams and adds them to some list in the main one? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Many that live deserve death. And some that die deserve life. Can you give it to them? Then do not be too eager to deal out death in judgement. For even the very wise cannot see all ends. -- Gandalf
On Thu, Nov 27, 2008 at 11:49 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Fri, Nov 21, 2008 at 11:13:30PM +0100, Anton Khirnov wrote:
On Fri, Nov 21, 2008 at 9:03 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
[...]
+#define AV_LINK_FILENAME 0x0001 ///< exact paths to external streams are known +#define AV_LINK_SAMEDIR 0x0002 ///< search for linked files in the same directory + +typedef struct AVLinkContext { + int search_flags; /**< Where should we look for external streams. */
is the reader supposed to guess what values this field has or if it maybe takes AV_LINK flags?
fixed =p
[...]
diff --git a/libavformat/avio.h b/libavformat/avio.h index 687333e..261fb32 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -135,6 +135,9 @@ typedef struct URLProtocol { int (*url_read_pause)(URLContext *h, int pause); int64_t (*url_read_seek)(URLContext *h, int stream_index, int64_t timestamp, int flags); + int (*url_opendir)(URLContext **h, const char *path, int flags); + int (*url_readdir)( URLContext *h, char *filename, int max_size); + void (*url_closedir)(URLContext *h); } URLProtocol;
This stuff belongs in a seperate patch
done
Anton
diff --git a/libavformat/avio.h b/libavformat/avio.h index 687333e..261fb32 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -135,6 +135,9 @@ typedef struct URLProtocol { int (*url_read_pause)(URLContext *h, int pause); int64_t (*url_read_seek)(URLContext *h, int stream_index, int64_t timestamp, int flags); + int (*url_opendir)(URLContext **h, const char *path, int flags); + int (*url_readdir)( URLContext *h, char *filename, int max_size); + void (*url_closedir)(URLContext *h); } URLProtocol;
i was wondering if this is needed, i mean url_open/url_read could be used too given a special flag during open to indicate opening a directory. But maybe this is undesireable, and your patch is better, i dont know except this i think the directory patch is fine
I'd say that since we treat directories differently from normal files, we should also use different functions. Besides i don't see an immediate way to determine if url_read is called for directory or file.
diff --git a/libavformat/avformat.h b/libavformat/avformat.h index acdcec4..e85b49d 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -22,8 +22,8 @@ #define AVFORMAT_AVFORMAT_H
#define LIBAVFORMAT_VERSION_MAJOR 52 -#define LIBAVFORMAT_VERSION_MINOR 23 -#define LIBAVFORMAT_VERSION_MICRO 1 +#define LIBAVFORMAT_VERSION_MINOR 24 +#define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ @@ -464,6 +464,29 @@ typedef struct AVChapter {
#define MAX_STREAMS 20
+#define AV_LINK_FILENAME 0x0001 ///< exact paths to external streams are known +#define AV_LINK_SAMEDIR 0x0002 ///< search for linked files in the same directory + +typedef struct AVLinkContext { + int search_flags; /**< Where should we look for external streams. See AV_LINK_* */ + char **filenames; /**< Paths to external streams, if known. */ + unsigned int nb_filenames; + char *extensions; /**< Extensions we are interested in, comma-separated. */ + struct AVFormatContext **external_ctx; /** Handles of external streams. */ + unsigned int nb_external_ctx; + /** + * Check if this stream is needed. + * First parameter is the main context, second is + * external stream. + */ + int (*check_external_stream)(struct AVFormatContext *, struct AVFormatContext *); + /** + * Prepare the main context for using external + * streams. + */ + int (*setup_context)(struct AVFormatContext *); +} AVLinkContext; + /** * Format I/O context. * New fields can be added to the end with minor version bumps.
Why this complexity?
I mean what is the problem with a demuxer calling a function that then creates more AVFormatContext/... for the external streams and adds them to some list in the main one?
I'm not sure what do you mean, some pingpong between demuxer and utils.c is unavoidable because the demuxer doesn's always know the filenames it'll need and utils.c can't do checking by itself. Anton
On Fri, Nov 28, 2008 at 04:08:08PM +0100, Anton Khirnov wrote:
On Thu, Nov 27, 2008 at 11:49 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Fri, Nov 21, 2008 at 11:13:30PM +0100, Anton Khirnov wrote:
On Fri, Nov 21, 2008 at 9:03 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
[...]
+#define AV_LINK_FILENAME 0x0001 ///< exact paths to external streams are known +#define AV_LINK_SAMEDIR 0x0002 ///< search for linked files in the same directory + +typedef struct AVLinkContext { + int search_flags; /**< Where should we look for external streams. */
is the reader supposed to guess what values this field has or if it maybe takes AV_LINK flags?
fixed =p
[...]
diff --git a/libavformat/avio.h b/libavformat/avio.h index 687333e..261fb32 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -135,6 +135,9 @@ typedef struct URLProtocol { int (*url_read_pause)(URLContext *h, int pause); int64_t (*url_read_seek)(URLContext *h, int stream_index, int64_t timestamp, int flags); + int (*url_opendir)(URLContext **h, const char *path, int flags); + int (*url_readdir)( URLContext *h, char *filename, int max_size); + void (*url_closedir)(URLContext *h); } URLProtocol;
This stuff belongs in a seperate patch
done
Anton
diff --git a/libavformat/avio.h b/libavformat/avio.h index 687333e..261fb32 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -135,6 +135,9 @@ typedef struct URLProtocol { int (*url_read_pause)(URLContext *h, int pause); int64_t (*url_read_seek)(URLContext *h, int stream_index, int64_t timestamp, int flags); + int (*url_opendir)(URLContext **h, const char *path, int flags); + int (*url_readdir)( URLContext *h, char *filename, int max_size); + void (*url_closedir)(URLContext *h); } URLProtocol;
i was wondering if this is needed, i mean url_open/url_read could be used too given a special flag during open to indicate opening a directory. But maybe this is undesireable, and your patch is better, i dont know except this i think the directory patch is fine
I'd say that since we treat directories differently from normal files, we should also use different functions.
we treat them differently because the underlaying functions we (have to) use treat them differently
Besides i don't see an immediate way to determine if url_read is called for directory or file.
the "int flags" like #define AV_OPEN_DIR 0x1234 url_open(..., AV_OPEN_DIR);
diff --git a/libavformat/avformat.h b/libavformat/avformat.h index acdcec4..e85b49d 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -22,8 +22,8 @@ #define AVFORMAT_AVFORMAT_H
#define LIBAVFORMAT_VERSION_MAJOR 52 -#define LIBAVFORMAT_VERSION_MINOR 23 -#define LIBAVFORMAT_VERSION_MICRO 1 +#define LIBAVFORMAT_VERSION_MINOR 24 +#define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ @@ -464,6 +464,29 @@ typedef struct AVChapter {
#define MAX_STREAMS 20
+#define AV_LINK_FILENAME 0x0001 ///< exact paths to external streams are known +#define AV_LINK_SAMEDIR 0x0002 ///< search for linked files in the same directory + +typedef struct AVLinkContext { + int search_flags; /**< Where should we look for external streams. See AV_LINK_* */ + char **filenames; /**< Paths to external streams, if known. */ + unsigned int nb_filenames; + char *extensions; /**< Extensions we are interested in, comma-separated. */ + struct AVFormatContext **external_ctx; /** Handles of external streams. */ + unsigned int nb_external_ctx; + /** + * Check if this stream is needed. + * First parameter is the main context, second is + * external stream. + */ + int (*check_external_stream)(struct AVFormatContext *, struct AVFormatContext *); + /** + * Prepare the main context for using external + * streams. + */ + int (*setup_context)(struct AVFormatContext *); +} AVLinkContext; + /** * Format I/O context. * New fields can be added to the end with minor version bumps.
Why this complexity?
I mean what is the problem with a demuxer calling a function that then creates more AVFormatContext/... for the external streams and adds them to some list in the main one?
I'm not sure what do you mean, some pingpong between demuxer and utils.c is unavoidable because the demuxer doesn's always know the filenames it'll need and utils.c can't do checking by itself.
i cant follow your logic. * there is a way to decide which file to open or the file could not be opened. * above way can be implemented in a function be that in the demuxer or utils.c * this function can be called to find the file, next it can be opened the contexts and streams be created ... at no point does a AVLinkContext with callbacks become needed thus my question again, what is this good for? If matroska uses some silly system to guess which file to open, its a matter of matroska calling a give_me_a_list_of_file_names() url_open(the_name_i_picked) [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Awnsering whenever a program halts or runs forever is On a turing machine, in general impossible (turings halting problem). On any real computer, always possible as a real computer has a finite number of states N, and will either halt in less than N cycles or never halt.
On Fri, Nov 28, 2008 at 5:10 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Fri, Nov 28, 2008 at 04:08:08PM +0100, Anton Khirnov wrote:
On Thu, Nov 27, 2008 at 11:49 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Fri, Nov 21, 2008 at 11:13:30PM +0100, Anton Khirnov wrote:
On Fri, Nov 21, 2008 at 9:03 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
[...]
+#define AV_LINK_FILENAME 0x0001 ///< exact paths to external streams are known +#define AV_LINK_SAMEDIR 0x0002 ///< search for linked files in the same directory + +typedef struct AVLinkContext { + int search_flags; /**< Where should we look for external streams. */
is the reader supposed to guess what values this field has or if it maybe takes AV_LINK flags?
fixed =p
[...]
diff --git a/libavformat/avio.h b/libavformat/avio.h index 687333e..261fb32 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -135,6 +135,9 @@ typedef struct URLProtocol { int (*url_read_pause)(URLContext *h, int pause); int64_t (*url_read_seek)(URLContext *h, int stream_index, int64_t timestamp, int flags); + int (*url_opendir)(URLContext **h, const char *path, int flags); + int (*url_readdir)( URLContext *h, char *filename, int max_size); + void (*url_closedir)(URLContext *h); } URLProtocol;
This stuff belongs in a seperate patch
done
Anton
diff --git a/libavformat/avio.h b/libavformat/avio.h index 687333e..261fb32 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -135,6 +135,9 @@ typedef struct URLProtocol { int (*url_read_pause)(URLContext *h, int pause); int64_t (*url_read_seek)(URLContext *h, int stream_index, int64_t timestamp, int flags); + int (*url_opendir)(URLContext **h, const char *path, int flags); + int (*url_readdir)( URLContext *h, char *filename, int max_size); + void (*url_closedir)(URLContext *h); } URLProtocol;
i was wondering if this is needed, i mean url_open/url_read could be used too given a special flag during open to indicate opening a directory. But maybe this is undesireable, and your patch is better, i dont know except this i think the directory patch is fine
I'd say that since we treat directories differently from normal files, we should also use different functions.
we treat them differently because the underlaying functions we (have to) use treat them differently
Besides i don't see an immediate way to determine if url_read is called for directory or file.
the "int flags"
like #define AV_OPEN_DIR 0x1234 url_open(..., AV_OPEN_DIR);
url_*read* or am i missing something?
diff --git a/libavformat/avformat.h b/libavformat/avformat.h index acdcec4..e85b49d 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -22,8 +22,8 @@ #define AVFORMAT_AVFORMAT_H
#define LIBAVFORMAT_VERSION_MAJOR 52 -#define LIBAVFORMAT_VERSION_MINOR 23 -#define LIBAVFORMAT_VERSION_MICRO 1 +#define LIBAVFORMAT_VERSION_MINOR 24 +#define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ @@ -464,6 +464,29 @@ typedef struct AVChapter {
#define MAX_STREAMS 20
+#define AV_LINK_FILENAME 0x0001 ///< exact paths to external streams are known +#define AV_LINK_SAMEDIR 0x0002 ///< search for linked files in the same directory + +typedef struct AVLinkContext { + int search_flags; /**< Where should we look for external streams. See AV_LINK_* */ + char **filenames; /**< Paths to external streams, if known. */ + unsigned int nb_filenames; + char *extensions; /**< Extensions we are interested in, comma-separated. */ + struct AVFormatContext **external_ctx; /** Handles of external streams. */ + unsigned int nb_external_ctx; + /** + * Check if this stream is needed. + * First parameter is the main context, second is + * external stream. + */ + int (*check_external_stream)(struct AVFormatContext *, struct AVFormatContext *); + /** + * Prepare the main context for using external + * streams. + */ + int (*setup_context)(struct AVFormatContext *); +} AVLinkContext; + /** * Format I/O context. * New fields can be added to the end with minor version bumps.
Why this complexity?
I mean what is the problem with a demuxer calling a function that then creates more AVFormatContext/... for the external streams and adds them to some list in the main one?
I'm not sure what do you mean, some pingpong between demuxer and utils.c is unavoidable because the demuxer doesn's always know the filenames it'll need and utils.c can't do checking by itself.
i cant follow your logic. * there is a way to decide which file to open or the file could not be opened. * above way can be implemented in a function be that in the demuxer or utils.c * this function can be called to find the file, next it can be opened the contexts and streams be created ...
at no point does a AVLinkContext with callbacks become needed thus my question again, what is this good for?
If matroska uses some silly system to guess which file to open, its a matter of matroska calling a give_me_a_list_of_file_names() url_open(the_name_i_picked)
each matroska file contains a UID and these UIDs are used for specifying linking betweeen files. So we open all mkv files in the same directory and search for these UIDs. This can't be done in demuxer-independent way. Anton
On Fri, Nov 28, 2008 at 08:14:31PM +0100, Anton Khirnov wrote:
On Fri, Nov 28, 2008 at 5:10 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Fri, Nov 28, 2008 at 04:08:08PM +0100, Anton Khirnov wrote:
On Thu, Nov 27, 2008 at 11:49 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Fri, Nov 21, 2008 at 11:13:30PM +0100, Anton Khirnov wrote:
On Fri, Nov 21, 2008 at 9:03 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
[...] > +#define AV_LINK_FILENAME 0x0001 ///< exact paths to external streams are known > +#define AV_LINK_SAMEDIR 0x0002 ///< search for linked files in the same directory > + > +typedef struct AVLinkContext { > + int search_flags; /**< Where should we look for external streams. */
is the reader supposed to guess what values this field has or if it maybe takes AV_LINK flags?
fixed =p
[...] > diff --git a/libavformat/avio.h b/libavformat/avio.h > index 687333e..261fb32 100644 > --- a/libavformat/avio.h > +++ b/libavformat/avio.h > @@ -135,6 +135,9 @@ typedef struct URLProtocol { > int (*url_read_pause)(URLContext *h, int pause); > int64_t (*url_read_seek)(URLContext *h, > int stream_index, int64_t timestamp, int flags); > + int (*url_opendir)(URLContext **h, const char *path, int flags); > + int (*url_readdir)( URLContext *h, char *filename, int max_size); > + void (*url_closedir)(URLContext *h); > } URLProtocol;
This stuff belongs in a seperate patch
done
Anton
diff --git a/libavformat/avio.h b/libavformat/avio.h index 687333e..261fb32 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -135,6 +135,9 @@ typedef struct URLProtocol { int (*url_read_pause)(URLContext *h, int pause); int64_t (*url_read_seek)(URLContext *h, int stream_index, int64_t timestamp, int flags); + int (*url_opendir)(URLContext **h, const char *path, int flags); + int (*url_readdir)( URLContext *h, char *filename, int max_size); + void (*url_closedir)(URLContext *h); } URLProtocol;
i was wondering if this is needed, i mean url_open/url_read could be used too given a special flag during open to indicate opening a directory. But maybe this is undesireable, and your patch is better, i dont know except this i think the directory patch is fine
I'd say that since we treat directories differently from normal files, we should also use different functions.
we treat them differently because the underlaying functions we (have to) use treat them differently
Besides i don't see an immediate way to determine if url_read is called for directory or file.
the "int flags"
like #define AV_OPEN_DIR 0x1234 url_open(..., AV_OPEN_DIR);
url_*read*
oops, reading too quick ... The first char of the filename could be used to identify directories/links/pipes/files/... and again i dont know if this is a good idea, its just an idea ...
or am i missing something?
diff --git a/libavformat/avformat.h b/libavformat/avformat.h index acdcec4..e85b49d 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -22,8 +22,8 @@ #define AVFORMAT_AVFORMAT_H
#define LIBAVFORMAT_VERSION_MAJOR 52 -#define LIBAVFORMAT_VERSION_MINOR 23 -#define LIBAVFORMAT_VERSION_MICRO 1 +#define LIBAVFORMAT_VERSION_MINOR 24 +#define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ @@ -464,6 +464,29 @@ typedef struct AVChapter {
#define MAX_STREAMS 20
+#define AV_LINK_FILENAME 0x0001 ///< exact paths to external streams are known +#define AV_LINK_SAMEDIR 0x0002 ///< search for linked files in the same directory + +typedef struct AVLinkContext { + int search_flags; /**< Where should we look for external streams. See AV_LINK_* */ + char **filenames; /**< Paths to external streams, if known. */ + unsigned int nb_filenames; + char *extensions; /**< Extensions we are interested in, comma-separated. */ + struct AVFormatContext **external_ctx; /** Handles of external streams. */ + unsigned int nb_external_ctx; + /** + * Check if this stream is needed. + * First parameter is the main context, second is + * external stream. + */ + int (*check_external_stream)(struct AVFormatContext *, struct AVFormatContext *); + /** + * Prepare the main context for using external + * streams. + */ + int (*setup_context)(struct AVFormatContext *); +} AVLinkContext; + /** * Format I/O context. * New fields can be added to the end with minor version bumps.
Why this complexity?
I mean what is the problem with a demuxer calling a function that then creates more AVFormatContext/... for the external streams and adds them to some list in the main one?
I'm not sure what do you mean, some pingpong between demuxer and utils.c is unavoidable because the demuxer doesn's always know the filenames it'll need and utils.c can't do checking by itself.
i cant follow your logic. * there is a way to decide which file to open or the file could not be opened. * above way can be implemented in a function be that in the demuxer or utils.c * this function can be called to find the file, next it can be opened the contexts and streams be created ...
at no point does a AVLinkContext with callbacks become needed thus my question again, what is this good for?
If matroska uses some silly system to guess which file to open, its a matter of matroska calling a give_me_a_list_of_file_names() url_open(the_name_i_picked)
each matroska file contains a UID and these UIDs are used for specifying linking betweeen files. So we open all mkv files in the same directory and search for these UIDs. This can't be done in demuxer-independent way.
true, but i cannot see how this is related to the complex code you propose the demuxer can easily just get a directory listing and check files until it found all it needs. That is once the URLProtocol supports listing directorie contents. My question is what the "pingpong" callback stuff is good for? Maybe it is usefull for something but i cant see what this somehing might be... [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
... defining _GNU_SOURCE... For the love of all that is holy, and some that is not, don't do that. -- Luca & Mans
On Fri, Nov 28, 2008 at 9:25 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Fri, Nov 28, 2008 at 08:14:31PM +0100, Anton Khirnov wrote:
On Fri, Nov 28, 2008 at 5:10 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Fri, Nov 28, 2008 at 04:08:08PM +0100, Anton Khirnov wrote:
On Thu, Nov 27, 2008 at 11:49 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Fri, Nov 21, 2008 at 11:13:30PM +0100, Anton Khirnov wrote:
On Fri, Nov 21, 2008 at 9:03 PM, Michael Niedermayer <michaelni at gmx.at> wrote: > > [...] >> +#define AV_LINK_FILENAME 0x0001 ///< exact paths to external streams are known >> +#define AV_LINK_SAMEDIR 0x0002 ///< search for linked files in the same directory >> + >> +typedef struct AVLinkContext { >> + int search_flags; /**< Where should we look for external streams. */ > > is the reader supposed to guess what values this field has or if it > maybe takes AV_LINK flags? >
fixed =p
> > [...] >> diff --git a/libavformat/avio.h b/libavformat/avio.h >> index 687333e..261fb32 100644 >> --- a/libavformat/avio.h >> +++ b/libavformat/avio.h >> @@ -135,6 +135,9 @@ typedef struct URLProtocol { >> int (*url_read_pause)(URLContext *h, int pause); >> int64_t (*url_read_seek)(URLContext *h, >> int stream_index, int64_t timestamp, int flags); >> + int (*url_opendir)(URLContext **h, const char *path, int flags); >> + int (*url_readdir)( URLContext *h, char *filename, int max_size); >> + void (*url_closedir)(URLContext *h); >> } URLProtocol; > > This stuff belongs in a seperate patch >
done
Anton
diff --git a/libavformat/avio.h b/libavformat/avio.h index 687333e..261fb32 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -135,6 +135,9 @@ typedef struct URLProtocol { int (*url_read_pause)(URLContext *h, int pause); int64_t (*url_read_seek)(URLContext *h, int stream_index, int64_t timestamp, int flags); + int (*url_opendir)(URLContext **h, const char *path, int flags); + int (*url_readdir)( URLContext *h, char *filename, int max_size); + void (*url_closedir)(URLContext *h); } URLProtocol;
i was wondering if this is needed, i mean url_open/url_read could be used too given a special flag during open to indicate opening a directory. But maybe this is undesireable, and your patch is better, i dont know except this i think the directory patch is fine
I'd say that since we treat directories differently from normal files, we should also use different functions.
we treat them differently because the underlaying functions we (have to) use treat them differently
Besides i don't see an immediate way to determine if url_read is called for directory or file.
the "int flags"
like #define AV_OPEN_DIR 0x1234 url_open(..., AV_OPEN_DIR);
url_*read*
oops, reading too quick ... The first char of the filename could be used to identify directories/links/pipes/files/...
and again i dont know if this is a good idea, its just an idea ...
i don't see any advantages in that :/
or am i missing something?
diff --git a/libavformat/avformat.h b/libavformat/avformat.h index acdcec4..e85b49d 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -22,8 +22,8 @@ #define AVFORMAT_AVFORMAT_H
#define LIBAVFORMAT_VERSION_MAJOR 52 -#define LIBAVFORMAT_VERSION_MINOR 23 -#define LIBAVFORMAT_VERSION_MICRO 1 +#define LIBAVFORMAT_VERSION_MINOR 24 +#define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ @@ -464,6 +464,29 @@ typedef struct AVChapter {
#define MAX_STREAMS 20
+#define AV_LINK_FILENAME 0x0001 ///< exact paths to external streams are known +#define AV_LINK_SAMEDIR 0x0002 ///< search for linked files in the same directory + +typedef struct AVLinkContext { + int search_flags; /**< Where should we look for external streams. See AV_LINK_* */ + char **filenames; /**< Paths to external streams, if known. */ + unsigned int nb_filenames; + char *extensions; /**< Extensions we are interested in, comma-separated. */ + struct AVFormatContext **external_ctx; /** Handles of external streams. */ + unsigned int nb_external_ctx; + /** + * Check if this stream is needed. + * First parameter is the main context, second is + * external stream. + */ + int (*check_external_stream)(struct AVFormatContext *, struct AVFormatContext *); + /** + * Prepare the main context for using external + * streams. + */ + int (*setup_context)(struct AVFormatContext *); +} AVLinkContext; + /** * Format I/O context. * New fields can be added to the end with minor version bumps.
Why this complexity?
I mean what is the problem with a demuxer calling a function that then creates more AVFormatContext/... for the external streams and adds them to some list in the main one?
I'm not sure what do you mean, some pingpong between demuxer and utils.c is unavoidable because the demuxer doesn's always know the filenames it'll need and utils.c can't do checking by itself.
i cant follow your logic. * there is a way to decide which file to open or the file could not be opened. * above way can be implemented in a function be that in the demuxer or utils.c * this function can be called to find the file, next it can be opened the contexts and streams be created ...
at no point does a AVLinkContext with callbacks become needed thus my question again, what is this good for?
If matroska uses some silly system to guess which file to open, its a matter of matroska calling a give_me_a_list_of_file_names() url_open(the_name_i_picked)
each matroska file contains a UID and these UIDs are used for specifying linking betweeen files. So we open all mkv files in the same directory and search for these UIDs. This can't be done in demuxer-independent way.
true, but i cannot see how this is related to the complex code you propose the demuxer can easily just get a directory listing and check files until it found all it needs. That is once the URLProtocol supports listing directorie contents. My question is what the "pingpong" callback stuff is good for? Maybe it is usefull for something but i cant see what this somehing might be...
the idea was to do as much as possible in utils.c to prevent code duplication and allow easy adding of other ways to locate needed files. the demuxer should do only what's absolutely necessary, i.e. checking files and modifying avformatcontext. Anton
On Sat, Nov 29, 2008 at 01:08:13PM +0100, Anton Khirnov wrote:
On Fri, Nov 28, 2008 at 9:25 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Fri, Nov 28, 2008 at 08:14:31PM +0100, Anton Khirnov wrote:
On Fri, Nov 28, 2008 at 5:10 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Fri, Nov 28, 2008 at 04:08:08PM +0100, Anton Khirnov wrote:
On Thu, Nov 27, 2008 at 11:49 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Fri, Nov 21, 2008 at 11:13:30PM +0100, Anton Khirnov wrote: > On Fri, Nov 21, 2008 at 9:03 PM, Michael Niedermayer <michaelni at gmx.at> wrote: [...]
or am i missing something?
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h > index acdcec4..e85b49d 100644 > --- a/libavformat/avformat.h > +++ b/libavformat/avformat.h > @@ -22,8 +22,8 @@ > #define AVFORMAT_AVFORMAT_H > > #define LIBAVFORMAT_VERSION_MAJOR 52 > -#define LIBAVFORMAT_VERSION_MINOR 23 > -#define LIBAVFORMAT_VERSION_MICRO 1 > +#define LIBAVFORMAT_VERSION_MINOR 24 > +#define LIBAVFORMAT_VERSION_MICRO 0 > > #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ > LIBAVFORMAT_VERSION_MINOR, \ > @@ -464,6 +464,29 @@ typedef struct AVChapter { > > #define MAX_STREAMS 20 > > +#define AV_LINK_FILENAME 0x0001 ///< exact paths to external streams are known > +#define AV_LINK_SAMEDIR 0x0002 ///< search for linked files in the same directory > + > +typedef struct AVLinkContext { > + int search_flags; /**< Where should we look for external streams. See AV_LINK_* */ > + char **filenames; /**< Paths to external streams, if known. */ > + unsigned int nb_filenames; > + char *extensions; /**< Extensions we are interested in, comma-separated. */ > + struct AVFormatContext **external_ctx; /** Handles of external streams. */ > + unsigned int nb_external_ctx; > + /** > + * Check if this stream is needed. > + * First parameter is the main context, second is > + * external stream. > + */ > + int (*check_external_stream)(struct AVFormatContext *, struct AVFormatContext *); > + /** > + * Prepare the main context for using external > + * streams. > + */ > + int (*setup_context)(struct AVFormatContext *); > +} AVLinkContext; > + > /** > * Format I/O context. > * New fields can be added to the end with minor version bumps.
Why this complexity?
I mean what is the problem with a demuxer calling a function that then creates more AVFormatContext/... for the external streams and adds them to some list in the main one?
I'm not sure what do you mean, some pingpong between demuxer and utils.c is unavoidable because the demuxer doesn's always know the filenames it'll need and utils.c can't do checking by itself.
i cant follow your logic. * there is a way to decide which file to open or the file could not be opened. * above way can be implemented in a function be that in the demuxer or utils.c * this function can be called to find the file, next it can be opened the contexts and streams be created ...
at no point does a AVLinkContext with callbacks become needed thus my question again, what is this good for?
If matroska uses some silly system to guess which file to open, its a matter of matroska calling a give_me_a_list_of_file_names() url_open(the_name_i_picked)
each matroska file contains a UID and these UIDs are used for specifying linking betweeen files. So we open all mkv files in the same directory and search for these UIDs. This can't be done in demuxer-independent way.
true, but i cannot see how this is related to the complex code you propose the demuxer can easily just get a directory listing and check files until it found all it needs. That is once the URLProtocol supports listing directorie contents. My question is what the "pingpong" callback stuff is good for? Maybe it is usefull for something but i cant see what this somehing might be...
the idea was to do as much as possible in utils.c to prevent code duplication and allow easy adding of other ways to locate needed files. the demuxer should do only what's absolutely necessary, i.e. checking files and modifying avformatcontext.
what other ways? what code duplication?! this is matroska specific iam against putting matroska "search the file with ID x" code in utils.c [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Many things microsoft did are stupid, but not doing something just because microsoft did it is even more stupid. If everything ms did were stupid they would be bankrupt already.
On Mon, Dec 1, 2008 at 5:46 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Sat, Nov 29, 2008 at 01:08:13PM +0100, Anton Khirnov wrote:
On Fri, Nov 28, 2008 at 9:25 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Fri, Nov 28, 2008 at 08:14:31PM +0100, Anton Khirnov wrote:
On Fri, Nov 28, 2008 at 5:10 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Fri, Nov 28, 2008 at 04:08:08PM +0100, Anton Khirnov wrote:
On Thu, Nov 27, 2008 at 11:49 AM, Michael Niedermayer <michaelni at gmx.at> wrote: > On Fri, Nov 21, 2008 at 11:13:30PM +0100, Anton Khirnov wrote: >> On Fri, Nov 21, 2008 at 9:03 PM, Michael Niedermayer <michaelni at gmx.at> wrote: [...]
or am i missing something?
> >> diff --git a/libavformat/avformat.h b/libavformat/avformat.h >> index acdcec4..e85b49d 100644 >> --- a/libavformat/avformat.h >> +++ b/libavformat/avformat.h >> @@ -22,8 +22,8 @@ >> #define AVFORMAT_AVFORMAT_H >> >> #define LIBAVFORMAT_VERSION_MAJOR 52 >> -#define LIBAVFORMAT_VERSION_MINOR 23 >> -#define LIBAVFORMAT_VERSION_MICRO 1 >> +#define LIBAVFORMAT_VERSION_MINOR 24 >> +#define LIBAVFORMAT_VERSION_MICRO 0 >> >> #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ >> LIBAVFORMAT_VERSION_MINOR, \ >> @@ -464,6 +464,29 @@ typedef struct AVChapter { >> >> #define MAX_STREAMS 20 >> >> +#define AV_LINK_FILENAME 0x0001 ///< exact paths to external streams are known >> +#define AV_LINK_SAMEDIR 0x0002 ///< search for linked files in the same directory >> + >> +typedef struct AVLinkContext { >> + int search_flags; /**< Where should we look for external streams. See AV_LINK_* */ >> + char **filenames; /**< Paths to external streams, if known. */ >> + unsigned int nb_filenames; >> + char *extensions; /**< Extensions we are interested in, comma-separated. */ >> + struct AVFormatContext **external_ctx; /** Handles of external streams. */ >> + unsigned int nb_external_ctx; >> + /** >> + * Check if this stream is needed. >> + * First parameter is the main context, second is >> + * external stream. >> + */ >> + int (*check_external_stream)(struct AVFormatContext *, struct AVFormatContext *); >> + /** >> + * Prepare the main context for using external >> + * streams. >> + */ >> + int (*setup_context)(struct AVFormatContext *); >> +} AVLinkContext; >> + >> /** >> * Format I/O context. >> * New fields can be added to the end with minor version bumps. > > Why this complexity? > > I mean what is the problem with a demuxer calling a function that then > creates more AVFormatContext/... for the external streams and adds them > to some list in the main one? >
I'm not sure what do you mean, some pingpong between demuxer and utils.c is unavoidable because the demuxer doesn's always know the filenames it'll need and utils.c can't do checking by itself.
i cant follow your logic. * there is a way to decide which file to open or the file could not be opened. * above way can be implemented in a function be that in the demuxer or utils.c * this function can be called to find the file, next it can be opened the contexts and streams be created ...
at no point does a AVLinkContext with callbacks become needed thus my question again, what is this good for?
If matroska uses some silly system to guess which file to open, its a matter of matroska calling a give_me_a_list_of_file_names() url_open(the_name_i_picked)
each matroska file contains a UID and these UIDs are used for specifying linking betweeen files. So we open all mkv files in the same directory and search for these UIDs. This can't be done in demuxer-independent way.
true, but i cannot see how this is related to the complex code you propose the demuxer can easily just get a directory listing and check files until it found all it needs. That is once the URLProtocol supports listing directorie contents. My question is what the "pingpong" callback stuff is good for? Maybe it is usefull for something but i cant see what this somehing might be...
the idea was to do as much as possible in utils.c to prevent code duplication and allow easy adding of other ways to locate needed files. the demuxer should do only what's absolutely necessary, i.e. checking files and modifying avformatcontext.
what other ways? what code duplication?! this is matroska specific iam against putting matroska "search the file with ID x" code in utils.c
Matroska specs don't say a thing about where should linked files be located (yes I know it's another proof that matroska sucks ;), my patch is searching for them in the same dir because that's what Haali's splitter does. But alternatively we could scan $PWD, or use a user-supplied list of files/dirs or whatever weird way that's needed for other formats. So we have a av_load_external_streams function in utils.c that tries to open all candidate files based on hints from the demuxer and then passes their AVFormatContexts to a demuxer-specific check. Now if you decided to add file linking to nut for example, it would require less work. Anton
On Mon, Dec 01, 2008 at 07:30:20PM +0100, Anton Khirnov wrote:
On Mon, Dec 1, 2008 at 5:46 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Sat, Nov 29, 2008 at 01:08:13PM +0100, Anton Khirnov wrote:
On Fri, Nov 28, 2008 at 9:25 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Fri, Nov 28, 2008 at 08:14:31PM +0100, Anton Khirnov wrote:
On Fri, Nov 28, 2008 at 5:10 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Fri, Nov 28, 2008 at 04:08:08PM +0100, Anton Khirnov wrote: > On Thu, Nov 27, 2008 at 11:49 AM, Michael Niedermayer <michaelni at gmx.at> wrote: > > On Fri, Nov 21, 2008 at 11:13:30PM +0100, Anton Khirnov wrote: > >> On Fri, Nov 21, 2008 at 9:03 PM, Michael Niedermayer <michaelni at gmx.at> wrote: [...]
or am i missing something?
> > > > >> diff --git a/libavformat/avformat.h b/libavformat/avformat.h > >> index acdcec4..e85b49d 100644 > >> --- a/libavformat/avformat.h > >> +++ b/libavformat/avformat.h > >> @@ -22,8 +22,8 @@ > >> #define AVFORMAT_AVFORMAT_H > >> > >> #define LIBAVFORMAT_VERSION_MAJOR 52 > >> -#define LIBAVFORMAT_VERSION_MINOR 23 > >> -#define LIBAVFORMAT_VERSION_MICRO 1 > >> +#define LIBAVFORMAT_VERSION_MINOR 24 > >> +#define LIBAVFORMAT_VERSION_MICRO 0 > >> > >> #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ > >> LIBAVFORMAT_VERSION_MINOR, \ > >> @@ -464,6 +464,29 @@ typedef struct AVChapter { > >> > >> #define MAX_STREAMS 20 > >> > >> +#define AV_LINK_FILENAME 0x0001 ///< exact paths to external streams are known > >> +#define AV_LINK_SAMEDIR 0x0002 ///< search for linked files in the same directory > >> + > >> +typedef struct AVLinkContext { > >> + int search_flags; /**< Where should we look for external streams. See AV_LINK_* */ > >> + char **filenames; /**< Paths to external streams, if known. */ > >> + unsigned int nb_filenames; > >> + char *extensions; /**< Extensions we are interested in, comma-separated. */ > >> + struct AVFormatContext **external_ctx; /** Handles of external streams. */ > >> + unsigned int nb_external_ctx; > >> + /** > >> + * Check if this stream is needed. > >> + * First parameter is the main context, second is > >> + * external stream. > >> + */ > >> + int (*check_external_stream)(struct AVFormatContext *, struct AVFormatContext *); > >> + /** > >> + * Prepare the main context for using external > >> + * streams. > >> + */ > >> + int (*setup_context)(struct AVFormatContext *); > >> +} AVLinkContext; > >> + > >> /** > >> * Format I/O context. > >> * New fields can be added to the end with minor version bumps. > > > > Why this complexity? > > > > I mean what is the problem with a demuxer calling a function that then > > creates more AVFormatContext/... for the external streams and adds them > > to some list in the main one? > > > > I'm not sure what do you mean, some pingpong between demuxer and > utils.c is unavoidable because the demuxer doesn's always know the > filenames it'll need and utils.c can't do checking by itself.
i cant follow your logic. * there is a way to decide which file to open or the file could not be opened. * above way can be implemented in a function be that in the demuxer or utils.c * this function can be called to find the file, next it can be opened the contexts and streams be created ...
at no point does a AVLinkContext with callbacks become needed thus my question again, what is this good for?
If matroska uses some silly system to guess which file to open, its a matter of matroska calling a give_me_a_list_of_file_names() url_open(the_name_i_picked)
each matroska file contains a UID and these UIDs are used for specifying linking betweeen files. So we open all mkv files in the same directory and search for these UIDs. This can't be done in demuxer-independent way.
true, but i cannot see how this is related to the complex code you propose the demuxer can easily just get a directory listing and check files until it found all it needs. That is once the URLProtocol supports listing directorie contents. My question is what the "pingpong" callback stuff is good for? Maybe it is usefull for something but i cant see what this somehing might be...
the idea was to do as much as possible in utils.c to prevent code duplication and allow easy adding of other ways to locate needed files. the demuxer should do only what's absolutely necessary, i.e. checking files and modifying avformatcontext.
what other ways? what code duplication?! this is matroska specific iam against putting matroska "search the file with ID x" code in utils.c
Matroska specs don't say a thing about where should linked files be located (yes I know it's another proof that matroska sucks ;), my patch is searching for them in the same dir because that's what Haali's splitter does. But alternatively we could scan $PWD, or use a user-supplied list of files/dirs or whatever weird way that's needed for other formats.
i ask again, what other formats? If you cannot name one, i think you should not design things with the assumtation that there are other formats doing this.
So we have a av_load_external_streams function in utils.c that tries to open all candidate files based on hints from the demuxer and then passes their AVFormatContexts to a demuxer-specific check.
Now if you decided to add file linking to nut for example, it would require less work.
ehm, if nut did link to files, it would link by relative pathnames not some file content specific thing. for further info see the file on the WWW with md5:1234 ;) what you are trying to do is abstract something for which you have only 1 sample ... [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Asymptotically faster algorithms should always be preferred if you have asymptotical amounts of data
ok, so you basically want me to reverse what Aurelien told me to do On Sun, Aug 24, 2008 at 6:15 PM, Aurelien Jacobs <aurel at gnuage.org> wrote:
There are many more things I don't like in this patch. One of them being that the demuxer try to parse a directory and open files itself. I think the demuxer should only deal with ByteIOContext that the generic framework (utils.c) passes to it. That's up to the generic framework to find and open files (or network streams of whatever...). That could also be useful for other demuxer.
joy, i love nothing more than moving random pieces of code betwenn utils and matroskadec :P
ehm, if nut did link to files, it would link by relative pathnames not some file content specific thing.
which means users can't rename their files. i'm not sure this is better than matroska system. btw is there a reason is_dos_path(), match_ext() and a bunch of other functions at the bottom of avformat.h don't have av_ prefix? Anton
Anton Khirnov wrote:
btw is there a reason is_dos_path(), match_ext() and a bunch of other functions at the bottom of avformat.h don't have av_ prefix?
They don't belong in avformat.h in the first place. -- M?ns Rullg?rd mans at mansr.com
On Wed, Dec 10, 2008 at 11:37:54AM +0100, Anton Khirnov wrote:
ok, so you basically want me to reverse what Aurelien told me to do
On Sun, Aug 24, 2008 at 6:15 PM, Aurelien Jacobs <aurel at gnuage.org> wrote:
There are many more things I don't like in this patch. One of them being that the demuxer try to parse a directory and open files itself. I think the demuxer should only deal with ByteIOContext that the generic framework (utils.c) passes to it. That's up to the generic framework to find and open files (or network streams of whatever...). That could also be useful for other demuxer.
joy, i love nothing more than moving random pieces of code betwenn utils and matroskadec :P
Well, i guess noone wants that random trash in code they maintain, i can understand aurel about this ...
ehm, if nut did link to files, it would link by relative pathnames not some file content specific thing.
which means users can't rename their files. i'm not sure this is better than matroska system.
The first thing is that having videos refer to other files being idiotic The second thing is that files are referred to by name on computers, pick a random file of your OS and rename it to see where the problem is, or try to rename a file on a server without updating the links to it (if you say this is a lame example, rename a video and update the other videos that refer to it by name, its the same thing) The third is that the ID inside the file just moves the name, its just a matter of time until someone wants to change that ID too (especially if its displayed by more tools ...) forth the file could use its own basename as well, not just the path, that would allow files to be renamed together. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is not what we do, but why we do it that matters.
participants (6)
-
aurel@gnuage.org -
jbfaad@gmail.com -
mans@mansr.com -
michaelni@gmx.at -
uoti.urpala@pp1.inet.fi -
wyskas@gmail.com