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

Function submit_packet

libavcodec/pthread_frame.c:499–561  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

497}
498
499static int submit_packet(PerThreadContext *p, AVCodecContext *user_avctx,
500 AVPacket *in_pkt)
501{
502 FrameThreadContext *fctx = p->parent;
503 PerThreadContext *prev_thread = fctx->prev_thread;
504 const AVCodec *codec = p->avctx->codec;
505 int ret;
506
507 pthread_mutex_lock(&p->mutex);
508
509 av_packet_unref(p->avpkt);
510 av_packet_move_ref(p->avpkt, in_pkt);
511
512 if (AVPACKET_IS_EMPTY(p->avpkt))
513 p->avctx->internal->draining = 1;
514
515 ret = update_context_from_user(p->avctx, user_avctx);
516 if (ret) {
517 pthread_mutex_unlock(&p->mutex);
518 return ret;
519 }
520 atomic_store_explicit(&p->debug_threads,
521 (p->avctx->debug & FF_DEBUG_THREADS) != 0,
522 memory_order_relaxed);
523
524 if (prev_thread) {
525 if (atomic_load(&prev_thread->state) == STATE_SETTING_UP) {
526 pthread_mutex_lock(&prev_thread->progress_mutex);
527 while (atomic_load(&prev_thread->state) == STATE_SETTING_UP)
528 pthread_cond_wait(&prev_thread->progress_cond, &prev_thread->progress_mutex);
529 pthread_mutex_unlock(&prev_thread->progress_mutex);
530 }
531
532 /* codecs without delay might not be prepared to be called repeatedly here during
533 * flushing (vp3/theora), and also don't need to be, since from this point on, they
534 * will always return EOF anyway */
535 if (!p->avctx->internal->draining ||
536 (codec->capabilities & AV_CODEC_CAP_DELAY)) {
537 ret = update_context_from_thread(p->avctx, prev_thread->avctx, 0);
538 if (ret) {
539 pthread_mutex_unlock(&p->mutex);
540 return ret;
541 }
542 }
543 }
544
545 /* transfer the stashed hwaccel state, if any */
546 av_assert0(!p->avctx->hwaccel || p->hwaccel_threadsafe);
547 if (!p->hwaccel_threadsafe) {
548 FFSWAP(const AVHWAccel*, p->avctx->hwaccel, fctx->stash_hwaccel);
549 FFSWAP(void*, p->avctx->hwaccel_context, fctx->stash_hwaccel_context);
550 FFSWAP(void*, p->avctx->internal->hwaccel_priv_data, fctx->stash_hwaccel_priv);
551 }
552
553 atomic_store(&p->state, STATE_SETTING_UP);
554 pthread_cond_signal(&p->input_cond);
555 pthread_mutex_unlock(&p->mutex);
556

Callers 1

ff_thread_receive_frameFunction · 0.85

Calls 8

av_packet_unrefFunction · 0.85
av_packet_move_refFunction · 0.85
update_context_from_userFunction · 0.85
pthread_mutex_lockFunction · 0.50
pthread_mutex_unlockFunction · 0.50
pthread_cond_waitFunction · 0.50
pthread_cond_signalFunction · 0.50

Tested by

no test coverage detected