From patchwork Sun Apr 25 21:25:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lynne X-Patchwork-Id: 27374 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:5014:0:0:0:0:0 with SMTP id e20csp3424898iob; Sun, 25 Apr 2021 14:26:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7IZeXLB2jnpV9unBbZc6tUpUo6B+P+Cc5bCEh7X/CGX6MvXZB3K3dSdinXNXgYPsNnImJ X-Received: by 2002:a17:906:3111:: with SMTP id 17mr14996750ejx.403.1619385966610; Sun, 25 Apr 2021 14:26:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619385966; cv=none; d=google.com; s=arc-20160816; b=T5FtJpLlkdDQNmNyQWMQWPAb1cDbwf3mHNIAgofogn0jatfvkEr5uZF29+CmTQDWsp Ww4G7B7hVP6+wIVn1mBYLmd8C+Vrd1H+1c3+eeKnI50HWbXnX5x+A9AyjEhV1ylknFCx gm0LJPYGszf/ROmjgFy9aQhxQtS349LOA2yOTIG6kGlMiCKy8M/85j4Oq5GcGYgjKKNJ 3hgyU2z6nzYuPMNmMIGZE3ufQ9ADPzMuLrCm2qGouf1fxEMGftX4oDB5zkFyZh42CZGo JjEndQQ7OMWj/zX6r/lUHpeL7JVroNU6+J8jixGnLi7TNbtihyb4VVPCZABuJe/l6o86 TpVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:message-id:to:from:date:dkim-signature:delivered-to; bh=INzAFUKfgprEN38YsS8c60dWCcMz3aFOJEDb15qC/fA=; b=ijsr+6sCl9qzhm0gxWN66wys6j0jfhb3OMQmyyc37fFWNb1+VCApyZki38sbnxFFYF TYRAistUvv3cOGcJajxl74pXiGiyofjxOAb5USlF5QhNNpUOXmWVUFrtWCJneJLzqknS MjEqrk8AlgRKdj/0Af7Z2QyODgpKoGzRBe3AiqSRq/D//XmqLnB4Bns/1Xnhgx/SI9gy gyKkJvgmY88kjMUOkdVBLUc4S+55NF9/ZpcrVnID4Gn+D9SIU1ZjkCgrG5jNzEBsY+Ee FAR5spRmOeg5+tE8tDu8dciob7E8cgr2fJ5CONtbpiKHzlPdhQlvEeofMHdW7o9RFMvL N7Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@lynne.ee header.s=s1 header.b=JAEsWHAc; 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=NONE dis=NONE) header.from=lynne.ee Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id d16si11063607edz.507.2021.04.25.14.26.05; Sun, 25 Apr 2021 14:26:06 -0700 (PDT) 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=@lynne.ee header.s=s1 header.b=JAEsWHAc; 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=NONE dis=NONE) header.from=lynne.ee Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 217BA6880B0; Mon, 26 Apr 2021 00:26:02 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 705226806F3 for ; Mon, 26 Apr 2021 00:25:55 +0300 (EEST) Received: from w3.tutanota.de (unknown [192.168.1.164]) by w4.tutanota.de (Postfix) with ESMTP id 0C678106015B for ; Sun, 25 Apr 2021 21:25:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1619385954; s=s1; d=lynne.ee; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:Sender; bh=GgxWYyWubUGHDxz2leKc+BLu5fKOYOuPJeT1JjtxZ1I=; b=JAEsWHAcxpq7OHP7j4o7dzHO0IWA1LvR1kwuvJAkmOchsoXZV1HjAOg8TLvMHicT 3goulEDphdIa8cTxVo94t6bUpRUGOLIutl3gKP8TbuXNFXG3w9WfNAzpt8YrxFutvUD 16uow7r3c7gHPm8lsicBk9MKxIiyMkkgT0R28044905ONP9P/lu4JFedBK2XqUnlXHz og9rUHjzDXDxLHgU/y5HH/SmdQwT0GuXii48+22YBf7sHRKZcVtZvbFBr/Plwxcf1FK 8MehcpNNaBfZ+4le8ztdNW2yaEysbWePUztllavbP6hCbuN2T3EXPfngSrP16MfrBqd Jip1tFZKHQ== Date: Sun, 25 Apr 2021 23:25:54 +0200 (CEST) From: Lynne To: Ffmpeg Devel Message-ID: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avpacket: ABI bump additions 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: l7MTKTnhJtSe This is the same patch sent in January, rebased on top of the ABI bump patchset. Two additions mirror exactly what AVFrame has - an opaque field and an opaque_ref for user-side private data. For justification on the void *opaque field, you can read the archives, since the question was brought up in January. As for the time_base field, for now, it will only be used to inform the user, and will not alter the behavior of the libraries. That change will come as an optional flag. Patch attached. Subject: [PATCH] avpacket: ABI bump additions --- libavcodec/avpacket.c | 5 +++++ libavcodec/packet.h | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index e32c467586..03b73b3b53 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -382,6 +382,10 @@ int av_packet_copy_props(AVPacket *dst, const AVPacket *src) dst->flags = src->flags; dst->stream_index = src->stream_index; + i = av_buffer_replace(&dst->opaque_ref, src->opaque_ref); + if (i < 0) + return i; + dst->side_data = NULL; dst->side_data_elems = 0; for (i = 0; i < src->side_data_elems; i++) { @@ -403,6 +407,7 @@ int av_packet_copy_props(AVPacket *dst, const AVPacket *src) void av_packet_unref(AVPacket *pkt) { av_packet_free_side_data(pkt); + av_buffer_unref(&pkt->opaque_ref); av_buffer_unref(&pkt->buf); get_packet_defaults(pkt); } diff --git a/libavcodec/packet.h b/libavcodec/packet.h index fad8341c12..c29ad18a2b 100644 --- a/libavcodec/packet.h +++ b/libavcodec/packet.h @@ -383,6 +383,27 @@ typedef struct AVPacket { int64_t duration; int64_t pos; ///< byte position in stream, -1 if unknown + + /** + * for some private data of the user + */ + void *opaque; + + /** + * AVBufferRef for free use by the API user. FFmpeg will never check the + * contents of the buffer ref. FFmpeg calls av_buffer_unref() on it when + * the packet is unreferenced. av_packet_copy_props() calls create a new + * reference with av_buffer_ref() for the target packet's opaque_ref field. + * + * This is unrelated to the opaque field, although it serves a similar + * purpose. + */ + AVBufferRef *opaque_ref; + + /** + * Time base of the packet's timestamps. + */ + AVRational time_base; } AVPacket; #if FF_API_INIT_PACKET