int as_int;
MV as_mv;
} mv;
- int partitioning;
- int partition_count;
- int mb_skip_coeff; //does this mb has coefficients at all, 1=no coefficients, 0=need decode tokens
- int dc_diff;
- unsigned char segment_id; // Which set of segmentation parameters should be used for this MB
- int force_no_skip;
- int need_to_clamp_mvs;
- B_MODE_INFO partition_bmi[16];
+
+ char partitioning;
+ unsigned char mb_skip_coeff; //does this mb has coefficients at all, 1=no coefficients, 0=need decode tokens
+ unsigned char dc_diff;
+ unsigned char need_to_clamp_mvs;
+
+ unsigned char segment_id; // Which set of segmentation parameters should be used for this MB
+
+ unsigned char force_no_skip; //encoder only
} MB_MODE_INFO;
YV12_BUFFER_CONFIG dst;
MODE_INFO *mode_info_context;
- MODE_INFO *mode_info;
-
int mode_info_stride;
FRAME_TYPE frame_type;
do /* for each subset j */
{
- B_MODE_INFO *const bmi = mbmi->partition_bmi + j;
- MV *const mv = & bmi->mv.as_mv;
+ B_MODE_INFO bmi;
+ MV *const mv = & bmi.mv.as_mv;
int k = -1; /* first block in subset j */
int mv_contz;
mv_contz = vp8_mv_cont(&(vp8_left_bmi(mi, k)->mv.as_mv), &(vp8_above_bmi(mi, k, mis)->mv.as_mv));
- switch (bmi->mode = (B_PREDICTION_MODE) sub_mv_ref(bc, vp8_sub_mv_ref_prob2 [mv_contz])) //pc->fc.sub_mv_ref_prob))
+ switch (bmi.mode = (B_PREDICTION_MODE) sub_mv_ref(bc, vp8_sub_mv_ref_prob2 [mv_contz])) //pc->fc.sub_mv_ref_prob))
{
case NEW4X4:
read_mv(bc, mv, (const MV_CONTEXT *) mvc);
refer back to us via "left" or "above". */
do
if (j == L[k])
- mi->bmi[k] = *bmi;
+ mi->bmi[k] = bmi;
while (++k < 16);
}
mbd->subpixel_predict8x8 = xd->subpixel_predict8x8;
mbd->subpixel_predict16x16 = xd->subpixel_predict16x16;
- mbd->mode_info = pc->mi - 1;
mbd->mode_info_context = pc->mi + pc->mode_info_stride * (i + 1);
mbd->mode_info_stride = pc->mode_info_stride;
//mbd->subpixel_predict8x8 = xd->subpixel_predict8x8;
//mbd->subpixel_predict16x16 = xd->subpixel_predict16x16;
- mbd->mode_info = pc->mi - 1;
mbd->mode_info_context = pc->mi + pc->mode_info_stride * (i + 1);
mbd->mode_info_stride = pc->mode_info_stride;
int prob_skip_false = 0;
ms = pc->mi - 1;
+ cpi->mb.partition_info = cpi->mb.pi;
+
// Calculate the probabilities to be used to code the reference frame based on actual useage this frame
if (!(cpi->prob_intra_coded = rf_intra * 255 / (rf_intra + rf_inter)))
cpi->prob_intra_coded = 1;
do
{
- const B_MODE_INFO *const b = mi->partition_bmi + j;
+ const B_MODE_INFO *const b = cpi->mb.partition_info->bmi + j;
const int *const L = vp8_mbsplits [mi->partitioning];
int k = -1; /* first block in subset j */
int mv_contz;
write_mv(w, &b->mv.as_mv, &best_mv, (const MV_CONTEXT *) mvc);
}
}
- while (++j < mi->partition_count);
+ while (++j < cpi->mb.partition_info->count);
}
break;
default:
}
++m;
+ cpi->mb.partition_info++;
}
++m; /* skip L prediction border */
+ cpi->mb.partition_info++;
}
}
typedef struct
{
+ int count;
+ B_MODE_INFO bmi[16];
+} PARTITION_INFO;
+
+typedef struct
+{
DECLARE_ALIGNED(16, short, src_diff[400]); // 16x16 Y 8x8 U 8x8 V 4x4 2nd Y
DECLARE_ALIGNED(16, short, coeff[400]); // 16x16 Y 8x8 U 8x8 V 4x4 2nd Y
YV12_BUFFER_CONFIG src;
MACROBLOCKD e_mbd;
+ PARTITION_INFO *partition_info; /* work pointer */
+ PARTITION_INFO *pi; /* Corresponds to upper left visible macroblock */
+ PARTITION_INFO *pip; /* Base of allocated array */
search_site *ss;
int ss_count;
for (b = 0; b < xd->mbmi.partition_count; b++)
{
- inter_b_modes[xd->mbmi.partition_bmi[b].mode] ++;
+ inter_b_modes[x->partition->bmi[b].mode] ++;
}
}
// skip to next mb
xd->mode_info_context++;
+ x->partition_info++;
xd->above_context++;
cpi->current_mb_col_main = mb_col;
// this is to account for the border
xd->mode_info_context++;
+ x->partition_info++;
}
totalrate = 0;
- xd->mode_info = cm->mi - 1;
+ x->partition_info = x->pi;
xd->mode_info_context = cm->mi;
xd->mode_info_stride = cm->mode_info_stride;
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;
+ x->partition_info += xd->mode_info_stride * cpi->encoding_thread_count;
if (mb_row < cm->mb_rows - 1)
//WaitForSingleObject(cpi->h_event_main, INFINITE);
for (b = 0; b < xd->mbmi.partition_count; b++)
{
- inter_b_modes[xd->mbmi.partition_bmi[b].mode] ++;
+ inter_b_modes[x->partition->bmi[b].mode] ++;
}
}
// skip to next mb
xd->mode_info_context++;
+ x->partition_info++;
xd->above_context++;
// this is to account for the border
xd->mode_info_context++;
+ x->partition_info++;
x->src.y_buffer += 16 * x->src.y_stride * (cpi->encoding_thread_count + 1) - 16 * 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;
xd->mode_info_context += xd->mode_info_stride * cpi->encoding_thread_count;
+ x->partition_info += xd->mode_info_stride * cpi->encoding_thread_count;
if (ithread == (cpi->encoding_thread_count - 1) || mb_row == cm->mb_rows - 1)
{
vpx_memset(mbr_ei[i].segment_counts, 0, sizeof(mbr_ei[i].segment_counts));
mbr_ei[i].totalrate = 0;
- mbd->mode_info = cm->mi - 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_stride = cm->mode_info_stride;
xd->pre = *lst_yv12;
xd->dst = *new_yv12;
+ x->partition_info = x->pi;
+
xd->mode_info_context = cm->mi;
vp8_build_block_offsets(x);
#include "swapyv12buffer.h"
#include "threading.h"
#include "vpx_ports/vpx_timer.h"
+#include "vpxerrors.h"
+
#include <math.h>
#include <stdio.h>
#include <limits.h>
cpi->gf_active_flags = 0;
+ if(cpi->mb.pip)
+ vpx_free(cpi->mb.pip);
+
+ cpi->mb.pip = 0;
+
}
static void enable_segmentation(VP8_PTR ptr)
cpi->source_buffer_count = 0;
}
+
+static int vp8_alloc_partition_data(VP8_COMP *cpi)
+{
+ cpi->mb.pip = vpx_calloc((cpi->common.mb_cols + 1) *
+ (cpi->common.mb_rows + 1),
+ sizeof(PARTITION_INFO));
+ if(!cpi->mb.pip)
+ return ALLOC_FAILURE;
+
+ cpi->mb.pi = cpi->mb.pip + cpi->common.mode_info_stride + 1;
+
+ return 0;
+}
+
void vp8_alloc_compressor_data(VP8_COMP *cpi)
{
VP8_COMMON *cm = & cpi->common;
vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
"Failed to allocate frame buffers");
+ if (vp8_alloc_partition_data(cpi))
+ vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
+ "Failed to allocate partition data");
+
+
if ((width & 0xf) != 0)
width += 16 - (width & 0xf);
MACROBLOCKD *xd = &x->e_mbd;
B_MODE_INFO best_bmodes[16];
MB_MODE_INFO best_mbmode;
+ PARTITION_INFO best_partition;
MV best_ref_mv1;
MV mode_mv[MB_MODE_COUNT];
MB_PREDICTION_MODE this_mode;
*returndistortion = distortion2;
best_rd = this_rd;
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)
for (i = 0; i < 16; i++)
best_mbmode.dc_diff = 0;
vpx_memcpy(&x->e_mbd.mode_info_context->mbmi, &best_mbmode, sizeof(MB_MODE_INFO));
+ vpx_memcpy(x->partition_info, &best_partition, sizeof(PARTITION_INFO));
for (i = 0; i < 16; i++)
{
// macroblock modes
vpx_memcpy(&x->e_mbd.mode_info_context->mbmi, &best_mbmode, sizeof(MB_MODE_INFO));
+ vpx_memcpy(x->partition_info, &best_partition, sizeof(PARTITION_INFO));
if (x->e_mbd.mode_info_context->mbmi.mode == B_PRED || x->e_mbd.mode_info_context->mbmi.mode == SPLITMV)
for (i = 0; i < 16; i++)
// save partitions
labels = vp8_mbsplits[best_seg];
x->e_mbd.mode_info_context->mbmi.partitioning = best_seg;
- x->e_mbd.mode_info_context->mbmi.partition_count = vp8_count_labels(labels);
+ x->partition_info->count = vp8_count_labels(labels);
- for (i = 0; i < x->e_mbd.mode_info_context->mbmi.partition_count; i++)
+ for (i = 0; i < x->partition_info->count; i++)
{
int j;
break;
}
- x->e_mbd.mode_info_context->mbmi.partition_bmi[i].mode = x->e_mbd.block[j].bmi.mode;
- x->e_mbd.mode_info_context->mbmi.partition_bmi[i].mv.as_mv = x->e_mbd.block[j].bmi.mv.as_mv;
+ x->partition_info->bmi[i].mode = x->e_mbd.block[j].bmi.mode;
+ x->partition_info->bmi[i].mv.as_mv = x->e_mbd.block[j].bmi.mv.as_mv;
}
return best_segment_rd;
MACROBLOCKD *xd = &x->e_mbd;
B_MODE_INFO best_bmodes[16];
MB_MODE_INFO best_mbmode;
+ PARTITION_INFO best_partition;
MV best_ref_mv;
MV mode_mv[MB_MODE_COUNT];
MB_PREDICTION_MODE this_mode;
}
// trap cases where the 8x8s can be promoted to 8x16s or 16x8s
- if (0)//x->e_mbd.mbmi.partition_count == 4)
+ if (0)//x->partition_info->count == 4)
{
- if (x->e_mbd.mode_info_context->mbmi.partition_bmi[0].mv.as_int == x->e_mbd.mode_info_context->mbmi.partition_bmi[1].mv.as_int
- && x->e_mbd.mode_info_context->mbmi.partition_bmi[2].mv.as_int == x->e_mbd.mode_info_context->mbmi.partition_bmi[3].mv.as_int)
+ if (x->partition_info->bmi[0].mv.as_int == x->partition_info->bmi[1].mv.as_int
+ && x->partition_info->bmi[2].mv.as_int == x->partition_info->bmi[3].mv.as_int)
{
const int *labels = vp8_mbsplits[2];
x->e_mbd.mode_info_context->mbmi.partitioning = 0;
rate -= vp8_cost_token(vp8_mbsplit_tree, vp8_mbsplit_probs, vp8_mbsplit_encodings + 2);
rate += vp8_cost_token(vp8_mbsplit_tree, vp8_mbsplit_probs, vp8_mbsplit_encodings);
- //rate -= x->inter_bmode_costs[ x->e_mbd.mbmi.partition_bmi[1]];
- //rate -= x->inter_bmode_costs[ x->e_mbd.mbmi.partition_bmi[3]];
- x->e_mbd.mode_info_context->mbmi.partition_bmi[1] = x->e_mbd.mode_info_context->mbmi.partition_bmi[2];
+ //rate -= x->inter_bmode_costs[ x->partition_info->bmi[1]];
+ //rate -= x->inter_bmode_costs[ x->partition_info->bmi[3]];
+ x->partition_info->bmi[1] = x->partition_info->bmi[2];
}
}
*returndistortion = distortion2;
best_rd = this_rd;
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));
for (i = 0; i < 16; i++)
{
best_mbmode.dc_diff = 0;
vpx_memcpy(&x->e_mbd.mode_info_context->mbmi, &best_mbmode, sizeof(MB_MODE_INFO));
+ vpx_memcpy(x->partition_info, &best_partition, sizeof(PARTITION_INFO));
for (i = 0; i < 16; i++)
{
// macroblock modes
vpx_memcpy(&x->e_mbd.mode_info_context->mbmi, &best_mbmode, sizeof(MB_MODE_INFO));
+ vpx_memcpy(x->partition_info, &best_partition, sizeof(PARTITION_INFO));
for (i = 0; i < 16; i++)
{