1 /* 2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef VPX_VP9_COMMON_VP9_THREAD_COMMON_H_ 12 #define VPX_VP9_COMMON_VP9_THREAD_COMMON_H_ 13 #include "./vpx_config.h" 14 #include "vp9/common/vp9_loopfilter.h" 15 #include "vpx_util/vpx_pthread.h" 16 #include "vpx_util/vpx_thread.h" 17 18 #ifdef __cplusplus 19 extern "C" { 20 #endif 21 22 struct VP9Common; 23 struct FRAME_COUNTS; 24 25 // Loopfilter row synchronization 26 typedef struct VP9LfSyncData { 27 #if CONFIG_MULTITHREAD 28 pthread_mutex_t *mutex; 29 pthread_cond_t *cond; 30 #endif 31 // Allocate memory to store the loop-filtered superblock index in each row. 32 int *cur_sb_col; 33 // The optimal sync_range for different resolution and platform should be 34 // determined by testing. Currently, it is chosen to be a power-of-2 number. 35 int sync_range; 36 int rows; 37 38 // Row-based parallel loopfilter data 39 LFWorkerData *lfdata; 40 int num_workers; // number of allocated workers. 41 int num_active_workers; // number of scheduled workers. 42 43 #if CONFIG_MULTITHREAD 44 pthread_mutex_t *lf_mutex; 45 pthread_mutex_t *recon_done_mutex; 46 pthread_cond_t *recon_done_cond; 47 #endif 48 int *num_tiles_done; 49 int corrupted; 50 } VP9LfSync; 51 52 // Allocate memory for loopfilter row synchronization. 53 void vp9_loop_filter_alloc(VP9LfSync *lf_sync, struct VP9Common *cm, int rows, 54 int width, int num_workers); 55 56 // Deallocate loopfilter synchronization related mutex and data. 57 void vp9_loop_filter_dealloc(VP9LfSync *lf_sync); 58 59 // Multi-threaded loopfilter that uses the tile threads. 60 void vp9_loop_filter_frame_mt(YV12_BUFFER_CONFIG *frame, struct VP9Common *cm, 61 struct macroblockd_plane planes[MAX_MB_PLANE], 62 int frame_filter_level, int y_only, 63 int partial_frame, VPxWorker *workers, 64 int num_workers, VP9LfSync *lf_sync); 65 66 // Multi-threaded loopfilter initialisations 67 void vp9_lpf_mt_init(VP9LfSync *lf_sync, struct VP9Common *cm, 68 int frame_filter_level, int num_workers); 69 70 void vp9_loopfilter_rows(LFWorkerData *lf_data, VP9LfSync *lf_sync); 71 72 void vp9_set_row(VP9LfSync *lf_sync, int num_tiles, int row, int is_last_row, 73 int corrupted); 74 75 void vp9_loopfilter_job(LFWorkerData *lf_data, VP9LfSync *lf_sync); 76 77 void vp9_accumulate_frame_counts(struct FRAME_COUNTS *accum, 78 const struct FRAME_COUNTS *counts, int is_dec); 79 80 #ifdef __cplusplus 81 } // extern "C" 82 #endif 83 84 #endif // VPX_VP9_COMMON_VP9_THREAD_COMMON_H_ 85