[FFmpeg-devel] [PATCH] WebM mux/demux
Michael Niedermayer
michaelni
Wed May 19 21:14:57 CEST 2010
On Wed, May 19, 2010 at 03:05:30PM -0400, David Conrad wrote:
> On May 19, 2010, at 3:02 PM, Ronald S. Bultje wrote:
>
> > Hi,
> >
> > On Wed, May 19, 2010 at 2:51 PM, James Zern <jzern at google.com> wrote:
> >> Related thread: '[PATCH] VP8 de/encode via libvpx'
> >> VP8 and associated WebM container made public today [1].
> >>
> >> The attached adds WebM de/muxing to matroska.
> >> For both some extra ifdef's/checks were added to only allow VP8/vorbis
> >> as that is the current supported configuration in web browsers. If
> >> these are too busy in this respect they be cleaned up.
> >
> > Why is the "webm demuxer" separate? Our quicktime demuxer, for
> > example, demuxes mp4 and 3gp also. The same could be done for
> > matroska. After all, it's a regular subset and thus any matroska
> > demuxer understanding the "webm" ID could demux webm files also. (I
> > know this isn't true for the muxer.)
>
> Agreed, it should be something like the attached
>
> commit a841b15bec8edc1c79fa2a23fb98ad0157a118b0
> Author: David Conrad <lessen42 at gmail.com>
> Date: Wed May 19 13:10:33 2010 -0400
>
> matroskadec: Add webm doctype
>
> Based on a Google patch
>
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index 1bde1af..d580469 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -209,6 +209,7 @@ typedef struct {
>
> typedef struct {
> AVFormatContext *ctx;
> + char *doctype;
>
> /* EBML stuff */
> int num_levels;
> @@ -505,6 +506,8 @@ static EbmlSyntax matroska_clusters[] = {
> { 0 }
> };
>
> +static const char *matroska_doctypes[] = { "matroska", "webm" };
> +
> /*
> * Return: Whether we reached the end of a level in the hierarchy or not.
> */
> @@ -825,8 +828,7 @@ static void ebml_free(EbmlSyntax *syntax, void *data)
> static int matroska_probe(AVProbeData *p)
> {
> uint64_t total = 0;
> - int len_mask = 0x80, size = 1, n = 1;
> - static const char probe_data[] = "matroska";
> + int len_mask = 0x80, size = 1, n = 1, i;
>
> /* EBML header? */
> if (AV_RB32(p->buf) != EBML_ID_HEADER)
> @@ -848,13 +850,14 @@ static int matroska_probe(AVProbeData *p)
> if (p->buf_size < 4 + size + total)
> return 0;
>
> - /* The header must contain the document type 'matroska'. For now,
> + /* The header must contain a known document type. For now,
> * we don't parse the whole header but simply check for the
> * availability of that array of characters inside the header.
> * Not fully fool-proof, but good enough. */
> - for (n = 4+size; n <= 4+size+total-(sizeof(probe_data)-1); n++)
> - if (!memcmp(p->buf+n, probe_data, sizeof(probe_data)-1))
> - return AVPROBE_SCORE_MAX;
> + for (i = 0; i < FF_ARRAY_ELEMS(matroska_doctypes); i++)
> + for (n = 4+size; n <= 4+size+total-(strlen(matroska_doctypes[i])-1); n++)
> + if (!memcmp(p->buf+n, probe_data, strlen(matroska_doctypes[i])-1))
> + return AVPROBE_SCORE_MAX;
>
> return 0;
> }
it would be more future proof if we didnt check this string at all (as long
as reliable detection is still possible of course)
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100519/608eacb6/attachment.pgp>
More information about the ffmpeg-devel
mailing list