From patchwork Sun Apr 24 10:14:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zane van Iperen X-Patchwork-Id: 35427 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b9e:b0:7d:cfb5:dc7c with SMTP id b30csp1335273pzh; Sun, 24 Apr 2022 03:15:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPt6R2+Gu6ARCzfPNFjeCJC+Zo+lR7ipwMxdwv7AF5dDfcGrIda1SlIBGz1wd/bGEEADZB X-Received: by 2002:a17:906:31c2:b0:6e8:6e8b:cbe4 with SMTP id f2-20020a17090631c200b006e86e8bcbe4mr11983629ejf.293.1650795310339; Sun, 24 Apr 2022 03:15:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650795310; cv=none; d=google.com; s=arc-20160816; b=otsumYw6UPmWdGJgG4C8cOL8LYnKCsRF2jfsqRujfko+fqtxsTTaZQn9W7ji7CjXNN sU57oLPWHOLLCz+Nz5Jh9d9aKZiQcljjhGCHiV29pXoR30ktVAfluRGxPuAkAHJXHp+1 gQjcKD7nLwAxgZFjF/X707fF9nyoAPPBgWhOkpw2ZITL7qqwWOSR0Xg1upd3B3v2SsJz PwHc+2jAjgF/ooXyTytenl0LtM2adADX4G902+LWs1y/nwQl6sMoEnast/dadEDuOBn+ ikgzfBFdkTykN7JJ6e0k9tnarGDOveo6Vy7JiaqVAjh5re7Tn5Wbau1F6weUgCVE3olZ ox6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=3xHPlrGFud+MATntjtHFGaukk9h7ShgLEcr0M3cHZIs=; b=Nb1u3rrOMXYXiI3XMX70uNcprnrapKwofNOM5nX4Wkk/awurpN1rsePPH+uwWIcSBv qLzBLW2qN09NFbLwA4Y1dU6w9Ybvrth3z37SDzjeRUOFRYzHeBlreKCl8oZUz2a0ybTI khqEeXfp+QDswuqqXinsnXP1CTbRhB7hk59hAPQkczt7VDH5Ge4QXt/qqqjEDPs8328D lPO5m2iRjwEA00vJlGKY8uJrqa7HVbFwJiqXsX5R+gmYvaZP0ktWW3eeXHxytzoLT6GC 9HYbGTZWov74+ko9iTXvjeaHOsQnlb5sQUfmwk4yTCR+qT2w7+KTNyEyR7EPQhNZgYQH BSvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zanevaniperen.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a8-20020a170906190800b006df76385ce8si10263087eje.392.2022.04.24.03.15.10; Sun, 24 Apr 2022 03:15:10 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zanevaniperen.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8FACC68B26B; Sun, 24 Apr 2022 13:14:47 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out0.migadu.com (out0.migadu.com [94.23.1.103]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A9EA868B22C for ; Sun, 24 Apr 2022 13:14:40 +0300 (EEST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Zane van Iperen To: ffmpeg-devel@ffmpeg.org Date: Sun, 24 Apr 2022 20:14:05 +1000 Message-Id: <20220424101409.95486-4-zane@zanevaniperen.com> In-Reply-To: <20220424101409.95486-1-zane@zanevaniperen.com> References: <20220424101409.95486-1-zane@zanevaniperen.com> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: cadance.vs49688.net Subject: [FFmpeg-devel] [PATCH v2 3/7] avformat/mov: refactor to use avutil/uuid 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 Cc: Pierre-Anthony Lemieux Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: /BZv8RV7HFqr From: Pierre-Anthony Lemieux --- 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, "\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);