[FFmpeg-devel] [PATCH 2/9] lavf: add a header for generic-layer interfaces
Anton Khirnov
anton at khirnov.net
Sun Oct 13 14:24:11 EEST 2024
Analogous to what was previously done in avcodec and avfilter.
---
libavdevice/alldevices.c | 2 +-
libavformat/allformats.c | 1 +
libavformat/avformat.c | 1 +
libavformat/avformat_internal.h | 93 +++++++++++++++++++++++++++++++++
libavformat/demux.c | 1 +
libavformat/demux.h | 16 ------
libavformat/internal.h | 45 ----------------
libavformat/mux.c | 1 +
libavformat/options.c | 1 +
libavformat/seek.c | 1 +
10 files changed, 100 insertions(+), 62 deletions(-)
create mode 100644 libavformat/avformat_internal.h
diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
index 9b9a9146c7..3f0e6101a5 100644
--- a/libavdevice/alldevices.c
+++ b/libavdevice/alldevices.c
@@ -20,8 +20,8 @@
#include "libavutil/attributes.h"
#include "libavutil/attributes_internal.h"
+#include "libavformat/avformat_internal.h"
#include "libavformat/demux.h"
-#include "libavformat/internal.h"
#include "libavformat/mux.h"
#include "avdevice.h"
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 305fa46532..445f13f42a 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -25,6 +25,7 @@
#include "libavformat/internal.h"
#include "avformat.h"
+#include "avformat_internal.h"
#include "demux.h"
#include "mux.h"
diff --git a/libavformat/avformat.c b/libavformat/avformat.c
index 89ee669bf9..471e148af4 100644
--- a/libavformat/avformat.c
+++ b/libavformat/avformat.c
@@ -36,6 +36,7 @@
#include "libavcodec/codec_desc.h"
#include "libavcodec/packet_internal.h"
#include "avformat.h"
+#include "avformat_internal.h"
#include "avio.h"
#include "demux.h"
#include "mux.h"
diff --git a/libavformat/avformat_internal.h b/libavformat/avformat_internal.h
new file mode 100644
index 0000000000..a1079fe122
--- /dev/null
+++ b/libavformat/avformat_internal.h
@@ -0,0 +1,93 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * APIs internal to the generic avformat layer.
+ *
+ * MUST NOT be included by individual muxers or demuxers.
+ */
+
+#ifndef AVFORMAT_AVFORMAT_INTERNAL_H
+#define AVFORMAT_AVFORMAT_INTERNAL_H
+
+#include <stdint.h>
+
+#include "avformat.h"
+
+#define RELATIVE_TS_BASE (INT64_MAX - (1LL << 48))
+
+static av_always_inline int is_relative(int64_t ts)
+{
+ return ts > (RELATIVE_TS_BASE - (1LL << 48));
+}
+
+/**
+ * Wrap a given time stamp, if there is an indication for an overflow
+ *
+ * @param st stream
+ * @param timestamp the time stamp to wrap
+ * @return resulting time stamp
+ */
+int64_t ff_wrap_timestamp(const AVStream *st, int64_t timestamp);
+
+typedef struct FFStreamGroup {
+ /**
+ * The public context.
+ */
+ AVStreamGroup pub;
+
+ AVFormatContext *fmtctx;
+} FFStreamGroup;
+
+static av_always_inline FFStreamGroup *ffstreamgroup(AVStreamGroup *stg)
+{
+ return (FFStreamGroup*)stg;
+}
+
+static av_always_inline const FFStreamGroup *cffstreamgroup(const AVStreamGroup *stg)
+{
+ return (const FFStreamGroup*)stg;
+}
+
+void ff_flush_packet_queue(AVFormatContext *s);
+
+const struct AVCodec *ff_find_decoder(AVFormatContext *s, const AVStream *st,
+ enum AVCodecID codec_id);
+
+/**
+ * Frees a stream without modifying the corresponding AVFormatContext.
+ * Must only be called if the latter doesn't matter or if the stream
+ * is not yet attached to an AVFormatContext.
+ */
+void ff_free_stream(AVStream **st);
+
+/**
+ * Frees a stream group without modifying the corresponding AVFormatContext.
+ * Must only be called if the latter doesn't matter or if the stream
+ * is not yet attached to an AVFormatContext.
+ */
+void ff_free_stream_group(AVStreamGroup **pstg);
+
+int ff_is_intra_only(enum AVCodecID id);
+
+struct FFOutputFormat;
+struct FFInputFormat;
+void avpriv_register_devices(const struct FFOutputFormat * const o[],
+ const struct FFInputFormat * const i[]);
+
+#endif // AVFORMAT_AVFORMAT_INTERNAL_H
diff --git a/libavformat/demux.c b/libavformat/demux.c
index 4fd22c4934..902056452d 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -43,6 +43,7 @@
#include "libavcodec/raw.h"
#include "avformat.h"
+#include "avformat_internal.h"
#include "avio_internal.h"
#include "demux.h"
#include "id3v2.h"
diff --git a/libavformat/demux.h b/libavformat/demux.h
index 9c76095662..647011affb 100644
--- a/libavformat/demux.h
+++ b/libavformat/demux.h
@@ -170,22 +170,6 @@ typedef struct FFStreamInfo {
*/
#define FFERROR_REDO FFERRTAG('R','E','D','O')
-#define RELATIVE_TS_BASE (INT64_MAX - (1LL << 48))
-
-static av_always_inline int is_relative(int64_t ts)
-{
- return ts > (RELATIVE_TS_BASE - (1LL << 48));
-}
-
-/**
- * Wrap a given time stamp, if there is an indication for an overflow
- *
- * @param st stream
- * @param timestamp the time stamp to wrap
- * @return resulting time stamp
- */
-int64_t ff_wrap_timestamp(const AVStream *st, int64_t timestamp);
-
/**
* Read a transport packet from a media file.
*
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 489a7cad08..0f31962d52 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -426,26 +426,6 @@ static av_always_inline const FFStream *cffstream(const AVStream *st)
return (const FFStream*)st;
}
-typedef struct FFStreamGroup {
- /**
- * The public context.
- */
- AVStreamGroup pub;
-
- AVFormatContext *fmtctx;
-} FFStreamGroup;
-
-
-static av_always_inline FFStreamGroup *ffstreamgroup(AVStreamGroup *stg)
-{
- return (FFStreamGroup*)stg;
-}
-
-static av_always_inline const FFStreamGroup *cffstreamgroup(const AVStreamGroup *stg)
-{
- return (const FFStreamGroup*)stg;
-}
-
#ifdef __GNUC__
#define dynarray_add(tab, nb_ptr, elem)\
do {\
@@ -461,9 +441,6 @@ do {\
} while(0)
#endif
-
-void ff_flush_packet_queue(AVFormatContext *s);
-
/**
* Automatically create sub-directories
*
@@ -591,9 +568,6 @@ void ff_parse_key_value(const char *str, ff_parse_key_val_cb callback_get_buf,
enum AVCodecID ff_guess_image2_codec(const char *filename);
-const struct AVCodec *ff_find_decoder(AVFormatContext *s, const AVStream *st,
- enum AVCodecID codec_id);
-
/**
* Set the time base and wrapping info for a given stream. This will be used
* to interpret the stream's timestamps. If the new time base is invalid
@@ -615,24 +589,12 @@ void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits,
*/
int ff_framehash_write_header(AVFormatContext *s);
-/**
- * Frees a stream without modifying the corresponding AVFormatContext.
- * Must only be called if the latter doesn't matter or if the stream
- * is not yet attached to an AVFormatContext.
- */
-void ff_free_stream(AVStream **st);
/**
* Remove a stream from its AVFormatContext and free it.
* The stream must be the last stream of the AVFormatContext.
*/
void ff_remove_stream(AVFormatContext *s, AVStream *st);
-/**
- * Frees a stream group without modifying the corresponding AVFormatContext.
- * Must only be called if the latter doesn't matter or if the stream
- * is not yet attached to an AVFormatContext.
- */
-void ff_free_stream_group(AVStreamGroup **pstg);
/**
* Remove a stream group from its AVFormatContext and free it.
* The stream group must be the last stream group of the AVFormatContext.
@@ -643,8 +605,6 @@ unsigned int ff_codec_get_tag(const AVCodecTag *tags, enum AVCodecID id);
enum AVCodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag);
-int ff_is_intra_only(enum AVCodecID id);
-
/**
* Select a PCM codec based on the given parameters.
*
@@ -752,9 +712,4 @@ int ff_match_url_ext(const char *url, const char *extensions);
int ff_get_frame_filename(char *buf, int buf_size, const char *path,
int64_t number, int flags);
-struct FFOutputFormat;
-struct FFInputFormat;
-void avpriv_register_devices(const struct FFOutputFormat * const o[],
- const struct FFInputFormat * const i[]);
-
#endif /* AVFORMAT_INTERNAL_H */
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 011de51ddd..7d2435c49f 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -20,6 +20,7 @@
*/
#include "avformat.h"
+#include "avformat_internal.h"
#include "internal.h"
#include "mux.h"
#include "version.h"
diff --git a/libavformat/options.c b/libavformat/options.c
index 039f1eea42..10d6ce2d35 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
+#include "avformat_internal.h"
#include "avio_internal.h"
#include "demux.h"
#include "internal.h"
diff --git a/libavformat/seek.c b/libavformat/seek.c
index 800ef40576..9822f9d83d 100644
--- a/libavformat/seek.c
+++ b/libavformat/seek.c
@@ -29,6 +29,7 @@
#include "libavcodec/avcodec.h"
#include "avformat.h"
+#include "avformat_internal.h"
#include "avio_internal.h"
#include "demux.h"
#include "internal.h"
--
2.43.0
More information about the ffmpeg-devel
mailing list