changed find_near_mvs search to include a mb from last frame
This is an experiment to include a mv contribution from last frame to nearest and near mv definition. Initial test showed some small though consistent gain. latest patch slightly better result ~.13%-~.18%. TODO: the entropy used to encode the mode choice, i.e. the mv counts based conditional distribution of modes should be re-collected to reflect this change, it is expected that there is some further gain from that. Change-Id: Ief1e284a36d8aa56b49ae5b360c91419ec494fa4
This commit is contained in:
@@ -116,7 +116,7 @@ int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height)
|
|||||||
oci->mi = oci->mip + oci->mode_info_stride + 1;
|
oci->mi = oci->mip + oci->mode_info_stride + 1;
|
||||||
|
|
||||||
/* allocate memory for last frame MODE_INFO array */
|
/* allocate memory for last frame MODE_INFO array */
|
||||||
#if CONFIG_ERROR_CONCEALMENT
|
#if CONFIG_ERROR_CONCEALMENT || CONFIG_NEWNEAR
|
||||||
oci->prev_mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MODE_INFO));
|
oci->prev_mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MODE_INFO));
|
||||||
|
|
||||||
if (!oci->prev_mip)
|
if (!oci->prev_mip)
|
||||||
|
|||||||
@@ -235,6 +235,9 @@ typedef struct MacroBlockD
|
|||||||
YV12_BUFFER_CONFIG pre; /* Filtered copy of previous frame reconstruction */
|
YV12_BUFFER_CONFIG pre; /* Filtered copy of previous frame reconstruction */
|
||||||
YV12_BUFFER_CONFIG dst;
|
YV12_BUFFER_CONFIG dst;
|
||||||
|
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
MODE_INFO *prev_mode_info_context;
|
||||||
|
#endif
|
||||||
MODE_INFO *mode_info_context;
|
MODE_INFO *mode_info_context;
|
||||||
int mode_info_stride;
|
int mode_info_stride;
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,141 @@ const unsigned char vp8_mbsplit_offset[4][16] = {
|
|||||||
/* Predict motion vectors using those from already-decoded nearby blocks.
|
/* Predict motion vectors using those from already-decoded nearby blocks.
|
||||||
Note that we only consider one 4x4 subblock from each candidate 16x16
|
Note that we only consider one 4x4 subblock from each candidate 16x16
|
||||||
macroblock. */
|
macroblock. */
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
void vp8_find_near_mvs
|
||||||
|
(
|
||||||
|
MACROBLOCKD *xd,
|
||||||
|
const MODE_INFO *here,
|
||||||
|
const MODE_INFO *lf_here,
|
||||||
|
int_mv *nearest,
|
||||||
|
int_mv *nearby,
|
||||||
|
int_mv *best_mv,
|
||||||
|
int cnt[4],
|
||||||
|
int refframe,
|
||||||
|
int *ref_frame_sign_bias
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const MODE_INFO *above = here - xd->mode_info_stride;
|
||||||
|
const MODE_INFO *left = here - 1;
|
||||||
|
const MODE_INFO *aboveleft = above - 1;
|
||||||
|
const MODE_INFO *third = NULL;
|
||||||
|
int_mv near_mvs[4];
|
||||||
|
int_mv *mv = near_mvs;
|
||||||
|
int *cntx = cnt;
|
||||||
|
enum {CNT_INTRA, CNT_NEAREST, CNT_NEAR, CNT_SPLITMV};
|
||||||
|
|
||||||
|
/* Zero accumulators */
|
||||||
|
mv[0].as_int = mv[1].as_int = mv[2].as_int = 0;
|
||||||
|
cnt[0] = cnt[1] = cnt[2] = cnt[3] = 0;
|
||||||
|
|
||||||
|
/* Process above */
|
||||||
|
if (above->mbmi.ref_frame != INTRA_FRAME)
|
||||||
|
{
|
||||||
|
if (above->mbmi.mv.as_int)
|
||||||
|
{
|
||||||
|
(++mv)->as_int = above->mbmi.mv.as_int;
|
||||||
|
mv_bias(ref_frame_sign_bias[above->mbmi.ref_frame],
|
||||||
|
refframe, mv, ref_frame_sign_bias);
|
||||||
|
++cntx;
|
||||||
|
}
|
||||||
|
*cntx += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Process left */
|
||||||
|
if (left->mbmi.ref_frame != INTRA_FRAME)
|
||||||
|
{
|
||||||
|
if (left->mbmi.mv.as_int)
|
||||||
|
{
|
||||||
|
int_mv this_mv;
|
||||||
|
this_mv.as_int = left->mbmi.mv.as_int;
|
||||||
|
mv_bias(ref_frame_sign_bias[left->mbmi.ref_frame],
|
||||||
|
refframe, &this_mv, ref_frame_sign_bias);
|
||||||
|
|
||||||
|
if (this_mv.as_int != mv->as_int)
|
||||||
|
{
|
||||||
|
(++mv)->as_int = this_mv.as_int;
|
||||||
|
++cntx;
|
||||||
|
}
|
||||||
|
*cntx += 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cnt[CNT_INTRA] += 2;
|
||||||
|
}
|
||||||
|
/* Process above left or the one frome last frame */
|
||||||
|
if ( aboveleft->mbmi.ref_frame != INTRA_FRAME||
|
||||||
|
(lf_here->mbmi.ref_frame==LAST_FRAME && refframe == LAST_FRAME))
|
||||||
|
{
|
||||||
|
if (aboveleft->mbmi.mv.as_int)
|
||||||
|
{
|
||||||
|
third = aboveleft;
|
||||||
|
}
|
||||||
|
else if(lf_here->mbmi.mv.as_int)
|
||||||
|
{
|
||||||
|
third = lf_here;
|
||||||
|
}
|
||||||
|
if(third)
|
||||||
|
{
|
||||||
|
int_mv this_mv;
|
||||||
|
this_mv.as_int = third->mbmi.mv.as_int;
|
||||||
|
mv_bias(ref_frame_sign_bias[third->mbmi.ref_frame],
|
||||||
|
refframe, &this_mv, ref_frame_sign_bias);
|
||||||
|
|
||||||
|
if (this_mv.as_int != mv->as_int)
|
||||||
|
{
|
||||||
|
(++mv)->as_int = this_mv.as_int;
|
||||||
|
++cntx;
|
||||||
|
}
|
||||||
|
*cntx += 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cnt[CNT_INTRA] += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we have three distinct MV's ... */
|
||||||
|
if (cnt[CNT_SPLITMV])
|
||||||
|
{
|
||||||
|
/* See if the third MV can be merged with NEAREST */
|
||||||
|
if (mv->as_int == near_mvs[CNT_NEAREST].as_int)
|
||||||
|
cnt[CNT_NEAREST] += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
cnt[CNT_SPLITMV] = ((above->mbmi.mode == SPLITMV)
|
||||||
|
+ (left->mbmi.mode == SPLITMV)) * 2
|
||||||
|
+ (
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
lf_here->mbmi.mode == SPLITMV ||
|
||||||
|
#endif
|
||||||
|
aboveleft->mbmi.mode == SPLITMV);
|
||||||
|
|
||||||
|
/* Swap near and nearest if necessary */
|
||||||
|
if (cnt[CNT_NEAR] > cnt[CNT_NEAREST])
|
||||||
|
{
|
||||||
|
int tmp;
|
||||||
|
tmp = cnt[CNT_NEAREST];
|
||||||
|
cnt[CNT_NEAREST] = cnt[CNT_NEAR];
|
||||||
|
cnt[CNT_NEAR] = tmp;
|
||||||
|
tmp = near_mvs[CNT_NEAREST].as_int;
|
||||||
|
near_mvs[CNT_NEAREST].as_int = near_mvs[CNT_NEAR].as_int;
|
||||||
|
near_mvs[CNT_NEAR].as_int = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Use near_mvs[0] to store the "best" MV */
|
||||||
|
if (cnt[CNT_NEAREST] >= cnt[CNT_INTRA])
|
||||||
|
near_mvs[CNT_INTRA] = near_mvs[CNT_NEAREST];
|
||||||
|
|
||||||
|
/* Set up return values */
|
||||||
|
best_mv->as_int = near_mvs[0].as_int;
|
||||||
|
nearest->as_int = near_mvs[CNT_NEAREST].as_int;
|
||||||
|
nearby->as_int = near_mvs[CNT_NEAR].as_int;
|
||||||
|
|
||||||
|
//TODO: move clamp outside findnearmv
|
||||||
|
vp8_clamp_mv2(nearest, xd);
|
||||||
|
vp8_clamp_mv2(nearby, xd);
|
||||||
|
vp8_clamp_mv2(best_mv, xd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
void vp8_find_near_mvs
|
void vp8_find_near_mvs
|
||||||
(
|
(
|
||||||
MACROBLOCKD *xd,
|
MACROBLOCKD *xd,
|
||||||
@@ -55,7 +190,6 @@ void vp8_find_near_mvs
|
|||||||
refframe, mv, ref_frame_sign_bias);
|
refframe, mv, ref_frame_sign_bias);
|
||||||
++cntx;
|
++cntx;
|
||||||
}
|
}
|
||||||
|
|
||||||
*cntx += 2;
|
*cntx += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +215,6 @@ void vp8_find_near_mvs
|
|||||||
else
|
else
|
||||||
cnt[CNT_INTRA] += 2;
|
cnt[CNT_INTRA] += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process above left */
|
/* Process above left */
|
||||||
if (aboveleft->mbmi.ref_frame != INTRA_FRAME)
|
if (aboveleft->mbmi.ref_frame != INTRA_FRAME)
|
||||||
{
|
{
|
||||||
@@ -143,6 +276,7 @@ void vp8_find_near_mvs
|
|||||||
vp8_clamp_mv2(nearby, xd);
|
vp8_clamp_mv2(nearby, xd);
|
||||||
vp8_clamp_mv2(best_mv, xd);
|
vp8_clamp_mv2(best_mv, xd);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
vp8_prob *vp8_mv_ref_probs(
|
vp8_prob *vp8_mv_ref_probs(
|
||||||
vp8_prob p[VP8_MVREFS-1], const int near_mv_ref_ct[4]
|
vp8_prob p[VP8_MVREFS-1], const int near_mv_ref_ct[4]
|
||||||
|
|||||||
@@ -75,6 +75,9 @@ void vp8_find_near_mvs
|
|||||||
(
|
(
|
||||||
MACROBLOCKD *xd,
|
MACROBLOCKD *xd,
|
||||||
const MODE_INFO *here,
|
const MODE_INFO *here,
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
const MODE_INFO *lfhere,
|
||||||
|
#endif
|
||||||
int_mv *nearest, int_mv *nearby, int_mv *best,
|
int_mv *nearest, int_mv *nearby, int_mv *best,
|
||||||
int near_mv_ref_cts[4],
|
int near_mv_ref_cts[4],
|
||||||
int refframe,
|
int refframe,
|
||||||
|
|||||||
@@ -425,6 +425,9 @@ static void mb_mode_mv_init(VP8D_COMP *pbi)
|
|||||||
|
|
||||||
|
|
||||||
static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
|
static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
MODE_INFO *prev_mi,
|
||||||
|
#endif
|
||||||
int mb_row, int mb_col)
|
int mb_row, int mb_col)
|
||||||
{
|
{
|
||||||
vp8_reader *const bc = & pbi->bc;
|
vp8_reader *const bc = & pbi->bc;
|
||||||
@@ -529,7 +532,11 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
|
|||||||
int_mv nearest, nearby, best_mv;
|
int_mv nearest, nearby, best_mv;
|
||||||
vp8_prob mv_ref_p [VP8_MVREFS-1];
|
vp8_prob mv_ref_p [VP8_MVREFS-1];
|
||||||
|
|
||||||
vp8_find_near_mvs(xd, mi, &nearest, &nearby, &best_mv, rct,
|
vp8_find_near_mvs(xd, mi,
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
prev_mi,
|
||||||
|
#endif
|
||||||
|
&nearest, &nearby, &best_mv, rct,
|
||||||
mbmi->ref_frame, pbi->common.ref_frame_sign_bias);
|
mbmi->ref_frame, pbi->common.ref_frame_sign_bias);
|
||||||
vp8_mv_ref_probs(mv_ref_p, rct);
|
vp8_mv_ref_probs(mv_ref_p, rct);
|
||||||
|
|
||||||
@@ -725,6 +732,11 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
|
|||||||
void vp8_decode_mode_mvs(VP8D_COMP *pbi)
|
void vp8_decode_mode_mvs(VP8D_COMP *pbi)
|
||||||
{
|
{
|
||||||
MODE_INFO *mi = pbi->common.mi;
|
MODE_INFO *mi = pbi->common.mi;
|
||||||
|
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
MODE_INFO *prev_mi = pbi->common.prev_mi;
|
||||||
|
#endif
|
||||||
|
|
||||||
int mb_row = -1;
|
int mb_row = -1;
|
||||||
|
|
||||||
//#if CONFIG_SEGFEATURES
|
//#if CONFIG_SEGFEATURES
|
||||||
@@ -771,7 +783,11 @@ void vp8_decode_mode_mvs(VP8D_COMP *pbi)
|
|||||||
if(pbi->common.frame_type == KEY_FRAME)
|
if(pbi->common.frame_type == KEY_FRAME)
|
||||||
vp8_kfread_modes(pbi, mi, mb_row, mb_col);
|
vp8_kfread_modes(pbi, mi, mb_row, mb_col);
|
||||||
else
|
else
|
||||||
read_mb_modes_mv(pbi, mi, &mi->mbmi, mb_row, mb_col);
|
read_mb_modes_mv(pbi, mi, &mi->mbmi,
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
prev_mi,
|
||||||
|
#endif
|
||||||
|
mb_row, mb_col);
|
||||||
|
|
||||||
//printf("%3d", mi->mbmi.mode);
|
//printf("%3d", mi->mbmi.mode);
|
||||||
|
|
||||||
@@ -807,11 +823,15 @@ void vp8_decode_mode_mvs(VP8D_COMP *pbi)
|
|||||||
fprintf(statsfile, "%2d%2d%2d ",
|
fprintf(statsfile, "%2d%2d%2d ",
|
||||||
mi->mbmi.segment_id, mi->mbmi.ref_frame, mi->mbmi.mode );
|
mi->mbmi.segment_id, mi->mbmi.ref_frame, mi->mbmi.mode );
|
||||||
#endif
|
#endif
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
prev_mi++;
|
||||||
|
#endif
|
||||||
mi++; /* next macroblock */
|
mi++; /* next macroblock */
|
||||||
}
|
}
|
||||||
// printf("\n");
|
// printf("\n");
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
prev_mi++;
|
||||||
|
#endif
|
||||||
mi++; /* skip left predictor each row */
|
mi++; /* skip left predictor each row */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,41 @@ void vp8_recon_write_yuv_frame(char *name, YV12_BUFFER_CONFIG *s)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if WRITE_RECON_BUFFER
|
||||||
|
void write_dx_frame_to_file(YV12_BUFFER_CONFIG *frame, int this_frame)
|
||||||
|
{
|
||||||
|
|
||||||
|
// write the frame
|
||||||
|
FILE *yframe;
|
||||||
|
int i;
|
||||||
|
char filename[255];
|
||||||
|
|
||||||
|
sprintf(filename, "dx\\y%04d.raw", this_frame);
|
||||||
|
yframe = fopen(filename, "wb");
|
||||||
|
|
||||||
|
for (i = 0; i < frame->y_height; i++)
|
||||||
|
fwrite(frame->y_buffer + i * frame->y_stride, frame->y_width, 1, yframe);
|
||||||
|
|
||||||
|
fclose(yframe);
|
||||||
|
sprintf(filename, "dx\\u%04d.raw", this_frame);
|
||||||
|
yframe = fopen(filename, "wb");
|
||||||
|
|
||||||
|
for (i = 0; i < frame->uv_height; i++)
|
||||||
|
fwrite(frame->u_buffer + i * frame->uv_stride, frame->uv_width, 1, yframe);
|
||||||
|
|
||||||
|
fclose(yframe);
|
||||||
|
sprintf(filename, "dx\\v%04d.raw", this_frame);
|
||||||
|
yframe = fopen(filename, "wb");
|
||||||
|
|
||||||
|
for (i = 0; i < frame->uv_height; i++)
|
||||||
|
fwrite(frame->v_buffer + i * frame->uv_stride, frame->uv_width, 1, yframe);
|
||||||
|
|
||||||
|
fclose(yframe);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void vp8dx_initialize()
|
void vp8dx_initialize()
|
||||||
{
|
{
|
||||||
static int init_done = 0;
|
static int init_done = 0;
|
||||||
@@ -540,6 +575,11 @@ int vp8dx_receive_compressed_data(VP8D_PTR ptr, unsigned long size, const unsign
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if WRITE_RECON_BUFFER
|
||||||
|
if(cm->show_frame)
|
||||||
|
write_dx_frame_to_file(cm->frame_to_show, cm->current_video_frame);
|
||||||
|
#endif
|
||||||
|
|
||||||
if(cm->filter_level)
|
if(cm->filter_level)
|
||||||
{
|
{
|
||||||
/* Apply the loop filter if appropriate. */
|
/* Apply the loop filter if appropriate. */
|
||||||
@@ -576,6 +616,19 @@ int vp8dx_receive_compressed_data(VP8D_PTR ptr, unsigned long size, const unsign
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
if(cm->show_frame)
|
||||||
|
{
|
||||||
|
vpx_memcpy(cm->prev_mip, cm->mip,
|
||||||
|
(cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vpx_memset(cm->prev_mip, 0,
|
||||||
|
(cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*vp8_print_modes_and_motion_vectors( cm->mi, cm->mb_rows,cm->mb_cols, cm->current_video_frame);*/
|
/*vp8_print_modes_and_motion_vectors( cm->mi, cm->mb_rows,cm->mb_cols, cm->current_video_frame);*/
|
||||||
|
|
||||||
if (cm->show_frame)
|
if (cm->show_frame)
|
||||||
|
|||||||
@@ -948,14 +948,17 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
|
|||||||
const int rf_intra = rfct[INTRA_FRAME];
|
const int rf_intra = rfct[INTRA_FRAME];
|
||||||
const int rf_inter = rfct[LAST_FRAME] + rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME];
|
const int rf_inter = rfct[LAST_FRAME] + rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME];
|
||||||
|
|
||||||
MODE_INFO *m = pc->mi, *ms;
|
MODE_INFO *m = pc->mi;
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
MODE_INFO *prev_m = pc->prev_mi;
|
||||||
|
#endif
|
||||||
|
|
||||||
const int mis = pc->mode_info_stride;
|
const int mis = pc->mode_info_stride;
|
||||||
int mb_row = -1;
|
int mb_row = -1;
|
||||||
|
|
||||||
int prob_last_coded;
|
int prob_last_coded;
|
||||||
int prob_gf_coded;
|
int prob_gf_coded;
|
||||||
int prob_skip_false = 0;
|
int prob_skip_false = 0;
|
||||||
ms = pc->mi - 1;
|
|
||||||
|
|
||||||
cpi->mb.partition_info = cpi->mb.pi;
|
cpi->mb.partition_info = cpi->mb.pi;
|
||||||
|
|
||||||
@@ -1033,6 +1036,9 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
|
|||||||
|
|
||||||
// Make sure the MacroBlockD mode info pointer is set correctly
|
// Make sure the MacroBlockD mode info pointer is set correctly
|
||||||
xd->mode_info_context = m;
|
xd->mode_info_context = m;
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
xd->prev_mode_info_context = prev_m;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ENTROPY_STATS
|
#ifdef ENTROPY_STATS
|
||||||
active_section = 9;
|
active_section = 9;
|
||||||
@@ -1110,7 +1116,11 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
|
|||||||
int_mv n1, n2;
|
int_mv n1, n2;
|
||||||
int ct[4];
|
int ct[4];
|
||||||
|
|
||||||
vp8_find_near_mvs(xd, m, &n1, &n2, &best_mv, ct, rf, cpi->common.ref_frame_sign_bias);
|
vp8_find_near_mvs(xd, m,
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
prev_m,
|
||||||
|
#endif
|
||||||
|
&n1, &n2, &best_mv, ct, rf, cpi->common.ref_frame_sign_bias);
|
||||||
vp8_mv_ref_probs(mv_ref_p, ct);
|
vp8_mv_ref_probs(mv_ref_p, ct);
|
||||||
|
|
||||||
#ifdef ENTROPY_STATS
|
#ifdef ENTROPY_STATS
|
||||||
@@ -1193,10 +1203,19 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
|
|||||||
}
|
}
|
||||||
|
|
||||||
++m;
|
++m;
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
++prev_m;
|
||||||
|
assert((prev_m-cpi->common.prev_mip)==(m-cpi->common.mip));
|
||||||
|
assert((prev_m-cpi->common.prev_mi)==(m-cpi->common.mi));
|
||||||
|
#endif
|
||||||
|
|
||||||
cpi->mb.partition_info++;
|
cpi->mb.partition_info++;
|
||||||
}
|
}
|
||||||
|
|
||||||
++m; /* skip L prediction border */
|
++m; /* skip L prediction border */
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
++prev_m;
|
||||||
|
#endif
|
||||||
cpi->mb.partition_info++;
|
cpi->mb.partition_info++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -767,6 +767,12 @@ void encode_mb_row(VP8_COMP *cpi,
|
|||||||
|
|
||||||
// skip to next mb
|
// skip to next mb
|
||||||
xd->mode_info_context++;
|
xd->mode_info_context++;
|
||||||
|
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
xd->prev_mode_info_context++;
|
||||||
|
assert((xd->prev_mode_info_context - cpi->common.prev_mip)
|
||||||
|
==(xd->mode_info_context - cpi->common.mip));
|
||||||
|
#endif
|
||||||
x->partition_info++;
|
x->partition_info++;
|
||||||
|
|
||||||
xd->above_context++;
|
xd->above_context++;
|
||||||
@@ -786,6 +792,9 @@ void encode_mb_row(VP8_COMP *cpi,
|
|||||||
xd->dst.v_buffer + 8);
|
xd->dst.v_buffer + 8);
|
||||||
|
|
||||||
// this is to account for the border
|
// this is to account for the border
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
xd->prev_mode_info_context++;
|
||||||
|
#endif
|
||||||
xd->mode_info_context++;
|
xd->mode_info_context++;
|
||||||
x->partition_info++;
|
x->partition_info++;
|
||||||
|
|
||||||
@@ -829,6 +838,10 @@ void init_encode_frame_mb_context(VP8_COMP *cpi)
|
|||||||
|
|
||||||
xd->mode_info_context = cm->mi;
|
xd->mode_info_context = cm->mi;
|
||||||
xd->mode_info_stride = cm->mode_info_stride;
|
xd->mode_info_stride = cm->mode_info_stride;
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
xd->prev_mode_info_context = cm->prev_mi;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
xd->frame_type = cm->frame_type;
|
xd->frame_type = cm->frame_type;
|
||||||
|
|
||||||
@@ -970,6 +983,11 @@ void vp8_encode_frame(VP8_COMP *cpi)
|
|||||||
|
|
||||||
xd->mode_info_context = cm->mi;
|
xd->mode_info_context = cm->mi;
|
||||||
|
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
xd->prev_mode_info_context = cm->prev_mi;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
vp8_zero(cpi->MVcount);
|
vp8_zero(cpi->MVcount);
|
||||||
vp8_zero(cpi->coef_counts);
|
vp8_zero(cpi->coef_counts);
|
||||||
|
|
||||||
@@ -1022,7 +1040,13 @@ void vp8_encode_frame(VP8_COMP *cpi)
|
|||||||
x->src.u_buffer += 8 * x->src.uv_stride * (cpi->encoding_thread_count + 1) - 8 * cm->mb_cols;
|
x->src.u_buffer += 8 * x->src.uv_stride * (cpi->encoding_thread_count + 1) - 8 * cm->mb_cols;
|
||||||
x->src.v_buffer += 8 * x->src.uv_stride * (cpi->encoding_thread_count + 1) - 8 * cm->mb_cols;
|
x->src.v_buffer += 8 * x->src.uv_stride * (cpi->encoding_thread_count + 1) - 8 * cm->mb_cols;
|
||||||
|
|
||||||
xd->mode_info_context += xd->mode_info_stride * cpi->encoding_thread_count;
|
xd->mode_info_context += xd->mode_info_stride
|
||||||
|
* cpi->encoding_thread_count;
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
xd->prev_mode_info_context += xd->mode_info_stride
|
||||||
|
* cpi->encoding_thread_count;
|
||||||
|
#endif
|
||||||
|
|
||||||
x->partition_info += xd->mode_info_stride * cpi->encoding_thread_count;
|
x->partition_info += xd->mode_info_stride * cpi->encoding_thread_count;
|
||||||
x->gf_active_ptr += cm->mb_cols * cpi->encoding_thread_count;
|
x->gf_active_ptr += cm->mb_cols * cpi->encoding_thread_count;
|
||||||
|
|
||||||
|
|||||||
@@ -248,6 +248,9 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data)
|
|||||||
recon_uvoffset += 8;
|
recon_uvoffset += 8;
|
||||||
|
|
||||||
// skip to next mb
|
// skip to next mb
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
xd->prev_mode_info_context++;
|
||||||
|
#endif
|
||||||
xd->mode_info_context++;
|
xd->mode_info_context++;
|
||||||
x->partition_info++;
|
x->partition_info++;
|
||||||
xd->above_context++;
|
xd->above_context++;
|
||||||
@@ -263,6 +266,10 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data)
|
|||||||
xd->dst.v_buffer + 8);
|
xd->dst.v_buffer + 8);
|
||||||
|
|
||||||
// this is to account for the border
|
// this is to account for the border
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
xd->prev_mode_info_context++;
|
||||||
|
#endif
|
||||||
|
|
||||||
xd->mode_info_context++;
|
xd->mode_info_context++;
|
||||||
x->partition_info++;
|
x->partition_info++;
|
||||||
|
|
||||||
@@ -270,7 +277,13 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data)
|
|||||||
x->src.u_buffer += 8 * x->src.uv_stride * (cpi->encoding_thread_count + 1) - 8 * cm->mb_cols;
|
x->src.u_buffer += 8 * x->src.uv_stride * (cpi->encoding_thread_count + 1) - 8 * cm->mb_cols;
|
||||||
x->src.v_buffer += 8 * x->src.uv_stride * (cpi->encoding_thread_count + 1) - 8 * cm->mb_cols;
|
x->src.v_buffer += 8 * x->src.uv_stride * (cpi->encoding_thread_count + 1) - 8 * cm->mb_cols;
|
||||||
|
|
||||||
xd->mode_info_context += xd->mode_info_stride * cpi->encoding_thread_count;
|
xd->mode_info_context += xd->mode_info_stride
|
||||||
|
* cpi->encoding_thread_count;
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
xd->prev_mode_info_context += xd->mode_info_stride
|
||||||
|
* cpi->encoding_thread_count;
|
||||||
|
#endif
|
||||||
|
|
||||||
x->partition_info += xd->mode_info_stride * cpi->encoding_thread_count;
|
x->partition_info += xd->mode_info_stride * cpi->encoding_thread_count;
|
||||||
x->gf_active_ptr += cm->mb_cols * cpi->encoding_thread_count;
|
x->gf_active_ptr += cm->mb_cols * cpi->encoding_thread_count;
|
||||||
|
|
||||||
@@ -437,7 +450,12 @@ void vp8cx_init_mbrthread_data(VP8_COMP *cpi,
|
|||||||
|
|
||||||
mb->partition_info = x->pi + x->e_mbd.mode_info_stride * (i + 1);
|
mb->partition_info = x->pi + x->e_mbd.mode_info_stride * (i + 1);
|
||||||
|
|
||||||
mbd->mode_info_context = cm->mi + x->e_mbd.mode_info_stride * (i + 1);
|
mbd->mode_info_context = cm->mi
|
||||||
|
+ x->e_mbd.mode_info_stride * (i + 1);
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
mbd->prev_mode_info_context = cm->prev_mi
|
||||||
|
+ x->e_mbd.mode_info_stride * (i + 1);
|
||||||
|
#endif
|
||||||
mbd->mode_info_stride = cm->mode_info_stride;
|
mbd->mode_info_stride = cm->mode_info_stride;
|
||||||
|
|
||||||
mbd->frame_type = cm->frame_type;
|
mbd->frame_type = cm->frame_type;
|
||||||
|
|||||||
@@ -3292,7 +3292,7 @@ static void Pass1Encode(VP8_COMP *cpi, unsigned long *size, unsigned char *dest,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if WRITE_RECON_BUFFER
|
||||||
void write_cx_frame_to_file(YV12_BUFFER_CONFIG *frame, int this_frame)
|
void write_cx_frame_to_file(YV12_BUFFER_CONFIG *frame, int this_frame)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -4437,6 +4437,11 @@ static void encode_frame_to_data_rate
|
|||||||
|
|
||||||
cm->frame_to_show = &cm->yv12_fb[cm->new_fb_idx];
|
cm->frame_to_show = &cm->yv12_fb[cm->new_fb_idx];
|
||||||
|
|
||||||
|
#if WRITE_RECON_BUFFER
|
||||||
|
if(cm->show_frame)
|
||||||
|
write_cx_frame_to_file(cm->frame_to_show, cm->current_video_frame);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CONFIG_MULTITHREAD
|
#if CONFIG_MULTITHREAD
|
||||||
if (cpi->b_multi_threaded)
|
if (cpi->b_multi_threaded)
|
||||||
{
|
{
|
||||||
@@ -4812,6 +4817,20 @@ static void encode_frame_to_data_rate
|
|||||||
vp8_write_yuv_rec_frame(cm);
|
vp8_write_yuv_rec_frame(cm);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
if(cm->show_frame)
|
||||||
|
{
|
||||||
|
vpx_memcpy(cm->prev_mip, cm->mip,
|
||||||
|
(cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vpx_memset(cm->prev_mip, 0,
|
||||||
|
(cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -460,7 +460,11 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
|
|||||||
{
|
{
|
||||||
YV12_BUFFER_CONFIG *lst_yv12 = &cpi->common.yv12_fb[cpi->common.lst_fb_idx];
|
YV12_BUFFER_CONFIG *lst_yv12 = &cpi->common.yv12_fb[cpi->common.lst_fb_idx];
|
||||||
|
|
||||||
vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context, &nearest_mv[LAST_FRAME], &near_mv[LAST_FRAME],
|
vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context,
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
x->e_mbd.prev_mode_info_context,
|
||||||
|
#endif
|
||||||
|
&nearest_mv[LAST_FRAME], &near_mv[LAST_FRAME],
|
||||||
&frame_best_ref_mv[LAST_FRAME], MDCounts[LAST_FRAME], LAST_FRAME, cpi->common.ref_frame_sign_bias);
|
&frame_best_ref_mv[LAST_FRAME], MDCounts[LAST_FRAME], LAST_FRAME, cpi->common.ref_frame_sign_bias);
|
||||||
|
|
||||||
y_buffer[LAST_FRAME] = lst_yv12->y_buffer + recon_yoffset;
|
y_buffer[LAST_FRAME] = lst_yv12->y_buffer + recon_yoffset;
|
||||||
@@ -474,7 +478,12 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
|
|||||||
{
|
{
|
||||||
YV12_BUFFER_CONFIG *gld_yv12 = &cpi->common.yv12_fb[cpi->common.gld_fb_idx];
|
YV12_BUFFER_CONFIG *gld_yv12 = &cpi->common.yv12_fb[cpi->common.gld_fb_idx];
|
||||||
|
|
||||||
vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context, &nearest_mv[GOLDEN_FRAME], &near_mv[GOLDEN_FRAME],
|
vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context,
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
x->e_mbd.prev_mode_info_context,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
&nearest_mv[GOLDEN_FRAME], &near_mv[GOLDEN_FRAME],
|
||||||
&frame_best_ref_mv[GOLDEN_FRAME], MDCounts[GOLDEN_FRAME], GOLDEN_FRAME, cpi->common.ref_frame_sign_bias);
|
&frame_best_ref_mv[GOLDEN_FRAME], MDCounts[GOLDEN_FRAME], GOLDEN_FRAME, cpi->common.ref_frame_sign_bias);
|
||||||
|
|
||||||
y_buffer[GOLDEN_FRAME] = gld_yv12->y_buffer + recon_yoffset;
|
y_buffer[GOLDEN_FRAME] = gld_yv12->y_buffer + recon_yoffset;
|
||||||
@@ -488,7 +497,11 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
|
|||||||
{
|
{
|
||||||
YV12_BUFFER_CONFIG *alt_yv12 = &cpi->common.yv12_fb[cpi->common.alt_fb_idx];
|
YV12_BUFFER_CONFIG *alt_yv12 = &cpi->common.yv12_fb[cpi->common.alt_fb_idx];
|
||||||
|
|
||||||
vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context, &nearest_mv[ALTREF_FRAME], &near_mv[ALTREF_FRAME],
|
vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context,
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
x->e_mbd.prev_mode_info_context,
|
||||||
|
#endif
|
||||||
|
&nearest_mv[ALTREF_FRAME], &near_mv[ALTREF_FRAME],
|
||||||
&frame_best_ref_mv[ALTREF_FRAME], MDCounts[ALTREF_FRAME], ALTREF_FRAME, cpi->common.ref_frame_sign_bias);
|
&frame_best_ref_mv[ALTREF_FRAME], MDCounts[ALTREF_FRAME], ALTREF_FRAME, cpi->common.ref_frame_sign_bias);
|
||||||
|
|
||||||
y_buffer[ALTREF_FRAME] = alt_yv12->y_buffer + recon_yoffset;
|
y_buffer[ALTREF_FRAME] = alt_yv12->y_buffer + recon_yoffset;
|
||||||
|
|||||||
@@ -2003,7 +2003,11 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
|
|||||||
{
|
{
|
||||||
YV12_BUFFER_CONFIG *lst_yv12 = &cpi->common.yv12_fb[cpi->common.lst_fb_idx];
|
YV12_BUFFER_CONFIG *lst_yv12 = &cpi->common.yv12_fb[cpi->common.lst_fb_idx];
|
||||||
|
|
||||||
vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context, &frame_nearest_mv[LAST_FRAME], &frame_near_mv[LAST_FRAME],
|
vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context,
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
x->e_mbd.prev_mode_info_context,
|
||||||
|
#endif
|
||||||
|
&frame_nearest_mv[LAST_FRAME], &frame_near_mv[LAST_FRAME],
|
||||||
&frame_best_ref_mv[LAST_FRAME], frame_mdcounts[LAST_FRAME], LAST_FRAME, cpi->common.ref_frame_sign_bias);
|
&frame_best_ref_mv[LAST_FRAME], frame_mdcounts[LAST_FRAME], LAST_FRAME, cpi->common.ref_frame_sign_bias);
|
||||||
|
|
||||||
y_buffer[LAST_FRAME] = lst_yv12->y_buffer + recon_yoffset;
|
y_buffer[LAST_FRAME] = lst_yv12->y_buffer + recon_yoffset;
|
||||||
@@ -2015,7 +2019,11 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
|
|||||||
{
|
{
|
||||||
YV12_BUFFER_CONFIG *gld_yv12 = &cpi->common.yv12_fb[cpi->common.gld_fb_idx];
|
YV12_BUFFER_CONFIG *gld_yv12 = &cpi->common.yv12_fb[cpi->common.gld_fb_idx];
|
||||||
|
|
||||||
vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context, &frame_nearest_mv[GOLDEN_FRAME], &frame_near_mv[GOLDEN_FRAME],
|
vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context,
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
x->e_mbd.prev_mode_info_context,
|
||||||
|
#endif
|
||||||
|
&frame_nearest_mv[GOLDEN_FRAME], &frame_near_mv[GOLDEN_FRAME],
|
||||||
&frame_best_ref_mv[GOLDEN_FRAME], frame_mdcounts[GOLDEN_FRAME], GOLDEN_FRAME, cpi->common.ref_frame_sign_bias);
|
&frame_best_ref_mv[GOLDEN_FRAME], frame_mdcounts[GOLDEN_FRAME], GOLDEN_FRAME, cpi->common.ref_frame_sign_bias);
|
||||||
|
|
||||||
y_buffer[GOLDEN_FRAME] = gld_yv12->y_buffer + recon_yoffset;
|
y_buffer[GOLDEN_FRAME] = gld_yv12->y_buffer + recon_yoffset;
|
||||||
@@ -2027,7 +2035,11 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
|
|||||||
{
|
{
|
||||||
YV12_BUFFER_CONFIG *alt_yv12 = &cpi->common.yv12_fb[cpi->common.alt_fb_idx];
|
YV12_BUFFER_CONFIG *alt_yv12 = &cpi->common.yv12_fb[cpi->common.alt_fb_idx];
|
||||||
|
|
||||||
vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context, &frame_nearest_mv[ALTREF_FRAME], &frame_near_mv[ALTREF_FRAME],
|
vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context,
|
||||||
|
#if CONFIG_NEWNEAR
|
||||||
|
x->e_mbd.prev_mode_info_context,
|
||||||
|
#endif
|
||||||
|
&frame_nearest_mv[ALTREF_FRAME], &frame_near_mv[ALTREF_FRAME],
|
||||||
&frame_best_ref_mv[ALTREF_FRAME], frame_mdcounts[ALTREF_FRAME], ALTREF_FRAME, cpi->common.ref_frame_sign_bias);
|
&frame_best_ref_mv[ALTREF_FRAME], frame_mdcounts[ALTREF_FRAME], ALTREF_FRAME, cpi->common.ref_frame_sign_bias);
|
||||||
|
|
||||||
y_buffer[ALTREF_FRAME] = alt_yv12->y_buffer + recon_yoffset;
|
y_buffer[ALTREF_FRAME] = alt_yv12->y_buffer + recon_yoffset;
|
||||||
|
|||||||
Reference in New Issue
Block a user