From patchwork Fri Nov 10 16:03:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Rothenpieler X-Patchwork-Id: 5935 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.90 with SMTP id m26csp3544889jah; Fri, 10 Nov 2017 08:03:51 -0800 (PST) X-Google-Smtp-Source: AGs4zMbBrTdHBIXQOXlJN0JxuP2XAviwYC1vaIspPWZYMlNi0vFAvrmlAhpuycK5jFop0nL0vDfQ X-Received: by 10.223.131.129 with SMTP id 1mr697071wre.205.1510329831319; Fri, 10 Nov 2017 08:03:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510329831; cv=none; d=google.com; s=arc-20160816; b=W+CN4SI/EuGLFAAji9VbFjcUDQXME6kRiOH32z3TOetMWkjoZNHeKcbyl9nB54bpkD 66hdh6DLjvVMLV9PrxzRJ2VLmE4bY7xLAWTIc84C0XX5lNUqkLjO7nBzYEBwT0rS+OJG 90X4noVCA+wAJI/y0LwkVkqb2aqNuGIw+YrT1M3ZtBo1S5B/rRuVYy+K0/jcb1lAI6uR wKP7Q/XSRQfR9L0RivecK07dB7YD+FmyRNF0ANdt5X/WdKH/aSseGqq2BcQFF7lQkEu+ 9VPjHTnEfYgUgSoKdRL9D7ev64NVeMoK1e5kWtkE5eOuXwvLLsN137MPK+u48Ps8CEw4 PdzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=h4A8iMxkhzit6JCQop5jiecFdS2IXuSMnIccuhM04Ns=; b=M8ceTFBxL8ks1WJhhUk7lcBj5bwtcgyim8k/mriVfbVevaQ5CX1jTZ1hVaXEM5rhtG ikhv5j2wScBO8I+z8RgZ4iFudGuC5ShOXelB/PIOcz27UfecuUUZySDz2rMqVwjBOXWw ZMABre8HT2irIwKxxYM5ZAnccmB+p2C1LXehN1lJh05ElaGLg4bDZgsp/hOMbQQK/D0Y gb4AvlTn2piBA3ybC2tQwptr8vJ453tTOlkSEY36+7kKMsfS5yedS9PEXodPugd6YSJX iWVA2iLL6FJDKG1iThHjKifF1KMLzQXc3oR4aYbKwJqFeB5DAu+cXmS8J/0PvmH71mMx Nk8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rothenpieler.org header.s=mail header.b=jd+6slfx; 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 s47si7894874wrc.173.2017.11.10.08.03.50; Fri, 10 Nov 2017 08:03:51 -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=@rothenpieler.org header.s=mail header.b=jd+6slfx; 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 828E4689E8E; Fri, 10 Nov 2017 18:03:23 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from btbn.de (btbn.de [5.9.118.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1B6E3689DAE for ; Fri, 10 Nov 2017 18:03:17 +0200 (EET) Received: from localhost.localdomain (unknown [134.102.43.210]) by btbn.de (Postfix) with ESMTPSA id 42ED43C5D6; Fri, 10 Nov 2017 17:03:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rothenpieler.org; s=mail; t=1510329809; bh=XW5bbrAwtpP6++YWJrerbWGyh77syyFJWZhtWlD7gd8=; h=From:To:Cc:Subject:Date; b=jd+6slfxiGMloF2ld873rlpbsTWcyCzypMYCbwqDlumKfnIuqR+axgJdkEs5yKXxw vr9pIdHunTx+NXwyyduBvCZAxsrW4mlLFSQ+YPQ4pqZlcS6DVdBz3bJQaCEuMlAaPf 53Dws3aZtzyJPSOuFxCMh0z7AxbqVVKrZIHcjZoQ= From: Timo Rothenpieler To: ffmpeg-devel@ffmpeg.org Date: Fri, 10 Nov 2017 17:03:14 +0100 Message-Id: <20171110160317.3584-1-timo@rothenpieler.org> X-Mailer: git-send-email 2.15.0 Subject: [FFmpeg-devel] [PATCH 1/4] avutil/frame: Add private_ref to AVFrame X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Michael Niedermayer MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Michael Niedermayer This gives FFmpeg libs a field that they can freely and safely use. Avoiding the need of wrapping of a users opaque_ref field and its issues. Signed-off-by: Michael Niedermayer --- libavutil/frame.c | 8 +++++++- libavutil/frame.h | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 982fbb5c81..662a7e5ab5 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -383,12 +383,17 @@ FF_ENABLE_DEPRECATION_WARNINGS #endif av_buffer_unref(&dst->opaque_ref); + av_buffer_unref(&dst->private_ref); if (src->opaque_ref) { dst->opaque_ref = av_buffer_ref(src->opaque_ref); if (!dst->opaque_ref) return AVERROR(ENOMEM); } - + if (src->private_ref) { + dst->private_ref = av_buffer_ref(src->private_ref); + if (!dst->private_ref) + return AVERROR(ENOMEM); + } return 0; } @@ -524,6 +529,7 @@ void av_frame_unref(AVFrame *frame) av_buffer_unref(&frame->hw_frames_ctx); av_buffer_unref(&frame->opaque_ref); + av_buffer_unref(&frame->private_ref); get_frame_defaults(frame); } diff --git a/libavutil/frame.h b/libavutil/frame.h index 0c6aab1c02..d54bd9a354 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -563,6 +563,19 @@ typedef struct AVFrame { /** * @} */ + + /** + * AVBufferRef for internal use by a single libav* library. + * Must not be used to transfer data between libraries. + * Has to be NULL when ownership of the frame leaves the respective library. + * + * Code outside the FFmpeg libs should never check or change the contents of the buffer ref. + * + * FFmpeg calls av_buffer_unref() on it when the frame is unreferenced. + * av_frame_copy_props() calls create a new reference with av_buffer_ref() + * for the target frame's private_ref field. + */ + AVBufferRef *private_ref; } AVFrame; #if FF_API_FRAME_GET_SET