| 749 | #undef OFF |
| 750 | |
| 751 | av_cold void ff_frame_thread_free(AVCodecContext *avctx, int thread_count) |
| 752 | { |
| 753 | FrameThreadContext *fctx = avctx->internal->thread_ctx; |
| 754 | const FFCodec *codec = ffcodec(avctx->codec); |
| 755 | int i; |
| 756 | |
| 757 | park_frame_worker_threads(fctx, thread_count); |
| 758 | |
| 759 | for (i = 0; i < thread_count; i++) { |
| 760 | PerThreadContext *p = &fctx->threads[i]; |
| 761 | AVCodecContext *ctx = p->avctx; |
| 762 | |
| 763 | if (ctx->internal) { |
| 764 | if (p->thread_init == INITIALIZED) { |
| 765 | pthread_mutex_lock(&p->mutex); |
| 766 | p->die = 1; |
| 767 | pthread_cond_signal(&p->input_cond); |
| 768 | pthread_mutex_unlock(&p->mutex); |
| 769 | |
| 770 | pthread_join(p->thread, NULL); |
| 771 | } |
| 772 | if (codec->close && p->thread_init != UNINITIALIZED) |
| 773 | codec->close(ctx); |
| 774 | |
| 775 | /* When using a threadsafe hwaccel, this is where |
| 776 | * each thread's context is uninit'd and freed. */ |
| 777 | ff_hwaccel_uninit(ctx); |
| 778 | |
| 779 | if (ctx->priv_data) { |
| 780 | if (codec->p.priv_class) |
| 781 | av_opt_free(ctx->priv_data); |
| 782 | av_freep(&ctx->priv_data); |
| 783 | } |
| 784 | |
| 785 | av_refstruct_unref(&ctx->internal->pool); |
| 786 | av_packet_free(&ctx->internal->in_pkt); |
| 787 | av_packet_free(&ctx->internal->last_pkt_props); |
| 788 | ff_decode_internal_uninit(ctx); |
| 789 | av_freep(&ctx->internal); |
| 790 | av_buffer_unref(&ctx->hw_frames_ctx); |
| 791 | av_frame_side_data_free(&ctx->decoded_side_data, |
| 792 | &ctx->nb_decoded_side_data); |
| 793 | } |
| 794 | |
| 795 | decoded_frames_free(&p->df); |
| 796 | |
| 797 | ff_pthread_free(p, per_thread_offsets); |
| 798 | av_packet_free(&p->avpkt); |
| 799 | |
| 800 | av_freep(&p->avctx); |
| 801 | } |
| 802 | |
| 803 | decoded_frames_free(&fctx->df); |
| 804 | av_packet_free(&fctx->next_pkt); |
| 805 | |
| 806 | av_freep(&fctx->threads); |
| 807 | ff_pthread_free(fctx, thread_ctx_offsets); |
| 808 |
no test coverage detected