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_thread.h" 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 struct VP9Common; 22 struct FRAME_COUNTS; 23 24 // Loopfilter row synchronization 25 typedef struct VP9LfSyncData { 26 #if CONFIG_MULTITHREAD 27 pthread_mutex_t *mutex; 28 pthread_cond_t *cond; 29 #endif 30 // Allocate memory to store the loop-filtered superblock index in each row. 31 int *cur_sb_col; 32 // The optimal sync_range for different resolution and platform should be 33 // determined by testing. Currently, it is chosen to be a power-of-2 number. 34 int sync_range; 35 int rows; 36 37 // Row-based parallel loopfilter data 38 LFWorkerData *lfdata; 39 int num_workers; // number of allocated workers. 40 int num_active_workers; // number of scheduled workers. 41 42 #if CONFIG_MULTITHREAD 43 pthread_mutex_t lf_mutex; 44 pthread_mutex_t *recon_done_mutex; 45 pthread_cond_t *recon_done_cond; 46 #endif 47 int *num_tiles_done; 48 int corrupted; 49 } VP9LfSync; 50 51 // Allocate memory for loopfilter row synchronization. 52 void vp9_loop_filter_alloc(VP9LfSync *lf_sync, struct VP9Common *cm, int rows, 53 int width, int num_workers); 54 55 // Deallocate loopfilter synchronization related mutex and data. 56 void vp9_loop_filter_dealloc(VP9LfSync *lf_sync); 57 58 // Multi-threaded loopfilter that uses the tile threads. 59 void vp9_loop_filter_frame_mt(YV12_BUFFER_CONFIG *frame, struct VP9Common *cm, 60 struct macroblockd_plane planes[MAX_MB_PLANE], 61 int frame_filter_level, int y_only, 62 int partial_frame, VPxWorker *workers, 63 int num_workers, VP9LfSync *lf_sync); 64 65 // Multi-threaded loopfilter initialisations 66 void vp9_lpf_mt_init(VP9LfSync *lf_sync, struct VP9Common *cm, 67 int frame_filter_level, int num_workers); 68 69 void vp9_loopfilter_rows(LFWorkerData *lf_data, VP9LfSync *lf_sync); 70 71 void vp9_set_row(VP9LfSync *lf_sync, int num_tiles, int row, int is_last_row, 72 int corrupted); 73 74 void vp9_set_last_decoded_row(struct VP9Common *cm, int tile_col, int mi_row); 75 76 void vp9_accumulate_frame_counts(struct FRAME_COUNTS *accum, 77 const struct FRAME_COUNTS *counts, int is_dec); 78 79 #ifdef __cplusplus 80 } // extern "C" 81 #endif 82 83 #endif // VPX_VP9_COMMON_VP9_THREAD_COMMON_H_ 84