From patchwork Thu Aug 5 05:14:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 29256 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6c0f:0:0:0:0:0 with SMTP id a15csp81552ioh; Wed, 4 Aug 2021 22:15:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/EuHgOQz8ox+0ZCkqqYMnaBmfHWhUQMZSaLqP82XGcX9p3EsADqa9OvUz1J74eXRVdDEp X-Received: by 2002:aa7:d296:: with SMTP id w22mr4111748edq.170.1628140507296; Wed, 04 Aug 2021 22:15:07 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f23si4544442ejt.744.2021.08.04.22.15.06; Wed, 04 Aug 2021 22:15:07 -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=@outlook.com header.s=selector1 header.b=ULjXHHBR; arc=fail (body hash mismatch); 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 860D868798E; Thu, 5 Aug 2021 08:15:02 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-oln040092067082.outbound.protection.outlook.com [40.92.67.82]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2DD3768022F for ; Thu, 5 Aug 2021 08:14:55 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dnSarGsZuyA9MHhm84+VtJ9rT8CH/sTDUyNDUZhPH3CUClIfSYnI3ZtLo5a/7wMGLtBUd8K4OFl5k8EcIMDZBCRbO1cQve2eNA2C+Q/LQ1+OaDhRB6xTVl3KID4S3USpBVt+8v0KjyAp6mpMGHyrYNLx49itMOvoyNSW+MJfJEyJNciAp+rpskPtshtQ5NBjHw+K9Of2Cz7kWXYw6CYSECsm2Izk+EXIyteigxE1wf+3MeK7zasXZ6MTxbsZMJUSdyV5X4zFJhn48YEpoTbugWeFI4V902ZC7Rl8mlDvK4Na05Ka9ZiMJXVep7KTa+/qx2E5X93Jw+xQZTlSph3DzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mpp1LEFtiGjLXIj7nGuYerHTy/mOTIgkhISlOXhTpPM=; b=JqGcY1XrLp6yQjejMgC5F5b8nMK4xyNXR2kGQdTwRSC5Z4wWfbr0n0j9Dgzn92QqsTjeHNUNzp5znMEHJSwMe+VoVMLfH+8cX1ObBase/1tmTvaNfMw61hfe/YBEO0dMru2XtVa0WyCergaqIeFoLzZvqDPGtxGnJVNuXlUvsq3nCWltS6pNCBAxsPJtDLUO4XJLDkJKuEQ9SngVysf6YpzKeDlLtzqDQFei084HpZ3tKVFw+DJYsDDs0rYvoty7BqK6ZBGcYJv051OIQn7XjOAAzDArY14/4VBBDZDLZWCx/FySAA1ZSjFeRyDheOxGMyPuj2JmUmi4iXVHVT5/GQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mpp1LEFtiGjLXIj7nGuYerHTy/mOTIgkhISlOXhTpPM=; b=ULjXHHBRCKXc3GVgnNDc/s6/ALUAAutWt2fm8Xh79XwrGO+VFEt/B5EWqBzxO4eOvXna0lJ8i4V4gW1zMMKw5B+jtFf42SqmVV8DeWhByJTRcGPH6kbRGhCe5WWeoeUAR/f12/TeTuTNFKWrOdarrcGQJ5DwXGYUG08elWyISpob/l1NGgieyrEcObapOhK2TB9sHYBFK4YzIEZP9gWMESb9N+YQcflkhviJuH1Qv6weziykBjvRq8w01uWGQCuc6PTaDm3HK6lN6xoamvwrdMOMvejysWIaDswumGMZmCZ8HlPCTXQvdyVrMaR86bkECBHLFESJQVkljErBS8Y6mw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AS8PR03MB6888.eurprd03.prod.outlook.com (2603:10a6:20b:294::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Thu, 5 Aug 2021 05:14:54 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::c9b2:14f8:d555:6f2d]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::c9b2:14f8:d555:6f2d%8]) with mapi id 15.20.4373.026; Thu, 5 Aug 2021 05:14:54 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Aug 2021 07:14:38 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 X-TMN: [NvYjY//TyH3EV5ZHSveX1JaljMpaWfUQ] X-ClientProxiedBy: AM0PR02CA0160.eurprd02.prod.outlook.com (2603:10a6:20b:28d::27) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20210805051446.2094068-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.94.230) by AM0PR02CA0160.eurprd02.prod.outlook.com (2603:10a6:20b:28d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.15 via Frontend Transport; Thu, 5 Aug 2021 05:14:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dedbc190-fb03-4632-e689-08d957cff551 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiTzvpWxvWYRCiBlmWjUmirgJJSpaDxpOQzGxea2Sj9BZdO4l0Mf1+lmvdnFalnobqJt196yrGDcNGhY3DDICA3m1HZ/TyserowtD6xXlWZlvLdldLp4Gg9tFV/f+zWwbozIYRVE6vG7qigcPCXlNwjaWHyri3SK3/M3RP3Qj0eWiW6+aKXbMCUxofbHQsE5MtMXzYPczjrN1jElsq/4JhyqMgwM/oxsC0VPHYhEFtwY6NeDeSei+PNskGC8uhRIo6SKVx5x6INB1KGmSQ7chdsuu6aHL6X5UBkTKF1o+u68Cih8tOa2C3H6dpt8ZsScrzlM3T21Ap0qSEA8m7X/APpeyhxzB03Zju0dZQP4RH3RcPxj71c6TeNcZb4UarDBGJbnyS1aNaIMU9DITA4pGTKA4ixuwCTL7xsEGyp0Xq9aWDvq+jNFohPNWgjB0KpbOKEV+TVvbWSOCbpn9WtD2YUM2GJjIDhTxX9wvLyUQEPf/V5+bGaPEBiIRM6lCLFVklu9BR8usiVOj7NwNDldiH/rQ3f5/mK2f696tyDpFuviGuLR0YV6WE1HdLDGyN9ipL+rmX+QXCiufQdo6dxOXNW9X2VM+zXT5y+IQM8W+3/809RkWMLM1C98g7m3EIcDvsKck2EuXgZ9AT6twYyCaEsHzr+Y5MDn1FCOMO/hjIfJ4eTA+Qs2s1sKbTuKEDj2GwkCmH0NUGmrbdye/Z/L2Z2l+QyA3E7KuV6gsy48ByD7LwWWu2nw5ZiZp0qegHPUyy4= X-MS-TrafficTypeDiagnostic: AS8PR03MB6888: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2Z14dtxjv00AROGXsYxLtjn2+ycyQuoEYWqHRw8wgiL5SSIdEC6CYGMHUAAd2fUCnXQ5tuBEoTAfAuYcVOwqJxj5jz8iRB0lbZOii6XVgxBFlmS7Mq0nycaREO5kgqoXLVC3rSd4AjGf6ttTs72u64xFpje2THNkatjNYmc91g50mz6VZ/YU+uS8+qPio8EMe02q0mTa1gg6Sx/x6B3Ey4ljn+/TV+nmdaccvqVmjU3nJMVrcTHdfC2DSjBPiPfwGxZ7YlWNeeHiOIPsh2H+2kuXR10ViILdyQhmuAaY4lmy/numbEVG2LFNnOHN3nLVDkkqXuQaKGOPXVFhH1L+XONiJFCQgSje2xd9lwQeewLwhLkfK9LK1Ws9Ksf7HO50QXr+R6VmQQCcnrm2RKrM0J/he9fgI+Yl4a0C8aX5d312EKtFccWPp6rpTYAQwq0j X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lqkvRwAB6CzqLdZomZdKD4zTDij6MusJu5lerFiNLJvZ7dcVBNDgwDJZzldSYVCW2pJDrjlvbFXfvtHvOxyppy9sBJs5c2h54DV9AG6WVH/Y1Io7MpKi08X7FZIsxTfsxyJV4kQGPOuLxZEqYVlzBg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: dedbc190-fb03-4632-e689-08d957cff551 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2021 05:14:54.0594 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB6888 Subject: [FFmpeg-devel] [PATCH 1/9] avformat/aviobuf: Avoid calling function twice due to FFMAX() 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: kZWSGFmHq80U Signed-off-by: Andreas Rheinhardt --- libavformat/aviobuf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 66fddf1433..164b07ae6a 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -274,8 +274,10 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence) return AVERROR(EINVAL); short_seek = s->short_seek_threshold; - if (s->short_seek_get) - short_seek = FFMAX(s->short_seek_get(s->opaque), short_seek); + if (s->short_seek_get) { + int tmp = s->short_seek_get(s->opaque); + short_seek = FFMAX(tmp, short_seek); + } offset1 = offset - pos; // "offset1" is the relative offset from the beginning of s->buffer s->buf_ptr_max = FFMAX(s->buf_ptr_max, s->buf_ptr); From patchwork Thu Aug 5 05:42:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 29257 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6c0f:0:0:0:0:0 with SMTP id a15csp96908ioh; Wed, 4 Aug 2021 22:43:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxf+RHrd/kvrZ/334ZXkmIUcBYR2/ygCaPMNIvrbxZMP3dRsSleqiiyS01O1cb681awvGPf X-Received: by 2002:a05:6402:514:: with SMTP id m20mr4270266edv.116.1628142208040; Wed, 04 Aug 2021 22:43:28 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h9si4092223edw.170.2021.08.04.22.43.05; Wed, 04 Aug 2021 22:43:28 -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=@outlook.com header.s=selector1 header.b=tQuEj+yq; arc=fail (body hash mismatch); 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 137CF68991B; Thu, 5 Aug 2021 08:43:02 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-oln040092073092.outbound.protection.outlook.com [40.92.73.92]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1164368991B for ; Thu, 5 Aug 2021 08:42:56 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QmJT6YT74aIsH9/BcD1DQN78PR7gfeBbwW6o18OceW4NDAsuWHqqaE9cbCNYApO4EST0dNsETSfBYZmCNfbWj/kJ6k6wXLc5uJnuj4yn3g2g3rxWaLQWsHghCNXdZ+Fad9lkh1o4lLrHb9G7wwk9HKslnAMIKLdGa3Zkx8CZec0L0obh3MNHdOGASE3bcm1SRU40ZQ27wSMDLAC4WgMKiZ2iMwLQ5KNMsPQejWlVxRozGNSb3r3OasggPloh8BqbEPR6L9VoZ7eXl/fCBgWtXUsSFQtTahf9JzAIjoxOPvhlHfQoUxi3QaRUBWvjyfP1nT57QsTc3/9Gx6eM1zeJXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mQD5NTly4SE4b4zUdX2GfsvR904X6/8ffdeJfUOemfQ=; b=XRttQFK7k9BeDzRUi3q0y5TZMxvOkAdho+xeW16529nEpHwUVOHjDLej0I8Mz9PPV3D1JTbuogdjUxleTPE/51nMBkfXkXvL+pvECbRGoPtEoHVQp0RHewCCLmLkF+yyVBpTv6DrDLeaq3bSeccT34JFOJIzrFLwVMim9oqlWuOb+1pz6Om9SCaghDFbx5WDrytHdxJmtbriiZqvAZN2eCQJJ3K1rPMkF3ZeNQz54JSD7eOKhIdDfXREEzEzD1DNkANPYCRUyS/O75xpN3kZSF+sDa5rMbDwTQi8W4Az2jlH7G3DxSiYPK5JcCNapLftQr/sKK2Gaqb6t26u0r/Jow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mQD5NTly4SE4b4zUdX2GfsvR904X6/8ffdeJfUOemfQ=; b=tQuEj+yqzFBx22YZFpZtLPrYbVBVNdynAJvcNKzHmkxnC4h+GtN1HLEjpbm720fFJKlyJhyKcGBCebDmOI3dSMUpbLIv5KEvBb42qvI+D3dzUE5aCJD9NlYlOmXuCkZg+QUIX5u+8CsXrPkpnASZ2I2w6XzcqgrLAqDKmrJZZNRbKxm4cwKrvcetHqT+lnZLJja1CkNHWlCo5Rkax42+t7pmyaysSwLKhxypClCeJJQPNMALV9AZ+8e+uTR7+HUMpZKdhoAdq9zjExxXfD7rzR/dH37ORFBkvmQl4uWJ72APYddhGhKCBjbpR81935ieIrwLbBlVUeMVRA4nX8zOzg== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AS8PR03MB6888.eurprd03.prod.outlook.com (2603:10a6:20b:294::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Thu, 5 Aug 2021 05:42:54 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::c9b2:14f8:d555:6f2d]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::c9b2:14f8:d555:6f2d%8]) with mapi id 15.20.4373.026; Thu, 5 Aug 2021 05:42:54 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Aug 2021 07:42:37 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: X-TMN: [N6nKWXxUUZpmAfjnJsTu/gv4G9r79WuB] X-ClientProxiedBy: AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20210805054244.2094251-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.94.230) by AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Thu, 5 Aug 2021 05:42:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9c39426c-6a55-4ea8-d4aa-08d957d3def0 X-MS-Exchange-SLBlob-MailProps: +LiGfBxqLEvXz/Cg0Ir87bEks07/0c4IuC0aWFxfqjFyd3ktvWf3DnenoeJSfnDiLGHqXOSHoASX1gk4DWhZoL2+E5ygo7fQSGaKEIm3itWzQFvSCgUhLSWolYCYtwlu+q2SHo5c84tu7FYmTnoSE196BXR+KB91twzdZUmOl83a18tSI2aCCRU2stgpbC5K9zTUE5FLnmxsYvjvKSaTeMYGX+nEnGIYFVyp7c33JM1n2cKQsvfYVD5XfBNbWaH1AvPDav8WcKnntc7ad55fsoZUzBDrbN/QUr1TNZ3mqDiX1uRyF7mvIiNgjAlg5FPxuA3CWG6UBqpWvW7uLk2ceAibksIEib7jYaavAVOMtlZCg0WZaTJEsPkqROZPVKJVmRtka2CxeIo9XUMIpg7soIxcV8BZuLWUTsmDwgHebeSjpoFbkZ9jrrsgDSasVe1L2uIBwSUyHj7c0kkPii8i/tGhym3gguqsgxRHcTEv/JWa5QszUFCdWjkaY1qlfthttiVLn6pZbQGVZgOlaT+TF18IEhbGZAd84pFPYGtHfVHOVw6W66EXZrBBBN9BuLII83dNRx46pwKjfpzpYyhRJiROuJSrLrAyw3RqOtLW1oTeDc4K1EDiL5Ve7Tnn77YkQ7Ueqbmoy41VrCrOpCAWX4g9hdrRVEHk6gD3XUCtwzqvn6FjKANsuIuCFN8hJQJpFz58+eZ3Q+8xMZxUk53VJOObAeLxSlHYzrfB/iH3fn1+j3wTOZrWucadlC0ULcVEy+5SOr8DSQG4DJtD6RzsWw63k8ME2Q84 X-MS-TrafficTypeDiagnostic: AS8PR03MB6888: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0LlH35K31SlYL0pReLgyuMdZpQca1qNFcAg3c0C8REhxFPq7Mp76M5hARJCdAlEhuI2AT26v+wU0rGYzYfJvduxzNZXzCd5XiegeXhg0Ew2N5QNwR0u4WoX/D7kDJHtNSytUaHH1n27WO4N0q3RQ7DABym8slnF+tW7xdKgsA1WiPI4Rhf7mljPoAnfmJSDQ300muYk7xw/TImcaB2z5NQDUuoPsroOA7pV915QbG+VKaGknTKKM2h+pM+b2bFq3AmzZxBLKxlirbkqFvfBYg9P9QBCqpN6EK9AbQ2RRacSvj0pLO1wCGLa19c5kcM4x47+cZMg+gDLYN0c3hMbvYA9OeGOey9WiOQy2ox7NJoApEMd3kMXiD7oPtzmOH/mUjx1Vo4EkqW6zFzJNwqUxXGCmdaY9GXFHeHW+NN6QCr2m9t014CR26Y78muGb/BF6 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rZvTwxELEirzS+EkOyFc4ZJxMsIQ0OhVodhYAWgtKCw/P8twNTBL9WtxaRAhE1krdKb46AnNF73bbu4KwTWQicZj/FfRgsCKKPTrJJ2HH7prXWTvF7FxgA0FGPplyjn4NODRcbZdAxGrD5umLjvBrg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9c39426c-6a55-4ea8-d4aa-08d957d3def0 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2021 05:42:54.2225 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB6888 Subject: [FFmpeg-devel] [PATCH 2/9] avformat/matroskadec: Read RealAudio extradata directly 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ubM3Oa7Lgsj0 Don't use the avio-API to read a few bytes at fixed offsets. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index fdfcc86aeb..1977240cf9 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2660,18 +2660,18 @@ static int matroska_parse_tracks(AVFormatContext *s) codec_id == AV_CODEC_ID_ATRAC3 || codec_id == AV_CODEC_ID_SIPR) && track->codec_priv.data) { + const uint8_t *ptr = track->codec_priv.data; int flavor; - ffio_init_context(&b, track->codec_priv.data, - track->codec_priv.size, - 0, NULL, NULL, NULL, NULL); - avio_skip(&b, 22); - flavor = avio_rb16(&b); - track->audio.coded_framesize = avio_rb32(&b); - avio_skip(&b, 12); - track->audio.sub_packet_h = avio_rb16(&b); - track->audio.frame_size = avio_rb16(&b); - track->audio.sub_packet_size = avio_rb16(&b); + if (track->codec_priv.size < 46) + return AVERROR_INVALIDDATA; + ptr += 22; + flavor = bytestream_get_be16(&ptr); + track->audio.coded_framesize = bytestream_get_be32(&ptr); + ptr += 12; + track->audio.sub_packet_h = bytestream_get_be16(&ptr); + track->audio.frame_size = bytestream_get_be16(&ptr); + track->audio.sub_packet_size = bytestream_get_be16(&ptr); if (track->audio.coded_framesize <= 0 || track->audio.sub_packet_h <= 0 || track->audio.frame_size <= 0) From patchwork Thu Aug 5 05:42:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 29264 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6c0f:0:0:0:0:0 with SMTP id a15csp96974ioh; Wed, 4 Aug 2021 22:43:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3u97sI3CJk9YIdpdsbiNqfR7oVRyowm9iifgzW+lNnq6noWW0pzv2yMuGD6VMakDvvHJ1 X-Received: by 2002:a17:907:3e1b:: with SMTP id hp27mr3144699ejc.116.1628142218359; Wed, 04 Aug 2021 22:43:38 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s18si5337038ejh.110.2021.08.04.22.43.15; Wed, 04 Aug 2021 22:43:38 -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=@outlook.com header.s=selector1 header.b=MXfAlfQY; arc=fail (body hash mismatch); 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 277CA68A212; Thu, 5 Aug 2021 08:43:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074083.outbound.protection.outlook.com [40.92.74.83]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B976B689D84 for ; Thu, 5 Aug 2021 08:43:03 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HPrLVcuPFWw6Ri7pkRbQeW7U/CPYSskkgcNfkuwM9/r5Y9rdYWsVn9oNYZuTKeg4u8IHWsEGBVh2xVoC+CSsPSgtVVSoueGHrrsI40VGHRgK0l4KxrNYhYy+/1bIuCzGU9Bi2qhHkCMg5kZtdbmN9rhGfNT0MKjUgfa9TmVUby76+E5mUU3UF6djLqh8PHK9vn5vg5+GlCpsLB6j+IjNlvpJsqN7qoSRmaRfOjd+BnwJdga6JAXNnrI4WZ4dk4EIIBFDORfN9hU7efAMBzuSfsvNn3ID7lA4zgaiu0/RlJulstTyHxEYDzYojneBIFIejmWL8HL5CWoU/0amjbFOeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GKVlaFw/SukbgHNapOQ6qp51NjIz9Kk2sWdz9dz1+4E=; b=D1q4ppqGkPtpuPrz0p791Hi0cBjNxxTSHADvHnefnzRWjfhY0ttaVewfmGVSX3c9u1yrEDlso46izftB0mY9jI1WywjTUeIggioryfr8rXOIFH11Bih9YWm6L0BiLz0Udvb2Pt7ydpYurSfDAxqkfwsp1+QawRhdJTGQCGHCLSMx9Q2EA75wCDHXX337wDmynsLK8ysgp+hP/0P/srsYsfPmx1figgR4RCWbu70mLLA9toxmzMwfjr9e/PMaqFO/OkfXFn2nsIIAZd1cLrYgzNhcRwy8XxFj31cClPrqahRn6eLaPT6xWifT8K82nFimSbKbdxJjZAQ3C7+7YEUZ4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GKVlaFw/SukbgHNapOQ6qp51NjIz9Kk2sWdz9dz1+4E=; b=MXfAlfQYDXOLIf+eTI2OjrGaze1p9uPDj+hxHJVubUi6m98IYgkAblMqMAVAjd5STaE9I5+17yU8O31e9ZRfIhHSgoa22yicopnNecSCARvhGuVcVfbdLB/t9bwtII1AAXIbxfk1da83cLu6QaKmFHy+EWzkNCQhOlX1AnYmxjYgGHs3wHFQHXMY5mZ5FAWmfT6niv8t1M5z65lsiWbgYxi+P5LWI4HA+J0VoawwYKsMbZuUVzqF3B7yTlYoxQ82pZkl7lc/GwGfqZygJe+o/k1sodJZxp0euTVwkElfz37bJNOGrwOuFuLB4TKUU9KnHxknXHGAHY1yPuc4Ohq+yQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AS8PR03MB6888.eurprd03.prod.outlook.com (2603:10a6:20b:294::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Thu, 5 Aug 2021 05:43:02 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::c9b2:14f8:d555:6f2d]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::c9b2:14f8:d555:6f2d%8]) with mapi id 15.20.4373.026; Thu, 5 Aug 2021 05:43:02 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Aug 2021 07:42:38 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: X-TMN: [WUpQSi2WON6kWVMiR0AA66Thlc7w+DLe] X-ClientProxiedBy: AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20210805054244.2094251-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.94.230) by AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Thu, 5 Aug 2021 05:43:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e781218d-f480-48b5-acd4-08d957d3e40b X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiTzvpWxvWYRCiBlmWjUmirgHa8co4T1+1z/TSITuJeCkE+uJQ86iSWweedFxlJZGglA6YoY9JskdEUf0C9t3D0ICOl/JSb4uyo/qGiumGzQ1Tb4/SMRj4wiZBdLd8n/gvBfhZN1mYi8YGnMdH5+UF5n3NZ2qoIuOxdXRFbkSekezKmMtC1Y/RPCXeZhWWjucQkZg313geMnIzLWGxt9k1V04CeBBJt2yrSscd0eY2fwQsfCeiXugU+Y2vm0qVxf3PfDel1OMm1A38IXSCsRR+pD3IAqaWQrACERT0QdeooTbztCPR7DGYFD2xEtkZ2IIMl2AAw8mcywgHBj00HRZu0zdTAy6W+HxL+aPyrNaKLHf+lFnLe0hwHYG/EkMEa4+deZmzksrkOmnCRViuTSk32GIzLKB63/535Scvj7U1cKB3NRSSIxY2p/98xBHDDv9NIk+N9XTUaK7V0FRJgbcP9eNx1TNq25YvZHZ6qVHvbMrNk4exs+CY0dktxVhJHdgpen/ro6oPVYJyYjSd10grByDjCA8lbPHVKtTvJl3/V8yNJ+lwaCgR1nwnqjj5J4YCReefJ3U/chXp879V4Lz96KqOLpyQIRuacnsRYmhglrhqps0wNdjV8zAYzJvVPue5qR8X2bPhD2ZzNP6WexzqLl8CJ6Fxmd1fWlXmJt6JUOeTolucjUgkwcsOYbu0LRufoUf2k1kYTUknFMCKg3IP/tB+lvC4BBm8CnpP58CUVUToXGmJGxatdyOqBje5nAN6o= X-MS-TrafficTypeDiagnostic: AS8PR03MB6888: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MU0iwghPbVrzv/1MOOrdQj0LaKKZqIYX7n4OMHt9cXuYH8TeYWDN7TYugOVO4wilcfXNT0/7ZRwKxLsg6nKQ/seEMxEDYu1WIq5Z9Ad9fs+HrhAFQbLzN0BuAcGVwWYl6a7kpReXoBIAiMEV8pE4tFF865V0xEr52pUyI0kX4VIwksd7rJGrSSWn/fLEqrQx8EM7tnClpRDOftiivXuYmN3SqBeJw2odYkJn5u6fp9pajNW1s5jPkKcqYsVuGYJRWrU+pJhJ0ReCSp0NU3D96FfUDT3GFeCiaHVcgDZnVLkG5gxORfR4DvEASqKSRBtETXo/tEhGXH7fVx1Q96E8sRl0CLdNrO0MeE0NC5Or5BJf9UYSDk9kQzjigbVK85rWRbf6j0jCogslNm6c5Ayoze6lazjT9hJwWZop6JjCdsaUmkFclfUNMt77fxnJ//iz X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QaFjw3hcxe9aJRhpK/aSTWIlsW9rRWzxB5WHJiVcDhrEbF7T86WO/h6C4nXYiW6prarR0wuHgkjkOa29lGTAeNCK+ujpQctEpasKPFPyNqMJAN4sJWVA4EdsZV+JoCnLAKCrTzTYZJzcORPp0gBP8A== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e781218d-f480-48b5-acd4-08d957d3e40b X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2021 05:43:02.7233 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB6888 Subject: [FFmpeg-devel] [PATCH 3/9] avformat/utils: Move ffio_limit() to aviobuf 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: uY+kW/fM2Zvh It is the more natural place for it given that it only deals with I/O; in fact, the function already has the ffio prefix and its declaration already is in avio_internal.h. Signed-off-by: Andreas Rheinhardt --- libavformat/aviobuf.c | 25 +++++++++++++++++++++++++ libavformat/utils.c | 25 ------------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 164b07ae6a..9322ed38bc 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -1015,6 +1015,31 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size) return 0; } +int ffio_limit(AVIOContext *s, int size) +{ + if (s->maxsize>= 0) { + int64_t pos = avio_tell(s); + int64_t remaining = s->maxsize - pos; + if (remaining < size) { + int64_t newsize = avio_size(s); + if (!s->maxsize || s->maxsizemaxsize = newsize - !newsize; + if (pos > s->maxsize && s->maxsize >= 0) + s->maxsize = AVERROR(EIO); + if (s->maxsize >= 0) + remaining = s->maxsize - pos; + } + + if (s->maxsize >= 0 && remaining < size && size > 1) { + av_log(NULL, remaining ? AV_LOG_ERROR : AV_LOG_DEBUG, + "Truncating packet of size %d to %"PRId64"\n", + size, remaining + !remaining); + size = remaining + !remaining; + } + } + return size; +} + int ffio_set_buf_size(AVIOContext *s, int buf_size) { uint8_t *buffer; diff --git a/libavformat/utils.c b/libavformat/utils.c index 60d7364018..8d1b76f590 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -213,31 +213,6 @@ static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream *st, /* an arbitrarily chosen "sane" max packet size -- 50M */ #define SANE_CHUNK_SIZE (50000000) -int ffio_limit(AVIOContext *s, int size) -{ - if (s->maxsize>= 0) { - int64_t pos = avio_tell(s); - int64_t remaining= s->maxsize - pos; - if (remaining < size) { - int64_t newsize = avio_size(s); - if (!s->maxsize || s->maxsizemaxsize = newsize - !newsize; - if (pos > s->maxsize && s->maxsize >= 0) - s->maxsize = AVERROR(EIO); - if (s->maxsize >= 0) - remaining = s->maxsize - pos; - } - - if (s->maxsize >= 0 && remaining < size && size > 1) { - av_log(NULL, remaining ? AV_LOG_ERROR : AV_LOG_DEBUG, - "Truncating packet of size %d to %"PRId64"\n", - size, remaining + !remaining); - size = remaining + !remaining; - } - } - return size; -} - /* Read the data in sane-sized chunks and append to pkt. * Return the number of bytes read or an error. */ static int append_packet_chunked(AVIOContext *s, AVPacket *pkt, int size) From patchwork Thu Aug 5 05:42:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 29260 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6c0f:0:0:0:0:0 with SMTP id a15csp97077ioh; Wed, 4 Aug 2021 22:43:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxU+A7MIVTN85zURtpvjEF3yCsBFlKTeMARrGBDRXjz5XbLGNDrMsHWJjflyyw+KobOetoP X-Received: by 2002:a05:6402:31a4:: with SMTP id dj4mr4260234edb.350.1628142230238; Wed, 04 Aug 2021 22:43:50 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y4si5154859ede.590.2021.08.04.22.43.27; Wed, 04 Aug 2021 22:43:50 -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=@outlook.com header.s=selector1 header.b=Wq2yPN18; arc=fail (body hash mismatch); 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2A31C68A2BD; Thu, 5 Aug 2021 08:43:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074080.outbound.protection.outlook.com [40.92.74.80]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4F90C68A199 for ; Thu, 5 Aug 2021 08:43:15 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JZYjTMSJYAqqYxMm8EOKM2TLplmScMgB/WNdX1s5wlBqB4yPPmBEGB4Pk4lW4Zn0pHsCwZpLDjsTuKXpn0LceNvtw6dz1QaueZZLflrsoDvxxVHoEzrK1ps8/I98Hs/gf6uhMfpsicDkOoEY0j+CWdkYdhLAsVDrtNcq+m4+XN16gThYh+IoxiY3/i80UwbwydFsW//qRSAvHwLGCLoN+KBVepYOJJZbs8vcGnGlGFCbSHCbyCG6Siw4xBjZ11oV3KTiZPCCCQ3fOef8TByhpA3KfCFyueBlTsoXA1JabID8lITX56Mt9HN2GF3Nv2nLsk271tCXFNCHwQP833Rpbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lD7V4FIq0d8M79E5KYDfMTyg9ZqIeJnxgOXy7gdm1X8=; b=TjAyvPcO0l2EKDzT15DISsS2Pa2rX7PHPtZIPEnEU1jf6Xaq352wK/Y3oJKDMptEuLVzGbuOdkF/reOrBs/DEULY/oza3BaW1q8vPIip55Pa1Mnk3MtI1YN4xEW3BTAMCkklYQI8SF7JVnxrFGE7E1OgG5Edb31Tw7MMIPFZhOJnFXfxYKpbbD3Gg3ypUH6AkHRmguoePiqk27miqN+AKh11NZJOLdP1UAMMUqCpmuKw73GPdJb1Jz08xkdm/LlKIhASbFaRIblm5sd4qLSugp3uwB/4mqQ3YYu+zniSY8JyjDPLrwnAlbDJDn74JP++BvnC5EQSpKU4UnVLDpLUog== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lD7V4FIq0d8M79E5KYDfMTyg9ZqIeJnxgOXy7gdm1X8=; b=Wq2yPN18SNxUJBISEXmfonwBXNqwgdIzbbBk9J69stXW4n/cgPwb8eQPqK4qgAn2ZCG66AtXfOiHwZuakNIuDkVkpoJVVSgkJgKhs/ve+WVlexQu7LTzrjsYb1/KKNiqbAz0PmsWt4UoOMZOOQvJKZclq2uChhFTo/Y3cAc2dT72lxxmI24LCy0PrrnC+FRAmiM8hWpmzwm8YtHAMrPhMqY8l6crTy6+2RlHkvBvOh9pNm7naizj1UULsT62x2DJamMsnk6fi7e7VF/UTYjs9N6+JCuqZ0P/LW8Kom6WHIeccdfDAxyDTobqfiT+cPb4dU667UGf0L9MuVH/ZOHQew== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AS8PR03MB6888.eurprd03.prod.outlook.com (2603:10a6:20b:294::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Thu, 5 Aug 2021 05:43:12 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::c9b2:14f8:d555:6f2d]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::c9b2:14f8:d555:6f2d%8]) with mapi id 15.20.4373.026; Thu, 5 Aug 2021 05:43:12 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Aug 2021 07:42:39 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: X-TMN: [PQD8Ih+wIjHCeqDw6RLIOV+VMHnPKt06] X-ClientProxiedBy: AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20210805054244.2094251-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.94.230) by AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Thu, 5 Aug 2021 05:43:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8d8723f2-ab3d-4efd-5943-08d957d3e9ea X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNW/g7RXT9bbJ0eAVVYsx4fIQcSVqciVGbe1nQCwUu4mgzeySSkWnjdNyEdU85rG37t3jDHd+NHlKcJ6Hx/Jt10KfKc/jA0o5kwws32ZbqbIZDgCKYrNL4XwDbgiG47xbSNiUjwB4CD/hnX19eg7ocPQeOgN/qz2sy810SFD5tarP2c2+haPyh8IBFSDYuLNaMpVHYxjssZVDrXdVLH4hr5JbVENHLLNtJloEGXMvFH/pmF6ejHm+Wr18XZdmAUGyULQM1SmLt4c06sNlBcVanfLva8VvSagm3Y3wZQJF/uaL2NMMgaTCJ7Wv3x7Gf6UDP9Pgc5h7ds2UAYMYDt5VNoHNwqG9KuhFb+N2DuQ2oJe+Ozb9oldul4M5I0zZVwiyFK/hwXk92mMODAbT1cP5ZejdbldhrbadyoX4CBfUnNKAyHXtqS1vX+1F3Ls/1yr4s+mos9jw/gbftHXEHOSoi/Fds3dMGKFkW5s7/aNCF18dybpEA355/8ygd3dZXuVdO/b1U9zrXQtOyAQNCJdu6iWDB32gzzWiv2Ff2Xw0fCV17lqlQYQDQQ17eGPWNmRH2h09PI/Yihw3BBE9uMOJmK7v3lmJ5TQDNuFrle47lOHSQK+k1jKXPqfcvMsGW6WQSMO6/Cy4av92DCV60JME/WgLXeuY3ZSujnwyLqdQhu6AhGKTUcyObc3f4KFEgFFzbnMLXT2Qe5cq1U5NAyVHj+gMvtcokqGzEo= X-MS-TrafficTypeDiagnostic: AS8PR03MB6888: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2sNa6TD0bymPIRKMdtEddHyQROm/zEdbqrRcLAYXzpH6q9Xs6cSUCcsQxjiFBFiyA7Lw83mHAaKRUsjVsKGM1sH0IWD8s+1gFFrwsiUBGccTycijo99C2o2zK6XP+dQIujdq5ushRqHH6zb4i/Mhs7VMsQj5nskSiXAzIJhf0j3Y96kDoYixYkNPF90QmyEVnFHZysg+rZZW2I9aimZG4N/6ZtDUMkpt/2nGT7C8Yie0oy7Ds52p1qEqmwyECwCeNTo2v8viH+7PsVZWsCeNf9f29dG1dkMv6brL0pj3lDSMHuLaIpswvm+TVOsHXPX05KN2XUGcpCqD6CmnkTu4xY9fWgViGdiOOluYEnjPOH6ZFC1v8fFKQ/vknxP/y3kVjoykvnBTlALtffXT/zqsfpv3M+VGufXiTL1rMAJmjpkIZALQ3sKb2Znay3RfA6Pc X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CcbPwSYRZIRkblMrO176hyEVqkXe/uArPRXrcxlL8ExaTMljnurfWQQqBcQleq/IEC0YL60AG8fuSjYw7l/Av+xok1oTIGYci/Yc6KeyDosai9BclX3lIaL7st2oZ3UCvgMU5dfgynWHh881vZ0Z7g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d8723f2-ab3d-4efd-5943-08d957d3e9ea X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2021 05:43:12.5932 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB6888 Subject: [FFmpeg-devel] [PATCH 4/9] avformat/aviobuf: Make ffio_set_buf_size() static 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: aIZkqwrMNN2F Possible since 9c3adb7ce23522dcceb264bc0bffd3592dd3e1a5. Signed-off-by: Andreas Rheinhardt --- It seems that despite the warning this function is called after having performed I/O; and that this is intended. Btw: Shall I move the functions around to avoid the forward declarations? libavformat/avio_internal.h | 3 --- libavformat/aviobuf.c | 8 +++++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index 2c6d00b5ff..de95b43bdb 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -83,9 +83,6 @@ uint64_t ffio_read_varlen(AVIOContext *bc); */ int ffio_read_size(AVIOContext *s, unsigned char *buf, int size); -/** @warning must be called before any I/O */ -int ffio_set_buf_size(AVIOContext *s, int buf_size); - /** * Reallocate a given buffer for AVIOContext. * diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 9322ed38bc..1f0819b328 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -74,6 +74,8 @@ const AVClass ff_avio_class = { static void fill_buffer(AVIOContext *s); static int url_resetbuf(AVIOContext *s, int flags); +/** @warning must be called before any I/O */ +static int set_buf_size(AVIOContext *s, int buf_size); int ffio_init_context(AVIOContext *s, unsigned char *buffer, @@ -543,7 +545,7 @@ static void fill_buffer(AVIOContext *s) /* make buffer smaller in case it ended up large after probing */ if (s->read_packet && s->orig_buffer_size && s->buffer_size > s->orig_buffer_size && len >= s->orig_buffer_size) { if (dst == s->buffer && s->buf_ptr != dst) { - int ret = ffio_set_buf_size(s, s->orig_buffer_size); + int ret = set_buf_size(s, s->orig_buffer_size); if (ret < 0) av_log(s, AV_LOG_WARNING, "Failed to decrease buffer size\n"); @@ -1040,7 +1042,7 @@ int ffio_limit(AVIOContext *s, int size) return size; } -int ffio_set_buf_size(AVIOContext *s, int buf_size) +static int set_buf_size(AVIOContext *s, int buf_size) { uint8_t *buffer; buffer = av_malloc(buf_size); @@ -1062,7 +1064,7 @@ int ffio_realloc_buf(AVIOContext *s, int buf_size) int data_size; if (!s->buffer_size) - return ffio_set_buf_size(s, buf_size); + return set_buf_size(s, buf_size); if (buf_size <= s->buffer_size) return 0; From patchwork Thu Aug 5 05:42:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 29263 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6c0f:0:0:0:0:0 with SMTP id a15csp96986ioh; Wed, 4 Aug 2021 22:43:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyI/oXbLTlRSVdX0/IrZ3wZDYvvF6p8nuR+y81TrMyPD9xvziHXGKHHi/be86A57Ug6/dy X-Received: by 2002:a17:906:2f15:: with SMTP id v21mr3012692eji.220.1628142220567; Wed, 04 Aug 2021 22:43:40 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id d18si4588454ejy.659.2021.08.04.22.43.39; Wed, 04 Aug 2021 22:43:40 -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=@outlook.com header.s=selector1 header.b=ktK6Je7s; arc=fail (body hash mismatch); 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2D57868A2FE; Thu, 5 Aug 2021 08:43:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074106.outbound.protection.outlook.com [40.92.74.106]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CF6DD68A21C for ; Thu, 5 Aug 2021 08:43:16 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=inRvivKzetuyu5/e0zQfepXRR6tWCltKbu4NSQaLmu0PZ8NL7ZWUdQZYnvW7rHg8ksweAvdI/B3YJoxx8dxO/2Gey7Z963auZaUB/GgsTviUTPfGYYuwsf1YvKsIsWgSpBc6Y/O5JmdV5RL9OckDSSCEdlDM3xH5q5WzfkIELqRb+TXnEkPlc8piz98AZzIdWdXEeOQiB6k0ZDKmUQlfm0nVpPyOvB2rBRCcWTUzvToz5EHg1pxb5HwKh58YaWL5RE0VYgC/sGGTQpbhFWZkyX+n6YfycAJIGq2ooWKK7Hv4radu0vIkDSplfPfV8sjCNvAPkyoH05oU2XNX1StRaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D9RTgNsPXN+G6GPQ7wu7P+yh5gT3uDEtWd4+L3gcuzo=; b=SVnMBhk4+zZccJF3I7Knvx/dU87mZGuvPTGkfYaDxusrVH5N5uThQvVvJhF4uESMEru2aYmM8wcGUebiauWfVk3ZmFGZ4d+gQbyEEhYXNY3apCRent69K1ZT/zjGXIFuIWHW0Un2tB90ZS5z7j4Du433lfRojjQm2dbrNhCelL8vs3QeKf9ZtKCdFyssn37KcJgpOfUXTiSawPaJlWLaDrHTVB087B/3Cs3f1S+lQb2/dyULSEZztrwcrqV7pNLJNw5ozVnc84XTrlMdxqhbZic4t7ndZRrnLMDgZh2vjqk5hewBfhgMqEm2JeXeKABexdgKHVw9gut4Fr4YSBPWmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D9RTgNsPXN+G6GPQ7wu7P+yh5gT3uDEtWd4+L3gcuzo=; b=ktK6Je7sC5vBir/LLKG7h8khx7f7hZvBXtTgIX1otw3kiZZF6AG4oK4LmyTDlXrrK+NruiTJKVDdX8qIgoZOe5UUwXT22tmXw2b3H+PBWFMy+MgdIAxsT7DIYTtaScoR0Z0UAO3PwcxwKU/LczhycCMD5n9ag/fg/ovvTH9vVU4s4eOMDOS4eSD4ylNR7ZjrysTYm25dIsaqjN7zbT6sVs+jIvJLPKY8TrxxlvvStShZgiDImqhtcafB+gpo5XN3ST8NwZo+lncQ0BrG8Crp/p8gA7pOyd6sJnfnJQjXtUMnULQ/rZa7qbOsQWCA5ZNgFAEmQ1ABHtkroyVmtJrTPQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AS8PR03MB6888.eurprd03.prod.outlook.com (2603:10a6:20b:294::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Thu, 5 Aug 2021 05:43:15 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::c9b2:14f8:d555:6f2d]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::c9b2:14f8:d555:6f2d%8]) with mapi id 15.20.4373.026; Thu, 5 Aug 2021 05:43:15 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Aug 2021 07:42:40 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: X-TMN: [bROvO6nfr4h4zo0rq7YZPlUL6iDA9B9V] X-ClientProxiedBy: AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20210805054244.2094251-4-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.94.230) by AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Thu, 5 Aug 2021 05:43:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d138436c-6fc5-4eaa-ce92-08d957d3eb32 X-MS-Exchange-SLBlob-MailProps: +LiGfBxqLEvXz/Cg0Ir87bEks07/0c4IXth8Hfu915MW8m3OfDM+GYpG+6OZ2hJUECaNZ+tKj3gbSONlkb2TZDfXgFW4zuOONXmhNLTaBK1j6Ns5AHFiV8lhLxvFU8sDoLEs6R0ucLwn9N5Dz5pXQBmFx26hC8KguCrz5lygPXZItFZENGMutrBCcXzhYbYkj7ZMQVTdONfxaVYLqGjt+DW3W6U5hviJUagu3ICzOWzoufdqQ6y6CkjZZ5/GjZF8k/xP2Qfqr1HgxIi2zm5jJEzTQtm+2dSjP0kAZMgC5b107N4wLC//I0QF37UDE6bAf57EMXuJOeV/jYDVecJo0YbVAUes3wIAXdQQwosUouC8SYTpv8PpH8pLO53TeSL9K90augRV5U5THivSEFeCHdgyHQKuQ3tskL2ktQZ4K23qixZ2pRkkmyN/sBKJAB7nVqZnagpE+qkRW2a9SaxDy29DZXa9bgvucQ/QtUSOtHSO5Sj+nNqD8S2DIwHpTyC0W60gT6uwuqIMmbQa6J8PpbEoAbIuo/BKKpxhbxcFAV6f5LMOwft7aXKtYybxr7cNyzl3jox/TZwb77SGpzvz+2zi+Pf5ARCxoBhMSOOcQIHqacU2vVmJnTD6YwIO1nc9Gk9bQWQSHCs8PSOrYPqZ8LzhA8navMgP7fu2d4jcu/po1DRFmuhiy1uJeymXVP4H69l6RUXHRJOgC4Ddu2qzxNGFJUESsdPhNmkI6EbP73vlEKHM9k1y0Nh2S3DzRfIfBPG5IFtCrKxVU0o6x/Dkamk3aj2UH9gs X-MS-TrafficTypeDiagnostic: AS8PR03MB6888: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i/5Kn2IZGZuDbDRQNXuJWxxMgwOepRLGaNSusJcSohtPCXF2GIk3lFkIKdMKKaIQQy5ubdYh4y8ra1ZqYWwL87nDbpuvS5pn9/LA//wAdXRQykxTcCGEk1mL/ISGuzKHKRtqCR2Q+X5wnjZT20I24P+JzLNv2thMydLc0dhs6yr33Gd8qySk7u1PL17y77N4e78qOfUDZCXDH9/j2ph9Irw7wjycllJYE5si2bB+XWSqFN25d6SOlENiQb/oTJCUGBdiRbJXKU2rmMQDF9kAZps5AUzYehZlo2M8rLbOe7A+YD2M54xAgdRZiYr1DXesohQ3JKNQii3joaxEHXgmUcHfJcS2wUIb7i7v2mkiHVSiMaOGI9K9D9AbILmQ35IfxsRcpI14OuWG/qWagW5oETQz+dpjZUxAe7450XhnFDnArKTj3Fl9b2QwbC7Qv3hFzHntswhcU4ZNP00aCeH9CHpqHSa7Zq7ml97QGPU50lc= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8oEtMfdXosGFWwVSxfYBO6FMxIsxov8tW/2TgOarpmngGGDAZhh2bICZ227PfOawljjWdBnrjgmFheHkjFdII+doeoNhb5c7C5mmRSVhd8RMxaZ7S05tDKjI7YUaoklyeAO98sPjkCs9WEUyrDviqw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d138436c-6fc5-4eaa-ce92-08d957d3eb32 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2021 05:43:15.1281 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB6888 Subject: [FFmpeg-devel] [PATCH 5/9] avformat/avio: Move internal AVIOContext fields to avio_internal.h 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: /0um1JYC1seJ Currently AVIOContext's private fields are all over AVIOContext. This commit moves them into a new structure in avio_internal.h instead. Said structure contains the public AVIOContext as its first element in order to avoid having to allocate a separate AVIOContextInternal which is costly for those use cases where one just wants to access an already existing buffer via the AVIOContext-API. For these cases ffio_init_context() can't fail and always returned zero, which was typically not checked. Therefore it has been made to not return anything. Signed-off-by: Andreas Rheinhardt --- I like the name FFIOContext (without any "internal" in it, because it contains more than just the internal fields), but the same can not be said about the "public" member, i.e. the public AVIOContext. It seems a bit long. Any better suggestions? pb would lead to expressions like &pb.pb which seems weird. Maybe just "pub"? Or something completely else? libavformat/aacdec.c | 6 +-- libavformat/asfenc.c | 8 +-- libavformat/av1.c | 4 +- libavformat/av1dec.c | 21 ++++---- libavformat/avio.h | 64 +++------------------- libavformat/avio_internal.h | 44 ++++++++++++++- libavformat/aviobuf.c | 105 +++++++++++++++++++----------------- libavformat/dashdec.c | 14 ++--- libavformat/hls.c | 23 ++++---- libavformat/id3v2.c | 6 +-- libavformat/matroskadec.c | 13 ++--- libavformat/matroskaenc.c | 5 +- libavformat/mmst.c | 4 +- libavformat/mov.c | 9 ++-- libavformat/mp3dec.c | 2 +- libavformat/mpegts.c | 76 +++++++++++++------------- libavformat/mpjpegdec.c | 4 +- libavformat/oggenc.c | 6 +-- libavformat/rdt.c | 33 ++++++------ libavformat/rtpdec_asf.c | 26 ++++----- libavformat/rtpdec_qt.c | 35 ++++++------ libavformat/rtsp.c | 4 +- libavformat/sapdec.c | 4 +- libavformat/subtitles.c | 3 +- libavformat/subtitles.h | 3 +- libavformat/thp.c | 9 ++-- libavformat/utils.c | 20 ++++--- libavformat/vividas.c | 10 ++-- 28 files changed, 290 insertions(+), 271 deletions(-) diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c index 94e39f592f..94cc98cc45 100644 --- a/libavformat/aacdec.c +++ b/libavformat/aacdec.c @@ -135,7 +135,7 @@ static int adts_aac_read_header(AVFormatContext *s) static int handle_id3(AVFormatContext *s, AVPacket *pkt) { AVDictionary *metadata = NULL; - AVIOContext ioctx; + FFIOContext pb; ID3v2ExtraMeta *id3v2_extra_meta; int ret; @@ -144,8 +144,8 @@ static int handle_id3(AVFormatContext *s, AVPacket *pkt) return ret; } - ffio_init_context(&ioctx, pkt->data, pkt->size, 0, NULL, NULL, NULL, NULL); - ff_id3v2_read_dict(&ioctx, &metadata, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta); + ffio_init_context(&pb, pkt->data, pkt->size, 0, NULL, NULL, NULL, NULL); + ff_id3v2_read_dict(&pb.public, &metadata, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta); if ((ret = ff_id3v2_parse_priv_dict(&metadata, id3v2_extra_meta)) < 0) goto error; diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c index a8a844ce6e..953e7b515c 100644 --- a/libavformat/asfenc.c +++ b/libavformat/asfenc.c @@ -236,7 +236,7 @@ typedef struct ASFContext { int64_t packet_timestamp_end; unsigned int packet_nb_payloads; uint8_t packet_buf[PACKET_SIZE_MAX]; - AVIOContext pb; + FFIOContext pb; /* only for reading */ uint64_t data_offset; ///< beginning of the first data packet @@ -911,7 +911,7 @@ static void put_payload_header(AVFormatContext *s, ASFStream *stream, int m_obj_offset, int payload_len, int flags) { ASFContext *asf = s->priv_data; - AVIOContext *pb = &asf->pb; + AVIOContext *const pb = &asf->pb.public; int val; val = stream->num; @@ -983,7 +983,7 @@ static void put_frame(AVFormatContext *s, ASFStream *stream, AVStream *avst, put_payload_header(s, stream, timestamp + PREROLL_TIME, m_obj_size, m_obj_offset, payload_len, flags); - avio_write(&asf->pb, buf, payload_len); + avio_write(&asf->pb.public, buf, payload_len); if (asf->multi_payloads_present) asf->packet_size_left -= (payload_len + PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS); @@ -1125,7 +1125,7 @@ static int asf_write_trailer(AVFormatContext *s) int ret; /* flush the current packet */ - if (asf->pb.buf_ptr > asf->pb.buffer) + if (asf->pb.public.buf_ptr > asf->pb.public.buffer) flush_packet(s); /* write index */ diff --git a/libavformat/av1.c b/libavformat/av1.c index 5512c4e0f7..de384b8866 100644 --- a/libavformat/av1.c +++ b/libavformat/av1.c @@ -86,7 +86,7 @@ int ff_av1_filter_obus(AVIOContext *pb, const uint8_t *buf, int size) int ff_av1_filter_obus_buf(const uint8_t *in, uint8_t **out, int *size, int *offset) { - AVIOContext pb; + FFIOContext pb; uint8_t *buf; int len, off, ret; @@ -108,7 +108,7 @@ int ff_av1_filter_obus_buf(const uint8_t *in, uint8_t **out, ffio_init_context(&pb, buf, len, 1, NULL, NULL, NULL, NULL); - ret = av1_filter_obus(&pb, in, *size, NULL); + ret = av1_filter_obus(&pb.public, in, *size, NULL); av_assert1(ret == len); memset(buf + len, 0, AV_INPUT_BUFFER_PADDING_SIZE); diff --git a/libavformat/av1dec.c b/libavformat/av1dec.c index f6c575069e..262fa0a5a0 100644 --- a/libavformat/av1dec.c +++ b/libavformat/av1dec.c @@ -135,32 +135,33 @@ static int read_obu(const uint8_t *buf, int size, int64_t *obu_size, int *type) static int annexb_probe(const AVProbeData *p) { - AVIOContext pb; + FFIOContext ctx; + AVIOContext *const pb = &ctx.public; int64_t obu_size; uint32_t temporal_unit_size, frame_unit_size, obu_unit_size; int seq = 0; int ret, type, cnt = 0; - ffio_init_context(&pb, p->buf, p->buf_size, 0, + ffio_init_context(&ctx, p->buf, p->buf_size, 0, NULL, NULL, NULL, NULL); - ret = leb(&pb, &temporal_unit_size); + ret = leb(pb, &temporal_unit_size); if (ret < 0) return 0; cnt += ret; - ret = leb(&pb, &frame_unit_size); + ret = leb(pb, &frame_unit_size); if (ret < 0 || ((int64_t)frame_unit_size + ret) > temporal_unit_size) return 0; cnt += ret; - ret = leb(&pb, &obu_unit_size); + ret = leb(pb, &obu_unit_size); if (ret < 0 || ((int64_t)obu_unit_size + ret) >= frame_unit_size) return 0; cnt += ret; frame_unit_size -= obu_unit_size + ret; - avio_skip(&pb, obu_unit_size); - if (pb.eof_reached || pb.error) + avio_skip(pb, obu_unit_size); + if (pb->eof_reached || pb->error) return 0; // Check that the first OBU is a Temporal Delimiter. @@ -170,13 +171,13 @@ static int annexb_probe(const AVProbeData *p) cnt += obu_unit_size; do { - ret = leb(&pb, &obu_unit_size); + ret = leb(pb, &obu_unit_size); if (ret < 0 || ((int64_t)obu_unit_size + ret) > frame_unit_size) return 0; cnt += ret; - avio_skip(&pb, obu_unit_size); - if (pb.eof_reached || pb.error) + avio_skip(pb, obu_unit_size); + if (pb->eof_reached || pb->error) return 0; ret = read_obu(p->buf + cnt, FFMIN(p->buf_size - cnt, obu_unit_size), &obu_size, &type); diff --git a/libavformat/avio.h b/libavformat/avio.h index 0b35409787..a7b56ab667 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -148,9 +148,9 @@ enum AVIODataMarkerType { /** * Bytestream IO Context. - * New fields can be added to the end with minor version bumps. - * Removal, reordering and changes to existing fields require a major - * version bump. + * New public fields can be added with minor version bumps. + * Removal, reordering and changes to existing public fields require + * a major version bump. * sizeof(AVIOContext) must not be used outside libav*. * * @note None of the function pointers in AVIOContext should be called @@ -237,12 +237,14 @@ typedef struct AVIOContext { int64_t (*seek)(void *opaque, int64_t offset, int whence); int64_t pos; /**< position in the file of the current buffer */ int eof_reached; /**< true if was unable to read due to error or eof */ + int error; /**< contains the error code or 0 if no error happened */ int write_flag; /**< true if open for writing */ int max_packet_size; + int min_packet_size; /**< Try to buffer at least this amount of data + before flushing it. */ unsigned long checksum; unsigned char *checksum_ptr; unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size); - int error; /**< contains the error code or 0 if no error happened */ /** * Pause or resume playback for network streaming protocols - e.g. MMS. */ @@ -259,12 +261,6 @@ typedef struct AVIOContext { */ int seekable; - /** - * max filesize, used to limit allocations - * This field is internal to libavformat and access from outside is not allowed. - */ - int64_t maxsize; - /** * avio_read and avio_write should if possible be satisfied directly * instead of going through a buffer, and avio_seek will always @@ -272,37 +268,6 @@ typedef struct AVIOContext { */ int direct; - /** - * Bytes read statistic - * This field is internal to libavformat and access from outside is not allowed. - */ - int64_t bytes_read; - - /** - * seek statistic - * This field is internal to libavformat and access from outside is not allowed. - */ - int seek_count; - - /** - * writeout statistic - * This field is internal to libavformat and access from outside is not allowed. - */ - int writeout_count; - - /** - * Original buffer size - * used internally after probing and ensure seekback to reset the buffer size - * This field is internal to libavformat and access from outside is not allowed. - */ - int orig_buffer_size; - - /** - * Threshold to favor readahead over seek. - * This is current internal only, do not use from outside. - */ - int short_seek_threshold; - /** * ',' separated list of allowed protocols. */ @@ -325,18 +290,6 @@ typedef struct AVIOContext { */ int ignore_boundary_point; - /** - * Internal, not meant to be used from outside of AVIOContext. - */ - enum AVIODataMarkerType current_type; - int64_t last_time; - - /** - * A callback that is used instead of short_seek_threshold. - * This is current internal only, do not use from outside. - */ - int (*short_seek_get)(void *opaque); - int64_t written; /** @@ -344,11 +297,6 @@ typedef struct AVIOContext { * used keeping track of already written data for a later flush. */ unsigned char *buf_ptr_max; - - /** - * Try to buffer at least this amount of data before flushing it - */ - int min_packet_size; } AVIOContext; /** diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index de95b43bdb..b2356529e1 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -26,7 +26,49 @@ extern const AVClass ff_avio_class; -int ffio_init_context(AVIOContext *s, +typedef struct FFIOContext { + AVIOContext public; + /** + * A callback that is used instead of short_seek_threshold. + */ + int (*short_seek_get)(void *opaque); + + /** + * Threshold to favor readahead over seek. + */ + int short_seek_threshold; + + enum AVIODataMarkerType current_type; + int64_t last_time; + + /** + * max filesize, used to limit allocations + */ + int64_t maxsize; + + /** + * Bytes read statistic + */ + int64_t bytes_read; + + /** + * seek statistic + */ + int seek_count; + + /** + * writeout statistic + */ + int writeout_count; + + /** + * Original buffer size + * used after probing to ensure seekback and to reset the buffer size + */ + int orig_buffer_size; +} FFIOContext; + +void ffio_init_context(FFIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 1f0819b328..f04e15f4f1 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -77,7 +77,7 @@ static int url_resetbuf(AVIOContext *s, int flags); /** @warning must be called before any I/O */ static int set_buf_size(AVIOContext *s, int buf_size); -int ffio_init_context(AVIOContext *s, +void ffio_init_context(FFIOContext *ctx, unsigned char *buffer, int buffer_size, int write_flag, @@ -86,10 +86,12 @@ int ffio_init_context(AVIOContext *s, int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t (*seek)(void *opaque, int64_t offset, int whence)) { - memset(s, 0, sizeof(AVIOContext)); + AVIOContext *const s = &ctx->public; + + memset(ctx, 0, sizeof(*ctx)); s->buffer = buffer; - s->orig_buffer_size = + ctx->orig_buffer_size = s->buffer_size = buffer_size; s->buf_ptr = buffer; s->buf_ptr_max = buffer; @@ -108,7 +110,7 @@ int ffio_init_context(AVIOContext *s, s->min_packet_size = 0; s->max_packet_size = 0; s->update_checksum = NULL; - s->short_seek_threshold = SHORT_SEEK_THRESHOLD; + ctx->short_seek_threshold = SHORT_SEEK_THRESHOLD; if (!read_packet && !write_flag) { s->pos = buffer_size; @@ -119,12 +121,10 @@ int ffio_init_context(AVIOContext *s, s->write_data_type = NULL; s->ignore_boundary_point = 0; - s->current_type = AVIO_DATA_MARKER_UNKNOWN; - s->last_time = AV_NOPTS_VALUE; - s->short_seek_get = NULL; + ctx->current_type = AVIO_DATA_MARKER_UNKNOWN; + ctx->last_time = AV_NOPTS_VALUE; + ctx->short_seek_get = NULL; s->written = 0; - - return 0; } AVIOContext *avio_alloc_context( @@ -136,12 +136,12 @@ AVIOContext *avio_alloc_context( int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t (*seek)(void *opaque, int64_t offset, int whence)) { - AVIOContext *s = av_malloc(sizeof(AVIOContext)); + FFIOContext *s = av_malloc(sizeof(*s)); if (!s) return NULL; ffio_init_context(s, buffer, buffer_size, write_flag, opaque, read_packet, write_packet, seek); - return s; + return &s->public; } void avio_context_free(AVIOContext **ps) @@ -151,13 +151,14 @@ void avio_context_free(AVIOContext **ps) static void writeout(AVIOContext *s, const uint8_t *data, int len) { + FFIOContext *const ctx = (FFIOContext*)s; if (!s->error) { int ret = 0; if (s->write_data_type) ret = s->write_data_type(s->opaque, (uint8_t *)data, len, - s->current_type, - s->last_time); + ctx->current_type, + ctx->last_time); else if (s->write_packet) ret = s->write_packet(s->opaque, (uint8_t *)data, len); if (ret < 0) { @@ -167,12 +168,12 @@ static void writeout(AVIOContext *s, const uint8_t *data, int len) s->written = s->pos + len; } } - if (s->current_type == AVIO_DATA_MARKER_SYNC_POINT || - s->current_type == AVIO_DATA_MARKER_BOUNDARY_POINT) { - s->current_type = AVIO_DATA_MARKER_UNKNOWN; + if (ctx->current_type == AVIO_DATA_MARKER_SYNC_POINT || + ctx->current_type == AVIO_DATA_MARKER_BOUNDARY_POINT) { + ctx->current_type = AVIO_DATA_MARKER_UNKNOWN; } - s->last_time = AV_NOPTS_VALUE; - s->writeout_count ++; + ctx->last_time = AV_NOPTS_VALUE; + ctx->writeout_count++; s->pos += len; } @@ -244,6 +245,7 @@ void avio_flush(AVIOContext *s) int64_t avio_seek(AVIOContext *s, int64_t offset, int whence) { + FFIOContext *const ctx = (FFIOContext*)s; int64_t offset1; int64_t pos; int force = whence & AVSEEK_FORCE; @@ -275,9 +277,9 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence) if (offset < 0) return AVERROR(EINVAL); - short_seek = s->short_seek_threshold; - if (s->short_seek_get) { - int tmp = s->short_seek_get(s->opaque); + short_seek = ctx->short_seek_threshold; + if (ctx->short_seek_get) { + int tmp = ctx->short_seek_get(s->opaque); short_seek = FFMAX(tmp, short_seek); } @@ -318,7 +320,7 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence) return AVERROR(EPIPE); if ((res = s->seek(s->opaque, offset, SEEK_SET)) < 0) return res; - s->seek_count ++; + ctx->seek_count++; if (!s->write_flag) s->buf_end = s->buffer; s->buf_ptr = s->buf_ptr_max = s->buffer; @@ -472,6 +474,7 @@ void avio_wb24(AVIOContext *s, unsigned int val) void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type) { + FFIOContext *const ctx = (FFIOContext*)s; if (type == AVIO_DATA_MARKER_FLUSH_POINT) { if (s->buf_ptr - s->buffer >= s->min_packet_size) avio_flush(s); @@ -485,8 +488,8 @@ void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType typ // Avoid unnecessary flushes if we are already in non-header/trailer // data and setting the type to unknown if (type == AVIO_DATA_MARKER_UNKNOWN && - (s->current_type != AVIO_DATA_MARKER_HEADER && - s->current_type != AVIO_DATA_MARKER_TRAILER)) + (ctx->current_type != AVIO_DATA_MARKER_HEADER && + ctx->current_type != AVIO_DATA_MARKER_TRAILER)) return; switch (type) { @@ -494,7 +497,7 @@ void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType typ case AVIO_DATA_MARKER_TRAILER: // For header/trailer, ignore a new marker of the same type; // consecutive header/trailer markers can be merged. - if (type == s->current_type) + if (type == ctx->current_type) return; break; } @@ -502,8 +505,8 @@ void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType typ // If we've reached here, we have a new, noteworthy marker. // Flush the previous data and mark the start of the new data. avio_flush(s); - s->current_type = type; - s->last_time = time; + ctx->current_type = type; + ctx->last_time = time; } static int read_packet_wrapper(AVIOContext *s, uint8_t *buf, int size) @@ -521,6 +524,7 @@ static int read_packet_wrapper(AVIOContext *s, uint8_t *buf, int size) static void fill_buffer(AVIOContext *s) { + FFIOContext *const ctx = (FFIOContext *)s; int max_buffer_size = s->max_packet_size ? s->max_packet_size : IO_BUFFER_SIZE; uint8_t *dst = s->buf_end - s->buffer + max_buffer_size <= s->buffer_size ? @@ -543,15 +547,16 @@ static void fill_buffer(AVIOContext *s) } /* make buffer smaller in case it ended up large after probing */ - if (s->read_packet && s->orig_buffer_size && s->buffer_size > s->orig_buffer_size && len >= s->orig_buffer_size) { + if (s->read_packet && ctx->orig_buffer_size && + s->buffer_size > ctx->orig_buffer_size && len >= ctx->orig_buffer_size) { if (dst == s->buffer && s->buf_ptr != dst) { - int ret = set_buf_size(s, s->orig_buffer_size); + int ret = set_buf_size(s, ctx->orig_buffer_size); if (ret < 0) av_log(s, AV_LOG_WARNING, "Failed to decrease buffer size\n"); s->checksum_ptr = dst = s->buffer; } - len = s->orig_buffer_size; + len = ctx->orig_buffer_size; } len = read_packet_wrapper(s, dst, len); @@ -566,7 +571,7 @@ static void fill_buffer(AVIOContext *s) s->pos += len; s->buf_ptr = dst; s->buf_end = dst + len; - s->bytes_read += len; + ((FFIOContext*)s)->bytes_read += len; } } @@ -639,7 +644,7 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size) break; } else { s->pos += len; - s->bytes_read += len; + ((FFIOContext*)s)->bytes_read += len; size -= len; buf += len; // reset the buffer @@ -955,7 +960,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h) if (h->prot->url_read_seek) (*s)->seekable |= AVIO_SEEKABLE_TIME; } - (*s)->short_seek_get = (int (*)(void *))ffurl_get_short_seek; + ((FFIOContext*)(*s))->short_seek_get = (int (*)(void *))ffurl_get_short_seek; (*s)->av_class = &ff_avio_class; return 0; fail: @@ -1019,20 +1024,21 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size) int ffio_limit(AVIOContext *s, int size) { - if (s->maxsize>= 0) { + FFIOContext *const ctx = (FFIOContext*)s; + if (ctx->maxsize >= 0) { int64_t pos = avio_tell(s); - int64_t remaining = s->maxsize - pos; + int64_t remaining = ctx->maxsize - pos; if (remaining < size) { int64_t newsize = avio_size(s); - if (!s->maxsize || s->maxsizemaxsize = newsize - !newsize; - if (pos > s->maxsize && s->maxsize >= 0) - s->maxsize = AVERROR(EIO); - if (s->maxsize >= 0) - remaining = s->maxsize - pos; + if (!ctx->maxsize || ctx->maxsize < newsize) + ctx->maxsize = newsize - !newsize; + if (pos > ctx->maxsize && ctx->maxsize >= 0) + ctx->maxsize = AVERROR(EIO); + if (ctx->maxsize >= 0) + remaining = ctx->maxsize - pos; } - if (s->maxsize >= 0 && remaining < size && size > 1) { + if (ctx->maxsize >= 0 && remaining < size && size > 1) { av_log(NULL, remaining ? AV_LOG_ERROR : AV_LOG_DEBUG, "Truncating packet of size %d to %"PRId64"\n", size, remaining + !remaining); @@ -1051,7 +1057,7 @@ static int set_buf_size(AVIOContext *s, int buf_size) av_free(s->buffer); s->buffer = buffer; - s->orig_buffer_size = + ((FFIOContext*)s)->orig_buffer_size = s->buffer_size = buf_size; s->buf_ptr = s->buf_ptr_max = buffer; url_resetbuf(s, s->write_flag ? AVIO_FLAG_WRITE : AVIO_FLAG_READ); @@ -1078,7 +1084,7 @@ int ffio_realloc_buf(AVIOContext *s, int buf_size) memcpy(buffer, s->write_flag ? s->buffer : s->buf_ptr, data_size); av_free(s->buffer); s->buffer = buffer; - s->orig_buffer_size = buf_size; + ((FFIOContext*)s)->orig_buffer_size = buf_size; s->buffer_size = buf_size; s->buf_ptr = s->write_flag ? (s->buffer + data_size) : s->buffer; if (s->write_flag) @@ -1180,6 +1186,7 @@ int avio_open2(AVIOContext **s, const char *filename, int flags, int avio_close(AVIOContext *s) { + FFIOContext *const ctx = (FFIOContext*)s; URLContext *h; if (!s) @@ -1191,9 +1198,11 @@ 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", s->seek_count, s->writeout_count); + av_log(s, AV_LOG_VERBOSE, "Statistics: %d seeks, %d writeouts\n", + ctx->seek_count, ctx->writeout_count); else - av_log(s, AV_LOG_VERBOSE, "Statistics: %"PRId64" bytes read, %d seeks\n", s->bytes_read, s->seek_count); + av_log(s, AV_LOG_VERBOSE, "Statistics: %"PRId64" bytes read, %d seeks\n", + ctx->bytes_read, ctx->seek_count); av_opt_free(s); avio_context_free(&s); @@ -1427,8 +1436,8 @@ void ffio_reset_dyn_buf(AVIOContext *s) DynBuffer *d = s->opaque; int max_packet_size = s->max_packet_size; - ffio_init_context(s, d->io_buffer, d->io_buffer_size, 1, d, NULL, - s->write_packet, s->seek); + ffio_init_context((FFIOContext*)s, d->io_buffer, d->io_buffer_size, + 1, d, NULL, s->write_packet, s->seek); s->max_packet_size = max_packet_size; d->pos = d->size = 0; } diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index 6105ec46d9..0ee2a963d1 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -77,7 +77,7 @@ struct timeline { */ struct representation { char *url_template; - AVIOContext pb; + FFIOContext pb; AVIOContext *input; AVFormatContext *parent; AVFormatContext *ctx; @@ -353,7 +353,7 @@ static void free_representation(struct representation *pls) free_fragment(&pls->cur_seg); free_fragment(&pls->init_section); av_freep(&pls->init_sec_buf); - av_freep(&pls->pb.buffer); + av_freep(&pls->pb.public.buffer); ff_format_io_close(pls->parent, &pls->input); if (pls->ctx) { pls->ctx->pb = NULL; @@ -1871,8 +1871,8 @@ static int nested_io_open(AVFormatContext *s, AVIOContext **pb, const char *url, static void close_demux_for_component(struct representation *pls) { /* note: the internal buffer could have changed */ - av_freep(&pls->pb.buffer); - memset(&pls->pb, 0x00, sizeof(AVIOContext)); + av_freep(&pls->pb.public.buffer); + memset(&pls->pb, 0x00, sizeof(pls->pb)); pls->ctx->pb = NULL; avformat_close_input(&pls->ctx); } @@ -1908,7 +1908,7 @@ static int reopen_demux_for_component(AVFormatContext *s, struct representation } ffio_init_context(&pls->pb, avio_ctx_buffer, INITIAL_BUFFER_SIZE, 0, pls, read_data, NULL, c->is_live ? NULL : seek_data); - pls->pb.seekable = 0; + pls->pb.public.seekable = 0; if ((ret = ff_copy_whiteblacklists(pls->ctx, s)) < 0) goto fail; @@ -1917,7 +1917,7 @@ static int reopen_demux_for_component(AVFormatContext *s, struct representation pls->ctx->probesize = s->probesize > 0 ? s->probesize : 1024 * 4; pls->ctx->max_analyze_duration = s->max_analyze_duration > 0 ? s->max_analyze_duration : 4 * AV_TIME_BASE; pls->ctx->interrupt_callback = s->interrupt_callback; - ret = av_probe_input_buffer(&pls->pb, &in_fmt, "", NULL, 0, 0); + ret = av_probe_input_buffer(&pls->pb.public, &in_fmt, "", NULL, 0, 0); if (ret < 0) { av_log(s, AV_LOG_ERROR, "Error when loading first fragment of playlist\n"); avformat_free_context(pls->ctx); @@ -1925,7 +1925,7 @@ static int reopen_demux_for_component(AVFormatContext *s, struct representation goto fail; } - pls->ctx->pb = &pls->pb; + pls->ctx->pb = &pls->pb.public; pls->ctx->io_open = nested_io_open; // provide additional information from mpd if available diff --git a/libavformat/hls.c b/libavformat/hls.c index 3c1b80f60c..56b440890b 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -92,7 +92,7 @@ enum PlaylistType { */ struct playlist { char url[MAX_URL_SIZE]; - AVIOContext pb; + FFIOContext pb; uint8_t* read_buffer; AVIOContext *input; int input_read_done; @@ -258,7 +258,7 @@ static void free_playlist_list(HLSContext *c) ff_id3v2_free_extra_meta(&pls->id3_deferred_extra); av_freep(&pls->init_sec_buf); av_packet_free(&pls->pkt); - av_freep(&pls->pb.buffer); + av_freep(&pls->pb.public.buffer); ff_format_io_close(c->ctx, &pls->input); pls->input_read_done = 0; ff_format_io_close(c->ctx, &pls->input_next); @@ -1222,9 +1222,9 @@ static void intercept_id3(struct playlist *pls, uint8_t *buf, if (pls->id3_buf) { /* Now parse all the ID3 tags */ - AVIOContext id3ioctx; + FFIOContext id3ioctx; ffio_init_context(&id3ioctx, pls->id3_buf, id3_buf_pos, 0, NULL, NULL, NULL, NULL); - handle_id3(&id3ioctx, pls); + handle_id3(&id3ioctx.public, pls); } if (pls->is_id3_timestamped == -1) @@ -1995,7 +1995,7 @@ static int hls_read_header(AVFormatContext *s) pls->ctx->max_analyze_duration = s->max_analyze_duration > 0 ? s->max_analyze_duration : 4 * AV_TIME_BASE; pls->ctx->interrupt_callback = s->interrupt_callback; url = av_strdup(pls->segments[0]->url); - ret = av_probe_input_buffer(&pls->pb, &in_fmt, url, NULL, 0, 0); + ret = av_probe_input_buffer(&pls->pb.public, &in_fmt, url, NULL, 0, 0); if (ret < 0) { /* Free the ctx - it isn't initialized properly at this point, * so avformat_close_input shouldn't be called. If @@ -2008,7 +2008,7 @@ static int hls_read_header(AVFormatContext *s) return ret; } av_free(url); - pls->ctx->pb = &pls->pb; + pls->ctx->pb = &pls->pb.public; pls->ctx->io_open = nested_io_open; pls->ctx->flags |= s->flags & ~AVFMT_FLAG_CUSTOM_IO; @@ -2087,7 +2087,7 @@ static int recheck_discard_flags(AVFormatContext *s, int first) pls->needed = 1; changed = 1; pls->cur_seq_no = select_cur_seq_no(c, pls); - pls->pb.eof_reached = 0; + pls->pb.public.eof_reached = 0; if (c->cur_timestamp != AV_NOPTS_VALUE) { /* catch up */ pls->seek_timestamp = c->cur_timestamp; @@ -2168,7 +2168,7 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt) AVRational tb; ret = av_read_frame(pls->ctx, pls->pkt); if (ret < 0) { - if (!avio_feof(&pls->pb) && ret != AVERROR_EOF) + if (!avio_feof(&pls->pb.public) && ret != AVERROR_EOF) return ret; break; } else { @@ -2336,16 +2336,17 @@ static int hls_read_seek(AVFormatContext *s, int stream_index, for (i = 0; i < c->n_playlists; i++) { /* Reset reading */ struct playlist *pls = c->playlists[i]; + AVIOContext *const pb = &pls->pb.public; ff_format_io_close(pls->parent, &pls->input); pls->input_read_done = 0; ff_format_io_close(pls->parent, &pls->input_next); pls->input_next_requested = 0; av_packet_unref(pls->pkt); - pls->pb.eof_reached = 0; + pb->eof_reached = 0; /* Clear any buffered data */ - pls->pb.buf_end = pls->pb.buf_ptr = pls->pb.buffer; + pb->buf_end = pb->buf_ptr = pb->buffer; /* Reset the pos, to let the mpegts demuxer know we've seeked. */ - pls->pb.pos = 0; + pb->pos = 0; /* Flush the packet queue of the subdemuxer. */ ff_read_frame_flush(pls->ctx); diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c index 96226193c1..0cc2ca32ff 100644 --- a/libavformat/id3v2.c +++ b/libavformat/id3v2.c @@ -827,7 +827,7 @@ static void id3v2_parse(AVIOContext *pb, AVDictionary **metadata, int64_t next, end = avio_tell(pb); int taghdrlen; const char *reason = NULL; - AVIOContext pb_local; + FFIOContext pb_local; AVIOContext *pbx; unsigned char *buffer = NULL; int buffer_size = 0; @@ -999,7 +999,7 @@ static void id3v2_parse(AVIOContext *pb, AVDictionary **metadata, ffio_init_context(&pb_local, buffer, b - buffer, 0, NULL, NULL, NULL, NULL); tlen = b - buffer; - pbx = &pb_local; // read from sync buffer + pbx = &pb_local.public; // read from sync buffer } #if CONFIG_ZLIB @@ -1035,7 +1035,7 @@ static void id3v2_parse(AVIOContext *pb, AVDictionary **metadata, } ffio_init_context(&pb_local, uncompressed_buffer, dlen, 0, NULL, NULL, NULL, NULL); tlen = dlen; - pbx = &pb_local; // read from sync buffer + pbx = &pb_local.public; // read from sync buffer } #endif if (tag[0] == 'T') diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 1977240cf9..6473d97796 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2350,7 +2350,7 @@ static int matroska_parse_tracks(AVFormatContext *s) int extradata_size = 0; int extradata_offset = 0; uint32_t fourcc = 0; - AVIOContext b; + FFIOContext b; char* key_id_base64 = NULL; int bit_depth = -1; @@ -2511,7 +2511,8 @@ static int matroska_parse_tracks(AVFormatContext *s) ffio_init_context(&b, track->codec_priv.data, track->codec_priv.size, 0, NULL, NULL, NULL, NULL); - ret = ff_get_wav_header(s, &b, st->codecpar, track->codec_priv.size, 0); + ret = ff_get_wav_header(s, &b.public, st->codecpar, + track->codec_priv.size, 0); if (ret < 0) return ret; codec_id = st->codecpar->codec_id; @@ -2557,7 +2558,7 @@ static int matroska_parse_tracks(AVFormatContext *s) ffio_init_context(&b, track->codec_priv.data, track->codec_priv.size, 0, NULL, NULL, NULL, NULL); - if (ff_get_qtpalette(codec_id, &b, track->palette)) { + if (ff_get_qtpalette(codec_id, &b.public, track->palette)) { bit_depth &= 0x1F; track->has_palette = 1; } @@ -3587,7 +3588,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf { uint64_t timecode = AV_NOPTS_VALUE; MatroskaTrack *track; - AVIOContext pb; + FFIOContext pb; int res = 0; AVStream *st; int16_t block_time; @@ -3598,7 +3599,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf ffio_init_context(&pb, data, size, 0, NULL, NULL, NULL, NULL); - if ((n = ebml_read_num(matroska, &pb, 8, &num, 1)) < 0) + if ((n = ebml_read_num(matroska, &pb.public, 8, &num, 1)) < 0) return n; data += n; size -= n; @@ -3656,7 +3657,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf } res = matroska_parse_laces(matroska, &data, size, (flags & 0x06) >> 1, - &pb, lace_size, &laces); + &pb.public, lace_size, &laces); if (res < 0) { av_log(matroska->ctx, AV_LOG_ERROR, "Error parsing frame sizes.\n"); return res; diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 899a3388cd..642cebe207 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -839,11 +839,12 @@ static void mkv_write_video_color(AVIOContext *pb, const AVStream *st, * a master element with two bytes ID and one byte length field * plus another byte to stay clear of the end. */ uint8_t colour[(2 + 1 + 8) * 18 + (2 + 1) + 1]; - AVIOContext buf, *dyn_cp = &buf; + FFIOContext buf; + AVIOContext *const dyn_cp = &buf.public; int colorinfo_size; const void *side_data; - ffio_init_context(dyn_cp, colour, sizeof(colour), 1, NULL, NULL, NULL, NULL); + ffio_init_context(&buf, colour, sizeof(colour), 1, NULL, NULL, NULL, NULL); if (par->color_trc != AVCOL_TRC_UNSPECIFIED && par->color_trc < AVCOL_TRC_NB) { diff --git a/libavformat/mmst.c b/libavformat/mmst.c index fa6e86ac26..520512490d 100644 --- a/libavformat/mmst.c +++ b/libavformat/mmst.c @@ -154,13 +154,13 @@ static int send_command_packet(MMSTContext *mmst) static int mms_put_utf16(MMSContext *mms, const uint8_t *src) { - AVIOContext bic; + FFIOContext bic; int size = mms->write_out_ptr - mms->out_buffer; int len; ffio_init_context(&bic, mms->write_out_ptr, sizeof(mms->out_buffer) - size, 1, NULL, NULL, NULL, NULL); - len = avio_put_str16le(&bic, src); + len = avio_put_str16le(&bic.public, src); if (len < 0) return len; mms->write_out_ptr += len; diff --git a/libavformat/mov.c b/libavformat/mov.c index e95d3d2a90..021102f7e4 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -5177,7 +5177,7 @@ static int mov_read_wide(MOVContext *c, AVIOContext *pb, MOVAtom atom) static int mov_read_cmov(MOVContext *c, AVIOContext *pb, MOVAtom atom) { #if CONFIG_ZLIB - AVIOContext ctx; + FFIOContext ctx; uint8_t *cmov_data; uint8_t *moov_data; /* uncompressed data */ long cmov_len, moov_len; @@ -5211,12 +5211,11 @@ static int mov_read_cmov(MOVContext *c, AVIOContext *pb, MOVAtom atom) ret = AVERROR_INVALIDDATA; if (uncompress (moov_data, (uLongf *) &moov_len, (const Bytef *)cmov_data, cmov_len) != Z_OK) goto free_and_return; - if (ffio_init_context(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL, NULL) != 0) - goto free_and_return; - ctx.seekable = AVIO_SEEKABLE_NORMAL; + ffio_init_context(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL, NULL); + ctx.public.seekable = AVIO_SEEKABLE_NORMAL; atom.type = MKTAG('m','o','o','v'); atom.size = moov_len; - ret = mov_read_default(c, &ctx, atom); + ret = mov_read_default(c, &ctx.public, atom); free_and_return: av_free(moov_data); av_free(cmov_data); diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index 0402700445..97b51d0f6a 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -380,7 +380,7 @@ static int mp3_read_header(AVFormatContext *s) // lcm of all mp3 sample rates avpriv_set_pts_info(st, 64, 1, 14112000); - s->pb->maxsize = -1; + ((FFIOContext*)s->pb)->maxsize = -1; off = avio_tell(s->pb); if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index a02965bacf..27b127f7ba 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -1427,7 +1427,7 @@ static PESContext *add_pes_stream(MpegTSContext *ts, int pid, int pcr_pid) #define MAX_LEVEL 4 typedef struct MP4DescrParseContext { AVFormatContext *s; - AVIOContext pb; + FFIOContext pb; Mp4Descr *descr; Mp4Descr *active_descr; int descr_count; @@ -1440,13 +1440,11 @@ static int init_MP4DescrParseContext(MP4DescrParseContext *d, AVFormatContext *s const uint8_t *buf, unsigned size, Mp4Descr *descr, int max_descr_count) { - int ret; if (size > (1 << 30)) return AVERROR_INVALIDDATA; - if ((ret = ffio_init_context(&d->pb, (unsigned char *)buf, size, 0, - NULL, NULL, NULL, NULL)) < 0) - return ret; + ffio_init_context(&d->pb, (unsigned char *)buf, size, + 0, NULL, NULL, NULL, NULL); d->s = s; d->level = 0; @@ -1474,20 +1472,21 @@ static int parse_mp4_descr_arr(MP4DescrParseContext *d, int64_t off, int len) int ret = parse_mp4_descr(d, off, len, 0); if (ret < 0) return ret; - update_offsets(&d->pb, &off, &len); + update_offsets(&d->pb.public, &off, &len); } return 0; } static int parse_MP4IODescrTag(MP4DescrParseContext *d, int64_t off, int len) { - avio_rb16(&d->pb); // ID - avio_r8(&d->pb); - avio_r8(&d->pb); - avio_r8(&d->pb); - avio_r8(&d->pb); - avio_r8(&d->pb); - update_offsets(&d->pb, &off, &len); + AVIOContext *const pb = &d->pb.public; + avio_rb16(pb); // ID + avio_r8(pb); + avio_r8(pb); + avio_r8(pb); + avio_r8(pb); + avio_r8(pb); + update_offsets(pb, &off, &len); return parse_mp4_descr_arr(d, off, len); } @@ -1496,9 +1495,9 @@ static int parse_MP4ODescrTag(MP4DescrParseContext *d, int64_t off, int len) int id_flags; if (len < 2) return 0; - id_flags = avio_rb16(&d->pb); + id_flags = avio_rb16(&d->pb.public); if (!(id_flags & 0x0020)) { // URL_Flag - update_offsets(&d->pb, &off, &len); + update_offsets(&d->pb.public, &off, &len); return parse_mp4_descr_arr(d, off, len); // ES_Descriptor[] } else { return 0; @@ -1507,19 +1506,20 @@ static int parse_MP4ODescrTag(MP4DescrParseContext *d, int64_t off, int len) static int parse_MP4ESDescrTag(MP4DescrParseContext *d, int64_t off, int len) { + AVIOContext *const pb = &d->pb.public; int es_id = 0; int ret = 0; if (d->descr_count >= d->max_descr_count) return AVERROR_INVALIDDATA; - ff_mp4_parse_es_descr(&d->pb, &es_id); + ff_mp4_parse_es_descr(pb, &es_id); d->active_descr = d->descr + (d->descr_count++); d->active_descr->es_id = es_id; - update_offsets(&d->pb, &off, &len); + update_offsets(pb, &off, &len); if ((ret = parse_mp4_descr(d, off, len, MP4DecConfigDescrTag)) < 0) return ret; - update_offsets(&d->pb, &off, &len); + update_offsets(pb, &off, &len); if (len > 0) ret = parse_mp4_descr(d, off, len, MP4SLDescrTag); d->active_descr = NULL; @@ -1536,42 +1536,43 @@ static int parse_MP4DecConfigDescrTag(MP4DescrParseContext *d, int64_t off, if (!descr->dec_config_descr) return AVERROR(ENOMEM); descr->dec_config_descr_len = len; - avio_read(&d->pb, descr->dec_config_descr, len); + avio_read(&d->pb.public, descr->dec_config_descr, len); return 0; } static int parse_MP4SLDescrTag(MP4DescrParseContext *d, int64_t off, int len) { Mp4Descr *descr = d->active_descr; + AVIOContext *const pb = &d->pb.public; int predefined; if (!descr) return AVERROR_INVALIDDATA; #define R8_CHECK_CLIP_MAX(dst, maxv) do { \ - descr->sl.dst = avio_r8(&d->pb); \ + descr->sl.dst = avio_r8(pb); \ if (descr->sl.dst > maxv) { \ descr->sl.dst = maxv; \ return AVERROR_INVALIDDATA; \ } \ } while (0) - predefined = avio_r8(&d->pb); + predefined = avio_r8(pb); if (!predefined) { int lengths; - int flags = avio_r8(&d->pb); + int flags = avio_r8(pb); descr->sl.use_au_start = !!(flags & 0x80); descr->sl.use_au_end = !!(flags & 0x40); descr->sl.use_rand_acc_pt = !!(flags & 0x20); descr->sl.use_padding = !!(flags & 0x08); descr->sl.use_timestamps = !!(flags & 0x04); descr->sl.use_idle = !!(flags & 0x02); - descr->sl.timestamp_res = avio_rb32(&d->pb); - avio_rb32(&d->pb); + descr->sl.timestamp_res = avio_rb32(pb); + avio_rb32(pb); R8_CHECK_CLIP_MAX(timestamp_len, 63); R8_CHECK_CLIP_MAX(ocr_len, 63); R8_CHECK_CLIP_MAX(au_len, 31); - descr->sl.inst_bitrate_len = avio_r8(&d->pb); - lengths = avio_rb16(&d->pb); + descr->sl.inst_bitrate_len = avio_r8(pb); + lengths = avio_rb16(pb); descr->sl.degr_prior_len = lengths >> 12; descr->sl.au_seq_num_len = (lengths >> 7) & 0x1f; descr->sl.packet_seq_num_len = (lengths >> 2) & 0x1f; @@ -1586,10 +1587,11 @@ static int parse_mp4_descr(MP4DescrParseContext *d, int64_t off, int len, int target_tag) { int tag; - int len1 = ff_mp4_read_descr(d->s, &d->pb, &tag); + AVIOContext *const pb = &d->pb.public; + int len1 = ff_mp4_read_descr(d->s, pb, &tag); int ret = 0; - update_offsets(&d->pb, &off, &len); + update_offsets(pb, &off, &len); if (len < 0 || len1 > len || len1 <= 0) { av_log(d->s, AV_LOG_ERROR, "Tag %x length violation new length %d bytes remaining %d\n", @@ -1631,7 +1633,7 @@ static int parse_mp4_descr(MP4DescrParseContext *d, int64_t off, int len, done: d->level--; - avio_seek(&d->pb, off + len1, SEEK_SET); + avio_seek(pb, off + len1, SEEK_SET); return ret; } @@ -1645,7 +1647,7 @@ static int mp4_read_iods(AVFormatContext *s, const uint8_t *buf, unsigned size, if (ret < 0) return ret; - ret = parse_mp4_descr(&d, avio_tell(&d.pb), size, MP4IODescrTag); + ret = parse_mp4_descr(&d, avio_tell(&d.pb.public), size, MP4IODescrTag); *descr_count = d.descr_count; return ret; @@ -1661,7 +1663,7 @@ static int mp4_read_od(AVFormatContext *s, const uint8_t *buf, unsigned size, if (ret < 0) return ret; - ret = parse_mp4_descr_arr(&d, avio_tell(&d.pb), size); + ret = parse_mp4_descr_arr(&d, avio_tell(&d.pb.public), size); *descr_count = d.descr_count; return ret; @@ -1674,7 +1676,6 @@ static void m4sl_cb(MpegTSFilter *filter, const uint8_t *section, MpegTSSectionFilter *tssf = &filter->u.section_filter; SectionHeader h; const uint8_t *p, *p_end; - AVIOContext pb; int mp4_descr_count = 0; Mp4Descr mp4_descr[MAX_MP4_DESCR_COUNT] = { { 0 } }; int i, pid; @@ -1698,6 +1699,7 @@ static void m4sl_cb(MpegTSFilter *filter, const uint8_t *section, for (i = 0; i < mp4_descr_count; i++) { PESContext *pes; AVStream *st; + FFIOContext pb; if (ts->pids[pid]->es_id != mp4_descr[i].es_id) continue; if (ts->pids[pid]->type != MPEGTS_PES) { @@ -1714,7 +1716,7 @@ static void m4sl_cb(MpegTSFilter *filter, const uint8_t *section, ffio_init_context(&pb, mp4_descr[i].dec_config_descr, mp4_descr[i].dec_config_descr_len, 0, NULL, NULL, NULL, NULL); - ff_mp4_read_dec_config_descr(s, st, &pb); + ff_mp4_read_dec_config_descr(s, st, &pb.public); if (st->codecpar->codec_id == AV_CODEC_ID_AAC && st->codecpar->extradata_size > 0) st->internal->need_parsing = 0; @@ -1819,11 +1821,11 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type for (i = 0; i < mp4_descr_count; i++) if (mp4_descr[i].dec_config_descr_len && mp4_descr[i].es_id == desc_es_id) { - AVIOContext pb; + FFIOContext pb; ffio_init_context(&pb, mp4_descr[i].dec_config_descr, mp4_descr[i].dec_config_descr_len, 0, NULL, NULL, NULL, NULL); - ff_mp4_read_dec_config_descr(fc, st, &pb); + ff_mp4_read_dec_config_descr(fc, st, &pb.public); if (st->codecpar->codec_id == AV_CODEC_ID_AAC && st->codecpar->extradata_size > 0) { st->internal->need_parsing = 0; @@ -1841,11 +1843,11 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type (st->internal->request_probe == 0 && st->codecpar->codec_id == AV_CODEC_ID_NONE) || st->internal->request_probe > 0) && mp4_descr->dec_config_descr_len && mp4_descr->es_id == pid) { - AVIOContext pb; + FFIOContext pb; ffio_init_context(&pb, mp4_descr->dec_config_descr, mp4_descr->dec_config_descr_len, 0, NULL, NULL, NULL, NULL); - ff_mp4_read_dec_config_descr(fc, st, &pb); + ff_mp4_read_dec_config_descr(fc, st, &pb.public); if (st->codecpar->codec_id == AV_CODEC_ID_AAC && st->codecpar->extradata_size > 0) { st->internal->request_probe = st->internal->need_parsing = 0; diff --git a/libavformat/mpjpegdec.c b/libavformat/mpjpegdec.c index 28a24184a2..7c0d6d016c 100644 --- a/libavformat/mpjpegdec.c +++ b/libavformat/mpjpegdec.c @@ -113,7 +113,7 @@ static int mpjpeg_read_close(AVFormatContext *s) static int mpjpeg_read_probe(const AVProbeData *p) { - AVIOContext pb; + FFIOContext pb; int ret = 0; int size = 0; @@ -122,7 +122,7 @@ static int mpjpeg_read_probe(const AVProbeData *p) ffio_init_context(&pb, p->buf, p->buf_size, 0, NULL, NULL, NULL, NULL); - ret = (parse_multipart_header(&pb, &size, "--", NULL) >= 0) ? AVPROBE_SCORE_MAX : 0; + ret = (parse_multipart_header(&pb.public, &size, "--", NULL) >= 0) ? AVPROBE_SCORE_MAX : 0; return ret; } diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c index aff0ca6b96..4d15a116d3 100644 --- a/libavformat/oggenc.c +++ b/libavformat/oggenc.c @@ -275,7 +275,7 @@ static uint8_t *ogg_write_vorbiscomment(int64_t offset, int bitexact, AVChapter **chapters, unsigned int nb_chapters) { const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT; - AVIOContext pb; + FFIOContext pb; int64_t size; uint8_t *p; @@ -289,9 +289,9 @@ static uint8_t *ogg_write_vorbiscomment(int64_t offset, int bitexact, return NULL; ffio_init_context(&pb, p + offset, size - offset, 1, NULL, NULL, NULL, NULL); - ff_vorbiscomment_write(&pb, *m, vendor, chapters, nb_chapters); + ff_vorbiscomment_write(&pb.public, *m, vendor, chapters, nb_chapters); if (framing_bit) - avio_w8(&pb, 1); + avio_w8(&pb.public, 1); *header_len = size; return p; diff --git a/libavformat/rdt.c b/libavformat/rdt.c index da55503ea6..56450403a1 100644 --- a/libavformat/rdt.c +++ b/libavformat/rdt.c @@ -131,7 +131,8 @@ ff_rdt_calc_response_and_checksum(char response[41], char chksum[9], static int rdt_load_mdpr (PayloadContext *rdt, AVStream *st, int rule_nr) { - AVIOContext pb; + FFIOContext pb0; + AVIOContext *const pb = &pb0.public; unsigned int size; uint32_t tag; @@ -151,32 +152,32 @@ rdt_load_mdpr (PayloadContext *rdt, AVStream *st, int rule_nr) */ if (!rdt->mlti_data) return -1; - ffio_init_context(&pb, rdt->mlti_data, rdt->mlti_data_size, 0, + ffio_init_context(&pb0, rdt->mlti_data, rdt->mlti_data_size, 0, NULL, NULL, NULL, NULL); - tag = avio_rl32(&pb); + tag = avio_rl32(pb); if (tag == MKTAG('M', 'L', 'T', 'I')) { int num, chunk_nr; /* read index of MDPR chunk numbers */ - num = avio_rb16(&pb); + num = avio_rb16(pb); if (rule_nr < 0 || rule_nr >= num) return -1; - avio_skip(&pb, rule_nr * 2); - chunk_nr = avio_rb16(&pb); - avio_skip(&pb, (num - 1 - rule_nr) * 2); + avio_skip(pb, rule_nr * 2); + chunk_nr = avio_rb16(pb); + avio_skip(pb, (num - 1 - rule_nr) * 2); /* read MDPR chunks */ - num = avio_rb16(&pb); + num = avio_rb16(pb); if (chunk_nr >= num) return -1; while (chunk_nr--) - avio_skip(&pb, avio_rb32(&pb)); - size = avio_rb32(&pb); + avio_skip(pb, avio_rb32(pb)); + size = avio_rb32(pb); } else { size = rdt->mlti_data_size; - avio_seek(&pb, 0, SEEK_SET); + avio_seek(pb, 0, SEEK_SET); } - if (ff_rm_read_mdpr_codecdata(rdt->rmctx, &pb, st, rdt->rmst[st->index], size, NULL) < 0) + if (ff_rm_read_mdpr_codecdata(rdt->rmctx, pb, st, rdt->rmst[st->index], size, NULL) < 0) return -1; return 0; @@ -296,16 +297,16 @@ rdt_parse_packet (AVFormatContext *ctx, PayloadContext *rdt, AVStream *st, const uint8_t *buf, int len, uint16_t rtp_seq, int flags) { int seq = 1, res; - AVIOContext pb; if (rdt->audio_pkt_cnt == 0) { + FFIOContext pb; int pos, rmflags; ffio_init_context(&pb, (uint8_t *)buf, len, 0, NULL, NULL, NULL, NULL); rmflags = (flags & RTP_FLAG_KEY) ? 2 : 0; - res = ff_rm_parse_packet (rdt->rmctx, &pb, st, rdt->rmst[st->index], len, pkt, - &seq, rmflags, *timestamp); - pos = avio_tell(&pb); + res = ff_rm_parse_packet(rdt->rmctx, &pb.public, st, rdt->rmst[st->index], + len, pkt, &seq, rmflags, *timestamp); + pos = avio_tell(&pb.public); if (res < 0) return res; if (res > 0) { diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c index 3802a57407..1ff1f3de0f 100644 --- a/libavformat/rtpdec_asf.c +++ b/libavformat/rtpdec_asf.c @@ -87,20 +87,20 @@ static int packetizer_read(void *opaque, uint8_t *buf, int buf_size) return AVERROR(EAGAIN); } -static void init_packetizer(AVIOContext *pb, uint8_t *buf, int len) +static void init_packetizer(FFIOContext *pb, uint8_t *buf, int len) { ffio_init_context(pb, buf, len, 0, NULL, packetizer_read, NULL, NULL); /* this "fills" the buffer with its current content */ - pb->pos = len; - pb->buf_end = buf + len; + pb->public.pos = len; + pb->public.buf_end = buf + len; } int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p) { int ret = 0; if (av_strstart(p, "pgmpu:data:application/vnd.ms.wms-hdr.asfv1;base64,", &p)) { - AVIOContext pb = { 0 }; + FFIOContext pb; RTSPState *rt = s->priv_data; AVDictionary *opts = NULL; int len = strlen(p) * 6 / 8; @@ -127,7 +127,7 @@ int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p) av_free(buf); return AVERROR(ENOMEM); } - rt->asf_ctx->pb = &pb; + rt->asf_ctx->pb = &pb.public; av_dict_set(&opts, "no_resync_search", "1", 0); if ((ret = ff_copy_whiteblacklists(rt->asf_ctx, s)) < 0) { @@ -138,12 +138,12 @@ int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p) ret = avformat_open_input(&rt->asf_ctx, "", iformat, &opts); av_dict_free(&opts); if (ret < 0) { - av_free(pb.buffer); + av_free(pb.public.buffer); return ret; } av_dict_copy(&s->metadata, rt->asf_ctx->metadata, 0); - rt->asf_pb_pos = avio_tell(&pb); - av_free(pb.buffer); + rt->asf_pb_pos = avio_tell(&pb.public); + av_free(pb.public.buffer); rt->asf_ctx->pb = NULL; } return ret; @@ -178,7 +178,8 @@ static int asfrtp_parse_sdp_line(AVFormatContext *s, int stream_index, } struct PayloadContext { - AVIOContext *pktbuf, pb; + FFIOContext pb; + AVIOContext *pktbuf; uint8_t *buf; }; @@ -193,7 +194,8 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, const uint8_t *buf, int len, uint16_t seq, int flags) { - AVIOContext *pb = &asf->pb; + FFIOContext *const pb0 = &asf->pb; + AVIOContext *const pb = &pb0->public; int res, mflags, len_off; RTSPState *rt = s->priv_data; @@ -208,7 +210,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, av_freep(&asf->buf); - ffio_init_context(pb, (uint8_t *)buf, len, 0, NULL, NULL, NULL, NULL); + ffio_init_context(pb0, (uint8_t *)buf, len, 0, NULL, NULL, NULL, NULL); while (avio_tell(pb) + 4 < len) { int start_off = avio_tell(pb); @@ -267,7 +269,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, } } - init_packetizer(pb, asf->buf, out_len); + init_packetizer(pb0, asf->buf, out_len); pb->pos += rt->asf_pb_pos; pb->eof_reached = 0; rt->asf_ctx->pb = pb; diff --git a/libavformat/rtpdec_qt.c b/libavformat/rtpdec_qt.c index 492a1b6715..524608ae00 100644 --- a/libavformat/rtpdec_qt.c +++ b/libavformat/rtpdec_qt.c @@ -54,7 +54,8 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt, uint32_t *timestamp, const uint8_t *buf, int len, uint16_t seq, int flags) { - AVIOContext pb; + FFIOContext pb0; + AVIOContext *const pb = &pb0.public; GetBitContext gb; int packing_scheme, has_payload_desc, has_packet_info, alen, has_marker_bit = flags & RTP_FLAG_MARKER, @@ -82,7 +83,7 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt, * http://developer.apple.com/quicktime/icefloe/dispatch026.html */ init_get_bits(&gb, buf, len << 3); - ffio_init_context(&pb, (uint8_t*)buf, len, 0, NULL, NULL, NULL, NULL); + ffio_init_context(&pb0, (uint8_t*)buf, len, 0, NULL, NULL, NULL, NULL); if (len < 4) return AVERROR_INVALIDDATA; @@ -114,22 +115,22 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt, skip_bits(&gb, 12); // reserved data_len = get_bits(&gb, 16); - avio_seek(&pb, pos + 4, SEEK_SET); - tag = avio_rl32(&pb); + avio_seek(pb, pos + 4, SEEK_SET); + tag = avio_rl32(pb); if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && tag != MKTAG('v','i','d','e')) || (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && tag != MKTAG('s','o','u','n'))) return AVERROR_INVALIDDATA; - avpriv_set_pts_info(st, 32, 1, avio_rb32(&pb)); + avpriv_set_pts_info(st, 32, 1, avio_rb32(pb)); if (pos + data_len > len) return AVERROR_INVALIDDATA; /* TLVs */ - while (avio_tell(&pb) + 4 < pos + data_len) { - int tlv_len = avio_rb16(&pb); - tag = avio_rl16(&pb); - if (avio_tell(&pb) + tlv_len > pos + data_len) + while (avio_tell(pb) + 4 < pos + data_len) { + int tlv_len = avio_rb16(pb); + tag = avio_rl16(pb); + if (avio_tell(pb) + tlv_len > pos + data_len) return AVERROR_INVALIDDATA; #define MKTAG16(a,b) MKTAG(a,b,0,0) @@ -151,7 +152,7 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt, /* ff_mov_read_stsd_entries updates stream s->nb_streams-1, * so set it temporarily to indicate which stream to update. */ s->nb_streams = st->index + 1; - ff_mov_read_stsd_entries(mc, &pb, 1); + ff_mov_read_stsd_entries(mc, pb, 1); qt->bytes_per_frame = msc->bytes_per_frame; av_free(msc); av_free(mc); @@ -160,22 +161,22 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt, break; } default: - avio_skip(&pb, tlv_len); + avio_skip(pb, tlv_len); break; } } /* 32-bit alignment */ - avio_skip(&pb, ((avio_tell(&pb) + 3) & ~3) - avio_tell(&pb)); + avio_skip(pb, ((avio_tell(pb) + 3) & ~3) - avio_tell(pb)); } else - avio_seek(&pb, 4, SEEK_SET); + avio_seek(pb, 4, SEEK_SET); if (has_packet_info) { avpriv_request_sample(s, "RTP-X-QT with packet-specific info"); return AVERROR_PATCHWELCOME; } - alen = len - avio_tell(&pb); + alen = len - avio_tell(pb); if (alen <= 0) return AVERROR_INVALIDDATA; @@ -197,7 +198,7 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt, qt->pkt->size = 0; qt->timestamp = *timestamp; } - memcpy(qt->pkt->data + qt->pkt->size, buf + avio_tell(&pb), alen); + memcpy(qt->pkt->data + qt->pkt->size, buf + avio_tell(pb), alen); qt->pkt->size += alen; if (has_marker_bit) { int ret = av_packet_from_data(pkt, qt->pkt->data, qt->pkt->size); @@ -220,7 +221,7 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt, qt->remaining = (alen / qt->bytes_per_frame) - 1; if ((ret = av_new_packet(pkt, qt->bytes_per_frame)) < 0) return ret; - memcpy(pkt->data, buf + avio_tell(&pb), qt->bytes_per_frame); + memcpy(pkt->data, buf + avio_tell(pb), qt->bytes_per_frame); pkt->flags = keyframe ? AV_PKT_FLAG_KEY : 0; pkt->stream_index = st->index; if (qt->remaining > 0) { @@ -232,7 +233,7 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt, } qt->pkt->size = qt->remaining * qt->bytes_per_frame; memcpy(qt->pkt->data, - buf + avio_tell(&pb) + qt->bytes_per_frame, + buf + avio_tell(pb) + qt->bytes_per_frame, qt->remaining * qt->bytes_per_frame); qt->pkt->flags = pkt->flags; return 1; diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 9869e1b72e..a7eb8da2f9 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -2496,7 +2496,7 @@ static int rtp_read_header(AVFormatContext *s) int payload_type; AVCodecParameters *par = NULL; struct sockaddr_storage addr; - AVIOContext pb; + FFIOContext pb; socklen_t addrlen = sizeof(addr); RTSPState *rt = s->priv_data; const char *p; @@ -2594,7 +2594,7 @@ static int rtp_read_header(AVFormatContext *s) avcodec_parameters_free(&par); ffio_init_context(&pb, sdp.str, sdp.len, 0, NULL, NULL, NULL, NULL); - s->pb = &pb; + s->pb = &pb.public; /* if sdp_read_header() fails then following ff_network_close() cancels out */ /* ff_network_init() at the start of this function. Otherwise it cancels out */ diff --git a/libavformat/sapdec.c b/libavformat/sapdec.c index a852b0782b..1ca4836ff6 100644 --- a/libavformat/sapdec.c +++ b/libavformat/sapdec.c @@ -35,7 +35,7 @@ struct SAPState { URLContext *ann_fd; AVFormatContext *sdp_ctx; - AVIOContext sdp_pb; + FFIOContext sdp_pb; uint16_t hash; char *sdp; int eof; @@ -160,7 +160,7 @@ static int sap_read_header(AVFormatContext *s) goto fail; } sap->sdp_ctx->max_delay = s->max_delay; - sap->sdp_ctx->pb = &sap->sdp_pb; + sap->sdp_ctx->pb = &sap->sdp_pb.public; sap->sdp_ctx->interrupt_callback = s->interrupt_callback; if ((ret = ff_copy_whiteblacklists(sap->sdp_ctx, s)) < 0) diff --git a/libavformat/subtitles.c b/libavformat/subtitles.c index f80a439bcc..fbf37c0cf1 100644 --- a/libavformat/subtitles.c +++ b/libavformat/subtitles.c @@ -51,9 +51,8 @@ void ff_text_init_avio(void *s, FFTextReader *r, AVIOContext *pb) void ff_text_init_buf(FFTextReader *r, void *buf, size_t size) { - memset(&r->buf_pb, 0, sizeof(r->buf_pb)); ffio_init_context(&r->buf_pb, buf, size, 0, NULL, NULL, NULL, NULL); - ff_text_init_avio(NULL, r, &r->buf_pb); + ff_text_init_avio(NULL, r, &r->buf_pb.public); } int64_t ff_text_pos(FFTextReader *r) diff --git a/libavformat/subtitles.h b/libavformat/subtitles.h index 37ca7b19b1..4460efacf3 100644 --- a/libavformat/subtitles.h +++ b/libavformat/subtitles.h @@ -25,6 +25,7 @@ #include #include "avformat.h" #include "libavutil/bprint.h" +#include "avio_internal.h" enum sub_sort { SUB_SORT_TS_POS = 0, ///< sort by timestamps, then position @@ -42,7 +43,7 @@ typedef struct { AVIOContext *pb; unsigned char buf[8]; int buf_pos, buf_len; - AVIOContext buf_pb; + FFIOContext buf_pb; } FFTextReader; /** diff --git a/libavformat/thp.c b/libavformat/thp.c index 7aad24221b..d5d91a9f23 100644 --- a/libavformat/thp.c +++ b/libavformat/thp.c @@ -22,6 +22,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/intfloat.h" #include "avformat.h" +#include "avio_internal.h" #include "internal.h" typedef struct ThpDemuxContext { @@ -65,6 +66,7 @@ static int thp_read_header(AVFormatContext *s) AVStream *st; AVIOContext *pb = s->pb; int64_t fsize= avio_size(pb); + uint32_t maxsize; int i; /* Read the file header. */ @@ -79,9 +81,10 @@ static int thp_read_header(AVFormatContext *s) return AVERROR_INVALIDDATA; thp->framecnt = avio_rb32(pb); thp->first_framesz = avio_rb32(pb); - pb->maxsize = avio_rb32(pb); - if(fsize>0 && (!pb->maxsize || fsize < pb->maxsize)) - pb->maxsize= fsize; + maxsize = avio_rb32(pb); + if (fsize > 0 && (!maxsize || fsize < maxsize)) + maxsize = fsize; + ((FFIOContext*)pb)->maxsize = fsize; thp->compoff = avio_rb32(pb); avio_rb32(pb); /* offsetDataOffset. */ diff --git a/libavformat/utils.c b/libavformat/utils.c index 8d1b76f590..d2c306a008 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -230,7 +230,7 @@ static int append_packet_chunked(AVIOContext *s, AVPacket *pkt, int size) if (read_size > SANE_CHUNK_SIZE/10) { read_size = ffio_limit(s, read_size); // If filesize/maxsize is unknown, limit to SANE_CHUNK_SIZE - if (s->maxsize < 0) + if (((FFIOContext*)s)->maxsize < 0) read_size = FFMIN(read_size, SANE_CHUNK_SIZE); } @@ -1972,6 +1972,7 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance) int64_t skip = 0; //We could use URLProtocol flags here but as many user applications do not use URLProtocols this would be unreliable const char *proto = avio_find_protocol_name(s->url); + FFIOContext *ctx; av_assert0(time_tolerance >= 0); @@ -2012,6 +2013,7 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance) } pos_delta *= 2; + ctx = (FFIOContext*)s->pb; /* XXX This could be adjusted depending on protocol*/ if (s->pb->buffer_size < pos_delta && pos_delta < (1<<24)) { av_log(s, AV_LOG_VERBOSE, "Reconfiguring buffers to size %"PRId64"\n", pos_delta); @@ -2022,11 +2024,11 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance) return; } - s->pb->short_seek_threshold = FFMAX(s->pb->short_seek_threshold, pos_delta/2); + ctx->short_seek_threshold = FFMAX(ctx->short_seek_threshold, pos_delta/2); } if (skip < (1<<23)) { - s->pb->short_seek_threshold = FFMAX(s->pb->short_seek_threshold, skip); + ctx->short_seek_threshold = FFMAX(ctx->short_seek_threshold, skip); } } @@ -3553,9 +3555,11 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) max_stream_analyze_duration = 7*AV_TIME_BASE; } - if (ic->pb) + if (ic->pb) { + FFIOContext *const ctx = (FFIOContext*)ic->pb; av_log(ic, AV_LOG_DEBUG, "Before avformat_find_stream_info() pos: %"PRId64" bytes read:%"PRId64" seeks:%d nb_streams:%d\n", - avio_tell(ic->pb), ic->pb->bytes_read, ic->pb->seek_count, ic->nb_streams); + avio_tell(ic->pb), ctx->bytes_read, ctx->seek_count, ic->nb_streams); + } for (i = 0; i < ic->nb_streams; i++) { const AVCodec *codec; @@ -4066,9 +4070,11 @@ find_stream_info_err: av_freep(&ic->streams[i]->internal->info); av_bsf_free(&ic->streams[i]->internal->extract_extradata.bsf); } - if (ic->pb) + if (ic->pb) { + FFIOContext *const ctx = (FFIOContext*)ic->pb; av_log(ic, AV_LOG_DEBUG, "After avformat_find_stream_info() pos: %"PRId64" bytes read:%"PRId64" seeks:%d frames:%d\n", - avio_tell(ic->pb), ic->pb->bytes_read, ic->pb->seek_count, count); + avio_tell(ic->pb), ctx->bytes_read, ctx->seek_count, count); + } return ret; unref_then_goto_end: diff --git a/libavformat/vividas.c b/libavformat/vividas.c index 8d1c1dab29..99e2bfa911 100644 --- a/libavformat/vividas.c +++ b/libavformat/vividas.c @@ -283,9 +283,10 @@ static int track_header(VividasDemuxContext *viv, AVFormatContext *s, uint8_t * int64_t off; int val_1; int num_video; - AVIOContext pb0, *pb = &pb0; + FFIOContext pb0; + AVIOContext *const pb = &pb0.public; - ffio_init_context(pb, buf, size, 0, NULL, NULL, NULL, NULL); + ffio_init_context(&pb0, buf, size, 0, NULL, NULL, NULL, NULL); ffio_read_varlen(pb); // track_header_len avio_r8(pb); // '1' @@ -436,12 +437,13 @@ static int track_index(VividasDemuxContext *viv, AVFormatContext *s, uint8_t *bu int64_t off; int64_t poff; int maxnp=0; - AVIOContext pb0, *pb = &pb0; + FFIOContext pb0; + AVIOContext *const pb = &pb0.public; int i; int64_t filesize = avio_size(s->pb); uint64_t n_sb_blocks_tmp; - ffio_init_context(pb, buf, size, 0, NULL, NULL, NULL, NULL); + ffio_init_context(&pb0, buf, size, 0, NULL, NULL, NULL, NULL); ffio_read_varlen(pb); // track_index_len avio_r8(pb); // 'c' From patchwork Thu Aug 5 05:42:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 29259 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6c0f:0:0:0:0:0 with SMTP id a15csp97118ioh; Wed, 4 Aug 2021 22:43:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlgQl7SWEnxL8joeEVfa4AP5bJoxNP2J29zH2MhrN+AC670WpAZ8kxbvbpQkbcniK0FoGI X-Received: by 2002:a17:906:94cd:: with SMTP id d13mr3157356ejy.158.1628142234085; Wed, 04 Aug 2021 22:43:54 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h14si4313069ejt.392.2021.08.04.22.43.52; Wed, 04 Aug 2021 22:43:54 -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=@outlook.com header.s=selector1 header.b=H3iTxMVb; arc=fail (body hash mismatch); 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1FD2568A1BB; Thu, 5 Aug 2021 08:43:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074106.outbound.protection.outlook.com [40.92.74.106]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 221A468A21C for ; Thu, 5 Aug 2021 08:43:17 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ePmWgAulAPn2wJQktYrDrVggGjfXU6SzIIEJJFKuWW6G0OIiAzBW29pCm029ll0IwGeJ/9AJOQ0gIHdcxmX61OIt7ljCblbd9cQFCaOsEo2VRHRIr3ud/ad++NO1bP//YFsY6USR02WBoteXnhGhJB8+fB3TC0XfSo7PjPsU6g7HT5vs3wXbHoIOnLAbB0viqi7dOOqLy1OqAkOWaOOHgywbz7neeCtGq3pQQcLqtrTrR5ygykhiYrIGaOedzfyPwC3Fdr3dxQ4hCTDAYzjnhZXO43rRuF5mFT2QQKvmUYxzHRwmGHD2sj6EayhmYGFALlErRIxvw3KyShgWx9bktg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YT4MeeWxVJVP7FXAdGiQtcF8+XnG2x20Z2V9UalP9Uw=; b=Hv/yUUa+W17i6QcDEwIRKw1Mytl31WATQ5r7sFmWVe3yR3DIwW2fntgzNFVz9RgSJVtenqaX+DdXFWH38MG83VYaIqUCvbCQZqWKQ4upQ/uWlMgWaPuhRar5cS3zyLhD3f2gkcOn+gpBYqrgBIJqLG8az1iKZ9hXD7X4akxEWdcBgj8GGBq3xJJK3VDxKATInayu5x34/ddK1b6u3Wgx2+j6lpAKDEaTLokcqtPAn2Amv6y9mxHm3ed4iID0GJ8Jy+4fHWTtA9HoiMZdybpZ1ycLqTqlsHrya9EGQXJE/pwRdBMzK00nwX6gdzB56mmQ/dbNCdVPOn5+0DsUOx5ODg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YT4MeeWxVJVP7FXAdGiQtcF8+XnG2x20Z2V9UalP9Uw=; b=H3iTxMVbhoaGAtUHBd3feu29MmheVgA6VVEmPOIAjrOQ4ZVUachkCEli7m/l2iikG+7WnsqSqzus5JYDFG/asy3r1pO3iWz4mhxCQprRjGwPUZtw+7KaXrFbsFOPr8pCkhwAkFRYXWA+X1lNttjz4tUgrZ/uNQarGSkCmsYgVroGeRodgBKfyp5lRBHkEqQ0EVVj1Rzk47NsKswsCKQFP+b3/0vdFhuJLqy2j3t3tPxvVSbo4M8zVjmPKEtXMl4sI3+KgjS5lO+IAlGFM3hA21qj0DIwy4uzv+t1xJ0h0ax/ewYEMNERcXjAhPJibwlUCiWjt93GhQKnNHMCqmzYrw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AS8PR03MB6888.eurprd03.prod.outlook.com (2603:10a6:20b:294::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Thu, 5 Aug 2021 05:43:16 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::c9b2:14f8:d555:6f2d]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::c9b2:14f8:d555:6f2d%8]) with mapi id 15.20.4373.026; Thu, 5 Aug 2021 05:43:16 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Aug 2021 07:42:41 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: X-TMN: [8G3hRmLPdWAKdSuBQtzJwYujGrffAtmT] X-ClientProxiedBy: AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20210805054244.2094251-5-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.94.230) by AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Thu, 5 Aug 2021 05:43:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1827076b-f4e2-44a8-8937-08d957d3ec4d X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiTzvpWxvWYRCiBlmWjUmirgXAI032YyguFEAtWipCIawfa3fixa1rP/mTFP9RrRXkXdVwYP+gKcFluLAOOYfhaBXucA0sx7D2/GtLZ/Gh+cDvAKGkqKFv8jcc7+AYRuD7EVVW/vYZDXqqeMZGfdHcQ6yvdgi+9SnxAuNCXmE/jqQ4BpU8IrtMOptAViEJuR7uAEjMN5ZVWPu0CYfi9apY0u31tzgKBQOEjmPZUoKF8pjTms8CfQCgAgeU4jxLWqv7+dpJ5o4jo7izPBZMBHC9oYzR/3C0C7cjglH/woEJLTxYgdwuHYj2LkrY6YmOR34z+skPAMi1iz8EwDN8pyzCxwy+Lbzs9RwzFJMlOlZSiwgoFGxTwFqRBV3KCjA+s3mFwkD8SjSKDb48F4jplUQR813e1CV6FzI/tCermIVG8a1U4nD1+knQzexUjueRsMl9t98EcROIfN2sRWbfN5zg5lJdcSWSXWdKWnQUZJMH/MppSbZCJmTIMbLqoE9xfu1UX+i1exl19ZgySFUZJ6ox51TaoRCludQKeCGlddZFX899mHbrGYDSKLy8T0iZ92JupgFsZ83TRhrCEeBHY/BFTS60IsnLYqdHWMXiZ2sYudmhWnwdA7DKNXD/vG9d2mliUZ2sk38fhjr1C6aubs1PhOGK/d6h/WsQA3WAMlwPmgHud8N5jUoCsY2lm7SVcDw4pQFNlVip1KBZbB7u7VG52+JszTs7k3OupxShglx9upfJYziwHhKsML4lxmnl5pRkE= X-MS-TrafficTypeDiagnostic: AS8PR03MB6888: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F7zWApXKTawukaTLfZxoJf1rnxcX/SxRz4PmlmXRkH5NxN2c1krfeFxVaHYIa9lmxrnlRC+SQZSzVWhU7sQYkgdAX4iws+vl2yzNV7QefiZaFS+KYpLp2qBsoKgKUaEFLV90JEQ2bn3tXB7jB8OtzSKlfHMey9mR4Ps36d74WUyaFWlKU6abW24sdmi17t6ZELx5RpS/Ro/xPLXngHtpZLPHef/ckKOJhv0AEY9V03loBkNSV79twP5445s+7XAz7nT0rBF6xsZo5TOr9qsYQnxGXc2FEMGrzeNXRNHFKqLL3YNP8hd9i5ymWLP4ui9slRym9I/lhwrrhi+5wlA4Z4oiQNVOoJjxobjlumJv/MVgeoUeS2vLCgGkhmb9W6zs8luAjSXVdEmzdy/D5LdR/fjAotwOpU4or1fvriVnUPdw9+gqlBTQ70/WhyJZ/iU8 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: spAr2HPk8B9ZOx53z+7jRa/9QO9uLwFPUtxcp1ERK8G33t4Mrmk1yWgL22Lp5LPGAp/Vu5akvBU4daf8uSiOIu7uM0IsXO3rsLZxn2lwusJy06Dd6mTa+RrnnTlNNxmEnDKj4Gog+SIOv0h/GVUHhA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1827076b-f4e2-44a8-8937-08d957d3ec4d X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2021 05:43:16.5907 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB6888 Subject: [FFmpeg-devel] [PATCH 6/9] avformat/aviobuf: Avoid allocation when using dynamic buffer 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: zvdj70iDRnoS This can be achieved by allocating the AVIOContext and the dynamic buffer's opaque and internal write buffer together. Signed-off-by: Andreas Rheinhardt --- libavformat/aviobuf.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index f04e15f4f1..a883a75380 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -1377,22 +1377,21 @@ static int64_t dyn_buf_seek(void *opaque, int64_t offset, int whence) static int url_open_dyn_buf_internal(AVIOContext **s, int max_packet_size) { + struct { FFIOContext pb; DynBuffer d; } *ret; DynBuffer *d; unsigned io_buffer_size = max_packet_size ? max_packet_size : 1024; - if (sizeof(DynBuffer) + io_buffer_size < io_buffer_size) + if (sizeof(*ret) + io_buffer_size < io_buffer_size) return AVERROR(ERANGE); - d = av_mallocz(sizeof(DynBuffer) + io_buffer_size); - if (!d) + ret = av_mallocz(sizeof(*ret) + io_buffer_size); + if (!ret) return AVERROR(ENOMEM); + d = &ret->d; d->io_buffer_size = io_buffer_size; - *s = avio_alloc_context(d->io_buffer, d->io_buffer_size, 1, d, NULL, - max_packet_size ? dyn_packet_buf_write : dyn_buf_write, - max_packet_size ? NULL : dyn_buf_seek); - if(!*s) { - av_free(d); - return AVERROR(ENOMEM); - } + ffio_init_context(&ret->pb, d->io_buffer, d->io_buffer_size, 1, d, NULL, + max_packet_size ? dyn_packet_buf_write : dyn_buf_write, + max_packet_size ? NULL : dyn_buf_seek); + *s = &ret->pb.public; (*s)->max_packet_size = max_packet_size; return 0; } @@ -1465,7 +1464,6 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) d = s->opaque; *pbuffer = d->buffer; size = d->size; - av_free(d); avio_context_free(&s); @@ -1481,7 +1479,6 @@ void ffio_free_dyn_buf(AVIOContext **s) d = (*s)->opaque; av_free(d->buffer); - av_free(d); avio_context_free(s); } @@ -1513,7 +1510,6 @@ int ffio_close_null_buf(AVIOContext *s) avio_flush(s); size = d->size; - av_free(d); avio_context_free(&s); From patchwork Thu Aug 5 05:42:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 29261 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6c0f:0:0:0:0:0 with SMTP id a15csp97205ioh; Wed, 4 Aug 2021 22:44:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJaSMXXa704vPlV1Sv+5Rsg5uFt2PGS4dOlf/yjwt6PMjpawNCmfdo8fh3O7A9h0pzYCoi X-Received: by 2002:a50:f1c7:: with SMTP id y7mr4229324edl.386.1628142244114; Wed, 04 Aug 2021 22:44:04 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b7si4533902edd.421.2021.08.04.22.44.03; Wed, 04 Aug 2021 22:44:04 -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=@outlook.com header.s=selector1 header.b=pn0bE3w7; arc=fail (body hash mismatch); 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F004868A2F4; Thu, 5 Aug 2021 08:43:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074039.outbound.protection.outlook.com [40.92.74.39]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5802568A33F for ; Thu, 5 Aug 2021 08:43:18 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hdpiIDf3nd6G2hVTHRIACA/bS5ZFtQFZfrpauXWsElgODgIcNDCxojIaejHxo1EdylTkyl9w68VfA8WK9ak+q64MSYH8wtTy4tkcFr3rcjvC5u+ZGXxPi/4aIVPOiHutFBwwJQqvx1wL+EvATs4S7H6QPYFsXVEPsnKDiTrVyM6eVBvck8mPXAk6hiD5N06jidjP+HMP8rSmzKQe2kzC4PhIRHqasHXRV9xCwhWrYFKRbyamh4/Q2UaTRx3cZqz8NBBPdAxewuwdoe+g+FpmWpNXixxnj7bnY7EWfW3eSY9vOm0rU0hohsLJNQKqcQyJ37hODDLXGp5BcjHct6EugQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0xw69DoBrLgoGtm6C6DsdWwUIKQoJzRF/S1xdCRcNjU=; b=AhU2zOh/EjGKyyvgNy7AIfw6ODqjFw6SHB7kXAG+UT9kv2i5oLrVVWM4Db/J4TDY+zBi1K95fNFfUU7NlzC9qoUbUaEcPhdGSBHK8flpNy+5GvYGrDjyJSYPfybNR1qzMpuxPg+suUrIbRwmY9Phia/IqU+2zcaxuvkWAbELySUlPle+XkmYm8WFvVhMVMKaGtDD6GSlFd8xiWBCAwRtO1n/CEVRmhCBjgE1BoVcUnXvRxa7BXlY0WTXSsFUToZOt4u9tDeFp/o40t2qivt42t+zSQg0EZXBUsntVyvWlqixt1iFi59wegflHNETP67XEJbUWkuOKvG6DjdjbfZmfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0xw69DoBrLgoGtm6C6DsdWwUIKQoJzRF/S1xdCRcNjU=; b=pn0bE3w75tp4TVHHdmIo7t3MUpuiXmW7ptkw045j9sMvdjMthNtrRY0S+Vg5OMbYCVFsjTb4wncE7Fl2xX8f7uQMwE3mBEU/xpIxw2k08gEg6Aq0UMHfl1KzEEtOR1lNunbFk6ngnvwYcW7u6LGX0dLs/jtm8j8u45eyHcfAO6wBm9ZAfF1ANwfiUg1TpSa/1OVudMjaCK6Fj/kxgQ0rUFHbg6b4w93S7nivFMmL1zvMGBRUHz1Wo9MFBf4DDJpW/3EvTwQ9biLuzQYVBLKdCgFfAMDKTbwiC1cXZCuB4z0sXY8OiM8Ra0iQN+y22eBkVtbuW8dyp19TlE6B87uhKA== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AS8PR03MB6888.eurprd03.prod.outlook.com (2603:10a6:20b:294::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Thu, 5 Aug 2021 05:43:17 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::c9b2:14f8:d555:6f2d]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::c9b2:14f8:d555:6f2d%8]) with mapi id 15.20.4373.026; Thu, 5 Aug 2021 05:43:17 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Aug 2021 07:42:42 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: X-TMN: [iar7Sy+K2UIgHgrYHCLGkZkot/zVKUxz] X-ClientProxiedBy: AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20210805054244.2094251-6-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.94.230) by AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Thu, 5 Aug 2021 05:43:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cba38195-fd0a-492f-181a-08d957d3ecf0 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNW/g7RXT9bbJ0eAVVYsx4fICGY8DjE/W5VoSB8wpAOBMP7IINGjwk7qnF11Xc1zEoLNMoZkrD4M3hBZkxB44SZ3DJPvwTs18yEB8ZEUxdfC3ygwwefWrR8KdBp7AWmdoOufTSJCcg/85kaUhapqwBhCtrTRUElNcbXo0tihZ0EHG2Mu6v3QXqNBz3WooqqD7XTz7Xe1p+ZSMjfrTbpWIBXKMKupdukYbED3ACxu2aNOPFl0w7gqm1ELQfqHagIM3Em8AIz0PaC3RqI/vnqwObM9jWQMUsm9AXoDCy+Su79yhAw0axcmRRt1hQr4aZHU2/osNMAFmfFD6ZS7tiyMSy2R7+CZv5EzFMbyv5QmbkiHaH8DCOAmlD44K4rqlfAB5K4d3Pi3n5kXW5xdQNcGbEStF8xwfgyCgoSdctQQHtF11dG9WcrwSEhovNL1BAzVUyz1kfdZ2iUWOboNmzCOjx+FE1W5onanTCj3RQh5mHTwwcZAfh2YaRWzrQ95X9ZRo5I1ppqt3Nhes767L4RBl/CvWSZY0vR9w0co21SzpS3CEPj9JHROVWSSkA1YqHiwxJrXW7JqboQ44BYm3Do9k9espUy4RosW54UHjKx0i00wwVgWuerZqZnizsC8smyLYTlnuSw0wfNzKWZVYrcQkjSpkg+bx0POhUaVS1VW6KO8zjqJ+7TexqPfMviN4fsXiOv5Mkp2Owq7ecwiOJn877L2pZofpLni4a0= X-MS-TrafficTypeDiagnostic: AS8PR03MB6888: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qGNAg0rWahFC54j8h1+BtKqKu3ktJCyG0qRz99cEzyYicvqmxoRcs+vDlNCogtVeLlH9OvkB4IFHznZDHfzEXTbKQtSX8agrPTqG4odtyEIujOf7teEROCbeRvBn14JYvprUI8QHrIdVPw1NQzpLrIdazXnFU4l81jHKk8NpqGNIPbWzIqEBBXjBXujwIdlP/wWeCTsrJlwQSGz0HD/+aTUeEFx5X/NrwaT0ia8FBDywjtXfqXF3UWVvwhbRWBW+TpWLTNuxtlqOhR6d8R1qeUbtweUY21obAv+cWG5lkdlUyd4A8ZKdL0mFLwTIhY/TY8l1JSb73ZNTc476xAjgx9hqpwL7s53kj/2W6DHr/qE+puwq6HIz7fEwyqMdy2/n+JtctyUmzw4wI2OVBYqcGafViFarnQ9M5T6u7CcY5El984ZYU8sRgeGnzD7vLnAP X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZcTTYmNHJGOi2LRnMeCxgUOBKRHqdm1U6CEaw3hX9hMYu1MBhF+LCo5Gj4XeWTwipt9mm4MiA19Hb82QVqenAmLOaYxvXUXkpoTMQ390HznBRnz69kukDqjP1IZHYmZu9tHe6tjgHDsb96NsFnD0Yg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: cba38195-fd0a-492f-181a-08d957d3ecf0 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2021 05:43:17.6600 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB6888 Subject: [FFmpeg-devel] [PATCH 7/9] avformat/aviobuf: Use ffio_fill for padding 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Eo0uCLjl2OdC Signed-off-by: Andreas Rheinhardt --- libavformat/aviobuf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index a883a75380..67963f85c7 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -26,7 +26,7 @@ #include "libavutil/log.h" #include "libavutil/opt.h" #include "libavutil/avassert.h" -#include "avformat.h" +#include "libavcodec/defs.h" #include "avio.h" #include "avio_internal.h" #include "internal.h" @@ -1445,7 +1445,6 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) { DynBuffer *d; int size; - static const char padbuf[AV_INPUT_BUFFER_PADDING_SIZE] = {0}; int padding = 0; if (!s) { @@ -1455,7 +1454,7 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) /* don't attempt to pad fixed-size packet buffers */ if (!s->max_packet_size) { - avio_write(s, padbuf, sizeof(padbuf)); + ffio_fill(s, 0, AV_INPUT_BUFFER_PADDING_SIZE); padding = AV_INPUT_BUFFER_PADDING_SIZE; } From patchwork Thu Aug 5 05:42:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 29262 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6c0f:0:0:0:0:0 with SMTP id a15csp97296ioh; Wed, 4 Aug 2021 22:44:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIHyYf+IxgpbqP9xV5og0+zEYqYtGjuLnGQ2e+stTeGGNVaEbGjHuTyhvJNE106hY+jUL/ X-Received: by 2002:a17:907:86ac:: with SMTP id qa44mr3043235ejc.509.1628142255750; Wed, 04 Aug 2021 22:44:15 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k19si4433609eds.581.2021.08.04.22.44.13; Wed, 04 Aug 2021 22:44:15 -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=@outlook.com header.s=selector1 header.b=OkKm6rOn; arc=fail (body hash mismatch); 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 191AB68A3B7; Thu, 5 Aug 2021 08:43:22 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-oln040092066101.outbound.protection.outlook.com [40.92.66.101]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EDE9B68A2F6 for ; Thu, 5 Aug 2021 08:43:19 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N5i8sHgtSrAzS439OxeJsOJxy7QUjmtEt9w7ZnSL/5KUEeMlZxeuPqLAn47SHRYsqWOzE5aSqSgfVY06BsB5f4NgXvGOEeWp/DAvabhBLQEQfTquDn0j0AWXQ+p43iSqHFw7DLLno0eu+7r/RPjuzMq38Kz729r6GxxQ+eXHs2foSOUQIryrjhJ7e5kBB6HbwgqeiCdKG8hqcOO5EoswSnp/hfRmxLbnoIzx7PvnNH2GuYB+9NSLOZjkc1NOiAy9hWaXNGzn7s639wRj+op8/UissuStcm0pJdoVPHHxw2B53XkwCmaCMUuPM1nWa2ifdDWtX3BNWJmUL6+/iCvM1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FZV7Kkebgs8/lk+iDTJylZ705UwRA1MV3rQi9A+pcfU=; b=PUM5LpPa9rc9f5S4G0RoninZlpSul66mn1hPs/EKoqJ/UOzVi3D+3MYFlEU5+H5PorgqCokhSpl0czXQ+IDBkjGP34xf7VYr9PoWf/xK0/veVect2lfMc70/h/YD9TbP+Dfs0uhboZLDjz0pos+Qnv9XDaxJASsav9HneJv+OhH0fme2S7qdpsxqJFxp+UfN4wyS/v+UzCxz428Gbn/n4jJyRX8xaB5uZ18OWuce37CWe2YAJ8UjwIprrI9gg17+uWxc4tcvCu4EqgtO2fpMKB8TEb52HKPmVyqzIayrLJHIFasCwsLX+4XpZUghzcr8KcZFpoTdiQkUzSEG6ILhrw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FZV7Kkebgs8/lk+iDTJylZ705UwRA1MV3rQi9A+pcfU=; b=OkKm6rOnz3FtLdPVgCiMLPJQHo/9LxX6yzSGrqrGOi6R4Z7Df7GRMDpfwYAS2N7YDIGZa8UfNqBZbHY0Gm42MSsS/FQhTJYhBUFxrg8B+OE+yvn5LGd06P95EA+fevWEGpkYzaDHNo3lfncoPpHMq7Y3UTjTAEqmDYbSGLIvZAatJ7JQRPr/rFavSAkEMu31Oo4Z9y8z5DPlMM2g4h305k2LkoqSw+8w1HA8MJOtfixKClnhoruXnR18unwEgLdmEDe/Tk2xvawyTG9GZ9mDxD+NON6L3T5L1uJWjXMlWg7Qzd/j4u5j+YN7IR5DAL0HFhbhPKArS4x/+mKZE94RZw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR03MB4776.eurprd03.prod.outlook.com (2603:10a6:20b:9::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.26; Thu, 5 Aug 2021 05:43:18 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::c9b2:14f8:d555:6f2d]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::c9b2:14f8:d555:6f2d%8]) with mapi id 15.20.4373.026; Thu, 5 Aug 2021 05:43:18 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Aug 2021 07:42:43 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: X-TMN: [ELpb5FJGEkhZmmr29X+tAE0WDbm1xanZ] X-ClientProxiedBy: AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20210805054244.2094251-7-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.94.230) by AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Thu, 5 Aug 2021 05:43:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 86556eba-7548-49b0-6282-08d957d3ed89 X-MS-Exchange-SLBlob-MailProps: +LiGfBxqLEvXz/Cg0Ir87bEks07/0c4IrhlNKvrU49HqjWIBdGSmHhJy4f32HCDj59njWlIhfH8Jk3i7wOVI9EhSmg34e7cTmoip1G6vKYcpe4xgFpqagVy7nMRDDwf69zzrCe4ezbBmiO94TxymCUyhGt0fOFhX1qEW+3XgyYwIbiq5xKZd9GG0hRJqYwjyU9/AA3ZKlQASGkpA+0tPbsByG268UaS/4Xc2mURb8mzIqlK/2wtfgJ7Na4NdQib/p1g/oA4bGghqF0BYyGwDYAJxuFmLUy+PYNeXalhjb+LPh/gJpywnOhDMqtaCL1+sxq13ii6kIkxI5AzGeR72/yILpIDeMPpmeYNZkkqlmIMNl+C0U3ZulFnxxUaOqsWpUVmqyGEKy864AL7I9mQui7QcCgqBSWvdnaDwf/oqQ1uYyV8BoaI2SX06grUD/PXvFeF9MvFVGHibsG838Q+zHo5hlg531NpC/Lll+S4BpowME4CvxPOFrfyLpGXSul+YLiXUaonNRWos/ufhoED94f5hSQwQ0u9nTBGW3UsNSOKoSvquwYvqL2YS/2DioJvu5Y1+Jr01SEDrYWkGQlQYB7XlqQlHuGtspcGRgcaFYGnuXK1TWcyiiqE8/54emzUwWgWPNII0TEAkqjoepqdxwfx/8+JGqYs44izDQbvwcT/frWYN6dlcrzmfOklOnVkNNRQdmk+pgOqkdtGA6oQ8yXd6HLyuNGxYKbpzqrESvBfqjjXYSbVNP8ZNLgxno/bK9Bvm3iqFNH59eIWO7daElUC6QCVdfkvo X-MS-TrafficTypeDiagnostic: AM6PR03MB4776: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m5KVq93bVC5H7BcfVtsqN+PWrRpV9KzYQ+5ufJiWuH03FD0cPlV7HDUYMf4zdSPQ2qsZsEaPP2SELkNbx22njwlhlW4yrFd0/SuexoskPpxP2jUH1v4Y0R+enrkl+bCuQfA2m1kPbDGDQvoJv83+4K7zyEm+MTTYFDWS+81XmkRKjav41izGGTCa81WJGgDTD0ZF41R+zFbLMMlEFgQzwDR71z6UzoN0GDGOs96og/kV0cULwqhke28q0Wd6XifRX4aKdrEsz7vlymCnouKbCqr6HxdrDJHxeemFoByxAsLgcQXgljAnuNGdor/i5b/E2pNPr43Uo8YZLGfKb1ljyXSalsHV/Cg5ds4NXsttV3eAo9Ae+YSIp0T3vyQh58yBmcTok74A+51owbOJjmcGPPglEpU05hs+9akPQsGe8ogeuABylpsC/ffOky3xMkl/tjpZNzZ3iB399qk/DUsa51ntTDp2oeYy5llNXW7AE1A= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: K4bY4egW8wzCo8gIKTKgq+Jsz3kv1tJsg8C/92EEDbRbD2DDZO5+zFUWkOE3ZiOCGaEE4NCxqeU2zaqRwVhm7Pl+I14TPecE4nHeAHy3zfuTXQahssz92i9I4ovdXCsqOsPlCM0HX1Zt/EETMQa2Gg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86556eba-7548-49b0-6282-08d957d3ed89 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2021 05:43:18.6377 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB4776 Subject: [FFmpeg-devel] [PATCH 8/9] avcodec/bsf: Avoid allocation for AVBSFInternal 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: spG29GVfZ7q4 Do this by allocating AVBSFContext together with the data that is currently in AVBSFInternal; or rather: Put AVBSFContext at the beginning of a new structure called FFBSFContext (which encompasses more than just the internal fields and is a proper context in its own right, hence the name) and remove the AVBSFInternal altogether. Signed-off-by: Andreas Rheinhardt --- This patch is a new version of my old patch [1], redone according to what was preferred back then (namely putting the public context inside the internal context instead of putting both contexts in one structure). Needless to say, this patch breaks ABI. [1]: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200810135522.5972-1-andreas.rheinhardt@gmail.com/ libavcodec/bsf.c | 45 +++++++++++++++++++-------------------------- libavcodec/bsf.h | 8 -------- 2 files changed, 19 insertions(+), 34 deletions(-) diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c index 0305244f8d..0f56655f78 100644 --- a/libavcodec/bsf.c +++ b/libavcodec/bsf.c @@ -32,29 +32,30 @@ #define IS_EMPTY(pkt) (!(pkt)->data && !(pkt)->side_data_elems) -struct AVBSFInternal { +typedef struct FFBSFContext { + AVBSFContext public; AVPacket *buffer_pkt; int eof; -}; +} FFBSFContext; void av_bsf_free(AVBSFContext **pctx) { AVBSFContext *ctx; + FFBSFContext *bsfi; if (!pctx || !*pctx) return; - ctx = *pctx; + ctx = *pctx; + bsfi = (FFBSFContext*)ctx; - if (ctx->internal) { + if (ctx->priv_data) { if (ctx->filter->close) ctx->filter->close(ctx); - av_packet_free(&ctx->internal->buffer_pkt); - av_freep(&ctx->internal); + if (ctx->filter->priv_class) + av_opt_free(ctx->priv_data); + av_freep(&ctx->priv_data); } - if (ctx->filter->priv_class && ctx->priv_data) - av_opt_free(ctx->priv_data); - - av_freep(&ctx->priv_data); + av_packet_free(&bsfi->buffer_pkt); avcodec_parameters_free(&ctx->par_in); avcodec_parameters_free(&ctx->par_out); @@ -92,12 +93,13 @@ const AVClass *av_bsf_get_class(void) int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx) { AVBSFContext *ctx; - AVBSFInternal *bsfi; + FFBSFContext *bsfi; int ret; - ctx = av_mallocz(sizeof(*ctx)); - if (!ctx) + bsfi = av_mallocz(sizeof(*bsfi)); + if (!bsfi) return AVERROR(ENOMEM); + ctx = &bsfi->public; ctx->av_class = &bsf_class; ctx->filter = filter; @@ -120,15 +122,6 @@ int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx) av_opt_set_defaults(ctx->priv_data); } } - /* Allocate AVBSFInternal; must happen after priv_data has been allocated - * so that a filter->close needing priv_data is never called without. */ - bsfi = av_mallocz(sizeof(*bsfi)); - if (!bsfi) { - ret = AVERROR(ENOMEM); - goto fail; - } - ctx->internal = bsfi; - bsfi->buffer_pkt = av_packet_alloc(); if (!bsfi->buffer_pkt) { ret = AVERROR(ENOMEM); @@ -185,7 +178,7 @@ int av_bsf_init(AVBSFContext *ctx) void av_bsf_flush(AVBSFContext *ctx) { - AVBSFInternal *bsfi = ctx->internal; + FFBSFContext *const bsfi = (FFBSFContext*)ctx; bsfi->eof = 0; @@ -197,7 +190,7 @@ void av_bsf_flush(AVBSFContext *ctx) int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt) { - AVBSFInternal *bsfi = ctx->internal; + FFBSFContext *const bsfi = (FFBSFContext*)ctx; int ret; if (!pkt || IS_EMPTY(pkt)) { @@ -228,7 +221,7 @@ int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt) int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt) { - AVBSFInternal *bsfi = ctx->internal; + FFBSFContext *const bsfi = (FFBSFContext*)ctx; AVPacket *tmp_pkt; if (bsfi->eof) @@ -249,7 +242,7 @@ int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt) int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt) { - AVBSFInternal *bsfi = ctx->internal; + FFBSFContext *const bsfi = (FFBSFContext*)ctx; if (bsfi->eof) return AVERROR_EOF; diff --git a/libavcodec/bsf.h b/libavcodec/bsf.h index 3b5faa85cb..8c5355d186 100644 --- a/libavcodec/bsf.h +++ b/libavcodec/bsf.h @@ -34,8 +34,6 @@ * @{ */ -typedef struct AVBSFInternal AVBSFInternal; - /** * The bitstream filter state. * @@ -57,12 +55,6 @@ typedef struct AVBSFContext { */ const struct AVBitStreamFilter *filter; - /** - * Opaque libavcodec internal data. Must not be touched by the caller in any - * way. - */ - AVBSFInternal *internal; - /** * Opaque filter-specific private data. If filter->priv_class is non-NULL, * this is an AVOptions-enabled struct. From patchwork Thu Aug 5 05:42:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 29258 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6c0f:0:0:0:0:0 with SMTP id a15csp97385ioh; Wed, 4 Aug 2021 22:44:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3dtRNkIua1tI/DSoyDI4Ploy7oc0Stu/Kg69iMOsdI8EB+8teJZajt3iDlJPoKT23t/11 X-Received: by 2002:a17:906:d93a:: with SMTP id rn26mr3021111ejb.382.1628142264845; Wed, 04 Aug 2021 22:44:24 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id eb8si2879507edb.231.2021.08.04.22.44.24; Wed, 04 Aug 2021 22:44:24 -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=@outlook.com header.s=selector1 header.b="Qpdw/GHU"; arc=fail (body hash mismatch); 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0D32A68A278; Thu, 5 Aug 2021 08:43:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-oln040092066083.outbound.protection.outlook.com [40.92.66.83]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1538F68A370 for ; Thu, 5 Aug 2021 08:43:22 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EI1bJ8IGKo6ZRwE5kr/lBPQDsqi0bAYSK/43LTKk48+msvy/Micmqi6S+bR0anrDwQZtki44tV5UOcMrZkshGrV5NNgtY/38MVrlh4BDf98EfCOMiB3zzoh3Tv149Q9mrjIwY97aThXeJL2aNRfk8TYAcs/jX9cagxLkvDW8qfxuBfKoJmkfatjTYWCRQ050I4eHSIvyRWQ2GxqggypwLwUgBJvy1XRIdKl2Jz3IkWuXI/pXkgYh+S1LsYm4UoyHWgUBVi2v3s1yKDDuefxaRtWHH6MnxDPhPxzR+bNXEmbwOIHKbwnT3gj3CMwvlOlqcKc1KDoRrOk8qACVQArbmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NNuSmMyu/O+0OOB+ZLhuVpawIQ9LVWRKz3khtvLi6aY=; b=h+VwGT3wKGpaTusorrDw8tuxZyqdYNd0tTb5lQPjpv5xNQXuc1AqmRlnghwU7IizKhBrGTezF2zCMFuJN1JVRR56GB/gW4beG4O2QteHqO0aHMbTQ32TdEzd+VPKrfvSWm/7G4nkr75lTcOHgwK1NiiKYVvj5OQdHG2n3v7zK1+A8JW1T/4V0ZJAW7clCKXb94KhtkLSL3ZSO4pXF9Flxk+VD4WypCGa2bjGAENSgWTRI6h57GlMygRUV6OAXQjCXOFryr39h9ANcDW24Fhg9t0UZ5Tu7S+C7/VyPAXFDjLyXW7HICC4/FnResmiDPR6X7t1FhuD5zB9j1qdK4qb1g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NNuSmMyu/O+0OOB+ZLhuVpawIQ9LVWRKz3khtvLi6aY=; b=Qpdw/GHUPrVpnnBRqAMho02+5d8ONXWgVAqwbrKc9PP1pwLkfhmc2ZId2N8Jkd6tCwkRMXoISo+9dTKiu/873sT9pViz2XuMkeozWpgQVYbgvhU69hBR1UPLdLHzd5mE89pVcoRnrVGc6C99d2hTlQGS8rMF82maceS0BzmqcFU6DjqCeG2772S5Ohyzhkqds4KbJQQ5OCHcPH/+AmXDKYMBCpXCQSNhowjQLzpCJVttHpbUOqMlyK9DaYFB6ZhYxp2rcpp0fwbxu7uImolNQJtYZwuSGH9gld41MJ+3zFBpkBNrsbheEyGYCVbAJnLVAZGnpB/RJQGnzhe5lGmYZA== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR03MB4776.eurprd03.prod.outlook.com (2603:10a6:20b:9::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.26; Thu, 5 Aug 2021 05:43:21 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::c9b2:14f8:d555:6f2d]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::c9b2:14f8:d555:6f2d%8]) with mapi id 15.20.4373.026; Thu, 5 Aug 2021 05:43:21 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Aug 2021 07:42:44 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: X-TMN: [dGlYyZEZ2CmGL1ZT4/VOYOcsO13XW++r] X-ClientProxiedBy: AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20210805054244.2094251-8-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.94.230) by AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Thu, 5 Aug 2021 05:43:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: afb9be35-e698-4c03-79ca-08d957d3ef6e X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/UL28/k2NJzNtIacap2Pd4pu9N01P678eM1dMLTvIpKP3y1OIn0ENFJXzNoHhxfgimUDRCdDtf7tfLGccMtTzM0/lFQySLO3sTm9XEoS4fnAAHkVTnYiGHFyPoa7s3rOkTFC6oi6P0YYsaBhJ2Bq3DxurcvoAh4QAhHg00JJnCkXGSPQaHnDMmNe/b09gOhZ1N0I0Ge4OwuB9/441i8rvlvMwu+fdg9mnE6gctiC8LDl/zxnAH1t/azx24PDHE12hL5v4geg7Ii6h9U+tZM+HzVRRH5sZZR8yUEJ72MBm6I4ajDbpaearrr+RIEXfqebdZeWcVd0nHJHMP7yCLXHQsxJYTFnc/gCmVnXQ2MvK2GNiHfGT7+tN5B+38xOFr0X1Wk4mX7Ud8XWIOVuVfyM7z6Svy6GSWepbg9+G3MfaYRUpsxeHmDCsK/tLuSQXjQKS0aQa+qB6RUJu1WHptyrrPw//Am6wLIsKvKTGFpQm1JNH3mkDSf4c5yR2JxNSUcINibc+osPA6W9SG6VLtbeGQYA4Lm8q8/QMcc/+1ks0XNn3y3tIP25rYt3uS4mDui6E/TQvKoX3O1fl5Y5b7byqBQBd/g0I5WUZUrfg4jIulPBlE9hL4wAtkTDJJTe4foj+GrrYdS5UabKMhmt8r3jE96ypzgu3RiYKUP8iC0Wa3b8SnBDYjQ8KcIx2eX9xB7ne59amvsT23A5HQ== X-MS-TrafficTypeDiagnostic: AM6PR03MB4776: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4F9FiLHY5D9i+5tCWGCkvkT4bGYNCh5zPOZwsWp9WhToikJO7CxFWPMZsMmsxoWEGP79vM6mnRrb3fJvS6koCp4Jz6DhzM7Lu/MvG1/aOrc1+cNCeSDcSRa47fIyiptHuDvenx6hmB67S0+xfYJ10NwC2GLFMxSa7ehwSmQPl9fB7eiQzljjS0xKWTPXsiHD7ATn15KcellCTk43Xt91LZncFTa53wMip4m9uCrgsoTO4BwXaw3dS9yke+NWUYsWpUw/SFml+r0m/0gMCA0pEA541o6Ge/w3Edv3So4thbAeGwnn/azE+VERUeESw1mYZZFX/PIw0GA09jxr3NbSpoMJKCAINQy7+lgzXxoYfZ5XWPxx8/S3JWxxdEwM9G663BXGfy2oa+/6lAxTteWuNXOHH/JDwaACVrMeuBSLTFu3X4UU/sDLEDauV6X1rSQh X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ykLQRuEktGADRzcoySBXPkfLrcE0p7V96KxSnmXIk03/85iNMG8diwS+1Na4swXMDCEn91wcDvTyHkT/CHVQLtO+Xfch2qaV+G3kPH7KWFsta3hZbJgcOusmgwqC8UJgmFTew4yoIDymyk6AhGdvpQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: afb9be35-e698-4c03-79ca-08d957d3ef6e X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2021 05:43:21.8487 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB4776 Subject: [FFmpeg-devel] [PATCH 9/9] avfilter/avfilter: Remove unused partial_buf 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: GUB+ynjITBkj It is unused since 02aa0701ae0dc2def8db640c9e3c06dc1b5de70c. The corresponding size field is write-only since then. Signed-off-by: Andreas Rheinhardt --- I was quite surprised to find this. libavfilter/af_firequalizer.c | 2 +- libavfilter/af_loudnorm.c | 6 ++---- libavfilter/af_lv2.c | 2 +- libavfilter/af_replaygain.c | 1 - libavfilter/avf_aphasemeter.c | 1 - libavfilter/avfilter.c | 1 - libavfilter/avfilter.h | 13 +------------ libavfilter/buffersink.c | 3 +-- libavfilter/f_ebur128.c | 3 +-- 9 files changed, 7 insertions(+), 25 deletions(-) diff --git a/libavfilter/af_firequalizer.c b/libavfilter/af_firequalizer.c index a4de76ee0f..77de69e3ef 100644 --- a/libavfilter/af_firequalizer.c +++ b/libavfilter/af_firequalizer.c @@ -837,7 +837,7 @@ static int config_input(AVFilterLink *inlink) inlink->sample_rate, inlink->channels, s->analysis_rdft_len, s->rdft_len, s->fir_len, s->nsamples_max); if (s->fixed) - inlink->min_samples = inlink->max_samples = inlink->partial_buf_size = s->nsamples_max; + inlink->min_samples = inlink->max_samples = s->nsamples_max; return generate_kernel(ctx, SELECT_GAIN(s), SELECT_GAIN_ENTRY(s)); } diff --git a/libavfilter/af_loudnorm.c b/libavfilter/af_loudnorm.c index 5a3e762b27..a07e8a3c93 100644 --- a/libavfilter/af_loudnorm.c +++ b/libavfilter/af_loudnorm.c @@ -504,8 +504,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) s->pts += out->nb_samples = inlink->min_samples = - inlink->max_samples = - inlink->partial_buf_size = subframe_length; + inlink->max_samples = subframe_length; s->frame_type = INNER_FRAME; break; @@ -761,8 +760,7 @@ static int config_input(AVFilterLink *inlink) if (s->frame_type != LINEAR_MODE) { inlink->min_samples = - inlink->max_samples = - inlink->partial_buf_size = frame_size(inlink->sample_rate, 3000); + inlink->max_samples = frame_size(inlink->sample_rate, 3000); } s->pts = AV_NOPTS_VALUE; diff --git a/libavfilter/af_lv2.c b/libavfilter/af_lv2.c index cc5d702e27..28b729691d 100644 --- a/libavfilter/af_lv2.c +++ b/libavfilter/af_lv2.c @@ -380,7 +380,7 @@ static int config_output(AVFilterLink *outlink) lilv_plugin_has_feature(s->plugin, s->boundedBlockLength))) { AVFilterLink *inlink = ctx->inputs[0]; - inlink->partial_buf_size = inlink->min_samples = inlink->max_samples = 4096; + inlink->min_samples = inlink->max_samples = 4096; } return 0; diff --git a/libavfilter/af_replaygain.c b/libavfilter/af_replaygain.c index a5f5959eb3..fd642297f8 100644 --- a/libavfilter/af_replaygain.c +++ b/libavfilter/af_replaygain.c @@ -359,7 +359,6 @@ static int config_input(AVFilterLink *inlink) s->yule_hist_i = 20; s->butter_hist_i = 4; - inlink->partial_buf_size = inlink->min_samples = inlink->max_samples = inlink->sample_rate / 20; diff --git a/libavfilter/avf_aphasemeter.c b/libavfilter/avf_aphasemeter.c index ef7e50e657..a31805f204 100644 --- a/libavfilter/avf_aphasemeter.c +++ b/libavfilter/avf_aphasemeter.c @@ -131,7 +131,6 @@ static int config_input(AVFilterLink *inlink) if (s->do_video) { nb_samples = FFMAX(1, av_rescale(inlink->sample_rate, s->frame_rate.den, s->frame_rate.num)); - inlink->partial_buf_size = inlink->min_samples = inlink->max_samples = nb_samples; } diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 24de8ebee3..1655a21f46 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -177,7 +177,6 @@ void avfilter_link_free(AVFilterLink **link) if (!*link) return; - av_frame_free(&(*link)->partial_buf); ff_framequeue_free(&(*link)->fifo); ff_frame_pool_uninit((FFFramePool**)&(*link)->frame_pool); diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index b82f72d040..e0914a151e 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -548,20 +548,9 @@ struct AVFilterLink { */ AVRational frame_rate; - /** - * Buffer partially filled with samples to achieve a fixed/minimum size. - */ - AVFrame *partial_buf; - - /** - * Size of the partial buffer to allocate. - * Must be between min_samples and max_samples. - */ - int partial_buf_size; - /** * Minimum number of samples to filter at once. If filter_frame() is - * called with fewer samples, it will accumulate them in partial_buf. + * called with fewer samples, it will accumulate them in fifo. * This field and the related ones must not be changed after filtering * has started. * If 0, all related fields are ignored. diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c index c4147bf732..07c4812f29 100644 --- a/libavfilter/buffersink.c +++ b/libavfilter/buffersink.c @@ -199,8 +199,7 @@ void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size) { AVFilterLink *inlink = ctx->inputs[0]; - inlink->min_samples = inlink->max_samples = - inlink->partial_buf_size = frame_size; + inlink->min_samples = inlink->max_samples = frame_size; } #define MAKE_AVFILTERLINK_ACCESSOR(type, field) \ diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c index bf7bb3af68..47ea9b59d7 100644 --- a/libavfilter/f_ebur128.c +++ b/libavfilter/f_ebur128.c @@ -413,8 +413,7 @@ static int config_audio_input(AVFilterLink *inlink) * filter_frame()). */ if (ebur128->metadata || (ebur128->peak_mode & PEAK_MODE_TRUE_PEAKS)) inlink->min_samples = - inlink->max_samples = - inlink->partial_buf_size = inlink->sample_rate / 10; + inlink->max_samples = inlink->sample_rate / 10; return 0; }