/* Free what has been allocated by avcodec_thread_init(). Must be called after decoding has finished, especially do not call while avcodec_thread_execute() is running.  */
void avcodec_thread_free(AVCodecContext *s)
/* Free what has been allocated by avcodec_thread_init(). Must be called after decoding has finished, especially do not call while avcodec_thread_execute() is running.  */
void avcodec_thread_free(AVCodecContext *s)
{
        c[i].func= NULL;
        c[i].func2= NULL;
    }
    ReleaseSemaphore(c[0].work_sem, s->thread_count, 0);
    for(i=0; i<s->thread_count; i++){
        WaitForSingleObject(c[i].thread, INFINITE);
        if(c[i].thread)   CloseHandle(c[i].thread);
    }
    if(c[0].work_sem) CloseHandle(c[0].work_sem);
    if(c[0].job_sem)  CloseHandle(c[0].job_sem);
    if(c[0].done_sem) CloseHandle(c[0].done_sem);
    av_freep(&s->thread_opaque);
}