From patchwork Thu Jun 2 00:30:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Anthony Lemieux X-Patchwork-Id: 36039 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6914:b0:82:6b11:2509 with SMTP id q20csp3739059pzj; Wed, 1 Jun 2022 17:31:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzB/eG8kBVy1vQT0+rqsMr6ag+WVBtrVkG4JriDnQAs2cON02N+bRwHLCLHdyWFkeYb2MDe X-Received: by 2002:a17:907:6d10:b0:6fe:c744:43be with SMTP id sa16-20020a1709076d1000b006fec74443bemr1945612ejc.470.1654129878346; Wed, 01 Jun 2022 17:31:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654129878; cv=none; d=google.com; s=arc-20160816; b=QDx3wPxY/SflWF/aIX17gQObDE5EZSk/A8+QuJOt5YNDfo7GZzvT+dKMWhKIkw/cuG m7Ko4udTxbZBdF2zCOdijE9Iv5naUopOr7zaZjY+6UZ2k8SIMqcB8q9b9g4OR4MammjE rxdg7TTno6wh6NDwqcN+nOm2/0dk6pEzxd499Z7UNzSpumER2z+hLnUAwuEr0tpcUfPI bic4vED+oXYvPuJ9OHthwJHlUGfqRoS+dhoSa410+6yvB97fDGhD/ljrCQ0kRbOBtPLq m7fSuEwzeCqIP7idq3UuKDgIkURlfE8Egn/1e/6PAxqNAFGYTkxV6obDDBt9Ghgh/5gL QG0g== 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=tlp/r1Wxu3czjqCEbHkLI/CqSBVWZ3XIHofZOIRHgGo=; b=eJkkYgMqrQjW9f/l31mDBSrWGaicZNuJPrhuthGe08aBrACn8LP9jxmXJDPA8jWY0I Kxc4EcE0ruYxazpavbOaK3DhWvcA3agEslA3/zFeJSCrDT2jzcO9s3kN6isjJ5KD2jnf INNS/zZOG1UPU3JJ+rzj7gvrwOZZ6j/rRJksFdGqR/EHdTA6u1839alrnrpQAqkPTS1j 50yT8zCpGVDWu8HDa/SLW+JkazbOkTFQbPZBuBaj2DFsaXByS91KaTdA3+4Nd0Ys45pe jb48m1Ny9lHI6ICyLk+zYbU5CeikYPbbZK2D1PV1VANR/2aKcLXWNufvsEnRnPyhLhQ5 MH+A== 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g15-20020a1709061c8f00b006ff04ae2168si2943727ejh.245.2022.06.01.17.31.17; Wed, 01 Jun 2022 17:31:18 -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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 287F568B66C; Thu, 2 Jun 2022 03:30:58 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 61DED68B70E for ; Thu, 2 Jun 2022 03:30:52 +0300 (EEST) Received: by mail-pg1-f174.google.com with SMTP id u4so377040pgk.11 for ; Wed, 01 Jun 2022 17:30:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=607MiutuA6X5Dja8NNSeYInwJNAgCLiHOCtV+yuJuYA=; b=ut0rq9Pb1oOmrA6FjdIhbS1UhEyg3afz7IjkKN62hJ0P+FufzRhzmmrPNgAYMNpn+P 5aGQ0XUREEDu/mqxG+GWIbFOD3OHiVwwayckTczN9/AugAHLqgJ3TZ73tbtTqCBvoK4F HOw/HbJIeW5Ridk//AtYbRPILZRp432cDCI4VLf44s2k2dMlc3jlrVXcQD6mQfMkcdBQ Pwl3FO0nvpWKwGUpZrE/pnt2BJJQzcTgJN1Tw/Hq7Q6GEb35N5bBFkyQBQFDw+3QB4cI h6SWVKEuvNttkB478f9ZDIC/FVc3qSfenNjsLB2zbDToEY1/03SRIumJDtpUtr0VUNUz 1rQQ== X-Gm-Message-State: AOAM530d+gzmlhHeqfdFefKZ5GGmKnOvRC0EAX/IKrp2Ee/efe8HdnH4 OlmDlNROKQX6cg4UFa6HCNKbHDuK01E= X-Received: by 2002:a63:24c7:0:b0:3fc:5c99:a196 with SMTP id k190-20020a6324c7000000b003fc5c99a196mr1714056pgk.521.1654129850329; Wed, 01 Jun 2022 17:30:50 -0700 (PDT) Received: from localhost (76-14-89-2.sf-cable.astound.net. [76.14.89.2]) by smtp.gmail.com with ESMTPSA id m13-20020a17090a858d00b001e325fbe508sm4311997pjn.25.2022.06.01.17.30.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 17:30:49 -0700 (PDT) Received: by localhost (sSMTP sendmail emulation); Wed, 01 Jun 2022 17:30:44 -0700 From: pal@sandflow.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 1 Jun 2022 17:30:34 -0700 Message-Id: <20220602003037.24597-3-pal@sandflow.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220602003037.24597-1-pal@sandflow.com> References: <20220602003037.24597-1-pal@sandflow.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 3/6] 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: 5cdFzEbOyE63 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 d7be593a86..f8248ab65b 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -47,6 +47,7 @@ #include "libavutil/spherical.h" #include "libavutil/stereo3d.h" #include "libavutil/timecode.h" +#include "libavutil/uuid.h" #include "libavcodec/ac3tab.h" #include "libavcodec/flac.h" #include "libavcodec/hevc.h" @@ -5956,21 +5957,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) @@ -5978,13 +5979,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; @@ -6022,9 +6023,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) { @@ -6044,8 +6045,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 de971f94e8..b7b2f46a17 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" @@ -4487,14 +4488,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"); @@ -4753,7 +4754,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); @@ -4779,7 +4780,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);