diff options
Diffstat (limited to 'vp9/encoder')
-rw-r--r-- | vp9/encoder/vp9_bitstream.c | 31 | ||||
-rw-r--r-- | vp9/encoder/vp9_encodeframe.c | 14 | ||||
-rw-r--r-- | vp9/encoder/vp9_onyx_if.c | 19 | ||||
-rw-r--r-- | vp9/encoder/vp9_segmentation.c | 21 |
4 files changed, 44 insertions, 41 deletions
diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c index a3c407865..c5f2a70c6 100644 --- a/vp9/encoder/vp9_bitstream.c +++ b/vp9/encoder/vp9_bitstream.c @@ -14,6 +14,7 @@ #include "vp9/common/vp9_entropymode.h" #include "vp9/common/vp9_entropymv.h" #include "vp9/common/vp9_findnearmv.h" +#include "vp9/common/vp9_tile_common.h" #include "vp9/encoder/vp9_mcomp.h" #include "vp9/common/vp9_systemdependent.h" #include <assert.h> @@ -2026,9 +2027,19 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest, } /* tiling */ - vp9_write(&header_bc, pc->tile_columns > 1, 128); - if (pc->tile_columns > 1) { - vp9_write(&header_bc, pc->tile_columns > 2, 128); + { + int min_log2_tiles, delta_log2_tiles, n_tile_bits, n; + + vp9_get_tile_n_bits(pc, &min_log2_tiles, &delta_log2_tiles); + n_tile_bits = pc->log2_tile_columns - min_log2_tiles; + for (n = 0; n < delta_log2_tiles; n++) { + if (n_tile_bits--) { + vp9_write_bit(&header_bc, 1); + } else { + vp9_write_bit(&header_bc, 0); + break; + } + } } vp9_stop_encode(&header_bc); @@ -2058,21 +2069,14 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest, } { - int mb_start = 0, tile; - int total_size = 0; + int tile, total_size = 0; unsigned char *data_ptr = cx_data + header_bc.pos; TOKENEXTRA *tok = cpi->tok; for (tile = 0; tile < pc->tile_columns; tile++) { - // calculate end of tile column - const int sb_cols = (pc->mb_cols + 3) >> 2; - const int sb_end = (sb_cols * (tile + 1)) >> cpi->oxcf.tile_columns; - const int mb_end = ((sb_end << 2) > pc->mb_cols) ? - pc->mb_cols : (sb_end << 2); - pc->cur_tile_idx = tile; - pc->cur_tile_mb_col_start = mb_start; - pc->cur_tile_mb_col_end = mb_end; + vp9_get_tile_offsets(pc, &pc->cur_tile_mb_col_start, + &pc->cur_tile_mb_col_end); if (tile < pc->tile_columns - 1) vp9_start_encode(&residual_bc, data_ptr + total_size + 4); @@ -2089,7 +2093,6 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest, total_size += 4; } - mb_start = mb_end; total_size += residual_bc.pos; } diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 927a1b901..c5f717f5f 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -28,6 +28,7 @@ #include "vp9/common/vp9_findnearmv.h" #include "vp9/common/vp9_reconintra.h" #include "vp9/common/vp9_seg_common.h" +#include "vp9/common/vp9_tile_common.h" #include "vp9/encoder/vp9_tokenize.h" #include "vp9_rtcd.h" #include <stdio.h> @@ -1312,23 +1313,16 @@ static void encode_frame_internal(VP9_COMP *cpi) { { // Take tiles into account and give start/end MB - int tile, mb_start = 0; + int tile; for (tile = 0; tile < cm->tile_columns; tile++) { - // calculate end of tile column - const int sb_cols = (cm->mb_cols + 3) >> 2; - const int sb_end = (sb_cols * (tile + 1)) >> cpi->oxcf.tile_columns; - const int mb_end = ((sb_end << 2) > cm->mb_cols) ? - cm->mb_cols : (sb_end << 2); - // For each row of SBs in the frame cm->cur_tile_idx = tile; - cm->cur_tile_mb_col_start = mb_start; - cm->cur_tile_mb_col_end = mb_end; + vp9_get_tile_offsets(cm, &cm->cur_tile_mb_col_start, + &cm->cur_tile_mb_col_end); for (mb_row = 0; mb_row < cm->mb_rows; mb_row += 4) { encode_sb_row(cpi, mb_row, &tp, &totalrate); } - mb_start = mb_end; } cpi->tok_count = (unsigned int)(tp - cpi->tok); diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index ad5fe7819..73b7b1f5f 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -23,6 +23,7 @@ #include "vp9/common/vp9_extend.h" #include "vp9/encoder/vp9_ratectrl.h" #include "vp9/common/vp9_quant_common.h" +#include "vp9/common/vp9_tile_common.h" #include "vp9/encoder/vp9_segmentation.h" #include "./vp9_rtcd.h" #include "./vpx_scale_rtcd.h" @@ -949,7 +950,6 @@ void vp9_alloc_compressor_data(VP9_COMP *cpi) { vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR, "Failed to allocate scaled source buffer"); - vpx_free(cpi->tok); { @@ -1107,6 +1107,17 @@ rescale(int val, int num, int denom) { return (int)(llval * llnum / llden); } +static void set_tile_limits(VP9_COMMON *cm) { + int min_log2_tiles, max_log2_tiles; + + vp9_get_tile_n_bits(cm, &min_log2_tiles, &max_log2_tiles); + max_log2_tiles += min_log2_tiles; + if (cm->log2_tile_columns < min_log2_tiles) + cm->log2_tile_columns = min_log2_tiles; + else if (cm->log2_tile_columns > max_log2_tiles) + cm->log2_tile_columns = max_log2_tiles; + cm->tile_columns = 1 << cm->log2_tile_columns; +} static void init_config(VP9_PTR ptr, VP9_CONFIG *oxcf) { VP9_COMP *cpi = (VP9_COMP *)(ptr); @@ -1145,7 +1156,8 @@ static void init_config(VP9_PTR ptr, VP9_CONFIG *oxcf) { cpi->gld_fb_idx = 1; cpi->alt_fb_idx = 2; - cm->tile_columns = 1 << cpi->oxcf.tile_columns; + cm->log2_tile_columns = cpi->oxcf.tile_columns; + set_tile_limits(cm); #if VP9_TEMPORAL_ALT_REF { @@ -1372,7 +1384,8 @@ void vp9_change_config(VP9_PTR ptr, VP9_CONFIG *oxcf) { cpi->last_frame_distortion = 0; #endif - cm->tile_columns = 1 << cpi->oxcf.tile_columns; + cm->log2_tile_columns = cpi->oxcf.tile_columns; + set_tile_limits(cm); } #define M_LOG2_E 0.693147180559945309417 diff --git a/vp9/encoder/vp9_segmentation.c b/vp9/encoder/vp9_segmentation.c index 17d8f25bd..710ca7ea0 100644 --- a/vp9/encoder/vp9_segmentation.c +++ b/vp9/encoder/vp9_segmentation.c @@ -13,6 +13,7 @@ #include "vpx_mem/vpx_mem.h" #include "vp9/encoder/vp9_segmentation.h" #include "vp9/common/vp9_pred_common.h" +#include "vp9/common/vp9_tile_common.h" void vp9_update_gf_useage_maps(VP9_COMP *cpi, VP9_COMMON *cm, MACROBLOCK *x) { int mb_row, mb_col; @@ -254,7 +255,7 @@ void vp9_choose_segmap_coding_method(VP9_COMP *cpi) { int t_pred_cost = INT_MAX; int i; - int tile, mb_row, mb_col, mb_start = 0; + int tile, mb_row, mb_col; int temporal_predictor_count[PREDICTION_PROBS][2]; int no_pred_segcounts[MAX_MB_SEGMENTS]; @@ -283,20 +284,14 @@ void vp9_choose_segmap_coding_method(VP9_COMP *cpi) { // predicts this one for (tile = 0; tile < cm->tile_columns; tile++) { - // calculate end of tile column - const int sb_cols = (cm->mb_cols + 3) >> 2; - const int sb_end = (sb_cols * (tile + 1)) >> cpi->oxcf.tile_columns; - const int mb_end = ((sb_end << 2) > cm->mb_cols) ? - cm->mb_cols : (sb_end << 2); - cm->cur_tile_idx = tile; - cm->cur_tile_mb_col_start = mb_start; - cm->cur_tile_mb_col_end = mb_end; - - mi_ptr = cm->mi + mb_start; + vp9_get_tile_offsets(cm, &cm->cur_tile_mb_col_start, + &cm->cur_tile_mb_col_end); + mi_ptr = cm->mi + cm->cur_tile_mb_col_start; for (mb_row = 0; mb_row < cm->mb_rows; mb_row += 4, mi_ptr += 4 * mis) { mi = mi_ptr; - for (mb_col = mb_start; mb_col < mb_end; mb_col += 4, mi += 4) { + for (mb_col = cm->cur_tile_mb_col_start; + mb_col < cm->cur_tile_mb_col_end; mb_col += 4, mi += 4) { if (mi->mbmi.sb_type == BLOCK_SIZE_SB64X64) { count_segs(cpi, mi, no_pred_segcounts, temporal_predictor_count, t_unpred_seg_counts, 4, mb_row, mb_col); @@ -338,8 +333,6 @@ void vp9_choose_segmap_coding_method(VP9_COMP *cpi) { } } } - - mb_start = mb_end; } // Work out probability tree for coding segments without prediction |