From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 84B4240444 for ; Mon, 24 Jan 2022 14:51:22 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CDFAE68B19A; Mon, 24 Jan 2022 16:48:53 +0200 (EET) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-oln040092065094.outbound.protection.outlook.com [40.92.65.94]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9162768B05B for ; Mon, 24 Jan 2022 16:48:52 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GpLH2bIP0qZqVJ5ySZ/BVosvvSjfoDc075/WyhrBhTt5kyfs2cpN/77zPNrJbh3Ku2JxRkosJMmZdQ1YGJbPhNqBCk+XTOhllTUKFYSt9GWIep+tuOGXxiRyxdijOYBsqs8+Gi3KMYjh4YONEMJZdithDM+H6ijUJ1pSYhVqMJ7jSSQItdrin+V6Pe5Z2iWETkWPKAEfs83f37lVmDcEXlWl/+/UUKlolnyXFNeINT9J9z4FL9t8M7zDedAqmwT7D+SZNAqna/qEZPHKQ+U0AQGg+Z0hxu4RavZBIWGsop1Z9owo6EDAxSl79q8LRkljn1ce9dzsTwcx511bg01MSQ== 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=+89zkahvhAU/eLlLLuOeUL9vBLSmkLMVIJt1h845us8=; b=MJDPG4BvfYb3D+fhE0JletZwENkXgLzx/kyRVn35/YVBZIccNrChhedUbzCeq8e6005IjYfCw/SLiH/DyVl/Z1VN/NmA3D8+zWJ1L/0DeIT4V8qN/8N5yYL1Zi9DEQ+uV2Rj0dXFrZUOt3OwsguV/1HJA6+gej6ilBonvwAT0Bn3oWCJDn/YyVgs+1wu6SdFpMFxK5eQt/eW50nTFtwsVI5fk03ue73C/FA9eBXh3YphIsB2KJczljzwraUpVzRIzvWZ5TQBz2OEq9X0R05+WmWXZz5LlmUrWLkQ7laPkLuJ1CatslARkIseDe0PxhrgM9ItY+oJWOjZQmmY8c7uOQ== 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=+89zkahvhAU/eLlLLuOeUL9vBLSmkLMVIJt1h845us8=; b=nwxhVWCJ5BzBTrsxqZUgi/LFwl1k3n8Na4gCcVEh29gfy+KBD/V62j0tiqjuVuTMKnK9+1lGyQoP9rISWOlW247cF+vj4nxuyxFsar8Fg2/ng/kJKWOrurq4F3Sfjmtje5CNgv/KAToigdOekuCembj52y4QggurzVw6608y1F7A9wEAxIZRveD3cfJFzSTA8QI0+NB+mtuJ2TZf2REJ97EgP17uKHTvkLf8ziYna/98cVvVKUvCO/ibYfwdm4uQqej7T5LPQMGI+Xqg5D+xhSwkZHu6ZHdle9/da0013gjtiDMFMnSr+aIX6Mm9OtVAljfP2AW0s/XuvW4NNwQxgg== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by VI1PR03MB4397.eurprd03.prod.outlook.com (2603:10a6:803:51::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.17; Mon, 24 Jan 2022 14:48:50 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::ac56:2ff4:d304:ab22]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::ac56:2ff4:d304:ab22%4]) with mapi id 15.20.4909.017; Mon, 24 Jan 2022 14:48:50 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 24 Jan 2022 15:46:13 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [gq/Fc0Wt1V/z2fH/N1M/Ap/GJ3rbD/dy] X-ClientProxiedBy: AM5PR0201CA0016.eurprd02.prod.outlook.com (2603:10a6:203:3d::26) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220124144616.559446-28-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cf3f1cb2-48c9-4138-3643-08d9df48a28a X-MS-TrafficTypeDiagnostic: VI1PR03MB4397:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZI3cn13mVNoJHlYqSYUPUvlwNUwBZHMv9HpdHRWJ2PcFWdqWgSkoqOPuXTPchwirCcq2g6tThmr1I93EgyvQF3GgYPSeZcXLCljV+tnAfrV0W+wvqvedf9/KtsJsulozODvjyDqY1rAjphgsPanLP8FqrG6xs4Hn6RrPOV8cgFOnXGfcLe59dxSnZdmFlc6pBdm5Hp6cHI3JHu5nugft9tfuDk2tKerUBxxXr1x7Q88B/qtfYyN/ps+zl/5yzlWrgh5bKzKWNHBZvnOgFHHjkkbXCYgcBbJ2kpK8offuSwGjBxV4ecp9l6qrkPdL6PlGLZ8hogF0phV+1IVIojSAN6ZdUL7aC/ufxzKCGBsVXpwc2VHrnX6Bbc9JRq7Jzb1b3jqsKPB+dW9/PhSeOk1HGriD85nvzSic7GNR5YNENv9G3ckgQ1wrbKjMidn+bTnzjYzC8XtaYtfZcWZt1rF/GmWohGj1vw9V3TqNfX+pSSNFZF8iXUIOrz0lN+KyZLZgc8etgPsGdRq9qF0CMsxc1d9E8kRTIE1ppNj8KNHSL3GY8npNPKbnYdFgvDzeGq3t+I+mBZrosSy+f6fnxSrJEQ== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?F8dHxQiQg6CoY5XWZ2NwdVPINcFx0f3n6qdAK7Y4J2RrwJm2Nv8Mm/jx1rZN?= =?us-ascii?Q?IgIwJdg+oqlxUfKf5oK5jOtUV2kTUQjUdl97AxF1eEHofZOBdWbLkj4OANSX?= =?us-ascii?Q?+8/DiVXcyIgBwUACa4iDundqjUTwz5VZK6PKri/p8JjaB+sGBg0qkJ8VHAUt?= =?us-ascii?Q?kzWj6n5gQvUrPTqA6thnR79uDvrICTJLk0SoSEQ5Di9LT/uH3KKJbOh97EzW?= =?us-ascii?Q?RmfhagnTL3lDkdax7bu50bRLwhUhMDyClCJ4f6yna046An2dfTDy4WSsYdzD?= =?us-ascii?Q?DOXbdfv1Cnq13Uhvesn7vbCqA/BWB+6K9TvTUi2LaScT6O3RU2Ztjwszp+3d?= =?us-ascii?Q?xJsXJQHCdr9vUXWgAGqhuWCu9TRF4dapdcppWbjvaNfXYmumegOoBk78LjLb?= =?us-ascii?Q?y9mnyfTiMmA+q/aRa5daseBQsKxV16SmSCEQMvY7BkXtxVToSCevx1DLxPOS?= =?us-ascii?Q?4MiU2GceCjchwlrDEIXSMppo7whDMuF0jn2BdYrzWLOyMho4P+Ie+ST2Okdg?= =?us-ascii?Q?sQZxMrIEY6ptNd0uq3D0UZcfsl6qDjGXajT2B3bG5cNk+/PzmT+w2JhLfQLs?= =?us-ascii?Q?Gdrg/6zm6iFht7yv76b187cVMdwwf6Yy+78gje4bv9UG/l4GQn4Pm1RnYrYK?= =?us-ascii?Q?3IUh2JmkrmpBqz6Lj8kVWeYklpGf/FGCUw46YTG58IXQ+/Ly14HFGE3tL4m1?= =?us-ascii?Q?F8KF7kIj+SVv6c4bt4WNvtJYX0VKkMsDuJ9T3x0EaPdL9vyV+vCr7Lja4oDc?= =?us-ascii?Q?Mpo5xAzNJu6V32X2u1dH3hvZ5nhbGy7wgO8hHfWBxKCY4UvIw+u88tXE2cLF?= =?us-ascii?Q?UO1/MYLWbYC5h0nwMR2iAhdvlq8orwTpYR9GASLbXIUJ1bmTsoPwSOTNyAk5?= =?us-ascii?Q?muLpMd0MY0GhiSBJNpCevaI9BZ6aZ8yQJIe6J4ED/vl4fHIcnu1/BVHFbERl?= =?us-ascii?Q?RFAPHUl9ZSQko5j1V9iZUA=3D=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: cf3f1cb2-48c9-4138-3643-08d9df48a28a X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2022 14:48:50.9130 (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: VI1PR03MB4397 Subject: [FFmpeg-devel] [PATCH v2 28/31] lavfi/vf_deshake_opencl: switch to new FIFO API 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: Anton Khirnov Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Anton Khirnov --- libavfilter/vf_deshake_opencl.c | 92 +++++++++++---------------------- 1 file changed, 29 insertions(+), 63 deletions(-) diff --git a/libavfilter/vf_deshake_opencl.c b/libavfilter/vf_deshake_opencl.c index 9c761ba5ad..c2b5bef897 100644 --- a/libavfilter/vf_deshake_opencl.c +++ b/libavfilter/vf_deshake_opencl.c @@ -134,7 +134,7 @@ typedef struct DebugMatches { // for each frame typedef struct AbsoluteFrameMotion { // Array with the various ringbuffers, indexed via the RingbufferIndices enum - AVFifoBuffer *ringbuffers[RingbufCount]; + AVFifo *ringbuffers[RingbufCount]; // Offset to get to the current frame being processed // (not in bytes) @@ -144,7 +144,7 @@ typedef struct AbsoluteFrameMotion { int data_start_offset; int data_end_offset; - AVFifoBuffer *debug_matches; + AVFifo *debug_matches; } AbsoluteFrameMotion; // Takes care of freeing the arrays within the DebugMatches inside of the @@ -156,18 +156,10 @@ static void free_debug_matches(AbsoluteFrameMotion *afm) { return; } - while (av_fifo_size(afm->debug_matches) > 0) { - av_fifo_generic_read( - afm->debug_matches, - &dm, - sizeof(DebugMatches), - NULL - ); - + while (av_fifo_read(afm->debug_matches, &dm, 1) >= 0) av_freep(&dm.matches); - } - av_fifo_freep(&afm->debug_matches); + av_fifo_freep2(&afm->debug_matches); } // Stores the translation, scale, rotation, and skew deltas between two frames @@ -853,7 +845,7 @@ static IterIndices start_end_for(DeshakeOpenCLContext *deshake_ctx, int length) // clipping the offset into the appropriate range static void ringbuf_float_at( DeshakeOpenCLContext *deshake_ctx, - AVFifoBuffer *values, + AVFifo *values, float *val, int offset ) { @@ -863,7 +855,7 @@ static void ringbuf_float_at( } else { // This expression represents the last valid index in the buffer, // which we use repeatedly at the end of the video. - clip_end = deshake_ctx->smooth_window - (av_fifo_space(values) / sizeof(float)) - 1; + clip_end = deshake_ctx->smooth_window - av_fifo_can_write(values) - 1; } if (deshake_ctx->abs_motion.data_start_offset != -1) { @@ -881,13 +873,7 @@ static void ringbuf_float_at( clip_end ); - av_fifo_generic_peek_at( - values, - val, - offset_clipped * sizeof(float), - sizeof(float), - NULL - ); + av_fifo_peek(values, val, 1, offset_clipped); } // Returns smoothed current frame value of the given buffer of floats based on the @@ -905,7 +891,7 @@ static float smooth( float *gauss_kernel, int length, float max_val, - AVFifoBuffer *values + AVFifo *values ) { float new_large_s = 0, new_small_s = 0, new_best = 0, old, diff_between, percent_of_max, inverted_percent; @@ -1069,7 +1055,7 @@ static av_cold void deshake_opencl_uninit(AVFilterContext *avctx) cl_int cle; for (int i = 0; i < RingbufCount; i++) - av_fifo_freep(&ctx->abs_motion.ringbuffers[i]); + av_fifo_freep2(&ctx->abs_motion.ringbuffers[i]); if (ctx->debug_on) free_debug_matches(&ctx->abs_motion); @@ -1188,10 +1174,8 @@ static int deshake_opencl_init(AVFilterContext *avctx) } for (int i = 0; i < RingbufCount; i++) { - ctx->abs_motion.ringbuffers[i] = av_fifo_alloc_array( - ctx->smooth_window, - sizeof(float) - ); + ctx->abs_motion.ringbuffers[i] = av_fifo_alloc2(ctx->smooth_window, + sizeof(float), 0); if (!ctx->abs_motion.ringbuffers[i]) { err = AVERROR(ENOMEM); @@ -1200,9 +1184,9 @@ static int deshake_opencl_init(AVFilterContext *avctx) } if (ctx->debug_on) { - ctx->abs_motion.debug_matches = av_fifo_alloc_array( + ctx->abs_motion.debug_matches = av_fifo_alloc2( ctx->smooth_window / 2, - sizeof(DebugMatches) + sizeof(DebugMatches), 0 ); if (!ctx->abs_motion.debug_matches) { @@ -1424,12 +1408,9 @@ static int filter_frame(AVFilterLink *link, AVFrame *input_frame) const float luma_h_over_chroma_h = ((float)input_frame->height / (float)chroma_height); if (deshake_ctx->debug_on) { - av_fifo_generic_read( + av_fifo_read( deshake_ctx->abs_motion.debug_matches, - &debug_matches, - sizeof(DebugMatches), - NULL - ); + &debug_matches, 1); } if (input_frame->pkt_duration) { @@ -1441,13 +1422,9 @@ static int filter_frame(AVFilterLink *link, AVFrame *input_frame) // Get the absolute transform data for this frame for (int i = 0; i < RingbufCount; i++) { - av_fifo_generic_peek_at( - deshake_ctx->abs_motion.ringbuffers[i], - &old_vals[i], - deshake_ctx->abs_motion.curr_frame_offset * sizeof(float), - sizeof(float), - NULL - ); + av_fifo_peek(deshake_ctx->abs_motion.ringbuffers[i], + &old_vals[i], 1, + deshake_ctx->abs_motion.curr_frame_offset); } if (deshake_ctx->tripod_mode) { @@ -1842,7 +1819,7 @@ static int queue_frame(AVFilterLink *link, AVFrame *input_frame) { sizeof(cl_mem), &deshake_ctx->brief_pattern} ); - if (av_fifo_size(deshake_ctx->abs_motion.ringbuffers[RingbufX]) == 0) { + if (!av_fifo_can_read(deshake_ctx->abs_motion.ringbuffers[RingbufX])) { // This is the first frame we've been given to queue, meaning there is // no previous frame to match descriptors to @@ -1892,7 +1869,7 @@ static int queue_frame(AVFilterLink *link, AVFrame *input_frame) // old data (and just treat them all as part of the new values) if (deshake_ctx->abs_motion.data_end_offset == -1) { deshake_ctx->abs_motion.data_end_offset = - av_fifo_size(deshake_ctx->abs_motion.ringbuffers[RingbufX]) / sizeof(float) - 1; + av_fifo_can_read(deshake_ctx->abs_motion.ringbuffers[RingbufX]) - 1; } goto no_motion_data; @@ -1934,13 +1911,10 @@ static int queue_frame(AVFilterLink *link, AVFrame *input_frame) // Get the absolute transform data for the previous frame for (int i = 0; i < RingbufCount; i++) { - av_fifo_generic_peek_at( + av_fifo_peek( deshake_ctx->abs_motion.ringbuffers[i], - &prev_vals[i], - av_fifo_size(deshake_ctx->abs_motion.ringbuffers[i]) - sizeof(float), - sizeof(float), - NULL - ); + &prev_vals[i], 1, + av_fifo_can_read(deshake_ctx->abs_motion.ringbuffers[i]) - 1); } new_vals[RingbufX] = prev_vals[RingbufX] + relative.translation.s[0]; @@ -2011,21 +1985,13 @@ end: } debug_matches.num_matches = num_vectors; - av_fifo_generic_write( + av_fifo_write( deshake_ctx->abs_motion.debug_matches, - &debug_matches, - sizeof(DebugMatches), - NULL - ); + &debug_matches, 1); } for (int i = 0; i < RingbufCount; i++) { - av_fifo_generic_write( - deshake_ctx->abs_motion.ringbuffers[i], - &new_vals[i], - sizeof(float), - NULL - ); + av_fifo_write(deshake_ctx->abs_motion.ringbuffers[i], &new_vals[i], 1); } return ff_framequeue_add(&deshake_ctx->fq, input_frame); @@ -2063,9 +2029,9 @@ static int activate(AVFilterContext *ctx) // If there is no more space in the ringbuffers, remove the oldest // values to make room for the new ones - if (av_fifo_space(deshake_ctx->abs_motion.ringbuffers[RingbufX]) == 0) { + if (!av_fifo_can_write(deshake_ctx->abs_motion.ringbuffers[RingbufX])) { for (int i = 0; i < RingbufCount; i++) { - av_fifo_drain(deshake_ctx->abs_motion.ringbuffers[i], sizeof(float)); + av_fifo_drain2(deshake_ctx->abs_motion.ringbuffers[i], 1); } } ret = queue_frame(inlink, frame); @@ -2092,7 +2058,7 @@ static int activate(AVFilterContext *ctx) // Finish processing the rest of the frames in the queue. while(ff_framequeue_queued_frames(&deshake_ctx->fq) != 0) { for (int i = 0; i < RingbufCount; i++) { - av_fifo_drain(deshake_ctx->abs_motion.ringbuffers[i], sizeof(float)); + av_fifo_drain2(deshake_ctx->abs_motion.ringbuffers[i], 1); } ret = filter_frame(inlink, ff_framequeue_take(&deshake_ctx->fq)); -- 2.32.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".