media/libvpx/vp9/common/vp9_tile_common.c

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /*
michael@0 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license
michael@0 5 * that can be found in the LICENSE file in the root of the source
michael@0 6 * tree. An additional intellectual property rights grant can be found
michael@0 7 * in the file PATENTS. All contributing project authors may
michael@0 8 * be found in the AUTHORS file in the root of the source tree.
michael@0 9 */
michael@0 10
michael@0 11 #include "vp9/common/vp9_tile_common.h"
michael@0 12
michael@0 13 #include "vp9/common/vp9_onyxc_int.h"
michael@0 14
michael@0 15 #define MIN_TILE_WIDTH_B64 4
michael@0 16 #define MAX_TILE_WIDTH_B64 64
michael@0 17
michael@0 18 static int get_tile_offset(int idx, int mis, int log2) {
michael@0 19 const int sb_cols = mi_cols_aligned_to_sb(mis) >> MI_BLOCK_SIZE_LOG2;
michael@0 20 const int offset = ((idx * sb_cols) >> log2) << MI_BLOCK_SIZE_LOG2;
michael@0 21 return MIN(offset, mis);
michael@0 22 }
michael@0 23
michael@0 24 void vp9_tile_init(TileInfo *tile, const VP9_COMMON *cm, int row, int col) {
michael@0 25 tile->mi_row_start = get_tile_offset(row, cm->mi_rows, cm->log2_tile_rows);
michael@0 26 tile->mi_row_end = get_tile_offset(row + 1, cm->mi_rows, cm->log2_tile_rows);
michael@0 27 tile->mi_col_start = get_tile_offset(col, cm->mi_cols, cm->log2_tile_cols);
michael@0 28 tile->mi_col_end = get_tile_offset(col + 1, cm->mi_cols, cm->log2_tile_cols);
michael@0 29 }
michael@0 30
michael@0 31 void vp9_get_tile_n_bits(int mi_cols,
michael@0 32 int *min_log2_tile_cols, int *max_log2_tile_cols) {
michael@0 33 const int sb_cols = mi_cols_aligned_to_sb(mi_cols) >> MI_BLOCK_SIZE_LOG2;
michael@0 34 int min_log2 = 0, max_log2 = 0;
michael@0 35
michael@0 36 // max
michael@0 37 while ((sb_cols >> max_log2) >= MIN_TILE_WIDTH_B64)
michael@0 38 ++max_log2;
michael@0 39 --max_log2;
michael@0 40 if (max_log2 < 0)
michael@0 41 max_log2 = 0;
michael@0 42
michael@0 43 // min
michael@0 44 while ((MAX_TILE_WIDTH_B64 << min_log2) < sb_cols)
michael@0 45 ++min_log2;
michael@0 46
michael@0 47 assert(min_log2 <= max_log2);
michael@0 48
michael@0 49 *min_log2_tile_cols = min_log2;
michael@0 50 *max_log2_tile_cols = max_log2;
michael@0 51 }

mercurial