Go to the documentation of this file.
46 const uint8_t *buf = start + 1;
47 int start_trim_flag, end_trim_flag, control_extension_flag, control_extension_length;
49 uint64_t payload_len_tmp;
54 flags = bytestream2_get_byte(&gb);
55 start_trim_flag = (
flags >> 4) & 1;
56 end_trim_flag = (
flags >> 3) & 1;
57 control_extension_flag = (
flags >> 2) & 1;
59 payload_len_tmp = *payload_len = 0;
60 while (bytestream2_peek_byte(&gb) == 0xff)
61 payload_len_tmp += bytestream2_get_byte(&gb);
63 payload_len_tmp += bytestream2_get_byte(&gb);
69 if (control_extension_flag) {
70 control_extension_length = bytestream2_get_byte(&gb);
77 *payload_len = payload_len_tmp;
83 const uint8_t *buf,
int buf_size)
102 const uint8_t *buf,
int buf_size,
int *header_len)
106 int ret, start_found,
i = 0, payload_len = 0;
107 const uint8_t *payload;
120 if (!
s->ts_framing && buf_size > 2) {
126 if (
s->ts_framing && !start_found) {
127 for (
i = 0;
i < buf_size-2;
i++) {
135 *header_len = payload - buf;
143 payload_len = buf_size;
145 if (payload_len <= buf_size && (!
s->ts_framing || start_found)) {
155 if (payload_len + *header_len <= buf_size) {
158 return payload_len + *header_len;
171 const uint8_t **poutbuf,
int *poutbuf_size,
172 const uint8_t *buf,
int buf_size)
176 int next, header_len = 0;
180 if (avctx->
extradata && !
s->extradata_parsed) {
186 s->extradata_parsed = 1;
207 *poutbuf = buf + header_len;
208 *poutbuf_size = buf_size - header_len;
int sample_rate
samples per second
static av_always_inline int bytestream2_tell(const GetByteContext *g)
av_cold void ff_parse_close(AVCodecParserContext *s)
static const uint8_t * parse_opus_ts_header(const uint8_t *start, int *payload_len, int buf_len)
uint32_t state
contains the last few bytes in MSB order
static av_cold void close(AVCodecParserContext *s)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int flags
Flags modifying the (de)muxer behaviour.
av_cold int ff_opus_parse_extradata(AVCodecContext *avctx, OpusParseContext *s)
const FFCodecParser ff_opus_parser
static int set_frame_duration(AVCodecParserContext *ctx, AVCodecContext *avctx, const uint8_t *buf, int buf_size)
static int parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
static int opus_parse(AVCodecParserContext *ctx, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
Combine the (truncated) bitstream to a complete frame.
#define PARSER_FLAG_COMPLETE_FRAMES
#define i(width, name, range_min, range_max)
static int opus_find_frame_end(AVCodecParserContext *ctx, AVCodecContext *avctx, const uint8_t *buf, int buf_size, int *header_len)
Find the end of the current frame in the bitstream.
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
#define PARSER_CODEC_LIST(...)
main external API structure.
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int ff_opus_parse_packet(OpusPacket *pkt, const uint8_t *buf, int buf_size, int self_delimiting)
Parse Opus packet info from raw packet data.
void * priv_data
Format private data.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16