From patchwork Mon Oct 18 12:47:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 31144 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2084:0:0:0:0 with SMTP id a4csp3262028ioa; Mon, 18 Oct 2021 05:47:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEb5TRyVGQl/2mM57BoViDwjZXFBqZ5fIhab5gpFABz1W1OqdRk7FwvIY1cKd07uKwioAf X-Received: by 2002:a17:907:c25:: with SMTP id ga37mr29201920ejc.2.1634561271011; Mon, 18 Oct 2021 05:47:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634561271; cv=none; d=google.com; s=arc-20160816; b=Tln1dj06a1CA36HaBgjRwmrjEJEk3tg9jqT4cPSBmZStvP7NAxicpKUSFi6cRPVt2s rheMDLQK4z/fmek1Afe6h/gCnAT8OhCQiSkil3kZqkLjLeekoc8KKTlII/BCPHCR2841 J08PG/49PKS96c6PvY6N9jPxKWw5W087N6bI+HEXqt9aOp+b8LsUq9VeVrZxR6vHU43+ we6sKaMENLR+p777tbKLB0Ju1w1ITFOlenbwbrCkYQXR//D9dKRGRuaKMKR7aFECfMZV Ya6OVd8g8/LkQ8VTAq2VqrVkLRnQb99uviFEMqvQhdFaYrEC12YuW2i8OelS5HCbLvJY SBHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=wRSEctCSmBoKcaCnnExPgzkkFSykaOoErg5UDBq8UPE=; b=ihc2Zb4Cp2csn47ULIUuOcMHeKBI8XOy11wljmaZWvvh9bkwhQQTC5uLkk3SmHNYrp /nXDsdRVGfuMTgGuIj1cVzHRd8z8tWd9rLCjYmRMt7Y/4/wa873VPOmj0UUCNAWgJjho 8c1QHlBcpO4PEHIhs1isg+HCJfwSyXpZgX1xPm0oWWovMWsk7suULrV8ugKPUZbBNLJy uX4P7gAbDFkR34u9HaLh5hQiWKSPmvIO94KI5vAwES21kE8DLix6AC7gBY++dhKOYASn s/h0JqC3UylWl9hpdxlKZynmw4DRsEkJCdRsl//WVg+Bkg4W86Z9xRvRIPMjtayClb3j PRuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=ArvVWNmw; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w18si18852312edu.157.2021.10.18.05.47.50; Mon, 18 Oct 2021 05:47:51 -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=@gmail.com header.s=20210112 header.b=ArvVWNmw; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 05D0B68A755; Mon, 18 Oct 2021 15:47:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CB7A468A1A7 for ; Mon, 18 Oct 2021 15:47:30 +0300 (EEST) Received: by mail-lj1-f178.google.com with SMTP id n7so8827189ljp.5 for ; Mon, 18 Oct 2021 05:47:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=C6ksTXyf1Yy/rjdG6mxROGVe8oQZKqi3I4aBfCc2oj8=; b=ArvVWNmwgW7KSmltxmoHp4a720RCxYj+3UmKQwPkjcpq6AHnadJcSYX/Vsp/SN05zn grjtYTHvgEpxho4ZNsztfJzKVxbSZbZw2UjLNIYjZky4nj2exRL1nGSDufx9+ZziJrSZ BjRZj9843++R6PfXb8xEmH5Som4Od2zDcCer7ab8BjHiOeMsAYGoyc8/x3JwNtLhpf5/ TCsB4pkt1j+dxNxWLJj9I/7YhgOXLVC2LyAYQyoJK2qVMbFkv0+jM5mrcbwv1KCLevuj OXjlRfwyFXIXaWL7vCuNZriGrhIfs2Tmh/Y5bcRxlh3zCP9p/2u0FVNzHu4VOostIOQ/ z2SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C6ksTXyf1Yy/rjdG6mxROGVe8oQZKqi3I4aBfCc2oj8=; b=lJ76i0PpykQaWM2rfWsQmA1Mkr/yHFAxq+uLC6uwkn7K5vwtichet6PYmdZrIivKXS WAyNuMnyA4bVH/SVIQLFZwwjkPqL7ks3KQHx2Q/6kk7jsYKexZSw7nakyYSmJmyqCEAL kPeB/fCxbqEUeMDpol0epdUXBiQnbMZe9Q+ayasGYLw+qhyRnB++CQwraacVDE/KmZm0 8xLf0Y17GsFobTVL+rbnj+9mISQMyS/zR02ZoMdynRCsYzSS9uoIILU2vZ/v3imek5TQ 2OklbVxdtylCmLIgJuT6C9BUlFTBGCforfZK5ee0ZxU+vFXgHo5izgs6SgoXx/0UoAFv 0Uqg== X-Gm-Message-State: AOAM531TzZpWVzLiSKE0w8e0oRX9+J/QQKJ7KxvRJekQV3ZFBEUls55J xYwyDqNhZsjoev7eHAusDNqgrxSFKQKoWqJI X-Received: by 2002:a2e:9c4b:: with SMTP id t11mr33291430ljj.376.1634561250175; Mon, 18 Oct 2021 05:47:30 -0700 (PDT) Received: from localhost.localdomain (91-159-194-103.elisa-laajakaista.fi. [91.159.194.103]) by smtp.gmail.com with ESMTPSA id m16sm1392779lfl.212.2021.10.18.05.47.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 05:47:29 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 18 Oct 2021 15:47:21 +0300 Message-Id: <20211018124723.11497-2-jeebjp@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211018124723.11497-1-jeebjp@gmail.com> References: <20211018124723.11497-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 1/3] avformat/avio: privatize point of truth for AVIOContext::written 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: uKqcBJGRVMgR Looking at 3f75e5116b900f1428aa13041fc7d6301bf1988a, the field was supposed to be private, but during merging the field and the group that had the comment about it got separated. Thus, move the actual privately utilized state of this variable into the private FFIOContext. Additionally, name the private field somewhat better, so that it does not get confused with the amount of bytes written out. --- libavformat/avio_internal.h | 6 ++++++ libavformat/aviobuf.c | 11 +++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index eded38759b..467e80701f 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -66,6 +66,12 @@ typedef struct FFIOContext { * used after probing to ensure seekback and to reset the buffer size */ int orig_buffer_size; + + /** + * Written output size + * is updated each time a successful writeout ends up further position-wise + */ + int64_t written_output_size; } FFIOContext; static av_always_inline FFIOContext *ffiocontext(AVIOContext *ctx) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 3d87d66091..b18a56ef19 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -164,8 +164,10 @@ static void writeout(AVIOContext *s, const uint8_t *data, int len) if (ret < 0) { s->error = ret; } else { - if (s->pos + len > s->written) - s->written = s->pos + len; + if (s->pos + len > ctx->written_output_size) { + ctx->written_output_size = s->pos + len; + s->written = ctx->written_output_size; + } } } if (ctx->current_type == AVIO_DATA_MARKER_SYNC_POINT || @@ -337,13 +339,14 @@ int64_t avio_skip(AVIOContext *s, int64_t offset) int64_t avio_size(AVIOContext *s) { + FFIOContext *const ctx = ffiocontext(s); int64_t size; if (!s) return AVERROR(EINVAL); - if (s->written) - return s->written; + if (ctx->written_output_size) + return ctx->written_output_size; if (!s->seek) return AVERROR(ENOSYS); From patchwork Mon Oct 18 12:47:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 31143 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2084:0:0:0:0 with SMTP id a4csp3262303ioa; Mon, 18 Oct 2021 05:48:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybOUyPR848Qt61MXwg248eiO9L8p5CR1nTuH5GZQya8A7hbCRPm6WO0tRZ/HrAuWPMK1Ne X-Received: by 2002:a50:e141:: with SMTP id i1mr45236390edl.157.1634561280231; Mon, 18 Oct 2021 05:48:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634561280; cv=none; d=google.com; s=arc-20160816; b=zgSmNxBPmdYj4ETKNrEOiK2JOITSgkExu85ohClOOb7wqXutyscrOLSQN1aXYJ4rKG ru98hA9/xwVQA/h9vc+4JWke5qvI9UzUfKA8250Uf1Wp6X0dPy7Tl9thQboXZOQ3kWRf uXCk4N3Kbbf0eVPLv7wKnz2L9ncErvOsqMFSjcJB6b+jyXCsTmSGcpKxCNVfpv6G/qAw Cwu1xh7Wuyy3mWz3gYFsWZTXBi/OMomT2l0b7vRul6zOGg4/smU9NAbnQC2qft8bhMf9 kVVK1jnDzFDEPjkvroqyGunf0qD37Q0OekyOa0rSK8Nj61pFFZKwfp7X03n9JriyKUwz RM/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=EVJqkj9KOlgNObXTfPI/VtkAw3VoVTp8otIzJUjbAqk=; b=FS0plp0XvzuPdWqbyj0wkxn6970lcsdPtOlEJZ48kX6N99aq3p/N5XTe5JslLJyOtU aA7nSfvBY2BqGM/7RSFQCNgQ6pqJBTqBaqLaNiyEXYXypnuBhpxxB9rDkTef/92v+iHJ VtoX7jzXX57aLXQuo81RzK3X4HsV1Kt8UoRe4Mp22ExQ0JZgQ/J8hC1TjlAWj+81Jug4 zYn153SRwKhNK5QY4ALrmLrHPQXw+sh//AEDTOlS3uVGZc/gMD7WT1aKNhyzwTNIYaOy eqocqiGv4Wfx0aY6a9JdrLLvmO5Y7+zxCOAZndBnxmDC4D5RQj9Vx5XuO/EAyn4lekG4 euYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=caGmTBrq; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id gz15si24407991ejc.443.2021.10.18.05.47.59; Mon, 18 Oct 2021 05:48:00 -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=@gmail.com header.s=20210112 header.b=caGmTBrq; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 055E968A633; Mon, 18 Oct 2021 15:47:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AA30168A6B0 for ; Mon, 18 Oct 2021 15:47:31 +0300 (EEST) Received: by mail-lf1-f54.google.com with SMTP id i24so66250064lfj.13 for ; Mon, 18 Oct 2021 05:47:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=YgpPHLM9gTKGT3kvBZqj0m3DbTFwA7GHLtERz8yiMMA=; b=caGmTBrqifKYroSxk3cleKefyTrkMh5Lj+wu8M8mGitfLJwYJgRafCbX+AJFUFsUba C2jz9AgurZSHTid49OQdqo55TjnmVNM7mg6auxAImgVVtn+FtdCfQEs/KoeqY37XFAQ8 YxFlkvqlOv06iJyNlWtPkTqT9EgNHd1QzawRbhKJwjz4EuyW8+IjWRohFvV6N2JJdQb9 CdgE3z0xkxi8c9gN9h4wyrAgTw4TA8wNwZZGS9EpVYL4VjRf4i0BjIEFDUsl8Tz8vSQ8 0BOsXoGRD64Swo0vCE8eGdW5FsElc8HamDRTI1HqRrmdnMrP/fAUYQSz41rW7E779eKG 5Y6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YgpPHLM9gTKGT3kvBZqj0m3DbTFwA7GHLtERz8yiMMA=; b=jBB+bso78hZwijcznnXqFsGvKgJyHGvRapBj9zaXuG0tAOGpf3QC49z6LK0mEFgzYn RnNpkTQ0I8hIBjYiCmo0Yya22Tdmb0iSgYRj9Of8MLsckSa3ikLlo54FMKGHn9nHqPeY WfBijws9MrZdB+Uneqn7o7oYIZ1DjR7PYcQUW0JaRdyTVmfhBfAbBxOJLNZYi8nqOznX aLgJiTUERh4xlfIj2FTiyBasGySuHAxtkOkZxOBhXY8T9VoHS5T0N9QwBWsoIpFTfTAN r2+7ISush7VVv8Gi+1rG2H0PS/Cm9RcP26vi5x16a36EVNrfUHFue9b5DTrgkDDpqsjt e/rg== X-Gm-Message-State: AOAM530W+uc46d3k8cgx90D4gzL51UDnCXNny+6Pp+LQ+7dne6KagIDx PT4Tz4vf1Z28yOVab5huL0dk3XZVc8cYDXP3 X-Received: by 2002:a05:6512:2025:: with SMTP id s5mr27765798lfs.30.1634561250688; Mon, 18 Oct 2021 05:47:30 -0700 (PDT) Received: from localhost.localdomain (91-159-194-103.elisa-laajakaista.fi. [91.159.194.103]) by smtp.gmail.com with ESMTPSA id m16sm1392779lfl.212.2021.10.18.05.47.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 05:47:30 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 18 Oct 2021 15:47:22 +0300 Message-Id: <20211018124723.11497-3-jeebjp@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211018124723.11497-1-jeebjp@gmail.com> References: <20211018124723.11497-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 2/3] avformat/avio{, buf}: deprecate AVIOContext::written 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: NtQNyL0uKbva Originally added as a private entry in commit 3f75e5116b900f1428aa13041fc7d6301bf1988a, but its grouping with the comment noting its private state was missed during merging of the field from Libav (most likely due to an already existing field in between). --- doc/APIchanges | 6 ++++++ libavformat/avio.h | 6 ++++++ libavformat/aviobuf.c | 9 +++++++++ libavformat/version.h | 5 ++++- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 7b267a79ac..4731e14cb1 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,12 @@ libavutil: 2021-04-27 API changes, most recent first: +2021-10-13 - xxxxxxxxxx - lavf 59.7.100 - avio.h + Deprecate AVIOContext.written. Originally added as a private entry in + commit 3f75e5116b900f1428aa13041fc7d6301bf1988a, its grouping with + the comment noting its private state was missed during merging of the field + from Libav (most likely due to an already existing field in between). + 2021-09-21 - xxxxxxxxxx - lavu 57.7.100 - pixfmt.h Add AV_PIX_FMT_X2BGR10. diff --git a/libavformat/avio.h b/libavformat/avio.h index a7b56ab667..5e60c2e35c 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -290,7 +290,13 @@ typedef struct AVIOContext { */ int ignore_boundary_point; +#if FF_API_AVIOCONTEXT_WRITTEN + /** + * @deprecated field utilized privately by libavformat. + */ + attribute_deprecated int64_t written; +#endif /** * Maximum reached position before a backward seek in the write buffer, diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index b18a56ef19..f21f1c89df 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -22,6 +22,7 @@ #include "libavutil/bprint.h" #include "libavutil/crc.h" #include "libavutil/dict.h" +#include "libavutil/internal.h" #include "libavutil/intreadwrite.h" #include "libavutil/log.h" #include "libavutil/opt.h" @@ -124,7 +125,11 @@ void ffio_init_context(FFIOContext *ctx, ctx->current_type = AVIO_DATA_MARKER_UNKNOWN; ctx->last_time = AV_NOPTS_VALUE; ctx->short_seek_get = NULL; +#if FF_API_AVIOCONTEXT_WRITTEN +FF_DISABLE_DEPRECATION_WARNINGS s->written = 0; +FF_ENABLE_DEPRECATION_WARNINGS +#endif } AVIOContext *avio_alloc_context( @@ -166,7 +171,11 @@ static void writeout(AVIOContext *s, const uint8_t *data, int len) } else { if (s->pos + len > ctx->written_output_size) { ctx->written_output_size = s->pos + len; +#if FF_API_AVIOCONTEXT_WRITTEN +FF_DISABLE_DEPRECATION_WARNINGS s->written = ctx->written_output_size; +FF_ENABLE_DEPRECATION_WARNINGS +#endif } } } diff --git a/libavformat/version.h b/libavformat/version.h index d5dd22059b..de780124c7 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,7 +32,7 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 59 -#define LIBAVFORMAT_VERSION_MINOR 6 +#define LIBAVFORMAT_VERSION_MINOR 7 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ @@ -61,6 +61,9 @@ #ifndef FF_API_COMPUTE_PKT_FIELDS2 #define FF_API_COMPUTE_PKT_FIELDS2 (LIBAVFORMAT_VERSION_MAJOR < 60) #endif +#ifndef FF_API_AVIOCONTEXT_WRITTEN +#define FF_API_AVIOCONTEXT_WRITTEN (LIBAVFORMAT_VERSION_MAJOR < 60) +#endif #ifndef FF_API_R_FRAME_RATE From patchwork Mon Oct 18 12:47:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 31141 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2084:0:0:0:0 with SMTP id a4csp3262489ioa; Mon, 18 Oct 2021 05:48:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy32GOsUQq8Ro68Y+U/wAwBciig3d33EHsmygpzKzVvqd1zpgFfrTmsBmzQyoOOlfPe5TV4 X-Received: by 2002:a17:907:7b9c:: with SMTP id ne28mr29709721ejc.531.1634561290191; Mon, 18 Oct 2021 05:48:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634561290; cv=none; d=google.com; s=arc-20160816; b=LvrBdkX1R5Cou4GiMhQG/z0T44Y4n/Dgtg9H5pXWDRjthqlWr8dwjRwihFQPSHmPJy 2INpw3uA4RN7/LHBF2fQNdOglrbcwMHCzr8InqP0V8pFBlrfNLFquT1D47W/NTVf2VUY nv0ui1NxgzkAXifsRM5R6iu7DrZdtQFdJoMgy5buReK7IppiW5giPBIJyL0Nu22KoZFe oe79oqdZUpjlp2XhQCctnRXfjy66YdpEeRxsLsgfCR1W8C4EyCXa6EzBjDegLiV2gw9m W7Hwdk+eMiZ3Bat96KLHL8pTPWK2mrqeaAxspLyEU3NIssTqseTZOfwe2iX+Enol20gL u/PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=hJA0OAU1kYM4Y2q5tI+e5odqAEHCgYVTdgjJxw8r0Vg=; b=KPuaGJn3wUZoVk+/BGCsuauq837E8q9Q5jjRFVGFqav54ArmE48AkFlVszDF+/8c4J +ySRhGRzAGnxuLnT2AnRnDQ1EfI7sMZhyhqQXzrkyWagfuuFYzNRWoJWZYR8bPaYBjeg Mi+BZZs4O/75w4r2juY608+6VMyhntPRWPVsQBB5yrgfwkBZhHGJGssxncumUSUTyiZ7 poj4xgR40wsqIT9OmS8Q3wPU1SHXjc7+G8yhR72roQhgImvnGKq53c9ZgcFqYkVo3e/L pc0mgoJ2DTWthMKjAXr/Jkm8GJ7B3cbL7wmLS2AaM9c+U7CSihBFOGOITipoPxlYDUhM FM3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=Jb+dkJfI; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z23si19863940edl.391.2021.10.18.05.48.09; Mon, 18 Oct 2021 05:48:10 -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=@gmail.com header.s=20210112 header.b=Jb+dkJfI; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1F7D768A77C; Mon, 18 Oct 2021 15:47:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CD24968A6B0 for ; Mon, 18 Oct 2021 15:47:31 +0300 (EEST) Received: by mail-lj1-f173.google.com with SMTP id q16so8818825ljg.3 for ; Mon, 18 Oct 2021 05:47:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=25UjHIsqyW/1m0Z8VId/8DvJ/GYhb+r3iwgYjHGFIls=; b=Jb+dkJfI7bfJQZuUK/Y3dC4/ub946l2Qp41h02wm5pkoMHYwQJJGAr7mdzj2qc+5r+ dM+V8PZwlylvBsFuDLVSnkBzHk2GWOz/FFouXgeHEp9YakeVYWPrBqDFmPcDNolqR+4G yzg/CBtMoQe/azyVAsMBdWAGCexoTtg//HMYK36ZBcMrViV4+T0oDRKJB064ZqmjYfE+ nuO5qsWBqSeDS3bBNenNxJ9BmJDFIdaGELIrM1auV0ByEFnH0InzKvmNbhmy1Xm9Xj06 cGnRmS3M/4MGE+vXuiS1iuqhr8GFVsCUySJDDRP3RXfnv24QIyu/yrFBLPzU9KKmhMtO Ee5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=25UjHIsqyW/1m0Z8VId/8DvJ/GYhb+r3iwgYjHGFIls=; b=J8EN2JAm3Dnue8Nfn+PBEqcc1LGJGA/+OFnf6f0i3mhAZwJ8KnCc3XlIQUanKUgF1f DSte0mIO9cqdhp+KEryXX2fSaJhFImTyO6WJcz07Pmte0KkW5zfOpBP7IRvvEyGSuNuG Z9b5fs3vJa5ieUjoIBXypK6njdwswYsMT12O+D761UQYG87+OBHXDx3E0CMePyx/02pm Tp0zFMUgzsXKLm1wDv+WgoIh4A0IRsQ3iPb7qtTyVl1pBbSFn+0JbC6AKPJoG2NPr+jr GSkMh6Bd8LFS6V4rAbjPfw46xQAJnXvY4d5Oic0W0juYIoelwk1oO5YvT+d8kreHd4sV IOMA== X-Gm-Message-State: AOAM531wsQU3ws3UyIeZNiHdunMGI+y/h02txRL2ivgkzDl6NP+gIofn EKVz0SvW60w1ehN2YC9Wmf3tBdbOjNx9vyGL X-Received: by 2002:a05:651c:54d:: with SMTP id q13mr8505467ljp.239.1634561251123; Mon, 18 Oct 2021 05:47:31 -0700 (PDT) Received: from localhost.localdomain (91-159-194-103.elisa-laajakaista.fi. [91.159.194.103]) by smtp.gmail.com with ESMTPSA id m16sm1392779lfl.212.2021.10.18.05.47.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 05:47:30 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 18 Oct 2021 15:47:23 +0300 Message-Id: <20211018124723.11497-4-jeebjp@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211018124723.11497-1-jeebjp@gmail.com> References: <20211018124723.11497-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 3/3] avformat/avio{, buf}: introduce public AVIOContext::bytes_{read, written} 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: dP4cGplnoMWK Such fields can be seen as generally useful in cases where the API user is not implementing custom AVIO callbacks, but still would like to know if data is being read or written out, such as in case data is being read from input but no AVPacket has been received yet. --- doc/APIchanges | 3 +++ libavformat/avio.h | 14 +++++++++++++- libavformat/avio_internal.h | 5 +++++ libavformat/aviobuf.c | 10 ++++++++-- libavformat/version.h | 2 +- 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 4731e14cb1..99e185ee4e 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2021-10-18 - xxxxxxxxxx - lavf 59.8.100 - avio.h + Introduce public bytes_{read,written} statistic fields to AVIOContext. + 2021-10-13 - xxxxxxxxxx - lavf 59.7.100 - avio.h Deprecate AVIOContext.written. Originally added as a private entry in commit 3f75e5116b900f1428aa13041fc7d6301bf1988a, its grouping with diff --git a/libavformat/avio.h b/libavformat/avio.h index 5e60c2e35c..cd63322a62 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -292,7 +292,9 @@ typedef struct AVIOContext { #if FF_API_AVIOCONTEXT_WRITTEN /** - * @deprecated field utilized privately by libavformat. + * @deprecated field utilized privately by libavformat. For a public + * statistic of how many bytes were written out, see + * AVIOContext::bytes_written. */ attribute_deprecated int64_t written; @@ -303,6 +305,16 @@ typedef struct AVIOContext { * used keeping track of already written data for a later flush. */ unsigned char *buf_ptr_max; + + /** + * Read-only statistic of bytes read for this AVIOContext. + */ + int64_t bytes_read; + + /** + * Read-only statistic of bytes written for this AVIOContext. + */ + int64_t bytes_written; } AVIOContext; /** diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index 467e80701f..187433f283 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -51,6 +51,11 @@ typedef struct FFIOContext { */ int64_t bytes_read; + /** + * Bytes written statistic + */ + int64_t bytes_written; + /** * seek statistic */ diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index f21f1c89df..5da4dea7b6 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -169,6 +169,9 @@ static void writeout(AVIOContext *s, const uint8_t *data, int len) if (ret < 0) { s->error = ret; } else { + ctx->bytes_written += len; + s->bytes_written = ctx->bytes_written; + if (s->pos + len > ctx->written_output_size) { ctx->written_output_size = s->pos + len; #if FF_API_AVIOCONTEXT_WRITTEN @@ -584,6 +587,7 @@ static void fill_buffer(AVIOContext *s) s->buf_ptr = dst; s->buf_end = dst + len; ffiocontext(s)->bytes_read += len; + s->bytes_read = ffiocontext(s)->bytes_read; } } @@ -657,6 +661,7 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size) } else { s->pos += len; ffiocontext(s)->bytes_read += len; + s->bytes_read = ffiocontext(s)->bytes_read; size -= len; buf += len; // reset the buffer @@ -1236,8 +1241,9 @@ int avio_close(AVIOContext *s) av_freep(&s->buffer); if (s->write_flag) - av_log(s, AV_LOG_VERBOSE, "Statistics: %d seeks, %d writeouts\n", - ctx->seek_count, ctx->writeout_count); + av_log(s, AV_LOG_VERBOSE, + "Statistics: %"PRId64" bytes written, %d seeks, %d writeouts\n", + ctx->bytes_written, ctx->seek_count, ctx->writeout_count); else av_log(s, AV_LOG_VERBOSE, "Statistics: %"PRId64" bytes read, %d seeks\n", ctx->bytes_read, ctx->seek_count); diff --git a/libavformat/version.h b/libavformat/version.h index de780124c7..81ed517609 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,7 +32,7 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 59 -#define LIBAVFORMAT_VERSION_MINOR 7 +#define LIBAVFORMAT_VERSION_MINOR 8 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \