[FFmpeg-devel] [PATCH 3/6] avformat: add support for demuxers/inputs from avradio
Michael Niedermayer
michael at niedermayer.cc
Sat Jul 22 22:29:54 EEST 2023
This avoids keeping diffs for libavformat in the libavradio repository
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
libavformat/allformats.c | 32 +++++++++++++++++++++++++-------
libavformat/internal.h | 1 +
2 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 6324952bd2..27a32028dd 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -570,6 +570,7 @@ extern const AVInputFormat ff_vapoursynth_demuxer;
static atomic_uintptr_t indev_list_intptr = ATOMIC_VAR_INIT(0);
static atomic_uintptr_t outdev_list_intptr = ATOMIC_VAR_INIT(0);
+static atomic_uintptr_t inradio_list_intptr= ATOMIC_VAR_INIT(0);
const AVOutputFormat *av_muxer_iterate(void **opaque)
{
@@ -594,20 +595,32 @@ const AVOutputFormat *av_muxer_iterate(void **opaque)
const AVInputFormat *av_demuxer_iterate(void **opaque)
{
- static const uintptr_t size = sizeof(demuxer_list)/sizeof(demuxer_list[0]) - 1;
uintptr_t i = (uintptr_t)*opaque;
const AVInputFormat *f = NULL;
uintptr_t tmp;
- if (i < size) {
- f = demuxer_list[i];
- } else if (tmp = atomic_load_explicit(&indev_list_intptr, memory_order_relaxed)) {
- const AVInputFormat *const *indev_list = (const AVInputFormat *const *)tmp;
- f = indev_list[i - size];
+ if (i % 4 == 0) {
+ f = demuxer_list[i/4];
+ if (!f)
+ i = 1;
+ }
+ if (i % 4 == 1) {
+ if(tmp = atomic_load_explicit(&indev_list_intptr, memory_order_relaxed)) {
+ const AVInputFormat *const *indev_list = (const AVInputFormat *const *)tmp;
+ f = indev_list[i/4];
+ }
+ if (!f)
+ i = 2;
+ }
+ if (i % 4 == 2) {
+ if(tmp = atomic_load_explicit(&inradio_list_intptr, memory_order_relaxed)) {
+ const AVInputFormat *const *indev_list = (const AVInputFormat *const *)tmp;
+ f = indev_list[i/4];
+ }
}
if (f)
- *opaque = (void*)(i + 1);
+ *opaque = (void*)(i + 4);
return f;
}
@@ -616,3 +629,8 @@ void avpriv_register_devices(const FFOutputFormat * const o[], const AVInputForm
atomic_store_explicit(&outdev_list_intptr, (uintptr_t)o, memory_order_relaxed);
atomic_store_explicit(&indev_list_intptr, (uintptr_t)i, memory_order_relaxed);
}
+
+void avpriv_register_radios(const FFOutputFormat * const o[], const AVInputFormat * const i[])
+{
+ atomic_store_explicit(&inradio_list_intptr, (uintptr_t)i, memory_order_relaxed);
+}
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 9fc980601f..aa6b8b21a9 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -719,5 +719,6 @@ int ff_match_url_ext(const char *url, const char *extensions);
struct FFOutputFormat;
void avpriv_register_devices(const struct FFOutputFormat * const o[], const AVInputFormat * const i[]);
+void avpriv_register_radios(const struct FFOutputFormat * const o[], const AVInputFormat * const i[]);
#endif /* AVFORMAT_INTERNAL_H */
--
2.17.1
More information about the ffmpeg-devel
mailing list