Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(881)

Side by Side Diff: source/libvpx/vp9/common/vp9_thread.h

Issue 958693004: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/libvpx/vp9/common/vp9_rtcd_defs.pl ('k') | source/libvpx/vp9/common/vp9_thread_common.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 Google Inc. All Rights Reserved. 1 // Copyright 2013 Google Inc. All Rights Reserved.
2 // 2 //
3 // Use of this source code is governed by a BSD-style license 3 // Use of this source code is governed by a BSD-style license
4 // that can be found in the COPYING file in the root of the source 4 // that can be found in the COPYING file in the root of the source
5 // tree. An additional intellectual property rights grant can be found 5 // tree. An additional intellectual property rights grant can be found
6 // in the file PATENTS. All contributing project authors may 6 // in the file PATENTS. All contributing project authors may
7 // be found in the AUTHORS file in the root of the source tree. 7 // be found in the AUTHORS file in the root of the source tree.
8 // ----------------------------------------------------------------------------- 8 // -----------------------------------------------------------------------------
9 // 9 //
10 // Multi-threaded worker 10 // Multi-threaded worker
11 // 11 //
12 // Original source: 12 // Original source:
13 // http://git.chromium.org/webm/libwebp.git 13 // http://git.chromium.org/webm/libwebp.git
14 // 100644 blob 7bd451b124ae3b81596abfbcc823e3cb129d3a38 src/utils/thread.h 14 // 100644 blob 7bd451b124ae3b81596abfbcc823e3cb129d3a38 src/utils/thread.h
15 15
16 #ifndef VP9_DECODER_VP9_THREAD_H_ 16 #ifndef VP9_DECODER_VP9_THREAD_H_
17 #define VP9_DECODER_VP9_THREAD_H_ 17 #define VP9_DECODER_VP9_THREAD_H_
18 18
19 #include "./vpx_config.h" 19 #include "./vpx_config.h"
20 20
21 #ifdef __cplusplus 21 #ifdef __cplusplus
22 extern "C" { 22 extern "C" {
23 #endif 23 #endif
24 24
25 // Set maximum decode threads to be 8 due to the limit of frame buffers
26 // and not enough semaphores in the emulation layer on windows.
27 #define MAX_DECODE_THREADS 8
28
25 #if CONFIG_MULTITHREAD 29 #if CONFIG_MULTITHREAD
26 30
27 #if defined(_WIN32) 31 #if defined(_WIN32) && !HAVE_PTHREAD_H
28 #include <errno.h> // NOLINT 32 #include <errno.h> // NOLINT
29 #include <process.h> // NOLINT 33 #include <process.h> // NOLINT
30 #include <windows.h> // NOLINT 34 #include <windows.h> // NOLINT
31 typedef HANDLE pthread_t; 35 typedef HANDLE pthread_t;
32 typedef CRITICAL_SECTION pthread_mutex_t; 36 typedef CRITICAL_SECTION pthread_mutex_t;
33 typedef struct { 37 typedef struct {
34 HANDLE waiting_sem_; 38 HANDLE waiting_sem_;
35 HANDLE received_sem_; 39 HANDLE received_sem_;
36 HANDLE signal_event_; 40 HANDLE signal_event_;
37 } pthread_cond_t; 41 } pthread_cond_t;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 int ok = 1; 100 int ok = 1;
97 ok &= (CloseHandle(condition->waiting_sem_) != 0); 101 ok &= (CloseHandle(condition->waiting_sem_) != 0);
98 ok &= (CloseHandle(condition->received_sem_) != 0); 102 ok &= (CloseHandle(condition->received_sem_) != 0);
99 ok &= (CloseHandle(condition->signal_event_) != 0); 103 ok &= (CloseHandle(condition->signal_event_) != 0);
100 return !ok; 104 return !ok;
101 } 105 }
102 106
103 static INLINE int pthread_cond_init(pthread_cond_t *const condition, 107 static INLINE int pthread_cond_init(pthread_cond_t *const condition,
104 void* cond_attr) { 108 void* cond_attr) {
105 (void)cond_attr; 109 (void)cond_attr;
106 condition->waiting_sem_ = CreateSemaphore(NULL, 0, 1, NULL); 110 condition->waiting_sem_ = CreateSemaphore(NULL, 0, MAX_DECODE_THREADS, NULL);
107 condition->received_sem_ = CreateSemaphore(NULL, 0, 1, NULL); 111 condition->received_sem_ = CreateSemaphore(NULL, 0, MAX_DECODE_THREADS, NULL);
108 condition->signal_event_ = CreateEvent(NULL, FALSE, FALSE, NULL); 112 condition->signal_event_ = CreateEvent(NULL, FALSE, FALSE, NULL);
109 if (condition->waiting_sem_ == NULL || 113 if (condition->waiting_sem_ == NULL ||
110 condition->received_sem_ == NULL || 114 condition->received_sem_ == NULL ||
111 condition->signal_event_ == NULL) { 115 condition->signal_event_ == NULL) {
112 pthread_cond_destroy(condition); 116 pthread_cond_destroy(condition);
113 return 1; 117 return 1;
114 } 118 }
115 return 0; 119 return 0;
116 } 120 }
117 121
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // Retrieve the currently set thread worker interface. 214 // Retrieve the currently set thread worker interface.
211 const VP9WorkerInterface *vp9_get_worker_interface(void); 215 const VP9WorkerInterface *vp9_get_worker_interface(void);
212 216
213 //------------------------------------------------------------------------------ 217 //------------------------------------------------------------------------------
214 218
215 #ifdef __cplusplus 219 #ifdef __cplusplus
216 } // extern "C" 220 } // extern "C"
217 #endif 221 #endif
218 222
219 #endif // VP9_DECODER_VP9_THREAD_H_ 223 #endif // VP9_DECODER_VP9_THREAD_H_
OLDNEW
« no previous file with comments | « source/libvpx/vp9/common/vp9_rtcd_defs.pl ('k') | source/libvpx/vp9/common/vp9_thread_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698