Merge remote branch 'origin/master' into experimental
Change-Id: I6f77e7c10a54c54b26126b8acd5edd0a03358a41
This commit is contained in:
commit
5dfd6f51cb
@ -173,8 +173,6 @@ typedef struct
|
||||
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;
|
||||
|
||||
|
||||
|
@ -207,12 +207,12 @@ static void build_inter_predictors2b(MACROBLOCKD *x, BLOCKD *d, int pitch)
|
||||
}
|
||||
|
||||
|
||||
/*encoder only*/
|
||||
void vp8_build_inter_predictors_mbuv(MACROBLOCKD *x)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (x->mode_info_context->mbmi.ref_frame != INTRA_FRAME &&
|
||||
x->mode_info_context->mbmi.mode != SPLITMV)
|
||||
if (x->mode_info_context->mbmi.mode != SPLITMV)
|
||||
{
|
||||
unsigned char *uptr, *vptr;
|
||||
unsigned char *upred_ptr = &x->predictor[256];
|
||||
@ -257,69 +257,32 @@ void vp8_build_inter_predictors_mbuv(MACROBLOCKD *x)
|
||||
}
|
||||
|
||||
/*encoder only*/
|
||||
void vp8_build_inter_predictors_mby(MACROBLOCKD *x)
|
||||
void vp8_build_inter16x16_predictors_mby(MACROBLOCKD *x)
|
||||
{
|
||||
unsigned char *ptr_base;
|
||||
unsigned char *ptr;
|
||||
unsigned char *pred_ptr = x->predictor;
|
||||
int mv_row = x->mode_info_context->mbmi.mv.as_mv.row;
|
||||
int mv_col = x->mode_info_context->mbmi.mv.as_mv.col;
|
||||
int pre_stride = x->block[0].pre_stride;
|
||||
|
||||
if (x->mode_info_context->mbmi.ref_frame != INTRA_FRAME &&
|
||||
x->mode_info_context->mbmi.mode != SPLITMV)
|
||||
ptr_base = x->pre.y_buffer;
|
||||
ptr = ptr_base + (mv_row >> 3) * pre_stride + (mv_col >> 3);
|
||||
|
||||
if ((mv_row | mv_col) & 7)
|
||||
{
|
||||
unsigned char *ptr_base;
|
||||
unsigned char *ptr;
|
||||
unsigned char *pred_ptr = x->predictor;
|
||||
int mv_row = x->mode_info_context->mbmi.mv.as_mv.row;
|
||||
int mv_col = x->mode_info_context->mbmi.mv.as_mv.col;
|
||||
int pre_stride = x->block[0].pre_stride;
|
||||
|
||||
ptr_base = x->pre.y_buffer;
|
||||
ptr = ptr_base + (mv_row >> 3) * pre_stride + (mv_col >> 3);
|
||||
|
||||
if ((mv_row | mv_col) & 7)
|
||||
{
|
||||
x->subpixel_predict16x16(ptr, pre_stride, mv_col & 7, mv_row & 7, pred_ptr, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
RECON_INVOKE(&x->rtcd->recon, copy16x16)(ptr, pre_stride, pred_ptr, 16);
|
||||
}
|
||||
x->subpixel_predict16x16(ptr, pre_stride, mv_col & 7, mv_row & 7, pred_ptr, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
if (x->mode_info_context->mbmi.partitioning < 3)
|
||||
{
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
BLOCKD *d = &x->block[bbb[i]];
|
||||
build_inter_predictors4b(x, d, 16);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < 16; i += 2)
|
||||
{
|
||||
BLOCKD *d0 = &x->block[i];
|
||||
BLOCKD *d1 = &x->block[i+1];
|
||||
|
||||
if (d0->bmi.mv.as_int == d1->bmi.mv.as_int)
|
||||
build_inter_predictors2b(x, d0, 16);
|
||||
else
|
||||
{
|
||||
vp8_build_inter_predictors_b(d0, 16, x->subpixel_predict);
|
||||
vp8_build_inter_predictors_b(d1, 16, x->subpixel_predict);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
RECON_INVOKE(&x->rtcd->recon, copy16x16)(ptr, pre_stride, pred_ptr, 16);
|
||||
}
|
||||
}
|
||||
|
||||
void vp8_build_inter_predictors_mb(MACROBLOCKD *x)
|
||||
{
|
||||
|
||||
if (x->mode_info_context->mbmi.ref_frame != INTRA_FRAME &&
|
||||
x->mode_info_context->mbmi.mode != SPLITMV)
|
||||
if (x->mode_info_context->mbmi.mode != SPLITMV)
|
||||
{
|
||||
int offset;
|
||||
unsigned char *ptr_base;
|
||||
@ -535,58 +498,58 @@ static void vp8_build_inter_predictors_b_s(BLOCKD *d, unsigned char *dst_ptr, vp
|
||||
|
||||
|
||||
|
||||
void vp8_build_inter16x16_predictors_mb_s(MACROBLOCKD *x)
|
||||
{
|
||||
unsigned char *dst_ptr = x->dst.y_buffer;
|
||||
|
||||
int offset;
|
||||
unsigned char *ptr_base;
|
||||
unsigned char *ptr;
|
||||
unsigned char *uptr, *vptr;
|
||||
unsigned char *udst_ptr = x->dst.u_buffer;
|
||||
unsigned char *vdst_ptr = x->dst.v_buffer;
|
||||
|
||||
int mv_row = x->mode_info_context->mbmi.mv.as_mv.row;
|
||||
int mv_col = x->mode_info_context->mbmi.mv.as_mv.col;
|
||||
int pre_stride = x->dst.y_stride; /*x->block[0].pre_stride;*/
|
||||
|
||||
ptr_base = x->pre.y_buffer;
|
||||
ptr = ptr_base + (mv_row >> 3) * pre_stride + (mv_col >> 3);
|
||||
|
||||
if ((mv_row | mv_col) & 7)
|
||||
{
|
||||
x->subpixel_predict16x16(ptr, pre_stride, mv_col & 7, mv_row & 7, dst_ptr, x->dst.y_stride); /*x->block[0].dst_stride);*/
|
||||
}
|
||||
else
|
||||
{
|
||||
RECON_INVOKE(&x->rtcd->recon, copy16x16)(ptr, pre_stride, dst_ptr, x->dst.y_stride); /*x->block[0].dst_stride);*/
|
||||
}
|
||||
|
||||
mv_row = x->block[16].bmi.mv.as_mv.row;
|
||||
mv_col = x->block[16].bmi.mv.as_mv.col;
|
||||
pre_stride >>= 1;
|
||||
offset = (mv_row >> 3) * pre_stride + (mv_col >> 3);
|
||||
uptr = x->pre.u_buffer + offset;
|
||||
vptr = x->pre.v_buffer + offset;
|
||||
|
||||
if ((mv_row | mv_col) & 7)
|
||||
{
|
||||
x->subpixel_predict8x8(uptr, pre_stride, mv_col & 7, mv_row & 7, udst_ptr, x->dst.uv_stride);
|
||||
x->subpixel_predict8x8(vptr, pre_stride, mv_col & 7, mv_row & 7, vdst_ptr, x->dst.uv_stride);
|
||||
}
|
||||
else
|
||||
{
|
||||
RECON_INVOKE(&x->rtcd->recon, copy8x8)(uptr, pre_stride, udst_ptr, x->dst.uv_stride);
|
||||
RECON_INVOKE(&x->rtcd->recon, copy8x8)(vptr, pre_stride, vdst_ptr, x->dst.uv_stride);
|
||||
}
|
||||
}
|
||||
void vp8_build_inter_predictors_mb_s(MACROBLOCKD *x)
|
||||
{
|
||||
/*unsigned char *pred_ptr = x->block[0].predictor;
|
||||
unsigned char *dst_ptr = *(x->block[0].base_dst) + x->block[0].dst;*/
|
||||
unsigned char *pred_ptr = x->predictor;
|
||||
unsigned char *dst_ptr = x->dst.y_buffer;
|
||||
|
||||
if (x->mode_info_context->mbmi.mode != SPLITMV)
|
||||
{
|
||||
int offset;
|
||||
unsigned char *ptr_base;
|
||||
unsigned char *ptr;
|
||||
unsigned char *uptr, *vptr;
|
||||
/*unsigned char *pred_ptr = x->predictor;
|
||||
unsigned char *upred_ptr = &x->predictor[256];
|
||||
unsigned char *vpred_ptr = &x->predictor[320];*/
|
||||
unsigned char *udst_ptr = x->dst.u_buffer;
|
||||
unsigned char *vdst_ptr = x->dst.v_buffer;
|
||||
|
||||
int mv_row = x->mode_info_context->mbmi.mv.as_mv.row;
|
||||
int mv_col = x->mode_info_context->mbmi.mv.as_mv.col;
|
||||
int pre_stride = x->dst.y_stride; /*x->block[0].pre_stride;*/
|
||||
|
||||
ptr_base = x->pre.y_buffer;
|
||||
ptr = ptr_base + (mv_row >> 3) * pre_stride + (mv_col >> 3);
|
||||
|
||||
if ((mv_row | mv_col) & 7)
|
||||
{
|
||||
x->subpixel_predict16x16(ptr, pre_stride, mv_col & 7, mv_row & 7, dst_ptr, x->dst.y_stride); /*x->block[0].dst_stride);*/
|
||||
}
|
||||
else
|
||||
{
|
||||
RECON_INVOKE(&x->rtcd->recon, copy16x16)(ptr, pre_stride, dst_ptr, x->dst.y_stride); /*x->block[0].dst_stride);*/
|
||||
}
|
||||
|
||||
mv_row = x->block[16].bmi.mv.as_mv.row;
|
||||
mv_col = x->block[16].bmi.mv.as_mv.col;
|
||||
pre_stride >>= 1;
|
||||
offset = (mv_row >> 3) * pre_stride + (mv_col >> 3);
|
||||
uptr = x->pre.u_buffer + offset;
|
||||
vptr = x->pre.v_buffer + offset;
|
||||
|
||||
if ((mv_row | mv_col) & 7)
|
||||
{
|
||||
x->subpixel_predict8x8(uptr, pre_stride, mv_col & 7, mv_row & 7, udst_ptr, x->dst.uv_stride);
|
||||
x->subpixel_predict8x8(vptr, pre_stride, mv_col & 7, mv_row & 7, vdst_ptr, x->dst.uv_stride);
|
||||
}
|
||||
else
|
||||
{
|
||||
RECON_INVOKE(&x->rtcd->recon, copy8x8)(uptr, pre_stride, udst_ptr, x->dst.uv_stride);
|
||||
RECON_INVOKE(&x->rtcd->recon, copy8x8)(vptr, pre_stride, vdst_ptr, x->dst.uv_stride);
|
||||
}
|
||||
vp8_build_inter16x16_predictors_mb_s(x);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -599,25 +562,20 @@ void vp8_build_inter_predictors_mb_s(MACROBLOCKD *x)
|
||||
{
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
unsigned char *ptr_base;
|
||||
unsigned char *ptr;
|
||||
BLOCKD *d = &x->block[bbb[i]];
|
||||
/*build_inter_predictors4b(x, d, 16);*/
|
||||
|
||||
ptr_base = *(d->base_pre);
|
||||
ptr = ptr_base + d->pre + (d->bmi.mv.as_mv.row >> 3) * d->pre_stride + (d->bmi.mv.as_mv.col >> 3);
|
||||
|
||||
if (d->bmi.mv.as_mv.row & 7 || d->bmi.mv.as_mv.col & 7)
|
||||
{
|
||||
unsigned char *ptr_base;
|
||||
unsigned char *ptr;
|
||||
unsigned char *pred_ptr = d->predictor;
|
||||
|
||||
ptr_base = *(d->base_pre);
|
||||
ptr = ptr_base + d->pre + (d->bmi.mv.as_mv.row >> 3) * d->pre_stride + (d->bmi.mv.as_mv.col >> 3);
|
||||
|
||||
if (d->bmi.mv.as_mv.row & 7 || d->bmi.mv.as_mv.col & 7)
|
||||
{
|
||||
x->subpixel_predict8x8(ptr, d->pre_stride, d->bmi.mv.as_mv.col & 7, d->bmi.mv.as_mv.row & 7, dst_ptr, x->dst.y_stride); /*x->block[0].dst_stride);*/
|
||||
}
|
||||
else
|
||||
{
|
||||
RECON_INVOKE(&x->rtcd->recon, copy8x8)(ptr, d->pre_stride, dst_ptr, x->dst.y_stride); /*x->block[0].dst_stride);*/
|
||||
}
|
||||
x->subpixel_predict8x8(ptr, d->pre_stride, d->bmi.mv.as_mv.col & 7, d->bmi.mv.as_mv.row & 7, dst_ptr, x->dst.y_stride); /*x->block[0].dst_stride);*/
|
||||
}
|
||||
else
|
||||
{
|
||||
RECON_INVOKE(&x->rtcd->recon, copy8x8)(ptr, d->pre_stride, dst_ptr, x->dst.y_stride); /*x->block[0].dst_stride);*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -633,7 +591,6 @@ void vp8_build_inter_predictors_mb_s(MACROBLOCKD *x)
|
||||
/*build_inter_predictors2b(x, d0, 16);*/
|
||||
unsigned char *ptr_base;
|
||||
unsigned char *ptr;
|
||||
unsigned char *pred_ptr = d0->predictor;
|
||||
|
||||
ptr_base = *(d0->base_pre);
|
||||
ptr = ptr_base + d0->pre + (d0->bmi.mv.as_mv.row >> 3) * d0->pre_stride + (d0->bmi.mv.as_mv.col >> 3);
|
||||
@ -665,7 +622,6 @@ void vp8_build_inter_predictors_mb_s(MACROBLOCKD *x)
|
||||
/*build_inter_predictors2b(x, d0, 8);*/
|
||||
unsigned char *ptr_base;
|
||||
unsigned char *ptr;
|
||||
unsigned char *pred_ptr = d0->predictor;
|
||||
|
||||
ptr_base = *(d0->base_pre);
|
||||
ptr = ptr_base + d0->pre + (d0->bmi.mv.as_mv.row >> 3) * d0->pre_stride + (d0->bmi.mv.as_mv.col >> 3);
|
||||
|
@ -14,8 +14,9 @@
|
||||
|
||||
extern void vp8_build_inter_predictors_mb(MACROBLOCKD *x);
|
||||
extern void vp8_build_inter_predictors_mb_s(MACROBLOCKD *x);
|
||||
extern void vp8_build_inter16x16_predictors_mb_s(MACROBLOCKD *x);
|
||||
|
||||
extern void vp8_build_inter_predictors_mby(MACROBLOCKD *x);
|
||||
extern void vp8_build_inter16x16_predictors_mby(MACROBLOCKD *x);
|
||||
extern void vp8_build_uvmvs(MACROBLOCKD *x, int fullpixel);
|
||||
extern void vp8_build_inter_predictors_b(BLOCKD *d, int pitch, vp8_subpix_fn_t sppf);
|
||||
extern void vp8_build_inter_predictors_mbuv(MACROBLOCKD *x);
|
||||
|
@ -120,7 +120,7 @@ static void skip_recon_mb(VP8D_COMP *pbi, MACROBLOCKD *xd)
|
||||
}
|
||||
else
|
||||
{
|
||||
vp8_build_inter_predictors_mb_s(xd);
|
||||
vp8_build_inter16x16_predictors_mb_s(xd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, int mb_row, int m
|
||||
}
|
||||
else
|
||||
{
|
||||
vp8_build_inter_predictors_mb_s(xd);
|
||||
vp8_build_inter16x16_predictors_mb_s(xd);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1381,7 +1381,7 @@ int vp8cx_encode_inter_macroblock
|
||||
cpi->MVcount[1][mv_max+((xd->block[0].bmi.mv.as_mv.col - best_ref_mv.col) >> 1)]++;
|
||||
}
|
||||
|
||||
if (!x->skip && !x->e_mbd.mode_info_context->mbmi.force_no_skip)
|
||||
if (!x->skip)
|
||||
{
|
||||
vp8_encode_inter16x16(IF_RTCD(&cpi->rtcd), x);
|
||||
|
||||
@ -1391,7 +1391,7 @@ int vp8cx_encode_inter_macroblock
|
||||
|
||||
}
|
||||
else
|
||||
vp8_stuff_inter16x16(x);
|
||||
vp8_build_inter_predictors_mb_s(xd);
|
||||
}
|
||||
|
||||
if (!x->skip)
|
||||
|
@ -196,39 +196,6 @@ static void transform_mby(MACROBLOCK *x)
|
||||
}
|
||||
|
||||
|
||||
void vp8_stuff_inter16x16(MACROBLOCK *x)
|
||||
{
|
||||
vp8_build_inter_predictors_mb_s(&x->e_mbd);
|
||||
/*
|
||||
// recon = copy from predictors to destination
|
||||
{
|
||||
BLOCKD *b = &x->e_mbd.block[0];
|
||||
unsigned char *pred_ptr = b->predictor;
|
||||
unsigned char *dst_ptr = *(b->base_dst) + b->dst;
|
||||
int stride = b->dst_stride;
|
||||
|
||||
int i;
|
||||
for(i=0;i<16;i++)
|
||||
vpx_memcpy(dst_ptr+i*stride,pred_ptr+16*i,16);
|
||||
|
||||
b = &x->e_mbd.block[16];
|
||||
pred_ptr = b->predictor;
|
||||
dst_ptr = *(b->base_dst) + b->dst;
|
||||
stride = b->dst_stride;
|
||||
|
||||
for(i=0;i<8;i++)
|
||||
vpx_memcpy(dst_ptr+i*stride,pred_ptr+8*i,8);
|
||||
|
||||
b = &x->e_mbd.block[20];
|
||||
pred_ptr = b->predictor;
|
||||
dst_ptr = *(b->base_dst) + b->dst;
|
||||
stride = b->dst_stride;
|
||||
|
||||
for(i=0;i<8;i++)
|
||||
vpx_memcpy(dst_ptr+i*stride,pred_ptr+8*i,8);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
#define RDTRUNC(RM,DM,R,D) ( (128+(R)*(RM)) & 0xFF )
|
||||
|
||||
@ -635,7 +602,7 @@ void vp8_encode_inter16x16(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
|
||||
/* this funciton is used by first pass only */
|
||||
void vp8_encode_inter16x16y(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
|
||||
{
|
||||
vp8_build_inter_predictors_mby(&x->e_mbd);
|
||||
vp8_build_inter16x16_predictors_mby(&x->e_mbd);
|
||||
|
||||
ENCODEMB_INVOKE(&rtcd->encodemb, submby)(x->src_diff, x->src.y_buffer, x->e_mbd.predictor, x->src.y_stride);
|
||||
|
||||
|
@ -95,8 +95,6 @@ typedef struct
|
||||
struct VP8_ENCODER_RTCD;
|
||||
void vp8_encode_inter16x16(const struct VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x);
|
||||
|
||||
extern void vp8_stuff_inter16x16(MACROBLOCK *x);
|
||||
|
||||
void vp8_build_dcblock(MACROBLOCK *b);
|
||||
void vp8_transform_mb(MACROBLOCK *mb);
|
||||
void vp8_transform_mbuv(MACROBLOCK *x);
|
||||
|
@ -1768,9 +1768,6 @@ void vp8_change_config(VP8_PTR ptr, VP8_CONFIG *oxcf)
|
||||
cm->horiz_scale = cpi->horiz_scale;
|
||||
cm->vert_scale = cpi->vert_scale ;
|
||||
|
||||
// As per VP8
|
||||
cpi->intra_frame_target = (4 * (cm->Width + cm->Height) / 15) * 1000;
|
||||
|
||||
// VP8 sharpness level mapping 0-7 (vs 0-10 in general VPx dialogs)
|
||||
if (cpi->oxcf.Sharpness > 7)
|
||||
cpi->oxcf.Sharpness = 7;
|
||||
@ -1800,10 +1797,6 @@ void vp8_change_config(VP8_PTR ptr, VP8_CONFIG *oxcf)
|
||||
vp8_alloc_compressor_data(cpi);
|
||||
}
|
||||
|
||||
// Clamp KF frame size to quarter of data rate
|
||||
if (cpi->intra_frame_target > cpi->target_bandwidth >> 2)
|
||||
cpi->intra_frame_target = cpi->target_bandwidth >> 2;
|
||||
|
||||
if (cpi->oxcf.fixed_q >= 0)
|
||||
{
|
||||
cpi->last_q[0] = cpi->oxcf.fixed_q;
|
||||
@ -2029,7 +2022,6 @@ VP8_PTR vp8_create_compressor(VP8_CONFIG *oxcf)
|
||||
|
||||
cpi->frames_till_gf_update_due = 0;
|
||||
cpi->key_frame_count = 1;
|
||||
cpi->tot_key_frame_bits = 0;
|
||||
|
||||
cpi->ni_av_qi = cpi->oxcf.worst_allowed_q;
|
||||
cpi->ni_tot_qi = 0;
|
||||
@ -2055,7 +2047,6 @@ VP8_PTR vp8_create_compressor(VP8_CONFIG *oxcf)
|
||||
|
||||
for (i = 0; i < KEY_FRAME_CONTEXT; i++)
|
||||
{
|
||||
cpi->prior_key_frame_size[i] = cpi->intra_frame_target;
|
||||
cpi->prior_key_frame_distance[i] = (int)cpi->output_frame_rate;
|
||||
}
|
||||
|
||||
@ -4456,9 +4447,9 @@ static void encode_frame_to_data_rate
|
||||
vp8_clear_system_state(); //__asm emms;
|
||||
|
||||
if (cpi->total_coded_error_left != 0.0)
|
||||
fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %6ld %6ld"
|
||||
"%6ld %6ld %6ld %5ld %5ld %5ld %8ld %8.2f %10d %10.3f"
|
||||
"%10.3f %8ld\n",
|
||||
fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %6d %6d"
|
||||
"%6d %6d %6d %5d %5d %5d %8d %8.2f %10d %10.3f"
|
||||
"%10.3f %8d\n",
|
||||
cpi->common.current_video_frame, cpi->this_frame_target,
|
||||
cpi->projected_frame_size,
|
||||
(cpi->projected_frame_size - cpi->this_frame_target),
|
||||
@ -4475,9 +4466,9 @@ static void encode_frame_to_data_rate
|
||||
(double)cpi->bits_left / cpi->total_coded_error_left,
|
||||
cpi->tot_recode_hits);
|
||||
else
|
||||
fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %6ld %6ld"
|
||||
"%6ld %6ld %6ld %5ld %5ld %5ld %8ld %8.2f %10d %10.3f"
|
||||
"%8ld\n",
|
||||
fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %6d %6d"
|
||||
"%6d %6d %6d %5d %5d %5d %8d %8.2f %10d %10.3f"
|
||||
"%8d\n",
|
||||
cpi->common.current_video_frame,
|
||||
cpi->this_frame_target, cpi->projected_frame_size,
|
||||
(cpi->projected_frame_size - cpi->this_frame_target),
|
||||
|
@ -385,14 +385,11 @@ typedef struct
|
||||
int active_arnr_frames; // <= cpi->oxcf.arnr_max_frames
|
||||
|
||||
INT64 key_frame_count;
|
||||
INT64 tot_key_frame_bits;
|
||||
int prior_key_frame_size[KEY_FRAME_CONTEXT];
|
||||
int prior_key_frame_distance[KEY_FRAME_CONTEXT];
|
||||
int per_frame_bandwidth; // Current section per frame bandwidth target
|
||||
int av_per_frame_bandwidth; // Average frame size target for clip
|
||||
int min_frame_bandwidth; // Minimum allocation that should be used for any frame
|
||||
int last_key_frame_size;
|
||||
int intra_frame_target;
|
||||
int inter_frame_target;
|
||||
double output_frame_rate;
|
||||
long long last_time_stamp_seen;
|
||||
|
@ -1497,86 +1497,83 @@ static int estimate_min_frame_size(VP8_COMP *cpi)
|
||||
return (bits_per_mb_at_max_q * cpi->common.MBs) >> BPER_MB_NORMBITS;
|
||||
}
|
||||
|
||||
void vp8_adjust_key_frame_context(VP8_COMP *cpi)
|
||||
|
||||
static int estimate_keyframe_frequency(VP8_COMP *cpi)
|
||||
{
|
||||
int i;
|
||||
int av_key_frames_per_second;
|
||||
|
||||
// Average key frame frequency and size
|
||||
unsigned int total_weight = 0;
|
||||
unsigned int av_key_frame_frequency = 0;
|
||||
unsigned int av_key_frame_bits = 0;
|
||||
// Average key frame frequency
|
||||
int av_key_frame_frequency = 0;
|
||||
|
||||
unsigned int output_frame_rate = (unsigned int)(100 * cpi->output_frame_rate);
|
||||
unsigned int target_bandwidth = (unsigned int)(100 * cpi->target_bandwidth);
|
||||
|
||||
// Clear down mmx registers to allow floating point in what follows
|
||||
vp8_clear_system_state(); //__asm emms;
|
||||
|
||||
// Update the count of total key frame bits
|
||||
cpi->tot_key_frame_bits += cpi->projected_frame_size;
|
||||
|
||||
// First key frame at start of sequence is a special case. We have no frequency data.
|
||||
/* First key frame at start of sequence is a special case. We have no
|
||||
* frequency data.
|
||||
*/
|
||||
if (cpi->key_frame_count == 1)
|
||||
{
|
||||
av_key_frame_frequency = (int)cpi->output_frame_rate * 2; // Assume a default of 1 kf every 2 seconds
|
||||
av_key_frame_bits = cpi->projected_frame_size;
|
||||
av_key_frames_per_second = output_frame_rate / av_key_frame_frequency; // Note output_frame_rate not cpi->output_frame_rate
|
||||
/* Assume a default of 1 kf every 2 seconds, or the max kf interval,
|
||||
* whichever is smaller.
|
||||
*/
|
||||
av_key_frame_frequency = (int)cpi->output_frame_rate * 2;
|
||||
if (av_key_frame_frequency > cpi->oxcf.key_freq)
|
||||
av_key_frame_frequency = cpi->oxcf.key_freq;
|
||||
|
||||
cpi->prior_key_frame_distance[KEY_FRAME_CONTEXT - 1]
|
||||
= av_key_frame_frequency;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int total_weight = 0;
|
||||
int last_kf_interval =
|
||||
(cpi->frames_since_key > 0) ? cpi->frames_since_key : 1;
|
||||
|
||||
// reset keyframe context and calculate weighted average of last KEY_FRAME_CONTEXT keyframes
|
||||
/* reset keyframe context and calculate weighted average of last
|
||||
* KEY_FRAME_CONTEXT keyframes
|
||||
*/
|
||||
for (i = 0; i < KEY_FRAME_CONTEXT; i++)
|
||||
{
|
||||
if (i < KEY_FRAME_CONTEXT - 1)
|
||||
{
|
||||
cpi->prior_key_frame_size[i] = cpi->prior_key_frame_size[i+1];
|
||||
cpi->prior_key_frame_distance[i] = cpi->prior_key_frame_distance[i+1];
|
||||
}
|
||||
cpi->prior_key_frame_distance[i]
|
||||
= cpi->prior_key_frame_distance[i+1];
|
||||
else
|
||||
{
|
||||
cpi->prior_key_frame_size[i] = cpi->projected_frame_size;
|
||||
cpi->prior_key_frame_distance[i] = last_kf_interval;
|
||||
}
|
||||
|
||||
av_key_frame_bits += prior_key_frame_weight[i] * cpi->prior_key_frame_size[i];
|
||||
av_key_frame_frequency += prior_key_frame_weight[i] * cpi->prior_key_frame_distance[i];
|
||||
total_weight += prior_key_frame_weight[i];
|
||||
av_key_frame_frequency += prior_key_frame_weight[i]
|
||||
* cpi->prior_key_frame_distance[i];
|
||||
total_weight += prior_key_frame_weight[i];
|
||||
}
|
||||
|
||||
av_key_frame_bits /= total_weight;
|
||||
av_key_frame_frequency /= total_weight;
|
||||
av_key_frames_per_second = output_frame_rate / av_key_frame_frequency;
|
||||
|
||||
}
|
||||
return av_key_frame_frequency;
|
||||
}
|
||||
|
||||
|
||||
void vp8_adjust_key_frame_context(VP8_COMP *cpi)
|
||||
{
|
||||
// Clear down mmx registers to allow floating point in what follows
|
||||
vp8_clear_system_state();
|
||||
|
||||
// Do we have any key frame overspend to recover?
|
||||
if ((cpi->pass != 2) && (cpi->projected_frame_size > cpi->per_frame_bandwidth))
|
||||
// Two-pass overspend handled elsewhere.
|
||||
if ((cpi->pass != 2)
|
||||
&& (cpi->projected_frame_size > cpi->per_frame_bandwidth))
|
||||
{
|
||||
// Update the count of key frame overspend to be recovered in subsequent frames
|
||||
// A portion of the KF overspend is treated as gf overspend (and hence recovered more quickly)
|
||||
// as the kf is also a gf. Otherwise the few frames following each kf tend to get more bits
|
||||
// allocated than those following other gfs.
|
||||
cpi->kf_overspend_bits += (cpi->projected_frame_size - cpi->per_frame_bandwidth) * 7 / 8;
|
||||
cpi->gf_overspend_bits += (cpi->projected_frame_size - cpi->per_frame_bandwidth) * 1 / 8;
|
||||
if(!av_key_frame_frequency)
|
||||
av_key_frame_frequency = 60;
|
||||
int overspend;
|
||||
|
||||
// Work out how much to try and recover per frame.
|
||||
// For one pass we estimate the number of frames to spread it over based upon past history.
|
||||
// For two pass we know how many frames there will be till the next kf.
|
||||
if (cpi->pass == 2)
|
||||
{
|
||||
if (cpi->frames_to_key > 16)
|
||||
cpi->kf_bitrate_adjustment = cpi->kf_overspend_bits / (int)cpi->frames_to_key;
|
||||
else
|
||||
cpi->kf_bitrate_adjustment = cpi->kf_overspend_bits / 16;
|
||||
}
|
||||
else
|
||||
cpi->kf_bitrate_adjustment = cpi->kf_overspend_bits / (int)av_key_frame_frequency;
|
||||
/* Update the count of key frame overspend to be recovered in
|
||||
* subsequent frames. A portion of the KF overspend is treated as gf
|
||||
* overspend (and hence recovered more quickly) as the kf is also a
|
||||
* gf. Otherwise the few frames following each kf tend to get more
|
||||
* bits allocated than those following other gfs.
|
||||
*/
|
||||
overspend = (cpi->projected_frame_size - cpi->per_frame_bandwidth);
|
||||
cpi->kf_overspend_bits += overspend * 7 / 8;
|
||||
cpi->gf_overspend_bits += overspend * 1 / 8;
|
||||
|
||||
/* Work out how much to try and recover per frame. */
|
||||
cpi->kf_bitrate_adjustment = cpi->kf_overspend_bits
|
||||
/ estimate_keyframe_frequency(cpi);
|
||||
}
|
||||
|
||||
cpi->frames_since_key = 0;
|
||||
@ -1584,6 +1581,7 @@ void vp8_adjust_key_frame_context(VP8_COMP *cpi)
|
||||
cpi->key_frame_count++;
|
||||
}
|
||||
|
||||
|
||||
void vp8_compute_frame_size_bounds(VP8_COMP *cpi, int *frame_under_shoot_limit, int *frame_over_shoot_limit)
|
||||
{
|
||||
// Set-up bounds on acceptable frame size:
|
||||
|
@ -1818,9 +1818,6 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
|
||||
//int intermodecost[MAX_MODES];
|
||||
|
||||
MB_PREDICTION_MODE uv_intra_mode;
|
||||
|
||||
int force_no_skip = 0;
|
||||
|
||||
MV mvp;
|
||||
int near_sadidx[8] = {0, 1, 2, 3, 4, 5, 6, 7};
|
||||
int saddone=0;
|
||||
@ -1923,8 +1920,6 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
|
||||
int disable_skip = 0;
|
||||
int other_cost = 0;
|
||||
|
||||
force_no_skip = 0;
|
||||
|
||||
// Experimental debug code.
|
||||
// Record of rd values recorded for this MB. -1 indicates not measured
|
||||
//all_rds[mode_index] = -1;
|
||||
@ -2299,7 +2294,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
|
||||
continue;
|
||||
|
||||
vp8_set_mbmode_and_mvs(x, this_mode, &mode_mv[this_mode]);
|
||||
vp8_build_inter_predictors_mby(&x->e_mbd);
|
||||
vp8_build_inter16x16_predictors_mby(&x->e_mbd);
|
||||
|
||||
if (cpi->active_map_enabled && x->active_ptr[0] == 0) {
|
||||
x->skip = 1;
|
||||
@ -2435,7 +2430,6 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
|
||||
{
|
||||
// Note index of best mode so far
|
||||
best_mode_index = mode_index;
|
||||
x->e_mbd.mode_info_context->mbmi.force_no_skip = force_no_skip;
|
||||
|
||||
if (this_mode <= B_PRED)
|
||||
{
|
||||
|
@ -229,16 +229,6 @@ void vp8_tokenize_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t)
|
||||
|
||||
x->mode_info_context->mbmi.dc_diff = 1;
|
||||
|
||||
#if 0
|
||||
|
||||
if (x->mbmi.force_no_skip)
|
||||
{
|
||||
x->mbmi.mb_skip_coeff = 1;
|
||||
//reset for next_mb.
|
||||
x->mbmi.force_no_skip = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user