From patchwork Sun Sep 26 15:48:18 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: 30592 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp3373845iob; Sun, 26 Sep 2021 08:48:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyXD2QJ1T4kG/crTvP508tmKEHFrP+TOa/Zd6iE7780ulkU5pbHDKLg10QFH7qFGv4Luic X-Received: by 2002:a17:906:3486:: with SMTP id g6mr22967696ejb.71.1632671315844; Sun, 26 Sep 2021 08:48:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632671315; cv=none; d=google.com; s=arc-20160816; b=L8qggOn89witDsa5eWV6/WDa6msRWdSBbSvKEwOUr4cD1U6kUO3paYbEhkdgeolsmx 90ICejckBhGfajc5kUhlNgS6/ucutL6EhzemvuJK9WlVHPybw7cRQ0LeHurqXrIUiBQ6 DtnXGH08EdFDt2QmyI2USoyUjvxLGiE7OdyKyK9rrJoCae1ykKMvkiRjXyWyL4ckBWBZ 8YLKBqMCBYu464z6bZLfFn2BO/VBuv//KVOfb31G41vInb6ElriEXUhOt3QmhwJ4s3Mr pyHFwjB7dqtPRB38XM/Vp00ZGp/5XphgrJlvDbm9qJnjGyov9e+XQ60xz81ffNCLIpx+ 254w== 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:message-id:date:to:from :dkim-signature:delivered-to; bh=xdHwISHE/IIba7jovpsm6nkIjZCVF5+nO2FbF0HSnBI=; b=r2zCsXCu0fo/oYJul4MhvaUCf+kweI6+20qQcD7UT4A7shGNx6kou84sJP/6Pq+EHm oBpeRf7iGvYmVxuLlqVqosMr5cSJrHpVmylJtqHytg2wnaq+48H25IaSWcdeW7OVAWwN vr2wJVdrSKSyoZTSN4AuNAFExG0OvODT9D4h7enHx0WEjBns/wZn3vmUPG/wgEoL9Ga8 4VaQFBmhXi3JbgGgXKeGcetFa3gBQEyRrUNtyR9eOEW7ftuyXa8n607b17HM4xONG6mx ImEcQtZk8C8GE59cBJVN2t5P9GCHo/TNlYmC6498dShdDeY4JXSnP9LRySgAGcrAjZA9 cKRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=KIzLpe7O; 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 k2si15888388ejo.293.2021.09.26.08.48.35; Sun, 26 Sep 2021 08:48:35 -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=KIzLpe7O; 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 7812B689E05; Sun, 26 Sep 2021 18:48:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B2C36689E05 for ; Sun, 26 Sep 2021 18:48:24 +0300 (EEST) Received: by mail-lf1-f44.google.com with SMTP id i25so65601620lfg.6 for ; Sun, 26 Sep 2021 08:48:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=5Qkwq3VVElhSlYGDi5JVhb/i3tGU43molm33YwvwI94=; b=KIzLpe7O8byYa3rF4bfDxp2acs9lJPnt2fyOaNZt07UVAJZS2UAOaR+je2obBiPB+Z glzIzSxh8LhzsFzQzIVReguaGh7Swe66a4LfNazlN2xr8Q3Kwny8prYp2jZiS+l9Eehq Kf94szkW0m2uIFiJdPH0uy4rHxeh8Q3VTFDzKIAv839EexO6fnO0F9EVhzGFyZYGwgPo I3dDO+tB1yAtdBG/U/BVL+A+I5t5ncit0mSQx0Ly6Qan+vHiuqMd0RGCLnYBeR/K5TNU s8HK1Om0MaYeQusEaMH1JpQlaWZhpEULwH9muQMPYnO9/pAY45Ao8HaYaGRXlotWBvb4 RoxQ== 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:mime-version :content-transfer-encoding; bh=5Qkwq3VVElhSlYGDi5JVhb/i3tGU43molm33YwvwI94=; b=A1HoML3ZTxoQtFDqWnytwnNoLSIE/DdSe44u95kXO6aI1oCaKs/bLyDk2kQcGhUuwR WZTzru1hPGjN0ZWjIt3hWB9besCdXudKoha0djmYh9tlSfFijU7GCMwAbwrW0kObGpGP WwiMDqEeW0fAM27s74kgdEdNfKAk945S/PxHgvDp85GaGAb5Z95C8CEJWefTPhocx3GZ PRtYtZ8g2IxM9fAEZ91tVhQuEO3ABKkgoQA2kUhvjZZOG8ZXGALyQnOHePAxWQfmB0fo MOU1b3moosORjIYSFAx5Z1xEl7nKr+wZT7fvI64KiYfy5t7eDAT2i+QskjuhZisUWgV9 2Yng== X-Gm-Message-State: AOAM531MB5SjrZFj5aMlI/shJSfJ/jHa8uFe9tZklxCSHHpIa0d/Fdi9 9JU+64AJEZ1ounKv7vaZpHpZIXddi90= X-Received: by 2002:a2e:7f04:: with SMTP id a4mr24774925ljd.308.1632671303896; Sun, 26 Sep 2021 08:48:23 -0700 (PDT) Received: from localhost.localdomain (91-159-194-103.elisa-laajakaista.fi. [91.159.194.103]) by smtp.gmail.com with ESMTPSA id j8sm1329168lfg.183.2021.09.26.08.48.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Sep 2021 08:48:23 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 26 Sep 2021 18:48:18 +0300 Message-Id: <20210926154818.15595-1-jeebjp@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/avio{, buf}: introduce public AVIOContext::bytes_read 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: UX2ZG4WjzbVR Such a field 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 even if AVPackets are not being returned. --- Originally I thought about making an accessor for the private field, to not grow the public struct's size (and have a duplicate field, as well as making sure the value was read-only). But an objection was raised that such accessors should be refrained from as they unnecessarily filled the function symbol space or so. Together with the objection, a proposal of making it a field on the public struct that was only written to was proposed. This patch follows that proposal. doc/APIchanges | 3 +++ libavformat/avio.h | 5 +++++ libavformat/aviobuf.c | 2 ++ libavformat/version.h | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 7b267a79ac..6a8cf8ea15 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2021-09-26 - xxxxxxxxxx - lavf 59.6.100 - avio.h + Introduce a public bytes_read statistic field to AVIOContext. + 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..2cfb548231 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -297,6 +297,11 @@ 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; } AVIOContext; /** diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index d79e41ca77..33825ade73 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -572,6 +572,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; } } @@ -645,6 +646,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 diff --git a/libavformat/version.h b/libavformat/version.h index 13df244d97..d5dd22059b 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 5 +#define LIBAVFORMAT_VERSION_MINOR 6 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \