PR #25789 opened by Romain Beauxis (toots)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25789
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25789.patch
This PR proposes a naming convention for files and folders in the FFmpeg source
tree, to be applied one subsystem at a time. It follows up on a discussion at
the VideoLAN Dev Days (VDD) and was also discussed with @michaelni.
It contains the convention itself, followed by a first pass on Ogg, ID3v2 and
the Vorbis comment code shared with FLAC and Matroska. This is a first step,
after which more PRs will follow.
## Convention
An include path should tell the reader what a file is and which logical group
it belongs to.
A subsystem is the set of files implementing one format, codec or shared
feature, such as Ogg or ID3v2. When it has more than one file, it gets its own
directory. File names inside drop the subsystem prefix and state their role in
full words (`demuxer.c`, `muxer.c`, `reader.c`, `writer.c`), since `dec` means
a decoder in libavcodec but a demuxer in libavformat. A shared header is named
after its subsystem and sits next to its directory, so `#include
"libavformat/id3v2.h"` reads as the subsystem's name.
The full rules are in the new "Source tree layout" section of
`doc/developer.texi`, which `CONTRIBUTING.md` links to.
## First pass
Resulting layout:
```
libavformat/id3v2.h
libavformat/id3v2/{reader,writer}.c
libavformat/ogg/{demuxer,muxer}.c
libavformat/ogg/mapping.h
libavformat/ogg/mapping/{dirac,flac,ogm,opus,skeleton,speex,theora,vorbis,vp8}.c
libavformat/vorbis/comment.h
libavformat/vorbis/comment/{reader,writer}.c
```
`ogg/mapping/` holds the per-codec Ogg mappings (`struct ogg_codec`).
As with the earlier `bsf/`, `aac/`, `hevc/` and `opus/` moves, each move commit
touches only paths, includes, header guards, Makefiles, `MAINTAINERS` and
`CODEOWNERS`. git therefore sees every file as a rename, and patches against
the old paths still apply with `git am -3`.
Only two commits change code. One extracts the Vorbis comment parser from
`oggparsevorbis.c` into `vorbis/comment/reader.c`, so the FLAC and Matroska
demuxers no longer depend on the Ogg demuxer. The other renames the functions
after their new path (`ff_vorbis_comment_read`, `ff_vorbis_comment_write`, ...)
and realigns the lines the rename shifts.
## Testing
Every commit builds and passes the relevant FATE tests. Static builds with a
single component enabled (flac, matroska and ogg demuxers; ogg, opus, flac,
matroska, mp3 and aiff muxers) all link, which confirms no Makefile is missing
an object.
From 78ca1f596dcb1a967e884c37e0efa3cd6d2c86b6 Mon Sep 17 00:00:00 2001
From: Romain Beauxis <[email protected]>
Date: Thu, 5 Nov 2026 10:03:50 -0600
Subject: [PATCH 1/7] doc/developer: add a source tree layout section
The section makes a file's path name what the file is and the logical group it
belongs to.
It sets the rules for subsystem directories, file names, includes, Makefiles
and commits that move files.
---
doc/developer.texi | 69 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/doc/developer.texi b/doc/developer.texi
index 92ccedd381b..9c85aebe640 100644
--- a/doc/developer.texi
+++ b/doc/developer.texi
@@ -380,6 +380,75 @@ letter as they are reserved by the C standard. Names
starting with @code{_}
are reserved at the file level and may not be used for externally visible
symbols. If in doubt, just avoid names starting with @code{_} altogether.
+@anchor{Source tree layout}
+@section Source tree layout
+
+A file's path tells the reader what the file is.
+It also tells the reader which logical group the file belongs to.
+The rules below follow from this principle.
+
+@subsection Directories
+
+A subsystem is the set of files implementing one format, codec or shared
+feature, for example Ogg or ID3v2.
+A subsystem made of more than one file lives in its own directory inside its
+library, for example @file{libavformat/ogg/}.
+A nested directory groups related files within a subsystem, for example the
+per-codec mappings (@code{struct ogg_codec}) in
@file{libavformat/ogg/mapping/}.
+
+@subsection File names
+
+Inside a subsystem directory, file names drop the subsystem prefix.
+The directory already carries it.
+
+A file name states the file's role in full words, for example
+@file{demuxer.c}, @file{muxer.c}, @file{decoder.c}, @file{encoder.c},
+@file{parser.c}, @file{reader.c} or @file{writer.c}.
+Abbreviations would be ambiguous across libraries.
+For example, @samp{dec} means a decoder in libavcodec and a demuxer in
+libavformat.
+
+A header shared by a subsystem is named after it.
+It sits next to the subsystem's directory, for example
@file{libavformat/id3v2.h}
+next to @file{libavformat/id3v2/}.
+Its include path then reads as the subsystem's name.
+
+Existing directories keep their file names until their maintainers move them.
+
+@subsection Includes
+
+A file includes headers from its own directory by their bare name, for example
+@code{#include "mapping.h"}.
+It includes all other headers by their path from the source root, for example
+@code{#include "libavformat/ogg/mapping.h"}.
+The include path then names the group each header belongs to.
+
+@subsection Build system
+
+Each subsystem directory has its own @file{Makefile}.
+It lists the objects of the components the subsystem implements, with paths
+relative to the library, for example
+@code{OBJS-$(CONFIG_OGG_DEMUXER) += ogg/demuxer.o}.
+It also has a @code{clean::} rule for each of its directories.
+The library @file{Makefile} includes it.
+Other components list the subsystem objects they use in their own
+@file{Makefile}.
+
+@subsection Moving files
+
+A commit that moves files changes nothing else.
+It updates only what refers to the moved files: includes, Makefiles,
+@file{MAINTAINERS} and @file{.forgejo/CODEOWNERS}.
+This lets git's rename detection carry pending patches and backports across
+the move.
+Patches written against the old paths apply with @command{git am -3}.
+
+Renaming symbols to match the new layout happens in one commit after the move.
+That commit also realigns the lines the rename shifts.
+
+Each subsystem moves in its own commit.
+Its maintainer leads the move.
+
@section Miscellaneous conventions
@itemize @bullet
--
2.54.0
From 9a85880d37b170598f40e4428bfa5dc374f79983 Mon Sep 17 00:00:00 2001
From: Romain Beauxis <[email protected]>
Date: Thu, 5 Nov 2026 10:03:50 -0600
Subject: [PATCH 2/7] CONTRIBUTING.md: point to the source tree layout rules
The pointer makes the rules visible to contributors and tools that read this
file before the developer documentation.
---
CONTRIBUTING.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 53c4d3a0342..64593787ff4 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -3,3 +3,7 @@
Patches should be submitted to
[Forgejo](https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls) or the [ffmpeg-devel
mailing list](https://lists.ffmpeg.org/mailman3/lists/ffmpeg-devel.ffmpeg.org/)
using `git format-patch` or `git send-email`. Github pull requests should be
avoided because they are not part of our review process and **will be ignored**.
See [https://ffmpeg.org/developer.html](https://ffmpeg.org/developer.html) for
more information.
+
+# Source tree layout
+
+Files are laid out so that a path names what a file is and the logical group
it belongs to. Before adding, renaming or moving files, read the "Source tree
layout" section of `doc/developer.texi`, also published at
[https://ffmpeg.org/developer.html#Source-tree-layout](https://ffmpeg.org/developer.html#Source-tree-layout).
--
2.54.0
From 779a1dcb3948bef1ed9491e19dc914157200e1b4 Mon Sep 17 00:00:00 2001
From: Romain Beauxis <[email protected]>
Date: Thu, 5 Nov 2026 10:14:07 -0600
Subject: [PATCH 3/7] avformat/vorbiscomment: move to vorbis/comment/
The writer moves to vorbis/comment/writer.c and its header to vorbis/comment.h,
following the source tree layout rules.
---
libavformat/Makefile | 21 ++++++++++---------
libavformat/flacenc.c | 2 +-
libavformat/matroskaenc.c | 2 +-
libavformat/oggenc.c | 2 +-
libavformat/oggparsevorbis.c | 2 +-
.../{vorbiscomment.h => vorbis/comment.h} | 10 ++++-----
libavformat/vorbis/comment/Makefile | 2 ++
.../comment/writer.c} | 10 ++++-----
8 files changed, 27 insertions(+), 24 deletions(-)
rename libavformat/{vorbiscomment.h => vorbis/comment.h} (92%)
create mode 100644 libavformat/vorbis/comment/Makefile
rename libavformat/{vorbiscomment.c => vorbis/comment/writer.c} (96%)
diff --git a/libavformat/Makefile b/libavformat/Makefile
index e479c5c67cf..973133dc45f 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -42,6 +42,7 @@ OBJS = allformats.o \
OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o
# subsystems
+include $(SRC_PATH)/libavformat/vorbis/comment/Makefile
OBJS-$(CONFIG_CBS_APV_LAVF) += cbs_apv.o cbs.o
OBJS-$(CONFIG_CBS_AV1_LAVF) += cbs_av1.o cbs.o
OBJS-$(CONFIG_ISO_MEDIA) += isom.o
@@ -228,9 +229,9 @@ OBJS-$(CONFIG_FLAC_DEMUXER) += flacdec.o
rawdec.o \
flac_picture.o \
oggparsevorbis.o \
replaygain.o \
- vorbiscomment.o
+ vorbis/comment/writer.o
OBJS-$(CONFIG_FLAC_MUXER) += flacenc.o flacenc_header.o \
- vorbiscomment.o
+ vorbis/comment/writer.o
OBJS-$(CONFIG_FLIC_DEMUXER) += flic.o
OBJS-$(CONFIG_FLV_DEMUXER) += flvdec.o
OBJS-$(CONFIG_LIVE_FLV_DEMUXER) += flvdec.o
@@ -372,10 +373,10 @@ OBJS-$(CONFIG_M4V_DEMUXER) += m4vdec.o
rawdec.o
OBJS-$(CONFIG_M4V_MUXER) += rawenc.o
OBJS-$(CONFIG_MATROSKA_DEMUXER) += matroskadec.o matroska.o \
flac_picture.o rmsipr.o \
- oggparsevorbis.o vorbiscomment.o \
+ oggparsevorbis.o
vorbis/comment/writer.o \
qtpalette.o replaygain.o
dovi_isom.o
OBJS-$(CONFIG_MATROSKA_MUXER) += matroskaenc.o matroska.o \
- flacenc_header.o vorbiscomment.o \
+ flacenc_header.o
vorbis/comment/writer.o \
wv.o dovi_isom.o
OBJS-$(CONFIG_MCA_DEMUXER) += mca.o
OBJS-$(CONFIG_MCC_DEMUXER) += mccdec.o subtitles.o
@@ -456,18 +457,18 @@ OBJS-$(CONFIG_OGG_DEMUXER) += oggdec.o
\
oggparsevorbis.o \
oggparsevp8.o \
replaygain.o \
- vorbiscomment.o \
+ vorbis/comment/writer.o \
flac_picture.o
OBJS-$(CONFIG_OGA_MUXER) += oggenc.o \
- vorbiscomment.o
+ vorbis/comment/writer.o
OBJS-$(CONFIG_OGG_MUXER) += oggenc.o \
- vorbiscomment.o
+ vorbis/comment/writer.o
OBJS-$(CONFIG_OGV_MUXER) += oggenc.o \
- vorbiscomment.o
+ vorbis/comment/writer.o
OBJS-$(CONFIG_OMA_DEMUXER) += omadec.o pcm.o oma.o
OBJS-$(CONFIG_OMA_MUXER) += omaenc.o rawenc.o oma.o id3v2enc.o
OBJS-$(CONFIG_OPUS_MUXER) += oggenc.o \
- vorbiscomment.o
+ vorbis/comment/writer.o
OBJS-$(CONFIG_OSQ_DEMUXER) += osq.o rawdec.o
OBJS-$(CONFIG_PAF_DEMUXER) += paf.o
OBJS-$(CONFIG_PCM_ALAW_DEMUXER) += pcmdec.o pcm.o
@@ -593,7 +594,7 @@ OBJS-$(CONFIG_SOX_MUXER) += soxenc.o
rawenc.o
OBJS-$(CONFIG_SPDIF_DEMUXER) += spdif.o spdifdec.o
OBJS-$(CONFIG_SPDIF_MUXER) += spdif.o spdifenc.o
OBJS-$(CONFIG_SPEEX_MUXER) += oggenc.o \
- vorbiscomment.o
+ vorbis/comment/writer.o
OBJS-$(CONFIG_SRT_DEMUXER) += srtdec.o subtitles.o
OBJS-$(CONFIG_SRT_MUXER) += srtenc.o
OBJS-$(CONFIG_STL_DEMUXER) += stldec.o subtitles.o
diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index 5397213fa5f..b9e6f6d32a1 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -32,7 +32,7 @@
#include "internal.h"
#include "mux.h"
#include "version.h"
-#include "vorbiscomment.h"
+#include "libavformat/vorbis/comment.h"
typedef struct FlacMuxerContext {
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index a8408da8c1a..795c65b6015 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -39,7 +39,7 @@
#include "mux.h"
#include "riff.h"
#include "version.h"
-#include "vorbiscomment.h"
+#include "libavformat/vorbis/comment.h"
#include "vvc.h"
#include "wv.h"
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index f07b986e136..21243b5af45 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -36,7 +36,7 @@
#include "internal.h"
#include "mux.h"
#include "version.h"
-#include "vorbiscomment.h"
+#include "libavformat/vorbis/comment.h"
#define MAX_PAGE_SIZE 65025
diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
index 4ecc5bd8aa3..f00dbfb5179 100644
--- a/libavformat/oggparsevorbis.c
+++ b/libavformat/oggparsevorbis.c
@@ -37,7 +37,7 @@
#include "flac_picture.h"
#include "internal.h"
#include "oggdec.h"
-#include "vorbiscomment.h"
+#include "libavformat/vorbis/comment.h"
#include "replaygain.h"
static int ogm_chapter(AVFormatContext *as, const uint8_t *key, const uint8_t
*val)
diff --git a/libavformat/vorbiscomment.h b/libavformat/vorbis/comment.h
similarity index 92%
rename from libavformat/vorbiscomment.h
rename to libavformat/vorbis/comment.h
index cd8b325fb6a..2762d63135c 100644
--- a/libavformat/vorbiscomment.h
+++ b/libavformat/vorbis/comment.h
@@ -19,11 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVFORMAT_VORBISCOMMENT_H
-#define AVFORMAT_VORBISCOMMENT_H
+#ifndef AVFORMAT_VORBIS_COMMENT_H
+#define AVFORMAT_VORBIS_COMMENT_H
-#include "avformat.h"
-#include "metadata.h"
+#include "libavformat/avformat.h"
+#include "libavformat/metadata.h"
/**
* Calculate the length in bytes of a VorbisComment. This is the minimum
@@ -54,4 +54,4 @@ int ff_vorbiscomment_write(AVIOContext *pb, const
AVDictionary *m,
extern const AVMetadataConv ff_vorbiscomment_metadata_conv[];
-#endif /* AVFORMAT_VORBISCOMMENT_H */
+#endif /* AVFORMAT_VORBIS_COMMENT_H */
diff --git a/libavformat/vorbis/comment/Makefile
b/libavformat/vorbis/comment/Makefile
new file mode 100644
index 00000000000..73e2ce2c360
--- /dev/null
+++ b/libavformat/vorbis/comment/Makefile
@@ -0,0 +1,2 @@
+clean::
+ $(RM) $(CLEANSUFFIXES:%=libavformat/vorbis/comment/%)
diff --git a/libavformat/vorbiscomment.c b/libavformat/vorbis/comment/writer.c
similarity index 96%
rename from libavformat/vorbiscomment.c
rename to libavformat/vorbis/comment/writer.c
index 09973a576db..c0b8f02a80b 100644
--- a/libavformat/vorbiscomment.c
+++ b/libavformat/vorbis/comment/writer.c
@@ -19,11 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "avio.h"
-#include "avio_internal.h"
-#include "avformat.h"
-#include "metadata.h"
-#include "vorbiscomment.h"
+#include "libavformat/avio.h"
+#include "libavformat/avio_internal.h"
+#include "libavformat/avformat.h"
+#include "libavformat/metadata.h"
+#include "libavformat/vorbis/comment.h"
#include "libavutil/dict.h"
/**
--
2.54.0
From 3868015213d304ec1e3a0f40d88aebcbeaf41262 Mon Sep 17 00:00:00 2001
From: Romain Beauxis <[email protected]>
Date: Thu, 5 Nov 2026 10:15:42 -0600
Subject: [PATCH 4/7] avformat/vorbis/comment: move the Vorbis comment reader
out of the Ogg demuxer
The reader moves from oggparsevorbis.c to vorbis/comment/reader.c and its
declarations to vorbis/comment.h, next to the writer.
The FLAC and Matroska demuxers link the reader instead of the Ogg Vorbis
mapping.
---
libavformat/Makefile | 7 +-
libavformat/flacdec.c | 2 +-
libavformat/matroskadec.c | 2 +-
libavformat/oggdec.h | 22 ----
libavformat/oggparseflac.c | 1 +
libavformat/oggparseogm.c | 1 +
libavformat/oggparseopus.c | 1 +
libavformat/oggparsespeex.c | 1 +
libavformat/oggparsetheora.c | 1 +
libavformat/oggparsevorbis.c | 157 ----------------------
libavformat/oggparsevp8.c | 1 +
libavformat/vorbis/comment.h | 22 ++++
libavformat/vorbis/comment/reader.c | 194 ++++++++++++++++++++++++++++
13 files changed, 228 insertions(+), 184 deletions(-)
create mode 100644 libavformat/vorbis/comment/reader.c
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 973133dc45f..69e5faa16d3 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -227,8 +227,8 @@ OBJS-$(CONFIG_FITS_DEMUXER) += fitsdec.o
OBJS-$(CONFIG_FITS_MUXER) += fitsenc.o
OBJS-$(CONFIG_FLAC_DEMUXER) += flacdec.o rawdec.o \
flac_picture.o \
- oggparsevorbis.o \
replaygain.o \
+ vorbis/comment/reader.o \
vorbis/comment/writer.o
OBJS-$(CONFIG_FLAC_MUXER) += flacenc.o flacenc_header.o \
vorbis/comment/writer.o
@@ -373,7 +373,7 @@ OBJS-$(CONFIG_M4V_DEMUXER) += m4vdec.o
rawdec.o
OBJS-$(CONFIG_M4V_MUXER) += rawenc.o
OBJS-$(CONFIG_MATROSKA_DEMUXER) += matroskadec.o matroska.o \
flac_picture.o rmsipr.o \
- oggparsevorbis.o
vorbis/comment/writer.o \
+ vorbis/comment/reader.o
vorbis/comment/writer.o \
qtpalette.o replaygain.o
dovi_isom.o
OBJS-$(CONFIG_MATROSKA_MUXER) += matroskaenc.o matroska.o \
flacenc_header.o
vorbis/comment/writer.o \
@@ -457,7 +457,8 @@ OBJS-$(CONFIG_OGG_DEMUXER) += oggdec.o
\
oggparsevorbis.o \
oggparsevp8.o \
replaygain.o \
- vorbis/comment/writer.o \
+ vorbis/comment/reader.o \
+ vorbis/comment/writer.o \
flac_picture.o
OBJS-$(CONFIG_OGA_MUXER) += oggenc.o \
vorbis/comment/writer.o
diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index 1f5cfeed71b..a07c8bacbac 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -30,7 +30,7 @@
#include "flac_picture.h"
#include "internal.h"
#include "rawdec.h"
-#include "oggdec.h"
+#include "libavformat/vorbis/comment.h"
#include "replaygain.h"
#define SEEKPOINT_SIZE 18
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index d36cc5c3452..c6f820a0565 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -66,7 +66,7 @@
#include "internal.h"
#include "isom.h"
#include "matroska.h"
-#include "oggdec.h"
+#include "libavformat/vorbis/comment.h"
/* For ff_codec_get_id(). */
#include "riff.h"
#include "rmsipr.h"
diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h
index b7b008cc1f0..107ba12f028 100644
--- a/libavformat/oggdec.h
+++ b/libavformat/oggdec.h
@@ -139,28 +139,6 @@ extern const struct ogg_codec ff_theora_codec;
extern const struct ogg_codec ff_vorbis_codec;
extern const struct ogg_codec ff_vp8_codec;
-/**
- * Parse Vorbis comments
- *
- * @note The buffer will be temporarily modified by this function,
- * so it needs to be writable. Furthermore it must be padded
- * by a single byte (not counted in size).
- * All changes will have been reverted upon return.
- */
-int ff_vorbis_comment(AVFormatContext *ms, AVDictionary **m,
- const uint8_t *buf, int size, int parse_picture);
-
-/**
- * Parse Vorbis comments and add metadata to an AVStream
- *
- * @note The buffer will be temporarily modified by this function,
- * so it needs to be writable. Furthermore it must be padded
- * by a single byte (not counted in size).
- * All changes will have been reverted upon return.
- */
-int ff_vorbis_stream_comment(AVFormatContext *as, AVStream *st,
- const uint8_t *buf, int size);
-
/**
* Parse Vorbis comments, add metadata to an AVStream
*
diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c
index 31dd1439da5..9926c5ebbb9 100644
--- a/libavformat/oggparseflac.c
+++ b/libavformat/oggparseflac.c
@@ -26,6 +26,7 @@
#include "avformat.h"
#include "internal.h"
#include "oggdec.h"
+#include "libavformat/vorbis/comment.h"
#define OGG_FLAC_METADATA_TYPE_STREAMINFO 0x7F
#define OGG_FLAC_MAGIC "\177FLAC"
diff --git a/libavformat/oggparseogm.c b/libavformat/oggparseogm.c
index 1e794745abf..371a05a2c63 100644
--- a/libavformat/oggparseogm.c
+++ b/libavformat/oggparseogm.c
@@ -31,6 +31,7 @@
#include "avformat.h"
#include "internal.h"
#include "oggdec.h"
+#include "libavformat/vorbis/comment.h"
#include "riff.h"
static int
diff --git a/libavformat/oggparseopus.c b/libavformat/oggparseopus.c
index 43840c003ea..e3501a170cc 100644
--- a/libavformat/oggparseopus.c
+++ b/libavformat/oggparseopus.c
@@ -26,6 +26,7 @@
#include "avformat.h"
#include "internal.h"
#include "oggdec.h"
+#include "libavformat/vorbis/comment.h"
struct oggopus_private {
int need_comments;
diff --git a/libavformat/oggparsespeex.c b/libavformat/oggparsespeex.c
index 0a4b32de15f..79ec881835b 100644
--- a/libavformat/oggparsespeex.c
+++ b/libavformat/oggparsespeex.c
@@ -29,6 +29,7 @@
#include "avformat.h"
#include "internal.h"
#include "oggdec.h"
+#include "libavformat/vorbis/comment.h"
struct speex_params {
int packet_size;
diff --git a/libavformat/oggparsetheora.c b/libavformat/oggparsetheora.c
index e104d63229e..c0ddbff8a38 100644
--- a/libavformat/oggparsetheora.c
+++ b/libavformat/oggparsetheora.c
@@ -29,6 +29,7 @@
#include "avformat.h"
#include "internal.h"
#include "oggdec.h"
+#include "libavformat/vorbis/comment.h"
typedef struct TheoraParams {
int gpshift;
diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
index f00dbfb5179..d50a8e01f7a 100644
--- a/libavformat/oggparsevorbis.c
+++ b/libavformat/oggparsevorbis.c
@@ -24,8 +24,6 @@
#include <stdlib.h>
-#include "libavutil/avstring.h"
-#include "libavutil/base64.h"
#include "libavutil/dict.h"
#include "libavutil/mem.h"
@@ -34,166 +32,11 @@
#include "avformat.h"
#include "demux.h"
-#include "flac_picture.h"
#include "internal.h"
#include "oggdec.h"
#include "libavformat/vorbis/comment.h"
#include "replaygain.h"
-static int ogm_chapter(AVFormatContext *as, const uint8_t *key, const uint8_t
*val)
-{
- int i, cnum, h, m, s, ms, keylen = strlen(key);
- AVChapter *chapter = NULL;
-
- if (keylen < 9 || av_strncasecmp(key, "CHAPTER", 7) || sscanf(key+7,
"%03d", &cnum) != 1)
- return 0;
-
- if (keylen <= 10) {
- if (sscanf(val, "%02d:%02d:%02d.%03d", &h, &m, &s, &ms) < 4)
- return 0;
-
- avpriv_new_chapter(as, cnum, (AVRational) { 1, 1000 },
- ms + 1000 * (s + 60 * (m + 60 * h)),
- AV_NOPTS_VALUE, NULL);
- } else if (!av_strcasecmp(key + keylen - 4, "NAME")) {
- for (i = 0; i < as->nb_chapters; i++)
- if (as->chapters[i]->id == cnum) {
- chapter = as->chapters[i];
- break;
- }
- if (!chapter)
- return 0;
-
- av_dict_set(&chapter->metadata, "title", val, 0);
- } else
- return 0;
-
- return 1;
-}
-
-int ff_vorbis_stream_comment(AVFormatContext *as, AVStream *st,
- const uint8_t *buf, int size)
-{
- int updates = ff_vorbis_comment(as, &st->metadata, buf, size, 1);
-
- if (updates > 0) {
- st->event_flags |= AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
- }
-
- return updates;
-}
-
-/**
- * This function temporarily modifies the (const qualified) input buffer
- * and reverts its changes before return. The input buffer needs to have
- * at least one byte of padding.
- */
-static int vorbis_parse_single_comment(AVFormatContext *as, AVDictionary **m,
- const uint8_t *buf, uint32_t size,
- int *updates, int parse_picture)
-{
- char *t = (char*)buf, *v = memchr(t, '=', size);
- int tl, vl;
- char backup;
-
- if (!v)
- return 0;
-
- tl = v - t;
- vl = size - tl - 1;
- v++;
-
- if (!tl || !vl)
- return 0;
-
- t[tl] = 0;
-
- backup = v[vl];
- v[vl] = 0;
-
- /* The format in which the pictures are stored is the FLAC format.
- * Xiph says: "The binary FLAC picture structure is base64 encoded
- * and placed within a VorbisComment with the tag name
- * 'METADATA_BLOCK_PICTURE'. This is the preferred and
- * recommended way of embedding cover art within VorbisComments."
- */
- if (!av_strcasecmp(t, "METADATA_BLOCK_PICTURE") && parse_picture) {
- int ret, len = AV_BASE64_DECODE_SIZE(vl);
- uint8_t *pict = av_malloc(len + AV_INPUT_BUFFER_PADDING_SIZE);
-
- if (!pict) {
- av_log(as, AV_LOG_WARNING, "out-of-memory error. Skipping cover
art block.\n");
- goto end;
- }
- ret = av_base64_decode(pict, v, len);
- if (ret > 0)
- ret = ff_flac_parse_picture(as, &pict, ret, 0);
- av_freep(&pict);
- if (ret < 0) {
- av_log(as, AV_LOG_WARNING, "Failed to parse cover art block.\n");
- goto end;
- }
- } else if (!ogm_chapter(as, t, v)) {
- (*updates)++;
- if (av_dict_get(*m, t, NULL, 0))
- av_dict_set(m, t, ";", AV_DICT_APPEND);
- av_dict_set(m, t, v, AV_DICT_APPEND);
- }
-end:
- t[tl] = '=';
- v[vl] = backup;
-
- return 0;
-}
-
-int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
- const uint8_t *buf, int size,
- int parse_picture)
-{
- const uint8_t *p = buf;
- const uint8_t *end = buf + size;
- int updates = 0;
- unsigned n;
- int s, ret;
-
- /* must have vendor_length and user_comment_list_length */
- if (size < 8)
- return AVERROR_INVALIDDATA;
-
- s = bytestream_get_le32(&p);
-
- if (end - p - 4 < s || s < 0)
- return AVERROR_INVALIDDATA;
-
- p += s;
-
- n = bytestream_get_le32(&p);
-
- while (end - p >= 4 && n > 0) {
- s = bytestream_get_le32(&p);
-
- if (end - p < s || s < 0)
- break;
-
- ret = vorbis_parse_single_comment(as, m, p, s, &updates,
parse_picture);
- if (ret < 0)
- return ret;
- p += s;
- n--;
- }
-
- if (p != end)
- av_log(as, AV_LOG_INFO,
- "%td bytes of comment header remain\n", end - p);
- if (n > 0)
- av_log(as, AV_LOG_INFO,
- "truncated comment header, %i comments not found\n", n);
-
- ff_metadata_conv(m, NULL, ff_vorbiscomment_metadata_conv);
-
- return updates;
-}
-
/*
* Parse the vorbis header
*
diff --git a/libavformat/oggparsevp8.c b/libavformat/oggparsevp8.c
index 676b3a0f8e0..39ab927500b 100644
--- a/libavformat/oggparsevp8.c
+++ b/libavformat/oggparsevp8.c
@@ -24,6 +24,7 @@
#include "avformat.h"
#include "internal.h"
#include "oggdec.h"
+#include "libavformat/vorbis/comment.h"
#define VP8_HEADER_SIZE 26
diff --git a/libavformat/vorbis/comment.h b/libavformat/vorbis/comment.h
index 2762d63135c..2256632348b 100644
--- a/libavformat/vorbis/comment.h
+++ b/libavformat/vorbis/comment.h
@@ -54,4 +54,26 @@ int ff_vorbiscomment_write(AVIOContext *pb, const
AVDictionary *m,
extern const AVMetadataConv ff_vorbiscomment_metadata_conv[];
+/**
+ * Parse Vorbis comments
+ *
+ * @note The buffer will be temporarily modified by this function,
+ * so it needs to be writable. Furthermore it must be padded
+ * by a single byte (not counted in size).
+ * All changes will have been reverted upon return.
+ */
+int ff_vorbis_comment(AVFormatContext *ms, AVDictionary **m,
+ const uint8_t *buf, int size, int parse_picture);
+
+/**
+ * Parse Vorbis comments and add metadata to an AVStream
+ *
+ * @note The buffer will be temporarily modified by this function,
+ * so it needs to be writable. Furthermore it must be padded
+ * by a single byte (not counted in size).
+ * All changes will have been reverted upon return.
+ */
+int ff_vorbis_stream_comment(AVFormatContext *as, AVStream *st,
+ const uint8_t *buf, int size);
+
#endif /* AVFORMAT_VORBIS_COMMENT_H */
diff --git a/libavformat/vorbis/comment/reader.c
b/libavformat/vorbis/comment/reader.c
new file mode 100644
index 00000000000..2e7215b9a85
--- /dev/null
+++ b/libavformat/vorbis/comment/reader.c
@@ -0,0 +1,194 @@
+/*
+ * Copyright (C) 2005 Michael Ahlberg, Måns Rullgård
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "libavutil/avstring.h"
+#include "libavutil/base64.h"
+#include "libavutil/dict.h"
+#include "libavutil/mem.h"
+
+#include "libavcodec/bytestream.h"
+
+#include "libavformat/avformat.h"
+#include "libavformat/demux.h"
+#include "libavformat/flac_picture.h"
+#include "libavformat/internal.h"
+#include "libavformat/metadata.h"
+#include "libavformat/vorbis/comment.h"
+
+static int ogm_chapter(AVFormatContext *as, const uint8_t *key, const uint8_t
*val)
+{
+ int i, cnum, h, m, s, ms, keylen = strlen(key);
+ AVChapter *chapter = NULL;
+
+ if (keylen < 9 || av_strncasecmp(key, "CHAPTER", 7) || sscanf(key+7,
"%03d", &cnum) != 1)
+ return 0;
+
+ if (keylen <= 10) {
+ if (sscanf(val, "%02d:%02d:%02d.%03d", &h, &m, &s, &ms) < 4)
+ return 0;
+
+ avpriv_new_chapter(as, cnum, (AVRational) { 1, 1000 },
+ ms + 1000 * (s + 60 * (m + 60 * h)),
+ AV_NOPTS_VALUE, NULL);
+ } else if (!av_strcasecmp(key + keylen - 4, "NAME")) {
+ for (i = 0; i < as->nb_chapters; i++)
+ if (as->chapters[i]->id == cnum) {
+ chapter = as->chapters[i];
+ break;
+ }
+ if (!chapter)
+ return 0;
+
+ av_dict_set(&chapter->metadata, "title", val, 0);
+ } else
+ return 0;
+
+ return 1;
+}
+
+int ff_vorbis_stream_comment(AVFormatContext *as, AVStream *st,
+ const uint8_t *buf, int size)
+{
+ int updates = ff_vorbis_comment(as, &st->metadata, buf, size, 1);
+
+ if (updates > 0) {
+ st->event_flags |= AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
+ }
+
+ return updates;
+}
+
+/**
+ * This function temporarily modifies the (const qualified) input buffer
+ * and reverts its changes before return. The input buffer needs to have
+ * at least one byte of padding.
+ */
+static int vorbis_parse_single_comment(AVFormatContext *as, AVDictionary **m,
+ const uint8_t *buf, uint32_t size,
+ int *updates, int parse_picture)
+{
+ char *t = (char*)buf, *v = memchr(t, '=', size);
+ int tl, vl;
+ char backup;
+
+ if (!v)
+ return 0;
+
+ tl = v - t;
+ vl = size - tl - 1;
+ v++;
+
+ if (!tl || !vl)
+ return 0;
+
+ t[tl] = 0;
+
+ backup = v[vl];
+ v[vl] = 0;
+
+ /* The format in which the pictures are stored is the FLAC format.
+ * Xiph says: "The binary FLAC picture structure is base64 encoded
+ * and placed within a VorbisComment with the tag name
+ * 'METADATA_BLOCK_PICTURE'. This is the preferred and
+ * recommended way of embedding cover art within VorbisComments."
+ */
+ if (!av_strcasecmp(t, "METADATA_BLOCK_PICTURE") && parse_picture) {
+ int ret, len = AV_BASE64_DECODE_SIZE(vl);
+ uint8_t *pict = av_malloc(len + AV_INPUT_BUFFER_PADDING_SIZE);
+
+ if (!pict) {
+ av_log(as, AV_LOG_WARNING, "out-of-memory error. Skipping cover
art block.\n");
+ goto end;
+ }
+ ret = av_base64_decode(pict, v, len);
+ if (ret > 0)
+ ret = ff_flac_parse_picture(as, &pict, ret, 0);
+ av_freep(&pict);
+ if (ret < 0) {
+ av_log(as, AV_LOG_WARNING, "Failed to parse cover art block.\n");
+ goto end;
+ }
+ } else if (!ogm_chapter(as, t, v)) {
+ (*updates)++;
+ if (av_dict_get(*m, t, NULL, 0))
+ av_dict_set(m, t, ";", AV_DICT_APPEND);
+ av_dict_set(m, t, v, AV_DICT_APPEND);
+ }
+end:
+ t[tl] = '=';
+ v[vl] = backup;
+
+ return 0;
+}
+
+int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
+ const uint8_t *buf, int size,
+ int parse_picture)
+{
+ const uint8_t *p = buf;
+ const uint8_t *end = buf + size;
+ int updates = 0;
+ unsigned n;
+ int s, ret;
+
+ /* must have vendor_length and user_comment_list_length */
+ if (size < 8)
+ return AVERROR_INVALIDDATA;
+
+ s = bytestream_get_le32(&p);
+
+ if (end - p - 4 < s || s < 0)
+ return AVERROR_INVALIDDATA;
+
+ p += s;
+
+ n = bytestream_get_le32(&p);
+
+ while (end - p >= 4 && n > 0) {
+ s = bytestream_get_le32(&p);
+
+ if (end - p < s || s < 0)
+ break;
+
+ ret = vorbis_parse_single_comment(as, m, p, s, &updates,
parse_picture);
+ if (ret < 0)
+ return ret;
+ p += s;
+ n--;
+ }
+
+ if (p != end)
+ av_log(as, AV_LOG_INFO,
+ "%td bytes of comment header remain\n", end - p);
+ if (n > 0)
+ av_log(as, AV_LOG_INFO,
+ "truncated comment header, %i comments not found\n", n);
+
+ ff_metadata_conv(m, NULL, ff_vorbiscomment_metadata_conv);
+
+ return updates;
+}
--
2.54.0
From 0f71fd3bd9dcb9bf2e7fb7d4731ae6c13d6c006a Mon Sep 17 00:00:00 2001
From: Romain Beauxis <[email protected]>
Date: Thu, 5 Nov 2026 10:16:29 -0600
Subject: [PATCH 5/7] avformat/vorbis/comment: name the functions after their
path
The functions take the ff_vorbis_comment_ prefix of vorbis/comment, with the
reader named ff_vorbis_comment_read().
---
libavformat/flacdec.c | 2 +-
libavformat/flacenc.c | 6 +++---
libavformat/matroskadec.c | 2 +-
libavformat/matroskaenc.c | 4 ++--
libavformat/oggenc.c | 6 +++---
libavformat/oggparseflac.c | 2 +-
libavformat/oggparseogm.c | 2 +-
libavformat/oggparseopus.c | 2 +-
libavformat/oggparsespeex.c | 2 +-
libavformat/oggparsetheora.c | 2 +-
libavformat/oggparsevorbis.c | 2 +-
libavformat/oggparsevp8.c | 2 +-
libavformat/vorbis/comment.h | 24 ++++++++++++------------
libavformat/vorbis/comment/reader.c | 14 +++++++-------
libavformat/vorbis/comment/writer.c | 14 +++++++-------
15 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index a07c8bacbac..e3c2229e404 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -201,7 +201,7 @@ static int flac_read_header(AVFormatContext *s)
if (metadata_type == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
AVDictionaryEntry *chmask;
- ret = ff_vorbis_comment(s, &s->metadata, buffer,
metadata_size, 1);
+ ret = ff_vorbis_comment_read(s, &s->metadata, buffer,
metadata_size, 1);
if (ret < 0) {
av_log(s, AV_LOG_WARNING, "error parsing VorbisComment
metadata\n");
} else if (ret > 0) {
diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index b9e6f6d32a1..8f6bda1b04d 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -66,9 +66,9 @@ static int flac_write_block_comment(AVIOContext *pb,
AVDictionary **m,
const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
int len;
- ff_metadata_conv(m, ff_vorbiscomment_metadata_conv, NULL);
+ ff_metadata_conv(m, ff_vorbis_comment_metadata_conv, NULL);
- len = ff_vorbiscomment_length(*m, vendor, NULL, 0);
+ len = ff_vorbis_comment_length(*m, vendor, NULL, 0);
if (len < 0)
return len;
if (len >= ((1<<24) - 4))
@@ -76,7 +76,7 @@ static int flac_write_block_comment(AVIOContext *pb,
AVDictionary **m,
avio_w8(pb, last_block ? 0x84 : 0x04);
avio_wb24(pb, len);
- ff_vorbiscomment_write(pb, *m, vendor, NULL, 0);
+ ff_vorbis_comment_write(pb, *m, vendor, NULL, 0);
return 0;
}
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index c6f820a0565..389197fe1b1 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2183,7 +2183,7 @@ static int matroska_parse_flac(AVFormatContext *s,
AVDictionary *dict = NULL;
AVDictionaryEntry *chmask;
- ff_vorbis_comment(s, &dict, p, block_size, 0);
+ ff_vorbis_comment_read(s, &dict, p, block_size, 0);
chmask = av_dict_get(dict, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK",
NULL, 0);
if (chmask) {
uint64_t mask = strtol(chmask->value, NULL, 0);
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 795c65b6015..f08fee0c9aa 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1097,7 +1097,7 @@ static int put_flac_codecpriv(AVFormatContext *s,
AVIOContext *pb,
snprintf(buf, sizeof(buf), "0x%"PRIx64, par->ch_layout.u.mask);
av_dict_set(&dict, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0);
- len = ff_vorbiscomment_length(dict, vendor, NULL, 0);
+ len = ff_vorbis_comment_length(dict, vendor, NULL, 0);
if (len < 0)
return len;
av_assert1(len < (1 << 24) - 4);
@@ -1105,7 +1105,7 @@ static int put_flac_codecpriv(AVFormatContext *s,
AVIOContext *pb,
avio_w8(pb, 0x84);
avio_wb24(pb, len);
- ff_vorbiscomment_write(pb, dict, vendor, NULL, 0);
+ ff_vorbis_comment_write(pb, dict, vendor, NULL, 0);
av_dict_free(&dict);
}
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index 21243b5af45..cf20918f279 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -304,9 +304,9 @@ static uint8_t *ogg_write_vorbiscomment(int64_t offset, int
bitexact,
int64_t size;
uint8_t *p;
- ff_metadata_conv(m, ff_vorbiscomment_metadata_conv, NULL);
+ ff_metadata_conv(m, ff_vorbis_comment_metadata_conv, NULL);
- size = ff_vorbiscomment_length(*m, vendor, chapters, nb_chapters);
+ size = ff_vorbis_comment_length(*m, vendor, chapters, nb_chapters);
if (size < 0)
return NULL;
size += offset + framing_bit;
@@ -317,7 +317,7 @@ static uint8_t *ogg_write_vorbiscomment(int64_t offset, int
bitexact,
return NULL;
ffio_init_write_context(&pb, p + offset, size - offset);
- ff_vorbiscomment_write(&pb.pub, *m, vendor, chapters, nb_chapters);
+ ff_vorbis_comment_write(&pb.pub, *m, vendor, chapters, nb_chapters);
if (framing_bit)
avio_w8(&pb.pub, 1);
diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c
index 9926c5ebbb9..0a8f965188d 100644
--- a/libavformat/oggparseflac.c
+++ b/libavformat/oggparseflac.c
@@ -77,7 +77,7 @@ flac_header (AVFormatContext * s, int idx)
avpriv_set_pts_info(st, 64, 1, samplerate);
} else if (mdt == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
- ff_vorbis_stream_comment(s, st, os->buf + os->pstart + 4, os->psize -
4);
+ ff_vorbis_comment_read_stream(s, st, os->buf + os->pstart + 4,
os->psize - 4);
}
return 1;
diff --git a/libavformat/oggparseogm.c b/libavformat/oggparseogm.c
index 371a05a2c63..d0106203b4b 100644
--- a/libavformat/oggparseogm.c
+++ b/libavformat/oggparseogm.c
@@ -122,7 +122,7 @@ ogm_header(AVFormatContext *s, int idx)
} else if (bytestream2_peek_byte(&p) == 3) {
bytestream2_skip(&p, 7);
if (bytestream2_get_bytes_left(&p) > 1)
- ff_vorbis_stream_comment(s, st, p.buffer,
bytestream2_get_bytes_left(&p) - 1);
+ ff_vorbis_comment_read_stream(s, st, p.buffer,
bytestream2_get_bytes_left(&p) - 1);
}
return 1;
diff --git a/libavformat/oggparseopus.c b/libavformat/oggparseopus.c
index e3501a170cc..9b0aa7df322 100644
--- a/libavformat/oggparseopus.c
+++ b/libavformat/oggparseopus.c
@@ -102,7 +102,7 @@ static int opus_header(AVFormatContext *avf, int idx)
if (priv->need_comments) {
if (os->psize < 8 || memcmp(packet, "OpusTags", 8))
return AVERROR_INVALIDDATA;
- ff_vorbis_stream_comment(avf, st, packet + 8, os->psize - 8);
+ ff_vorbis_comment_read_stream(avf, st, packet + 8, os->psize - 8);
priv->need_comments--;
return 1;
}
diff --git a/libavformat/oggparsespeex.c b/libavformat/oggparsespeex.c
index 79ec881835b..e0953cc8d0c 100644
--- a/libavformat/oggparsespeex.c
+++ b/libavformat/oggparsespeex.c
@@ -96,7 +96,7 @@ static int speex_header(AVFormatContext *s, int idx) {
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
} else
- ff_vorbis_stream_comment(s, st, p, os->psize);
+ ff_vorbis_comment_read_stream(s, st, p, os->psize);
spxp->seq++;
return 1;
diff --git a/libavformat/oggparsetheora.c b/libavformat/oggparsetheora.c
index c0ddbff8a38..1f39489a9e5 100644
--- a/libavformat/oggparsetheora.c
+++ b/libavformat/oggparsetheora.c
@@ -118,7 +118,7 @@ static int theora_header(AVFormatContext *s, int idx)
}
break;
case 0x81:
- ff_vorbis_stream_comment(s, st, os->buf + os->pstart + 7, os->psize -
7);
+ ff_vorbis_comment_read_stream(s, st, os->buf + os->pstart + 7,
os->psize - 7);
av_fallthrough;
case 0x82:
if (!thp->version)
diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
index d50a8e01f7a..6bfec70c138 100644
--- a/libavformat/oggparsevorbis.c
+++ b/libavformat/oggparsevorbis.c
@@ -131,7 +131,7 @@ int ff_vorbis_update_metadata(AVFormatContext *s, AVStream
*st,
/* New metadata packet; release old data. */
av_dict_free(&st->metadata);
- ret = ff_vorbis_stream_comment(s, st, buf, size);
+ ret = ff_vorbis_comment_read_stream(s, st, buf, size);
if (ret < 0)
return ret;
diff --git a/libavformat/oggparsevp8.c b/libavformat/oggparsevp8.c
index 39ab927500b..b6fdf6c7758 100644
--- a/libavformat/oggparsevp8.c
+++ b/libavformat/oggparsevp8.c
@@ -67,7 +67,7 @@ static int vp8_header(AVFormatContext *s, int idx)
case 0x02:
if (p[6] != 0x20)
return AVERROR_INVALIDDATA;
- ff_vorbis_stream_comment(s, st, p + 7, os->psize - 7);
+ ff_vorbis_comment_read_stream(s, st, p + 7, os->psize - 7);
break;
default:
av_log(s, AV_LOG_ERROR, "Unknown VP8 header type 0x%02X\n", p[5]);
diff --git a/libavformat/vorbis/comment.h b/libavformat/vorbis/comment.h
index 2256632348b..59ac0169292 100644
--- a/libavformat/vorbis/comment.h
+++ b/libavformat/vorbis/comment.h
@@ -27,20 +27,20 @@
/**
* Calculate the length in bytes of a VorbisComment. This is the minimum
- * size required by ff_vorbiscomment_write().
+ * size required by ff_vorbis_comment_write().
*
* @param m The metadata structure to be parsed. For no metadata, set to NULL.
* @param vendor_string The vendor string to be added into the VorbisComment.
* For no string, set to an empty string.
* @return The length in bytes.
*/
-int ff_vorbiscomment_length(const AVDictionary *m, const char *vendor_string,
- AVChapter **chapters, unsigned int nb_chapters);
+int ff_vorbis_comment_length(const AVDictionary *m, const char *vendor_string,
+ AVChapter **chapters, unsigned int nb_chapters);
/**
* Write a VorbisComment into an AVIOContext. The output size can be obtained
* in advance by passing the same chapters, AVDictionary and vendor_string to
- * ff_vorbiscomment_length()
+ * ff_vorbis_comment_length()
*
* @param pb The AVIOContext to write the output.
* @param m The metadata struct to write.
@@ -48,11 +48,11 @@ int ff_vorbiscomment_length(const AVDictionary *m, const
char *vendor_string,
* @param chapters The chapters to write.
* @param nb_chapters The number of chapters to write.
*/
-int ff_vorbiscomment_write(AVIOContext *pb, const AVDictionary *m,
- const char *vendor_string,
- AVChapter **chapters, unsigned int nb_chapters);
+int ff_vorbis_comment_write(AVIOContext *pb, const AVDictionary *m,
+ const char *vendor_string,
+ AVChapter **chapters, unsigned int nb_chapters);
-extern const AVMetadataConv ff_vorbiscomment_metadata_conv[];
+extern const AVMetadataConv ff_vorbis_comment_metadata_conv[];
/**
* Parse Vorbis comments
@@ -62,8 +62,8 @@ extern const AVMetadataConv ff_vorbiscomment_metadata_conv[];
* by a single byte (not counted in size).
* All changes will have been reverted upon return.
*/
-int ff_vorbis_comment(AVFormatContext *ms, AVDictionary **m,
- const uint8_t *buf, int size, int parse_picture);
+int ff_vorbis_comment_read(AVFormatContext *ms, AVDictionary **m,
+ const uint8_t *buf, int size, int parse_picture);
/**
* Parse Vorbis comments and add metadata to an AVStream
@@ -73,7 +73,7 @@ int ff_vorbis_comment(AVFormatContext *ms, AVDictionary **m,
* by a single byte (not counted in size).
* All changes will have been reverted upon return.
*/
-int ff_vorbis_stream_comment(AVFormatContext *as, AVStream *st,
- const uint8_t *buf, int size);
+int ff_vorbis_comment_read_stream(AVFormatContext *as, AVStream *st,
+ const uint8_t *buf, int size);
#endif /* AVFORMAT_VORBIS_COMMENT_H */
diff --git a/libavformat/vorbis/comment/reader.c
b/libavformat/vorbis/comment/reader.c
index 2e7215b9a85..8c064774043 100644
--- a/libavformat/vorbis/comment/reader.c
+++ b/libavformat/vorbis/comment/reader.c
@@ -70,10 +70,10 @@ static int ogm_chapter(AVFormatContext *as, const uint8_t
*key, const uint8_t *v
return 1;
}
-int ff_vorbis_stream_comment(AVFormatContext *as, AVStream *st,
- const uint8_t *buf, int size)
+int ff_vorbis_comment_read_stream(AVFormatContext *as, AVStream *st,
+ const uint8_t *buf, int size)
{
- int updates = ff_vorbis_comment(as, &st->metadata, buf, size, 1);
+ int updates = ff_vorbis_comment_read(as, &st->metadata, buf, size, 1);
if (updates > 0) {
st->event_flags |= AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
@@ -145,9 +145,9 @@ end:
return 0;
}
-int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
- const uint8_t *buf, int size,
- int parse_picture)
+int ff_vorbis_comment_read(AVFormatContext *as, AVDictionary **m,
+ const uint8_t *buf, int size,
+ int parse_picture)
{
const uint8_t *p = buf;
const uint8_t *end = buf + size;
@@ -188,7 +188,7 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
av_log(as, AV_LOG_INFO,
"truncated comment header, %i comments not found\n", n);
- ff_metadata_conv(m, NULL, ff_vorbiscomment_metadata_conv);
+ ff_metadata_conv(m, NULL, ff_vorbis_comment_metadata_conv);
return updates;
}
diff --git a/libavformat/vorbis/comment/writer.c
b/libavformat/vorbis/comment/writer.c
index c0b8f02a80b..8681b309608 100644
--- a/libavformat/vorbis/comment/writer.c
+++ b/libavformat/vorbis/comment/writer.c
@@ -31,7 +31,7 @@
* from Ogg Vorbis I format specification: comment field and header
specification
* http://xiph.org/vorbis/doc/v-comment.html
*/
-const AVMetadataConv ff_vorbiscomment_metadata_conv[] = {
+const AVMetadataConv ff_vorbis_comment_metadata_conv[] = {
{ "ALBUMARTIST", "album_artist" },
{ "TRACKNUMBER", "track" },
{ "DISCNUMBER", "disc" },
@@ -41,8 +41,8 @@ const AVMetadataConv ff_vorbiscomment_metadata_conv[] = {
{ 0 }
};
-int ff_vorbiscomment_length(const AVDictionary *m, const char *vendor_string,
- AVChapter **chapters, unsigned int nb_chapters)
+int ff_vorbis_comment_length(const AVDictionary *m, const char *vendor_string,
+ AVChapter **chapters, unsigned int nb_chapters)
{
AVIOContext *avio_buf;
int ret, len;
@@ -51,7 +51,7 @@ int ff_vorbiscomment_length(const AVDictionary *m, const char
*vendor_string,
if (ret < 0)
return ret;
- ret = ff_vorbiscomment_write(avio_buf, m, vendor_string, chapters,
nb_chapters);
+ ret = ff_vorbis_comment_write(avio_buf, m, vendor_string, chapters,
nb_chapters);
len = ffio_close_null_buf(avio_buf);
if (ret < 0)
return ret;
@@ -59,9 +59,9 @@ int ff_vorbiscomment_length(const AVDictionary *m, const char
*vendor_string,
return len;
}
-int ff_vorbiscomment_write(AVIOContext *pb, const AVDictionary *dict,
- const char *vendor_string,
- AVChapter **chapters, unsigned int nb_chapters)
+int ff_vorbis_comment_write(AVIOContext *pb, const AVDictionary *dict,
+ const char *vendor_string,
+ AVChapter **chapters, unsigned int nb_chapters)
{
size_t vendor_string_length = strlen(vendor_string);
int cm_count = 0;
--
2.54.0
From 477502b526dbc3031ca66ff4c7c13e86fc3924ff Mon Sep 17 00:00:00 2001
From: Romain Beauxis <[email protected]>
Date: Thu, 5 Nov 2026 10:17:34 -0600
Subject: [PATCH 6/7] avformat/id3v2: move to id3v2/
The reader moves to id3v2/reader.c and the writer to id3v2/writer.c, following
the source tree layout rules, while id3v2.h stays next to the directory.
---
MAINTAINERS | 2 +-
libavformat/Makefile | 11 ++++++-----
libavformat/id3v2/Makefile | 2 ++
libavformat/{id3v2.c => id3v2/reader.c} | 10 +++++-----
libavformat/{id3v2enc.c => id3v2/writer.c} | 12 ++++++------
5 files changed, 20 insertions(+), 17 deletions(-)
create mode 100644 libavformat/id3v2/Makefile
rename libavformat/{id3v2.c => id3v2/reader.c} (99%)
rename libavformat/{id3v2enc.c => id3v2/writer.c} (98%)
diff --git a/MAINTAINERS b/MAINTAINERS
index 58e71ac77a4..7237e8185a0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -434,7 +434,7 @@ Muxers/Demuxers:
hlsenc.c Christian Suloway, Steven Liu
hxvs.c Zhao Zhili
iamf* [2] James Almer
- id3v2* Romain Beauxis
+ id3v2.h, id3v2/* Romain Beauxis
idcin.c Mike Melanson
idroqdec.c Mike Melanson
iff.c Jaikrishnan Menon
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 69e5faa16d3..3cfaebcd446 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -19,7 +19,7 @@ OBJS = allformats.o \
dv.o \
format.o \
id3v1.o \
- id3v2.o \
+ id3v2/reader.o \
isom_tags.o \
lcevc.o \
metadata.o \
@@ -42,6 +42,7 @@ OBJS = allformats.o \
OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o
# subsystems
+include $(SRC_PATH)/libavformat/id3v2/Makefile
include $(SRC_PATH)/libavformat/vorbis/comment/Makefile
OBJS-$(CONFIG_CBS_APV_LAVF) += cbs_apv.o cbs.o
OBJS-$(CONFIG_CBS_AV1_LAVF) += cbs_av1.o cbs.o
@@ -102,7 +103,7 @@ OBJS-$(CONFIG_ADF_DEMUXER) += bintext.o
sauce.o
OBJS-$(CONFIG_ADP_DEMUXER) += adp.o
OBJS-$(CONFIG_ADS_DEMUXER) += ads.o
OBJS-$(CONFIG_ADTS_MUXER) += adtsenc.o apetag.o img2.o \
- id3v2enc.o
+ id3v2/writer.o
OBJS-$(CONFIG_ADX_DEMUXER) += adxdec.o rawdec.o
OBJS-$(CONFIG_ADX_MUXER) += rawenc.o
OBJS-$(CONFIG_AEA_DEMUXER) += aeadec.o pcm.o
@@ -110,7 +111,7 @@ OBJS-$(CONFIG_AEA_MUXER) += aeaenc.o
rawenc.o
OBJS-$(CONFIG_AFC_DEMUXER) += afc.o
OBJS-$(CONFIG_AIFF_DEMUXER) += aiffdec.o aiff.o pcm.o \
mov_chan.o replaygain.o
-OBJS-$(CONFIG_AIFF_MUXER) += aiffenc.o aiff.o id3v2enc.o
+OBJS-$(CONFIG_AIFF_MUXER) += aiffenc.o aiff.o id3v2/writer.o
OBJS-$(CONFIG_AIX_DEMUXER) += aixdec.o
OBJS-$(CONFIG_ALP_DEMUXER) += alp.o
OBJS-$(CONFIG_ALP_MUXER) += alp.o rawenc.o
@@ -405,7 +406,7 @@ OBJS-$(CONFIG_MOV_MUXER) += movenc.o \
apv.o dovi_isom.o evc.o
OBJS-$(CONFIG_MP2_MUXER) += rawenc.o
OBJS-$(CONFIG_MP3_DEMUXER) += mp3dec.o replaygain.o
-OBJS-$(CONFIG_MP3_MUXER) += mp3enc.o rawenc.o id3v2enc.o
+OBJS-$(CONFIG_MP3_MUXER) += mp3enc.o rawenc.o id3v2/writer.o
OBJS-$(CONFIG_MPC_DEMUXER) += mpc.o apetag.o img2.o
OBJS-$(CONFIG_MPC8_DEMUXER) += mpc8.o apetag.o img2.o
OBJS-$(CONFIG_MPEG1SYSTEM_MUXER) += mpegenc.o
@@ -467,7 +468,7 @@ OBJS-$(CONFIG_OGG_MUXER) += oggenc.o \
OBJS-$(CONFIG_OGV_MUXER) += oggenc.o \
vorbis/comment/writer.o
OBJS-$(CONFIG_OMA_DEMUXER) += omadec.o pcm.o oma.o
-OBJS-$(CONFIG_OMA_MUXER) += omaenc.o rawenc.o oma.o id3v2enc.o
+OBJS-$(CONFIG_OMA_MUXER) += omaenc.o rawenc.o oma.o
id3v2/writer.o
OBJS-$(CONFIG_OPUS_MUXER) += oggenc.o \
vorbis/comment/writer.o
OBJS-$(CONFIG_OSQ_DEMUXER) += osq.o rawdec.o
diff --git a/libavformat/id3v2/Makefile b/libavformat/id3v2/Makefile
new file mode 100644
index 00000000000..156806c75f9
--- /dev/null
+++ b/libavformat/id3v2/Makefile
@@ -0,0 +1,2 @@
+clean::
+ $(RM) $(CLEANSUFFIXES:%=libavformat/id3v2/%)
diff --git a/libavformat/id3v2.c b/libavformat/id3v2/reader.c
similarity index 99%
rename from libavformat/id3v2.c
rename to libavformat/id3v2/reader.c
index 20d37f345b3..1a8c534f71a 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2/reader.c
@@ -40,11 +40,11 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
#include "libavcodec/png.h"
-#include "avio_internal.h"
-#include "avlanguage.h"
-#include "demux.h"
-#include "id3v1.h"
-#include "id3v2.h"
+#include "libavformat/avio_internal.h"
+#include "libavformat/avlanguage.h"
+#include "libavformat/demux.h"
+#include "libavformat/id3v1.h"
+#include "libavformat/id3v2.h"
const AVMetadataConv ff_id3v2_34_metadata_conv[] = {
{ "COMM", "comment" },
diff --git a/libavformat/id3v2enc.c b/libavformat/id3v2/writer.c
similarity index 98%
rename from libavformat/id3v2enc.c
rename to libavformat/id3v2/writer.c
index c538d13829b..cab838a4566 100644
--- a/libavformat/id3v2enc.c
+++ b/libavformat/id3v2/writer.c
@@ -25,12 +25,12 @@
#include "libavutil/dict.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
-#include "avformat.h"
-#include "avlanguage.h"
-#include "avio.h"
-#include "avio_internal.h"
-#include "id3v2.h"
-#include "mux.h"
+#include "libavformat/avformat.h"
+#include "libavformat/avlanguage.h"
+#include "libavformat/avio.h"
+#include "libavformat/avio_internal.h"
+#include "libavformat/id3v2.h"
+#include "libavformat/mux.h"
static void id3v2_put_size(AVIOContext *pb, int size)
{
--
2.54.0
From 580869e40b1a0bb2bf1256cd9727689e7c25f360 Mon Sep 17 00:00:00 2001
From: Romain Beauxis <[email protected]>
Date: Thu, 5 Nov 2026 10:19:17 -0600
Subject: [PATCH 7/7] avformat/ogg: move to ogg/
The demuxer moves to ogg/demuxer.c, the muxer to ogg/muxer.c and the per-codec
mappings to ogg/mapping/, following the source tree layout rules.
The header shared by the demuxer and its mappings moves to ogg/mapping.h, next
to the mapping directory.
---
MAINTAINERS | 6 ++--
libavformat/Makefile | 28 +++++--------------
libavformat/ogg/Makefile | 21 ++++++++++++++
libavformat/{oggdec.c => ogg/demuxer.c} | 10 +++----
libavformat/{oggdec.h => ogg/mapping.h} | 8 +++---
.../{oggparsedirac.c => ogg/mapping/dirac.c} | 6 ++--
.../{oggparseflac.c => ogg/mapping/flac.c} | 6 ++--
.../{oggparseogm.c => ogg/mapping/ogm.c} | 8 +++---
.../{oggparseopus.c => ogg/mapping/opus.c} | 6 ++--
.../mapping/skeleton.c} | 6 ++--
.../{oggparsespeex.c => ogg/mapping/speex.c} | 6 ++--
.../mapping/theora.c} | 6 ++--
.../mapping/vorbis.c} | 10 +++----
.../{oggparsevp8.c => ogg/mapping/vp8.c} | 6 ++--
libavformat/{oggenc.c => ogg/muxer.c} | 10 +++----
15 files changed, 75 insertions(+), 68 deletions(-)
create mode 100644 libavformat/ogg/Makefile
rename libavformat/{oggdec.c => ogg/demuxer.c} (99%)
rename libavformat/{oggdec.h => ogg/mapping.h} (97%)
rename libavformat/{oggparsedirac.c => ogg/mapping/dirac.c} (97%)
rename libavformat/{oggparseflac.c => ogg/mapping/flac.c} (98%)
rename libavformat/{oggparseogm.c => ogg/mapping/ogm.c} (98%)
rename libavformat/{oggparseopus.c => ogg/mapping/opus.c} (98%)
rename libavformat/{oggparseskeleton.c => ogg/mapping/skeleton.c} (96%)
rename libavformat/{oggparsespeex.c => ogg/mapping/speex.c} (97%)
rename libavformat/{oggparsetheora.c => ogg/mapping/theora.c} (98%)
rename libavformat/{oggparsevorbis.c => ogg/mapping/vorbis.c} (99%)
rename libavformat/{oggparsevp8.c => ogg/mapping/vp8.c} (97%)
rename libavformat/{oggenc.c => ogg/muxer.c} (99%)
diff --git a/MAINTAINERS b/MAINTAINERS
index 7237e8185a0..03e7670b12e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -469,9 +469,9 @@ Muxers/Demuxers:
nsvdec.c Francois Revol
nut* Michael Niedermayer
nuv.c Reimar Doeffinger
- oggdec.c, oggdec.h David Conrad, Romain Beauxis
- oggenc.c Baptiste Coudurier, Romain Beauxis
- oggparse*.c David Conrad, Romain Beauxis
+ ogg/demuxer.c, ogg/mapping.h David Conrad, Romain Beauxis
+ ogg/muxer.c Baptiste Coudurier, Romain Beauxis
+ ogg/mapping/* David Conrad, Romain Beauxis
oma.c Maxim Poliakovski
pp_bnk.c Zane van Iperen
psxstr.c Mike Melanson
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 3cfaebcd446..13c9225b311 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -43,6 +43,7 @@ OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o
# subsystems
include $(SRC_PATH)/libavformat/id3v2/Makefile
+include $(SRC_PATH)/libavformat/ogg/Makefile
include $(SRC_PATH)/libavformat/vorbis/comment/Makefile
OBJS-$(CONFIG_CBS_APV_LAVF) += cbs_apv.o cbs.o
OBJS-$(CONFIG_CBS_AV1_LAVF) += cbs_av1.o cbs.o
@@ -447,30 +448,16 @@ OBJS-$(CONFIG_NUV_DEMUXER) += nuv.o
OBJS-$(CONFIG_AV1_DEMUXER) += av1dec.o
OBJS-$(CONFIG_OBU_DEMUXER) += av1dec.o
OBJS-$(CONFIG_OBU_MUXER) += rawenc.o
-OBJS-$(CONFIG_OGG_DEMUXER) += oggdec.o \
- oggparsedirac.o \
- oggparseflac.o \
- oggparseogm.o \
- oggparseopus.o \
- oggparseskeleton.o \
- oggparsespeex.o \
- oggparsetheora.o \
- oggparsevorbis.o \
- oggparsevp8.o \
- replaygain.o \
+OBJS-$(CONFIG_OGG_DEMUXER) += replaygain.o \
vorbis/comment/reader.o \
vorbis/comment/writer.o \
flac_picture.o
-OBJS-$(CONFIG_OGA_MUXER) += oggenc.o \
- vorbis/comment/writer.o
-OBJS-$(CONFIG_OGG_MUXER) += oggenc.o \
- vorbis/comment/writer.o
-OBJS-$(CONFIG_OGV_MUXER) += oggenc.o \
- vorbis/comment/writer.o
+OBJS-$(CONFIG_OGA_MUXER) += vorbis/comment/writer.o
+OBJS-$(CONFIG_OGG_MUXER) += vorbis/comment/writer.o
+OBJS-$(CONFIG_OGV_MUXER) += vorbis/comment/writer.o
OBJS-$(CONFIG_OMA_DEMUXER) += omadec.o pcm.o oma.o
OBJS-$(CONFIG_OMA_MUXER) += omaenc.o rawenc.o oma.o
id3v2/writer.o
-OBJS-$(CONFIG_OPUS_MUXER) += oggenc.o \
- vorbis/comment/writer.o
+OBJS-$(CONFIG_OPUS_MUXER) += vorbis/comment/writer.o
OBJS-$(CONFIG_OSQ_DEMUXER) += osq.o rawdec.o
OBJS-$(CONFIG_PAF_DEMUXER) += paf.o
OBJS-$(CONFIG_PCM_ALAW_DEMUXER) += pcmdec.o pcm.o
@@ -595,8 +582,7 @@ OBJS-$(CONFIG_SOX_DEMUXER) += soxdec.o pcm.o
OBJS-$(CONFIG_SOX_MUXER) += soxenc.o rawenc.o
OBJS-$(CONFIG_SPDIF_DEMUXER) += spdif.o spdifdec.o
OBJS-$(CONFIG_SPDIF_MUXER) += spdif.o spdifenc.o
-OBJS-$(CONFIG_SPEEX_MUXER) += oggenc.o \
- vorbis/comment/writer.o
+OBJS-$(CONFIG_SPEEX_MUXER) += vorbis/comment/writer.o
OBJS-$(CONFIG_SRT_DEMUXER) += srtdec.o subtitles.o
OBJS-$(CONFIG_SRT_MUXER) += srtenc.o
OBJS-$(CONFIG_STL_DEMUXER) += stldec.o subtitles.o
diff --git a/libavformat/ogg/Makefile b/libavformat/ogg/Makefile
new file mode 100644
index 00000000000..6aebf757265
--- /dev/null
+++ b/libavformat/ogg/Makefile
@@ -0,0 +1,21 @@
+clean::
+ $(RM) $(CLEANSUFFIXES:%=libavformat/ogg/%)
+ $(RM) $(CLEANSUFFIXES:%=libavformat/ogg/mapping/%)
+
+OBJS-$(CONFIG_OGG_DEMUXER) += \
+ ogg/demuxer.o \
+ ogg/mapping/dirac.o \
+ ogg/mapping/flac.o \
+ ogg/mapping/ogm.o \
+ ogg/mapping/opus.o \
+ ogg/mapping/skeleton.o \
+ ogg/mapping/speex.o \
+ ogg/mapping/theora.o \
+ ogg/mapping/vorbis.o \
+ ogg/mapping/vp8.o \
+
+OBJS-$(CONFIG_OGA_MUXER) += ogg/muxer.o
+OBJS-$(CONFIG_OGG_MUXER) += ogg/muxer.o
+OBJS-$(CONFIG_OGV_MUXER) += ogg/muxer.o
+OBJS-$(CONFIG_OPUS_MUXER) += ogg/muxer.o
+OBJS-$(CONFIG_SPEEX_MUXER) += ogg/muxer.o
diff --git a/libavformat/oggdec.c b/libavformat/ogg/demuxer.c
similarity index 99%
rename from libavformat/oggdec.c
rename to libavformat/ogg/demuxer.c
index 1c3e7eec6c5..015f0e1b9c8 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/ogg/demuxer.c
@@ -32,11 +32,11 @@
#include "libavutil/avassert.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
-#include "avio_internal.h"
-#include "demux.h"
-#include "oggdec.h"
-#include "avformat.h"
-#include "internal.h"
+#include "libavformat/avio_internal.h"
+#include "libavformat/demux.h"
+#include "mapping.h"
+#include "libavformat/avformat.h"
+#include "libavformat/internal.h"
#define MAX_PAGE_SIZE 65307
#define DECODER_BUFFER_SIZE MAX_PAGE_SIZE
diff --git a/libavformat/oggdec.h b/libavformat/ogg/mapping.h
similarity index 97%
rename from libavformat/oggdec.h
rename to libavformat/ogg/mapping.h
index 107ba12f028..eed10aaa98d 100644
--- a/libavformat/oggdec.h
+++ b/libavformat/ogg/mapping.h
@@ -22,10 +22,10 @@
DEALINGS IN THE SOFTWARE.
**/
-#ifndef AVFORMAT_OGGDEC_H
-#define AVFORMAT_OGGDEC_H
+#ifndef AVFORMAT_OGG_MAPPING_H
+#define AVFORMAT_OGG_MAPPING_H
-#include "avformat.h"
+#include "libavformat/avformat.h"
struct ogg_codec {
const int8_t *magic;
@@ -188,4 +188,4 @@ ogg_gptopts (AVFormatContext * s, int i, uint64_t gp,
int64_t *dts)
return pts;
}
-#endif /* AVFORMAT_OGGDEC_H */
+#endif /* AVFORMAT_OGG_MAPPING_H */
diff --git a/libavformat/oggparsedirac.c b/libavformat/ogg/mapping/dirac.c
similarity index 97%
rename from libavformat/oggparsedirac.c
rename to libavformat/ogg/mapping/dirac.c
index c5bd43a7574..7b6523ac055 100644
--- a/libavformat/oggparsedirac.c
+++ b/libavformat/ogg/mapping/dirac.c
@@ -22,9 +22,9 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
#include "libavcodec/dirac.h"
-#include "avformat.h"
-#include "internal.h"
-#include "oggdec.h"
+#include "libavformat/avformat.h"
+#include "libavformat/internal.h"
+#include "libavformat/ogg/mapping.h"
static int dirac_header(AVFormatContext *s, int idx)
{
diff --git a/libavformat/oggparseflac.c b/libavformat/ogg/mapping/flac.c
similarity index 98%
rename from libavformat/oggparseflac.c
rename to libavformat/ogg/mapping/flac.c
index 0a8f965188d..a9c0317a9b9 100644
--- a/libavformat/oggparseflac.c
+++ b/libavformat/ogg/mapping/flac.c
@@ -23,9 +23,9 @@
#include "libavcodec/avcodec.h"
#include "libavcodec/bytestream.h"
#include "libavcodec/flac.h"
-#include "avformat.h"
-#include "internal.h"
-#include "oggdec.h"
+#include "libavformat/avformat.h"
+#include "libavformat/internal.h"
+#include "libavformat/ogg/mapping.h"
#include "libavformat/vorbis/comment.h"
#define OGG_FLAC_METADATA_TYPE_STREAMINFO 0x7F
diff --git a/libavformat/oggparseogm.c b/libavformat/ogg/mapping/ogm.c
similarity index 98%
rename from libavformat/oggparseogm.c
rename to libavformat/ogg/mapping/ogm.c
index d0106203b4b..1db2268ea0f 100644
--- a/libavformat/oggparseogm.c
+++ b/libavformat/ogg/mapping/ogm.c
@@ -28,11 +28,11 @@
#include "libavcodec/bytestream.h"
-#include "avformat.h"
-#include "internal.h"
-#include "oggdec.h"
+#include "libavformat/avformat.h"
+#include "libavformat/internal.h"
+#include "libavformat/ogg/mapping.h"
#include "libavformat/vorbis/comment.h"
-#include "riff.h"
+#include "libavformat/riff.h"
static int
ogm_header(AVFormatContext *s, int idx)
diff --git a/libavformat/oggparseopus.c b/libavformat/ogg/mapping/opus.c
similarity index 98%
rename from libavformat/oggparseopus.c
rename to libavformat/ogg/mapping/opus.c
index 9b0aa7df322..c306717395d 100644
--- a/libavformat/oggparseopus.c
+++ b/libavformat/ogg/mapping/opus.c
@@ -23,9 +23,9 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
-#include "avformat.h"
-#include "internal.h"
-#include "oggdec.h"
+#include "libavformat/avformat.h"
+#include "libavformat/internal.h"
+#include "libavformat/ogg/mapping.h"
#include "libavformat/vorbis/comment.h"
struct oggopus_private {
diff --git a/libavformat/oggparseskeleton.c b/libavformat/ogg/mapping/skeleton.c
similarity index 96%
rename from libavformat/oggparseskeleton.c
rename to libavformat/ogg/mapping/skeleton.c
index 2016b16c954..53eb176f98d 100644
--- a/libavformat/oggparseskeleton.c
+++ b/libavformat/ogg/mapping/skeleton.c
@@ -19,9 +19,9 @@
*/
#include "libavutil/intreadwrite.h"
-#include "avformat.h"
-#include "internal.h"
-#include "oggdec.h"
+#include "libavformat/avformat.h"
+#include "libavformat/internal.h"
+#include "libavformat/ogg/mapping.h"
static int skeleton_header(AVFormatContext *s, int idx)
{
diff --git a/libavformat/oggparsespeex.c b/libavformat/ogg/mapping/speex.c
similarity index 97%
rename from libavformat/oggparsespeex.c
rename to libavformat/ogg/mapping/speex.c
index e0953cc8d0c..f15d3e50d07 100644
--- a/libavformat/oggparsespeex.c
+++ b/libavformat/ogg/mapping/speex.c
@@ -26,9 +26,9 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
-#include "avformat.h"
-#include "internal.h"
-#include "oggdec.h"
+#include "libavformat/avformat.h"
+#include "libavformat/internal.h"
+#include "libavformat/ogg/mapping.h"
#include "libavformat/vorbis/comment.h"
struct speex_params {
diff --git a/libavformat/oggparsetheora.c b/libavformat/ogg/mapping/theora.c
similarity index 98%
rename from libavformat/oggparsetheora.c
rename to libavformat/ogg/mapping/theora.c
index 1f39489a9e5..66905823f71 100644
--- a/libavformat/oggparsetheora.c
+++ b/libavformat/ogg/mapping/theora.c
@@ -26,9 +26,9 @@
#include "libavutil/attributes.h"
#include "libavutil/mem.h"
#include "libavcodec/get_bits.h"
-#include "avformat.h"
-#include "internal.h"
-#include "oggdec.h"
+#include "libavformat/avformat.h"
+#include "libavformat/internal.h"
+#include "libavformat/ogg/mapping.h"
#include "libavformat/vorbis/comment.h"
typedef struct TheoraParams {
diff --git a/libavformat/oggparsevorbis.c b/libavformat/ogg/mapping/vorbis.c
similarity index 99%
rename from libavformat/oggparsevorbis.c
rename to libavformat/ogg/mapping/vorbis.c
index 6bfec70c138..e3380d665af 100644
--- a/libavformat/oggparsevorbis.c
+++ b/libavformat/ogg/mapping/vorbis.c
@@ -30,12 +30,12 @@
#include "libavcodec/bytestream.h"
#include "libavcodec/vorbis_parser.h"
-#include "avformat.h"
-#include "demux.h"
-#include "internal.h"
-#include "oggdec.h"
+#include "libavformat/avformat.h"
+#include "libavformat/demux.h"
+#include "libavformat/internal.h"
+#include "libavformat/ogg/mapping.h"
#include "libavformat/vorbis/comment.h"
-#include "replaygain.h"
+#include "libavformat/replaygain.h"
/*
* Parse the vorbis header
diff --git a/libavformat/oggparsevp8.c b/libavformat/ogg/mapping/vp8.c
similarity index 97%
rename from libavformat/oggparsevp8.c
rename to libavformat/ogg/mapping/vp8.c
index b6fdf6c7758..0bf22bb03db 100644
--- a/libavformat/oggparsevp8.c
+++ b/libavformat/ogg/mapping/vp8.c
@@ -21,9 +21,9 @@
#include "libavutil/intreadwrite.h"
-#include "avformat.h"
-#include "internal.h"
-#include "oggdec.h"
+#include "libavformat/avformat.h"
+#include "libavformat/internal.h"
+#include "libavformat/ogg/mapping.h"
#include "libavformat/vorbis/comment.h"
#define VP8_HEADER_SIZE 26
diff --git a/libavformat/oggenc.c b/libavformat/ogg/muxer.c
similarity index 99%
rename from libavformat/oggenc.c
rename to libavformat/ogg/muxer.c
index cf20918f279..f2dc935aee7 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/ogg/muxer.c
@@ -31,11 +31,11 @@
#include "libavcodec/xiph.h"
#include "libavcodec/bytestream.h"
#include "libavcodec/flac.h"
-#include "avformat.h"
-#include "avio_internal.h"
-#include "internal.h"
-#include "mux.h"
-#include "version.h"
+#include "libavformat/avformat.h"
+#include "libavformat/avio_internal.h"
+#include "libavformat/internal.h"
+#include "libavformat/mux.h"
+#include "libavformat/version.h"
#include "libavformat/vorbis/comment.h"
#define MAX_PAGE_SIZE 65025
--
2.54.0
_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]