[FFmpeg-devel] [PATCH 3/3] lavf/movenc: add faststart option.

Michael Niedermayer michaelni at gmx.at
Sun Sep 23 03:55:10 CEST 2012


On Thu, Sep 20, 2012 at 10:47:20AM +0200, Clément Bœsch wrote:
> From: Clément Bœsch <clement.boesch at smartjog.com>
> 
> ---
>  libavformat/movenc.c |  125 +++++++++++++++++++++++++++++++++++++++++++++++---
>  libavformat/movenc.h |    3 +-
>  2 files changed, 121 insertions(+), 7 deletions(-)

this will need a fate test


[...]
> +static int shift_data(AVFormatContext *s)
> +{
> +    int ret, moov_size;
> +    MOVMuxContext *mov = s->priv_data;
> +    int64_t pos, pos_end = avio_tell(s->pb);
> +    uint8_t *buf, *read_buf[2];
> +    int read_buf_id = 0;
> +    int read_size[2];
> +    AVIOContext *read_pb;
> +
> +    moov_size = compute_moov_size(s);
> +    if (moov_size < 0)
> +        return moov_size;
> +
> +    buf = av_malloc(moov_size * 2);
> +    if (!buf)
> +        return AVERROR(ENOMEM);
> +    read_buf[0] = buf;
> +    read_buf[1] = buf + moov_size;
> +
> +    /* Shift the data: the AVIO context of the output can only be used for
> +     * writing, so we re-open the same output, but for reading. It also avoids
> +     * a read/seek/write/seek back and forth. */
> +    avio_flush(s->pb);
> +    ret = avio_open(&read_pb, s->filename, AVIO_FLAG_READ);
> +    if (ret < 0) {
> +        av_log(s, AV_LOG_ERROR, "Unable to re-open %s output file for "
> +               "the second pass (faststart)\n", s->filename);
> +        return ret;
> +    }

memleak (buf)

otherwise things look nice from a quick look

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120923/186ca893/attachment.asc>


More information about the ffmpeg-devel mailing list