2013-02-07 00:30:21 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "vp9/common/vp9_tile_common.h"
|
|
|
|
|
2013-07-16 23:47:15 +02:00
|
|
|
#define MIN_TILE_WIDTH_B64 4
|
|
|
|
#define MAX_TILE_WIDTH_B64 64
|
2013-03-05 23:12:16 +01:00
|
|
|
|
2013-07-08 23:54:04 +02:00
|
|
|
static int to_sbs(n_mis) {
|
2013-08-22 23:45:24 +02:00
|
|
|
return mi_cols_aligned_to_sb(n_mis) >> MI_BLOCK_SIZE_LOG2;
|
2013-07-08 23:54:04 +02:00
|
|
|
}
|
|
|
|
|
2013-07-16 23:47:15 +02:00
|
|
|
static void vp9_get_tile_offsets(int *min_tile_off, int *max_tile_off,
|
|
|
|
int tile_idx, int log2_n_tiles, int n_mis) {
|
2013-07-08 23:54:04 +02:00
|
|
|
const int n_sbs = to_sbs(n_mis);
|
2013-02-08 20:33:11 +01:00
|
|
|
const int sb_off1 = (tile_idx * n_sbs) >> log2_n_tiles;
|
|
|
|
const int sb_off2 = ((tile_idx + 1) * n_sbs) >> log2_n_tiles;
|
|
|
|
|
2013-05-05 07:09:43 +02:00
|
|
|
*min_tile_off = MIN(sb_off1 << 3, n_mis);
|
|
|
|
*max_tile_off = MIN(sb_off2 << 3, n_mis);
|
2013-02-08 20:33:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void vp9_get_tile_col_offsets(VP9_COMMON *cm, int tile_col_idx) {
|
2013-07-16 23:47:15 +02:00
|
|
|
vp9_get_tile_offsets(&cm->cur_tile_mi_col_start, &cm->cur_tile_mi_col_end,
|
|
|
|
tile_col_idx, cm->log2_tile_cols, cm->mi_cols);
|
2013-02-08 20:33:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void vp9_get_tile_row_offsets(VP9_COMMON *cm, int tile_row_idx) {
|
2013-07-16 23:47:15 +02:00
|
|
|
vp9_get_tile_offsets(&cm->cur_tile_mi_row_start, &cm->cur_tile_mi_row_end,
|
|
|
|
tile_row_idx, cm->log2_tile_rows, cm->mi_rows);
|
2013-02-07 00:30:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-16 23:47:15 +02:00
|
|
|
void vp9_get_tile_n_bits(int mi_cols,
|
|
|
|
int *min_log2_tile_cols, int *max_log2_tile_cols) {
|
|
|
|
const int sb_cols = to_sbs(mi_cols);
|
2013-02-07 00:30:21 +01:00
|
|
|
int min_log2_n_tiles, max_log2_n_tiles;
|
|
|
|
|
|
|
|
for (max_log2_n_tiles = 0;
|
2013-07-16 23:47:15 +02:00
|
|
|
(sb_cols >> max_log2_n_tiles) >= MIN_TILE_WIDTH_B64;
|
2013-02-07 00:30:21 +01:00
|
|
|
max_log2_n_tiles++) {}
|
2013-05-31 20:18:23 +02:00
|
|
|
max_log2_n_tiles--;
|
|
|
|
if (max_log2_n_tiles < 0)
|
|
|
|
max_log2_n_tiles = 0;
|
|
|
|
|
2013-02-07 00:30:21 +01:00
|
|
|
for (min_log2_n_tiles = 0;
|
2013-07-16 23:47:15 +02:00
|
|
|
(MAX_TILE_WIDTH_B64 << min_log2_n_tiles) < sb_cols;
|
2013-02-07 00:30:21 +01:00
|
|
|
min_log2_n_tiles++) {}
|
|
|
|
|
2013-07-16 23:47:15 +02:00
|
|
|
assert(min_log2_n_tiles <= max_log2_n_tiles);
|
|
|
|
|
|
|
|
*min_log2_tile_cols = min_log2_n_tiles;
|
|
|
|
*max_log2_tile_cols = max_log2_n_tiles;
|
2013-02-07 00:30:21 +01:00
|
|
|
}
|