From patchwork Tue Jan 11 20:45:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 33258 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp4049886iog; Tue, 11 Jan 2022 12:51:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQdVNgca+4jv6kbekwHnJCes95ETuaDs32RQPNvJlqZCEgNd8ZPqeHnOExng8+Y+VXDhQn X-Received: by 2002:aa7:ce8b:: with SMTP id y11mr6104353edv.54.1641934290822; Tue, 11 Jan 2022 12:51:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641934290; cv=none; d=google.com; s=arc-20160816; b=AUw4L394SRQg6tNnQC48wemtsw915lJ3XYsEfwgQuey7Do9C4x8Jda8OzPx4WhjoYI BoV4ovYXc9bUO52dLdi96B3m5Xb+oGCdDVISWB7YGJnzX3J/QH0sIFuCb7gRr1/WBXtS YIRNq4jZwUx6CzzLWrp1ESD/g0vdzTUGMkliWu1qsFd1HMNhEN1pPmTZPQK6cn/UKdzz 9u42WhmpXrgZYnN8Ovrw7NXBxV5gTL+kcIyri39BzKOEU1wt9o6++3LOu+4loWGf0xsR 5B4qeWnKxFO0m/gBWV7dM3M0dWlgJ+iuIZa7E2pJE9ESwy7L6a+cUUQwg3ZCy48+8GG9 pRFw== 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=xH/QxFasKWa0i4zJJM12kxgoChIlOkxS0umTVrIOKSY=; b=oRb3oeqWl4By+ZhqqEF3pwVPolFCxA5RyU21XA+Ax7r58p+aUUJvh73B/zJi7uEIvx bWyctYxc7OlRnSUOPiGgsBDfqsUQ5fJSaDBz4Ca/BVLoVYXWBtCOwXSd/dM0ovQEYH+S Km/BQAR9wVGPCK641pkk3h+jDYVq5PLNr9VMESyQwkn23sJ/L299JPsoAX3Q4JbT8m3V t6A3jgPBv3Z+X4ZgWDFJYS0pB5OF6GoxWUw3/15R+9llTcYlmy4wjz/4b6qkcOC2noLb JwCN9GRIMIN/RVK513/sasYjGK/sFYi6oNoQE1OTlqo1g4Mce22CTs3jg9/qULZV8zSF Jv/g== 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 du16si5513266ejc.905.2022.01.11.12.51.30; Tue, 11 Jan 2022 12:51:30 -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 7269D68AFE7; Tue, 11 Jan 2022 22:47:56 +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 E497668AF2E for ; Tue, 11 Jan 2022 22:47:32 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 0B2EE24055A for ; Tue, 11 Jan 2022 21:47:31 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ivEzWt_PxDGJ for ; Tue, 11 Jan 2022 21:47:30 +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 206AB240590 for ; Tue, 11 Jan 2022 21:47:26 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 4856A3A0D18; Tue, 11 Jan 2022 21:47:25 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 11 Jan 2022 21:45:58 +0100 Message-Id: <20220111204610.14262-23-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 23/35] lavf/dvenc: 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: RkcC44rV/Pga --- libavformat/dvenc.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c index 03b63cff89..b9c9ba236d 100644 --- a/libavformat/dvenc.c +++ b/libavformat/dvenc.c @@ -202,7 +202,7 @@ static void dv_inject_audio(DVMuxContext *c, int channel, uint8_t* frame_ptr) continue; // FIXME: maybe we have to admit that DV is a big-endian PCM - av_fifo_generic_peek_at(c->audio_data[channel], frame_ptr + d, of * 2, 2, NULL); + av_fifo_peek(c->audio_data[channel], frame_ptr + d, 2, of * 2); FFSWAP(uint8_t, frame_ptr[d], frame_ptr[d + 1]); } frame_ptr += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */ @@ -272,16 +272,16 @@ static int dv_assemble_frame(AVFormatContext *s, for (i = 0; i < c->n_ast && st != c->ast[i]; i++); /* FIXME: we have to have more sensible approach than this one */ - if (av_fifo_size(c->audio_data[i]) + data_size >= 100*MAX_AUDIO_FRAME_SIZE) { + if (av_fifo_can_write(c->audio_data[i]) < data_size) { av_log(s, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient video data or severe sync problem.\n", c->frames); return AVERROR(EINVAL); } - av_fifo_generic_write(c->audio_data[i], data, data_size, NULL); + av_fifo_write(c->audio_data[i], data, data_size); reqasize = 4 * dv_audio_frame_size(c->sys, c->frames, st->codecpar->sample_rate); /* Let us see if we've got enough audio for one DV frame. */ - c->has_audio |= ((reqasize <= av_fifo_size(c->audio_data[i])) << i); + c->has_audio |= ((reqasize <= av_fifo_can_read(c->audio_data[i])) << i); break; default: @@ -295,8 +295,8 @@ static int dv_assemble_frame(AVFormatContext *s, for (i=0; i < c->n_ast; i++) { dv_inject_audio(c, i, *frame); reqasize = 4 * dv_audio_frame_size(c->sys, c->frames, c->ast[i]->codecpar->sample_rate); - av_fifo_drain(c->audio_data[i], reqasize); - c->has_audio |= ((reqasize <= av_fifo_size(c->audio_data[i])) << i); + av_fifo_drain2(c->audio_data[i], reqasize); + c->has_audio |= ((reqasize <= av_fifo_can_read(c->audio_data[i])) << i); } c->has_video = 0; @@ -374,9 +374,11 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s) ff_parse_creation_time_metadata(s, &c->start_time, 1); for (i=0; i < c->n_ast; i++) { - if (c->ast[i] && !(c->audio_data[i]=av_fifo_alloc_array(100, MAX_AUDIO_FRAME_SIZE))) { + if (!c->ast[i]) + continue; + c->audio_data[i] = av_fifo_alloc2(100 * MAX_AUDIO_FRAME_SIZE, 1, 0); + if (!c->audio_data[i]) goto bail_out; - } } return c;