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

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

Issue 375983002: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_dthread.c ('k') | source/libvpx/vp9/decoder/vp9_thread.c » ('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 13a61a4c84194c3374080cbf03d881d3cd6af40d src/utils/thread.h 14 // 100644 blob 7bd451b124ae3b81596abfbcc823e3cb129d3a38 src/utils/thread.h
15
16 15
17 #ifndef VP9_DECODER_VP9_THREAD_H_ 16 #ifndef VP9_DECODER_VP9_THREAD_H_
18 #define VP9_DECODER_VP9_THREAD_H_ 17 #define VP9_DECODER_VP9_THREAD_H_
19 18
20 #include "./vpx_config.h" 19 #include "./vpx_config.h"
21 20
22 #ifdef __cplusplus 21 #ifdef __cplusplus
23 extern "C" { 22 extern "C" {
24 #endif 23 #endif
25 24
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 typedef enum { 155 typedef enum {
157 NOT_OK = 0, // object is unusable 156 NOT_OK = 0, // object is unusable
158 OK, // ready to work 157 OK, // ready to work
159 WORK // busy finishing the current task 158 WORK // busy finishing the current task
160 } VP9WorkerStatus; 159 } VP9WorkerStatus;
161 160
162 // Function to be called by the worker thread. Takes two opaque pointers as 161 // Function to be called by the worker thread. Takes two opaque pointers as
163 // arguments (data1 and data2), and should return false in case of error. 162 // arguments (data1 and data2), and should return false in case of error.
164 typedef int (*VP9WorkerHook)(void*, void*); 163 typedef int (*VP9WorkerHook)(void*, void*);
165 164
166 // Synchronize object used to launch job in the worker thread 165 // Platform-dependent implementation details for the worker.
166 typedef struct VP9WorkerImpl VP9WorkerImpl;
167
168 // Synchronization object used to launch job in the worker thread
167 typedef struct { 169 typedef struct {
168 #if CONFIG_MULTITHREAD 170 VP9WorkerImpl *impl_;
169 pthread_mutex_t mutex_;
170 pthread_cond_t condition_;
171 pthread_t thread_;
172 #endif
173 VP9WorkerStatus status_; 171 VP9WorkerStatus status_;
174 VP9WorkerHook hook; // hook to call 172 VP9WorkerHook hook; // hook to call
175 void* data1; // first argument passed to 'hook' 173 void *data1; // first argument passed to 'hook'
176 void* data2; // second argument passed to 'hook' 174 void *data2; // second argument passed to 'hook'
177 int had_error; // return value of the last call to 'hook' 175 int had_error; // return value of the last call to 'hook'
178 } VP9Worker; 176 } VP9Worker;
179 177
180 // Must be called first, before any other method. 178 // The interface for all thread-worker related functions. All these functions
181 void vp9_worker_init(VP9Worker* const worker); 179 // must be implemented.
182 // Must be called to initialize the object and spawn the thread. Re-entrant. 180 typedef struct {
183 // Will potentially launch the thread. Returns false in case of error. 181 // Must be called first, before any other method.
184 int vp9_worker_reset(VP9Worker* const worker); 182 void (*init)(VP9Worker *const worker);
185 // Makes sure the previous work is finished. Returns true if worker->had_error 183 // Must be called to initialize the object and spawn the thread. Re-entrant.
186 // was not set and no error condition was triggered by the working thread. 184 // Will potentially launch the thread. Returns false in case of error.
187 int vp9_worker_sync(VP9Worker* const worker); 185 int (*reset)(VP9Worker *const worker);
188 // Triggers the thread to call hook() with data1 and data2 argument. These 186 // Makes sure the previous work is finished. Returns true if worker->had_error
189 // hook/data1/data2 can be changed at any time before calling this function, 187 // was not set and no error condition was triggered by the working thread.
190 // but not be changed afterward until the next call to vp9_worker_sync(). 188 int (*sync)(VP9Worker *const worker);
191 void vp9_worker_launch(VP9Worker* const worker); 189 // Triggers the thread to call hook() with data1 and data2 arguments. These
192 // This function is similar to vp9_worker_launch() except that it calls the 190 // hook/data1/data2 values can be changed at any time before calling this
193 // hook directly instead of using a thread. Convenient to bypass the thread 191 // function, but not be changed afterward until the next call to Sync().
194 // mechanism while still using the VP9Worker structs. vp9_worker_sync() must 192 void (*launch)(VP9Worker *const worker);
195 // still be called afterward (for error reporting). 193 // This function is similar to launch() except that it calls the
196 void vp9_worker_execute(VP9Worker* const worker); 194 // hook directly instead of using a thread. Convenient to bypass the thread
197 // Kill the thread and terminate the object. To use the object again, one 195 // mechanism while still using the VP9Worker structs. sync() must
198 // must call vp9_worker_reset() again. 196 // still be called afterward (for error reporting).
199 void vp9_worker_end(VP9Worker* const worker); 197 void (*execute)(VP9Worker *const worker);
198 // Kill the thread and terminate the object. To use the object again, one
199 // must call reset() again.
200 void (*end)(VP9Worker *const worker);
201 } VP9WorkerInterface;
202
203 // Install a new set of threading functions, overriding the defaults. This
204 // should be done before any workers are started, i.e., before any encoding or
205 // decoding takes place. The contents of the interface struct are copied, it
206 // is safe to free the corresponding memory after this call. This function is
207 // not thread-safe. Return false in case of invalid pointer or methods.
208 int vp9_set_worker_interface(const VP9WorkerInterface *const winterface);
209
210 // Retrieve the currently set thread worker interface.
211 const VP9WorkerInterface *vp9_get_worker_interface(void);
200 212
201 //------------------------------------------------------------------------------ 213 //------------------------------------------------------------------------------
202 214
203 #ifdef __cplusplus 215 #ifdef __cplusplus
204 } // extern "C" 216 } // extern "C"
205 #endif 217 #endif
206 218
207 #endif // VP9_DECODER_VP9_THREAD_H_ 219 #endif // VP9_DECODER_VP9_THREAD_H_
OLDNEW
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_dthread.c ('k') | source/libvpx/vp9/decoder/vp9_thread.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698