From patchwork Mon Feb 24 12:37:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 17914 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 1689F44A135 for ; Mon, 24 Feb 2020 14:39:43 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 04BA568B597; Mon, 24 Feb 2020 14:39:43 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.red.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D948868B59A for ; Mon, 24 Feb 2020 14:39:40 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail.red.khirnov.net (Postfix) with ESMTP id 92A5A2951A7 for ; Mon, 24 Feb 2020 13:39:40 +0100 (CET) Received: from mail.red.khirnov.net ([IPv6:::1]) by localhost (mail.red.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id z46WjyV-vQ3z for ; Mon, 24 Feb 2020 13:39:40 +0100 (CET) Received: from quelana.khirnov.net (unknown [IPv6:2002:b061:f0a:201:5e:e696:5100:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) client-signature RSA-PSS (2048 bits)) (Client CN "quelana.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail.red.khirnov.net (Postfix) with ESMTPS id 2A5D0295126 for ; Mon, 24 Feb 2020 13:39:40 +0100 (CET) Received: from localhost (quelana.khirnov.net [IPv6:::1]) by quelana.khirnov.net (Postfix) with ESMTP id CC45B2522B for ; Mon, 24 Feb 2020 13:39:39 +0100 (CET) Received: from quelana.khirnov.net ([IPv6:::1]) by localhost (quelana.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id TZcBAND9mzzi for ; Mon, 24 Feb 2020 13:39:14 +0100 (CET) Received: from libav.daenerys.khirnov.net (libav.daenerys.khirnov.net [IPv6:2a00:c500:561:201::7]) by quelana.khirnov.net (Postfix) with ESMTP id 6939325225 for ; Mon, 24 Feb 2020 13:39:14 +0100 (CET) Received: by libav.daenerys.khirnov.net (Postfix, from userid 1000) id D3AC220E0017; Mon, 24 Feb 2020 13:39:10 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 24 Feb 2020 13:37:28 +0100 Message-Id: <20200224123739.31154-2-anton@khirnov.net> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200224123739.31154-1-anton@khirnov.net> References: <20200224123739.31154-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/12] fifo: uninline av_fifo_peek2() on the next major bump X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" Inline public functions should be avoided unless absolutely necessary, and no such necessity exists in this code. --- libavutil/fifo.c | 13 +++++++++++++ libavutil/fifo.h | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/libavutil/fifo.c b/libavutil/fifo.c index 1060aedf13..0baaadc521 100644 --- a/libavutil/fifo.c +++ b/libavutil/fifo.c @@ -23,6 +23,7 @@ #include "avassert.h" #include "common.h" #include "fifo.h" +#include "version.h" static AVFifoBuffer *fifo_alloc_common(void *buffer, size_t size) { @@ -238,3 +239,15 @@ void av_fifo_drain(AVFifoBuffer *f, int size) f->rptr -= f->end - f->buffer; f->rndx += size; } + +#if LIBAVUTIL_VERSION_MAJOR >= 57 +uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs); +{ + uint8_t *ptr = f->rptr + offs; + if (ptr >= f->end) + ptr = f->buffer + (ptr - f->end); + else if (ptr < f->buffer) + ptr = f->end - (f->buffer - ptr); + return ptr; +} +#endif diff --git a/libavutil/fifo.h b/libavutil/fifo.h index dc7bc6f0dd..8cd964ef45 100644 --- a/libavutil/fifo.h +++ b/libavutil/fifo.h @@ -27,6 +27,7 @@ #include #include "avutil.h" #include "attributes.h" +#include "version.h" typedef struct AVFifoBuffer { uint8_t *buffer; @@ -166,6 +167,7 @@ void av_fifo_drain(AVFifoBuffer *f, int size); * point outside to the buffer data. * The used buffer size can be checked with av_fifo_size(). */ +#if LIBAVUTIL_VERSION_MAJOR < 57 static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs) { uint8_t *ptr = f->rptr + offs; @@ -175,5 +177,8 @@ static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs) ptr = f->end - (f->buffer - ptr); return ptr; } +#else +uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs); +#endif #endif /* AVUTIL_FIFO_H */