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

Function receive_for_stream

fftools/sync_queue.c:502–560  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

500}
501
502static int receive_for_stream(SyncQueue *sq, unsigned int stream_idx,
503 SyncQueueFrame frame)
504{
505 const SyncQueueStream *st_head = sq->head_stream >= 0 ?
506 &sq->streams[sq->head_stream] : NULL;
507 SyncQueueStream *st;
508
509 av_assert0(stream_idx < sq->nb_streams);
510 st = &sq->streams[stream_idx];
511
512 if (av_container_fifo_can_read(st->fifo) &&
513 (st->frame_samples <= st->samples_queued || st->finished)) {
514 int nb_samples = st->frame_samples;
515 SyncQueueFrame peek;
516 int64_t ts;
517 int cmp = 1;
518
519 if (st->finished)
520 nb_samples = FFMIN(nb_samples, st->samples_queued);
521
522 av_container_fifo_peek(st->fifo, (void**)&peek, 0);
523 ts = frame_end(sq, peek, nb_samples);
524
525 /* check if this stream's tail timestamp does not overtake
526 * the overall queue head */
527 if (ts != AV_NOPTS_VALUE && st_head)
528 cmp = av_compare_ts(ts, st->tb, st_head->head_ts, st_head->tb);
529
530 /* We can release frames that do not end after the queue head.
531 * Frames with no timestamps are just passed through with no conditions.
532 * Frames are also passed through when there are no limiting streams.
533 */
534 if (cmp <= 0 || ts == AV_NOPTS_VALUE || !sq->have_limiting) {
535 if (nb_samples &&
536 (nb_samples != peek.f->nb_samples || !frame_is_aligned(sq, peek.f))) {
537 int ret = receive_samples(sq, st, frame.f, nb_samples);
538 if (ret < 0)
539 return ret;
540 } else {
541 int ret = av_container_fifo_read(st->fifo, SQPTR(sq, frame), 0);
542 av_assert0(ret >= 0);
543
544 av_assert0(st->samples_queued >= frame_samples(sq, frame));
545 st->samples_queued -= frame_samples(sq, frame);
546 }
547
548 av_log(sq->logctx, AV_LOG_DEBUG,
549 "sq: receive %u ts %s queue head %d ts %s\n", stream_idx,
550 av_ts2timestr(frame_end(sq, frame, 0), &st->tb),
551 sq->head_stream,
552 st_head ? av_ts2timestr(st_head->head_ts, &st_head->tb) : "N/A");
553
554 return 0;
555 }
556 }
557
558 return (sq->finished || (st->finished && !av_container_fifo_can_read(st->fifo))) ?
559 AVERROR_EOF : AVERROR(EAGAIN);

Callers 1

receive_internalFunction · 0.85

Calls 9

av_container_fifo_peekFunction · 0.85
av_compare_tsFunction · 0.85
frame_is_alignedFunction · 0.85
receive_samplesFunction · 0.85
av_container_fifo_readFunction · 0.85
frame_samplesFunction · 0.85
av_logFunction · 0.85
frame_endFunction · 0.70

Tested by

no test coverage detected