Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Anton Khirnov <anton@khirnov.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 3/7] lavu/fifo: deprecate av_fifo_peek2()
Date: Fri, 31 Dec 2021 11:53:03 +0100
Message-ID: <20211231105307.30946-3-anton@khirnov.net> (raw)
In-Reply-To: <20211231105307.30946-1-anton@khirnov.net>

It returns a pointer inside the fifo's buffer, which cannot be safely
used without accessing AVFifoBuffer internals. It is easier and safer to
use av_fifo_generic_peek_at().
---
 libavutil/fifo.h       |  4 ++++
 libavutil/tests/fifo.c |  8 --------
 libavutil/version.h    |  1 +
 tests/ref/fate/fifo    | 26 --------------------------
 4 files changed, 5 insertions(+), 34 deletions(-)

diff --git a/libavutil/fifo.h b/libavutil/fifo.h
index dc7bc6f0dd..37da9f14c2 100644
--- a/libavutil/fifo.h
+++ b/libavutil/fifo.h
@@ -156,6 +156,7 @@ int av_fifo_grow(AVFifoBuffer *f, unsigned int additional_space);
  */
 void av_fifo_drain(AVFifoBuffer *f, int size);
 
+#if FF_API_OLD_FIFO
 /**
  * Return a pointer to the data stored in a FIFO buffer at a certain offset.
  * The FIFO buffer is not modified.
@@ -165,7 +166,9 @@ void av_fifo_drain(AVFifoBuffer *f, int size);
  *             than the used buffer size or the returned pointer will
  *             point outside to the buffer data.
  *             The used buffer size can be checked with av_fifo_size().
+ * @deprecated use av_fifo_generic_peek_at()
  */
+attribute_deprecated
 static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs)
 {
     uint8_t *ptr = f->rptr + offs;
@@ -175,5 +178,6 @@ static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs)
         ptr = f->end - (f->buffer - ptr);
     return ptr;
 }
+#endif
 
 #endif /* AVUTIL_FIFO_H */
diff --git a/libavutil/tests/fifo.c b/libavutil/tests/fifo.c
index 8a550e088b..a17d913233 100644
--- a/libavutil/tests/fifo.c
+++ b/libavutil/tests/fifo.c
@@ -30,14 +30,6 @@ int main(void)
     for (i = 0; av_fifo_space(fifo) >= sizeof(int); i++)
         av_fifo_generic_write(fifo, &i, sizeof(int), NULL);
 
-    /* peek at FIFO */
-    n = av_fifo_size(fifo) / sizeof(int);
-    for (i = -n + 1; i < n; i++) {
-        int *v = (int *)av_fifo_peek2(fifo, i * sizeof(int));
-        printf("%d: %d\n", i, *v);
-    }
-    printf("\n");
-
     /* peek_at at FIFO */
     n = av_fifo_size(fifo) / sizeof(int);
     for (i = 0; i < n; i++) {
diff --git a/libavutil/version.h b/libavutil/version.h
index 3cac09cb96..0ba8f2d2d0 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -109,6 +109,7 @@
 #define FF_API_DECLARE_ALIGNED          (LIBAVUTIL_VERSION_MAJOR < 58)
 #define FF_API_COLORSPACE_NAME          (LIBAVUTIL_VERSION_MAJOR < 58)
 #define FF_API_AV_MALLOCZ_ARRAY         (LIBAVUTIL_VERSION_MAJOR < 58)
+#define FF_API_OLD_FIFO                 (LIBAVUTIL_VERSION_MAJOR < 58)
 
 /**
  * @}
diff --git a/tests/ref/fate/fifo b/tests/ref/fate/fifo
index 2b18ed5ffc..1b0e005412 100644
--- a/tests/ref/fate/fifo
+++ b/tests/ref/fate/fifo
@@ -1,29 +1,3 @@
--12: 1
--11: 2
--10: 3
--9: 4
--8: 5
--7: 6
--6: 7
--5: 8
--4: 9
--3: 10
--2: 11
--1: 12
-0: 0
-1: 1
-2: 2
-3: 3
-4: 4
-5: 5
-6: 6
-7: 7
-8: 8
-9: 9
-10: 10
-11: 11
-12: 12
-
 0: 0
 1: 1
 2: 2
-- 
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".

  parent reply	other threads:[~2021-12-31 10:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-31 10:53 [FFmpeg-devel] [PATCH 1/7] lavc/flac_parser: use a custom FIFO implementation Anton Khirnov
2021-12-31 10:53 ` [FFmpeg-devel] [PATCH 2/7] lavf/dvenc: replace av_fifo_peek2() with av_fifo_generic_peek_at() Anton Khirnov
2021-12-31 10:53 ` Anton Khirnov [this message]
2021-12-31 10:53 ` [FFmpeg-devel] [PATCH 4/7] lavu/fifo: simplify av_fifo_alloc() Anton Khirnov
2021-12-31 10:53 ` [FFmpeg-devel] [PATCH 5/7] lavu/fifo: do not copy the whole fifo when reallocating Anton Khirnov
2021-12-31 10:53 ` [FFmpeg-devel] [PATCH 6/7] lavu/fifo: drop useless comments Anton Khirnov
2021-12-31 11:47   ` Andreas Rheinhardt
2021-12-31 10:53 ` [FFmpeg-devel] [PATCH 7/7] lavu/fifo: return errors on trying to read/write too much Anton Khirnov
2021-12-31 11:30 ` [FFmpeg-devel] [PATCH 1/7] lavc/flac_parser: use a custom FIFO implementation Andreas Rheinhardt
2022-01-02 14:24   ` [FFmpeg-devel] [PATCH] " Anton Khirnov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211231105307.30946-3-anton@khirnov.net \
    --to=anton@khirnov.net \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git