From: Romain Beauxis <romain.beauxis@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Romain Beauxis <romain.beauxis@gmail.com>
Subject: [FFmpeg-devel] [PATCH v4 1/6] Pass ogg/opus secondary header packets to the
Date: Mon, 10 Feb 2025 13:25:55 -0600
Message-ID: <20250210192600.42502-2-romain.beauxis@gmail.com> (raw)
In-Reply-To: <20250210192600.42502-1-romain.beauxis@gmail.com>
These changes make it possible to access the initial header packets of
secondary chained ogg/opus bitstreams.
libavformat/oggparseopus.c: Parse extradata from
secondary chained streams header packet.
libavformat/oggdec.c: Do not force ogg stream header parsing on
secondary ogg/opus chained streams.
libavcodec/opus/dec.c: Ignore opus header packets from secondary chained
streams.
---
libavcodec/opus/dec.c | 5 +++++
libavformat/oggdec.c | 4 ----
libavformat/oggparseopus.c | 11 +++++++++++
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/libavcodec/opus/dec.c b/libavcodec/opus/dec.c
index 6c59dc1f46..88a650c81c 100644
--- a/libavcodec/opus/dec.c
+++ b/libavcodec/opus/dec.c
@@ -486,6 +486,11 @@ static int opus_decode_packet(AVCodecContext *avctx, AVFrame *frame,
int delayed_samples = 0;
int i, ret;
+ if (buf_size > 8 && (
+ !memcmp(buf, "OpusHead", 8) ||
+ !memcmp(buf, "OpusTags", 8)))
+ return buf_size;
+
/* calculate the number of delayed samples */
for (int i = 0; i < c->p.nb_streams; i++) {
OpusStreamContext *s = &c->streams[i];
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 5339fdd32c..4425279ce8 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -239,10 +239,6 @@ static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, char *magic,
os->start_trimming = 0;
os->end_trimming = 0;
- /* Chained files have extradata as a new packet */
- if (codec == &ff_opus_codec)
- os->header = -1;
-
return i;
}
diff --git a/libavformat/oggparseopus.c b/libavformat/oggparseopus.c
index 218e9df581..950b93bd31 100644
--- a/libavformat/oggparseopus.c
+++ b/libavformat/oggparseopus.c
@@ -125,6 +125,17 @@ static int opus_packet(AVFormatContext *avf, int idx)
return AVERROR_INVALIDDATA;
}
+ if (os->psize > 8 && !memcmp(packet, "OpusHead", 8)) {
+ if ((ret = ff_alloc_extradata(st->codecpar, os->psize)) < 0)
+ return ret;
+
+ memcpy(st->codecpar->extradata, packet, os->psize);
+ return 0;
+ }
+
+ if (os->psize > 8 && !memcmp(packet, "OpusTags", 8))
+ return 0;
+
if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && !(os->flags & OGG_FLAG_EOS)) {
int seg, d;
int duration;
--
2.39.5 (Apple Git-154)
_______________________________________________
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".
next prev parent reply other threads:[~2025-02-10 19:26 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-10 19:25 [FFmpeg-devel] [PATCH v4 0/5] Properly decode ogg metadata in ogg/flac and ogg/opus chained bitstreams Romain Beauxis
2025-02-10 19:25 ` Romain Beauxis [this message]
2025-02-10 19:25 ` [FFmpeg-devel] [PATCH v4 2/6] tests: Add stream dump test API util Romain Beauxis
2025-02-10 19:25 ` [FFmpeg-devel] [PATCH v4 3/6] Pass secondary ogg/opus chained streams metadata Romain Beauxis
2025-02-13 21:53 ` Lynne
2025-02-13 23:27 ` Romain Beauxis
2025-02-13 23:37 ` Lynne
2025-02-14 15:48 ` Romain Beauxis
2025-02-14 16:18 ` Lynne
2025-02-14 16:50 ` Romain Beauxis
2025-02-14 17:55 ` Lynne
2025-02-14 18:08 ` Romain Beauxis
2025-02-16 21:02 ` Romain Beauxis
2025-02-16 21:03 ` Romain Beauxis
2025-02-10 19:25 ` [FFmpeg-devel] [PATCH v4 4/6] tests: Add chained ogg/opus stream dump test Romain Beauxis
2025-02-10 19:25 ` [FFmpeg-devel] [PATCH v4 5/6] Parse secondary chained ogg/flac stream comments Romain Beauxis
2025-02-10 19:26 ` [FFmpeg-devel] [PATCH v4 6/6] tests: Add chained ogg/flac stream dump test Romain Beauxis
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=20250210192600.42502-2-romain.beauxis@gmail.com \
--to=romain.beauxis@gmail.com \
--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