media/libvpx/vp9/common/vp9_tile_common.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libvpx/vp9/common/vp9_tile_common.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,51 @@
     1.4 +/*
     1.5 + *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
     1.6 + *
     1.7 + *  Use of this source code is governed by a BSD-style license
     1.8 + *  that can be found in the LICENSE file in the root of the source
     1.9 + *  tree. An additional intellectual property rights grant can be found
    1.10 + *  in the file PATENTS.  All contributing project authors may
    1.11 + *  be found in the AUTHORS file in the root of the source tree.
    1.12 + */
    1.13 +
    1.14 +#include "vp9/common/vp9_tile_common.h"
    1.15 +
    1.16 +#include "vp9/common/vp9_onyxc_int.h"
    1.17 +
    1.18 +#define MIN_TILE_WIDTH_B64 4
    1.19 +#define MAX_TILE_WIDTH_B64 64
    1.20 +
    1.21 +static int get_tile_offset(int idx, int mis, int log2) {
    1.22 +  const int sb_cols = mi_cols_aligned_to_sb(mis) >> MI_BLOCK_SIZE_LOG2;
    1.23 +  const int offset = ((idx * sb_cols) >> log2) << MI_BLOCK_SIZE_LOG2;
    1.24 +  return MIN(offset, mis);
    1.25 +}
    1.26 +
    1.27 +void vp9_tile_init(TileInfo *tile, const VP9_COMMON *cm, int row, int col) {
    1.28 +  tile->mi_row_start = get_tile_offset(row, cm->mi_rows, cm->log2_tile_rows);
    1.29 +  tile->mi_row_end = get_tile_offset(row + 1, cm->mi_rows, cm->log2_tile_rows);
    1.30 +  tile->mi_col_start = get_tile_offset(col, cm->mi_cols, cm->log2_tile_cols);
    1.31 +  tile->mi_col_end = get_tile_offset(col + 1, cm->mi_cols, cm->log2_tile_cols);
    1.32 +}
    1.33 +
    1.34 +void vp9_get_tile_n_bits(int mi_cols,
    1.35 +                         int *min_log2_tile_cols, int *max_log2_tile_cols) {
    1.36 +  const int sb_cols = mi_cols_aligned_to_sb(mi_cols) >> MI_BLOCK_SIZE_LOG2;
    1.37 +  int min_log2 = 0, max_log2 = 0;
    1.38 +
    1.39 +  // max
    1.40 +  while ((sb_cols >> max_log2) >= MIN_TILE_WIDTH_B64)
    1.41 +    ++max_log2;
    1.42 +  --max_log2;
    1.43 +  if (max_log2 < 0)
    1.44 +    max_log2 = 0;
    1.45 +
    1.46 +  // min
    1.47 +  while ((MAX_TILE_WIDTH_B64 << min_log2) < sb_cols)
    1.48 +    ++min_log2;
    1.49 +
    1.50 +  assert(min_log2 <= max_log2);
    1.51 +
    1.52 +  *min_log2_tile_cols = min_log2;
    1.53 +  *max_log2_tile_cols = max_log2;
    1.54 +}

mercurial