From patchwork Tue May 31 03:13:32 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: 35997 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6914:b0:82:6b11:2509 with SMTP id q20csp2607119pzj; Mon, 30 May 2022 20:15:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/rSoVQ3IbLujfxKrAJCQ81ysSEjLaOTlqjN3Sc6WqI4y9RPq9XRiko2vpvM4VBDU6QAlK X-Received: by 2002:a17:906:b10f:b0:6fe:a059:f6f4 with SMTP id u15-20020a170906b10f00b006fea059f6f4mr48896933ejy.194.1653966900229; Mon, 30 May 2022 20:15:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653966900; cv=none; d=google.com; s=arc-20160816; b=cqE5ueDpr+tVYiOEEq0rEuDi15ukD0eWML3jTtGnYTy/JFy+Cq3D7a+cq22jh+6bsp HCkBp5LWfD+ReMpX9XmOnxnj+7tDoFXFLy2VSFpnGuM3XVAk+cIjskZx9wr6QxHiV9+R 3CWlwinEQIIXzEsaMX/j7DakXbULo8+P8wv9rYkkfpM483jC8XXlWuyKkMVhM8pt1zQu HYhbXWSfo14i+W/UHwNarXR5cO9shA5oGAhGHrtj1+KDMJE8T9E/iWNf4Y7VW6LR95z8 yjf2rvm68ITvVbqJkovNT7tNmrdLB+JOzlBCN3Y2qE4URCXLLeg7eeql5lpp1vownZca 5iQg== 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=Wkh1VPBNvqVI8DMV0F5ngUbIuG521RSXeTohGt0vthufxnlSRI95Fn3Z2g3kGn3kx8 Iflee1ePkfrs5GnyyOCbkNgwybabjDFpb8CwH33Z9Pc4vBkdOjQD141Ww0a2e0qb+3ZR BUYsiYiXp+D5X9GQZnL2bhQDHKP4HFfSz47JscABVAuJbSgYkE/32lQMidqXQZ8uZXKu ZEll8+1+rUk5foVM8WHxsg9mmyieM8qVWEcuPXubyf6li3V8KWOCPn1sW9zwMoTPS+2o vn7TrX9E6gpjr5JUX8lx4NHNeboa9ztc05oUucQA6sBpfejsfr/mWXLoN8MU7ddyGquC Gkpw== 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 dt4-20020a170907728400b006f429eb5456si14333505ejc.836.2022.05.30.20.14.59; Mon, 30 May 2022 20:15:00 -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 2757168B63F; Tue, 31 May 2022 06:14:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 93FAC68AE7C for ; Tue, 31 May 2022 06:14:35 +0300 (EEST) Received: by mail-pl1-f176.google.com with SMTP id b5so11712069plx.10 for ; Mon, 30 May 2022 20:14:35 -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=DpcAunsx7Ps5QKDwh75IVR3POo+le6yV3x9O/Asn4aSsYpD/jVOfzLs/YrJwOScLYk Q6CDek2lIwOTOGN+T1gKCCHhKCXoEiMbLOwxNoXLb6M4+kyaAxo8DPaY4ZU8l/8UI7eO JVJjhZjvdamvntOLpzjiFFzOp04RfkovqCT+fNYmq4OaI+uuw3lf9sgu4ZcYLVVERPRj pjCJivMvKvJhZ5rPid6fQtFiT1/cxQ7iTGTrS3os7v5Jg3s32sX7PT4/bTyhDc5pdSQp s/5Yz2QMyC3zHuxPlqg2mmFJHVKutOJeGLcMtw7LLHA5maVGQqwdefJiNDGauAgMg+gd sbAw== X-Gm-Message-State: AOAM530o5tb5nAiIt4h8PizeJuIVkmt6G6Zu37ChbEeA/XFzmdEaWOOe ila/8/qzvHFnpSHjJ9BvcoMjGrBrUtI= X-Received: by 2002:a17:90a:550d:b0:1e2:eb94:588e with SMTP id b13-20020a17090a550d00b001e2eb94588emr10540434pji.15.1653966873591; Mon, 30 May 2022 20:14:33 -0700 (PDT) Received: from localhost (76-14-89-2.sf-cable.astound.net. [76.14.89.2]) by smtp.gmail.com with ESMTPSA id ik19-20020a170902ab1300b0015e8d4eb283sm6462523plb.205.2022.05.30.20.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 May 2022 20:14:33 -0700 (PDT) Received: by localhost (sSMTP sendmail emulation); Mon, 30 May 2022 20:14:29 -0700 From: pal@sandflow.com To: ffmpeg-devel@ffmpeg.org Date: Mon, 30 May 2022 20:13:32 -0700 Message-Id: <20220531031334.19488-3-pal@sandflow.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220531031334.19488-1-pal@sandflow.com> References: <20220531031334.19488-1-pal@sandflow.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 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: 3V5TaxQ1x8YP 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);