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 7BC2F4A432 for ; Thu, 28 Mar 2024 03:13:07 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4E14C68D6F7; Thu, 28 Mar 2024 05:12:49 +0200 (EET) Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DD1AD68D1AE for ; Thu, 28 Mar 2024 05:12:41 +0200 (EET) Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-6e69a9c0eaeso297421a34.3 for ; Wed, 27 Mar 2024 20:12:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711595559; x=1712200359; 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=D4XKWHImBFVZyGI+3N8WOnDK82IyGtdzc5wiQ2b6UmA=; b=X08gvrfn1RpqOdjaaxRmDtptP4NTVCUtORW6ib87ECA8U9dknib8KOX8U39ExBuAio vLc/wBNFRyokUB7PF8IvbZQAVadmXCzXnZdg5gpi7ht6xKnG3t8MPIxsaokW351+v91b mFre5ywvNrBWzMSqlKgRB9ctUVtI/gztQ3fmynVYCMq6ovzZlqGjt4YNKiMxsKX1MHhH N3X/XG81VGsTPruE2YwGyKeHVn0GbZSCsqlIPpObWBFW+wnKRfFnbIrewkhRKNtLcPJ4 dtvCjbyLMjLnAxUKwUu07PjO7i/4k46WrO3rG14qpyfiEwNDv3NFYJnmXqGhKzelQRQ1 YvMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711595559; x=1712200359; 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=D4XKWHImBFVZyGI+3N8WOnDK82IyGtdzc5wiQ2b6UmA=; b=N22l4CK755Hy1lb9v7NU37PVHmp9bmwWog+jbwVaeS2AIVmKanBzjl5qsPHDzb1V9S KDww/30Mbire+xAublWses8xUZFs2LbEbYFWfddUc7vUfXXr4QY5sQf4NEWVVxt7OEn6 sEV1oMdCpchoPbbwDLduJiaOpdTl+PtVcZhMdEcu30viobomchyprgfU+dMTsQjc2pQL sFJjHaKxUv9V0QDrRMukM4s+PsaocyA4bg2Ozcv1FOsEInd85YZVToEwyc/laimOglAv 0pm2ha/uqU1ttbdniKZBjpw1rP+YsPJKKjCUXzVvhpAac8Vg4+LxEk8CZhzKVMuJzAhX hGSQ== X-Gm-Message-State: AOJu0YwJ6gknzFBpc9YV8wyOp0GLsTpJI3g378RiWXqo4+s7EuGJUDjs KCJB5zX2LWrTNlcjnWugjxng9AOl0Bil7BahBkXAw5wq0cgNlUsBhMC7KAXH X-Google-Smtp-Source: AGHT+IHFj0lZDNKwMpdQCiWZOkki7xhMdMzI5fjBolQCqr0bjIUcTXY2HAKnw4/g3DPvl3PrMi3xwg== X-Received: by 2002:a9d:6c86:0:b0:6e5:1e4b:c3f1 with SMTP id c6-20020a9d6c86000000b006e51e4bc3f1mr1965698otr.34.1711595559293; Wed, 27 Mar 2024 20:12:39 -0700 (PDT) Received: from localhost.localdomain ([190.194.167.233]) by smtp.gmail.com with ESMTPSA id q20-20020a635054000000b005dc120fa3b2sm249964pgl.18.2024.03.27.20.12.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 20:12:38 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 28 Mar 2024 00:12:06 -0300 Message-ID: <20240328031210.21407-3-jamrial@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240328031210.21407-1-jamrial@gmail.com> References: <20240328031210.21407-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/7 v4] avutil/frame: use the same data pointer 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 does not need to match src->buf->data Signed-off-by: James Almer --- libavutil/frame.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index a165e56a64..d27998d1f4 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -744,13 +744,11 @@ AVBufferRef *av_frame_get_plane_buffer(const AVFrame *frame, int plane) static AVFrameSideData *add_side_data_from_buf(AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type, - AVBufferRef *buf) + 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; @@ -778,9 +776,13 @@ AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef *buf) { + if (!buf) + return NULL; + return add_side_data_from_buf( - &frame->side_data, &frame->nb_side_data, type, buf); + &frame->side_data, &frame->nb_side_data, type, buf, + buf->data, buf->size); } AVFrameSideData *av_frame_new_side_data(AVFrame *frame, @@ -827,7 +829,9 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, } buf = av_buffer_alloc(size); - ret = add_side_data_from_buf(sd, nb_sd, type, buf); + if (!buf) + return NULL; + ret = add_side_data_from_buf(sd, nb_sd, type, buf, buf->data, size); if (!ret) av_buffer_unref(&buf); @@ -873,8 +877,10 @@ AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, buf = (flags & AV_FRAME_SIDE_DATA_FLAG_NEW_REF) ? av_buffer_ref(*pbuf) : *pbuf; + if (!buf) + return NULL; - sd_dst = add_side_data_from_buf(sd, nb_sd, type, buf); + sd_dst = add_side_data_from_buf(sd, nb_sd, type, buf, buf->data, buf->size); if (!sd_dst) { if (flags & AV_FRAME_SIDE_DATA_FLAG_NEW_REF) av_buffer_unref(&buf); @@ -933,7 +939,7 @@ 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(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".