#else
static const unsigned int kf_y_mode_cts[VP8_YMODES] = { 49, 22, 23, 11, 23, 128};
#endif
-static const unsigned int y_mode_cts [VP8_YMODES] = { 8080, 1908, 1582, 1007, 0, 5874};
+/* TODO: calibrate the baseline distribution */
+static const unsigned int y_mode_cts [VP8_YMODES] = { 8080, 1908, 1582, 1007, 2000, 5874};
#else
static const unsigned int kf_y_mode_cts[VP8_YMODES] = { 1607, 915, 812, 811, 5455};
static const unsigned int y_mode_cts [VP8_YMODES] = { 8080, 1908, 1582, 1007, 5874};
/* Again, these trees use the same probability indices as their
explicitly-programmed predecessors. */
-const vp8_tree_index vp8_ymode_tree[8] =
+#if CONFIG_I8X8
+const vp8_tree_index vp8_ymode_tree[10] =
{
-DC_PRED, 2,
4, 6,
-V_PRED, -H_PRED,
- -TM_PRED, -B_PRED
+ -TM_PRED, 8,
+ -B_PRED, -I8X8_PRED
};
-#if CONFIG_I8X8
const vp8_tree_index vp8_kf_ymode_tree[10] =
{
-B_PRED, 2,
-H_PRED, -TM_PRED
};
#else
+const vp8_tree_index vp8_ymode_tree[8] =
+{
+ -DC_PRED, 2,
+ 4, 6,
+ -V_PRED, -H_PRED,
+ -TM_PRED, -B_PRED
+};
const vp8_tree_index vp8_kf_ymode_tree[8] =
{
return B_DC_PRED;
}
}
-
return (cur_mb->bmi + b - 1)->as_mode;
}
int i;
if (x->mode_info_context->mbmi.mode != B_PRED &&
+#if CONFIG_I8X8
+ x->mode_info_context->mbmi.mode != I8X8_PRED &&
+#endif
x->mode_info_context->mbmi.mode != SPLITMV)
{
/* do 2nd order transform on the dc block */
lfi->mode_lf_lut[H_PRED] = 1;
lfi->mode_lf_lut[TM_PRED] = 1;
lfi->mode_lf_lut[B_PRED] = 0;
-
+#if CONFIG_I8X8
+ lfi->mode_lf_lut[I8X8_PRED]=0;
+#endif
lfi->mode_lf_lut[ZEROMV] = 1;
lfi->mode_lf_lut[NEARESTMV] = 2;
lfi->mode_lf_lut[NEARMV] = 2;
for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
{
int skip_lf = (mode_info_context->mbmi.mode != B_PRED &&
+#if CONFIG_I8X8
+ mode_info_context->mbmi.mode != I8X8_PRED &&
+#endif
mode_info_context->mbmi.mode != SPLITMV &&
mode_info_context->mbmi.mb_skip_coeff);
for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
{
int skip_lf = (mode_info_context->mbmi.mode != B_PRED &&
+#if CONFIG_I8X8
+ mode_info_context->mbmi.mode != I8X8_PRED &&
+#endif
+
mode_info_context->mbmi.mode != SPLITMV &&
mode_info_context->mbmi.mb_skip_coeff);
for (mb_col = 0; mb_col < mb_cols; mb_col++)
{
int skip_lf = (mode_info_context->mbmi.mode != B_PRED &&
+#if CONFIG_I8X8
+ mode_info_context->mbmi.mode != I8X8_PRED &&
+#endif
mode_info_context->mbmi.mode != SPLITMV &&
mode_info_context->mbmi.mb_skip_coeff);
#include "vpx_ports/mem.h"
#include "vpx_config.h"
+#include "blockd.h"
#define MAX_LOOP_FILTER 63
DECLARE_ALIGNED(SIMD_WIDTH, unsigned char, hev_thr[4][SIMD_WIDTH]);
unsigned char lvl[4][4][4];
unsigned char hev_thr_lut[2][MAX_LOOP_FILTER + 1];
- unsigned char mode_lf_lut[10];
+ unsigned char mode_lf_lut[MB_MODE_COUNT];
} loop_filter_info_n;
typedef struct
{
int i;
int mode8x8;
- //printf("F%3d:%d:%d:",
- pbi->common.current_video_frame, mb_row, mb_col);
for(i=0;i<4;i++)
{
int ib = vp8_i8x8_block[i];
m->bmi[ib+4].as_mode= mode8x8;
m->bmi[ib+5].as_mode= mode8x8;
}
- //printf("%2d%2d%2d%2d\n", m->bmi[0].as_mode,m->bmi[2].as_mode,
- // m->bmi[8].as_mode,m->bmi[10].as_mode);
}
else
#endif
while (++j < 16);
}
+#if CONFIG_I8X8
+ if(mbmi->mode == I8X8_PRED)
+ {
+ int i;
+ int mode8x8;
+ for(i=0;i<4;i++)
+ {
+ int ib = vp8_i8x8_block[i];
+ mode8x8 = vp8_read_i8x8_mode(bc, pbi->common.i8x8_mode_prob);
+ mi->bmi[ib+0].as_mode= mode8x8;
+ mi->bmi[ib+1].as_mode= mode8x8;
+ mi->bmi[ib+4].as_mode= mode8x8;
+ mi->bmi[ib+5].as_mode= mode8x8;
+ }
+ }
+ else
+#endif
mbmi->uv_mode = (MB_PREDICTION_MODE)vp8_read_uv_mode(bc, pbi->common.fc.uv_mode_prob);
}
#include <assert.h>
#include <stdio.h>
+
#ifdef DEC_DEBUG
int dec_debug = 0;
#endif
vp8_build_inter16x16_predictors_mb(xd, xd->dst.y_buffer,
xd->dst.u_buffer, xd->dst.v_buffer,
xd->dst.y_stride, xd->dst.uv_stride);
+ }
#ifdef DEC_DEBUG
if (dec_debug) {
int i, j;
}
}
#endif
- }
+
}
static void clamp_mv_to_umv_border(MV *mv, const MACROBLOCKD *xd)
return;
}
+#ifdef DEC_DEBUG
+ if (dec_debug) {
+ int i, j;
+ printf("Generating predictors\n");
+ for (i=0;i<16;i++) {
+ for (j=0;j<16;j++) printf("%3d ", xd->dst.y_buffer[i*xd->dst.y_stride+j]);
+ printf("\n");
+ }
+ }
+#endif
+
+
+
if (xd->segmentation_enabled)
mb_init_dequantizer(pbi, xd);
}
#ifdef DEC_DEBUG
- dec_debug = (pc->current_video_frame==0 && mb_row==1 && mb_col==11);
+ dec_debug = (pc->current_video_frame==1 && mb_row==4 && mb_col==0);
#endif
decode_macroblock(pbi, xd, mb_row * pc->mb_cols + mb_col);
{
/* Clear entropy contexts for Y2 blocks */
if (x->mode_info_context->mbmi.mode != B_PRED &&
+#if CONFIG_I8X8
+ x->mode_info_context->mbmi.mode != I8X8_PRED &&
+#endif
x->mode_info_context->mbmi.mode != SPLITMV)
{
vpx_memset(x->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES));
fclose(yuv_file);
}
#endif
-
#if WRITE_RECON_BUFFER
void write_dx_frame_to_file(YV12_BUFFER_CONFIG *frame, int this_frame)
{
#if WRITE_RECON_BUFFER
if(cm->show_frame)
write_dx_frame_to_file(cm->frame_to_show, cm->current_video_frame);
+ else
+ write_dx_frame_to_file(cm->frame_to_show, cm->current_video_frame+1000);
#endif
if(cm->filter_level)
if (pbi->common.filter_level)
{
int skip_lf = (xd->mode_info_context->mbmi.mode != B_PRED &&
+#if CONFIG_I8X8
+ xd->mode_info_context->mbmi.mode != I8X8_PRED &&
+#endif
xd->mode_info_context->mbmi.mode != SPLITMV &&
xd->mode_info_context->mbmi.mb_skip_coeff);
write_bmode(w, m->bmi[j].as_mode, pc->fc.bmode_prob);
while (++j < 16);
}
+#if CONFIG_I8X8
+ if(mode == I8X8_PRED)
+ {
+ write_i8x8_mode(w, m->bmi[0].as_mode, pc->i8x8_mode_prob);
+ write_i8x8_mode(w, m->bmi[2].as_mode, pc->i8x8_mode_prob);
+ write_i8x8_mode(w, m->bmi[8].as_mode, pc->i8x8_mode_prob);
+ write_i8x8_mode(w, m->bmi[10].as_mode, pc->i8x8_mode_prob);
+ }
+ else
+#endif
write_uv_mode(w, mi->uv_mode, pc->fc.uv_mode_prob);
}
for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
{
#ifdef ENC_DEBUG
- //enc_debug = (cpi->count==29 && mb_row==5 && mb_col==0);
- enc_debug = (cpi->count==4 && mb_row==17 && mb_col==13);
+ enc_debug = (cpi->common.current_video_frame ==1 && mb_row==4 && mb_col==0);
mb_col_debug=mb_col;
mb_row_debug=mb_row;
#endif
vp8_encode_intra16x16mbuv(IF_RTCD(&cpi->rtcd), x);
vp8_encode_intra4x4mby(IF_RTCD(&cpi->rtcd), x);
}
+#if CONFIG_I8X8
+ else if(xd->mode_info_context->mbmi.mode == I8X8_PRED)
+ {
+ vp8_encode_intra8x8mby(IF_RTCD(&cpi->rtcd), x);
+ vp8_encode_intra8x8mbuv(IF_RTCD(&cpi->rtcd), x);
+ }
+#endif
else
{
vp8_encode_intra16x16mbuv(IF_RTCD(&cpi->rtcd), x);
vp8_encode_intra16x16mby(IF_RTCD(&cpi->rtcd), x);
}
-
sum_intra_stats(cpi, x);
}
else
tl = (ENTROPY_CONTEXT *)&t_left;
has_2nd_order = (x->e_mbd.mode_info_context->mbmi.mode != B_PRED
+#if CONFIG_I8X8
+ &&x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
+#endif
&& x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
type = has_2nd_order ? PLANE_TYPE_Y_NO_DC : PLANE_TYPE_Y_WITH_DC;
tl = (ENTROPY_CONTEXT *)&t_left;
has_2nd_order = (x->e_mbd.mode_info_context->mbmi.mode != B_PRED
+#if CONFIG_I8X8
+ &&x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
+#endif
&& x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
type = has_2nd_order ? PLANE_TYPE_Y_NO_DC : PLANE_TYPE_Y_WITH_DC;
tl = (ENTROPY_CONTEXT *)&t_left;
has_2nd_order = (x->e_mbd.mode_info_context->mbmi.mode != B_PRED
+#if CONFIG_I8X8
+ &&x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
+#endif
+
&& x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
type = has_2nd_order ? 0 : 3;
tl = (ENTROPY_CONTEXT *)&t_left;
has_2nd_order = (x->e_mbd.mode_info_context->mbmi.mode != B_PRED
+#if CONFIG_I8X8
+ && x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
+#endif
&& x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
type = has_2nd_order ? 0 : 3;
sf->thresh_mult[THR_V_PRED ] = 1000;
sf->thresh_mult[THR_H_PRED ] = 1000;
sf->thresh_mult[THR_B_PRED ] = 2000;
+#if CONFIG_I8X8
+ sf->thresh_mult[THR_I8X8_PRED] = 2000;
+#endif
sf->thresh_mult[THR_TM ] = 1000;
sf->thresh_mult[THR_NEWMV ] = 1000;
sf->thresh_mult[THR_V_PRED ] = 1000;
sf->thresh_mult[THR_H_PRED ] = 1000;
sf->thresh_mult[THR_B_PRED ] = 2500;
+#if CONFIG_I8X8
+ sf->thresh_mult[THR_I8X8_PRED] = 2500;
+#endif
sf->thresh_mult[THR_TM ] = 1000;
sf->thresh_mult[THR_NEARESTG ] = 1000;
sf->thresh_mult[THR_V_PRED ] = 1500;
sf->thresh_mult[THR_H_PRED ] = 1500;
sf->thresh_mult[THR_B_PRED ] = 5000;
-
+#if CONFIG_I8X8
+ sf->thresh_mult[THR_I8X8_PRED] = 5000;
+#endif
if (cpi->ref_frame_flags & VP8_LAST_FLAG)
{
sf->thresh_mult[THR_NEWMV ] = 2000;
sf->thresh_mult[THR_V_PRED ] = 2000;
sf->thresh_mult[THR_H_PRED ] = 2000;
sf->thresh_mult[THR_B_PRED ] = 7500;
+#if CONFIG_I8X8
+ sf->thresh_mult[THR_I8X8_PRED] = 7500;
+#endif
if (cpi->ref_frame_flags & VP8_LAST_FLAG)
{
cpi->mode_check_freq[THR_V_PRED] = 0;
cpi->mode_check_freq[THR_H_PRED] = 0;
cpi->mode_check_freq[THR_B_PRED] = 0;
+#if CONFIG_I8X8
+ cpi->mode_check_freq[THR_I8X8_PRED] = 0;
+#endif
+
cpi->mode_check_freq[THR_NEARG] = 0;
cpi->mode_check_freq[THR_NEWG] = 0;
cpi->mode_check_freq[THR_NEARA] = 0;
cpi->mode_check_freq[THR_V_PRED] = 2;
cpi->mode_check_freq[THR_H_PRED] = 2;
cpi->mode_check_freq[THR_B_PRED] = 2;
+#if CONFIG_I8X8
+ cpi->mode_check_freq[THR_I8X8_PRED]=2;
+#endif
+
if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
{
sf->thresh_mult[THR_V_PRED ] = 1000;
sf->thresh_mult[THR_H_PRED ] = 1000;
sf->thresh_mult[THR_B_PRED ] = 2500;
+#if CONFIG_I8X8
+ sf->thresh_mult[THR_I8X8_PRED] = 2500;
+#endif
sf->thresh_mult[THR_NEARESTG ] = 1000;
sf->thresh_mult[THR_ZEROG ] = 1000;
sf->thresh_mult[THR_NEARG ] = 1000;
sf->thresh_mult[THR_V_PRED ] = 2000;
sf->thresh_mult[THR_H_PRED ] = 2000;
sf->thresh_mult[THR_B_PRED ] = 5000;
+#if CONFIG_I8X8
+ sf->thresh_mult[THR_I8X8_PRED] = 5000;
+#endif
if (cpi->ref_frame_flags & VP8_LAST_FLAG)
{
sf->thresh_mult[THR_V_PRED ] = 2000;
sf->thresh_mult[THR_H_PRED ] = 2000;
sf->thresh_mult[THR_B_PRED ] = 5000;
-
+#if CONFIG_I8X8
+ sf->thresh_mult[THR_I8X8_PRED] = 5000;
+#endif
if (cpi->ref_frame_flags & VP8_LAST_FLAG)
{
sf->thresh_mult[THR_NEWMV ] = 2000;
cpi->mode_check_freq[THR_V_PRED] = 2;
cpi->mode_check_freq[THR_H_PRED] = 2;
cpi->mode_check_freq[THR_B_PRED] = 2;
+#if CONFIG_I8X8
+ cpi->mode_check_freq[THR_I8X8_PRED]=2;
+#endif
+
if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
{
cpi->mode_check_freq[THR_V_PRED] = 4;
cpi->mode_check_freq[THR_H_PRED] = 4;
cpi->mode_check_freq[THR_B_PRED] = 4;
-
+#if CONFIG_I8X8
+ cpi->mode_check_freq[THR_I8X8_PRED]=4;
+#endif
if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
{
cpi->mode_check_freq[THR_NEARG] = 2;
sf->thresh_mult[THR_TM ] = 2000;
sf->thresh_mult[THR_B_PRED ] = 5000;
+#if CONFIG_I8X8
+ sf->thresh_mult[THR_I8X8_PRED] = 5000;
+#endif
+
if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
{
{
// Disable split MB intra prediction mode
sf->thresh_mult[THR_B_PRED] = INT_MAX;
+#if CONFIG_I8X8
+ sf->thresh_mult[THR_I8X8_PRED] = INT_MAX;
+#endif
}
if (Speed > 6)
#if WRITE_RECON_BUFFER
if(cm->show_frame)
write_cx_frame_to_file(cm->frame_to_show, cm->current_video_frame);
+ else
+ write_cx_frame_to_file(cm->frame_to_show, cm->current_video_frame+1000);
#endif
#if CONFIG_MULTITHREAD
#define AF_THRESH 25
#define AF_THRESH2 100
#define ARF_DECAY_THRESH 12
+#if CONFIG_I8X8
+#define MAX_MODES 21
+#else
#define MAX_MODES 20
-
+#endif
#define MIN_THRESHMULT 32
#define MAX_THRESHMULT 512
int uv_modes[VP8_UV_MODES];
int i8x8_modes[VP8_I8X8_MODES];
int b_modes[10];
- int inter_y_modes[10];
+ int inter_y_modes[MB_MODE_COUNT];
int inter_uv_modes[VP8_UV_MODES];
int inter_b_modes[10];
#endif
THR_SPLITA = 18,
THR_B_PRED = 19,
+#if CONFIG_I8X8
+ THR_I8X8_PRED = 20,
+#endif
}
THR_MODES;
{
int i;
int has_2nd_order = (x->e_mbd.mode_info_context->mbmi.mode != B_PRED
+#if CONFIG_I8X8
+ && x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
+#endif
&& x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
for (i = 0; i < 16; i++)
{
int i;
int has_2nd_order=(x->e_mbd.mode_info_context->mbmi.mode != B_PRED
+#if CONFIG_I8X8
+ && x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
+#endif
&& x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
for (i = 0; i < 24+has_2nd_order; i++)
SPLITMV,
B_PRED,
+#if CONFIG_I8X8
+ I8X8_PRED,
+#endif
};
const MV_REFERENCE_FRAME vp8_ref_frame_order[MAX_MODES] =
ALTREF_FRAME,
INTRA_FRAME,
+#if CONFIG_I8X8
+ INTRA_FRAME,
+#endif
};
static void fill_token_costs(
}
}
+#if CONFIG_I8X8
+static void set_i8x8_block_modes(MACROBLOCK *x, int *modes)
+{
+ int i;
+ MACROBLOCKD *xd = &x->e_mbd;
+ for(i=0;i<4;i++)
+ {
+ int ib = vp8_i8x8_block[i];
+ x->e_mbd.mode_info_context->bmi[ib+0].as_mode= modes[i];
+ x->e_mbd.mode_info_context->bmi[ib+1].as_mode= modes[i];
+ x->e_mbd.mode_info_context->bmi[ib+4].as_mode= modes[i];
+ x->e_mbd.mode_info_context->bmi[ib+5].as_mode= modes[i];
+ }
+
+ for (i = 0; i < 16; i++)
+ {
+ xd->block[i].bmi = xd->mode_info_context->bmi[i];
+ }
+}
+#endif
+
+
+
void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int recon_uvoffset, int *returnrate, int *returndistortion, int *returnintra)
{
BLOCK *b = &x->block[0];
MB_PREDICTION_MODE this_mode;
int num00;
int best_mode_index = 0;
+#if CONFIG_I8X8
+ int mode8x8[4];
+#endif
unsigned char segment_id = xd->mode_info_context->mbmi.segment_id;
int i;
}
}
break;
+#if CONFIG_I8X8
+ case I8X8_PRED:
+ {
+ int tmp_rd;
+ tmp_rd = rd_pick_intra8x8mby_modes(cpi,
+ x, &rate, &rate_y, &distortion, best_yrd);
+ rate2 += rate;
+ distortion2 += distortion;
+
+ mode8x8[0]= x->e_mbd.mode_info_context->bmi[0].as_mode;
+ mode8x8[1]= x->e_mbd.mode_info_context->bmi[2].as_mode;
+ mode8x8[2]= x->e_mbd.mode_info_context->bmi[8].as_mode;
+ mode8x8[3]= x->e_mbd.mode_info_context->bmi[10].as_mode;
+
+ /* TODO: uv rate maybe over-estimated here since there is UV intra
+ mode coded in I8X8_PRED prediction */
+ if(tmp_rd < best_yrd)
+ {
+ rate2 += uv_intra_rate;
+ rate_uv = uv_intra_rate_tokenonly;
+ distortion2 += uv_intra_distortion;
+ distortion_uv = uv_intra_distortion;
+ }
+ else
+ {
+ this_rd = INT_MAX;
+ disable_skip = 1;
+ }
+ }
+ break;
+#endif
case SPLITMV:
{
vpx_memcpy(&best_mbmode, &x->e_mbd.mode_info_context->mbmi, sizeof(MB_MODE_INFO));
vpx_memcpy(&best_partition, x->partition_info, sizeof(PARTITION_INFO));
- if ((this_mode == B_PRED) || (this_mode == SPLITMV))
+ if ((this_mode == B_PRED)
+#if CONFIG_I8X8
+ ||(this_mode == I8X8_PRED)
+#endif
+ || (this_mode == SPLITMV))
for (i = 0; i < 16; i++)
{
best_bmodes[i] = x->e_mbd.block[i].bmi;
if (best_mbmode.mode == B_PRED)
{
for (i = 0; i < 16; i++)
+ {
xd->mode_info_context->bmi[i].as_mode = best_bmodes[i].as_mode;
+ xd->block[i].bmi.as_mode = xd->mode_info_context->bmi[i].as_mode;
+ }
+ }
+
+#if CONFIG_I8X8
+ if (best_mbmode.mode == I8X8_PRED)
+ {
+ set_i8x8_block_modes(x, mode8x8);
}
+#endif
if (best_mbmode.mode == SPLITMV)
{
}
-#if CONFIG_I8X8
-static void set_i8x8_block_modes(MACROBLOCK *x, int *modes)
-{
- int i;
- MACROBLOCKD *xd = &x->e_mbd;
- for(i=0;i<4;i++)
- {
- int ib = vp8_i8x8_block[i];
- x->e_mbd.mode_info_context->bmi[ib+0].as_mode= modes[i];
- x->e_mbd.mode_info_context->bmi[ib+1].as_mode= modes[i];
- x->e_mbd.mode_info_context->bmi[ib+4].as_mode= modes[i];
- x->e_mbd.mode_info_context->bmi[ib+5].as_mode= modes[i];
- }
-
- for (i = 0; i < 16; i++)
- {
- xd->block[i].bmi = xd->mode_info_context->bmi[i];
- }
-}
-#endif
-
void vp8_rd_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate_)
{
MACROBLOCKD *xd = &x->e_mbd;
void vp8_fix_contexts(MACROBLOCKD *x)
{
/* Clear entropy contexts for Y2 blocks */
- if (x->mode_info_context->mbmi.mode != B_PRED && x->mode_info_context->mbmi.mode != SPLITMV)
+ if (x->mode_info_context->mbmi.mode != B_PRED
+#if CONFIG_I8X8
+ && x->mode_info_context->mbmi.mode != I8X8_PRED
+#endif
+ && x->mode_info_context->mbmi.mode != SPLITMV)
{
vpx_memset(x->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES));
vpx_memset(x->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES));