From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 5D48F42E5B for ; Tue, 10 May 2022 13:18:31 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1367068B3A7; Tue, 10 May 2022 16:18:28 +0300 (EEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05olkn2082.outbound.protection.outlook.com [40.92.90.82]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BFB7668AD28 for ; Tue, 10 May 2022 16:18:21 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lTSh7qeIcbE1wT3RRnUgtLPvBLOP7n9X0Vsvyf5W9M5V6Ovv7q8MxV8QKVFYJ3uk6UqQVzl23CIiPoy81/IMkQJzcdAgsK8MRFzpZmsWHX5Xe2BGjxgIK+vyXj4SX3odmN7rHtM2tEUZqRpwzfoKhxWCr828kv+Jcw8rcmyb4eNoqBCYB3a2O/f4WyUxYlKIP6H/xviV3dPEYBYmaOVEIh393vi5pqLOV0fezQk+iBuoO6SqoIxUNwkpfr1Xm1fDYOrqFkr828fh0bZE4Gr5KUJAWNjDdBWib0hZnDwYlOUjACyFXti5jS89gIXny+X9QaCmOyiUVO7ONORd8WkGrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TCxlgHsmmf/vSCRItjlu/5QH9naAjVKzYC4JXjQ7ukY=; b=LEoqOWyjhBMPMQKDZiNAeVmqYrZdVF69Ugy2fDChOmunLf44G51Srr1xINpCZ76KwGCPt376BORkBojab5CxmtVh3m4ml3qs99BeF4s1eQO6DaD6gS6acS0VNKf3ZSkHL8DEoVU0beH0I1x4AeeKOq8nlVCj++WkSGAJkkK/zgzC8Pm3kqVPtR8jCyza4D3EsTDPlkBJ5oqGf3VpJUdXL5LhpHTfIded/p7hRb0b+SoBCzp/cU0BqnGkqybPAosUbW2OpH+Sb+DKZ6isCuQLi/kmC4oPTNjkZy6/PYxbZiQd+DMzLkSQi2NkpJQAb1ILUhgmjT8rZp6IfjkPs1p7oA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TCxlgHsmmf/vSCRItjlu/5QH9naAjVKzYC4JXjQ7ukY=; b=cevnKD6Sf3lVrX7SyWwvcoGxAPA4f1LObW23BgXxxf99TiL71NohKDnrjYcAWV5eHuTpTynJKPs2A5LBn1mwEkn4oHgE5Vi1+ZynXU+rxwn5fU3aaQSyVaexxD+Q+Qb0kMO1Zjh1C6sh4NEJpphcSkB5wk40jP1bz6Tp9rFcH+AdkoEKpSNWLdqzJgo3YYQEYQ3dTUrLIfCOk8hNnTCakJDFYdUokIRCFL8TOBZyQngAkPppaI4CfxSJ9UYwi8SWIY9CqnTYg+uHoOrPCP9CcbHm5qYs/zZJZLQswNQUGzE81+U0FbXFbXL4YJgK9eGCnYRNUr2pIV/c009NVea9gg== Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) by HE1PR0101MB2218.eurprd01.prod.exchangelabs.com (2603:10a6:3:1d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.21; Tue, 10 May 2022 13:18:19 +0000 Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c]) by DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c%9]) with mapi id 15.20.5227.023; Tue, 10 May 2022 13:18:19 +0000 Message-ID: Date: Tue, 10 May 2022 15:18:16 +0200 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20220424101409.95486-1-zane@zanevaniperen.com> <20220424101409.95486-2-zane@zanevaniperen.com> From: Andreas Rheinhardt In-Reply-To: <20220424101409.95486-2-zane@zanevaniperen.com> X-TMN: [a3u8WWdz7gBa/o1YMKX3YqYe072dPUpE] X-ClientProxiedBy: ZR0P278CA0036.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::23) To DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 79079920-c358-46d1-ca25-08da32878c96 X-MS-TrafficTypeDiagnostic: HE1PR0101MB2218:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MFOJBIrk6NqlcTDjfbiLYZgPR4MpCcuaszpsDmHpLW6ysuj4IwL3JxAmQ9LkxOGcudI4oxqJTauuRbohkMZD8yTvHFCBNe19OL+px6mBn/6SEuGXhrgWgk5M6SkwpIRKgq6gfoFv+fWAhj2i8jrHruI7PeM57nBQBLvKCbjMjJ/iYI+0kIpJN29GI9h5uXCNbwhtGlaY+Q45Kaj0+mD8+1mjJsnuj0GYhi3j+6lc7D7WZ5S9XP6igCJUCO63FruMLRO4Cz/bYlAn48Jo9cXpYngLM2VS97hz3Q3Jos6UuPFGFgMaC3cwDr+oyJS+D9Il8cC2UekSIaS67/GGCjNeg6hiU62PBWmuDSEBfbZWe/tsvMp5hQFkSGp9WTgzdP0SqFtua8GAApvcEWNfy+7IDqLb04fFbv/eb3DaeiKS1aj44lvWT/xOiVNnVxo7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OeGtGOFU1?= =?utf-8?B?VjdoSkFVOWxGV3pxUTZJd3dpYUZyem5pdk0rdHNNcDRPQWdvbmFVL2JRdUdH?= =?utf-8?B?QWVlMDVUQit6dVptTU91dmNvcVFZV1RlK0lwRWQzMVhwd1FzRmg2TldpbXQz?= =?utf-8?B?R3VuU1lId3Z2ekhudkI5UUNqemU3dkxaOWRyMUNER1ZwVjhKK1Z3cFV6MmUx?= =?utf-8?B?SEpoQVNUdDUwcmdsaEtWdnFMbDkvL0h6dUhVRThaN0FDWUpEczQxa0VUUXhj?= =?utf-8?B?M3NWazQvcm5OYkRRWEtTS2dnV1NGNVlWaENNaTdEQW5wZUZGMWxPZXR4cmU4?= =?utf-8?B?TEJqeUVvb3h5V3VQNTRJZFNpNDJBYUo3eEJVZ1JDMmtEdkhGSVdCYXNDZUNL?= =?utf-8?B?V1FVL0RNMWx2VnRrN0lIUTJEMEJFd1N3RHpPaThmRUozNlI2M3RIbExRU0hE?= =?utf-8?B?NEVid0huZHhBPT0=?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 79079920-c358-46d1-ca25-08da32878c96 X-MS-Exchange-CrossTenant-AuthSource: DB6PR0101MB2214.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2022 13:18:19.0137 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0101MB2218 Subject: Re: [FFmpeg-devel] [PATCH v2 1/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Zane van Iperen: > Co-authored-by: Pierre-Anthony Lemieux > Signed-off-by: Zane van Iperen > --- > 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 > + * Zane van Iperen > + * > + * 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 > + * @author Zane van Iperen > + */ > + > +#include "uuid.h" > +#include "error.h" > +#include "avstring.h" > +#include > +#include > + > +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 > + * Zane van Iperen > + * > + * 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 > + * @author Zane van Iperen > + */ > + > +#ifndef AVUTIL_UUID_H > +#define AVUTIL_UUID_H > + > +#include > + > +#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".