Lines Matching refs:ctx
173 static int get_next_nal_unit(CodecParserContext *ctx, NALUnit *nalu)
175 const uint8_t *nalu_start = ctx->buf_ptr;
177 if (ctx->buf_end - ctx->buf_ptr >= 4 && AV_RB32(ctx->buf_ptr) == 0x00000001)
179 else if (ctx->buf_end - ctx->buf_ptr >= 3 && AV_RB24(ctx->buf_ptr) == 0x000001)
184 ctx->buf_ptr += nalu->start_code_length;
186 while (ctx->buf_ptr < ctx->buf_end) {
187 if (ctx->buf_end - ctx->buf_ptr >= 4 && AV_RB32(ctx->buf_ptr) == 0x00000001)
189 else if (ctx->buf_end - ctx->buf_ptr >= 3 && AV_RB24(ctx->buf_ptr) == 0x000001)
191 ctx->buf_ptr++;
195 nalu->length = ctx->buf_ptr - nalu->data;
236 CodecParserContext ctx;
241 memset(&ctx, 0, sizeof(ctx));
242 ctx.buf_ptr = pkt->data;
243 ctx.buf_end = pkt->data + pkt->size;
247 while (ctx.buf_ptr < ctx.buf_end) {
249 ret = get_next_nal_unit(&ctx, &nalu);
269 static int get_next_adts_frame(CodecParserContext *ctx, AudioFrame *frame)
276 while (ctx->buf_ptr < ctx->buf_end - 1) {
277 if (*ctx->buf_ptr == 0xFF && (*(ctx->buf_ptr + 1) & 0xF0) == 0xF0)
279 ctx->buf_ptr++;
282 if (ctx->buf_ptr >= ctx->buf_end - 1)
285 frame->data = (uint8_t*)ctx->buf_ptr;
287 ret = avpriv_adts_header_parse (&adts_hdr, frame->data, ctx->buf_end - frame->data);
299 static int get_next_ac3_eac3_sync_frame(CodecParserContext *ctx, AudioFrame *frame)
306 while (ctx->buf_ptr < ctx->buf_end - 1) {
307 if (*ctx->buf_ptr == 0x0B && *(ctx->buf_ptr + 1) == 0x77)
309 ctx->buf_ptr++;
312 if (ctx->buf_ptr >= ctx->buf_end - 1)
315 frame->data = (uint8_t*)ctx->buf_ptr;
318 ret = avpriv_ac3_parse_header(&hdr, frame->data, ctx->buf_end - frame->data);
332 static int get_next_sync_frame(enum AVCodecID codec_id, CodecParserContext *ctx, AudioFrame *frame)
335 return get_next_adts_frame(ctx, frame);
337 return get_next_ac3_eac3_sync_frame(ctx, frame);
364 CodecParserContext ctx;
367 memset(&ctx, 0, sizeof(ctx));
368 ctx.buf_ptr = pkt->data;
369 ctx.buf_end = pkt->data + pkt->size;
371 while (ctx.buf_ptr < ctx.buf_end) {
373 ret = get_next_sync_frame(codec_id, &ctx, &frame);
381 ctx.buf_ptr += frame.length;