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

Function init_thread

libavcodec/pthread_frame.c:819–914  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

817}
818
819static av_cold int init_thread(PerThreadContext *p, int *threads_to_free,
820 FrameThreadContext *fctx, AVCodecContext *avctx,
821 const FFCodec *codec, int first)
822{
823 AVCodecContext *copy;
824 int err;
825
826 atomic_init(&p->state, STATE_INPUT_READY);
827
828 copy = av_memdup(avctx, sizeof(*avctx));
829 if (!copy)
830 return AVERROR(ENOMEM);
831 copy->priv_data = NULL;
832 copy->decoded_side_data = NULL;
833 copy->nb_decoded_side_data = 0;
834
835 /* From now on, this PerThreadContext will be cleaned up by
836 * ff_frame_thread_free in case of errors. */
837 (*threads_to_free)++;
838
839 p->parent = fctx;
840 p->avctx = copy;
841
842 copy->internal = ff_decode_internal_alloc();
843 if (!copy->internal)
844 return AVERROR(ENOMEM);
845 ff_decode_internal_sync(copy, avctx);
846 copy->internal->thread_ctx = p;
847 copy->internal->progress_frame_pool = avctx->internal->progress_frame_pool;
848
849 copy->delay = avctx->delay;
850
851 if (codec->priv_data_size) {
852 copy->priv_data = av_mallocz(codec->priv_data_size);
853 if (!copy->priv_data)
854 return AVERROR(ENOMEM);
855
856 if (codec->p.priv_class) {
857 *(const AVClass **)copy->priv_data = codec->p.priv_class;
858 err = av_opt_copy(copy->priv_data, avctx->priv_data);
859 if (err < 0)
860 return err;
861 }
862 }
863
864 err = ff_pthread_init(p, per_thread_offsets);
865 if (err < 0)
866 return err;
867
868 if (!(p->avpkt = av_packet_alloc()))
869 return AVERROR(ENOMEM);
870
871 copy->internal->is_frame_mt = 1;
872 if (!first)
873 copy->internal->is_copy = 1;
874
875 copy->internal->in_pkt = av_packet_alloc();
876 if (!copy->internal->in_pkt)

Callers 1

ff_frame_thread_initFunction · 0.85

Calls 11

av_memdupFunction · 0.85
ff_decode_internal_allocFunction · 0.85
ff_decode_internal_syncFunction · 0.85
av_opt_copyFunction · 0.85
ff_pthread_initFunction · 0.85
av_packet_allocFunction · 0.85
av_frame_side_data_freeFunction · 0.85
av_frame_side_data_cloneFunction · 0.85
av_malloczFunction · 0.50
pthread_createFunction · 0.50

Tested by

no test coverage detected