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 43FA942B12 for ; Tue, 11 Jan 2022 20:49:38 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CACA668AF8D; Tue, 11 Jan 2022 22:47:45 +0200 (EET) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B9D3368AEAF for ; Tue, 11 Jan 2022 22:47:35 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 3EFA924017C for ; Tue, 11 Jan 2022 21:47:35 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id TMGUz891PJmX for ; Tue, 11 Jan 2022 21:47:34 +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 478DD240685 for ; Tue, 11 Jan 2022 21:47:26 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 509C93A0631; Tue, 11 Jan 2022 21:47:25 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 11 Jan 2022 21:46:00 +0100 Message-Id: <20220111204610.14262-25-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 25/35] lavf/swfenc: 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: --- libavformat/swfenc.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c index 1fd2ad81a3..ca9a358ccc 100644 --- a/libavformat/swfenc.c +++ b/libavformat/swfenc.c @@ -211,7 +211,7 @@ static int swf_write_header(AVFormatContext *s) } if (par->codec_id == AV_CODEC_ID_MP3) { swf->audio_par = par; - swf->audio_fifo= av_fifo_alloc(AUDIO_FIFO_SIZE); + swf->audio_fifo = av_fifo_alloc2(AUDIO_FIFO_SIZE, 1, 0); if (!swf->audio_fifo) return AVERROR(ENOMEM); } else { @@ -362,6 +362,12 @@ static int swf_write_header(AVFormatContext *s) return 0; } +static int fifo_avio_wrapper(void *opaque, void *buf, size_t *nb_elems) +{ + avio_write(opaque, buf, *nb_elems); + return 0; +} + static int swf_write_video(AVFormatContext *s, AVCodecParameters *par, const uint8_t *buf, int size, unsigned pkt_flags) { @@ -454,12 +460,12 @@ static int swf_write_video(AVFormatContext *s, swf->swf_frame_number++; /* streaming sound always should be placed just before showframe tags */ - if (swf->audio_par && av_fifo_size(swf->audio_fifo)) { - int frame_size = av_fifo_size(swf->audio_fifo); + if (swf->audio_par && av_fifo_can_read(swf->audio_fifo)) { + size_t frame_size = av_fifo_can_read(swf->audio_fifo); put_swf_tag(s, TAG_STREAMBLOCK | TAG_LONG); avio_wl16(pb, swf->sound_samples); avio_wl16(pb, 0); // seek samples - av_fifo_generic_read(swf->audio_fifo, pb, frame_size, (void*)avio_write); + av_fifo_read_to_cb(swf->audio_fifo, fifo_avio_wrapper, pb, &frame_size); put_swf_end_tag(s); /* update FIFO */ @@ -482,12 +488,12 @@ static int swf_write_audio(AVFormatContext *s, if (swf->swf_frame_number == 16000) av_log(s, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n"); - if (av_fifo_size(swf->audio_fifo) + size > AUDIO_FIFO_SIZE) { + if (av_fifo_can_write(swf->audio_fifo) < size) { av_log(s, AV_LOG_ERROR, "audio fifo too small to mux audio essence\n"); return -1; } - av_fifo_generic_write(swf->audio_fifo, buf, size, NULL); + av_fifo_write(swf->audio_fifo, buf, size); swf->sound_samples += av_get_audio_frame_duration2(par, size); /* if audio only stream make sure we add swf frames */ -- 2.33.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".