diff options
author | Romain Beauxis <romain.beauxis@gmail.com> | 2025-05-06 09:13:06 -0500 |
---|---|---|
committer | Lynne <dev@lynne.ee> | 2025-05-19 07:24:05 +0200 |
commit | 2fb6416dd06b5e66eca035458bb91b7956760d7c (patch) | |
tree | 7949a97c3d0bb09ee02e22457ff5cc6beb1a980f /libavformat/oggparseflac.c | |
parent | bd2dcfaed478740dc9b0e467849535bc3426950c (diff) | |
download | ffmpeg-2fb6416dd06b5e66eca035458bb91b7956760d7c.tar.gz |
ogg/flac: implement header packet skip in chained ogg bitstreams.
Diffstat (limited to 'libavformat/oggparseflac.c')
-rw-r--r-- | libavformat/oggparseflac.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c index f25ed9cc15..d66b85b09e 100644 --- a/libavformat/oggparseflac.c +++ b/libavformat/oggparseflac.c @@ -27,6 +27,8 @@ #include "oggdec.h" #define OGG_FLAC_METADATA_TYPE_STREAMINFO 0x7F +#define OGG_FLAC_MAGIC "\177FLAC" +#define OGG_FLAC_MAGIC_SIZE sizeof(OGG_FLAC_MAGIC)-1 static int flac_header (AVFormatContext * s, int idx) @@ -79,6 +81,27 @@ flac_header (AVFormatContext * s, int idx) } static int +flac_packet (AVFormatContext * s, int idx) +{ + struct ogg *ogg = s->priv_data; + struct ogg_stream *os = ogg->streams + idx; + + if (os->psize > OGG_FLAC_MAGIC_SIZE && + !memcmp( + os->buf + os->pstart, + OGG_FLAC_MAGIC, + OGG_FLAC_MAGIC_SIZE)) + return 1; + + if (os->psize > 0 && + ((os->buf[os->pstart] & 0x7F) == FLAC_METADATA_TYPE_VORBIS_COMMENT)) { + return 1; + } + + return 0; +} + +static int old_flac_header (AVFormatContext * s, int idx) { struct ogg *ogg = s->priv_data; @@ -127,10 +150,11 @@ fail: } const struct ogg_codec ff_flac_codec = { - .magic = "\177FLAC", - .magicsize = 5, + .magic = OGG_FLAC_MAGIC, + .magicsize = OGG_FLAC_MAGIC_SIZE, .header = flac_header, .nb_header = 2, + .packet = flac_packet, }; const struct ogg_codec ff_old_flac_codec = { |