From patchwork Sun Nov 26 19:58:23 2023 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: 44811 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bca6:b0:181:818d:5e7f with SMTP id fx38csp2879834pzb; Sun, 26 Nov 2023 11:59:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IGrZ6yO58jtIcf+1ZSwnXJ3IIeODvXhbFnK9uQcGRfuBCfyTEEx1lRQYTAasA0keLzRNoVq X-Received: by 2002:a17:906:5b:b0:a02:99b5:d0dc with SMTP id 27-20020a170906005b00b00a0299b5d0dcmr7171910ejg.10.1701028775509; Sun, 26 Nov 2023 11:59:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701028775; cv=none; d=google.com; s=arc-20160816; b=Ghf3IJ+QxlBFtIfGovzi7yJqEM9z/9TGsfchCzkM2hwnQTekvXEBKCrJdb0xm3cBpp OC9F7fIe1Vnbp9CtGD62nJvXLKKUL+qhmReK3Y+HU4QbmxurXs5FL4HtSCFy8kWG+DrP kUvNTpcH79KqOHB2qvI17piDP2y8vUmtK5TJ84PNHJKHzJfKZEJXbxiqWlCtRfbDzFge 9NjEsRbOHSvSVLdaEg+LPxmN058f/mwiyOOcPCR6UvgF16aZtdVpQq6p8i2mC0feU/+y MReC6uwk9MmY6iTytELbUIDHi3gmSSn5RFacHXc/vsNHD4cQS8h4glL0BRMmeotzfFWQ hgTQ== 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=G9WtvGwNaMRYfcc85MN/d9HFRR/iJNUSFZcZtWZDK/M=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=0nN82YWiTNKeq1Hg5GONNNlNqDy/xNi2r8yCo2JrwkolcrXNiyxyDnTyRTAgxEKL1o HY4MjJAdJ05aA++rLNbZnSS4RSPdTpJpC1CJfjYohvMgQMDF8DofiH+v/3tyZLMNaZOm 5sc7vCAQDANuWGBV/eVJth9Rv8mbrP01x8v77e5jq0MT4yGMahOK6FwZ2nAFJPnfiZh8 DVX5em6VFZ06MXEjRnuLRr/LHhYjA1uUeznSGZbYps7+n8jZXYhKYEfuIk9QXJKJQvMe tVI+P8I23C34Y7v4jyYwPRMULnLa5k6g/CfwpAGzCbf4f7woWoi5zzGmPM3SfjhjM0Gd jj5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=SDPvo4bD; 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 u24-20020a170906c41800b009fc6ac2810dsi4354702ejz.120.2023.11.26.11.59.35; Sun, 26 Nov 2023 11:59:35 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=SDPvo4bD; 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 D09E068CF88; Sun, 26 Nov 2023 21:58:58 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9967468CF5C for ; Sun, 26 Nov 2023 21:58:49 +0200 (EET) Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-50ba78c7ee2so2129820e87.3 for ; Sun, 26 Nov 2023 11:58:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701028729; x=1701633529; 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=+iho3qtVEgfxrxxKhLyLoYNFM/rc4iRaWmJZ8aYQlQI=; b=SDPvo4bDlVl5/ZQ2NKPe+FKNCQ6ttwh2yHti/uTF0+46sSZ7r1/Pl4tGIxu28rdbPm jSmL3yYMFDexRC566cf2N4g1iWH13jT5qQuXYMw6K8BhmeJq0r2OMoLPAKnAgb8C9kTO 9cZzJez+ML1VzzaSRDT6gsTpy8R9duNDz+yG4SKuRMIba6ThPkA8jCQ2ItB6GJPH90cQ o9bmWrI1+rpf9QyKDAVrisij+3dt090ipht4huVx57jqqfR835SSDQmfKWkHV8gp+RhU 9P9sRbw0rsrOX50/2cvHpU0Y6wFqvmPaJB3wXmPENRBleCSKAYxx9EXqcTHQ2q5tm85A X/yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701028729; x=1701633529; 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=+iho3qtVEgfxrxxKhLyLoYNFM/rc4iRaWmJZ8aYQlQI=; b=uemaoj1ZfcFh2NA7XqvQbcUzDMEB17LMvqfKJvC2mwat3FXeZDR0diVTnib4BICg45 B+CLL3oy+xF9ZB4PJ0t+JL69/40pre6Z/2NI5DVtm1LToRZuzHKu0t2xVdtX+F2vdalf pgyunwk81O4bR+4tN1CwOA7ZlP7fHZiag7eFhZkIloJY5kcET78goM5fP4A/0H7J61hv A5WMSCYKaqZ5RzwNDVQJZ2xMy3EU9RD8xGCd7qpMibpDstlh1NPv68v4hsZQOuIHRRM8 Lz38LPenxvYhHePjIpdMWlpPZZ5WuO624MxyFPDZ6kNwiTbHcjwbr2ylfox2faeBA0Ri 8QIA== X-Gm-Message-State: AOJu0YxDui0lA8pyBKvA2Pn5lxdGwWxJCDRNEHnATmfaeDJwUwO1D0NR JsDN6vt4I1z8QfjfnKMMWtrZ05oN+AI= X-Received: by 2002:a05:6512:3f1e:b0:507:9803:ff8b with SMTP id y30-20020a0565123f1e00b005079803ff8bmr7357887lfa.44.1701028728592; Sun, 26 Nov 2023 11:58:48 -0800 (PST) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id k16-20020ac24f10000000b00500d1a72734sm1281833lfr.130.2023.11.26.11.58.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Nov 2023 11:58:48 -0800 (PST) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 26 Nov 2023 21:58:23 +0200 Message-ID: <20231126195838.392467-5-jeebjp@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231126195838.392467-1-jeebjp@gmail.com> References: <20231126195838.392467-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v5 04/14] avutil/frame: split side_data_from_buf to base and AVFrame func 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: Oqkc53T53KaU --- libavutil/frame.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 941a0a8148..49da452fa5 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -787,23 +787,22 @@ FF_ENABLE_DEPRECATION_WARNINGS return NULL; } -AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, - enum AVFrameSideDataType type, - AVBufferRef *buf) +static AVFrameSideData *add_side_data_to_set_from_buf(AVFrameSideDataSet *set, + enum AVFrameSideDataType type, + AVBufferRef *buf) { AVFrameSideData *ret, **tmp; if (!buf) return NULL; - if (frame->nb_side_data > INT_MAX / sizeof(*frame->side_data) - 1) + if (set->nb_sd > INT_MAX / sizeof(*set->sd) - 1) return NULL; - tmp = av_realloc(frame->side_data, - (frame->nb_side_data + 1) * sizeof(*frame->side_data)); + tmp = av_realloc(set->sd, (set->nb_sd + 1) * sizeof(*set->sd)); if (!tmp) return NULL; - frame->side_data = tmp; + set->sd = tmp; ret = av_mallocz(sizeof(*ret)); if (!ret) @@ -814,7 +813,23 @@ AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, ret->size = buf->size; ret->type = type; - frame->side_data[frame->nb_side_data++] = ret; + set->sd[set->nb_sd++] = ret; + + return ret; +} + +AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, + enum AVFrameSideDataType type, + AVBufferRef *buf) +{ + AVFrameSideDataSet set = { + .sd = frame->side_data, + .nb_sd = frame->nb_side_data, + }; + AVFrameSideData *ret = add_side_data_to_set_from_buf(&set, type, buf); + + frame->side_data = set.sd; + frame->nb_side_data = set.nb_sd; return ret; }