[FFmpeg-devel] [PATCH v5] libavformat/mxfenc: write package name metadata

Tomas Härdin tomas.hardin at codemill.se
Thu Mar 5 11:37:28 CET 2015


On Wed, 2015-03-04 at 12:31 -0800, Mark Reid wrote:
> +/*
> + * Returns the calculated length a local tag containing an utf-8 string as utf-16
> + */
> +static int mxf_utf16_local_tag_length(const char *utf8_str)
> +{
> +    uint64_t size;
> +
> +    if (!utf8_str)
> +        return 0;
> +
> +    size = mxf_utf16len(utf8_str);
> +    if (size >= UINT16_MAX || size * 2 >= UINT16_MAX) {

if (size >= UINT16_MAX/2) {

> +        av_log(NULL, AV_LOG_ERROR, "utf16 local tag size %"PRIx64" invalid (too large), ignoring\n", size);
> +        return 0;
> +    }
> +
> +    return 4 + size * 2;
> +}
> +
> +/*
> + * Write a local tag containing an utf-8 string as utf-16
>   */
>  static void mxf_write_local_tag_utf16(AVIOContext *pb, int tag, const char *value)
>  {
> -    int i, size = strlen(value);
> +    uint64_t size = mxf_utf16len(value);
> +
> +    if (size >= UINT16_MAX || size * 2 >= UINT16_MAX) {

if (size >= UINT16_MAX/2) {

> +        av_log(NULL, AV_LOG_ERROR, "utf16 local tag size %"PRIx64" invalid (too large), ignoring\n", size);
> +        return;
> +    }
> +
>      mxf_write_local_tag(pb, size*2, tag);
> -    for (i = 0; i < size; i++)
> -        avio_wb16(pb, value[i]);
> +    avio_put_str16be(pb, value);
>  }

The rest looks OK to me. Nice work :)

/Tomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150305/e8d12f29/attachment.asc>


More information about the ffmpeg-devel mailing list