diff options
Diffstat (limited to 'vp9/encoder/vp9_encodeframe.c')
-rw-r--r-- | vp9/encoder/vp9_encodeframe.c | 62 |
1 files changed, 41 insertions, 21 deletions
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 503c6a829..2e7cb291d 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -1248,15 +1248,13 @@ static void rd_use_partition(VP9_COMP *cpi, MODE_INFO *m, TOKENEXTRA **tp, case PARTITION_NONE: pick_sb_modes(cpi, mi_row, mi_col, &last_part_rate, &last_part_dist, bsize, get_block_context(x, bsize), INT64_MAX); - set_partition_seg_context(cm, xd, mi_row, mi_col); - pl = partition_plane_context(xd, bsize); - last_part_rate += x->partition_cost[pl][PARTITION_NONE]; break; case PARTITION_HORZ: *(get_sb_index(xd, subsize)) = 0; pick_sb_modes(cpi, mi_row, mi_col, &last_part_rate, &last_part_dist, subsize, get_block_context(x, subsize), INT64_MAX); - if (bsize >= BLOCK_SIZE_SB8X8 && mi_row + (mh >> 1) < cm->mi_rows) { + if (last_part_rate != INT_MAX && + bsize >= BLOCK_SIZE_SB8X8 && mi_row + (mh >> 1) < cm->mi_rows) { int rt = 0; int64_t dt = 0; update_state(cpi, get_block_context(x, subsize), subsize, 0); @@ -1264,18 +1262,22 @@ static void rd_use_partition(VP9_COMP *cpi, MODE_INFO *m, TOKENEXTRA **tp, *(get_sb_index(xd, subsize)) = 1; pick_sb_modes(cpi, mi_row + (ms >> 1), mi_col, &rt, &dt, subsize, get_block_context(x, subsize), INT64_MAX); + if (rt == INT_MAX || dt == INT_MAX) { + last_part_rate = INT_MAX; + last_part_dist = INT_MAX; + break; + } + last_part_rate += rt; last_part_dist += dt; } - set_partition_seg_context(cm, xd, mi_row, mi_col); - pl = partition_plane_context(xd, bsize); - last_part_rate += x->partition_cost[pl][PARTITION_HORZ]; break; case PARTITION_VERT: *(get_sb_index(xd, subsize)) = 0; pick_sb_modes(cpi, mi_row, mi_col, &last_part_rate, &last_part_dist, subsize, get_block_context(x, subsize), INT64_MAX); - if (bsize >= BLOCK_SIZE_SB8X8 && mi_col + (ms >> 1) < cm->mi_cols) { + if (last_part_rate != INT_MAX && + bsize >= BLOCK_SIZE_SB8X8 && mi_col + (ms >> 1) < cm->mi_cols) { int rt = 0; int64_t dt = 0; update_state(cpi, get_block_context(x, subsize), subsize, 0); @@ -1283,12 +1285,14 @@ static void rd_use_partition(VP9_COMP *cpi, MODE_INFO *m, TOKENEXTRA **tp, *(get_sb_index(xd, subsize)) = 1; pick_sb_modes(cpi, mi_row, mi_col + (ms >> 1), &rt, &dt, subsize, get_block_context(x, subsize), INT64_MAX); + if (rt == INT_MAX || dt == INT_MAX) { + last_part_rate = INT_MAX; + last_part_dist = INT_MAX; + break; + } last_part_rate += rt; last_part_dist += dt; } - set_partition_seg_context(cm, xd, mi_row, mi_col); - pl = partition_plane_context(xd, bsize); - last_part_rate += x->partition_cost[pl][PARTITION_VERT]; break; case PARTITION_SPLIT: // Split partition. @@ -1308,16 +1312,23 @@ static void rd_use_partition(VP9_COMP *cpi, MODE_INFO *m, TOKENEXTRA **tp, rd_use_partition(cpi, m + jj * bss * mis + ii * bss, tp, mi_row + y_idx, mi_col + x_idx, subsize, &rt, &dt, i != 3); + if (rt == INT_MAX || dt == INT_MAX) { + last_part_rate = INT_MAX; + last_part_dist = INT_MAX; + break; + } last_part_rate += rt; last_part_dist += dt; } - set_partition_seg_context(cm, xd, mi_row, mi_col); - pl = partition_plane_context(xd, bsize); - last_part_rate += x->partition_cost[pl][PARTITION_SPLIT]; break; default: assert(0); } + set_partition_seg_context(cm, xd, mi_row, mi_col); + pl = partition_plane_context(xd, bsize); + if (last_part_rate < INT_MAX) + last_part_rate += x->partition_cost[pl][partition]; + if (cpi->sf.adjust_partitioning_from_last_frame && partition != PARTITION_SPLIT && bsize > BLOCK_SIZE_SB8X8 && (mi_row + ms < cm->mi_rows || mi_row + (ms >> 1) == cm->mi_rows) @@ -1352,7 +1363,13 @@ static void rd_use_partition(VP9_COMP *cpi, MODE_INFO *m, TOKENEXTRA **tp, restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); - if (rt < INT_MAX && dt < INT_MAX && i != 3) + if (rt == INT_MAX || dt == INT_MAX) { + split_rate = INT_MAX; + split_dist = INT_MAX; + break; + } + + if (i != 3) encode_sb(cpi, tp, mi_row + y_idx, mi_col + x_idx, 0, split_subsize); @@ -1364,10 +1381,12 @@ static void rd_use_partition(VP9_COMP *cpi, MODE_INFO *m, TOKENEXTRA **tp, } set_partition_seg_context(cm, xd, mi_row, mi_col); pl = partition_plane_context(xd, bsize); - split_rate += x->partition_cost[pl][PARTITION_SPLIT]; + if (split_rate < INT_MAX) { + split_rate += x->partition_cost[pl][PARTITION_SPLIT]; - chosen_rate = split_rate; - chosen_dist = split_dist; + chosen_rate = split_rate; + chosen_dist = split_dist; + } } // If last_part is better set the partitioning to that... @@ -1392,10 +1411,12 @@ static void rd_use_partition(VP9_COMP *cpi, MODE_INFO *m, TOKENEXTRA **tp, // We must have chosen a partitioning and encoding or we'll fail later on. // No other opportunities for success. - assert(chosen_rate < INT_MAX && chosen_dist < INT_MAX); + if ( bsize == BLOCK_SIZE_SB64X64) + assert(chosen_rate < INT_MAX && chosen_dist < INT_MAX); if (do_recon) encode_sb(cpi, tp, mi_row, mi_col, bsize == BLOCK_SIZE_SB64X64, bsize); + *rate = chosen_rate; *dist = chosen_dist; } @@ -1907,7 +1928,6 @@ static void init_encode_frame_mb_context(VP9_COMP *cpi) { cpi->seg0_idx = 0; xd->mode_info_stride = cm->mode_info_stride; - xd->frame_type = cm->frame_type; // reset intra mode contexts if (cm->frame_type == KEY_FRAME) @@ -1953,7 +1973,7 @@ static void switch_lossless_mode(VP9_COMP *cpi, int lossless) { cpi->mb.e_mbd.inv_txm4x4_1_add = vp9_short_iwalsh4x4_1_add; cpi->mb.e_mbd.inv_txm4x4_add = vp9_short_iwalsh4x4_add; cpi->mb.optimize = 0; - cpi->common.filter_level = 0; + cpi->mb.e_mbd.lf.filter_level = 0; cpi->zbin_mode_boost_enabled = 0; cpi->common.tx_mode = ONLY_4X4; } else { |