xref: /aosp_15_r20/external/libvpx/vp9/encoder/vp9_ethread.h (revision fb1b10ab9aebc7c7068eedab379b749d7e3900be)
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_ENCODER_VP9_ETHREAD_H_
12 #define VPX_VP9_ENCODER_VP9_ETHREAD_H_
13 
14 #include "vpx_util/vpx_pthread.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #define MAX_NUM_TILE_COLS (1 << 6)
21 #define MAX_NUM_TILE_ROWS 4
22 #define MAX_NUM_THREADS 64
23 
24 struct VP9_COMP;
25 struct ThreadData;
26 
27 typedef struct EncWorkerData {
28   struct VP9_COMP *cpi;
29   struct ThreadData *td;
30   int start;
31   int thread_id;
32   int tile_completion_status[MAX_NUM_TILE_COLS];
33 } EncWorkerData;
34 
35 // Encoder row synchronization
36 typedef struct VP9RowMTSyncData {
37 #if CONFIG_MULTITHREAD
38   pthread_mutex_t *mutex;
39   pthread_cond_t *cond;
40 #endif
41   // Allocate memory to store the sb/mb block index in each row.
42   int *cur_col;
43   int sync_range;
44   int rows;
45 } VP9RowMTSync;
46 
47 // Frees EncWorkerData related allocations made by vp9_encode_*_mt().
48 // row_mt specific data is freed with vp9_row_mt_mem_dealloc() and is not
49 // called by this function.
50 void vp9_encode_free_mt_data(struct VP9_COMP *cpi);
51 
52 void vp9_encode_tiles_mt(struct VP9_COMP *cpi);
53 
54 void vp9_encode_tiles_row_mt(struct VP9_COMP *cpi);
55 
56 void vp9_encode_fp_row_mt(struct VP9_COMP *cpi);
57 
58 void vp9_row_mt_sync_read(VP9RowMTSync *const row_mt_sync, int r, int c);
59 void vp9_row_mt_sync_write(VP9RowMTSync *const row_mt_sync, int r, int c,
60                            const int cols);
61 
62 void vp9_row_mt_sync_read_dummy(VP9RowMTSync *const row_mt_sync, int r, int c);
63 void vp9_row_mt_sync_write_dummy(VP9RowMTSync *const row_mt_sync, int r, int c,
64                                  const int cols);
65 
66 // Allocate memory for row based multi-threading synchronization.
67 void vp9_row_mt_sync_mem_alloc(VP9RowMTSync *row_mt_sync, struct VP9Common *cm,
68                                int rows);
69 
70 // Deallocate row based multi-threading synchronization related mutex and data.
71 void vp9_row_mt_sync_mem_dealloc(VP9RowMTSync *row_mt_sync);
72 
73 void vp9_temporal_filter_row_mt(struct VP9_COMP *cpi);
74 
75 #ifdef __cplusplus
76 }  // extern "C"
77 #endif
78 
79 #endif  // VPX_VP9_ENCODER_VP9_ETHREAD_H_
80