From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id C036D49AA2 for ; Thu, 28 Mar 2024 16:53:54 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0C15668D056; Thu, 28 Mar 2024 18:53:38 +0200 (EET) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 717D668D591 for ; Thu, 28 Mar 2024 18:53:31 +0200 (EET) Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1def89f0cfdso17995175ad.0 for ; Thu, 28 Mar 2024 09:53:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711644809; x=1712249609; 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=2CXOi5Xmnl6ODPKl09G0iN+OyC37sEjQsh/qudo/ZqQ=; b=CPIiURf7W169TA66YXt31OmMMrBFgM50C4mX/oRBdteirXa4eR4egAFtCG+ktARZaL cV/QwSMvJXX7Juik2U3jzR5t+TZDkXoYI9S08B5zTBbIgbwhN43KeV2BbHcWmpIUkXye cRRbwX4oY608R5vJxuSmy2WUbp8vwQUeUdbySHIsRbjYVMMuHI9z24n8EtvcRgEAe5zL KIw3qZlzReXvWu9/h7TBZ6d/5AHYuYW21HyAEvjIJCg0uJSZ9O1/ry2o1Bqf35DtbIaF c3n9puDsGW7N9B+uqxAQlZ2ZixevI3LJWAnAmC8dHfYOGwB+fuUuVtBKwmSboorlY2uw IgSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711644809; x=1712249609; 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=2CXOi5Xmnl6ODPKl09G0iN+OyC37sEjQsh/qudo/ZqQ=; b=dTYAlbDg/nOpjsTR5cAU/5Oj0WFiHP+RZ5Th07Je2VHhRvk6m5ayxU8YsA6klxxKSn ykrsYEs1Px40Bz/BoY6eH/1acYXh0HQK/EWXJNF0eU+uqNXG0Ad4KSA15H37Hq9nU2py hMSo3NxtMRLXn4C7pMm+A1HJOy5tTP5CBfeXl9if7e7Qk7kSYxQevesskeIwGrzdJmfk vjGdmdO3mwUzQbSz+z97Y6MLAtIPeWgH1OvU4uoR4a/Vunrx8g4eQjjk3hp7SfizXLin 5m4xSdIecopgWzn30eH545VBovBzu4txHr+EGGKKiwFNqwwVIGW6bQpxRdgQ10/b2qg/ VkiQ== X-Gm-Message-State: AOJu0YwSQY9VNgoHDS7wGPrHwPtggMn23qvCzNsn/8jajdhqVsRvtzSS e5wGqWhleV/emA2jN7gnPdU4blgzHAPdvgufs0a1hYFL/KXs87/1Rwg5Rcad X-Google-Smtp-Source: AGHT+IGiB0NlnN6ffSWUyCGHdrqJ49R0lGdwl9aHIFeWQ1fJsO2LTw1Sq+43Pwh9iyP2eoVmWh5OOg== X-Received: by 2002:a17:902:e54d:b0:1e0:9d43:55cb with SMTP id n13-20020a170902e54d00b001e09d4355cbmr4032424plf.34.1711644808572; Thu, 28 Mar 2024 09:53:28 -0700 (PDT) Received: from localhost.localdomain ([190.194.167.233]) by smtp.gmail.com with ESMTPSA id w4-20020a1709029a8400b001d8f111804asm1822860plp.113.2024.03.28.09.53.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 09:53:27 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 28 Mar 2024 13:52:46 -0300 Message-ID: <20240328165250.64259-3-jamrial@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240328165250.64259-1-jamrial@gmail.com> References: <20240328165250.64259-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/7 v5] avutil/frame: use the same data information as the source entry when cloning side data 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: src->{data,size} does not need to match src->buf->{data,size}. Signed-off-by: James Almer --- libavutil/frame.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 9c3569db0e..d37f1511e8 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -741,16 +741,14 @@ AVBufferRef *av_frame_get_plane_buffer(const AVFrame *frame, int plane) return NULL; } -static AVFrameSideData *add_side_data_from_buf(AVFrameSideData ***sd, - int *nb_sd, - enum AVFrameSideDataType type, - AVBufferRef *buf) +static AVFrameSideData *add_side_data_from_buf_ext(AVFrameSideData ***sd, + int *nb_sd, + enum AVFrameSideDataType type, + AVBufferRef *buf, uint8_t *data, + size_t size) { AVFrameSideData *ret, **tmp; - if (!buf) - return NULL; - // *nb_sd + 1 needs to fit into an int and a size_t. if ((unsigned)*nb_sd >= FFMIN(INT_MAX, SIZE_MAX)) return NULL; @@ -765,8 +763,8 @@ static AVFrameSideData *add_side_data_from_buf(AVFrameSideData ***sd, return NULL; ret->buf = buf; - ret->data = ret->buf->data; - ret->size = buf->size; + ret->data = data; + ret->size = size; ret->type = type; (*sd)[(*nb_sd)++] = ret; @@ -774,6 +772,17 @@ static AVFrameSideData *add_side_data_from_buf(AVFrameSideData ***sd, return ret; } +static AVFrameSideData *add_side_data_from_buf(AVFrameSideData ***sd, + int *nb_sd, + enum AVFrameSideDataType type, + AVBufferRef *buf) +{ + if (!buf) + return NULL; + + return add_side_data_from_buf_ext(sd, nb_sd, type, buf, buf->data, buf->size); +} + AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef *buf) @@ -901,7 +910,8 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, if (!buf) return AVERROR(ENOMEM); - sd_dst = add_side_data_from_buf(sd, nb_sd, src->type, buf); + sd_dst = add_side_data_from_buf_ext(sd, nb_sd, src->type, buf, + src->data, src->size); if (!sd_dst) { av_buffer_unref(&buf); return AVERROR(ENOMEM); -- 2.44.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".