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 B38F042B05 for ; Tue, 11 Jan 2022 20:48:59 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C438B68AF80; Tue, 11 Jan 2022 22:47:41 +0200 (EET) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1A24868AEAF for ; Tue, 11 Jan 2022 22:47:34 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 77BB52404FE for ; Tue, 11 Jan 2022 21:47:33 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id g-NVOgpIH7Jg for ; Tue, 11 Jan 2022 21:47:32 +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 3B164240593 for ; Tue, 11 Jan 2022 21:47:26 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 2F1B03A0BC7; Tue, 11 Jan 2022 21:47:25 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 11 Jan 2022 21:45:52 +0100 Message-Id: <20220111204610.14262-17-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 17/35] lavc/libvpxenc: switch to the 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: --- libavcodec/libvpxenc.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 10e5a22fa9..55f587c490 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -324,20 +324,11 @@ static av_cold void free_frame_list(struct FrameListData *list) } } -static av_cold int add_hdr10_plus(AVFifoBuffer *fifo, struct FrameHDR10Plus *data) -{ - int err = av_fifo_grow(fifo, sizeof(*data)); - if (err < 0) - return err; - av_fifo_generic_write(fifo, data, sizeof(*data), NULL); - return 0; -} - static av_cold void free_hdr10_plus_fifo(AVFifoBuffer **fifo) { FrameHDR10Plus frame_hdr10_plus; - while (av_fifo_size(*fifo) >= sizeof(frame_hdr10_plus)) { - av_fifo_generic_read(*fifo, &frame_hdr10_plus, sizeof(frame_hdr10_plus), NULL); + while (av_fifo_can_read(*fifo)) { + av_fifo_read(*fifo, &frame_hdr10_plus, 1); av_buffer_unref(&frame_hdr10_plus.hdr10_plus); } av_fifo_freep(fifo); @@ -347,16 +338,12 @@ static int copy_hdr10_plus_to_pkt(AVFifoBuffer *fifo, AVPacket *pkt) { FrameHDR10Plus frame_hdr10_plus; uint8_t *data; - if (!pkt) - return 0; - if (av_fifo_size(fifo) < sizeof(frame_hdr10_plus)) + if (!pkt || !av_fifo_can_read(fifo)) return 0; - av_fifo_generic_peek(fifo, &frame_hdr10_plus, sizeof(frame_hdr10_plus), NULL); + av_fifo_peek(fifo, &frame_hdr10_plus, 1, 0); if (!frame_hdr10_plus.hdr10_plus || frame_hdr10_plus.pts != pkt->pts) return 0; - av_fifo_generic_read(fifo, &frame_hdr10_plus, sizeof(frame_hdr10_plus), NULL); - if (!frame_hdr10_plus.hdr10_plus) - return 0; + av_fifo_drain2(fifo, 1); data = av_packet_new_side_data(pkt, AV_PKT_DATA_DYNAMIC_HDR10_PLUS, frame_hdr10_plus.hdr10_plus->size); if (!data) { @@ -933,7 +920,8 @@ static av_cold int vpx_init(AVCodecContext *avctx, // it has PQ trc (SMPTE2084). if (enccfg.g_bit_depth > 8 && avctx->color_trc == AVCOL_TRC_SMPTE2084) { ctx->discard_hdr10_plus = 0; - ctx->hdr10_plus_fifo = av_fifo_alloc(sizeof(FrameHDR10Plus)); + ctx->hdr10_plus_fifo = av_fifo_alloc2(1, sizeof(FrameHDR10Plus), + AV_FIFO_FLAG_AUTO_GROW); if (!ctx->hdr10_plus_fifo) return AVERROR(ENOMEM); } @@ -1727,7 +1715,7 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket *pkt, data.hdr10_plus = av_buffer_ref(hdr10_plus_metadata->buf); if (!data.hdr10_plus) return AVERROR(ENOMEM); - err = add_hdr10_plus(ctx->hdr10_plus_fifo, &data); + err = av_fifo_write(ctx->hdr10_plus_fifo, &data, 1); if (err < 0) { av_buffer_unref(&data.hdr10_plus); return err; -- 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".