From ff0107f60dbddec82d7d7feacd1c9a3ff9ab4a51 Mon Sep 17 00:00:00 2001 From: Yunqing Wang Date: Wed, 6 Jan 2016 18:27:37 -0800 Subject: Amend and improve VP8 multithreading implementation There are flaws in current implementation of VP8 multithreading encoder and decoder as reported in the following issue: https://code.google.com/p/chromium/issues/detail?id=158922 Although the data race warnings are harmless, and wouldn't cause real problems while encoding and decoding videos, it is better to fix the warnings so that VP8 code could pass the TSan test. To synchronize the thread-shared data access and maintain the speed (i.e. decoding speed), use multiple mutexes based on mb_rows to reduce the number of synchronizations needed, make the reads and writes of the shared data protected, and reduce the number of mb_col writes by nsync times. The decoder speed tests showed < 3% speed loss while using 2 ~ 4 threads. Change-Id: Ie296defffcd86a693188b668270d811964227882 --- vp8/encoder/onyx_int.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'vp8/encoder/onyx_int.h') diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h index 317e4b9e4..2b2f7a0a9 100644 --- a/vp8/encoder/onyx_int.h +++ b/vp8/encoder/onyx_int.h @@ -530,6 +530,8 @@ typedef struct VP8_COMP #if CONFIG_MULTITHREAD /* multithread data */ + pthread_mutex_t *pmutex; + pthread_mutex_t mt_mutex; /* mutex for b_multi_threaded */ int * mt_current_mb_col; int mt_sync_range; int b_multi_threaded; -- cgit v1.2.3