1 /* 2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved 3 * 4 * This source code is subject to the terms of the BSD 2 Clause License and 5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License 6 * was not distributed with this source code in the LICENSE file, you can 7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open 8 * Media Patent License 1.0 was not distributed with this source code in the 9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent. 10 */ 11 12 #ifndef AOM_AV1_COMMON_THREAD_COMMON_H_ 13 #define AOM_AV1_COMMON_THREAD_COMMON_H_ 14 15 #include "config/aom_config.h" 16 17 #include "av1/common/av1_loopfilter.h" 18 #include "aom_util/aom_thread.h" 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 struct AV1Common; 25 26 typedef struct AV1LfMTInfo { 27 int mi_row; 28 int plane; 29 int dir; 30 } AV1LfMTInfo; 31 32 // Loopfilter row synchronization 33 typedef struct AV1LfSyncData { 34 #if CONFIG_MULTITHREAD 35 pthread_mutex_t *mutex_[MAX_MB_PLANE]; 36 pthread_cond_t *cond_[MAX_MB_PLANE]; 37 #endif 38 // Allocate memory to store the loop-filtered superblock index in each row. 39 int *cur_sb_col[MAX_MB_PLANE]; 40 // The optimal sync_range for different resolution and platform should be 41 // determined by testing. Currently, it is chosen to be a power-of-2 number. 42 int sync_range; 43 int rows; 44 45 // Row-based parallel loopfilter data 46 LFWorkerData *lfdata; 47 int num_workers; 48 49 #if CONFIG_MULTITHREAD 50 pthread_mutex_t *job_mutex; 51 #endif 52 AV1LfMTInfo *job_queue; 53 int jobs_enqueued; 54 int jobs_dequeued; 55 } AV1LfSync; 56 57 typedef struct AV1LrMTInfo { 58 int v_start; 59 int v_end; 60 int lr_unit_row; 61 int plane; 62 int sync_mode; 63 int v_copy_start; 64 int v_copy_end; 65 } AV1LrMTInfo; 66 67 typedef struct LoopRestorationWorkerData { 68 int32_t *rst_tmpbuf; 69 void *rlbs; 70 void *lr_ctxt; 71 } LRWorkerData; 72 73 // Looprestoration row synchronization 74 typedef struct AV1LrSyncData { 75 #if CONFIG_MULTITHREAD 76 pthread_mutex_t *mutex_[MAX_MB_PLANE]; 77 pthread_cond_t *cond_[MAX_MB_PLANE]; 78 #endif 79 // Allocate memory to store the loop-restoration block index in each row. 80 int *cur_sb_col[MAX_MB_PLANE]; 81 // The optimal sync_range for different resolution and platform should be 82 // determined by testing. Currently, it is chosen to be a power-of-2 number. 83 int sync_range; 84 int rows; 85 int num_planes; 86 87 int num_workers; 88 89 #if CONFIG_MULTITHREAD 90 pthread_mutex_t *job_mutex; 91 #endif 92 // Row-based parallel loopfilter data 93 LRWorkerData *lrworkerdata; 94 95 AV1LrMTInfo *job_queue; 96 int jobs_enqueued; 97 int jobs_dequeued; 98 } AV1LrSync; 99 100 // Deallocate loopfilter synchronization related mutex and data. 101 void av1_loop_filter_dealloc(AV1LfSync *lf_sync); 102 103 void av1_loop_filter_frame_mt(YV12_BUFFER_CONFIG *frame, struct AV1Common *cm, 104 struct macroblockd *xd, int plane_start, 105 int plane_end, int partial_frame, 106 #if CONFIG_LPF_MASK 107 int is_decoding, 108 #endif 109 AVxWorker *workers, int num_workers, 110 AV1LfSync *lf_sync); 111 void av1_loop_restoration_filter_frame_mt(YV12_BUFFER_CONFIG *frame, 112 struct AV1Common *cm, 113 int optimized_lr, AVxWorker *workers, 114 int num_workers, AV1LrSync *lr_sync, 115 void *lr_ctxt); 116 void av1_loop_restoration_dealloc(AV1LrSync *lr_sync, int num_workers); 117 118 #ifdef __cplusplus 119 } // extern "C" 120 #endif 121 122 #endif // AOM_AV1_COMMON_THREAD_COMMON_H_ 123