From patchwork Sun Mar 17 20:00:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 47137 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp656603pzb; Sun, 17 Mar 2024 13:02:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUHA0uXzPscUD4y+yyN/TUElXcMjtnJLwJ3tRKnNOVIkggMTleYA6jVa6gCR1SBnOvrChfi64x0tfqeH5AEQZBlCW2Xd78pqUFmiA== X-Google-Smtp-Source: AGHT+IHl70sZDZjQ0IydehKW6HjmnysXV66U2QfCZ2XE0T6Bm8jOMJ2lqW7oZZQ3htghdDNoJu7O X-Received: by 2002:a05:6402:4284:b0:568:1100:2d95 with SMTP id g4-20020a056402428400b0056811002d95mr8730031edc.31.1710705749883; Sun, 17 Mar 2024 13:02:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710705749; cv=none; d=google.com; s=arc-20160816; b=LU42Z6WbmsiJH2p4evgxr57D5Vn89I0zhCsj4Q9wMg97zeCr4ts1CKWwnMmMJOuD+m bZRmJhQRkFRN6p63S0tOLQjhufxdfZ5zuDJEI5Yj3VCcdnND9VXRbgfes+j+QAfaey6m HCrz+RBZlzd32e8x5fPL3EG/XTEl+xIeCvaXoZCVYz9t0+wrnaJ0OiWeHgeZoWhgubEF 7pmcAnqBKpIh/UOQkvfD3Ri/QOIxF7rBn1yywpgmTikiXvm424kgvR+LqHDeCnCD9Y6U WjVLWjKf7G3MzxkfWvrKM17PWzG2YoJ5Cslb/AuSYsIRUazum0yFos/XZ+BjJeaDr8Ix ytIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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:dkim-signature:delivered-to; bh=pUTWJM83vSEYgpAPS00vzYNwTaKnMgdFvz2a34SpvH4=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Di2VCTJiGzl4vknujgB6RysjMa9eZdziic0fvrH/4bg2DqDxWHqrVvd6SWI1wSNW7e bSRBbz+q9C5VcauRCfJZSRYLEnIGg/zVT0zHL6FsPrykp2HyAZsKGR3LEqDq4SBddBFD NrfTrIpM38rDxZRSKVha/86CuTWV2AHyhn75bhhQ/S8Mjonh3iOSP0EQzAlXJGmDABQ/ DUO8sS6wj1wAIF0/DuiTM5gHAvqcvIsCnPmIiFYkThe8KH0ERaVKfAUiVvrLLPiEft0E STFymagRJbgG1FiHLjbGh+GoSrShc5v+wijFE86MdZue4VqyChSyY6S3fOueon+VhLP3 R3rw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=I11lJqhP; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id em3-20020a056402364300b00568b5637c0fsi2494681edb.618.2024.03.17.13.02.29; Sun, 17 Mar 2024 13:02:29 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=I11lJqhP; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 60CAD68D21F; Sun, 17 Mar 2024 22:01:25 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 33E6668CE16 for ; Sun, 17 Mar 2024 22:01:13 +0200 (EET) Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-513c8b72b24so4040449e87.3 for ; Sun, 17 Mar 2024 13:01:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710705672; x=1711310472; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=d3MtCUCOihj3VKTQqRWzPEObCrL2n3nz5OOEwI2agUs=; b=I11lJqhP82i/VMa2DAXSUtXQyG+e8DejzHiHUa9K44FwBMIYtX79hFmhchDzh4Zenz i0C4uGPlTSjqi3O+FoEhG/AzQmiPa8mX0h3T0vtT96bG3juMwAicKTGe78lKUX2F39Dg M6PcOwz4RvAYVGkua9zRgZ6/asCr3OeiEtEx0Xyur3sr/N2JpsWLU9XzNZ46Ng7MpBXv kvHYg2SqkRDN2JwMvngcISGihoxNnyFaWMI5FuwqNEg2UvuRHr+4EAnKMCWDaZiKJRba E/aI+y9m1eI4esGhCLCSE0GhyZY8vuXJFIToqDrl4TFI044xJLIIokpN8cehax65V7fR 2dZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710705672; x=1711310472; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d3MtCUCOihj3VKTQqRWzPEObCrL2n3nz5OOEwI2agUs=; b=P1je0QIKTtIybeQurHsr2UaZjxK3EPhxxnjEdomN5EMc4Z0F3rN9tgapMfu11OCOzV ADIsVynUoJ01lxAl9AE7T17t7sPRgUPHKdUzkYuRh0hf4BDWeTopT7qI1U9NeoEgCPeW JUaLjOPaw7B/GKQK23lCiyrIIAWCn1K1DT7NXNI4dDlmhfDWxUX6GWAnPEz6LMKDbBcZ 6VjVpBW2BHxlsxFdh2YxILAQsI6ORFDD/ei6nOkYzmZHwvGunWJTY5pBe0RyuV9KfUK7 JfKwlY2GueC/KcnK7w1tbRdk6AqkRpkSoX+QpkpvCvQTWKVhBre0LAlmVP8WieVNhq7p VDiQ== X-Gm-Message-State: AOJu0YzWUJ9nIRIzWfX5eftC4uIqJeL4dxKXYQue+WHZwSCAF0KLSbBw 8g2wC4rSJ3G/0LZRrt6N3Mx/5nST4qe/3m2/8blc7uuExOWvqpG+sabnGc5U X-Received: by 2002:a05:6512:3ca6:b0:513:d3e3:f78c with SMTP id h38-20020a0565123ca600b00513d3e3f78cmr8927053lfv.40.1710705672310; Sun, 17 Mar 2024 13:01:12 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id y3-20020a056512044300b00513c844603fsm1340462lfk.41.2024.03.17.13.01.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 13:01:12 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 22:00:45 +0200 Message-ID: <20240317200100.152097-9-jeebjp@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317200100.152097-1-jeebjp@gmail.com> References: <20240317200100.152097-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v9 08/14] avutil/frame: add helper for getting side data from array 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: My8rjaVtSX2C --- libavutil/frame.c | 20 +++++++++++++++----- libavutil/frame.h | 14 ++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 30db83a5e5..47ecd964b8 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -830,16 +830,26 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, return 0; } -AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, - enum AVFrameSideDataType type) +const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData **sd, + const int nb_sd, + enum AVFrameSideDataType type) { - for (int i = 0; i < frame->nb_side_data; i++) { - if (frame->side_data[i]->type == type) - return frame->side_data[i]; + for (int i = 0; i < nb_sd; i++) { + if (sd[i]->type == type) + return sd[i]; } return NULL; } +AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, + enum AVFrameSideDataType type) +{ + return (AVFrameSideData *)av_frame_side_data_get( + (const AVFrameSideData **)frame->side_data, frame->nb_side_data, + type + ); +} + static int frame_copy_video(AVFrame *dst, const AVFrame *src) { int planes; diff --git a/libavutil/frame.h b/libavutil/frame.h index a7e62ded15..e59f033cce 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1062,6 +1062,20 @@ AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, const AVFrameSideData *src, unsigned int flags); +/** + * Get a side data entry of a specific type from an array. + * + * @param sd array of side data. + * @param nb_sd integer containing the number of entries in the array. + * @param type type of side data to be queried + * + * @return a pointer to the side data of a given type on success, NULL if there + * is no side data with such type in this set. + */ +const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData **sd, + const int nb_sd, + enum AVFrameSideDataType type); + /** * @} */