From patchwork Mon Oct 11 15:36:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 31060 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2084:0:0:0:0 with SMTP id a4csp3821860ioa; Mon, 11 Oct 2021 08:37:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCfaXXHK6M0t14snKLhcIbve/8Htz+nlowXIFrWlQY8exEqqoeQmBaO5pxU7GeVdM0ogCz X-Received: by 2002:a05:6402:350c:: with SMTP id b12mr42684993edd.244.1633966661437; Mon, 11 Oct 2021 08:37:41 -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 bi21si11700534edb.618.2021.10.11.08.37.41; Mon, 11 Oct 2021 08:37:41 -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=cFD5YYfK; 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 C4E3768A8F5; Mon, 11 Oct 2021 18:37:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2075.outbound.protection.outlook.com [40.92.91.75]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 223CF68A8DB for ; Mon, 11 Oct 2021 18:37:07 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NfA7vxN8+cVmhhCNKf6Op6YNRSvIP6bVl2MAgBJJZXS6vffOlK13AVPqPWccPhwimokNG9E7SyIWx6CF5QoyRBFdJ6goIOZg+ibGYrjkG4ag2gd97wg6X2eOPq/PIHC26DIPecKUqIctdCb8LdJUuqKzEMegIL1VdCY1Ggen1IUoK1JUUuKC6uovaB3j5UiYjUKWHsC1LCgXztFNQ3GzbVq6Rn3mPdhk0qT1TYUaBntjJeORoBfTf8bjlib76uwVBOhvhqw6AKtPLFlNHqd+40OQmbCkF9hvXYs4Ax1pMZmYWNGDOIcYXPGO27/ro8ntywxzDyAguwEojIARk8DGuQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cjZvMZgydJbkS3nxiRXqqBbRgnwkPe7BEFbaPMkvKOE=; b=YoKmPbg2IoMaNt+EvPL6EwBckmgA+Psr6D0RY87EMi+sL/xsNeiSl8nzDBif/gVnu9ZOi2BXp78LyL7TK2ssnrgC4udEP3moq9TSObKnlrI1qU7xA9DuJerkWTMGaiv4js8R5IMvepVrI+33wmHlLpFrZdQoDCsmfAJkpytKN9c6WBSjuQIlfjb21t71G+xxZfIg+ByyrfZ9b8NMt6ycIElsdNlUk7nsunLHJGMT6fMdfeai6dF4HW+mEOd/d22SQ70b2TDCzPl/lJvN417lAZs+lxdS/vaipRRvTcAprdIKPLmSreSYpj0Vvy99raM1os3LGx6ev+r77lvnS/v8oA== 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=cjZvMZgydJbkS3nxiRXqqBbRgnwkPe7BEFbaPMkvKOE=; b=cFD5YYfKOR+lPppu8UZ4k2/4C52pKh1Q5Q7a8QIkzxdD4hTfJkje3C7mQNb9yixheSlO1wsnFElvHzFtHxV903mvIzwTgXS7iZOI/oy9sFbPg7NHWntKU0B2c8rP/KXgFTHPJJYIYb7reTovCL/F6sgcU7eDEEeNK4GQ2RWIdvP9lZriejrjPs0f8be7eCGb6GJFrVJ0Idnp/fBrIf85RD6LigDal5ruzo5b6Jj3xB5WYNyuElJ8hOivL7t0gL7uzBcgSH7EASGdAWAxqcGh3Ey0c04ilnwJzicSajCz3i9RKMZz2w2CFb6wsdtsjPeZ7hdc/ug6Ou/gvx9vGzVU6A== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR03MB5046.eurprd03.prod.outlook.com (2603:10a6:20b:88::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.22; Mon, 11 Oct 2021 15:37:01 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::700f:d70b:3bb8:4d51]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::700f:d70b:3bb8:4d51%9]) with mapi id 15.20.4587.026; Mon, 11 Oct 2021 15:37:01 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 11 Oct 2021 17:36:45 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: X-TMN: [1IwAxCJ0kLHOeaWEQHESQgyXC8lqhZuB] X-ClientProxiedBy: AM5PR0601CA0070.eurprd06.prod.outlook.com (2603:10a6:206::35) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20211011153649.1961025-5-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.170.49) by AM5PR0601CA0070.eurprd06.prod.outlook.com (2603:10a6:206::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18 via Frontend Transport; Mon, 11 Oct 2021 15:37:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 58501930-044e-4622-69c0-08d98cccf822 X-MS-Exchange-SLBlob-MailProps: +LiGfBxqLEuXvjPRxFEFEnb/PQXfcGTfszCDiFaULQcvi+gmNeuU2KQMj0LsKd9OBKSychKUU5uR1MzZFiGfTPjGymPrgn71WUtMjpsKSnUYoLY/Sw+lTcbJsX1lgvuHk4mK4fVFBgkSFSLBaJNY9DXekyyIQGhq/BK+pyIXLnLKGED0wdI4LzvNNrsFDJMVtunQyNEwdi3GEPVfSCm1T/J3zr1tQB7+O3tO4BKZNNAVtUDXbzOXX8IDhPpMux7E4xjr/m9/Q/a2i54H+97s7bC0eb2yXZRA3a6ihJnrupxsi+G6cOjiDCvVXH1L/6i8YbsldY4GdRJP6mzDrLv8IH4Pwv/9bCeR5NK4kmK2vIBOWkMd1dP8W4aMVbdgBvTGs3BPfi1Ny58Km0o5S9H1sb//vSdrGuSUxnOf2raV0Epkw+LcUdSY88SOv7U3zWGBq1k+B8XwuQBsv4dVKv6pr2MTn53CdXp7m61MWdpqXfYwLVgIt2Gc35bmd3crsd30rjA/aMTit8EvLndhN/cD4ehhZFF/p/KwHdUJdZgAshcskTOPdJ8iSEEbf9uYEtqiu9ubh2zVlJLW7r6ufsSe3QHooNZKe2Ow1PLvu4uRXg387Z8vpMvFy+UT3UJi4wh6GULapJMxdGfE82/ua/FqUEd/smYxYGiJJN2warTKjNO+jUCh77rMrD1iGeQ/tnbGTRKuvB7hPx/DwQWoq4unAOGa4CCEfNxwzrAymRTMBuO/usue13DnoxJkCOKNPK755btN37dlAtmc9NCB35KpnfCnllLMtVEF X-MS-TrafficTypeDiagnostic: AM6PR03MB5046: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UcDK0eDmm7m1iqcpVvo+BKfOrnpBsn30acdAQhZv4I9JCU9CnDJm0pRcNk0wLvvfm/oUViEycJpxECeyQEOE0EB2nB3WFkGkeS404VG8CmGO2bXjf5JvXKX5M0/Pd4CsNXPj2q+pgFYUQ97Nx7mViHlWjn6MHlywCNFLpTrTkd9vCbdZh2YEz4VHdgnuL//isavz53GlETT5Htc8YtTuGKNhPKD5SvammYycIaKrs5oxoJKQfjvpifEzFmTF/4KIYUtziWMZInjmVyxoAMWtmYNoDUhSXuTsgUOpq4n3BXqU18sM17RqiYk4JdHgq3f1DNKlIB5cGAwJuuOHc41V4AXnlQiq53c+AaZTF5i+EkDW/zfepCDuKg++yN1BJUKG5oNUzez4wnzbLpAXzaf9Fc/MshZNnqQkZvuDKCHerSFW1hMK7ku0TRumAtYJT/Vz X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BHKZlL94eMIZLBLNVV1tFl6EdmJEiYKmnyOBOg69vWi+3U4z3nbOK8lXaONyez7PwdOpt7Sr+fJiOa24xSEDfFEgK7fbKguwQ68arO5Lg1UtZmxWBPFQK7ISTzEzB6FdgLZ4SHC6Eh7g+yVgIs82+g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 58501930-044e-4622-69c0-08d98cccf822 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2021 15:37:01.7312 (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: AM6PR03MB5046 Subject: [FFmpeg-devel] [PATCH 06/10] avcodec/cuviddec: Use AVCodecInternal.in_pkt instead of stack packet 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: s8fhrdCRlcFV Signed-off-by: Andreas Rheinhardt --- libavcodec/cuviddec.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c index e157777c51..f03bbd8c4b 100644 --- a/libavcodec/cuviddec.c +++ b/libavcodec/cuviddec.c @@ -53,6 +53,10 @@ typedef struct CuvidContext CUvideodecoder cudecoder; CUvideoparser cuparser; + /* This packet coincides with AVCodecInternal.in_pkt + * and is not owned by us. */ + AVPacket *pkt; + char *cu_gpu; int nb_surfaces; int drop_second_field; @@ -466,12 +470,12 @@ static int cuvid_output_frame(AVCodecContext *avctx, AVFrame *frame) } if (!cuvid_is_buffer_full(avctx)) { - AVPacket pkt = {0}; - ret = ff_decode_get_packet(avctx, &pkt); + AVPacket *const pkt = ctx->pkt; + ret = ff_decode_get_packet(avctx, pkt); if (ret < 0 && ret != AVERROR_EOF) return ret; - ret = cuvid_decode_packet(avctx, &pkt); - av_packet_unref(&pkt); + ret = cuvid_decode_packet(avctx, pkt); + av_packet_unref(pkt); // cuvid_is_buffer_full() should avoid this. if (ret == AVERROR(EAGAIN)) ret = AVERROR_EXTERNAL; @@ -797,6 +801,7 @@ static av_cold int cuvid_decode_init(AVCodecContext *avctx) if (probe_desc && probe_desc->nb_components) probed_bit_depth = probe_desc->comp[0].depth; + ctx->pkt = avctx->internal->in_pkt; // Accelerated transcoding scenarios with 'ffmpeg' require that the // pix_fmt be set to AV_PIX_FMT_CUDA early. The sw_pix_fmt, and the // pix_fmt for non-accelerated transcoding, do not need to be correct