From patchwork Mon Feb 19 23:42:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 46380 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dda5:b0:19e:cdac:8cce with SMTP id kw37csp1552689pzb; Mon, 19 Feb 2024 15:42:56 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV5F20KUL1vCk0nMWqfaNKGZ/K3GTLUFNiPYFPOex/0yE7rFmqxn7fz14pEQsN/Y2aRKm7FiHbHB+4vnZlgqxAzjfrzAZwnP+wKgg== X-Google-Smtp-Source: AGHT+IE0bqZjBpi3so8/c6tnJpyoMpZjK3GZyA1l109rfOj9Cq6Y9jagEDcEf7XH2b2TqjaBmWac X-Received: by 2002:a17:906:b17:b0:a3e:ed80:561e with SMTP id u23-20020a1709060b1700b00a3eed80561emr371831ejg.47.1708386176423; Mon, 19 Feb 2024 15:42:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708386176; cv=none; d=google.com; s=arc-20160816; b=GgukL8M+3TQBmhBmTdZOGXxbABWbtQ7IIJtaVEw3Ic9iIV53bMituUuh5YWxrnrKOo Ql5QsvzVYbeoQ8wgHIGrmNLlbP/lTvwDrnt25RBZDZXDj6BlSI2SInVh2jYy2JwtZ+R9 E6QQ1yhOwstwMbcnye4uqL7HXGYGfF3EABbh6G6QitJ8f03+tAcsgOwJ7myQo009zptK UT2UyteIt9jgjP6WEvPm1NufeXYRjYCjhBYUw949nFKA8mzlfghYVgYcuzmt8FI8nBOX WxzLW67rESq/jHa2Z/IJDwyANkyQF/f7R0T5QjiYm4u7+55MKmH76WK4LRiy5Uu4fia2 quPw== 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:message-id:date:to:from :delivered-to; bh=owzpeUv7zHYDuyB24eCIgrrUIjbtUJiPNI2ol7Qnezw=; fh=s+G8Ss4JbeMFkWPSp2LmIH/LXFyBlALRiww1j3FPjHY=; b=MQsH/3hVr6PqO10ylUYJtdel4R1EaFBdmhg3jRcht5zogqZk0ymGgMDulvMpcPLKbJ u35UevF7bqkYc2bP5TWB4kc95vh8zCQJ/K7FmmdS/CJRfCyGHnx0Igl9IInB19ijT7hz sTN091hMeyGroIiiJIPoUBXpb5jLaWKGBcSr5gN8LlCStyUWYUTyIEzWWm5cRgadDdxY BGWmmnSrHLqi1JbXf0win7g+osD2r65z4d6r+NjrF6PWnbK3WIds23WpkJ3H9VuCvzeL kfqm8XiKD8xK6riBiLTj2KPwgoiY7IPsdvXJYrsYk42+fkzCu1LP0tR+8cBa9h8MsRbP 9Csg==; dara=google.com 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 hq16-20020a1709073f1000b00a3ec1a9686fsi873208ejc.9.2024.02.19.15.42.56; Mon, 19 Feb 2024 15:42:56 -0800 (PST) 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 260FD68D43E; Tue, 20 Feb 2024 01:42:53 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 024D768D420 for ; Tue, 20 Feb 2024 01:42:46 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id BD7DEE9F5E; Tue, 20 Feb 2024 00:42:46 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OARhBEnDPM8o; Tue, 20 Feb 2024 00:42:44 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 5D5C2E98C3; Tue, 20 Feb 2024 00:42:44 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 20 Feb 2024 00:42:39 +0100 Message-Id: <20240219234240.21622-1-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avformat/mxfdec: remove resolve_strong_ref usage with AnyType 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: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Je0vD8Tt7Pfp UUIDs do not have to be unique if their type sets them apart, so avoid using AnyType, since we are only interested in specific types. Signed-off-by: Marton Balint --- libavformat/mxf.h | 3 +-- libavformat/mxfdec.c | 54 ++++++++++++++++---------------------------- 2 files changed, 20 insertions(+), 37 deletions(-) diff --git a/libavformat/mxf.h b/libavformat/mxf.h index 7dd1681e60..e16843214c 100644 --- a/libavformat/mxf.h +++ b/libavformat/mxf.h @@ -30,8 +30,7 @@ typedef AVUUID UID; enum MXFMetadataSetType { - AnyType, - MaterialPackage, + MaterialPackage = 1, SourcePackage, SourceClip, TimecodeComponent, diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 446bcf3276..b7b9207a5b 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -1582,7 +1582,7 @@ static void *mxf_resolve_strong_ref(MXFContext *mxf, UID *strong_ref, enum MXFMe return NULL; for (i = mxf->metadata_sets_count - 1; i >= 0; i--) { if (!memcmp(*strong_ref, mxf->metadata_sets[i]->uid, 16) && - (type == AnyType || mxf->metadata_sets[i]->type == type)) { + (mxf->metadata_sets[i]->type == type)) { return mxf->metadata_sets[i]; } } @@ -2221,22 +2221,17 @@ static int mxf_add_timecode_metadata(AVDictionary **pm, const char *key, AVTimec static MXFTimecodeComponent* mxf_resolve_timecode_component(MXFContext *mxf, UID *strong_ref) { - MXFStructuralComponent *component = NULL; - MXFPulldownComponent *pulldown = NULL; + MXFTimecodeComponent *timecode; + MXFPulldownComponent *pulldown; - component = mxf_resolve_strong_ref(mxf, strong_ref, AnyType); - if (!component) - return NULL; + timecode = mxf_resolve_strong_ref(mxf, strong_ref, TimecodeComponent); + if (timecode) + return timecode; - switch (component->meta.type) { - case TimecodeComponent: - return (MXFTimecodeComponent*)component; - case PulldownComponent: /* timcode component may be located on a pulldown component */ - pulldown = (MXFPulldownComponent*)component; + pulldown = mxf_resolve_strong_ref(mxf, strong_ref, PulldownComponent); + if (pulldown) return mxf_resolve_strong_ref(mxf, &pulldown->input_segment_ref, TimecodeComponent); - default: - break; - } + return NULL; } @@ -2280,14 +2275,20 @@ static MXFDescriptor* mxf_resolve_descriptor(MXFContext *mxf, UID *strong_ref, i return NULL; } -static MXFStructuralComponent* mxf_resolve_essence_group_choice(MXFContext *mxf, MXFEssenceGroup *essence_group) +static MXFStructuralComponent* mxf_resolve_sourceclip(MXFContext *mxf, UID *strong_ref) { MXFStructuralComponent *component = NULL; MXFPackage *package = NULL; MXFDescriptor *descriptor = NULL; + MXFEssenceGroup *essence_group; int i; - if (!essence_group || !essence_group->structural_components_count) + component = mxf_resolve_strong_ref(mxf, strong_ref, SourceClip); + if (component) + return component; + + essence_group = mxf_resolve_strong_ref(mxf, strong_ref, EssenceGroup); + if (!essence_group) return NULL; /* essence groups contains multiple representations of the same media, @@ -2304,24 +2305,7 @@ static MXFStructuralComponent* mxf_resolve_essence_group_choice(MXFContext *mxf, if (descriptor) return component; } - return NULL; -} - -static MXFStructuralComponent* mxf_resolve_sourceclip(MXFContext *mxf, UID *strong_ref) -{ - MXFStructuralComponent *component = NULL; - component = mxf_resolve_strong_ref(mxf, strong_ref, AnyType); - if (!component) - return NULL; - switch (component->meta.type) { - case SourceClip: - return component; - case EssenceGroup: - return mxf_resolve_essence_group_choice(mxf, (MXFEssenceGroup*) component); - default: - break; - } return NULL; } @@ -3243,7 +3227,7 @@ static const MXFMetadataReadTableEntry mxf_metadata_read_table[] = { { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x04,0x00 }, mxf_read_partition_pack }, { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x2f,0x00 }, mxf_read_preface_metadata }, { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x30,0x00 }, mxf_read_identification_metadata }, - { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x18,0x00 }, mxf_read_content_storage, 0, AnyType }, + { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x18,0x00 }, mxf_read_content_storage }, { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x37,0x00 }, mxf_read_package, sizeof(MXFPackage), SourcePackage }, { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x36,0x00 }, mxf_read_package, sizeof(MXFPackage), MaterialPackage }, { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x0f,0x00 }, mxf_read_sequence, sizeof(MXFSequence), Sequence }, @@ -3272,7 +3256,7 @@ static const MXFMetadataReadTableEntry mxf_metadata_read_table[] = { { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x04,0x01,0x02,0x02,0x00,0x00 }, mxf_read_cryptographic_context, sizeof(MXFCryptoContext), CryptoContext }, { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x10,0x01,0x00 }, mxf_read_index_table_segment, sizeof(MXFIndexTableSegment), IndexTableSegment }, { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x23,0x00 }, mxf_read_essence_container_data, sizeof(MXFEssenceContainerData), EssenceContainerData }, - { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, NULL, 0, AnyType }, + { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, NULL }, }; static int mxf_metadataset_init(MXFMetadataSet *ctx, enum MXFMetadataSetType type, MXFPartition *partition)