]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/pthread.c
100l qprd fix 2nd try
[ffmpeg] / libavcodec / pthread.c
index 57bbfb29952def122a92a187c93c1ca1ea7b08cd..4737211cbc18cc3ca6ee9e211920b1390de83bc6 100644 (file)
@@ -5,19 +5,21 @@
  * to Michael Niedermayer <michaelni@gmx.at> for writing initial
  * implementation.
  *
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  *
  */
 #include <pthread.h>
@@ -53,24 +55,24 @@ static void* worker(void *v)
     pthread_mutex_lock(&c->current_job_lock);
     self_id = c->current_job++;
     for (;;){
-       while (our_job >= c->job_count) {
-           if (c->current_job == thread_count + c->job_count)
-               pthread_cond_signal(&c->last_job_cond);
+        while (our_job >= c->job_count) {
+            if (c->current_job == thread_count + c->job_count)
+                pthread_cond_signal(&c->last_job_cond);
 
-           pthread_cond_wait(&c->current_job_cond, &c->current_job_lock);
+            pthread_cond_wait(&c->current_job_cond, &c->current_job_lock);
             our_job = self_id;
 
-           if (c->done) {
-               pthread_mutex_unlock(&c->current_job_lock);
-               return NULL;
-           }
-       }
-       pthread_mutex_unlock(&c->current_job_lock);
+            if (c->done) {
+                pthread_mutex_unlock(&c->current_job_lock);
+                return NULL;
+            }
+        }
+        pthread_mutex_unlock(&c->current_job_lock);
 
-       c->rets[our_job%c->rets_count] = c->func(avctx, c->args[our_job]);
+        c->rets[our_job%c->rets_count] = c->func(avctx, c->args[our_job]);
 
-       pthread_mutex_lock(&c->current_job_lock);
-       our_job = c->current_job++;
+        pthread_mutex_lock(&c->current_job_lock);
+        our_job = c->current_job++;
     }
 }
 
@@ -116,10 +118,10 @@ int avcodec_thread_execute(AVCodecContext *avctx, action_t* func, void **arg, in
     c->func = func;
     if (ret) {
         c->rets = ret;
-       c->rets_count = job_count;
+        c->rets_count = job_count;
     } else {
         c->rets = &dummy_ret;
-       c->rets_count = 1;
+        c->rets_count = 1;
     }
     pthread_cond_broadcast(&c->current_job_cond);
 
@@ -154,8 +156,8 @@ int avcodec_thread_init(AVCodecContext *avctx, int thread_count)
     pthread_mutex_lock(&c->current_job_lock);
     for (i=0; i<thread_count; i++) {
         if(pthread_create(&c->workers[i], NULL, worker, avctx)) {
-          avctx->thread_count = i;
-          pthread_mutex_unlock(&c->current_job_lock);
+           avctx->thread_count = i;
+           pthread_mutex_unlock(&c->current_job_lock);
            avcodec_thread_free(avctx);
            return -1;
         }