Merge commit 'daa7a1d4431b6acf1f93c4a98b3de123abf4ca18'
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 4 Nov 2013 10:05:52 +0000 (11:05 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 4 Nov 2013 10:05:52 +0000 (11:05 +0100)
* commit 'daa7a1d4431b6acf1f93c4a98b3de123abf4ca18':
  pthread_slice: rename ThreadContext -> SliceThreadContext

Conflicts:
libavcodec/pthread_slice.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/pthread_slice.c

@@@ -60,13 -58,7 +60,13 @@@ typedef struct SliceThreadContext 
      unsigned current_execute;
      int current_job;
      int done;
- } ThreadContext;
 +
 +    int *entries;
 +    int entries_count;
 +    int thread_count;
 +    pthread_cond_t *progress_cond;
 +    pthread_mutex_t *progress_mutex;
+ } SliceThreadContext;
  
  static void* attribute_align_arg worker(void *v)
  {
@@@ -231,62 -222,3 +231,62 @@@ int ff_slice_thread_init(AVCodecContex
      avctx->execute2 = thread_execute2;
      return 0;
  }
-     ThreadContext *p = avctx->thread_opaque;
 +
 +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]);
 +    entries[field] +=n;
 +    pthread_cond_signal(&p->progress_cond[thread]);
 +    pthread_mutex_unlock(&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;
 +
 +    thread = thread ? thread - 1 : p->thread_count - 1;
 +
 +    pthread_mutex_lock(&p->progress_mutex[thread]);
 +    while ((entries[field - 1] - entries[field]) < shift){
 +        pthread_cond_wait(&p->progress_cond[thread], &p->progress_mutex[thread]);
 +    }
 +    pthread_mutex_unlock(&p->progress_mutex[thread]);
 +}
 +
 +int ff_alloc_entries(AVCodecContext *avctx, int count)
 +{
 +    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));
 +
 +        if (!p->entries) {
 +            return AVERROR(ENOMEM);
 +        }
 +
 +        p->entries_count  = count;
 +        p->progress_mutex = av_malloc(p->thread_count * sizeof(pthread_mutex_t));
 +        p->progress_cond  = av_malloc(p->thread_count * sizeof(pthread_cond_t));
 +
 +        for (i = 0; i < p->thread_count; i++) {
 +            pthread_mutex_init(&p->progress_mutex[i], NULL);
 +            pthread_cond_init(&p->progress_cond[i], NULL);
 +        }
 +    }
 +
 +    return 0;
 +}
 +
 +void ff_reset_entries(AVCodecContext *avctx)
 +{
++    SliceThreadContext *p = avctx->thread_opaque;
 +    memset(p->entries, 0, p->entries_count * sizeof(int));
 +}