From patchwork Sat Jan 23 19:10:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lynne X-Patchwork-Id: 25124 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 8B8B3449B8B for ; Sat, 23 Jan 2021 21:10:54 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6705268828E; Sat, 23 Jan 2021 21:10:54 +0200 (EET) 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 1794B688126 for ; Sat, 23 Jan 2021 21:10:48 +0200 (EET) Received: from w3.tutanota.de (unknown [192.168.1.164]) by w4.tutanota.de (Postfix) with ESMTP id B264610602E1 for ; Sat, 23 Jan 2021 19:10:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1611429046; 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=MeBpp/mjBcJXEYFqDdKe6bZirI0HMH8Y1pnlYZ7kGoY=; b=Fgzj9kTHSWc3sgrxcmLaeLNjymA6zzDEHKBj6QQCKTsEuGYJggvQTJL8O0hysdzS rttMWaO7YrCOVfTmGck+7zv7owwYajluuydVG7byK2HQLJRw+MkSggX+JyhC5sIC0Gk Vo6lx+aRQ/k2pIPv+eN4fFzU3fTkvGi7oWO1iyEsVqzlfpA5ar4tMuVpkPqSZX8uPMM tA2gVOV0WKFNtuA3Z/CWCwJjmNvMjfKZCZVAiHg8GusNQhIkYrVqDUhdUUOiQsak6yX nLw+qKlbkUlxe2V7JzURFRNkOmmPGjJ7XCNgYpAI5q769EiAuKZmxboQOeSQV68oLiw WFLbkhbcMA== Date: Sat, 23 Jan 2021 20:10:46 +0100 (CET) From: Lynne To: Ffmpeg Devel Message-ID: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avpacket: RFC for ABI bump additions 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This is an RFC about the upcoming additions to the AVPacket structure (whose size is still part of the ABI, so we need to plan for any changes). The current RFC patch adds 3 fields:     - "void *opaque;" for the user to use as they wish, same as AVFrame.opaque     - "void *opaque_ref;" for more permanent and propagating user data, same as AVFrame.opaque_ref     - "AVRational time_base;" which will be set to indicate the time base of the packet's timestamps Some devs (JEEB) wanted reception timestamps and original, overflowed timestamps for MPEG-TS. I'd be willing to add a reception timestamp as long as we add an additional time_base field and make it independent of the packet's pts field, since those timestamps are usually on highly precise system clock time bases, and reducing their precision would be undesirable. I'm not sure about overflowed original timestamps or how they would help. Perhaps we should introduce an AVBufferRef *internal_ref like with AVFrame to store such single library-only data? Subject: [PATCH] avpacket: RFC for ABI bump additions Signed-off-by: James Almer --- doc/APIchanges | 3 +++ libavcodec/avpacket.c | 9 +++++++++ libavcodec/packet.h | 23 +++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/doc/APIchanges b/doc/APIchanges index bbf56a5385..d239ef7627 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2017-10-21 API changes, most recent first: +2021-xx-xx - xxxxxxxxxx - lavc 59.100.100 - avpacket.h + Add AVPacket.opaque, AVPacket.opaque_ref and AVPacket.time_base + 2021-01-11 - xxxxxxxxxx - lavc 58.116.100 - avcodec.h Add FF_PROFILE_VVC_MAIN_10 and FF_PROFILE_VVC_MAIN_10_444. diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index e4ba403cf6..cf2c5efb66 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -585,6 +585,12 @@ FF_ENABLE_DEPRECATION_WARNINGS dst->flags = src->flags; dst->stream_index = src->stream_index; +#if LIBAVCODEC_VERSION_MAJOR > 58 + i = av_buffer_replace(&dst->opaque_ref, src->opaque_ref); + if (i < 0) + return i; +#endif + dst->side_data = NULL; dst->side_data_elems = 0; for (i = 0; i < src->side_data_elems; i++) { @@ -606,6 +612,9 @@ FF_ENABLE_DEPRECATION_WARNINGS void av_packet_unref(AVPacket *pkt) { av_packet_free_side_data(pkt); +#if LIBAVCODEC_VERSION_MAJOR > 58 + av_buffer_unref(&pkt->opaque_ref); +#endif av_buffer_unref(&pkt->buf); av_init_packet(pkt); pkt->data = NULL; diff --git a/libavcodec/packet.h b/libavcodec/packet.h index b9d4c9c2c8..8e3f95e6ae 100644 --- a/libavcodec/packet.h +++ b/libavcodec/packet.h @@ -391,6 +391,29 @@ typedef struct AVPacket { attribute_deprecated int64_t convergence_duration; #endif + +#if LIBAVCODEC_VERSION_MAJOR > 58 + /** + * 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; +#endif } AVPacket; typedef struct AVPacketList {