[FFmpeg-devel] [PATCH] support for ordered chapters/segment linking in Matroska

Anton Khirnov wyskas
Sat Nov 15 15:47:10 CET 2008


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 01_lavf_external_files.diff
Type: text/x-diff
Size: 9844 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20081115/39a3bd1b/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 02_matroska_ordered_chapter.diff
Type: text/x-diff
Size: 20053 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20081115/39a3bd1b/attachment-0001.diff>



More information about the ffmpeg-devel mailing list