typedef int (action_func)(AVCodecContext *c, void *arg);
typedef int (action_func2)(AVCodecContext *c, void *arg, int jobnr, int threadnr);
-typedef struct ThreadContext {
+typedef struct SliceThreadContext {
pthread_t *workers;
action_func *func;
action_func2 *func2;
int thread_count;
pthread_cond_t *progress_cond;
pthread_mutex_t *progress_mutex;
-} ThreadContext;
+} SliceThreadContext;
static void* attribute_align_arg worker(void *v)
{
AVCodecContext *avctx = v;
- ThreadContext *c = avctx->thread_opaque;
+ SliceThreadContext *c = avctx->thread_opaque;
unsigned last_execute = 0;
int our_job = c->job_count;
int thread_count = avctx->thread_count;
void ff_slice_thread_free(AVCodecContext *avctx)
{
- ThreadContext *c = avctx->thread_opaque;
+ SliceThreadContext *c = avctx->thread_opaque;
int i;
pthread_mutex_lock(&c->current_job_lock);
av_freep(&avctx->thread_opaque);
}
-static av_always_inline void thread_park_workers(ThreadContext *c, int thread_count)
+static av_always_inline void thread_park_workers(SliceThreadContext *c, int thread_count)
{
while (c->current_job != thread_count + c->job_count)
pthread_cond_wait(&c->last_job_cond, &c->current_job_lock);
static int thread_execute(AVCodecContext *avctx, action_func* func, void *arg, int *ret, int job_count, int job_size)
{
- ThreadContext *c= avctx->thread_opaque;
+ SliceThreadContext *c = avctx->thread_opaque;
int dummy_ret;
if (!(avctx->active_thread_type&FF_THREAD_SLICE) || avctx->thread_count <= 1)
static int thread_execute2(AVCodecContext *avctx, action_func2* func2, void *arg, int *ret, int job_count)
{
- ThreadContext *c= avctx->thread_opaque;
+ SliceThreadContext *c = avctx->thread_opaque;
c->func2 = func2;
return thread_execute(avctx, NULL, arg, ret, job_count, 0);
}
int ff_slice_thread_init(AVCodecContext *avctx)
{
int i;
- ThreadContext *c;
+ SliceThreadContext *c;
int thread_count = avctx->thread_count;
#if HAVE_W32THREADS
return 0;
}
- c = av_mallocz(sizeof(ThreadContext));
+ c = av_mallocz(sizeof(SliceThreadContext));
if (!c)
return -1;
void ff_thread_report_progress2(AVCodecContext *avctx, int field, int thread, int n)
{
- ThreadContext *p = avctx->thread_opaque;
+ SliceThreadContext *p = avctx->thread_opaque;
int *entries = p->entries;
pthread_mutex_lock(&p->progress_mutex[thread]);
void ff_thread_await_progress2(AVCodecContext *avctx, int field, int thread, int shift)
{
- ThreadContext *p = avctx->thread_opaque;
+ SliceThreadContext *p = avctx->thread_opaque;
int *entries = p->entries;
if (!entries || !field) return;
int i;
if (avctx->active_thread_type & FF_THREAD_SLICE) {
- ThreadContext *p = avctx->thread_opaque;
+ SliceThreadContext *p = avctx->thread_opaque;
p->thread_count = avctx->thread_count;
p->entries = av_mallocz(count * sizeof(int));
void ff_reset_entries(AVCodecContext *avctx)
{
- ThreadContext *p = avctx->thread_opaque;
+ SliceThreadContext *p = avctx->thread_opaque;
memset(p->entries, 0, p->entries_count * sizeof(int));
}