Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH v2 0/7] Add UUID functionality to libavutil
@ 2022-04-24 10:14 Zane van Iperen
  2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 1/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122 Zane van Iperen
                   ` (6 more replies)
  0 siblings, 7 replies; 20+ messages in thread
From: Zane van Iperen @ 2022-04-24 10:14 UTC (permalink / raw)
  To: ffmpeg-devel

This patchset adds functions for handling UUIDs to libavutil, under the av_uuid_*
prefix, and refactors the various ad-hoc handling to use it. This was
proposed in [1].

This is _heavily_ based off libuuid with various parts of the code
simplified to remove unnecessary functionality (e.g. generation, and v1
UUIDs).

v2:
- Removed unnecessary license header in libavutil/uuid.h
- Cosmetic fixes

[1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2022-January/291917.html

Pierre-Anthony Lemieux (6):
  avutil/tests/uuid: add uuid tests
  avformat/mov: refactor to use avutil/uuid
  avformat/smoothstreamingenc: refactor to use avutil/uuid
  avcodec/cbs_sei: refactor to use avutil/uuid
  avformat/imf: refactor to use avutil/uuid
  avfilter/showinfo: refactor to use avutil/uuid

Zane van Iperen (1):
  avutil/uuid: add utility library for manipulating UUIDs as specified
    in RFC 4122

 libavcodec/cbs_sei.h             |   3 +-
 libavcodec/vaapi_encode_h264.c   |   8 +-
 libavfilter/vf_showinfo.c        |  17 +---
 libavformat/imf.h                |  18 +---
 libavformat/imf_cpl.c            |  60 +++++-------
 libavformat/imfdec.c             |  34 +++----
 libavformat/mov.c                |  25 ++---
 libavformat/movenc.c             |   9 +-
 libavformat/smoothstreamingenc.c |   7 +-
 libavformat/tests/imf.c          |  18 ++--
 libavutil/Makefile               |   3 +
 libavutil/tests/.gitignore       |   1 +
 libavutil/tests/uuid.c           | 139 +++++++++++++++++++++++++++
 libavutil/uuid.c                 | 155 +++++++++++++++++++++++++++++++
 libavutil/uuid.h                 | 137 +++++++++++++++++++++++++++
 tests/fate/libavutil.mak         |   5 +
 16 files changed, 525 insertions(+), 114 deletions(-)
 create mode 100644 libavutil/tests/uuid.c
 create mode 100644 libavutil/uuid.c
 create mode 100644 libavutil/uuid.h

-- 
2.35.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH v2 1/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122
  2022-04-24 10:14 [FFmpeg-devel] [PATCH v2 0/7] Add UUID functionality to libavutil Zane van Iperen
@ 2022-04-24 10:14 ` Zane van Iperen
  2022-05-10 13:18   ` Andreas Rheinhardt
  2022-05-11 11:53   ` Anton Khirnov
  2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 2/7] avutil/tests/uuid: add uuid tests Zane van Iperen
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 20+ messages in thread
From: Zane van Iperen @ 2022-04-24 10:14 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Pierre-Anthony Lemieux

Co-authored-by: Pierre-Anthony Lemieux <pal@palemieux.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
---
 libavutil/Makefile |   2 +
 libavutil/uuid.c   | 155 +++++++++++++++++++++++++++++++++++++++++++++
 libavutil/uuid.h   | 137 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 294 insertions(+)
 create mode 100644 libavutil/uuid.c
 create mode 100644 libavutil/uuid.h

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 81df3b0640..29742668b8 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -82,6 +82,7 @@ HEADERS = adler32.h                                                     \
           timestamp.h                                                   \
           tree.h                                                        \
           twofish.h                                                     \
+          uuid.h                                                        \
           version.h                                                     \
           video_enc_params.h                                            \
           xtea.h                                                        \
@@ -174,6 +175,7 @@ OBJS = adler32.o                                                        \
        tx_float.o                                                       \
        tx_double.o                                                      \
        tx_int32.o                                                       \
+       uuid.o                                                           \
        video_enc_params.o                                               \
        film_grain_params.o                                              \
 
diff --git a/libavutil/uuid.c b/libavutil/uuid.c
new file mode 100644
index 0000000000..6cf7a20c23
--- /dev/null
+++ b/libavutil/uuid.c
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2022 Pierre-Anthony Lemieux <pal@palemieux.com>
+ *                    Zane van Iperen <zane@zanevaniperen.com>
+ *
+ * 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
+ */
+
+/*
+ * Copyright (C) 1996, 1997 Theodore Ts'o.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, and the entire permission notice in its entirety,
+ *    including the disclaimer of warranties.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+/**
+ * @file
+ * UUID parsing and serialization utilities.
+ * The library treat the UUID as an opaque sequence of 16 unsigned bytes,
+ * i.e. ignoring the internal layout of the UUID, which depends on the type
+ * of the UUID.
+ *
+ * @author Pierre-Anthony Lemieux <pal@palemieux.com>
+ * @author Zane van Iperen <zane@zanevaniperen.com>
+ */
+
+#include "uuid.h"
+#include "error.h"
+#include "avstring.h"
+#include <stdlib.h>
+#include <string.h>
+
+int av_uuid_parse(const char *in, AVUUID uu)
+{
+    if (strlen(in) != 36)
+        return AVERROR(EINVAL);
+
+    return av_uuid_parse_range(in, in + 36, uu);
+}
+
+int av_uuid_parse_range(const char *in_start, const char *in_end, AVUUID uu)
+{
+    int i;
+    const char *cp;
+    char buf[3];
+
+    if ((in_end - in_start) != 36)
+        return -1;
+
+    for (i = 0, cp = in_start; i < 36; i++, cp++) {
+        if (i == 8 || i == 13 || i == 18 || i == 23) {
+            if (*cp == '-')
+                continue;
+            return AVERROR(EINVAL);
+        }
+
+        if (!av_isxdigit(*cp))
+            return AVERROR(EINVAL);
+    }
+
+    buf[2] = '\0';
+    for (i = 0, cp = in_start; i < 16; i++) {
+        if (i == 4 || i == 6 || i == 8 || i == 10)
+            cp++;
+
+        buf[0] = *cp++;
+        buf[1] = *cp++;
+
+        errno = 0;
+        uu[i] = strtoul(buf, NULL, 16);
+        if (errno)
+            return AVERROR(errno);
+    }
+
+    return 0;
+}
+
+static char const hexdigits_lower[16] = "0123456789abcdef";
+
+void av_uuid_unparse(const AVUUID uuid, char *out)
+{
+    char *p = out;
+
+    for (int i = 0; i < 16; i++) {
+        uint8_t tmp;
+
+        if (i == 4 || i == 6 || i == 8 || i == 10)
+            *p++ = '-';
+
+        tmp = uuid[i];
+        *p++ = hexdigits_lower[tmp >> 4];
+        *p++ = hexdigits_lower[tmp & 15];
+    }
+
+    *p = '\0';
+}
+
+int av_uuid_urn_parse(const char *in, AVUUID uu)
+{
+    if (av_stristr(in, "urn:uuid:") != in)
+        return AVERROR(EINVAL);
+
+    return av_uuid_parse(in + 9, uu);
+}
+
+int av_uuid_equal(const AVUUID uu1, const AVUUID uu2)
+{
+    return memcmp(uu1, uu2, AV_UUID_LEN) == 0;
+}
+
+void av_uuid_copy(AVUUID dest, const AVUUID src)
+{
+    memcpy(dest, src, AV_UUID_LEN);
+}
+
+void av_uuid_nil_set(AVUUID uu)
+{
+    memset(uu, 0, AV_UUID_LEN);
+}
diff --git a/libavutil/uuid.h b/libavutil/uuid.h
new file mode 100644
index 0000000000..d7cd382ec2
--- /dev/null
+++ b/libavutil/uuid.h
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2022 Pierre-Anthony Lemieux <pal@palemieux.com>
+ *                    Zane van Iperen <zane@zanevaniperen.com>
+ *
+ * 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
+ * UUID parsing and serialization utilities.
+ * The library treat the UUID as an opaque sequence of 16 unsigned bytes,
+ * i.e. ignoring the internal layout of the UUID, which depends on the type
+ * of the UUID.
+ *
+ * @author Pierre-Anthony Lemieux <pal@palemieux.com>
+ * @author Zane van Iperen <zane@zanevaniperen.com>
+ */
+
+#ifndef AVUTIL_UUID_H
+#define AVUTIL_UUID_H
+
+#include <stdint.h>
+
+#define AV_PRI_UUID                          \
+    "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-" \
+    "%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
+
+#define AV_PRI_URN_UUID                               \
+    "urn:uuid:%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-" \
+    "%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
+
+/* AV_UUID_ARG() is used together with AV_PRI_UUID() or AV_PRI_URN_UUID
+ * to print UUIDs, e.g.
+ * av_log(NULL, AV_LOG_DEBUG, "UUID: " AV_PRI_UUID, AV_UUID_ARG(uuid));
+ */
+#define AV_UUID_ARG(x)                  \
+    (x)[ 0], (x)[ 1], (x)[ 2], (x)[ 3], \
+    (x)[ 4], (x)[ 5], (x)[ 6], (x)[ 7], \
+    (x)[ 8], (x)[ 9], (x)[10], (x)[11], \
+    (x)[12], (x)[13], (x)[14], (x)[15]
+
+#define AV_UUID_LEN 16
+
+/* Binary representation of a UUID */
+typedef uint8_t AVUUID[AV_UUID_LEN];
+
+/**
+ * Parses a string representation of a UUID formatted according to IETF RFC 4122
+ * into an AVUUID. The parsing is case-insensitive. The string must be 37
+ * characters long, including the terminating NULL character.
+ *
+ * Example string representation: "2fceebd0-7017-433d-bafb-d073a7116696"
+ *
+ * @param[in]  in  String representation of a UUID,
+ *                 e.g. 2fceebd0-7017-433d-bafb-d073a7116696
+ * @param[out] uu  AVUUID
+ * @return         A non-zero value in case of an error.
+ */
+int av_uuid_parse(const char *in, AVUUID uu);
+
+/**
+ * Parses a URN representation of a UUID, as specified at IETF RFC 4122,
+ * into an AVUUID. The parsing is case-insensitive. The string must be 46
+ * characters long, including the terminating NULL character.
+ *
+ * Example string representation: "urn:uuid:2fceebd0-7017-433d-bafb-d073a7116696"
+ *
+ * @param[in]  in  URN UUID
+ * @param[out] uu  AVUUID
+ * @return         A non-zero value in case of an error.
+ */
+int av_uuid_urn_parse(const char *in, AVUUID uu);
+
+/**
+ * Parses a string representation of a UUID formatted according to IETF RFC 4122
+ * into an AVUUID. The parsing is case-insensitive. The string must consist of
+ * 36 characters, i.e. `in_end - in_start == 36`
+ *
+ * @param[in]  in_start Pointer to the first character of the string representation
+ * @param[in]  in_end   Pointer to the character after the last character of the
+ *                      string representation. That memory location is never
+ *                      accessed
+ * @param[out] uu       AVUUID
+ * @return              A non-zero value in case of an error.
+ */
+int av_uuid_parse_range(const char *in_start, const char *in_end, AVUUID uu);
+
+/**
+ * Serializes a AVUUID into a string representation according to IETF RFC 4122.
+ * The string is lowercase and always 37 characters long, including the
+ * terminating NULL character.
+ *
+ * @param[in]  uu  AVUUID
+ * @param[out] out Pointer to a array of no less than 37 characters.
+ * @return         A non-zero value in case of an error.
+ */
+void av_uuid_unparse(const AVUUID uu, char *out);
+
+/**
+ * Compares two UUIDs for equality.
+ *
+ * @param[in]  uu1  AVUUID
+ * @param[in]  uu2  AVUUID
+ * @return          Nonzero if uu1 and uu2 are identical, 0 otherwise
+ */
+int av_uuid_equal(const AVUUID uu1, const AVUUID uu2);
+
+/**
+ * Copies the bytes of src into dest.
+ *
+ * @param[out]  dest  AVUUID
+ * @param[in]   src   AVUUID
+ */
+void av_uuid_copy(AVUUID dest, const AVUUID src);
+
+/**
+ * Sets a UUID to nil
+ *
+ * @param[in,out]  uu  UUID to be set to nil
+ */
+void av_uuid_nil_set(AVUUID uu);
+
+#endif /* AVUTIL_UUID_H */
-- 
2.35.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH v2 2/7] avutil/tests/uuid: add uuid tests
  2022-04-24 10:14 [FFmpeg-devel] [PATCH v2 0/7] Add UUID functionality to libavutil Zane van Iperen
  2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 1/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122 Zane van Iperen
@ 2022-04-24 10:14 ` Zane van Iperen
  2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 3/7] avformat/mov: refactor to use avutil/uuid Zane van Iperen
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Zane van Iperen @ 2022-04-24 10:14 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Pierre-Anthony Lemieux

From: Pierre-Anthony Lemieux <pal@palemieux.com>

---
 libavutil/Makefile         |   1 +
 libavutil/tests/.gitignore |   1 +
 libavutil/tests/uuid.c     | 139 +++++++++++++++++++++++++++++++++++++
 tests/fate/libavutil.mak   |   5 ++
 4 files changed, 146 insertions(+)
 create mode 100644 libavutil/tests/uuid.c

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 29742668b8..fef726b39a 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -260,6 +260,7 @@ TESTPROGS = adler32                                                     \
             tree                                                        \
             twofish                                                     \
             utf8                                                        \
+            uuid                                                        \
             xtea                                                        \
             tea                                                         \
 
diff --git a/libavutil/tests/.gitignore b/libavutil/tests/.gitignore
index 9d90827954..919010e4fc 100644
--- a/libavutil/tests/.gitignore
+++ b/libavutil/tests/.gitignore
@@ -48,4 +48,5 @@
 /tree
 /twofish
 /utf8
+/uuid
 /xtea
diff --git a/libavutil/tests/uuid.c b/libavutil/tests/uuid.c
new file mode 100644
index 0000000000..0a7a0eb07d
--- /dev/null
+++ b/libavutil/tests/uuid.c
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2022 Pierre-Anthony Lemieux <pal@palemieux.com>
+ *                    Zane van Iperen <zane@zanevaniperen.com>
+ *
+ * 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
+ */
+
+#include "libavutil/uuid.h"
+#include "libavutil/log.h"
+
+static const char *UUID_1        = "6021b21e-894e-43ff-8317-1ca891c1c49b";
+static const char *UUID_1_UC     = "6021B21E-894E-43FF-8317-1CA891C1C49B";
+static const char *UUID_1_MIXED  = "6021b21e-894E-43fF-8317-1CA891C1c49b";
+static const char *UUID_1_URN    = "urn:uuid:6021b21e-894e-43ff-8317-1ca891c1c49b";
+static const AVUUID UUID_1_BYTES = {0x60, 0x21, 0xb2, 0x1e, 0x89, 0x4e, 0x43, 0xff,
+                                    0x83, 0x17, 0x1c, 0xa8, 0x91, 0xc1, 0xc4, 0x9b};
+
+static const AVUUID UUID_NIL = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+static const char *UUID_BAD_1 = "16a2c9f8-afbc-4767-8621-8cb2b27599";
+static const char *UUID_BAD_2 = "75df62c2999b4bd38c9d8058fcde9123";
+static const char *UUID_BAD_3 = "a1b9a05e-f1d1-464g-a951-1ba0a374f02";
+static const char *UUID_BAD_4 = "279c66d432-7b39-41d5-966f-5e8138265c20";
+
+int main(int argc, char **argv)
+{
+    AVUUID uuid;
+    AVUUID uuid2 = {0x32, 0xc7, 0x00, 0xc4, 0xd5, 0xd7, 0x42, 0x0,
+                    0x93, 0xc0, 0x3b, 0x6d, 0xea, 0x1b, 0x20, 0x5b};
+
+    /* test parsing */
+
+    if (av_uuid_parse(UUID_1, uuid))
+        return 1;
+
+    if (!av_uuid_equal(uuid, UUID_1_BYTES))
+        return 1;
+
+    /* test nil */
+
+    av_uuid_nil_set(uuid);
+
+    if (!av_uuid_equal(uuid, UUID_NIL))
+        return 1;
+
+    /* test equality */
+
+    if (av_uuid_equal(UUID_1_BYTES, uuid2))
+        return 1;
+
+    /* test copy */
+
+    av_uuid_copy(uuid2, UUID_1_BYTES);
+
+    if (!av_uuid_equal(uuid2, UUID_1_BYTES))
+        return 1;
+
+    /* test uppercase parsing */
+
+    if (av_uuid_parse(UUID_1_UC, uuid))
+        return 1;
+
+    if (!av_uuid_equal(uuid, UUID_1_BYTES))
+        return 1;
+
+    /* test mixed-case parsing */
+
+    if (av_uuid_parse(UUID_1_MIXED, uuid))
+        return 1;
+
+    if (!av_uuid_equal(uuid, UUID_1_BYTES))
+        return 1;
+
+    /* test URN uuid parse */
+
+    if (av_uuid_urn_parse(UUID_1_URN, uuid))
+        return 1;
+
+    if (!av_uuid_equal(uuid, UUID_1_BYTES))
+        return 1;
+
+    /* test parse range */
+
+    if (av_uuid_parse_range(UUID_1_URN + 9, UUID_1_URN + 45, uuid))
+        return 1;
+
+    if (!av_uuid_equal(uuid, UUID_1_BYTES))
+        return 1;
+
+    /* test bad parse range */
+
+    if (!av_uuid_parse_range(UUID_1_URN + 9, UUID_1_URN + 44, uuid))
+        return 1;
+
+    /* test bad parse range 2 */
+
+    if (!av_uuid_parse_range(UUID_1_URN + 8, UUID_1_URN + 44, uuid))
+        return 1;
+
+    /* test bad parse range 2 */
+
+    if (!av_uuid_parse_range(UUID_1_URN + 8, UUID_1_URN + 45, uuid))
+        return 1;
+
+    /* test bad uuid 1 */
+
+    if (!av_uuid_parse(UUID_BAD_1, uuid))
+        return 1;
+
+    /* test bad uuid 2 */
+
+    if (!av_uuid_parse(UUID_BAD_2, uuid))
+        return 1;
+
+    /* test bad uuid 3 */
+
+    if (!av_uuid_parse(UUID_BAD_3, uuid))
+        return 1;
+
+    /* test bad uuid 4 */
+
+    if (!av_uuid_parse(UUID_BAD_4, uuid))
+        return 1;
+}
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index c32cf2e706..80153f4395 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -170,6 +170,11 @@ FATE_LIBAVUTIL += fate-opt
 fate-opt: libavutil/tests/opt$(EXESUF)
 fate-opt: CMD = run libavutil/tests/opt$(EXESUF)
 
+FATE_LIBAVUTIL += fate-uuid
+fate-uuid: libavutil/tests/uuid$(EXESUF)
+fate-uuid: CMD = run libavutil/tests/uuid$(EXESUF)
+fate-uuid: CMP = null
+
 FATE_LIBAVUTIL += $(FATE_LIBAVUTIL-yes)
 FATE-$(CONFIG_AVUTIL) += $(FATE_LIBAVUTIL)
 fate-libavutil: $(FATE_LIBAVUTIL)
-- 
2.35.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH v2 3/7] avformat/mov: refactor to use avutil/uuid
  2022-04-24 10:14 [FFmpeg-devel] [PATCH v2 0/7] Add UUID functionality to libavutil Zane van Iperen
  2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 1/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122 Zane van Iperen
  2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 2/7] avutil/tests/uuid: add uuid tests Zane van Iperen
@ 2022-04-24 10:14 ` Zane van Iperen
  2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 4/7] avformat/smoothstreamingenc: " Zane van Iperen
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Zane van Iperen @ 2022-04-24 10:14 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Pierre-Anthony Lemieux

From: Pierre-Anthony Lemieux <pal@palemieux.com>

---
 libavformat/mov.c    | 25 +++++++++++++------------
 libavformat/movenc.c |  9 +++++----
 2 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 3e83e54a77..cb6b49d98e 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -50,6 +50,7 @@
 #include "libavutil/stereo3d.h"
 #include "libavutil/timecode.h"
 #include "libavutil/dovi_meta.h"
+#include "libavutil/uuid.h"
 #include "libavcodec/ac3tab.h"
 #include "libavcodec/flac.h"
 #include "libavcodec/hevc.h"
@@ -5960,21 +5961,21 @@ static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     AVStream *st;
     MOVStreamContext *sc;
     int64_t ret;
-    uint8_t uuid[16];
-    static const uint8_t uuid_isml_manifest[] = {
+    AVUUID uuid;
+    static const AVUUID uuid_isml_manifest = {
         0xa5, 0xd4, 0x0b, 0x30, 0xe8, 0x14, 0x11, 0xdd,
         0xba, 0x2f, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66
     };
-    static const uint8_t uuid_xmp[] = {
+    static const AVUUID uuid_xmp = {
         0xbe, 0x7a, 0xcf, 0xcb, 0x97, 0xa9, 0x42, 0xe8,
         0x9c, 0x71, 0x99, 0x94, 0x91, 0xe3, 0xaf, 0xac
     };
-    static const uint8_t uuid_spherical[] = {
+    static const AVUUID uuid_spherical = {
         0xff, 0xcc, 0x82, 0x63, 0xf8, 0x55, 0x4a, 0x93,
         0x88, 0x14, 0x58, 0x7a, 0x02, 0x52, 0x1f, 0xdd,
     };
 
-    if (atom.size < sizeof(uuid) || atom.size >= FFMIN(INT_MAX, SIZE_MAX))
+    if (atom.size < AV_UUID_LEN || atom.size >= FFMIN(INT_MAX, SIZE_MAX))
         return AVERROR_INVALIDDATA;
 
     if (c->fc->nb_streams < 1)
@@ -5982,13 +5983,13 @@ static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     st = c->fc->streams[c->fc->nb_streams - 1];
     sc = st->priv_data;
 
-    ret = ffio_read_size(pb, uuid, sizeof(uuid));
+    ret = ffio_read_size(pb, uuid, AV_UUID_LEN);
     if (ret < 0)
         return ret;
-    if (!memcmp(uuid, uuid_isml_manifest, sizeof(uuid))) {
+    if (av_uuid_equal(uuid, uuid_isml_manifest)) {
         uint8_t *buffer, *ptr;
         char *endptr;
-        size_t len = atom.size - sizeof(uuid);
+        size_t len = atom.size - AV_UUID_LEN;
 
         if (len < 4) {
             return AVERROR_INVALIDDATA;
@@ -6026,9 +6027,9 @@ static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         }
 
         av_free(buffer);
-    } else if (!memcmp(uuid, uuid_xmp, sizeof(uuid))) {
+    } else if (av_uuid_equal(uuid, uuid_xmp)) {
         uint8_t *buffer;
-        size_t len = atom.size - sizeof(uuid);
+        size_t len = atom.size - AV_UUID_LEN;
         if (c->export_xmp) {
             buffer = av_mallocz(len + 1);
             if (!buffer) {
@@ -6048,8 +6049,8 @@ static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
             if (ret < 0)
                 return ret;
         }
-    } else if (!memcmp(uuid, uuid_spherical, sizeof(uuid))) {
-        size_t len = atom.size - sizeof(uuid);
+    } else if (av_uuid_equal(uuid, uuid_spherical)) {
+        size_t len = atom.size - AV_UUID_LEN;
         ret = mov_parse_uuid_spherical(sc, pb, len);
         if (ret < 0)
             return ret;
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index b9956e699c..b4de843e49 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -57,6 +57,7 @@
 #include "libavutil/timecode.h"
 #include "libavutil/dovi_meta.h"
 #include "libavutil/color_utils.h"
+#include "libavutil/uuid.h"
 #include "hevc.h"
 #include "rtpenc.h"
 #include "mov_chan.h"
@@ -4319,14 +4320,14 @@ static int mov_write_isml_manifest(AVIOContext *pb, MOVMuxContext *mov, AVFormat
     int64_t pos = avio_tell(pb);
     int i;
 
-    static const uint8_t uuid[] = {
+    static const AVUUID uuid = {
         0xa5, 0xd4, 0x0b, 0x30, 0xe8, 0x14, 0x11, 0xdd,
         0xba, 0x2f, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66
     };
 
     avio_wb32(pb, 0);
     ffio_wfourcc(pb, "uuid");
-    avio_write(pb, uuid, sizeof(uuid));
+    avio_write(pb, uuid, AV_UUID_LEN);
     avio_wb32(pb, 0);
 
     avio_printf(pb, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
@@ -4585,7 +4586,7 @@ static int mov_write_tfxd_tag(AVIOContext *pb, MOVTrack *track)
 
     avio_wb32(pb, 0); /* size placeholder */
     ffio_wfourcc(pb, "uuid");
-    avio_write(pb, uuid, sizeof(uuid));
+    avio_write(pb, uuid, AV_UUID_LEN);
     avio_w8(pb, 1);
     avio_wb24(pb, 0);
     avio_wb64(pb, track->cluster[0].dts + track->cluster[0].cts);
@@ -4611,7 +4612,7 @@ static int mov_write_tfrf_tag(AVIOContext *pb, MOVMuxContext *mov,
     avio_seek(pb, track->frag_info[entry].tfrf_offset, SEEK_SET);
     avio_wb32(pb, size);
     ffio_wfourcc(pb, "uuid");
-    avio_write(pb, uuid, sizeof(uuid));
+    avio_write(pb, uuid, AV_UUID_LEN);
     avio_w8(pb, 1);
     avio_wb24(pb, 0);
     avio_w8(pb, n);
-- 
2.35.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH v2 4/7] avformat/smoothstreamingenc: refactor to use avutil/uuid
  2022-04-24 10:14 [FFmpeg-devel] [PATCH v2 0/7] Add UUID functionality to libavutil Zane van Iperen
                   ` (2 preceding siblings ...)
  2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 3/7] avformat/mov: refactor to use avutil/uuid Zane van Iperen
@ 2022-04-24 10:14 ` Zane van Iperen
  2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 5/7] avcodec/cbs_sei: " Zane van Iperen
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Zane van Iperen @ 2022-04-24 10:14 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Pierre-Anthony Lemieux

From: Pierre-Anthony Lemieux <pal@palemieux.com>

---
 libavformat/smoothstreamingenc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
index c67f0cba43..3d857b932e 100644
--- a/libavformat/smoothstreamingenc.c
+++ b/libavformat/smoothstreamingenc.c
@@ -38,6 +38,7 @@
 #include "libavutil/file.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/uuid.h"
 
 typedef struct Fragment {
     int64_t start_time, duration;
@@ -420,13 +421,13 @@ static int parse_fragment(AVFormatContext *s, const char *filename, int64_t *sta
         if (len < 8 || len >= *moof_size)
             goto fail;
         if (tag == MKTAG('u','u','i','d')) {
-            static const uint8_t tfxd[] = {
+            static const AVUUID tfxd = {
                 0x6d, 0x1d, 0x9b, 0x05, 0x42, 0xd5, 0x44, 0xe6,
                 0x80, 0xe2, 0x14, 0x1d, 0xaf, 0xf7, 0x57, 0xb2
             };
-            uint8_t uuid[16];
+            AVUUID uuid;
             avio_read(in, uuid, 16);
-            if (!memcmp(uuid, tfxd, 16) && len >= 8 + 16 + 4 + 16) {
+            if (av_uuid_equal(uuid, tfxd) && len >= 8 + 16 + 4 + 16) {
                 avio_seek(in, 4, SEEK_CUR);
                 *start_ts = avio_rb64(in);
                 *duration = avio_rb64(in);
-- 
2.35.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH v2 5/7] avcodec/cbs_sei: refactor to use avutil/uuid
  2022-04-24 10:14 [FFmpeg-devel] [PATCH v2 0/7] Add UUID functionality to libavutil Zane van Iperen
                   ` (3 preceding siblings ...)
  2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 4/7] avformat/smoothstreamingenc: " Zane van Iperen
@ 2022-04-24 10:14 ` Zane van Iperen
  2022-04-30 17:31   ` Mark Thompson
  2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 6/7] avformat/imf: " Zane van Iperen
  2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 7/7] avfilter/showinfo: " Zane van Iperen
  6 siblings, 1 reply; 20+ messages in thread
From: Zane van Iperen @ 2022-04-24 10:14 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Pierre-Anthony Lemieux

From: Pierre-Anthony Lemieux <pal@palemieux.com>

---
 libavcodec/cbs_sei.h           | 3 ++-
 libavcodec/vaapi_encode_h264.c | 8 ++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavcodec/cbs_sei.h b/libavcodec/cbs_sei.h
index c7a7a95be0..67c6e6cbbd 100644
--- a/libavcodec/cbs_sei.h
+++ b/libavcodec/cbs_sei.h
@@ -23,6 +23,7 @@
 #include <stdint.h>
 
 #include "libavutil/buffer.h"
+#include "libavutil/uuid.h"
 
 #include "cbs.h"
 #include "sei.h"
@@ -41,7 +42,7 @@ typedef struct SEIRawUserDataRegistered {
 } SEIRawUserDataRegistered;
 
 typedef struct SEIRawUserDataUnregistered {
-    uint8_t      uuid_iso_iec_11578[16];
+    AVUUID      uuid_iso_iec_11578;
     uint8_t     *data;
     AVBufferRef *data_ref;
     size_t       data_length;
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index 7a6b54ab6f..b3105d6ccc 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -25,6 +25,7 @@
 #include "libavutil/common.h"
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"
+#include "libavutil/uuid.h"
 
 #include "avcodec.h"
 #include "cbs.h"
@@ -43,7 +44,7 @@ enum {
 };
 
 // Random (version 4) ISO 11578 UUID.
-static const uint8_t vaapi_encode_h264_sei_identifier_uuid[16] = {
+static const AVUUID vaapi_encode_h264_sei_identifier_uuid = {
     0x59, 0x94, 0x8b, 0x28, 0x11, 0xec, 0x45, 0xaf,
     0x96, 0x75, 0x19, 0xd4, 0x1f, 0xea, 0xa9, 0x4d,
 };
@@ -1089,9 +1090,8 @@ static av_cold int vaapi_encode_h264_configure(AVCodecContext *avctx)
         const char *driver;
         int len;
 
-        memcpy(priv->sei_identifier.uuid_iso_iec_11578,
-               vaapi_encode_h264_sei_identifier_uuid,
-               sizeof(priv->sei_identifier.uuid_iso_iec_11578));
+        av_uuid_copy(priv->sei_identifier.uuid_iso_iec_11578,
+                     vaapi_encode_h264_sei_identifier_uuid);
 
         driver = vaQueryVendorString(ctx->hwctx->display);
         if (!driver)
-- 
2.35.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH v2 6/7] avformat/imf: refactor to use avutil/uuid
  2022-04-24 10:14 [FFmpeg-devel] [PATCH v2 0/7] Add UUID functionality to libavutil Zane van Iperen
                   ` (4 preceding siblings ...)
  2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 5/7] avcodec/cbs_sei: " Zane van Iperen
@ 2022-04-24 10:14 ` Zane van Iperen
  2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 7/7] avfilter/showinfo: " Zane van Iperen
  6 siblings, 0 replies; 20+ messages in thread
From: Zane van Iperen @ 2022-04-24 10:14 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Pierre-Anthony Lemieux

From: Pierre-Anthony Lemieux <pal@palemieux.com>

---
 libavformat/imf.h       | 18 ++++---------
 libavformat/imf_cpl.c   | 60 +++++++++++++++--------------------------
 libavformat/imfdec.c    | 34 +++++++++++------------
 libavformat/tests/imf.c | 18 ++++++-------
 4 files changed, 52 insertions(+), 78 deletions(-)

diff --git a/libavformat/imf.h b/libavformat/imf.h
index 62c4468ce9..4271cd9582 100644
--- a/libavformat/imf.h
+++ b/libavformat/imf.h
@@ -58,17 +58,9 @@
 #include "avformat.h"
 #include "libavformat/avio.h"
 #include "libavutil/rational.h"
+#include "libavutil/uuid.h"
 #include <libxml/tree.h>
 
-#define FF_IMF_UUID_FORMAT                            \
-    "urn:uuid:%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-" \
-    "%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
-
-/**
- * UUID as defined in IETF RFC 422
- */
-typedef uint8_t FFIMFUUID[16];
-
 /**
  * IMF Composition Playlist Base Resource
  */
@@ -84,7 +76,7 @@ typedef struct FFIMFBaseResource {
  */
 typedef struct FFIMFTrackFileResource {
     FFIMFBaseResource base;
-    FFIMFUUID track_file_uuid; /**< TrackFileResourceType/TrackFileId */
+    AVUUID track_file_uuid; /**< TrackFileResourceType/TrackFileId */
 } FFIMFTrackFileResource;
 
 /**
@@ -109,7 +101,7 @@ typedef struct FFIMFMarkerResource {
  * IMF Composition Playlist Virtual Track
  */
 typedef struct FFIMFBaseVirtualTrack {
-    FFIMFUUID id_uuid; /**< TrackId associated with the Virtual Track */
+    AVUUID id_uuid; /**< TrackId associated with the Virtual Track */
 } FFIMFBaseVirtualTrack;
 
 /**
@@ -135,7 +127,7 @@ typedef struct FFIMFMarkerVirtualTrack {
  * IMF Composition Playlist
  */
 typedef struct FFIMFCPL {
-    FFIMFUUID id_uuid;                               /**< CompositionPlaylist/Id element */
+    AVUUID id_uuid;                               /**< CompositionPlaylist/Id element */
     xmlChar *content_title_utf8;                     /**< CompositionPlaylist/ContentTitle element */
     AVRational edit_rate;                            /**< CompositionPlaylist/EditRate element */
     FFIMFMarkerVirtualTrack *main_markers_track;     /**< Main Marker Virtual Track */
@@ -196,7 +188,7 @@ int ff_imf_xml_read_rational(xmlNodePtr element, AVRational *rational);
  * Reads a UUID from an XML element
  * @return 0 on success, < 0 AVERROR code on error.
  */
-int ff_imf_xml_read_uuid(xmlNodePtr element, uint8_t uuid[16]);
+int ff_imf_xml_read_uuid(xmlNodePtr element, AVUUID uuid);
 
 /**
  * Returns the first child element with the specified local name
diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c
index 102a6b4549..c0d43cbfad 100644
--- a/libavformat/imf_cpl.c
+++ b/libavformat/imf_cpl.c
@@ -70,32 +70,14 @@ xmlNodePtr ff_imf_xml_get_child_element_by_name(xmlNodePtr parent, const char *n
     return NULL;
 }
 
-int ff_imf_xml_read_uuid(xmlNodePtr element, uint8_t uuid[16])
+int ff_imf_xml_read_uuid(xmlNodePtr element, AVUUID uuid)
 {
     xmlChar *element_text = NULL;
-    int scanf_ret;
     int ret = 0;
 
     element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1);
-    scanf_ret = sscanf(element_text,
-                       FF_IMF_UUID_FORMAT,
-                       &uuid[0],
-                       &uuid[1],
-                       &uuid[2],
-                       &uuid[3],
-                       &uuid[4],
-                       &uuid[5],
-                       &uuid[6],
-                       &uuid[7],
-                       &uuid[8],
-                       &uuid[9],
-                       &uuid[10],
-                       &uuid[11],
-                       &uuid[12],
-                       &uuid[13],
-                       &uuid[14],
-                       &uuid[15]);
-    if (scanf_ret != 16) {
+    ret = av_uuid_urn_parse(element_text, uuid);
+    if (ret) {
         av_log(NULL, AV_LOG_ERROR, "Invalid UUID\n");
         ret = AVERROR_INVALIDDATA;
     }
@@ -370,7 +352,7 @@ static int fill_marker_resource(xmlNodePtr marker_resource_elem,
 static int push_marker_sequence(xmlNodePtr marker_sequence_elem, FFIMFCPL *cpl)
 {
     int ret = 0;
-    uint8_t uuid[16];
+    AVUUID uuid;
     xmlNodePtr resource_list_elem = NULL;
     xmlNodePtr resource_elem = NULL;
     xmlNodePtr track_id_elem = NULL;
@@ -388,8 +370,8 @@ static int push_marker_sequence(xmlNodePtr marker_sequence_elem, FFIMFCPL *cpl)
     }
     av_log(NULL,
            AV_LOG_DEBUG,
-           "Processing IMF CPL Marker Sequence for Virtual Track " FF_IMF_UUID_FORMAT "\n",
-           UID_ARG(uuid));
+           "Processing IMF CPL Marker Sequence for Virtual Track " AV_PRI_UUID "\n",
+           AV_UUID_ARG(uuid));
 
     /* create main marker virtual track if it does not exist */
     if (!cpl->main_markers_track) {
@@ -397,9 +379,9 @@ static int push_marker_sequence(xmlNodePtr marker_sequence_elem, FFIMFCPL *cpl)
         if (!cpl->main_markers_track)
             return AVERROR(ENOMEM);
         imf_marker_virtual_track_init(cpl->main_markers_track);
-        memcpy(cpl->main_markers_track->base.id_uuid, uuid, sizeof(uuid));
+        av_uuid_copy(cpl->main_markers_track->base.id_uuid, uuid);
 
-    } else if (memcmp(cpl->main_markers_track->base.id_uuid, uuid, sizeof(uuid)) != 0) {
+    } else if (!av_uuid_equal(cpl->main_markers_track->base.id_uuid, uuid)) {
         av_log(NULL, AV_LOG_ERROR, "Multiple marker virtual tracks were found\n");
         return AVERROR_INVALIDDATA;
     }
@@ -457,7 +439,7 @@ static int has_stereo_resources(xmlNodePtr element)
 static int push_main_audio_sequence(xmlNodePtr audio_sequence_elem, FFIMFCPL *cpl)
 {
     int ret = 0;
-    uint8_t uuid[16];
+    AVUUID uuid;
     xmlNodePtr resource_list_elem = NULL;
     xmlNodePtr resource_elem = NULL;
     xmlNodePtr track_id_elem = NULL;
@@ -476,12 +458,12 @@ static int push_main_audio_sequence(xmlNodePtr audio_sequence_elem, FFIMFCPL *cp
     }
     av_log(NULL,
            AV_LOG_DEBUG,
-           "Processing IMF CPL Audio Sequence for Virtual Track " FF_IMF_UUID_FORMAT "\n",
-           UID_ARG(uuid));
+           "Processing IMF CPL Audio Sequence for Virtual Track " AV_PRI_UUID "\n",
+           AV_UUID_ARG(uuid));
 
     /* get the main audio virtual track corresponding to the sequence */
     for (uint32_t i = 0; i < cpl->main_audio_track_count; i++) {
-        if (memcmp(cpl->main_audio_tracks[i].base.id_uuid, uuid, sizeof(uuid)) == 0) {
+        if (av_uuid_equal(cpl->main_audio_tracks[i].base.id_uuid, uuid)) {
             vt = &cpl->main_audio_tracks[i];
             break;
         }
@@ -501,7 +483,7 @@ static int push_main_audio_sequence(xmlNodePtr audio_sequence_elem, FFIMFCPL *cp
         vt = &cpl->main_audio_tracks[cpl->main_audio_track_count];
         imf_trackfile_virtual_track_init(vt);
         cpl->main_audio_track_count++;
-        memcpy(vt->base.id_uuid, uuid, sizeof(uuid));
+        av_uuid_copy(vt->base.id_uuid, uuid);
     }
 
     /* process resources */
@@ -544,7 +526,7 @@ static int push_main_audio_sequence(xmlNodePtr audio_sequence_elem, FFIMFCPL *cp
 static int push_main_image_2d_sequence(xmlNodePtr image_sequence_elem, FFIMFCPL *cpl)
 {
     int ret = 0;
-    uint8_t uuid[16];
+    AVUUID uuid;
     xmlNodePtr resource_list_elem = NULL;
     xmlNodePtr resource_elem = NULL;
     xmlNodePtr track_id_elem = NULL;
@@ -573,16 +555,16 @@ static int push_main_image_2d_sequence(xmlNodePtr image_sequence_elem, FFIMFCPL
         if (!cpl->main_image_2d_track)
             return AVERROR(ENOMEM);
         imf_trackfile_virtual_track_init(cpl->main_image_2d_track);
-        memcpy(cpl->main_image_2d_track->base.id_uuid, uuid, sizeof(uuid));
+        av_uuid_copy(cpl->main_image_2d_track->base.id_uuid, uuid);
 
-    } else if (memcmp(cpl->main_image_2d_track->base.id_uuid, uuid, sizeof(uuid)) != 0) {
+    } else if (!av_uuid_equal(cpl->main_image_2d_track->base.id_uuid, uuid)) {
         av_log(NULL, AV_LOG_ERROR, "Multiple MainImage virtual tracks found\n");
         return AVERROR_INVALIDDATA;
     }
     av_log(NULL,
            AV_LOG_DEBUG,
-           "Processing IMF CPL Main Image Sequence for Virtual Track " FF_IMF_UUID_FORMAT "\n",
-           UID_ARG(uuid));
+           "Processing IMF CPL Main Image Sequence for Virtual Track " AV_PRI_UUID "\n",
+           AV_UUID_ARG(uuid));
 
     /* process resources */
     resource_list_elem = ff_imf_xml_get_child_element_by_name(image_sequence_elem, "ResourceList");
@@ -746,7 +728,7 @@ static void imf_trackfile_virtual_track_free(FFIMFTrackFileVirtualTrack *vt)
 
 static void imf_cpl_init(FFIMFCPL *cpl)
 {
-    memset(cpl->id_uuid, 0, sizeof(cpl->id_uuid));
+    av_uuid_nil_set(cpl->id_uuid);
     cpl->content_title_utf8 = NULL;
     cpl->edit_rate = av_make_q(0, 1);
     cpl->main_markers_track = NULL;
@@ -828,8 +810,8 @@ int ff_imf_parse_cpl(AVIOContext *in, FFIMFCPL **cpl)
                 (*cpl)->content_title_utf8);
         av_log(NULL,
                 AV_LOG_INFO,
-                "IMF CPL Id: " FF_IMF_UUID_FORMAT "\n",
-                UID_ARG((*cpl)->id_uuid));
+                "IMF CPL Id: " AV_PRI_UUID "\n",
+                AV_UUID_ARG((*cpl)->id_uuid));
     }
 
     xmlFreeDoc(doc);
diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c
index 2fe79dfbad..989abe67b7 100644
--- a/libavformat/imfdec.c
+++ b/libavformat/imfdec.c
@@ -82,7 +82,7 @@
  * IMF Asset locator
  */
 typedef struct IMFAssetLocator {
-    FFIMFUUID uuid;
+    AVUUID uuid;
     char *absolute_uri;
 } IMFAssetLocator;
 
@@ -238,7 +238,7 @@ static int parse_imf_asset_map_from_xml_dom(AVFormatContext *s,
             return AVERROR_INVALIDDATA;
         }
 
-        av_log(s, AV_LOG_DEBUG, "Found asset id: " FF_IMF_UUID_FORMAT "\n", UID_ARG(asset->uuid));
+        av_log(s, AV_LOG_DEBUG, "Found asset id: " AV_PRI_URN_UUID "\n", AV_UUID_ARG(asset->uuid));
 
         if (!(node = ff_imf_xml_get_child_element_by_name(asset_element, "ChunkList"))) {
             av_log(s, AV_LOG_ERROR, "Unable to parse asset map XML - missing ChunkList node\n");
@@ -343,7 +343,7 @@ clean_up:
     return ret;
 }
 
-static IMFAssetLocator *find_asset_map_locator(IMFAssetLocatorMap *asset_map, FFIMFUUID uuid)
+static IMFAssetLocator *find_asset_map_locator(IMFAssetLocatorMap *asset_map, AVUUID uuid)
 {
     for (uint32_t i = 0; i < asset_map->asset_count; i++) {
         if (memcmp(asset_map->assets[i].uuid, uuid, 16) == 0)
@@ -453,15 +453,15 @@ static int open_track_file_resource(AVFormatContext *s,
 
     asset_locator = find_asset_map_locator(&c->asset_locator_map, track_file_resource->track_file_uuid);
     if (!asset_locator) {
-        av_log(s, AV_LOG_ERROR, "Could not find asset locator for UUID: " FF_IMF_UUID_FORMAT "\n",
-               UID_ARG(track_file_resource->track_file_uuid));
+        av_log(s, AV_LOG_ERROR, "Could not find asset locator for UUID: " AV_PRI_URN_UUID "\n",
+               AV_UUID_ARG(track_file_resource->track_file_uuid));
         return AVERROR_INVALIDDATA;
     }
 
     av_log(s,
            AV_LOG_DEBUG,
-           "Found locator for " FF_IMF_UUID_FORMAT ": %s\n",
-           UID_ARG(asset_locator->uuid),
+           "Found locator for " AV_PRI_URN_UUID ": %s\n",
+           AV_UUID_ARG(asset_locator->uuid),
            asset_locator->absolute_uri);
 
     if (track->resource_count > INT32_MAX - track_file_resource->base.repeat_count
@@ -523,14 +523,14 @@ static int open_virtual_track(AVFormatContext *s,
     for (uint32_t i = 0; i < virtual_track->resource_count; i++) {
         av_log(s,
                AV_LOG_DEBUG,
-               "Open stream from file " FF_IMF_UUID_FORMAT ", stream %d\n",
-               UID_ARG(virtual_track->resources[i].track_file_uuid),
+               "Open stream from file " AV_PRI_URN_UUID ", stream %d\n",
+               AV_UUID_ARG(virtual_track->resources[i].track_file_uuid),
                i);
         if ((ret = open_track_file_resource(s, &virtual_track->resources[i], track)) != 0) {
             av_log(s,
                    AV_LOG_ERROR,
-                   "Could not open image track resource " FF_IMF_UUID_FORMAT "\n",
-                   UID_ARG(virtual_track->resources[i].track_file_uuid));
+                   "Could not open image track resource " AV_PRI_URN_UUID "\n",
+                   AV_UUID_ARG(virtual_track->resources[i].track_file_uuid));
             goto clean_up;
         }
     }
@@ -604,16 +604,16 @@ static int open_cpl_tracks(AVFormatContext *s)
 
     if (c->cpl->main_image_2d_track) {
         if ((ret = open_virtual_track(s, c->cpl->main_image_2d_track, track_index++)) != 0) {
-            av_log(s, AV_LOG_ERROR, "Could not open image track " FF_IMF_UUID_FORMAT "\n",
-                   UID_ARG(c->cpl->main_image_2d_track->base.id_uuid));
+            av_log(s, AV_LOG_ERROR, "Could not open image track " AV_PRI_URN_UUID "\n",
+                   AV_UUID_ARG(c->cpl->main_image_2d_track->base.id_uuid));
             return ret;
         }
     }
 
     for (uint32_t i = 0; i < c->cpl->main_audio_track_count; i++) {
         if ((ret = open_virtual_track(s, &c->cpl->main_audio_tracks[i], track_index++)) != 0) {
-            av_log(s, AV_LOG_ERROR, "Could not open audio track " FF_IMF_UUID_FORMAT "\n",
-                   UID_ARG(c->cpl->main_audio_tracks[i].base.id_uuid));
+            av_log(s, AV_LOG_ERROR, "Could not open audio track " AV_PRI_URN_UUID "\n",
+                   AV_UUID_ARG(c->cpl->main_audio_tracks[i].base.id_uuid));
             return ret;
         }
     }
@@ -647,8 +647,8 @@ static int imf_read_header(AVFormatContext *s)
 
     av_log(s,
            AV_LOG_DEBUG,
-           "parsed IMF CPL: " FF_IMF_UUID_FORMAT "\n",
-           UID_ARG(c->cpl->id_uuid));
+           "parsed IMF CPL: " AV_PRI_URN_UUID "\n",
+           AV_UUID_ARG(c->cpl->id_uuid));
 
     if (!c->asset_map_paths) {
         c->asset_map_paths = av_append_path_component(c->base_url, "ASSETMAP.xml");
diff --git a/libavformat/tests/imf.c b/libavformat/tests/imf.c
index 142aa04261..e65629ccbc 100644
--- a/libavformat/tests/imf.c
+++ b/libavformat/tests/imf.c
@@ -304,7 +304,7 @@ static int test_cpl_parsing(void)
     }
 
     printf("%s\n", cpl->content_title_utf8);
-    printf(FF_IMF_UUID_FORMAT "\n", UID_ARG(cpl->id_uuid));
+    printf(AV_PRI_URN_UUID "\n", AV_UUID_ARG(cpl->id_uuid));
     printf("%i %i\n", cpl->edit_rate.num, cpl->edit_rate.den);
 
     printf("Marker resource count: %" PRIu32 "\n", cpl->main_markers_track->resource_count);
@@ -320,7 +320,7 @@ static int test_cpl_parsing(void)
     printf("Main image resource count: %" PRIu32 "\n", cpl->main_image_2d_track->resource_count);
     for (uint32_t i = 0; i < cpl->main_image_2d_track->resource_count; i++) {
         printf("Track file resource %" PRIu32 "\n", i);
-        printf("  " FF_IMF_UUID_FORMAT "\n", UID_ARG(cpl->main_image_2d_track->resources[i].track_file_uuid));
+        printf("  " AV_PRI_URN_UUID "\n", AV_UUID_ARG(cpl->main_image_2d_track->resources[i].track_file_uuid));
     }
 
     printf("Main audio track count: %" PRIu32 "\n", cpl->main_audio_track_count);
@@ -329,7 +329,7 @@ static int test_cpl_parsing(void)
         printf("  Main audio resource count: %" PRIu32 "\n", cpl->main_audio_tracks[i].resource_count);
         for (uint32_t j = 0; j < cpl->main_audio_tracks[i].resource_count; j++) {
             printf("  Track file resource %" PRIu32 "\n", j);
-            printf("    " FF_IMF_UUID_FORMAT "\n", UID_ARG(cpl->main_audio_tracks[i].resources[j].track_file_uuid));
+            printf("    " AV_PRI_URN_UUID "\n", AV_UUID_ARG(cpl->main_audio_tracks[i].resources[j].track_file_uuid));
         }
     }
 
@@ -363,15 +363,15 @@ static int test_bad_cpl_parsing(void)
 static int check_asset_locator_attributes(IMFAssetLocator *asset, IMFAssetLocator *expected_asset)
 {
 
-    printf("\tCompare " FF_IMF_UUID_FORMAT " to " FF_IMF_UUID_FORMAT ".\n",
-           UID_ARG(asset->uuid),
-           UID_ARG(expected_asset->uuid));
+    printf("\tCompare " AV_PRI_URN_UUID " to " AV_PRI_URN_UUID ".\n",
+           AV_UUID_ARG(asset->uuid),
+           AV_UUID_ARG(expected_asset->uuid));
 
     for (uint32_t i = 0; i < 16; ++i) {
         if (asset->uuid[i] != expected_asset->uuid[i]) {
-            printf("Invalid asset locator UUID: found " FF_IMF_UUID_FORMAT " instead of " FF_IMF_UUID_FORMAT " expected.\n",
-                   UID_ARG(asset->uuid),
-                   UID_ARG(expected_asset->uuid));
+            printf("Invalid asset locator UUID: found " AV_PRI_URN_UUID " instead of " AV_PRI_URN_UUID " expected.\n",
+                   AV_UUID_ARG(asset->uuid),
+                   AV_UUID_ARG(expected_asset->uuid));
             return 1;
         }
     }
-- 
2.35.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [FFmpeg-devel] [PATCH v2 7/7] avfilter/showinfo: refactor to use avutil/uuid
  2022-04-24 10:14 [FFmpeg-devel] [PATCH v2 0/7] Add UUID functionality to libavutil Zane van Iperen
                   ` (5 preceding siblings ...)
  2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 6/7] avformat/imf: " Zane van Iperen
@ 2022-04-24 10:14 ` Zane van Iperen
  6 siblings, 0 replies; 20+ messages in thread
From: Zane van Iperen @ 2022-04-24 10:14 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Pierre-Anthony Lemieux

From: Pierre-Anthony Lemieux <pal@palemieux.com>

---
 libavfilter/vf_showinfo.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 12d39310ef..0d6f2805bb 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -42,6 +42,7 @@
 #include "libavutil/mastering_display_metadata.h"
 #include "libavutil/video_enc_params.h"
 #include "libavutil/detection_bbox.h"
+#include "libavutil/uuid.h"
 
 #include "avfilter.h"
 #include "internal.h"
@@ -421,29 +422,21 @@ static void dump_video_enc_params(AVFilterContext *ctx, const AVFrameSideData *s
 
 static void dump_sei_unregistered_metadata(AVFilterContext *ctx, const AVFrameSideData *sd)
 {
-    const int uuid_size = 16;
     const uint8_t *user_data = sd->data;
     int i;
 
-    if (sd->size < uuid_size) {
+    if (sd->size < AV_UUID_LEN) {
         av_log(ctx, AV_LOG_ERROR, "invalid data(%"SIZE_SPECIFIER" < "
-               "UUID(%d-bytes))\n", sd->size, uuid_size);
+               "UUID(%d-bytes))\n", sd->size, AV_UUID_LEN);
         return;
     }
 
     av_log(ctx, AV_LOG_INFO, "User Data Unregistered:\n");
-    av_log(ctx, AV_LOG_INFO, "UUID=");
-    for (i = 0; i < uuid_size; i++) {
-        av_log(ctx, AV_LOG_INFO, "%02x", user_data[i]);
-        if (i == 3 || i == 5 || i == 7 || i == 9)
-            av_log(ctx, AV_LOG_INFO, "-");
-    }
-    av_log(ctx, AV_LOG_INFO, "\n");
+    av_log(ctx, AV_LOG_INFO, "UUID=" AV_PRI_UUID "\n", AV_UUID_ARG(user_data));
 
     av_log(ctx, AV_LOG_INFO, "User Data=");
-    for (; i < sd->size; i++) {
+    for (i = 16; i < sd->size; i++)
         av_log(ctx, AV_LOG_INFO, "%02x", user_data[i]);
-    }
     av_log(ctx, AV_LOG_INFO, "\n");
 }
 
-- 
2.35.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 5/7] avcodec/cbs_sei: refactor to use avutil/uuid
  2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 5/7] avcodec/cbs_sei: " Zane van Iperen
@ 2022-04-30 17:31   ` Mark Thompson
  2022-04-30 17:53     ` Pierre-Anthony Lemieux
  0 siblings, 1 reply; 20+ messages in thread
From: Mark Thompson @ 2022-04-30 17:31 UTC (permalink / raw)
  To: ffmpeg-devel

On 24/04/2022 11:14, Zane van Iperen wrote:
> From: Pierre-Anthony Lemieux <pal@palemieux.com>
> 
> ---
>   libavcodec/cbs_sei.h           | 3 ++-
>   libavcodec/vaapi_encode_h264.c | 8 ++++----
>   2 files changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/cbs_sei.h b/libavcodec/cbs_sei.h
> index c7a7a95be0..67c6e6cbbd 100644
> --- a/libavcodec/cbs_sei.h
> +++ b/libavcodec/cbs_sei.h
> @@ -23,6 +23,7 @@
>   #include <stdint.h>
>   
>   #include "libavutil/buffer.h"
> +#include "libavutil/uuid.h"
>   
>   #include "cbs.h"
>   #include "sei.h"
> @@ -41,7 +42,7 @@ typedef struct SEIRawUserDataRegistered {
>   } SEIRawUserDataRegistered;
>   
>   typedef struct SEIRawUserDataUnregistered {
> -    uint8_t      uuid_iso_iec_11578[16];
> +    AVUUID      uuid_iso_iec_11578;
>       uint8_t     *data;
>       AVBufferRef *data_ref;
>       size_t       data_length;

This feels like a step backwards?  The syntax template files are explicitly relying on this being uint8_t[16], so giving it a different name is confusing.

> diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
> index 7a6b54ab6f..b3105d6ccc 100644
> --- a/libavcodec/vaapi_encode_h264.c
> +++ b/libavcodec/vaapi_encode_h264.c
> @@ -25,6 +25,7 @@
>   #include "libavutil/common.h"
>   #include "libavutil/internal.h"
>   #include "libavutil/opt.h"
> +#include "libavutil/uuid.h"
>   
>   #include "avcodec.h"
>   #include "cbs.h"
> @@ -43,7 +44,7 @@ enum {
>   };
>   
>   // Random (version 4) ISO 11578 UUID.
> -static const uint8_t vaapi_encode_h264_sei_identifier_uuid[16] = {
> +static const AVUUID vaapi_encode_h264_sei_identifier_uuid = {
>       0x59, 0x94, 0x8b, 0x28, 0x11, 0xec, 0x45, 0xaf,
>       0x96, 0x75, 0x19, 0xd4, 0x1f, 0xea, 0xa9, 0x4d,
>   };
> @@ -1089,9 +1090,8 @@ static av_cold int vaapi_encode_h264_configure(AVCodecContext *avctx)
>           const char *driver;
>           int len;
>   
> -        memcpy(priv->sei_identifier.uuid_iso_iec_11578,
> -               vaapi_encode_h264_sei_identifier_uuid,
> -               sizeof(priv->sei_identifier.uuid_iso_iec_11578));
> +        av_uuid_copy(priv->sei_identifier.uuid_iso_iec_11578,
> +                     vaapi_encode_h264_sei_identifier_uuid);
>   
>           driver = vaQueryVendorString(ctx->hwctx->display);
>           if (!driver)

This is fair.

- Mark
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 5/7] avcodec/cbs_sei: refactor to use avutil/uuid
  2022-04-30 17:31   ` Mark Thompson
@ 2022-04-30 17:53     ` Pierre-Anthony Lemieux
  2022-04-30 19:25       ` Mark Thompson
  0 siblings, 1 reply; 20+ messages in thread
From: Pierre-Anthony Lemieux @ 2022-04-30 17:53 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Sat, Apr 30, 2022 at 10:31 AM Mark Thompson <sw@jkqxz.net> wrote:
>
> On 24/04/2022 11:14, Zane van Iperen wrote:
> > From: Pierre-Anthony Lemieux <pal@palemieux.com>
> >
> > ---
> >   libavcodec/cbs_sei.h           | 3 ++-
> >   libavcodec/vaapi_encode_h264.c | 8 ++++----
> >   2 files changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/libavcodec/cbs_sei.h b/libavcodec/cbs_sei.h
> > index c7a7a95be0..67c6e6cbbd 100644
> > --- a/libavcodec/cbs_sei.h
> > +++ b/libavcodec/cbs_sei.h
> > @@ -23,6 +23,7 @@
> >   #include <stdint.h>
> >
> >   #include "libavutil/buffer.h"
> > +#include "libavutil/uuid.h"
> >
> >   #include "cbs.h"
> >   #include "sei.h"
> > @@ -41,7 +42,7 @@ typedef struct SEIRawUserDataRegistered {
> >   } SEIRawUserDataRegistered;
> >
> >   typedef struct SEIRawUserDataUnregistered {
> > -    uint8_t      uuid_iso_iec_11578[16];
> > +    AVUUID      uuid_iso_iec_11578;
> >       uint8_t     *data;
> >       AVBufferRef *data_ref;
> >       size_t       data_length;
>
> This feels like a step backwards?  The syntax template files are explicitly relying on this being uint8_t[16], so giving it a different name is confusing.

What/where are the syntax template files?

>
> > diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
> > index 7a6b54ab6f..b3105d6ccc 100644
> > --- a/libavcodec/vaapi_encode_h264.c
> > +++ b/libavcodec/vaapi_encode_h264.c
> > @@ -25,6 +25,7 @@
> >   #include "libavutil/common.h"
> >   #include "libavutil/internal.h"
> >   #include "libavutil/opt.h"
> > +#include "libavutil/uuid.h"
> >
> >   #include "avcodec.h"
> >   #include "cbs.h"
> > @@ -43,7 +44,7 @@ enum {
> >   };
> >
> >   // Random (version 4) ISO 11578 UUID.
> > -static const uint8_t vaapi_encode_h264_sei_identifier_uuid[16] = {
> > +static const AVUUID vaapi_encode_h264_sei_identifier_uuid = {
> >       0x59, 0x94, 0x8b, 0x28, 0x11, 0xec, 0x45, 0xaf,
> >       0x96, 0x75, 0x19, 0xd4, 0x1f, 0xea, 0xa9, 0x4d,
> >   };
> > @@ -1089,9 +1090,8 @@ static av_cold int vaapi_encode_h264_configure(AVCodecContext *avctx)
> >           const char *driver;
> >           int len;
> >
> > -        memcpy(priv->sei_identifier.uuid_iso_iec_11578,
> > -               vaapi_encode_h264_sei_identifier_uuid,
> > -               sizeof(priv->sei_identifier.uuid_iso_iec_11578));
> > +        av_uuid_copy(priv->sei_identifier.uuid_iso_iec_11578,
> > +                     vaapi_encode_h264_sei_identifier_uuid);
> >
> >           driver = vaQueryVendorString(ctx->hwctx->display);
> >           if (!driver)
>
> This is fair.
>
> - Mark
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 5/7] avcodec/cbs_sei: refactor to use avutil/uuid
  2022-04-30 17:53     ` Pierre-Anthony Lemieux
@ 2022-04-30 19:25       ` Mark Thompson
  2022-04-30 20:53         ` Pierre-Anthony Lemieux
  0 siblings, 1 reply; 20+ messages in thread
From: Mark Thompson @ 2022-04-30 19:25 UTC (permalink / raw)
  To: ffmpeg-devel

On 30/04/2022 18:53, Pierre-Anthony Lemieux wrote:
> On Sat, Apr 30, 2022 at 10:31 AM Mark Thompson <sw@jkqxz.net> wrote:
>>
>> On 24/04/2022 11:14, Zane van Iperen wrote:
>>> From: Pierre-Anthony Lemieux <pal@palemieux.com>
>>>
>>> ---
>>>    libavcodec/cbs_sei.h           | 3 ++-
>>>    libavcodec/vaapi_encode_h264.c | 8 ++++----
>>>    2 files changed, 6 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/libavcodec/cbs_sei.h b/libavcodec/cbs_sei.h
>>> index c7a7a95be0..67c6e6cbbd 100644
>>> --- a/libavcodec/cbs_sei.h
>>> +++ b/libavcodec/cbs_sei.h
>>> @@ -23,6 +23,7 @@
>>>    #include <stdint.h>
>>>
>>>    #include "libavutil/buffer.h"
>>> +#include "libavutil/uuid.h"
>>>
>>>    #include "cbs.h"
>>>    #include "sei.h"
>>> @@ -41,7 +42,7 @@ typedef struct SEIRawUserDataRegistered {
>>>    } SEIRawUserDataRegistered;
>>>
>>>    typedef struct SEIRawUserDataUnregistered {
>>> -    uint8_t      uuid_iso_iec_11578[16];
>>> +    AVUUID      uuid_iso_iec_11578;
>>>        uint8_t     *data;
>>>        AVBufferRef *data_ref;
>>>        size_t       data_length;
>>
>> This feels like a step backwards?  The syntax template files are explicitly relying on this being uint8_t[16], so giving it a different name is confusing.
> 
> What/where are the syntax template files?

<http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavcodec/cbs_sei_syntax_template.c#l87>

(It's included twice by cbs_h2645.c for read/write with different macro setups.)

- Mark
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 5/7] avcodec/cbs_sei: refactor to use avutil/uuid
  2022-04-30 19:25       ` Mark Thompson
@ 2022-04-30 20:53         ` Pierre-Anthony Lemieux
  2022-05-01 21:06           ` Mark Thompson
  0 siblings, 1 reply; 20+ messages in thread
From: Pierre-Anthony Lemieux @ 2022-04-30 20:53 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Sat, Apr 30, 2022 at 12:26 PM Mark Thompson <sw@jkqxz.net> wrote:
>
> On 30/04/2022 18:53, Pierre-Anthony Lemieux wrote:
> > On Sat, Apr 30, 2022 at 10:31 AM Mark Thompson <sw@jkqxz.net> wrote:
> >>
> >> On 24/04/2022 11:14, Zane van Iperen wrote:
> >>> From: Pierre-Anthony Lemieux <pal@palemieux.com>
> >>>
> >>> ---
> >>>    libavcodec/cbs_sei.h           | 3 ++-
> >>>    libavcodec/vaapi_encode_h264.c | 8 ++++----
> >>>    2 files changed, 6 insertions(+), 5 deletions(-)
> >>>
> >>> diff --git a/libavcodec/cbs_sei.h b/libavcodec/cbs_sei.h
> >>> index c7a7a95be0..67c6e6cbbd 100644
> >>> --- a/libavcodec/cbs_sei.h
> >>> +++ b/libavcodec/cbs_sei.h
> >>> @@ -23,6 +23,7 @@
> >>>    #include <stdint.h>
> >>>
> >>>    #include "libavutil/buffer.h"
> >>> +#include "libavutil/uuid.h"
> >>>
> >>>    #include "cbs.h"
> >>>    #include "sei.h"
> >>> @@ -41,7 +42,7 @@ typedef struct SEIRawUserDataRegistered {
> >>>    } SEIRawUserDataRegistered;
> >>>
> >>>    typedef struct SEIRawUserDataUnregistered {
> >>> -    uint8_t      uuid_iso_iec_11578[16];
> >>> +    AVUUID      uuid_iso_iec_11578;
> >>>        uint8_t     *data;
> >>>        AVBufferRef *data_ref;
> >>>        size_t       data_length;
> >>
> >> This feels like a step backwards?  The syntax template files are explicitly relying on this being uint8_t[16], so giving it a different name is confusing.
> >
> > What/where are the syntax template files?
>
> <http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavcodec/cbs_sei_syntax_template.c#l87>
>
> (It's included twice by cbs_h2645.c for read/write with different macro setups.)

Ok. Thanks. Are you concerned that the following line assumes that
uuid_iso_iec_11578 is uint8_t[16] instead of being the opaque AVUUID?

us(8, uuid_iso_iec_11578[i], 0x00, 0xff, 1, i);

Did I get this right? If so, couple of options come to mind:

(a) revert the change
(b) define a macro to access individual bytes of AVUUID, thereby
keeping AVUUID opaque
(c) not handle AVUUID as opaque, but instead always as uint8_t[16]

Maybe additional options exist.

I do not have a definitive opinion. Some folks expressed strong
interest in having a consistent scheme for manipulating UUIDs.

>
> - Mark
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 5/7] avcodec/cbs_sei: refactor to use avutil/uuid
  2022-04-30 20:53         ` Pierre-Anthony Lemieux
@ 2022-05-01 21:06           ` Mark Thompson
  2022-05-04 16:21             ` Zane van Iperen
  0 siblings, 1 reply; 20+ messages in thread
From: Mark Thompson @ 2022-05-01 21:06 UTC (permalink / raw)
  To: ffmpeg-devel

On 30/04/2022 21:53, Pierre-Anthony Lemieux wrote:
> On Sat, Apr 30, 2022 at 12:26 PM Mark Thompson <sw@jkqxz.net> wrote:
>>
>> On 30/04/2022 18:53, Pierre-Anthony Lemieux wrote:
>>> On Sat, Apr 30, 2022 at 10:31 AM Mark Thompson <sw@jkqxz.net> wrote:
>>>>
>>>> On 24/04/2022 11:14, Zane van Iperen wrote:
>>>>> From: Pierre-Anthony Lemieux <pal@palemieux.com>
>>>>>
>>>>> ---
>>>>>     libavcodec/cbs_sei.h           | 3 ++-
>>>>>     libavcodec/vaapi_encode_h264.c | 8 ++++----
>>>>>     2 files changed, 6 insertions(+), 5 deletions(-)
>>>>>
>>>>> diff --git a/libavcodec/cbs_sei.h b/libavcodec/cbs_sei.h
>>>>> index c7a7a95be0..67c6e6cbbd 100644
>>>>> --- a/libavcodec/cbs_sei.h
>>>>> +++ b/libavcodec/cbs_sei.h
>>>>> @@ -23,6 +23,7 @@
>>>>>     #include <stdint.h>
>>>>>
>>>>>     #include "libavutil/buffer.h"
>>>>> +#include "libavutil/uuid.h"
>>>>>
>>>>>     #include "cbs.h"
>>>>>     #include "sei.h"
>>>>> @@ -41,7 +42,7 @@ typedef struct SEIRawUserDataRegistered {
>>>>>     } SEIRawUserDataRegistered;
>>>>>
>>>>>     typedef struct SEIRawUserDataUnregistered {
>>>>> -    uint8_t      uuid_iso_iec_11578[16];
>>>>> +    AVUUID      uuid_iso_iec_11578;
>>>>>         uint8_t     *data;
>>>>>         AVBufferRef *data_ref;
>>>>>         size_t       data_length;
>>>>
>>>> This feels like a step backwards?  The syntax template files are explicitly relying on this being uint8_t[16], so giving it a different name is confusing.
>>>
>>> What/where are the syntax template files?
>>
>> <http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavcodec/cbs_sei_syntax_template.c#l87>
>>
>> (It's included twice by cbs_h2645.c for read/write with different macro setups.)
> 
> Ok. Thanks. Are you concerned that the following line assumes that
> uuid_iso_iec_11578 is uint8_t[16] instead of being the opaque AVUUID?
> 
> us(8, uuid_iso_iec_11578[i], 0x00, 0xff, 1, i);

Yes.

> Did I get this right? If so, couple of options come to mind:
> 
> (a) revert the change
> (b) define a macro to access individual bytes of AVUUID, thereby
> keeping AVUUID opaque
> (c) not handle AVUUID as opaque, but instead always as uint8_t[16]
> 
> Maybe additional options exist.
> 
> I do not have a definitive opinion. Some folks expressed strong
> interest in having a consistent scheme for manipulating UUIDs.

I think for now the simplest option is just not to change the CBS header, which is completely fine with your current patch set.

Thanks,

- Mark
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 5/7] avcodec/cbs_sei: refactor to use avutil/uuid
  2022-05-01 21:06           ` Mark Thompson
@ 2022-05-04 16:21             ` Zane van Iperen
  0 siblings, 0 replies; 20+ messages in thread
From: Zane van Iperen @ 2022-05-04 16:21 UTC (permalink / raw)
  To: ffmpeg-devel



On 2/5/22 07:06, Mark Thompson wrote:

>> Maybe additional options exist.
>>
>> I do not have a definitive opinion. Some folks expressed strong
>> interest in having a consistent scheme for manipulating UUIDs.
> 
> I think for now the simplest option is just not to change the CBS header, which is completely fine with your current patch set.
> 

Okay, I'll drop the header changes from the patch set.

Zane
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 1/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122
  2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 1/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122 Zane van Iperen
@ 2022-05-10 13:18   ` Andreas Rheinhardt
  2022-05-11 15:02     ` Zane van Iperen
  2022-05-11 11:53   ` Anton Khirnov
  1 sibling, 1 reply; 20+ messages in thread
From: Andreas Rheinhardt @ 2022-05-10 13:18 UTC (permalink / raw)
  To: ffmpeg-devel

Zane van Iperen:
> Co-authored-by: Pierre-Anthony Lemieux <pal@palemieux.com>
> Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
> ---
>  libavutil/Makefile |   2 +
>  libavutil/uuid.c   | 155 +++++++++++++++++++++++++++++++++++++++++++++
>  libavutil/uuid.h   | 137 +++++++++++++++++++++++++++++++++++++++
>  3 files changed, 294 insertions(+)
>  create mode 100644 libavutil/uuid.c
>  create mode 100644 libavutil/uuid.h
> 
> diff --git a/libavutil/Makefile b/libavutil/Makefile
> index 81df3b0640..29742668b8 100644
> --- a/libavutil/Makefile
> +++ b/libavutil/Makefile
> @@ -82,6 +82,7 @@ HEADERS = adler32.h                                                     \
>            timestamp.h                                                   \
>            tree.h                                                        \
>            twofish.h                                                     \
> +          uuid.h                                                        \
>            version.h                                                     \
>            video_enc_params.h                                            \
>            xtea.h                                                        \
> @@ -174,6 +175,7 @@ OBJS = adler32.o                                                        \
>         tx_float.o                                                       \
>         tx_double.o                                                      \
>         tx_int32.o                                                       \
> +       uuid.o                                                           \
>         video_enc_params.o                                               \
>         film_grain_params.o                                              \
>  
> diff --git a/libavutil/uuid.c b/libavutil/uuid.c
> new file mode 100644
> index 0000000000..6cf7a20c23
> --- /dev/null
> +++ b/libavutil/uuid.c
> @@ -0,0 +1,155 @@
> +/*
> + * Copyright (c) 2022 Pierre-Anthony Lemieux <pal@palemieux.com>
> + *                    Zane van Iperen <zane@zanevaniperen.com>
> + *
> + * 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
> + */
> +
> +/*
> + * Copyright (C) 1996, 1997 Theodore Ts'o.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + *    notice, and the entire permission notice in its entirety,
> + *    including the disclaimer of warranties.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *    notice, this list of conditions and the following disclaimer in the
> + *    documentation and/or other materials provided with the distribution.
> + * 3. The name of the author may not be used to endorse or promote
> + *    products derived from this software without specific prior
> + *    written permission.
> + *
> + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
> + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
> + * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
> + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
> + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
> + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
> + * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
> + * DAMAGE.
> + */
> +
> +/**
> + * @file
> + * UUID parsing and serialization utilities.
> + * The library treat the UUID as an opaque sequence of 16 unsigned bytes,
> + * i.e. ignoring the internal layout of the UUID, which depends on the type
> + * of the UUID.
> + *
> + * @author Pierre-Anthony Lemieux <pal@palemieux.com>
> + * @author Zane van Iperen <zane@zanevaniperen.com>
> + */
> +
> +#include "uuid.h"
> +#include "error.h"
> +#include "avstring.h"
> +#include <stdlib.h>
> +#include <string.h>
> +
> +int av_uuid_parse(const char *in, AVUUID uu)
> +{
> +    if (strlen(in) != 36)
> +        return AVERROR(EINVAL);
> +
> +    return av_uuid_parse_range(in, in + 36, uu);
> +}
> +
> +int av_uuid_parse_range(const char *in_start, const char *in_end, AVUUID uu)
> +{
> +    int i;
> +    const char *cp;
> +    char buf[3];
> +
> +    if ((in_end - in_start) != 36)
> +        return -1;
> +
> +    for (i = 0, cp = in_start; i < 36; i++, cp++) {
> +        if (i == 8 || i == 13 || i == 18 || i == 23) {
> +            if (*cp == '-')
> +                continue;
> +            return AVERROR(EINVAL);
> +        }
> +
> +        if (!av_isxdigit(*cp))
> +            return AVERROR(EINVAL);
> +    }
> +
> +    buf[2] = '\0';
> +    for (i = 0, cp = in_start; i < 16; i++) {
> +        if (i == 4 || i == 6 || i == 8 || i == 10)
> +            cp++;
> +
> +        buf[0] = *cp++;
> +        buf[1] = *cp++;
> +
> +        errno = 0;
> +        uu[i] = strtoul(buf, NULL, 16);
> +        if (errno)
> +            return AVERROR(errno);

How could this ever happen given that you have already checked that the
buffer only contains hex digits? And isn't using strtoul a bit overkill
anyway? I'd just check and parse this stuff in one loop.

> +    }
> +
> +    return 0;
> +}
> +
> +static char const hexdigits_lower[16] = "0123456789abcdef";
> +
> +void av_uuid_unparse(const AVUUID uuid, char *out)
> +{
> +    char *p = out;
> +
> +    for (int i = 0; i < 16; i++) {
> +        uint8_t tmp;
> +
> +        if (i == 4 || i == 6 || i == 8 || i == 10)
> +            *p++ = '-';
> +
> +        tmp = uuid[i];
> +        *p++ = hexdigits_lower[tmp >> 4];
> +        *p++ = hexdigits_lower[tmp & 15];
> +    }
> +
> +    *p = '\0';
> +}
> +
> +int av_uuid_urn_parse(const char *in, AVUUID uu)
> +{
> +    if (av_stristr(in, "urn:uuid:") != in)
> +        return AVERROR(EINVAL);
> +
> +    return av_uuid_parse(in + 9, uu);
> +}
> +
> +int av_uuid_equal(const AVUUID uu1, const AVUUID uu2)
> +{
> +    return memcmp(uu1, uu2, AV_UUID_LEN) == 0;
> +}
> +
> +void av_uuid_copy(AVUUID dest, const AVUUID src)
> +{
> +    memcpy(dest, src, AV_UUID_LEN);
> +}
> +
> +void av_uuid_nil_set(AVUUID uu)
> +{
> +    memset(uu, 0, AV_UUID_LEN);
> +}
> diff --git a/libavutil/uuid.h b/libavutil/uuid.h
> new file mode 100644
> index 0000000000..d7cd382ec2
> --- /dev/null
> +++ b/libavutil/uuid.h
> @@ -0,0 +1,137 @@
> +/*
> + * Copyright (c) 2022 Pierre-Anthony Lemieux <pal@palemieux.com>
> + *                    Zane van Iperen <zane@zanevaniperen.com>
> + *
> + * 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
> + * UUID parsing and serialization utilities.
> + * The library treat the UUID as an opaque sequence of 16 unsigned bytes,
                       ^
                       s

> + * i.e. ignoring the internal layout of the UUID, which depends on the type
> + * of the UUID.
> + *
> + * @author Pierre-Anthony Lemieux <pal@palemieux.com>
> + * @author Zane van Iperen <zane@zanevaniperen.com>
> + */
> +
> +#ifndef AVUTIL_UUID_H
> +#define AVUTIL_UUID_H
> +
> +#include <stdint.h>
> +
> +#define AV_PRI_UUID                          \
> +    "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-" \
> +    "%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
> +
> +#define AV_PRI_URN_UUID                               \
> +    "urn:uuid:%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-" \
> +    "%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
> +
> +/* AV_UUID_ARG() is used together with AV_PRI_UUID() or AV_PRI_URN_UUID
> + * to print UUIDs, e.g.
> + * av_log(NULL, AV_LOG_DEBUG, "UUID: " AV_PRI_UUID, AV_UUID_ARG(uuid));
> + */
> +#define AV_UUID_ARG(x)                  \
> +    (x)[ 0], (x)[ 1], (x)[ 2], (x)[ 3], \
> +    (x)[ 4], (x)[ 5], (x)[ 6], (x)[ 7], \
> +    (x)[ 8], (x)[ 9], (x)[10], (x)[11], \
> +    (x)[12], (x)[13], (x)[14], (x)[15]
> +
> +#define AV_UUID_LEN 16
> +
> +/* Binary representation of a UUID */
> +typedef uint8_t AVUUID[AV_UUID_LEN];
> +
> +/**
> + * Parses a string representation of a UUID formatted according to IETF RFC 4122
> + * into an AVUUID. The parsing is case-insensitive. The string must be 37
> + * characters long, including the terminating NULL character.

NUL, NULL is for pointers.

> + *
> + * Example string representation: "2fceebd0-7017-433d-bafb-d073a7116696"
> + *
> + * @param[in]  in  String representation of a UUID,
> + *                 e.g. 2fceebd0-7017-433d-bafb-d073a7116696
> + * @param[out] uu  AVUUID
> + * @return         A non-zero value in case of an error.
> + */
> +int av_uuid_parse(const char *in, AVUUID uu);
> +
> +/**
> + * Parses a URN representation of a UUID, as specified at IETF RFC 4122,
> + * into an AVUUID. The parsing is case-insensitive. The string must be 46
> + * characters long, including the terminating NULL character.
> + *
> + * Example string representation: "urn:uuid:2fceebd0-7017-433d-bafb-d073a7116696"
> + *
> + * @param[in]  in  URN UUID
> + * @param[out] uu  AVUUID
> + * @return         A non-zero value in case of an error.
> + */
> +int av_uuid_urn_parse(const char *in, AVUUID uu);
> +
> +/**
> + * Parses a string representation of a UUID formatted according to IETF RFC 4122
> + * into an AVUUID. The parsing is case-insensitive. The string must consist of
> + * 36 characters, i.e. `in_end - in_start == 36`
> + *
> + * @param[in]  in_start Pointer to the first character of the string representation
> + * @param[in]  in_end   Pointer to the character after the last character of the
> + *                      string representation. That memory location is never
> + *                      accessed
> + * @param[out] uu       AVUUID
> + * @return              A non-zero value in case of an error.
> + */
> +int av_uuid_parse_range(const char *in_start, const char *in_end, AVUUID uu);

This sounds like in_end is actually redundant. Does retaining it improve
extensibility?

> +
> +/**
> + * Serializes a AVUUID into a string representation according to IETF RFC 4122.
> + * The string is lowercase and always 37 characters long, including the
> + * terminating NULL character.
> + *
> + * @param[in]  uu  AVUUID
> + * @param[out] out Pointer to a array of no less than 37 characters.
                                  ^
                                  n

> + * @return         A non-zero value in case of an error.
> + */
> +void av_uuid_unparse(const AVUUID uu, char *out);
> +
> +/**
> + * Compares two UUIDs for equality.
> + *
> + * @param[in]  uu1  AVUUID
> + * @param[in]  uu2  AVUUID
> + * @return          Nonzero if uu1 and uu2 are identical, 0 otherwise
> + */
> +int av_uuid_equal(const AVUUID uu1, const AVUUID uu2);
> +
> +/**
> + * Copies the bytes of src into dest.
> + *
> + * @param[out]  dest  AVUUID
> + * @param[in]   src   AVUUID
> + */
> +void av_uuid_copy(AVUUID dest, const AVUUID src);
> +
> +/**
> + * Sets a UUID to nil
> + *
> + * @param[in,out]  uu  UUID to be set to nil
> + */
> +void av_uuid_nil_set(AVUUID uu);

Why are these three functions not static inline? Exporting them seems
like a waste.

> +
> +#endif /* AVUTIL_UUID_H */

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 1/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122
  2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 1/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122 Zane van Iperen
  2022-05-10 13:18   ` Andreas Rheinhardt
@ 2022-05-11 11:53   ` Anton Khirnov
  2022-05-11 15:02     ` Zane van Iperen
  1 sibling, 1 reply; 20+ messages in thread
From: Anton Khirnov @ 2022-05-11 11:53 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Pierre-Anthony Lemieux

Quoting Zane van Iperen (2022-04-24 12:14:03)
> +void av_uuid_nil_set(AVUUID uu)
                ^^^^^^^
sounds weird

av_uuid_zero()?
av_uuid_reset()?

-- 
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 1/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122
  2022-05-10 13:18   ` Andreas Rheinhardt
@ 2022-05-11 15:02     ` Zane van Iperen
  2022-05-31  3:17       ` Pierre-Anthony Lemieux
  0 siblings, 1 reply; 20+ messages in thread
From: Zane van Iperen @ 2022-05-11 15:02 UTC (permalink / raw)
  To: ffmpeg-devel



On 10/5/22 23:18, Andreas Rheinhardt wrote:

>> +int av_uuid_parse_range(const char *in_start, const char *in_end, AVUUID uu)
>> +{
>> +    int i;
>> +    const char *cp;
>> +    char buf[3];
>> +
>> +    if ((in_end - in_start) != 36)
>> +        return -1;
>> +
>> +    for (i = 0, cp = in_start; i < 36; i++, cp++) {
>> +        if (i == 8 || i == 13 || i == 18 || i == 23) {
>> +            if (*cp == '-')
>> +                continue;
>> +            return AVERROR(EINVAL);
>> +        }
>> +
>> +        if (!av_isxdigit(*cp))
>> +            return AVERROR(EINVAL);
>> +    }
>> +
>> +    buf[2] = '\0';
>> +    for (i = 0, cp = in_start; i < 16; i++) {
>> +        if (i == 4 || i == 6 || i == 8 || i == 10)
>> +            cp++;
>> +
>> +        buf[0] = *cp++;
>> +        buf[1] = *cp++;
>> +
>> +        errno = 0;
>> +        uu[i] = strtoul(buf, NULL, 16);
>> +        if (errno)
>> +            return AVERROR(errno);
> 
> How could this ever happen given that you have already checked that the
> buffer only contains hex digits? And isn't using strtoul a bit overkill
> anyway? I'd just check and parse this stuff in one loop.
> 

Yeah, good point. It's based off libuuid's, which has some time/clock uuid handling
between the two loops. I'll tidy it up in the next few days... hopefully...

>> +/**
>> + * @file
>> + * UUID parsing and serialization utilities.
>> + * The library treat the UUID as an opaque sequence of 16 unsigned bytes,
>                         ^
>                         s

Fixed.

>> +/**
>> + * Parses a string representation of a UUID formatted according to IETF RFC 4122
>> + * into an AVUUID. The parsing is case-insensitive. The string must be 37
>> + * characters long, including the terminating NULL character.
> 
> NUL, NULL is for pointers.
> 

Changed.

>> +/**
>> + * Parses a string representation of a UUID formatted according to IETF RFC 4122
>> + * into an AVUUID. The parsing is case-insensitive. The string must consist of
>> + * 36 characters, i.e. `in_end - in_start == 36`
>> + *
>> + * @param[in]  in_start Pointer to the first character of the string representation
>> + * @param[in]  in_end   Pointer to the character after the last character of the
>> + *                      string representation. That memory location is never
>> + *                      accessed
>> + * @param[out] uu       AVUUID
>> + * @return              A non-zero value in case of an error.
>> + */
>> +int av_uuid_parse_range(const char *in_start, const char *in_end, AVUUID uu);
> 
> This sounds like in_end is actually redundant. Does retaining it improve
> extensibility?
> 

I believe so. The main difference is av_uuid_parse_range() can handle non NUL-termiated
strings. I can just remove the entire last sentence (or change "must" to "should").

>> +
>> +/**
>> + * Serializes a AVUUID into a string representation according to IETF RFC 4122.
>> + * The string is lowercase and always 37 characters long, including the
>> + * terminating NULL character.
>> + *
>> + * @param[in]  uu  AVUUID
>> + * @param[out] out Pointer to a array of no less than 37 characters.
>                                    ^
>                                    n
> 

Fixed.


>> +/**
>> + * Sets a UUID to nil
>> + *
>> + * @param[in,out]  uu  UUID to be set to nil
>> + */
>> +void av_uuid_nil_set(AVUUID uu);
> 
> Why are these three functions not static inline? Exporting them seems
> like a waste.
> 

No particular reason, it's easy enough to change.

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 1/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122
  2022-05-11 11:53   ` Anton Khirnov
@ 2022-05-11 15:02     ` Zane van Iperen
  2022-05-31  3:16       ` Pierre-Anthony Lemieux
  0 siblings, 1 reply; 20+ messages in thread
From: Zane van Iperen @ 2022-05-11 15:02 UTC (permalink / raw)
  To: ffmpeg-devel



On 11/5/22 21:53, Anton Khirnov wrote:
> Quoting Zane van Iperen (2022-04-24 12:14:03)
>> +void av_uuid_nil_set(AVUUID uu)
>                  ^^^^^^^
> sounds weird
> 
> av_uuid_zero()?
> av_uuid_reset()?
> 

Good point, `av_uuid_zero()` has a nice ring to it.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 1/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122
  2022-05-11 15:02     ` Zane van Iperen
@ 2022-05-31  3:16       ` Pierre-Anthony Lemieux
  0 siblings, 0 replies; 20+ messages in thread
From: Pierre-Anthony Lemieux @ 2022-05-31  3:16 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Wed, May 11, 2022 at 8:03 AM Zane van Iperen <zane@zanevaniperen.com> wrote:
>
>
>
> On 11/5/22 21:53, Anton Khirnov wrote:
> > Quoting Zane van Iperen (2022-04-24 12:14:03)
> >> +void av_uuid_nil_set(AVUUID uu)
> >                  ^^^^^^^
> > sounds weird
> >
> > av_uuid_zero()?
> > av_uuid_reset()?
> >
>
> Good point, `av_uuid_zero()` has a nice ring to it.

I think we should keep `nil` in the name since the _nil UUID_ has a
special meaning in RFC 4122. have proposed av_uuid_nil() in v3 of the
patchset.


> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2 1/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122
  2022-05-11 15:02     ` Zane van Iperen
@ 2022-05-31  3:17       ` Pierre-Anthony Lemieux
  0 siblings, 0 replies; 20+ messages in thread
From: Pierre-Anthony Lemieux @ 2022-05-31  3:17 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Wed, May 11, 2022 at 8:02 AM Zane van Iperen <zane@zanevaniperen.com> wrote:
>
>
>
> On 10/5/22 23:18, Andreas Rheinhardt wrote:
>
> >> +int av_uuid_parse_range(const char *in_start, const char *in_end, AVUUID uu)
> >> +{
> >> +    int i;
> >> +    const char *cp;
> >> +    char buf[3];
> >> +
> >> +    if ((in_end - in_start) != 36)
> >> +        return -1;
> >> +
> >> +    for (i = 0, cp = in_start; i < 36; i++, cp++) {
> >> +        if (i == 8 || i == 13 || i == 18 || i == 23) {
> >> +            if (*cp == '-')
> >> +                continue;
> >> +            return AVERROR(EINVAL);
> >> +        }
> >> +
> >> +        if (!av_isxdigit(*cp))
> >> +            return AVERROR(EINVAL);
> >> +    }
> >> +
> >> +    buf[2] = '\0';
> >> +    for (i = 0, cp = in_start; i < 16; i++) {
> >> +        if (i == 4 || i == 6 || i == 8 || i == 10)
> >> +            cp++;
> >> +
> >> +        buf[0] = *cp++;
> >> +        buf[1] = *cp++;
> >> +
> >> +        errno = 0;
> >> +        uu[i] = strtoul(buf, NULL, 16);
> >> +        if (errno)
> >> +            return AVERROR(errno);
> >
> > How could this ever happen given that you have already checked that the
> > buffer only contains hex digits? And isn't using strtoul a bit overkill
> > anyway? I'd just check and parse this stuff in one loop.
> >
>
> Yeah, good point. It's based off libuuid's, which has some time/clock uuid handling
> between the two loops. I'll tidy it up in the next few days... hopefully...
>
> >> +/**
> >> + * @file
> >> + * UUID parsing and serialization utilities.
> >> + * The library treat the UUID as an opaque sequence of 16 unsigned bytes,
> >                         ^
> >                         s
>
> Fixed.
>
> >> +/**
> >> + * Parses a string representation of a UUID formatted according to IETF RFC 4122
> >> + * into an AVUUID. The parsing is case-insensitive. The string must be 37
> >> + * characters long, including the terminating NULL character.
> >
> > NUL, NULL is for pointers.
> >
>
> Changed.
>
> >> +/**
> >> + * Parses a string representation of a UUID formatted according to IETF RFC 4122
> >> + * into an AVUUID. The parsing is case-insensitive. The string must consist of
> >> + * 36 characters, i.e. `in_end - in_start == 36`
> >> + *
> >> + * @param[in]  in_start Pointer to the first character of the string representation
> >> + * @param[in]  in_end   Pointer to the character after the last character of the
> >> + *                      string representation. That memory location is never
> >> + *                      accessed
> >> + * @param[out] uu       AVUUID
> >> + * @return              A non-zero value in case of an error.
> >> + */
> >> +int av_uuid_parse_range(const char *in_start, const char *in_end, AVUUID uu);
> >
> > This sounds like in_end is actually redundant. Does retaining it improve
> > extensibility?
> >
>
> I believe so. The main difference is av_uuid_parse_range() can handle non NUL-termiated
> strings. I can just remove the entire last sentence (or change "must" to "should").

I have modified the documentation in v3 of the patchset to emphasize
that `in_end - in_start != 36` results in an error.

>
> >> +
> >> +/**
> >> + * Serializes a AVUUID into a string representation according to IETF RFC 4122.
> >> + * The string is lowercase and always 37 characters long, including the
> >> + * terminating NULL character.
> >> + *
> >> + * @param[in]  uu  AVUUID
> >> + * @param[out] out Pointer to a array of no less than 37 characters.
> >                                    ^
> >                                    n
> >
>
> Fixed.
>
>
> >> +/**
> >> + * Sets a UUID to nil
> >> + *
> >> + * @param[in,out]  uu  UUID to be set to nil
> >> + */
> >> +void av_uuid_nil_set(AVUUID uu);
> >
> > Why are these three functions not static inline? Exporting them seems
> > like a waste.
> >
>
> No particular reason, it's easy enough to change.
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2022-05-31  3:17 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-24 10:14 [FFmpeg-devel] [PATCH v2 0/7] Add UUID functionality to libavutil Zane van Iperen
2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 1/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122 Zane van Iperen
2022-05-10 13:18   ` Andreas Rheinhardt
2022-05-11 15:02     ` Zane van Iperen
2022-05-31  3:17       ` Pierre-Anthony Lemieux
2022-05-11 11:53   ` Anton Khirnov
2022-05-11 15:02     ` Zane van Iperen
2022-05-31  3:16       ` Pierre-Anthony Lemieux
2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 2/7] avutil/tests/uuid: add uuid tests Zane van Iperen
2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 3/7] avformat/mov: refactor to use avutil/uuid Zane van Iperen
2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 4/7] avformat/smoothstreamingenc: " Zane van Iperen
2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 5/7] avcodec/cbs_sei: " Zane van Iperen
2022-04-30 17:31   ` Mark Thompson
2022-04-30 17:53     ` Pierre-Anthony Lemieux
2022-04-30 19:25       ` Mark Thompson
2022-04-30 20:53         ` Pierre-Anthony Lemieux
2022-05-01 21:06           ` Mark Thompson
2022-05-04 16:21             ` Zane van Iperen
2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 6/7] avformat/imf: " Zane van Iperen
2022-04-24 10:14 ` [FFmpeg-devel] [PATCH v2 7/7] avfilter/showinfo: " Zane van Iperen

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git