From patchwork Sun Nov 5 12:34:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 5865 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.90 with SMTP id m26csp1860070jah; Sun, 5 Nov 2017 04:35:12 -0800 (PST) X-Google-Smtp-Source: ABhQp+T6PFdszLcS/0LZLgca7SCB7sFaJvZEO/uvqlllgHsl69s2lwjeKhJYwuHcz8kdrk1xVTQ4 X-Received: by 10.28.29.215 with SMTP id d206mr3162806wmd.130.1509885312837; Sun, 05 Nov 2017 04:35:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509885312; cv=none; d=google.com; s=arc-20160816; b=KAtb7wBo4BslAqGvLbb0mscpIqlBYnsJFGB32myEC0UF2V0jfVHEjxbQADzvptJ7Yp 6Wj68BuSDhpdpKrbFC96cktpinHZJlUx+9+NXgdAIw4Rl3b7kcJvh2SPhXQ+rrG8eVSO A4pZkK2p8tSjWwZYI2gI2N6ZKe2Ic0Q8TEp5eiaamqQSChVjKbBJpB60zzypeNia7dyl ijCf5IJomvy6Zolp7A67bh1jAqkNpcij1KVWT1irs7w3zm+LMg61lKHhxs0yd4cjkeuq Z4ozvxO28i+VDmD/Y60iThLBETpfnOFutejn2s03lmUp/Ksm6uWhwPQRG/YGgFcYxcrW LeEg== 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:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to :arc-authentication-results; bh=ZRDkcinBuJVgQg5Ryil8gZzg4imnA7KcjqlGPPNfZGA=; b=EH72fvWDAyVujO8yo0XgII2185XumYbJ0B0tJvitFovoaprn5m11Jbtg0n9AljO9Ok CqfXPV0AVR0I9hNotP0sIHF5UMPuEPC8HKo3FJ2JHlK5X1EnelPdyppde0uTFnIqWSIB 7otChBbtYjrezCkqGWYqpiJ9cSIktXqzSiiQkgZ6Q2ov7vdjQIXtFotZ+2/iweKw9jve bZ0MpsSx+4rbY1AuQ8Iiehfwce8gCXD0HerUhX7HkA96G5naPxze8vpbp6x5UlzuIAlm TeY31FuOZNoMHjqOoiGzTt85kIAaK1FY5QnWNYkpUk9PtR6qvDfn2YR3ZnPkP3kTaabx Y+Mg== ARC-Authentication-Results: i=1; mx.google.com; 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 x14si2605694wrg.244.2017.11.05.04.35.11; Sun, 05 Nov 2017 04:35:12 -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; 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 0CFF3689CAD; Sun, 5 Nov 2017 14:34:59 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe01-1.mx.upcmail.net (vie01a-qmta-pe01-1.mx.upcmail.net [62.179.121.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4278F689C12 for ; Sun, 5 Nov 2017 14:34:52 +0200 (EET) Received: from [172.31.218.34] (helo=vie01a-dmta-pe02-1.mx.upcmail.net) by vie01a-pqmta-pe01.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1eBK8l-00048z-IT for ffmpeg-devel@ffmpeg.org; Sun, 05 Nov 2017 13:35:03 +0100 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe02.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1eBK8f-0001Qk-Lc for ffmpeg-devel@ffmpeg.org; Sun, 05 Nov 2017 13:34:57 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id WCar1w0140S5wYM01CashH; Sun, 05 Nov 2017 13:34:52 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 5 Nov 2017 13:34:51 +0100 Message-Id: <20171105123451.22556-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.15.0 Subject: [FFmpeg-devel] [PATCH] avutil/frame: Add avcodec_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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This gives libavcodec a field that it can freely and safely use. Avoiding the need of wraping of a users opaque_ref field and its issues. Signed-off-by: Michael Niedermayer --- libavutil/frame.c | 8 +++++++- libavutil/frame.h | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 982fbb5c81..6ddaef1e74 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->avcodec_private_ref); if (src->opaque_ref) { dst->opaque_ref = av_buffer_ref(src->opaque_ref); if (!dst->opaque_ref) return AVERROR(ENOMEM); } - + if (src->avcodec_private_ref) { + dst->avcodec_private_ref = av_buffer_ref(src->avcodec_private_ref); + if (!dst->avcodec_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->avcodec_private_ref); get_frame_defaults(frame); } diff --git a/libavutil/frame.h b/libavutil/frame.h index 0c6aab1c02..73b7d949a9 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -563,6 +563,16 @@ typedef struct AVFrame { /** * @} */ + /** + * AVBufferRef for free use by libavcodec. Code outside avcodec will 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 avcodec_private_ref field. + * + * avcodec should never assign mutually incompatible types to this field. + */ + AVBufferRef *avcodec_private_ref; } AVFrame; #if FF_API_FRAME_GET_SET