From patchwork Tue Jan 11 20:45:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 33242 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp4048267iog; Tue, 11 Jan 2022 12:48:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBBKqKvb2SaPx3M25z5ZTPzHlFEp2p9B6lth9Sb/JvP4pGWHHTqFMasElQTxyctjwNb7iW X-Received: by 2002:a17:907:3e12:: with SMTP id hp18mr4811913ejc.576.1641934132365; Tue, 11 Jan 2022 12:48:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641934132; cv=none; d=google.com; s=arc-20160816; b=LuyYNJVpPm+TAd+zNAkOqmJZbNvPIm8o6UsW6N2dhUPNC/xiKr7r0g+mbSiiR2onMr cXMwqmcqT31mm03YSsK+TA/l3sMoozF6VcvM0KvzU/LK8qQlaWnE9BtcC4PHLPa5iv/d M33UjdZlD7oafb2O6TkhN1iUHOfzY803CS629woBweWkOI5SbOWCAGx6U2Um4crDTSMI l4d1/Uegcxc2BRFmk+bFijd4cq617vhvSMIzUQpLhlQ6/BAhVsb5rQ4Ar+/2pkqL+sT5 2X6bbB5WtpvZ1JIXrvZEuHzGa3/xDQkZbD5sOwmnRBqkA/lEKef/mU6WB4IBl5JJ3x7/ rtWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=bSQTt7xVOheYai4iJ3L+CzmQx6CWR7dDpUPqs1/0iRA=; b=C4f6mlQUkkiF7YerJj7efx/jt1gAGYdSubwDKPBS0PIwxL6fp0slGIHu4BY3Qx8Xap Qq/sq3u2pqwvo+eGr5NTWO6TOfJvUz+xCFjzzgTSIPScUr4S/iSjrPx5X6OmZmr2CbE6 b0mEyT3KlYH5gcC6pROxwZ7+B+UtEOB+PV2L11lWop3h7QkJ4q6muwYeUJbEEv4jpXlb tUI2v5kWRF+B8zkk3bdNN0CfA5vwdDV0nJvDaU1BLAJRIRKN07zSG/xNZY5sWv3bdCQ3 DlcAAQs26gvI9Qlnv4uDIXZ1QQwbYTvDJmifucnDApqIi33PHCUQSLu0EChVelFDoLIn AIIw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id sa41si5313342ejc.888.2022.01.11.12.48.52; Tue, 11 Jan 2022 12:48:52 -0800 (PST) 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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0E15768AF7E; Tue, 11 Jan 2022 22:47:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 19EC568AE87 for ; Tue, 11 Jan 2022 22:47:34 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id E088324056A for ; Tue, 11 Jan 2022 21:47:32 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id mvFidiFG6K-U for ; Tue, 11 Jan 2022 21:47:31 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 1F978240179 for ; Tue, 11 Jan 2022 21:47:26 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 2AE493A0B4A; Tue, 11 Jan 2022 21:47:25 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 11 Jan 2022 21:45:51 +0100 Message-Id: <20220111204610.14262-16-anton@khirnov.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220111204610.14262-1-anton@khirnov.net> References: <20220111204610.14262-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 16/35] lavc/libvorbisenc: 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: /42DN3DBi+Gg --- libavcodec/libvorbisenc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/libvorbisenc.c b/libavcodec/libvorbisenc.c index fa0d5f4b42..8db782b188 100644 --- a/libavcodec/libvorbisenc.c +++ b/libavcodec/libvorbisenc.c @@ -271,7 +271,7 @@ static av_cold int libvorbis_encode_init(AVCodecContext *avctx) avctx->frame_size = LIBVORBIS_FRAME_SIZE; ff_af_queue_init(avctx, &s->afq); - s->pkt_fifo = av_fifo_alloc(BUFFER_SIZE); + s->pkt_fifo = av_fifo_alloc2(BUFFER_SIZE, 1, 0); if (!s->pkt_fifo) { ret = AVERROR(ENOMEM); goto error; @@ -327,12 +327,12 @@ static int libvorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, /* add any available packets to the output packet buffer */ while ((ret = vorbis_bitrate_flushpacket(&s->vd, &op)) == 1) { - if (av_fifo_space(s->pkt_fifo) < sizeof(ogg_packet) + op.bytes) { + if (av_fifo_can_write(s->pkt_fifo) < sizeof(ogg_packet) + op.bytes) { av_log(avctx, AV_LOG_ERROR, "packet buffer is too small\n"); return AVERROR_BUG; } - av_fifo_generic_write(s->pkt_fifo, &op, sizeof(ogg_packet), NULL); - av_fifo_generic_write(s->pkt_fifo, op.packet, op.bytes, NULL); + av_fifo_write(s->pkt_fifo, &op, sizeof(ogg_packet)); + av_fifo_write(s->pkt_fifo, op.packet, op.bytes); } if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "error getting available packets\n"); @@ -345,14 +345,14 @@ static int libvorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, } /* check for available packets */ - if (av_fifo_size(s->pkt_fifo) < sizeof(ogg_packet)) + if (av_fifo_can_read(s->pkt_fifo) < sizeof(ogg_packet)) return 0; - av_fifo_generic_read(s->pkt_fifo, &op, sizeof(ogg_packet), NULL); + av_fifo_read(s->pkt_fifo, &op, sizeof(ogg_packet)); if ((ret = ff_get_encode_buffer(avctx, avpkt, op.bytes, 0)) < 0) return ret; - av_fifo_generic_read(s->pkt_fifo, avpkt->data, op.bytes, NULL); + av_fifo_read(s->pkt_fifo, avpkt->data, op.bytes); avpkt->pts = ff_samples_to_time_base(avctx, op.granulepos);