MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / opus_parse

Function opus_parse

libavcodec/opus/parser.c:170–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168}
169
170static int opus_parse(AVCodecParserContext *ctx, AVCodecContext *avctx,
171 const uint8_t **poutbuf, int *poutbuf_size,
172 const uint8_t *buf, int buf_size)
173{
174 OpusParserContext *s = ctx->priv_data;
175 ParseContext *pc = &s->pc;
176 int next, header_len = 0;
177
178 avctx->sample_rate = 48000;
179
180 if (avctx->extradata && !s->extradata_parsed) {
181 if (ff_opus_parse_extradata(avctx, &s->ctx) < 0) {
182 av_log(avctx, AV_LOG_ERROR, "Error parsing Ogg extradata.\n");
183 goto fail;
184 }
185 av_freep(&s->ctx.channel_maps);
186 s->extradata_parsed = 1;
187 }
188
189 if (ctx->flags & PARSER_FLAG_COMPLETE_FRAMES) {
190 next = buf_size;
191
192 if (buf_size && set_frame_duration(ctx, avctx, buf, buf_size) < 0)
193 goto fail;
194 } else {
195 next = opus_find_frame_end(ctx, avctx, buf, buf_size, &header_len);
196
197 if (s->ts_framing && next != AVERROR_INVALIDDATA &&
198 ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
199 goto fail;
200 }
201
202 if (next == AVERROR_INVALIDDATA){
203 goto fail;
204 }
205 }
206
207 *poutbuf = buf + header_len;
208 *poutbuf_size = buf_size - header_len;
209 return next;
210
211fail:
212 *poutbuf = NULL;
213 *poutbuf_size = 0;
214 return buf_size;
215}
216
217const FFCodecParser ff_opus_parser = {
218 PARSER_CODEC_LIST(AV_CODEC_ID_OPUS),

Callers

nothing calls this directly

Calls 6

ff_opus_parse_extradataFunction · 0.85
av_logFunction · 0.85
av_freepFunction · 0.85
set_frame_durationFunction · 0.85
opus_find_frame_endFunction · 0.85
ff_combine_frameFunction · 0.85

Tested by

no test coverage detected