[FFmpeg-devel] [PATCH] lavf: add data: URI scheme.

Clément Bœsch ubitux at gmail.com
Thu Dec 27 00:55:06 CET 2012


On Wed, Dec 26, 2012 at 10:49:37PM +0100, Nicolas George wrote:
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
>  Changelog                |    1 +
>  doc/protocols.texi       |    8 ++++
>  libavformat/Makefile     |    1 +
>  libavformat/allformats.c |    1 +
>  libavformat/data_uri.c   |  114 ++++++++++++++++++++++++++++++++++++++++++++++
>  libavformat/version.h    |    4 +-
>  6 files changed, 127 insertions(+), 2 deletions(-)
>  create mode 100644 libavformat/data_uri.c
> 
> 
> Updated to suit Stefano's comments.
> 
> 
[...]
> +
> +    data++;
> +    in_size = strlen(data);
> +    if (base64) {
> +        size_t out_size = 3 * in_size / 4 + 1;
> +

Why not AV_BASE64_SIZE()?

> +        if (out_size > INT_MAX || !(ddata = av_malloc(out_size)))
> +            return AVERROR(ENOMEM);
> +        if ((ret = av_base64_decode(ddata, data, out_size)) < 0) {
> +            av_free(ddata);
> +            return ret;
> +        }
> +        dc->data = dc->tofree = ddata;
> +        dc->size = ret;
> +    } else {
> +        dc->data = data;
> +        dc->size = in_size;
> +    }
> +    return 0;
> +}
> +

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121227/7862f566/attachment.asc>


More information about the ffmpeg-devel mailing list