[FFmpeg-devel] [PATCH] Adobe Filmstrip muxer and demuxer

Michael Niedermayer michaelni
Tue Jan 12 14:52:58 CET 2010


On Tue, Jan 12, 2010 at 10:03:56PM +1100, pross at xvid.org wrote:
> $subject
> 
> Samples in upload.mplayerhq.hu /MPlayer/incoming/filmstrip

[...]
> diff --git a/libavformat/filmstrip.c b/libavformat/filmstrip.c
> new file mode 100644
> index 0000000..ceb1dac
> --- /dev/null
> +++ b/libavformat/filmstrip.c
> @@ -0,0 +1,177 @@
> +/*
> + * Adobe Filmstrip muxer and demuxer
> + * Copyright (c) 2010 Peter Ross

please split them in 2 files


> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +/**
> + * @file libavformat/filmstrip.c
> + * Adobe Filmstrip muxer and demuxer
> + */
> +
> +#include "libavutil/intreadwrite.h"
> +#include "avformat.h"
> +
> +#define RAND_TAG MKBETAG('R','a','n','d')
> +
> +#if CONFIG_FILMSTRIP_DEMUXER
> +typedef struct {
> +    int leading;
> +} FilmstripDemuxContext;
> +

> +static int probe(AVProbeData *p)
> +{
> +    if (av_match_ext(p->filename, "flm"))
> +        return AVPROBE_SCORE_MAX / 2;
> +    return 0;
> +}

This can be done simpler by setting the extension for the format,
but cant this be probed in some more advanced way?


> +
> +static int read_header(AVFormatContext *s,
> +                       AVFormatParameters *ap)
> +{
> +    FilmstripDemuxContext *film = s->priv_data;
> +    ByteIOContext *pb = s->pb;
> +    AVStream *st;
> +
> +    if (url_is_streamed(s->pb))
> +        return AVERROR(EIO);
> +
> +    url_fseek(pb, url_fsize(pb) - 36, SEEK_SET);
> +    if (get_be32(pb) != RAND_TAG) {
> +        av_log(s, AV_LOG_ERROR, "magic number not found");
> +        return AVERROR_INVALIDDATA;
> +    }
> +
> +    st = av_new_stream(s, 0);
> +    if (!st)
> +        return AVERROR(ENOMEM);
> +
> +    st->nb_frames = get_be32(pb);
> +    if (get_be16(pb) != 0) {
> +        av_log_ask_for_sample(s, "unsupported packing method\n");

> +        av_close_input_stream(s);

uneeded?


[...]
> +static int write_trailer(AVFormatContext *s)
> +{
> +    FilmstripMuxContext *film = s->priv_data;
> +    ByteIOContext *pb = s->pb;
> +    AVStream *st = s->streams[0];
> +    int i;
> +
> +    put_be32(pb, RAND_TAG);
> +    put_be32(pb, film->nb_frames);
> +    put_be16(pb, 0);  // packing method
> +    put_be16(pb, 0);  // reserved
> +    put_be16(pb, st->codec->width);
> +    put_be16(pb, st->codec->height);
> +    put_be16(pb, 0);  // leading

> +    put_be16(pb, (float)st->codec->time_base.den / (float)st->codec->time_base.num);

av_q2d()


[...]
-- 
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.
-------------- 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/20100112/fe1c8db1/attachment.pgp>



More information about the ffmpeg-devel mailing list