static void frame_thread_free(AVCodecContext *avctx, int thread_count) { FrameThreadContext *fctx = avctx->thread_opaque; AVCodec *codec = avctx->codec; int i; park_frame_worker_threads(fctx, thread_count); if (fctx->prev_thread && fctx->prev_thread != fctx->threads) update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0); fctx->die = 1; for (i = 0; i < thread_count; i++) { PerThreadContext *p = &fctx->threads[i]; pthread_mutex_lock(&p->mutex); pthread_cond_signal(&p->input_cond); pthread_mutex_unlock(&p->mutex); if (p->thread_init) pthread_join(p->thread, NULL); p->thread_init=0; if (codec->close) codec->close(p->avctx); avctx->codec = NULL; release_delayed_buffers(p); } for (i = 0; i < thread_count; i++) { PerThreadContext *p = &fctx->threads[i]; avcodec_default_free_buffers(p->avctx); pthread_mutex_destroy(&p->mutex); pthread_mutex_destroy(&p->progress_mutex); pthread_cond_destroy(&p->input_cond); pthread_cond_destroy(&p->progress_cond); pthread_cond_destroy(&p->output_cond); av_freep(&p->avpkt.data); if (i) { av_freep(&p->avctx->priv_data); av_freep(&p->avctx->internal); av_freep(&p->avctx->slice_offset); } av_freep(&p->avctx); } av_freep(&fctx->threads); pthread_mutex_destroy(&fctx->buffer_mutex); av_freep(&avctx->thread_opaque); }
void MPV_common_end(MpegEncContext *s) { int i; av_freep(&s->cbp_table); if(s->picture) { for(i=0; i<MAX_PICTURE_COUNT; i++) { free_picture(s, &s->picture[i]); } } av_freep(&s->picture); avcodec_default_free_buffers(s->avctx); s->context_initialized = 0; s->last_picture_ptr= NULL; s->next_picture_ptr= NULL; s->current_picture_ptr= NULL; }
static int decode_end(AVCodecContext *avctx){ avcodec_default_free_buffers(avctx); return 0; }