ffmpeg | branch: master | James Almer <jamr...@gmail.com> | Wed Jan  1 12:11:15 
2025 -0300| [873a34c129869e551cb7d3d2445e28c0ba079948] | committer: James Almer

avcodec/opus/parser: set sample rate

Ensures it's set on scenarios where a parser is requested but no decoder is
present.

Signed-off-by: James Almer <jamr...@gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=873a34c129869e551cb7d3d2445e28c0ba079948
---

 libavcodec/opus/parser.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavcodec/opus/parser.c b/libavcodec/opus/parser.c
index 41665e68f9..eb16562530 100644
--- a/libavcodec/opus/parser.c
+++ b/libavcodec/opus/parser.c
@@ -170,9 +170,14 @@ static int opus_parse(AVCodecParserContext *ctx, 
AVCodecContext *avctx,
 {
     OpusParserContext *s = ctx->priv_data;
     ParseContext *pc    = &s->pc;
-    int next, header_len;
+    int next, header_len = 0;
 
-    next = opus_find_frame_end(ctx, avctx, buf, buf_size, &header_len);
+    avctx->sample_rate = 48000;
+
+    if (ctx->flags & PARSER_FLAG_COMPLETE_FRAMES)
+        next = buf_size;
+    else {
+        next = opus_find_frame_end(ctx, avctx, buf, buf_size, &header_len);
 
     if (s->ts_framing && next != AVERROR_INVALIDDATA &&
         ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
@@ -186,6 +191,7 @@ static int opus_parse(AVCodecParserContext *ctx, 
AVCodecContext *avctx,
         *poutbuf_size = 0;
         return buf_size;
     }
+    }
 
     *poutbuf      = buf + header_len;
     *poutbuf_size = buf_size - header_len;

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to