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 D5C3243092 for ; Thu, 13 Jan 2022 18:21:45 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1BAC968B4E1; Thu, 13 Jan 2022 20:21:43 +0200 (EET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05olkn2079.outbound.protection.outlook.com [40.92.90.79]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1669468B3EF for ; Thu, 13 Jan 2022 20:21:35 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QIZw2facWGxHjgcoJohwBiCvA6uzYQoQEmc6zzIaZrZ1Cq87Qm6iLQs+Bs8/9KhhJDnYP/OllQgmroUkKzBRfjAmxHTF+dbLRJID4Q2lnxVz9H4lm68mpKe2TIIoJARWFFK5u38Ipq8ssPxU1eVuKSovVtTq99RLGtZtTmsUHBBjdcMI5rZOuVjHmEetUOFfpqx9NmapIkblXUu1Kjabav/UvfyHkEDxS4XYnX4mquvaaZcZscsDQGSeket/OfLMhqqGR5WJwo76FXR7x6hg8kbJYV+oNm7EtyTxjjHhi8eTFIOLV5ZQWjPH0daa68ZD2WnuC4K/W7WbDYpc/K4bSA== 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=qcRNeJQ6AYr2CN587ZgQw9HSPmkArNie5im6bNVp15Q=; b=Tr+SoGvIIR7133s8kPME0VwhnIqfzCKW8TUCOTGRehrAGkS6PwKZHCBTH+FQC18Gz45XyFp8bq1cvRyLR0uUxAABEvKNhSVvtgtlCWChScOlJtndRPR+1EZva5b6RoKqPCeLVSq07fC+YXgiqOi4z5unJ6B6JJULbAZhGWKAVn/rrXwYNZBwmJvYt+8yyxnwYQRp1XMBhnUGw25tP1z4e+fBVbcRoq7JqHZuamyDSLk1Zj9v8WhMl55y7YPfvg7U5g70/I9TTABuGYjeSa83KKFbxMCAAIngg3mIMRi5MC0//bBkGYBAyoaNquUXuELW4KkDAqHYJ1P6vzsBQyr/WQ== 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=qcRNeJQ6AYr2CN587ZgQw9HSPmkArNie5im6bNVp15Q=; b=Syv1gDEWCstnRZ3i6slFMQRwdB7n5/PjH/KMJGGyOrqWDjL1A7KBBam4qK1/me52g/5PhhKin0mwCiwDJWfEsc/e+xdO9RcEZmxJFkVJj1+oXg/hnzgioSIC0J0Mc01IBQooj3qby3dOBEwFD5gKUYCSYqJmtZSe/2UIrHH0437sDhq+PskLIx3232EDw/IHcxw5H9l8YS9A9zfUuGUssCg/O9wm/6xSErNHNX1UlMEund4noa52vhA0dblK0QQdu+sbO3Y+y1u69fX49Y+7YnRZ7PiJ1aeWmwcpAYo19BctSs7XDsOzM3SU5K9Gj1FiwaT3heKakU47+06NUnHjVw== Received: from PR3PR03MB6665.eurprd03.prod.outlook.com (2603:10a6:102:7d::6) by DBBPR03MB6699.eurprd03.prod.outlook.com (2603:10a6:10:20b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.9; Thu, 13 Jan 2022 18:21:32 +0000 Received: from PR3PR03MB6665.eurprd03.prod.outlook.com ([fe80::bd94:8238:bf7f:ca2]) by PR3PR03MB6665.eurprd03.prod.outlook.com ([fe80::bd94:8238:bf7f:ca2%5]) with mapi id 15.20.4888.011; Thu, 13 Jan 2022 18:21:32 +0000 Message-ID: Date: Thu, 13 Jan 2022 19:21:31 +0100 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20220111204610.14262-1-anton@khirnov.net> <20220111204610.14262-12-anton@khirnov.net> From: Andreas Rheinhardt In-Reply-To: <20220111204610.14262-12-anton@khirnov.net> X-TMN: [zJsyRESo7f0lxmgcrHNKDMyiEQT64RZ/] X-ClientProxiedBy: AM4PR0902CA0004.eurprd09.prod.outlook.com (2603:10a6:200:9b::14) To PR3PR03MB6665.eurprd03.prod.outlook.com (2603:10a6:102:7d::6) X-Microsoft-Original-Message-ID: <4e934253-0283-4c55-ca66-49f753118748@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 05fe0767-13af-457d-c57c-08d9d6c1867f X-MS-TrafficTypeDiagnostic: DBBPR03MB6699:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pgGHwPFPOeHYr83dCSCoeyTU2onXZYSQ9AsrQ3WMLpn6eL8w3QJb4j+5esnUSc1+62/jB9lIZYCm6vlZEDDrHvY5prufImm6LPmgTyYwzA802JQEnBOcYX0xX6odGTqPOt656kG9QrcakQ8folp9N3iDcz54JfuX+aCiweUts3T1k8qxWoF3cKrHBF5yEG626U35h3055iSf6i7CTMzPMwFRrUc24geVcgFpDMMic6Gtq4bChi6fVwdX9WJQyRFqMKK1YxQxaGXeMVIXmxezkslcgWgrRtcN1suyom/fnChD0xwtXR1VM7+Lz6THRVyOHJMJ2gIOXZj0PK9vhaa31EblIM1yq47yCrtCw3eEF4gyA+8Vs4BRb4Ta/wQ5VpjuBNzxc5nWTexkoHYsNsPNBiWTE5OOqLdv+eeNq56PBybr/Ic41yHDVrhZqLLnygypoTmS4CaH9vlqpjVNcKvAy9a3bugRNm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ekU1clR0U2pXK3Y4Ny9zajQreDJtNVRMa3lvUHdyN2Mz?= =?utf-8?B?SzFwdjVSS284bXR1ZWRXbUVia05RN3d3N01wby9hY3F5Tk9pREZHS1V2N1o2?= =?utf-8?B?emVOaVlzRWhvclNkTkJ2c0RkMVJ4dk4va0lhZjdqdkF2aGQrcDNqL0lLSHda?= =?utf-8?B?aXpZaFdqQnJ4U0xCbzNVQ1FES1lhKzE2amV5V25jZWxPSDBaSGJqVktoamly?= =?utf-8?B?c0RXRzdORjRkUkFkY0owNDNhc1I5Z243cFRHa1cxWmdRYmJ5L0RjM3RlQTlw?= =?utf-8?B?c29WZVFVdXVhOGlBQmFmVE8vSGo3R0c5dW9PMjNKSldKMGJJZEw0aFA1ZXY5?= =?utf-8?B?RVA0anZDQ3MzMngwMGtJbDE1SnpoS1F4M1BkbWFpWWY2eHlPak5NcTFWeE9x?= =?utf-8?B?NkxRNXJ2cnp2MkdzK2V2L3RKMktmQ00vL3g4RmszTFIyRW92WlhYN0U1OGV5?= =?utf-8?B?U3A0Zkh4Z09vSjVXYlVobTZaanRoVTBXNFY0VVF4NitNRWtxaG9NN1ZTNVNn?= =?utf-8?B?NkllU2NsQmhjQ09WMWdmS3lNWmp6VEFDS3pXRnNCUWU5L25TZz09?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 05fe0767-13af-457d-c57c-08d9d6c1867f X-MS-Exchange-CrossTenant-AuthSource: PR3PR03MB6665.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2022 18:21:32.6781 (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: DBBPR03MB6699 Subject: Re: [FFmpeg-devel] [PATCH 12/35] lavc/avcodec: 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 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: Anton Khirnov: > --- > libavcodec/avcodec.c | 15 ++++++--------- > libavcodec/decode.c | 22 ++++++++-------------- > 2 files changed, 14 insertions(+), 23 deletions(-) > > diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c > index c00a9b2af8..a75bbe721f 100644 > --- a/libavcodec/avcodec.c > +++ b/libavcodec/avcodec.c > @@ -183,7 +183,8 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code > avci->es.in_frame = av_frame_alloc(); > avci->in_pkt = av_packet_alloc(); > avci->last_pkt_props = av_packet_alloc(); > - avci->pkt_props = av_fifo_alloc(sizeof(*avci->last_pkt_props)); > + avci->pkt_props = av_fifo_alloc2(1, sizeof(*avci->last_pkt_props), > + AV_FIFO_FLAG_AUTO_GROW); > if (!avci->buffer_frame || !avci->buffer_pkt || > !avci->es.in_frame || !avci->in_pkt || > !avci->last_pkt_props || !avci->pkt_props) { > @@ -399,13 +400,10 @@ void avcodec_flush_buffers(AVCodecContext *avctx) > av_packet_unref(avci->buffer_pkt); > > av_packet_unref(avci->last_pkt_props); > - while (av_fifo_size(avci->pkt_props) >= sizeof(*avci->last_pkt_props)) { > - av_fifo_generic_read(avci->pkt_props, > - avci->last_pkt_props, sizeof(*avci->last_pkt_props), > - NULL); > + while (av_fifo_can_read(avci->pkt_props)) { > + av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1); > av_packet_unref(avci->last_pkt_props); Could be simplified to do { av_packet_unref(avci->last_pkt_props); } while (av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1) >= 0); The same goes for other loop below and probably more loops in the next patches. (This of course presumes that one is allowed to call av_fifo_read() to tentatively read more elements than are currently available. I think this should be allowed.) > } > - av_fifo_reset(avci->pkt_props); > > av_frame_unref(avci->es.in_frame); > av_packet_unref(avci->in_pkt); > @@ -464,10 +462,9 @@ av_cold int avcodec_close(AVCodecContext *avctx) > av_frame_free(&avci->buffer_frame); > av_packet_free(&avci->buffer_pkt); > if (avci->pkt_props) { > - while (av_fifo_size(avci->pkt_props) >= sizeof(*avci->last_pkt_props)) { > + while (av_fifo_can_read(avci->pkt_props)) { > av_packet_unref(avci->last_pkt_props); > - av_fifo_generic_read(avci->pkt_props, avci->last_pkt_props, > - sizeof(*avci->last_pkt_props), NULL); > + av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1); > } > av_fifo_freep(&avci->pkt_props); > } > diff --git a/libavcodec/decode.c b/libavcodec/decode.c > index 0912f86a14..9f6f2e7fa6 100644 > --- a/libavcodec/decode.c > +++ b/libavcodec/decode.c > @@ -165,26 +165,21 @@ static int extract_packet_props(AVCodecInternal *avci, const AVPacket *pkt) > int ret = 0; > > if (IS_EMPTY(avci->last_pkt_props)) { > - if (av_fifo_size(avci->pkt_props) >= sizeof(*pkt)) { > - av_fifo_generic_read(avci->pkt_props, avci->last_pkt_props, > - sizeof(*avci->last_pkt_props), NULL); > + if (av_fifo_can_read(avci->pkt_props)) { > + av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1); > } else if (av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1) < 0) > return copy_packet_props(avci->last_pkt_props, pkt); > } > > - if (av_fifo_space(avci->pkt_props) < sizeof(*pkt)) { > - ret = av_fifo_grow(avci->pkt_props, sizeof(*pkt)); > - if (ret < 0) > - return ret; > - } > - > ret = copy_packet_props(&tmp, pkt); > if (ret < 0) > return ret; > > - av_fifo_generic_write(avci->pkt_props, &tmp, sizeof(tmp), NULL); > + ret = av_fifo_write(avci->pkt_props, &tmp, 1); > + if (ret < 0) > + av_packet_unref(&tmp); > > - return 0; > + return ret; > } > > static int decode_bsfs_init(AVCodecContext *avctx) > @@ -543,9 +538,8 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) > avci->draining_done = 1; > > if (!(avctx->codec->caps_internal & FF_CODEC_CAP_SETS_FRAME_PROPS) && > - IS_EMPTY(avci->last_pkt_props) && av_fifo_size(avci->pkt_props) >= sizeof(*avci->last_pkt_props)) > - av_fifo_generic_read(avci->pkt_props, > - avci->last_pkt_props, sizeof(*avci->last_pkt_props), NULL); > + IS_EMPTY(avci->last_pkt_props) && av_fifo_can_read(avci->pkt_props)) The av_fifo_can_read() check could be dropped. > + av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1); > > if (!ret) { > frame->best_effort_timestamp = guess_correct_pts(avctx, > _______________________________________________ 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".