]> granicus.if.org Git - libvpx/blob - vp9/common/vp9_thread_common.c
a8f1c3986ddefd2e44763101f7d14a22906d98fa
[libvpx] / vp9 / common / vp9_thread_common.c
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 #include "./vpx_config.h"
12 #include "vpx_dsp/vpx_dsp_common.h"
13 #include "vpx_mem/vpx_mem.h"
14 #include "vp9/common/vp9_entropymode.h"
15 #include "vp9/common/vp9_thread_common.h"
16 #include "vp9/common/vp9_reconinter.h"
17 #include "vp9/common/vp9_loopfilter.h"
18
19 #if CONFIG_MULTITHREAD
20 static INLINE void mutex_lock(pthread_mutex_t *const mutex) {
21   const int kMaxTryLocks = 4000;
22   int locked = 0;
23   int i;
24
25   for (i = 0; i < kMaxTryLocks; ++i) {
26     if (!pthread_mutex_trylock(mutex)) {
27       locked = 1;
28       break;
29     }
30   }
31
32   if (!locked) pthread_mutex_lock(mutex);
33 }
34 #endif  // CONFIG_MULTITHREAD
35
36 static INLINE void sync_read(VP9LfSync *const lf_sync, int r, int c) {
37 #if CONFIG_MULTITHREAD
38   const int nsync = lf_sync->sync_range;
39
40   if (r && !(c & (nsync - 1))) {
41     pthread_mutex_t *const mutex = &lf_sync->mutex[r - 1];
42     mutex_lock(mutex);
43
44     while (c > lf_sync->cur_sb_col[r - 1] - nsync) {
45       pthread_cond_wait(&lf_sync->cond[r - 1], mutex);
46     }
47     pthread_mutex_unlock(mutex);
48   }
49 #else
50   (void)lf_sync;
51   (void)r;
52   (void)c;
53 #endif  // CONFIG_MULTITHREAD
54 }
55
56 static INLINE void sync_write(VP9LfSync *const lf_sync, int r, int c,
57                               const int sb_cols) {
58 #if CONFIG_MULTITHREAD
59   const int nsync = lf_sync->sync_range;
60   int cur;
61   // Only signal when there are enough filtered SB for next row to run.
62   int sig = 1;
63
64   if (c < sb_cols - 1) {
65     cur = c;
66     if (c % nsync) sig = 0;
67   } else {
68     cur = sb_cols + nsync;
69   }
70
71   if (sig) {
72     mutex_lock(&lf_sync->mutex[r]);
73
74     lf_sync->cur_sb_col[r] = cur;
75
76     pthread_cond_signal(&lf_sync->cond[r]);
77     pthread_mutex_unlock(&lf_sync->mutex[r]);
78   }
79 #else
80   (void)lf_sync;
81   (void)r;
82   (void)c;
83   (void)sb_cols;
84 #endif  // CONFIG_MULTITHREAD
85 }
86
87 // Implement row loopfiltering for each thread.
88 static INLINE void thread_loop_filter_rows(
89     const YV12_BUFFER_CONFIG *const frame_buffer, VP9_COMMON *const cm,
90     struct macroblockd_plane planes[MAX_MB_PLANE], int start, int stop,
91     int y_only, VP9LfSync *const lf_sync) {
92   const int num_planes = y_only ? 1 : MAX_MB_PLANE;
93   const int sb_cols = mi_cols_aligned_to_sb(cm->mi_cols) >> MI_BLOCK_SIZE_LOG2;
94   const int num_active_workers = VPXMIN(lf_sync->num_workers, lf_sync->rows);
95   int mi_row, mi_col;
96   enum lf_path path;
97   if (y_only)
98     path = LF_PATH_444;
99   else if (planes[1].subsampling_y == 1 && planes[1].subsampling_x == 1)
100     path = LF_PATH_420;
101   else if (planes[1].subsampling_y == 0 && planes[1].subsampling_x == 0)
102     path = LF_PATH_444;
103   else
104     path = LF_PATH_SLOW;
105
106   for (mi_row = start; mi_row < stop;
107        mi_row += num_active_workers * MI_BLOCK_SIZE) {
108     MODE_INFO **const mi = cm->mi_grid_visible + mi_row * cm->mi_stride;
109     LOOP_FILTER_MASK *lfm = get_lfm(&cm->lf, mi_row, 0);
110
111     for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MI_BLOCK_SIZE, ++lfm) {
112       const int r = mi_row >> MI_BLOCK_SIZE_LOG2;
113       const int c = mi_col >> MI_BLOCK_SIZE_LOG2;
114       int plane;
115
116       sync_read(lf_sync, r, c);
117
118       vp9_setup_dst_planes(planes, frame_buffer, mi_row, mi_col);
119
120       vp9_adjust_mask(cm, mi_row, mi_col, lfm);
121
122       vp9_filter_block_plane_ss00(cm, &planes[0], mi_row, lfm);
123       for (plane = 1; plane < num_planes; ++plane) {
124         switch (path) {
125           case LF_PATH_420:
126             vp9_filter_block_plane_ss11(cm, &planes[plane], mi_row, lfm);
127             break;
128           case LF_PATH_444:
129             vp9_filter_block_plane_ss00(cm, &planes[plane], mi_row, lfm);
130             break;
131           case LF_PATH_SLOW:
132             vp9_filter_block_plane_non420(cm, &planes[plane], mi + mi_col,
133                                           mi_row, mi_col);
134             break;
135         }
136       }
137
138       sync_write(lf_sync, r, c, sb_cols);
139     }
140   }
141 }
142
143 // Row-based multi-threaded loopfilter hook
144 static int loop_filter_row_worker(void *arg1, void *arg2) {
145   VP9LfSync *const lf_sync = (VP9LfSync *)arg1;
146   LFWorkerData *const lf_data = (LFWorkerData *)arg2;
147   thread_loop_filter_rows(lf_data->frame_buffer, lf_data->cm, lf_data->planes,
148                           lf_data->start, lf_data->stop, lf_data->y_only,
149                           lf_sync);
150   return 1;
151 }
152
153 static void loop_filter_rows_mt(YV12_BUFFER_CONFIG *frame, VP9_COMMON *cm,
154                                 struct macroblockd_plane planes[MAX_MB_PLANE],
155                                 int start, int stop, int y_only,
156                                 VPxWorker *workers, int nworkers,
157                                 VP9LfSync *lf_sync) {
158   const VPxWorkerInterface *const winterface = vpx_get_worker_interface();
159   // Number of superblock rows and cols
160   const int sb_rows = mi_cols_aligned_to_sb(cm->mi_rows) >> MI_BLOCK_SIZE_LOG2;
161   const int num_workers = VPXMIN(nworkers, sb_rows);
162   int i;
163
164   if (!lf_sync->sync_range || sb_rows != lf_sync->rows ||
165       num_workers > lf_sync->num_workers) {
166     vp9_loop_filter_dealloc(lf_sync);
167     vp9_loop_filter_alloc(lf_sync, cm, sb_rows, cm->width, num_workers);
168   }
169
170   // Initialize cur_sb_col to -1 for all SB rows.
171   memset(lf_sync->cur_sb_col, -1, sizeof(*lf_sync->cur_sb_col) * sb_rows);
172
173   // Set up loopfilter thread data.
174   // The decoder is capping num_workers because it has been observed that using
175   // more threads on the loopfilter than there are cores will hurt performance
176   // on Android. This is because the system will only schedule the tile decode
177   // workers on cores equal to the number of tile columns. Then if the decoder
178   // tries to use more threads for the loopfilter, it will hurt performance
179   // because of contention. If the multithreading code changes in the future
180   // then the number of workers used by the loopfilter should be revisited.
181   for (i = 0; i < num_workers; ++i) {
182     VPxWorker *const worker = &workers[i];
183     LFWorkerData *const lf_data = &lf_sync->lfdata[i];
184
185     worker->hook = loop_filter_row_worker;
186     worker->data1 = lf_sync;
187     worker->data2 = lf_data;
188
189     // Loopfilter data
190     vp9_loop_filter_data_reset(lf_data, frame, cm, planes);
191     lf_data->start = start + i * MI_BLOCK_SIZE;
192     lf_data->stop = stop;
193     lf_data->y_only = y_only;
194
195     // Start loopfiltering
196     if (i == num_workers - 1) {
197       winterface->execute(worker);
198     } else {
199       winterface->launch(worker);
200     }
201   }
202
203   // Wait till all rows are finished
204   for (i = 0; i < num_workers; ++i) {
205     winterface->sync(&workers[i]);
206   }
207 }
208
209 void vp9_loop_filter_frame_mt(YV12_BUFFER_CONFIG *frame, VP9_COMMON *cm,
210                               struct macroblockd_plane planes[MAX_MB_PLANE],
211                               int frame_filter_level, int y_only,
212                               int partial_frame, VPxWorker *workers,
213                               int num_workers, VP9LfSync *lf_sync) {
214   int start_mi_row, end_mi_row, mi_rows_to_filter;
215
216   if (!frame_filter_level) return;
217
218   start_mi_row = 0;
219   mi_rows_to_filter = cm->mi_rows;
220   if (partial_frame && cm->mi_rows > 8) {
221     start_mi_row = cm->mi_rows >> 1;
222     start_mi_row &= 0xfffffff8;
223     mi_rows_to_filter = VPXMAX(cm->mi_rows / 8, 8);
224   }
225   end_mi_row = start_mi_row + mi_rows_to_filter;
226   vp9_loop_filter_frame_init(cm, frame_filter_level);
227
228   loop_filter_rows_mt(frame, cm, planes, start_mi_row, end_mi_row, y_only,
229                       workers, num_workers, lf_sync);
230 }
231
232 void vp9_lpf_mt_init(VP9LfSync *lf_sync, VP9_COMMON *cm, int frame_filter_level,
233                      int num_workers) {
234   const int sb_rows = mi_cols_aligned_to_sb(cm->mi_rows) >> MI_BLOCK_SIZE_LOG2;
235
236   if (!frame_filter_level) return;
237
238   if (!lf_sync->sync_range || sb_rows != lf_sync->rows ||
239       num_workers > lf_sync->num_workers) {
240     vp9_loop_filter_dealloc(lf_sync);
241     vp9_loop_filter_alloc(lf_sync, cm, sb_rows, cm->width, num_workers);
242   }
243
244   // Initialize cur_sb_col to -1 for all SB rows.
245   memset(lf_sync->cur_sb_col, -1, sizeof(*lf_sync->cur_sb_col) * sb_rows);
246
247   memset(lf_sync->num_tiles_done, 0,
248          sizeof(*lf_sync->num_tiles_done) * sb_rows);
249   cm->lf_row = 0;
250 }
251
252 // Set up nsync by width.
253 static INLINE int get_sync_range(int width) {
254   // nsync numbers are picked by testing. For example, for 4k
255   // video, using 4 gives best performance.
256   if (width < 640)
257     return 1;
258   else if (width <= 1280)
259     return 2;
260   else if (width <= 4096)
261     return 4;
262   else
263     return 8;
264 }
265
266 // Allocate memory for lf row synchronization
267 void vp9_loop_filter_alloc(VP9LfSync *lf_sync, VP9_COMMON *cm, int rows,
268                            int width, int num_workers) {
269   lf_sync->rows = rows;
270 #if CONFIG_MULTITHREAD
271   {
272     int i;
273
274     CHECK_MEM_ERROR(cm, lf_sync->mutex,
275                     vpx_malloc(sizeof(*lf_sync->mutex) * rows));
276     if (lf_sync->mutex) {
277       for (i = 0; i < rows; ++i) {
278         pthread_mutex_init(&lf_sync->mutex[i], NULL);
279       }
280     }
281
282     CHECK_MEM_ERROR(cm, lf_sync->cond,
283                     vpx_malloc(sizeof(*lf_sync->cond) * rows));
284     if (lf_sync->cond) {
285       for (i = 0; i < rows; ++i) {
286         pthread_cond_init(&lf_sync->cond[i], NULL);
287       }
288     }
289     pthread_mutex_init(&lf_sync->lf_mutex, NULL);
290
291     CHECK_MEM_ERROR(cm, lf_sync->recon_done_mutex,
292                     vpx_malloc(sizeof(*lf_sync->recon_done_mutex) * rows));
293     if (lf_sync->recon_done_mutex) {
294       int i;
295       for (i = 0; i < rows; ++i) {
296         pthread_mutex_init(&lf_sync->recon_done_mutex[i], NULL);
297       }
298     }
299
300     CHECK_MEM_ERROR(cm, lf_sync->recon_done_cond,
301                     vpx_malloc(sizeof(*lf_sync->recon_done_cond) * rows));
302     if (lf_sync->recon_done_cond) {
303       int i;
304       for (i = 0; i < rows; ++i) {
305         pthread_cond_init(&lf_sync->recon_done_cond[i], NULL);
306       }
307     }
308   }
309 #endif  // CONFIG_MULTITHREAD
310
311   CHECK_MEM_ERROR(cm, lf_sync->lfdata,
312                   vpx_malloc(num_workers * sizeof(*lf_sync->lfdata)));
313   lf_sync->num_workers = num_workers;
314
315   CHECK_MEM_ERROR(cm, lf_sync->cur_sb_col,
316                   vpx_malloc(sizeof(*lf_sync->cur_sb_col) * rows));
317
318   CHECK_MEM_ERROR(cm, lf_sync->num_tiles_done,
319                   vpx_malloc(sizeof(*lf_sync->num_tiles_done) *
320                                  mi_cols_aligned_to_sb(cm->mi_rows) >>
321                              MI_BLOCK_SIZE_LOG2));
322
323   // Set up nsync.
324   lf_sync->sync_range = get_sync_range(width);
325 }
326
327 // Deallocate lf synchronization related mutex and data
328 void vp9_loop_filter_dealloc(VP9LfSync *lf_sync) {
329   if (lf_sync != NULL) {
330 #if CONFIG_MULTITHREAD
331     int i;
332
333     if (lf_sync->mutex != NULL) {
334       for (i = 0; i < lf_sync->rows; ++i) {
335         pthread_mutex_destroy(&lf_sync->mutex[i]);
336       }
337       vpx_free(lf_sync->mutex);
338     }
339     if (lf_sync->cond != NULL) {
340       for (i = 0; i < lf_sync->rows; ++i) {
341         pthread_cond_destroy(&lf_sync->cond[i]);
342       }
343       vpx_free(lf_sync->cond);
344     }
345     if (lf_sync->recon_done_mutex != NULL) {
346       int i;
347       for (i = 0; i < lf_sync->rows; ++i) {
348         pthread_mutex_destroy(&lf_sync->recon_done_mutex[i]);
349       }
350       vpx_free(lf_sync->recon_done_mutex);
351     }
352
353     pthread_mutex_destroy(&lf_sync->lf_mutex);
354     if (lf_sync->recon_done_cond != NULL) {
355       int i;
356       for (i = 0; i < lf_sync->rows; ++i) {
357         pthread_cond_destroy(&lf_sync->recon_done_cond[i]);
358       }
359       vpx_free(lf_sync->recon_done_cond);
360     }
361 #endif  // CONFIG_MULTITHREAD
362
363     vpx_free(lf_sync->lfdata);
364     vpx_free(lf_sync->cur_sb_col);
365     vpx_free(lf_sync->num_tiles_done);
366     // clear the structure as the source of this call may be a resize in which
367     // case this call will be followed by an _alloc() which may fail.
368     vp9_zero(*lf_sync);
369   }
370 }
371
372 static int get_next_row(VP9_COMMON *cm, VP9LfSync *lf_sync) {
373   int return_val = -1;
374   int cur_row;
375   const int max_rows = cm->mi_rows;
376
377 #if CONFIG_MULTITHREAD
378   const int tile_cols = 1 << cm->log2_tile_cols;
379
380   pthread_mutex_lock(&lf_sync->lf_mutex);
381   if (cm->lf_row < max_rows) {
382     cur_row = cm->lf_row >> MI_BLOCK_SIZE_LOG2;
383     return_val = cm->lf_row;
384     cm->lf_row += MI_BLOCK_SIZE;
385     if (cm->lf_row < max_rows) {
386       /* If this is not the last row, make sure the next row is also decoded.
387        * This is because the intra predict has to happen before loop filter */
388       cur_row += 1;
389     }
390   }
391   pthread_mutex_unlock(&lf_sync->lf_mutex);
392
393   if (return_val == -1) return return_val;
394
395   pthread_mutex_lock(&lf_sync->recon_done_mutex[cur_row]);
396   if (lf_sync->num_tiles_done[cur_row] < tile_cols) {
397     pthread_cond_wait(&lf_sync->recon_done_cond[cur_row],
398                       &lf_sync->recon_done_mutex[cur_row]);
399   }
400   pthread_mutex_unlock(&lf_sync->recon_done_mutex[cur_row]);
401 #else
402   (void)lf_sync;
403   if (cm->lf_row < max_rows) {
404     cur_row = cm->lf_row >> MI_BLOCK_SIZE_LOG2;
405     return_val = cm->lf_row;
406     cm->lf_row += MI_BLOCK_SIZE;
407     if (cm->lf_row < max_rows) {
408       /* If this is not the last row, make sure the next row is also decoded.
409        * This is because the intra predict has to happen before loop filter */
410       cur_row += 1;
411     }
412   }
413 #endif  // CONFIG_MULTITHREAD
414
415   return return_val;
416 }
417
418 void vp9_loopfilter_rows(LFWorkerData *lf_data, VP9LfSync *lf_sync,
419                          MACROBLOCKD *xd) {
420   int mi_row;
421   VP9_COMMON *cm = lf_data->cm;
422
423   while (!xd->corrupted && (mi_row = get_next_row(cm, lf_sync)) != -1 &&
424          mi_row < cm->mi_rows) {
425     lf_data->start = mi_row;
426     lf_data->stop = mi_row + MI_BLOCK_SIZE;
427
428     thread_loop_filter_rows(lf_data->frame_buffer, lf_data->cm, lf_data->planes,
429                             lf_data->start, lf_data->stop, lf_data->y_only,
430                             lf_sync);
431   }
432 }
433
434 void vp9_set_row(VP9LfSync *lf_sync, int num_tiles, int row, int is_last_row) {
435 #if CONFIG_MULTITHREAD
436   pthread_mutex_lock(&lf_sync->recon_done_mutex[row]);
437   lf_sync->num_tiles_done[row] += 1;
438   if (num_tiles == lf_sync->num_tiles_done[row]) {
439     if (is_last_row) {
440       /* The last 2 rows wait on the last row to be done.
441        * So, we have to broadcast the signal in this case.
442        */
443       pthread_cond_broadcast(&lf_sync->recon_done_cond[row]);
444     } else {
445       pthread_cond_signal(&lf_sync->recon_done_cond[row]);
446     }
447   }
448   pthread_mutex_unlock(&lf_sync->recon_done_mutex[row]);
449 #else
450   (void)lf_sync;
451   (void)num_tiles;
452   (void)row;
453   (void)is_last_row;
454 #endif  // CONFIG_MULTITHREAD
455 }
456
457 // Accumulate frame counts.
458 void vp9_accumulate_frame_counts(FRAME_COUNTS *accum,
459                                  const FRAME_COUNTS *counts, int is_dec) {
460   int i, j, k, l, m;
461
462   for (i = 0; i < BLOCK_SIZE_GROUPS; i++)
463     for (j = 0; j < INTRA_MODES; j++)
464       accum->y_mode[i][j] += counts->y_mode[i][j];
465
466   for (i = 0; i < INTRA_MODES; i++)
467     for (j = 0; j < INTRA_MODES; j++)
468       accum->uv_mode[i][j] += counts->uv_mode[i][j];
469
470   for (i = 0; i < PARTITION_CONTEXTS; i++)
471     for (j = 0; j < PARTITION_TYPES; j++)
472       accum->partition[i][j] += counts->partition[i][j];
473
474   if (is_dec) {
475     int n;
476     for (i = 0; i < TX_SIZES; i++)
477       for (j = 0; j < PLANE_TYPES; j++)
478         for (k = 0; k < REF_TYPES; k++)
479           for (l = 0; l < COEF_BANDS; l++)
480             for (m = 0; m < COEFF_CONTEXTS; m++) {
481               accum->eob_branch[i][j][k][l][m] +=
482                   counts->eob_branch[i][j][k][l][m];
483               for (n = 0; n < UNCONSTRAINED_NODES + 1; n++)
484                 accum->coef[i][j][k][l][m][n] += counts->coef[i][j][k][l][m][n];
485             }
486   } else {
487     for (i = 0; i < TX_SIZES; i++)
488       for (j = 0; j < PLANE_TYPES; j++)
489         for (k = 0; k < REF_TYPES; k++)
490           for (l = 0; l < COEF_BANDS; l++)
491             for (m = 0; m < COEFF_CONTEXTS; m++)
492               accum->eob_branch[i][j][k][l][m] +=
493                   counts->eob_branch[i][j][k][l][m];
494     // In the encoder, coef is only updated at frame
495     // level, so not need to accumulate it here.
496     // for (n = 0; n < UNCONSTRAINED_NODES + 1; n++)
497     //   accum->coef[i][j][k][l][m][n] +=
498     //       counts->coef[i][j][k][l][m][n];
499   }
500
501   for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++)
502     for (j = 0; j < SWITCHABLE_FILTERS; j++)
503       accum->switchable_interp[i][j] += counts->switchable_interp[i][j];
504
505   for (i = 0; i < INTER_MODE_CONTEXTS; i++)
506     for (j = 0; j < INTER_MODES; j++)
507       accum->inter_mode[i][j] += counts->inter_mode[i][j];
508
509   for (i = 0; i < INTRA_INTER_CONTEXTS; i++)
510     for (j = 0; j < 2; j++)
511       accum->intra_inter[i][j] += counts->intra_inter[i][j];
512
513   for (i = 0; i < COMP_INTER_CONTEXTS; i++)
514     for (j = 0; j < 2; j++) accum->comp_inter[i][j] += counts->comp_inter[i][j];
515
516   for (i = 0; i < REF_CONTEXTS; i++)
517     for (j = 0; j < 2; j++)
518       for (k = 0; k < 2; k++)
519         accum->single_ref[i][j][k] += counts->single_ref[i][j][k];
520
521   for (i = 0; i < REF_CONTEXTS; i++)
522     for (j = 0; j < 2; j++) accum->comp_ref[i][j] += counts->comp_ref[i][j];
523
524   for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
525     for (j = 0; j < TX_SIZES; j++)
526       accum->tx.p32x32[i][j] += counts->tx.p32x32[i][j];
527
528     for (j = 0; j < TX_SIZES - 1; j++)
529       accum->tx.p16x16[i][j] += counts->tx.p16x16[i][j];
530
531     for (j = 0; j < TX_SIZES - 2; j++)
532       accum->tx.p8x8[i][j] += counts->tx.p8x8[i][j];
533   }
534
535   for (i = 0; i < TX_SIZES; i++)
536     accum->tx.tx_totals[i] += counts->tx.tx_totals[i];
537
538   for (i = 0; i < SKIP_CONTEXTS; i++)
539     for (j = 0; j < 2; j++) accum->skip[i][j] += counts->skip[i][j];
540
541   for (i = 0; i < MV_JOINTS; i++) accum->mv.joints[i] += counts->mv.joints[i];
542
543   for (k = 0; k < 2; k++) {
544     nmv_component_counts *const comps = &accum->mv.comps[k];
545     const nmv_component_counts *const comps_t = &counts->mv.comps[k];
546
547     for (i = 0; i < 2; i++) {
548       comps->sign[i] += comps_t->sign[i];
549       comps->class0_hp[i] += comps_t->class0_hp[i];
550       comps->hp[i] += comps_t->hp[i];
551     }
552
553     for (i = 0; i < MV_CLASSES; i++) comps->classes[i] += comps_t->classes[i];
554
555     for (i = 0; i < CLASS0_SIZE; i++) {
556       comps->class0[i] += comps_t->class0[i];
557       for (j = 0; j < MV_FP_SIZE; j++)
558         comps->class0_fp[i][j] += comps_t->class0_fp[i][j];
559     }
560
561     for (i = 0; i < MV_OFFSET_BITS; i++)
562       for (j = 0; j < 2; j++) comps->bits[i][j] += comps_t->bits[i][j];
563
564     for (i = 0; i < MV_FP_SIZE; i++) comps->fp[i] += comps_t->fp[i];
565   }
566 }