Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: source/libvpx/vp9/common/vp9_thread_common.c

Issue 958693004: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 #include "./vpx_config.h" 11 #include "./vpx_config.h"
12 #include "vpx_mem/vpx_mem.h" 12 #include "vpx_mem/vpx_mem.h"
13 #include "vp9/common/vp9_loopfilter_thread.h" 13 #include "vp9/common/vp9_entropymode.h"
14 #include "vp9/common/vp9_thread_common.h"
14 #include "vp9/common/vp9_reconinter.h" 15 #include "vp9/common/vp9_reconinter.h"
15 16
16 #if CONFIG_MULTITHREAD 17 #if CONFIG_MULTITHREAD
17 static INLINE void mutex_lock(pthread_mutex_t *const mutex) { 18 static INLINE void mutex_lock(pthread_mutex_t *const mutex) {
18 const int kMaxTryLocks = 4000; 19 const int kMaxTryLocks = 4000;
19 int locked = 0; 20 int locked = 0;
20 int i; 21 int i;
21 22
22 for (i = 0; i < kMaxTryLocks; ++i) { 23 for (i = 0; i < kMaxTryLocks; ++i) {
23 if (!pthread_mutex_trylock(mutex)) { 24 if (!pthread_mutex_trylock(mutex)) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 VP9LfSync *lf_sync) { 146 VP9LfSync *lf_sync) {
146 const VP9WorkerInterface *const winterface = vp9_get_worker_interface(); 147 const VP9WorkerInterface *const winterface = vp9_get_worker_interface();
147 // Number of superblock rows and cols 148 // Number of superblock rows and cols
148 const int sb_rows = mi_cols_aligned_to_sb(cm->mi_rows) >> MI_BLOCK_SIZE_LOG2; 149 const int sb_rows = mi_cols_aligned_to_sb(cm->mi_rows) >> MI_BLOCK_SIZE_LOG2;
149 // Decoder may allocate more threads than number of tiles based on user's 150 // Decoder may allocate more threads than number of tiles based on user's
150 // input. 151 // input.
151 const int tile_cols = 1 << cm->log2_tile_cols; 152 const int tile_cols = 1 << cm->log2_tile_cols;
152 const int num_workers = MIN(nworkers, tile_cols); 153 const int num_workers = MIN(nworkers, tile_cols);
153 int i; 154 int i;
154 155
155 if (!lf_sync->sync_range || cm->last_height != cm->height || 156 if (!lf_sync->sync_range || sb_rows != lf_sync->rows ||
156 num_workers > lf_sync->num_workers) { 157 num_workers > lf_sync->num_workers) {
157 vp9_loop_filter_dealloc(lf_sync); 158 vp9_loop_filter_dealloc(lf_sync);
158 vp9_loop_filter_alloc(lf_sync, cm, sb_rows, cm->width, num_workers); 159 vp9_loop_filter_alloc(lf_sync, cm, sb_rows, cm->width, num_workers);
159 } 160 }
160 161
161 // Initialize cur_sb_col to -1 for all SB rows. 162 // Initialize cur_sb_col to -1 for all SB rows.
162 vpx_memset(lf_sync->cur_sb_col, -1, sizeof(*lf_sync->cur_sb_col) * sb_rows); 163 vpx_memset(lf_sync->cur_sb_col, -1, sizeof(*lf_sync->cur_sb_col) * sb_rows);
163 164
164 // Set up loopfilter thread data. 165 // Set up loopfilter thread data.
165 // The decoder is capping num_workers because it has been observed that using 166 // The decoder is capping num_workers because it has been observed that using
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 vpx_free(lf_sync->cond_); 293 vpx_free(lf_sync->cond_);
293 } 294 }
294 #endif // CONFIG_MULTITHREAD 295 #endif // CONFIG_MULTITHREAD
295 vpx_free(lf_sync->lfdata); 296 vpx_free(lf_sync->lfdata);
296 vpx_free(lf_sync->cur_sb_col); 297 vpx_free(lf_sync->cur_sb_col);
297 // clear the structure as the source of this call may be a resize in which 298 // clear the structure as the source of this call may be a resize in which
298 // case this call will be followed by an _alloc() which may fail. 299 // case this call will be followed by an _alloc() which may fail.
299 vp9_zero(*lf_sync); 300 vp9_zero(*lf_sync);
300 } 301 }
301 } 302 }
303
304 // Accumulate frame counts.
305 void vp9_accumulate_frame_counts(VP9_COMMON *cm, FRAME_COUNTS *counts,
306 int is_dec) {
307 int i, j, k, l, m;
308
309 for (i = 0; i < BLOCK_SIZE_GROUPS; i++)
310 for (j = 0; j < INTRA_MODES; j++)
311 cm->counts.y_mode[i][j] += counts->y_mode[i][j];
312
313 for (i = 0; i < INTRA_MODES; i++)
314 for (j = 0; j < INTRA_MODES; j++)
315 cm->counts.uv_mode[i][j] += counts->uv_mode[i][j];
316
317 for (i = 0; i < PARTITION_CONTEXTS; i++)
318 for (j = 0; j < PARTITION_TYPES; j++)
319 cm->counts.partition[i][j] += counts->partition[i][j];
320
321 if (is_dec) {
322 int n;
323 for (i = 0; i < TX_SIZES; i++)
324 for (j = 0; j < PLANE_TYPES; j++)
325 for (k = 0; k < REF_TYPES; k++)
326 for (l = 0; l < COEF_BANDS; l++)
327 for (m = 0; m < COEFF_CONTEXTS; m++) {
328 cm->counts.eob_branch[i][j][k][l][m] +=
329 counts->eob_branch[i][j][k][l][m];
330 for (n = 0; n < UNCONSTRAINED_NODES + 1; n++)
331 cm->counts.coef[i][j][k][l][m][n] +=
332 counts->coef[i][j][k][l][m][n];
333 }
334 } else {
335 for (i = 0; i < TX_SIZES; i++)
336 for (j = 0; j < PLANE_TYPES; j++)
337 for (k = 0; k < REF_TYPES; k++)
338 for (l = 0; l < COEF_BANDS; l++)
339 for (m = 0; m < COEFF_CONTEXTS; m++)
340 cm->counts.eob_branch[i][j][k][l][m] +=
341 counts->eob_branch[i][j][k][l][m];
342 // In the encoder, cm->counts.coef is only updated at frame
343 // level, so not need to accumulate it here.
344 // for (n = 0; n < UNCONSTRAINED_NODES + 1; n++)
345 // cm->counts.coef[i][j][k][l][m][n] +=
346 // counts->coef[i][j][k][l][m][n];
347 }
348
349 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++)
350 for (j = 0; j < SWITCHABLE_FILTERS; j++)
351 cm->counts.switchable_interp[i][j] += counts->switchable_interp[i][j];
352
353 for (i = 0; i < INTER_MODE_CONTEXTS; i++)
354 for (j = 0; j < INTER_MODES; j++)
355 cm->counts.inter_mode[i][j] += counts->inter_mode[i][j];
356
357 for (i = 0; i < INTRA_INTER_CONTEXTS; i++)
358 for (j = 0; j < 2; j++)
359 cm->counts.intra_inter[i][j] += counts->intra_inter[i][j];
360
361 for (i = 0; i < COMP_INTER_CONTEXTS; i++)
362 for (j = 0; j < 2; j++)
363 cm->counts.comp_inter[i][j] += counts->comp_inter[i][j];
364
365 for (i = 0; i < REF_CONTEXTS; i++)
366 for (j = 0; j < 2; j++)
367 for (k = 0; k < 2; k++)
368 cm->counts.single_ref[i][j][k] += counts->single_ref[i][j][k];
369
370 for (i = 0; i < REF_CONTEXTS; i++)
371 for (j = 0; j < 2; j++)
372 cm->counts.comp_ref[i][j] += counts->comp_ref[i][j];
373
374 for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
375 for (j = 0; j < TX_SIZES; j++)
376 cm->counts.tx.p32x32[i][j] += counts->tx.p32x32[i][j];
377
378 for (j = 0; j < TX_SIZES - 1; j++)
379 cm->counts.tx.p16x16[i][j] += counts->tx.p16x16[i][j];
380
381 for (j = 0; j < TX_SIZES - 2; j++)
382 cm->counts.tx.p8x8[i][j] += counts->tx.p8x8[i][j];
383 }
384
385 for (i = 0; i < SKIP_CONTEXTS; i++)
386 for (j = 0; j < 2; j++)
387 cm->counts.skip[i][j] += counts->skip[i][j];
388
389 for (i = 0; i < MV_JOINTS; i++)
390 cm->counts.mv.joints[i] += counts->mv.joints[i];
391
392 for (k = 0; k < 2; k++) {
393 nmv_component_counts *comps = &cm->counts.mv.comps[k];
394 nmv_component_counts *comps_t = &counts->mv.comps[k];
395
396 for (i = 0; i < 2; i++) {
397 comps->sign[i] += comps_t->sign[i];
398 comps->class0_hp[i] += comps_t->class0_hp[i];
399 comps->hp[i] += comps_t->hp[i];
400 }
401
402 for (i = 0; i < MV_CLASSES; i++)
403 comps->classes[i] += comps_t->classes[i];
404
405 for (i = 0; i < CLASS0_SIZE; i++) {
406 comps->class0[i] += comps_t->class0[i];
407 for (j = 0; j < MV_FP_SIZE; j++)
408 comps->class0_fp[i][j] += comps_t->class0_fp[i][j];
409 }
410
411 for (i = 0; i < MV_OFFSET_BITS; i++)
412 for (j = 0; j < 2; j++)
413 comps->bits[i][j] += comps_t->bits[i][j];
414
415 for (i = 0; i < MV_FP_SIZE; i++)
416 comps->fp[i] += comps_t->fp[i];
417 }
418 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/common/vp9_thread_common.h ('k') | source/libvpx/vp9/common/x86/vp9_high_intrapred_sse2.asm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698