44 int start_trim_flag, end_trim_flag, control_extension_flag, control_extension_length;
46 uint64_t payload_len_tmp;
51 flags = bytestream2_get_byte(&gb);
52 start_trim_flag = (flags >> 4) & 1;
53 end_trim_flag = (flags >> 3) & 1;
54 control_extension_flag = (flags >> 2) & 1;
56 payload_len_tmp = *payload_len = 0;
57 while (bytestream2_peek_byte(&gb) == 0xff)
58 payload_len_tmp += bytestream2_get_byte(&gb);
60 payload_len_tmp += bytestream2_get_byte(&gb);
66 if (control_extension_flag) {
67 control_extension_length = bytestream2_get_byte(&gb);
74 *payload_len = payload_len_tmp;
84 const uint8_t *
buf,
int buf_size,
int *header_len)
88 int ret, start_found, i = 0, payload_len = 0;
109 for (i = 0; i < buf_size-2; i++) {
110 state = (state << 8) | payload[i];
117 *header_len = payload -
buf;
125 payload_len = buf_size;
137 if (payload_len <= buf_size && (!s->
ts_framing || start_found)) {
150 if (payload_len + *header_len <= buf_size) {
153 return payload_len + *header_len;
166 const uint8_t **poutbuf,
int *poutbuf_size,
171 int next, header_len;
188 *poutbuf = buf + header_len;
189 *poutbuf_size = buf_size - header_len;
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.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int frame_count
frame count
static const uint8_t * parse_opus_ts_header(const uint8_t *start, int *payload_len, int buf_len)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
int duration
Duration of the current frame.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
ChannelMap * channel_maps
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
Combine the (truncated) bitstream to a complete frame.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
void ff_parse_close(AVCodecParserContext *s)
int frame_duration
frame duration, in samples @ 48kHz
static av_always_inline int bytestream2_tell(GetByteContext *g)
static int opus_parse(AVCodecParserContext *ctx, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
Libavcodec external API header.
main external API structure.
uint32_t state
contains the last few bytes in MSB order
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.
AVCodecParser ff_opus_parser
av_cold int ff_opus_parse_extradata(AVCodecContext *avctx, OpusContext *s)