OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 #else | 82 #else |
83 (void)lf_sync; | 83 (void)lf_sync; |
84 (void)r; | 84 (void)r; |
85 (void)c; | 85 (void)c; |
86 (void)sb_cols; | 86 (void)sb_cols; |
87 #endif // CONFIG_MULTITHREAD | 87 #endif // CONFIG_MULTITHREAD |
88 } | 88 } |
89 | 89 |
90 // Implement row loopfiltering for each thread. | 90 // Implement row loopfiltering for each thread. |
91 static void loop_filter_rows_mt(const YV12_BUFFER_CONFIG *const frame_buffer, | 91 static void loop_filter_rows_mt(const YV12_BUFFER_CONFIG *const frame_buffer, |
92 VP9_COMMON *const cm, MACROBLOCKD *const xd, | 92 VP9_COMMON *const cm, |
| 93 struct macroblockd_plane planes[MAX_MB_PLANE], |
93 int start, int stop, int y_only, | 94 int start, int stop, int y_only, |
94 VP9LfSync *const lf_sync, int num_lf_workers) { | 95 VP9LfSync *const lf_sync, int num_lf_workers) { |
95 const int num_planes = y_only ? 1 : MAX_MB_PLANE; | 96 const int num_planes = y_only ? 1 : MAX_MB_PLANE; |
96 int r, c; // SB row and col | 97 int r, c; // SB row and col |
97 const int sb_cols = mi_cols_aligned_to_sb(cm->mi_cols) >> MI_BLOCK_SIZE_LOG2; | 98 const int sb_cols = mi_cols_aligned_to_sb(cm->mi_cols) >> MI_BLOCK_SIZE_LOG2; |
98 | 99 |
99 for (r = start; r < stop; r += num_lf_workers) { | 100 for (r = start; r < stop; r += num_lf_workers) { |
100 const int mi_row = r << MI_BLOCK_SIZE_LOG2; | 101 const int mi_row = r << MI_BLOCK_SIZE_LOG2; |
101 MODE_INFO **const mi = cm->mi_grid_visible + mi_row * cm->mi_stride; | 102 MODE_INFO **const mi = cm->mi_grid_visible + mi_row * cm->mi_stride; |
102 | 103 |
103 for (c = 0; c < sb_cols; ++c) { | 104 for (c = 0; c < sb_cols; ++c) { |
104 const int mi_col = c << MI_BLOCK_SIZE_LOG2; | 105 const int mi_col = c << MI_BLOCK_SIZE_LOG2; |
105 LOOP_FILTER_MASK lfm; | 106 LOOP_FILTER_MASK lfm; |
106 int plane; | 107 int plane; |
107 | 108 |
108 sync_read(lf_sync, r, c); | 109 sync_read(lf_sync, r, c); |
109 | 110 |
110 vp9_setup_dst_planes(xd, frame_buffer, mi_row, mi_col); | 111 vp9_setup_dst_planes(planes, frame_buffer, mi_row, mi_col); |
111 vp9_setup_mask(cm, mi_row, mi_col, mi + mi_col, cm->mi_stride, &lfm); | 112 vp9_setup_mask(cm, mi_row, mi_col, mi + mi_col, cm->mi_stride, &lfm); |
112 | 113 |
113 for (plane = 0; plane < num_planes; ++plane) { | 114 for (plane = 0; plane < num_planes; ++plane) { |
114 vp9_filter_block_plane(cm, &xd->plane[plane], mi_row, &lfm); | 115 vp9_filter_block_plane(cm, &planes[plane], mi_row, &lfm); |
115 } | 116 } |
116 | 117 |
117 sync_write(lf_sync, r, c, sb_cols); | 118 sync_write(lf_sync, r, c, sb_cols); |
118 } | 119 } |
119 } | 120 } |
120 } | 121 } |
121 | 122 |
122 // Row-based multi-threaded loopfilter hook | 123 // Row-based multi-threaded loopfilter hook |
123 static int loop_filter_row_worker(void *arg1, void *arg2) { | 124 static int loop_filter_row_worker(void *arg1, void *arg2) { |
124 TileWorkerData *const tile_data = (TileWorkerData*)arg1; | 125 TileWorkerData *const tile_data = (TileWorkerData*)arg1; |
125 LFWorkerData *const lf_data = &tile_data->lfdata; | 126 LFWorkerData *const lf_data = &tile_data->lfdata; |
126 | 127 |
127 loop_filter_rows_mt(lf_data->frame_buffer, lf_data->cm, &lf_data->xd, | 128 loop_filter_rows_mt(lf_data->frame_buffer, lf_data->cm, lf_data->planes, |
128 lf_data->start, lf_data->stop, lf_data->y_only, | 129 lf_data->start, lf_data->stop, lf_data->y_only, |
129 lf_data->lf_sync, lf_data->num_lf_workers); | 130 lf_data->lf_sync, lf_data->num_lf_workers); |
130 return 1; | 131 return 1; |
131 } | 132 } |
132 | 133 |
133 // VP9 decoder: Implement multi-threaded loopfilter that uses the tile | 134 // VP9 decoder: Implement multi-threaded loopfilter that uses the tile |
134 // threads. | 135 // threads. |
135 void vp9_loop_filter_frame_mt(YV12_BUFFER_CONFIG *frame, | 136 void vp9_loop_filter_frame_mt(YV12_BUFFER_CONFIG *frame, |
136 VP9Decoder *pbi, VP9_COMMON *cm, | 137 VP9Decoder *pbi, VP9_COMMON *cm, |
137 int frame_filter_level, | 138 int frame_filter_level, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 for (i = 0; i < num_workers; ++i) { | 180 for (i = 0; i < num_workers; ++i) { |
180 VP9Worker *const worker = &pbi->tile_workers[i]; | 181 VP9Worker *const worker = &pbi->tile_workers[i]; |
181 TileWorkerData *const tile_data = (TileWorkerData*)worker->data1; | 182 TileWorkerData *const tile_data = (TileWorkerData*)worker->data1; |
182 LFWorkerData *const lf_data = &tile_data->lfdata; | 183 LFWorkerData *const lf_data = &tile_data->lfdata; |
183 | 184 |
184 worker->hook = (VP9WorkerHook)loop_filter_row_worker; | 185 worker->hook = (VP9WorkerHook)loop_filter_row_worker; |
185 | 186 |
186 // Loopfilter data | 187 // Loopfilter data |
187 lf_data->frame_buffer = frame; | 188 lf_data->frame_buffer = frame; |
188 lf_data->cm = cm; | 189 lf_data->cm = cm; |
189 lf_data->xd = pbi->mb; | 190 vp9_copy(lf_data->planes, pbi->mb.plane); |
190 lf_data->start = i; | 191 lf_data->start = i; |
191 lf_data->stop = sb_rows; | 192 lf_data->stop = sb_rows; |
192 lf_data->y_only = y_only; // always do all planes in decoder | 193 lf_data->y_only = y_only; // always do all planes in decoder |
193 | 194 |
194 lf_data->lf_sync = lf_sync; | 195 lf_data->lf_sync = lf_sync; |
195 lf_data->num_lf_workers = num_workers; | 196 lf_data->num_lf_workers = num_workers; |
196 | 197 |
197 // Start loopfiltering | 198 // Start loopfiltering |
198 if (i == num_workers - 1) { | 199 if (i == num_workers - 1) { |
199 vp9_worker_execute(worker); | 200 vp9_worker_execute(worker); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 } | 271 } |
271 vpx_free(lf_sync->cond_); | 272 vpx_free(lf_sync->cond_); |
272 } | 273 } |
273 #endif // CONFIG_MULTITHREAD | 274 #endif // CONFIG_MULTITHREAD |
274 vpx_free(lf_sync->cur_sb_col); | 275 vpx_free(lf_sync->cur_sb_col); |
275 // clear the structure as the source of this call may be a resize in which | 276 // clear the structure as the source of this call may be a resize in which |
276 // case this call will be followed by an _alloc() which may fail. | 277 // case this call will be followed by an _alloc() which may fail. |
277 vp9_zero(*lf_sync); | 278 vp9_zero(*lf_sync); |
278 } | 279 } |
279 } | 280 } |
OLD | NEW |