xref: /aosp_15_r20/external/libaom/av1/encoder/ethread.h (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
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_ENCODER_ETHREAD_H_
13 #define AOM_AV1_ENCODER_ETHREAD_H_
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 struct AV1_COMP;
20 struct ThreadData;
21 
22 typedef struct EncWorkerData {
23   struct AV1_COMP *cpi;
24   struct ThreadData *td;
25   struct ThreadData *original_td;
26   struct aom_internal_error_info error_info;
27   AV1LfSync *lf_sync;
28   LFWorkerData *lf_data;
29   int start;
30   int thread_id;
31 } EncWorkerData;
32 
33 void av1_row_mt_sync_read(AV1EncRowMultiThreadSync *row_mt_sync, int r, int c);
34 void av1_row_mt_sync_write(AV1EncRowMultiThreadSync *row_mt_sync, int r, int c,
35                            int cols);
36 
37 void av1_row_mt_sync_read_dummy(AV1EncRowMultiThreadSync *row_mt_sync, int r,
38                                 int c);
39 void av1_row_mt_sync_write_dummy(AV1EncRowMultiThreadSync *row_mt_sync, int r,
40                                  int c, int cols);
41 
42 void av1_encode_tiles_mt(struct AV1_COMP *cpi);
43 void av1_encode_tiles_row_mt(struct AV1_COMP *cpi);
44 
45 #if !CONFIG_REALTIME_ONLY
46 void av1_fp_encode_tiles_row_mt(AV1_COMP *cpi);
47 
48 int av1_fp_compute_num_enc_workers(AV1_COMP *cpi);
49 #endif
50 
51 void av1_accumulate_frame_counts(struct FRAME_COUNTS *acc_counts,
52                                  const struct FRAME_COUNTS *counts);
53 
54 void av1_row_mt_mem_dealloc(AV1_COMP *cpi);
55 
56 void av1_row_mt_sync_mem_dealloc(AV1EncRowMultiThreadSync *row_mt_sync);
57 
58 void av1_global_motion_estimation_mt(AV1_COMP *cpi);
59 
60 #if !CONFIG_REALTIME_ONLY
61 void av1_tpl_row_mt_sync_read_dummy(AV1TplRowMultiThreadSync *tpl_mt_sync,
62                                     int r, int c);
63 void av1_tpl_row_mt_sync_write_dummy(AV1TplRowMultiThreadSync *tpl_mt_sync,
64                                      int r, int c, int cols);
65 
66 void av1_tpl_row_mt_sync_read(AV1TplRowMultiThreadSync *tpl_mt_sync, int r,
67                               int c);
68 void av1_tpl_row_mt_sync_write(AV1TplRowMultiThreadSync *tpl_mt_sync, int r,
69                                int c, int cols);
70 
71 void av1_mc_flow_dispenser_mt(AV1_COMP *cpi);
72 
73 void av1_tpl_dealloc(AV1TplRowMultiThreadSync *tpl_sync);
74 
75 #endif  // !CONFIG_REALTIME_ONLY
76 
77 void av1_calc_mb_wiener_var_mt(AV1_COMP *cpi, int num_workers,
78                                double *sum_rec_distortion,
79                                double *sum_est_rate);
80 
81 void av1_tf_do_filtering_mt(AV1_COMP *cpi);
82 
83 void av1_tf_mt_dealloc(AV1TemporalFilterSync *tf_sync);
84 
85 void av1_compute_num_workers_for_mt(AV1_COMP *cpi);
86 
87 int av1_get_max_num_workers(const AV1_COMP *cpi);
88 
89 void av1_create_workers(AV1_PRIMARY *ppi, int num_workers);
90 
91 void av1_terminate_workers(AV1_PRIMARY *ppi);
92 
93 void av1_init_frame_mt(AV1_PRIMARY *ppi, AV1_COMP *cpi);
94 
95 void av1_init_cdef_worker(AV1_COMP *cpi);
96 
97 #if !CONFIG_REALTIME_ONLY
98 void av1_init_lr_mt_buffers(AV1_COMP *cpi);
99 #endif
100 
101 #if CONFIG_MULTITHREAD
102 void av1_init_mt_sync(AV1_COMP *cpi, int is_first_pass);
103 #endif  // CONFIG_MULTITHREAD
104 
105 int av1_get_num_mod_workers_for_alloc(const PrimaryMultiThreadInfo *p_mt_info,
106                                       MULTI_THREADED_MODULES mod_name);
107 
108 void av1_init_tile_thread_data(AV1_PRIMARY *ppi, int is_first_pass);
109 
110 void av1_cdef_mse_calc_frame_mt(AV1_COMP *cpi);
111 
112 void av1_cdef_mt_dealloc(AV1CdefSync *cdef_sync);
113 
114 void av1_write_tile_obu_mt(
115     AV1_COMP *const cpi, uint8_t *const dst, uint32_t *total_size,
116     struct aom_write_bit_buffer *saved_wb, uint8_t obu_extn_header,
117     const FrameHeaderInfo *fh_info, int *const largest_tile_id,
118     unsigned int *max_tile_size, uint32_t *const obu_header_size,
119     uint8_t **tile_data_start, const int num_workers);
120 
121 int av1_compute_num_fp_contexts(AV1_PRIMARY *ppi, AV1EncoderConfig *oxcf);
122 
123 int av1_check_fpmt_config(AV1_PRIMARY *const ppi,
124                           const AV1EncoderConfig *const oxcf);
125 
126 void av1_compress_parallel_frames(AV1_PRIMARY *const ppi,
127                                   AV1_COMP_DATA *const first_cpi_data);
128 #ifdef __cplusplus
129 }  // extern "C"
130 #endif
131 
132 #endif  // AOM_AV1_ENCODER_ETHREAD_H_
133