void vp8_de_alloc_frame_buffers(VP8_COMMON *oci) {
int i;
- for (i = 0; i < NUM_YV12_BUFFERS; ++i)
+ for (i = 0; i < NUM_YV12_BUFFERS; ++i) {
vp8_yv12_de_alloc_frame_buffer(&oci->yv12_fb[i]);
+ }
vp8_yv12_de_alloc_frame_buffer(&oci->temp_scale_frame);
#if CONFIG_POSTPROC
vp8_yv12_de_alloc_frame_buffer(&oci->post_proc_buffer);
- if (oci->post_proc_buffer_int_used)
+ if (oci->post_proc_buffer_int_used) {
vp8_yv12_de_alloc_frame_buffer(&oci->post_proc_buffer_int);
+ }
vpx_free(oci->pp_limits_buffer);
oci->pp_limits_buffer = NULL;
oci->fb_idx_ref_cnt[i] = 0;
oci->yv12_fb[i].flags = 0;
if (vp8_yv12_alloc_frame_buffer(&oci->yv12_fb[i], width, height,
- VP8BORDERINPIXELS) < 0)
+ VP8BORDERINPIXELS) < 0) {
goto allocation_fail;
+ }
}
oci->new_fb_idx = 0;
oci->fb_idx_ref_cnt[3] = 1;
if (vp8_yv12_alloc_frame_buffer(&oci->temp_scale_frame, width, 16,
- VP8BORDERINPIXELS) < 0)
+ VP8BORDERINPIXELS) < 0) {
goto allocation_fail;
+ }
oci->mb_rows = height >> 4;
oci->mb_cols = width >> 4;
#if CONFIG_POSTPROC
if (vp8_yv12_alloc_frame_buffer(&oci->post_proc_buffer, width, height,
- VP8BORDERINPIXELS) < 0)
+ VP8BORDERINPIXELS) < 0) {
goto allocation_fail;
+ }
oci->post_proc_buffer_int_used = 0;
memset(&oci->postproc_state, 0, sizeof(oci->postproc_state));
/* Normalize back to 0-255 */
Temp = Temp >> VP8_FILTER_SHIFT;
- if (Temp < 0)
+ if (Temp < 0) {
Temp = 0;
- else if (Temp > 255)
+ } else if (Temp > 255) {
Temp = 255;
+ }
output_ptr[j] = Temp;
src_ptr++;
/* Normalize back to 0-255 */
Temp = Temp >> VP8_FILTER_SHIFT;
- if (Temp < 0)
+ if (Temp < 0) {
Temp = 0;
- else if (Temp > 255)
+ } else if (Temp > 255) {
Temp = 255;
+ }
output_ptr[j] = (unsigned char)Temp;
src_ptr++;
}
*cntx += 2;
- } else
+ } else {
cnt[CNT_INTRA] += 2;
+ }
}
/* Process above left */
}
*cntx += 1;
- } else
+ } else {
cnt[CNT_INTRA] += 1;
+ }
}
/* If we have three distinct MV's ... */
}
/* Use near_mvs[0] to store the "best" MV */
- if (cnt[CNT_NEAREST] >= cnt[CNT_INTRA])
+ 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;
#define LEFT_TOP_MARGIN (16 << 3)
#define RIGHT_BOTTOM_MARGIN (16 << 3)
static INLINE void vp8_clamp_mv2(int_mv *mv, const MACROBLOCKD *xd) {
- if (mv->as_mv.col < (xd->mb_to_left_edge - LEFT_TOP_MARGIN))
+ if (mv->as_mv.col < (xd->mb_to_left_edge - LEFT_TOP_MARGIN)) {
mv->as_mv.col = xd->mb_to_left_edge - LEFT_TOP_MARGIN;
- else if (mv->as_mv.col > xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN)
+ } else if (mv->as_mv.col > xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN) {
mv->as_mv.col = xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN;
+ }
- if (mv->as_mv.row < (xd->mb_to_top_edge - LEFT_TOP_MARGIN))
+ if (mv->as_mv.row < (xd->mb_to_top_edge - LEFT_TOP_MARGIN)) {
mv->as_mv.row = xd->mb_to_top_edge - LEFT_TOP_MARGIN;
- else if (mv->as_mv.row > xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN)
+ } else if (mv->as_mv.row > xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN) {
mv->as_mv.row = xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN;
+ }
}
static INLINE void vp8_clamp_mv(int_mv *mv, int mb_to_left_edge,
for (i = 0; i < 4; ++i) {
for (j = 0; j < 4; ++j) {
- if (*eobs++ > 1)
+ if (*eobs++ > 1) {
vp8_dequant_idct_add_c(q, dq, dst, stride);
- else {
+ } else {
vp8_dc_only_idct_add_c(q[0] * dq[0], dst, stride, dst, stride);
memset(q, 0, 2 * sizeof(q[0]));
}
for (i = 0; i < 2; ++i) {
for (j = 0; j < 2; ++j) {
- if (*eobs++ > 1)
+ if (*eobs++ > 1) {
vp8_dequant_idct_add_c(q, dq, dstu, stride);
- else {
+ } else {
vp8_dc_only_idct_add_c(q[0] * dq[0], dstu, stride, dstu, stride);
memset(q, 0, 2 * sizeof(q[0]));
}
for (i = 0; i < 2; ++i) {
for (j = 0; j < 2; ++j) {
- if (*eobs++ > 1)
+ if (*eobs++ > 1) {
vp8_dequant_idct_add_c(q, dq, dstv, stride);
- else {
+ } else {
vp8_dc_only_idct_add_c(q[0] * dq[0], dstv, stride, dstv, stride);
memset(q, 0, 2 * sizeof(q[0]));
}
vp8_mbloop_filter_horizontal_edge_c(y_ptr, y_stride, lfi->mblim, lfi->lim,
lfi->hev_thr, 2);
- if (u_ptr)
+ if (u_ptr) {
vp8_mbloop_filter_horizontal_edge_c(u_ptr, uv_stride, lfi->mblim, lfi->lim,
lfi->hev_thr, 1);
+ }
- if (v_ptr)
+ if (v_ptr) {
vp8_mbloop_filter_horizontal_edge_c(v_ptr, uv_stride, lfi->mblim, lfi->lim,
lfi->hev_thr, 1);
+ }
}
/* Vertical MB Filtering */
vp8_mbloop_filter_vertical_edge_c(y_ptr, y_stride, lfi->mblim, lfi->lim,
lfi->hev_thr, 2);
- if (u_ptr)
+ if (u_ptr) {
vp8_mbloop_filter_vertical_edge_c(u_ptr, uv_stride, lfi->mblim, lfi->lim,
lfi->hev_thr, 1);
+ }
- if (v_ptr)
+ if (v_ptr) {
vp8_mbloop_filter_vertical_edge_c(v_ptr, uv_stride, lfi->mblim, lfi->lim,
lfi->hev_thr, 1);
+ }
}
/* Horizontal B Filtering */
vp8_loop_filter_horizontal_edge_c(y_ptr + 12 * y_stride, y_stride, lfi->blim,
lfi->lim, lfi->hev_thr, 2);
- if (u_ptr)
+ if (u_ptr) {
vp8_loop_filter_horizontal_edge_c(u_ptr + 4 * uv_stride, uv_stride,
lfi->blim, lfi->lim, lfi->hev_thr, 1);
+ }
- if (v_ptr)
+ if (v_ptr) {
vp8_loop_filter_horizontal_edge_c(v_ptr + 4 * uv_stride, uv_stride,
lfi->blim, lfi->lim, lfi->hev_thr, 1);
+ }
}
void vp8_loop_filter_bhs_c(unsigned char *y_ptr, int y_stride,
vp8_loop_filter_vertical_edge_c(y_ptr + 12, y_stride, lfi->blim, lfi->lim,
lfi->hev_thr, 2);
- if (u_ptr)
+ if (u_ptr) {
vp8_loop_filter_vertical_edge_c(u_ptr + 4, uv_stride, lfi->blim, lfi->lim,
lfi->hev_thr, 1);
+ }
- if (v_ptr)
+ if (v_ptr) {
vp8_loop_filter_vertical_edge_c(v_ptr + 4, uv_stride, lfi->blim, lfi->lim,
lfi->hev_thr, 1);
+ }
}
void vp8_loop_filter_bvs_c(unsigned char *y_ptr, int y_stride,
{
vp8_copy_mem8x8(y, y_stride, yd, yd_stride);
for (up = u, udp = ud, i = 0; i < uvblksize;
- ++i, up += uv_stride, udp += uvd_stride)
+ ++i, up += uv_stride, udp += uvd_stride) {
memcpy(udp, up, uvblksize);
+ }
for (vp = v, vdp = vd, i = 0; i < uvblksize;
- ++i, vp += uv_stride, vdp += uvd_stride)
+ ++i, vp += uv_stride, vdp += uvd_stride) {
memcpy(vdp, vp, uvblksize);
+ }
}
}
}
static int qualify_inter_mb(const MODE_INFO *mode_info_context, int *map) {
- if (mode_info_context->mbmi.mb_skip_coeff)
+ if (mode_info_context->mbmi.mb_skip_coeff) {
map[0] = map[1] = map[2] = map[3] = 1;
- else if (mode_info_context->mbmi.mode == SPLITMV) {
+ } else if (mode_info_context->mbmi.mode == SPLITMV) {
static int ndx[4][4] = {
{ 0, 1, 4, 5 }, { 2, 3, 6, 7 }, { 8, 9, 12, 13 }, { 10, 11, 14, 15 }
};
int i, j;
for (i = 0; i < 4; ++i) {
map[i] = 1;
- for (j = 0; j < 4 && map[j]; ++j)
+ for (j = 0; j < 4 && map[j]; ++j) {
map[i] &= (mode_info_context->bmi[ndx[i][j]].mv.as_mv.row <= 2 &&
mode_info_context->bmi[ndx[i][j]].mv.as_mv.col <= 2);
+ }
}
} else {
map[0] = map[1] = map[2] = map[3] =
for (mb_row = 0; mb_row < cm->mb_rows; ++mb_row) {
for (mb_col = 0; mb_col < cm->mb_cols; ++mb_col) {
/* if motion is high there will likely be no benefit */
- if (frame_type == INTER_FRAME)
+ if (frame_type == INTER_FRAME) {
totmap = qualify_inter_mb(mode_info_context, map);
- else
+ } else {
totmap = (frame_type == KEY_FRAME ? 4 : 0);
+ }
if (totmap) {
if (totmap < 4) {
int i, j;
- for (i = 0; i < 2; ++i)
+ for (i = 0; i < 2; ++i) {
for (j = 0; j < 2; ++j) {
if (map[i * 2 + j]) {
multiframe_quality_enhance_block(
}
}
}
+ }
} else /* totmap = 4 */
{
multiframe_quality_enhance_block(
for (mbc = 0; mbc < cm->mb_cols; ++mbc) {
unsigned char mb_ppl;
- if (mode_info_context->mbmi.mb_skip_coeff)
+ if (mode_info_context->mbmi.mb_skip_coeff) {
mb_ppl = (unsigned char)ppl >> 1;
- else
+ } else {
mb_ppl = (unsigned char)ppl;
+ }
memset(ylptr, mb_ppl, 16);
memset(uvlptr, mb_ppl, 8);
int height = (oci->Height + 15) & ~15;
if (vp8_yv12_alloc_frame_buffer(&oci->post_proc_buffer_int, width, height,
- VP8BORDERINPIXELS))
+ VP8BORDERINPIXELS)) {
vpx_internal_error(&oci->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate MFQE framebuffer");
+ }
oci->post_proc_buffer_int_used = 1;
QIndex = QIndex + Delta;
- if (QIndex > 127)
+ if (QIndex > 127) {
QIndex = 127;
- else if (QIndex < 0)
+ } else if (QIndex < 0) {
QIndex = 0;
+ }
retval = dc_qlookup[QIndex];
return retval;
QIndex = QIndex + Delta;
- if (QIndex > 127)
+ if (QIndex > 127) {
QIndex = 127;
- else if (QIndex < 0)
+ } else if (QIndex < 0) {
QIndex = 0;
+ }
retval = dc_qlookup[QIndex] * 2;
return retval;
QIndex = QIndex + Delta;
- if (QIndex > 127)
+ if (QIndex > 127) {
QIndex = 127;
- else if (QIndex < 0)
+ } else if (QIndex < 0) {
QIndex = 0;
+ }
retval = dc_qlookup[QIndex];
int vp8_ac_yquant(int QIndex) {
int retval;
- if (QIndex > 127)
+ if (QIndex > 127) {
QIndex = 127;
- else if (QIndex < 0)
+ } else if (QIndex < 0) {
QIndex = 0;
+ }
retval = ac_qlookup[QIndex];
return retval;
QIndex = QIndex + Delta;
- if (QIndex > 127)
+ if (QIndex > 127) {
QIndex = 127;
- else if (QIndex < 0)
+ } else if (QIndex < 0) {
QIndex = 0;
+ }
/* For all x in [0..284], x*155/100 is bitwise equal to (x*101581) >> 16.
* The smallest precision for that is '(x*6349) >> 12' but 16 is a good
QIndex = QIndex + Delta;
- if (QIndex > 127)
+ if (QIndex > 127) {
QIndex = 127;
- else if (QIndex < 0)
+ } else if (QIndex < 0) {
QIndex = 0;
+ }
retval = ac_qlookup[QIndex];
return retval;
BLOCKD *d0 = &x->block[i];
BLOCKD *d1 = &x->block[i + 1];
- if (d0->bmi.mv.as_int == d1->bmi.mv.as_int)
+ if (d0->bmi.mv.as_int == d1->bmi.mv.as_int) {
build_inter_predictors2b(x, d0, d0->predictor, 8, base_pre, pre_stride);
- else {
+ } else {
vp8_build_inter_predictors_b(d0, 8, base_pre, pre_stride,
x->subpixel_predict);
vp8_build_inter_predictors_b(d1, 8, base_pre, pre_stride,
BLOCKD *d0 = &x->block[i];
BLOCKD *d1 = &x->block[i + 1];
- if (d0->bmi.mv.as_int == d1->bmi.mv.as_int)
+ if (d0->bmi.mv.as_int == d1->bmi.mv.as_int) {
build_inter_predictors2b(x, d0, d0->predictor, 8, base_pre, pre_stride);
- else {
+ } else {
vp8_build_inter_predictors_b(d0, 8, base_pre, pre_stride,
x->subpixel_predict);
vp8_build_inter_predictors_b(d1, 8, base_pre, pre_stride,
* filtering. The bottom and right edges use 16 pixels plus 2 pixels
* left of the central pixel when filtering.
*/
- if (mv->col < (xd->mb_to_left_edge - (19 << 3)))
+ if (mv->col < (xd->mb_to_left_edge - (19 << 3))) {
mv->col = xd->mb_to_left_edge - (16 << 3);
- else if (mv->col > xd->mb_to_right_edge + (18 << 3))
+ } else if (mv->col > xd->mb_to_right_edge + (18 << 3)) {
mv->col = xd->mb_to_right_edge + (16 << 3);
+ }
- if (mv->row < (xd->mb_to_top_edge - (19 << 3)))
+ if (mv->row < (xd->mb_to_top_edge - (19 << 3))) {
mv->row = xd->mb_to_top_edge - (16 << 3);
- else if (mv->row > xd->mb_to_bottom_edge + (18 << 3))
+ } else if (mv->row > xd->mb_to_bottom_edge + (18 << 3)) {
mv->row = xd->mb_to_bottom_edge + (16 << 3);
+ }
}
/* A version of the above function for chroma block MVs.*/
clamp_mv_to_umv_border(&x->block[i + 1].bmi.mv.as_mv, x);
}
- if (d0->bmi.mv.as_int == d1->bmi.mv.as_int)
+ if (d0->bmi.mv.as_int == d1->bmi.mv.as_int) {
build_inter_predictors2b(x, d0, base_dst + d0->offset, dst_stride,
base_pre, dst_stride);
- else {
+ } else {
build_inter_predictors_b(d0, base_dst + d0->offset, dst_stride,
base_pre, dst_stride, x->subpixel_predict);
build_inter_predictors_b(d1, base_dst + d1->offset, dst_stride,
/* Note: uv mvs already clamped in build_4x4uvmvs() */
- if (d0->bmi.mv.as_int == d1->bmi.mv.as_int)
+ if (d0->bmi.mv.as_int == d1->bmi.mv.as_int) {
build_inter_predictors2b(x, d0, base_dst + d0->offset, dst_stride,
base_pre, dst_stride);
- else {
+ } else {
build_inter_predictors_b(d0, base_dst + d0->offset, dst_stride, base_pre,
dst_stride, x->subpixel_predict);
build_inter_predictors_b(d1, base_dst + d1->offset, dst_stride, base_pre,
/* Note: uv mvs already clamped in build_4x4uvmvs() */
- if (d0->bmi.mv.as_int == d1->bmi.mv.as_int)
+ if (d0->bmi.mv.as_int == d1->bmi.mv.as_int) {
build_inter_predictors2b(x, d0, base_dst + d0->offset, dst_stride,
base_pre, dst_stride);
- else {
+ } else {
build_inter_predictors_b(d0, base_dst + d0->offset, dst_stride, base_pre,
dst_stride, x->subpixel_predict);
build_inter_predictors_b(d1, base_dst + d1->offset, dst_stride, base_pre,
x->block[uoffset].bmi.mv.as_mv.col = (temp / 8) & x->fullpixel_mask;
- if (x->mode_info_context->mbmi.need_to_clamp_mvs)
+ if (x->mode_info_context->mbmi.need_to_clamp_mvs) {
clamp_uvmv_to_umv_border(&x->block[uoffset].bmi.mv.as_mv, x);
+ }
x->block[voffset].bmi.mv.as_int = x->block[uoffset].bmi.mv.as_int;
}
/* set up frame new frame for intra coded blocks */
memset(ybf->y_buffer - 1 - ybf->y_stride, 127, ybf->y_width + 5);
- for (i = 0; i < ybf->y_height; ++i)
+ for (i = 0; i < ybf->y_height; ++i) {
ybf->y_buffer[ybf->y_stride * i - 1] = (unsigned char)129;
+ }
memset(ybf->u_buffer - 1 - ybf->uv_stride, 127, ybf->uv_width + 5);
- for (i = 0; i < ybf->uv_height; ++i)
+ for (i = 0; i < ybf->uv_height; ++i) {
ybf->u_buffer[ybf->uv_stride * i - 1] = (unsigned char)129;
+ }
memset(ybf->v_buffer - 1 - ybf->uv_stride, 127, ybf->uv_width + 5);
- for (i = 0; i < ybf->uv_height; ++i)
+ for (i = 0; i < ybf->uv_height; ++i) {
ybf->v_buffer[ybf->uv_stride * i - 1] = (unsigned char)129;
+ }
}
void vp8_setup_intra_recon_top_line(YV12_BUFFER_CONFIG *ybf) {
if (j <= 0) {
p[-j].value = v;
p[-j].Len = L;
- } else
+ } else {
tree2tok(p, t, j, v, L);
+ }
} while (++v & 1);
}
if (tot) {
const unsigned int p = ((c[0] * Pfac) + (rd ? tot >> 1 : 0)) / tot;
probs[t] = p < 256 ? (p ? p : 1) : 255; /* agree w/old version for now */
- } else
+ } else {
probs[t] = vp8_prob_half;
+ }
} while (++t < tree_len);
}
block_inside_limit = block_inside_limit >> (sharpness_lvl > 4);
if (sharpness_lvl > 0) {
- if (block_inside_limit > (9 - sharpness_lvl))
+ if (block_inside_limit > (9 - sharpness_lvl)) {
block_inside_limit = (9 - sharpness_lvl);
+ }
}
if (block_inside_limit < 1) block_inside_limit = 1;
int i;
for (i = 0; i < 4; ++i) {
- if (eobs[0] > 1)
+ if (eobs[0] > 1) {
vp8_dequant_idct_add_mmx(q, dq, dst, stride);
- else if (eobs[0] == 1) {
+ } else if (eobs[0] == 1) {
vp8_dc_only_idct_add_mmx(q[0] * dq[0], dst, stride, dst, stride);
memset(q, 0, 2 * sizeof(q[0]));
}
- if (eobs[1] > 1)
+ if (eobs[1] > 1) {
vp8_dequant_idct_add_mmx(q + 16, dq, dst + 4, stride);
- else if (eobs[1] == 1) {
+ } else if (eobs[1] == 1) {
vp8_dc_only_idct_add_mmx(q[16] * dq[0], dst + 4, stride, dst + 4, stride);
memset(q + 16, 0, 2 * sizeof(q[0]));
}
- if (eobs[2] > 1)
+ if (eobs[2] > 1) {
vp8_dequant_idct_add_mmx(q + 32, dq, dst + 8, stride);
- else if (eobs[2] == 1) {
+ } else if (eobs[2] == 1) {
vp8_dc_only_idct_add_mmx(q[32] * dq[0], dst + 8, stride, dst + 8, stride);
memset(q + 32, 0, 2 * sizeof(q[0]));
}
- if (eobs[3] > 1)
+ if (eobs[3] > 1) {
vp8_dequant_idct_add_mmx(q + 48, dq, dst + 12, stride);
- else if (eobs[3] == 1) {
+ } else if (eobs[3] == 1) {
vp8_dc_only_idct_add_mmx(q[48] * dq[0], dst + 12, stride, dst + 12,
stride);
memset(q + 48, 0, 2 * sizeof(q[0]));
int i;
for (i = 0; i < 2; ++i) {
- if (eobs[0] > 1)
+ if (eobs[0] > 1) {
vp8_dequant_idct_add_mmx(q, dq, dstu, stride);
- else if (eobs[0] == 1) {
+ } else if (eobs[0] == 1) {
vp8_dc_only_idct_add_mmx(q[0] * dq[0], dstu, stride, dstu, stride);
memset(q, 0, 2 * sizeof(q[0]));
}
- if (eobs[1] > 1)
+ if (eobs[1] > 1) {
vp8_dequant_idct_add_mmx(q + 16, dq, dstu + 4, stride);
- else if (eobs[1] == 1) {
+ } else if (eobs[1] == 1) {
vp8_dc_only_idct_add_mmx(q[16] * dq[0], dstu + 4, stride, dstu + 4,
stride);
memset(q + 16, 0, 2 * sizeof(q[0]));
}
for (i = 0; i < 2; ++i) {
- if (eobs[0] > 1)
+ if (eobs[0] > 1) {
vp8_dequant_idct_add_mmx(q, dq, dstv, stride);
- else if (eobs[0] == 1) {
+ } else if (eobs[0] == 1) {
vp8_dc_only_idct_add_mmx(q[0] * dq[0], dstv, stride, dstv, stride);
memset(q, 0, 2 * sizeof(q[0]));
}
- if (eobs[1] > 1)
+ if (eobs[1] > 1) {
vp8_dequant_idct_add_mmx(q + 16, dq, dstv + 4, stride);
- else if (eobs[1] == 1) {
+ } else if (eobs[1] == 1) {
vp8_dc_only_idct_add_mmx(q[16] * dq[0], dstv + 4, stride, dstv + 4,
stride);
memset(q + 16, 0, 2 * sizeof(q[0]));
for (i = 0; i < 4; ++i) {
if (((short *)(eobs))[0]) {
- if (((short *)(eobs))[0] & 0xfefe)
+ if (((short *)(eobs))[0] & 0xfefe) {
vp8_idct_dequant_full_2x_sse2(q, dq, dst, stride);
- else
+ } else {
vp8_idct_dequant_0_2x_sse2(q, dq, dst, stride);
+ }
}
if (((short *)(eobs))[1]) {
- if (((short *)(eobs))[1] & 0xfefe)
+ if (((short *)(eobs))[1] & 0xfefe) {
vp8_idct_dequant_full_2x_sse2(q + 32, dq, dst + 8, stride);
- else
+ } else {
vp8_idct_dequant_0_2x_sse2(q + 32, dq, dst + 8, stride);
+ }
}
q += 64;
dst += stride * 4;
unsigned char *dstv, int stride,
char *eobs) {
if (((short *)(eobs))[0]) {
- if (((short *)(eobs))[0] & 0xfefe)
+ if (((short *)(eobs))[0] & 0xfefe) {
vp8_idct_dequant_full_2x_sse2(q, dq, dstu, stride);
- else
+ } else {
vp8_idct_dequant_0_2x_sse2(q, dq, dstu, stride);
+ }
}
q += 32;
dstu += stride * 4;
if (((short *)(eobs))[1]) {
- if (((short *)(eobs))[1] & 0xfefe)
+ if (((short *)(eobs))[1] & 0xfefe) {
vp8_idct_dequant_full_2x_sse2(q, dq, dstu, stride);
- else
+ } else {
vp8_idct_dequant_0_2x_sse2(q, dq, dstu, stride);
+ }
}
q += 32;
if (((short *)(eobs))[2]) {
- if (((short *)(eobs))[2] & 0xfefe)
+ if (((short *)(eobs))[2] & 0xfefe) {
vp8_idct_dequant_full_2x_sse2(q, dq, dstv, stride);
- else
+ } else {
vp8_idct_dequant_0_2x_sse2(q, dq, dstv, stride);
+ }
}
q += 32;
dstv += stride * 4;
if (((short *)(eobs))[3]) {
- if (((short *)(eobs))[3] & 0xfefe)
+ if (((short *)(eobs))[3] & 0xfefe) {
vp8_idct_dequant_full_2x_sse2(q, dq, dstv, stride);
- else
+ } else {
vp8_idct_dequant_0_2x_sse2(q, dq, dstv, stride);
+ }
}
}
vp8_mbloop_filter_horizontal_edge_mmx(y_ptr, y_stride, lfi->mblim, lfi->lim,
lfi->hev_thr, 2);
- if (u_ptr)
+ if (u_ptr) {
vp8_mbloop_filter_horizontal_edge_mmx(u_ptr, uv_stride, lfi->mblim,
lfi->lim, lfi->hev_thr, 1);
+ }
- if (v_ptr)
+ if (v_ptr) {
vp8_mbloop_filter_horizontal_edge_mmx(v_ptr, uv_stride, lfi->mblim,
lfi->lim, lfi->hev_thr, 1);
+ }
}
/* Vertical MB Filtering */
vp8_mbloop_filter_vertical_edge_mmx(y_ptr, y_stride, lfi->mblim, lfi->lim,
lfi->hev_thr, 2);
- if (u_ptr)
+ if (u_ptr) {
vp8_mbloop_filter_vertical_edge_mmx(u_ptr, uv_stride, lfi->mblim, lfi->lim,
lfi->hev_thr, 1);
+ }
- if (v_ptr)
+ if (v_ptr) {
vp8_mbloop_filter_vertical_edge_mmx(v_ptr, uv_stride, lfi->mblim, lfi->lim,
lfi->hev_thr, 1);
+ }
}
/* Horizontal B Filtering */
vp8_loop_filter_horizontal_edge_mmx(y_ptr + 12 * y_stride, y_stride,
lfi->blim, lfi->lim, lfi->hev_thr, 2);
- if (u_ptr)
+ if (u_ptr) {
vp8_loop_filter_horizontal_edge_mmx(u_ptr + 4 * uv_stride, uv_stride,
lfi->blim, lfi->lim, lfi->hev_thr, 1);
+ }
- if (v_ptr)
+ if (v_ptr) {
vp8_loop_filter_horizontal_edge_mmx(v_ptr + 4 * uv_stride, uv_stride,
lfi->blim, lfi->lim, lfi->hev_thr, 1);
+ }
}
void vp8_loop_filter_bhs_mmx(unsigned char *y_ptr, int y_stride,
vp8_loop_filter_vertical_edge_mmx(y_ptr + 12, y_stride, lfi->blim, lfi->lim,
lfi->hev_thr, 2);
- if (u_ptr)
+ if (u_ptr) {
vp8_loop_filter_vertical_edge_mmx(u_ptr + 4, uv_stride, lfi->blim, lfi->lim,
lfi->hev_thr, 1);
+ }
- if (v_ptr)
+ if (v_ptr) {
vp8_loop_filter_vertical_edge_mmx(v_ptr + 4, uv_stride, lfi->blim, lfi->lim,
lfi->hev_thr, 1);
+ }
}
void vp8_loop_filter_bvs_mmx(unsigned char *y_ptr, int y_stride,
vp8_mbloop_filter_horizontal_edge_sse2(y_ptr, y_stride, lfi->mblim, lfi->lim,
lfi->hev_thr);
- if (u_ptr)
+ if (u_ptr) {
vp8_mbloop_filter_horizontal_edge_uv_sse2(u_ptr, uv_stride, lfi->mblim,
lfi->lim, lfi->hev_thr, v_ptr);
+ }
}
/* Vertical MB Filtering */
vp8_mbloop_filter_vertical_edge_sse2(y_ptr, y_stride, lfi->mblim, lfi->lim,
lfi->hev_thr);
- if (u_ptr)
+ if (u_ptr) {
vp8_mbloop_filter_vertical_edge_uv_sse2(u_ptr, uv_stride, lfi->mblim,
lfi->lim, lfi->hev_thr, v_ptr);
+ }
}
/* Horizontal B Filtering */
lfi->blim, lfi->lim, lfi->hev_thr);
#endif
- if (u_ptr)
+ if (u_ptr) {
vp8_loop_filter_horizontal_edge_uv_sse2(u_ptr + 4 * uv_stride, uv_stride,
lfi->blim, lfi->lim, lfi->hev_thr,
v_ptr + 4 * uv_stride);
+ }
}
void vp8_loop_filter_bhs_sse2(unsigned char *y_ptr, int y_stride,
lfi->hev_thr);
#endif
- if (u_ptr)
+ if (u_ptr) {
vp8_loop_filter_vertical_edge_uv_sse2(u_ptr + 4, uv_stride, lfi->blim,
lfi->lim, lfi->hev_thr, v_ptr + 4);
+ }
}
void vp8_loop_filter_bvs_sse2(unsigned char *y_ptr, int y_stride,
/* Decide whether to use the default or alternate baseline Q value. */
if (xd->segmentation_enabled) {
/* Abs Value */
- if (xd->mb_segement_abs_delta == SEGMENT_ABSDATA)
+ if (xd->mb_segement_abs_delta == SEGMENT_ABSDATA) {
QIndex = xd->segment_feature_data[MB_LVL_ALT_Q][mbmi->segment_id];
- /* Delta Value */
- else
+ /* Delta Value */
+ } else {
QIndex = pc->base_qindex +
xd->segment_feature_data[MB_LVL_ALT_Q][mbmi->segment_id];
+ }
QIndex = (QIndex >= 0) ? ((QIndex <= MAXQ) ? QIndex : MAXQ)
: 0; /* Clamp to valid range */
- } else
+ } else {
QIndex = pc->base_qindex;
+ }
/* Set up the macroblock dequant constants */
xd->dequant_y1_dc[0] = 1;
if (pc->filter_level) {
if (mb_row > 0) {
- if (pc->filter_type == NORMAL_LOOPFILTER)
+ if (pc->filter_type == NORMAL_LOOPFILTER) {
vp8_loop_filter_row_normal(pc, lf_mic, mb_row - 1, recon_y_stride,
recon_uv_stride, lf_dst[0], lf_dst[1],
lf_dst[2]);
- else
+ } else {
vp8_loop_filter_row_simple(pc, lf_mic, mb_row - 1, recon_y_stride,
recon_uv_stride, lf_dst[0], lf_dst[1],
lf_dst[2]);
+ }
if (mb_row > 1) {
yv12_extend_frame_left_right_c(yv12_fb_new, eb_dst[0], eb_dst[1],
eb_dst[2]);
}
if (pc->filter_level) {
- if (pc->filter_type == NORMAL_LOOPFILTER)
+ if (pc->filter_type == NORMAL_LOOPFILTER) {
vp8_loop_filter_row_normal(pc, lf_mic, mb_row - 1, recon_y_stride,
recon_uv_stride, lf_dst[0], lf_dst[1],
lf_dst[2]);
- else
+ } else {
vp8_loop_filter_row_simple(pc, lf_mic, mb_row - 1, recon_y_stride,
recon_uv_stride, lf_dst[0], lf_dst[1],
lf_dst[2]);
+ }
yv12_extend_frame_left_right_c(yv12_fb_new, eb_dst[0], eb_dst[1],
eb_dst[2]);
* or throw an error.
*/
if (i < num_part - 1) {
- if (read_is_valid(partition_size_ptr, 3, first_fragment_end))
+ if (read_is_valid(partition_size_ptr, 3, first_fragment_end)) {
partition_size = read_partition_size(pbi, partition_size_ptr);
- else if (pbi->ec_active)
+ } else if (pbi->ec_active) {
partition_size = (unsigned int)bytes_left;
- else
+ } else {
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
"Truncated partition size data");
- } else
+ }
+ } else {
partition_size = (unsigned int)bytes_left;
+ }
/* Validate the calculated partition length. If the buffer
* described by the partition can't be fully read, then restrict
* it to the portion that can be (for EC mode) or throw an error.
*/
if (!read_is_valid(fragment_start, partition_size, fragment_end)) {
- if (pbi->ec_active)
+ if (pbi->ec_active) {
partition_size = (unsigned int)bytes_left;
- else
+ } else {
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
"Truncated packet or corrupt partition "
"%d length",
i + 1);
+ }
}
return partition_size;
}
TOKEN_PARTITION multi_token_partition =
(TOKEN_PARTITION)vp8_read_literal(&pbi->mbc[8], 2);
- if (!vp8dx_bool_error(&pbi->mbc[8]))
+ if (!vp8dx_bool_error(&pbi->mbc[8])) {
pbi->common.multi_token_partition = multi_token_partition;
+ }
num_token_partitions = 1 << pbi->common.multi_token_partition;
/* Check for partitions within the fragments and unpack the fragments
++partition_idx) {
if (vp8dx_start_decode(bool_decoder, pbi->fragments.ptrs[partition_idx],
pbi->fragments.sizes[partition_idx], pbi->decrypt_cb,
- pbi->decrypt_state))
+ pbi->decrypt_state)) {
vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR,
"Failed to allocate bool decoder %d", partition_idx);
+ }
bool_decoder++;
}
#if CONFIG_MULTITHREAD
/* Clamp number of decoder threads */
- if (pbi->decoding_thread_count > num_token_partitions - 1)
+ if (pbi->decoding_thread_count > num_token_partitions - 1) {
pbi->decoding_thread_count = num_token_partitions - 1;
+ }
#endif
}
xd->subpixel_predict16x16 = vp8_bilinear_predict16x16;
}
- if (pbi->decoded_key_frame && pbi->ec_enabled && !pbi->ec_active)
+ if (pbi->decoded_key_frame && pbi->ec_enabled && !pbi->ec_active) {
pbi->ec_active = 1;
+ }
}
xd->left_context = &pc->left_context;
(clear[0] | (clear[1] << 8) | (clear[2] << 16)) >> 5;
if (!pbi->ec_active && (data + first_partition_length_in_bytes > data_end ||
- data + first_partition_length_in_bytes < data))
+ data + first_partition_length_in_bytes < data)) {
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
"Truncated packet or corrupt partition 0 length");
+ }
data += 3;
clear += 3;
* code if we have enough bits available
*/
if (!pbi->ec_active || data + 3 < data_end) {
- if (clear[0] != 0x9d || clear[1] != 0x01 || clear[2] != 0x2a)
+ if (clear[0] != 0x9d || clear[1] != 0x01 || clear[2] != 0x2a) {
vpx_internal_error(&pc->error, VPX_CODEC_UNSUP_BITSTREAM,
"Invalid frame sync code");
+ }
}
/* If error concealment is enabled we should only parse the new size
init_frame(pbi);
if (vp8dx_start_decode(bc, data, (unsigned int)(data_end - data),
- pbi->decrypt_cb, pbi->decrypt_state))
+ pbi->decrypt_cb, pbi->decrypt_state)) {
vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate bool decoder 0");
+ }
if (pc->frame_type == KEY_FRAME) {
(void)vp8_read_bit(bc); // colorspace
pc->clamp_type = (CLAMP_TYPE)vp8_read_bit(bc);
xd->segment_feature_data[i][j] =
(signed char)vp8_read_literal(bc, mb_feature_data_bits[i]);
- if (vp8_read_bit(bc))
+ if (vp8_read_bit(bc)) {
xd->segment_feature_data[i][j] = -xd->segment_feature_data[i][j];
- } else
+ }
+ } else {
xd->segment_feature_data[i][j] = 0;
+ }
}
}
}
/* Read the probs used to decode the segment id for each macro block. */
for (i = 0; i < MB_FEATURE_TREE_PROBS; ++i) {
/* If not explicitly set value is defaulted to 255 by memset above */
- if (vp8_read_bit(bc))
+ if (vp8_read_bit(bc)) {
xd->mb_segment_tree_probs[i] = (vp8_prob)vp8_read_literal(bc, 8);
+ }
}
}
} else {
/*sign = vp8_read_bit( bc );*/
xd->ref_lf_deltas[i] = (signed char)vp8_read_literal(bc, 6);
- if (vp8_read_bit(bc)) /* Apply sign */
+ if (vp8_read_bit(bc)) { /* Apply sign */
xd->ref_lf_deltas[i] = xd->ref_lf_deltas[i] * -1;
+ }
}
}
/*sign = vp8_read_bit( bc );*/
xd->mode_lf_deltas[i] = (signed char)vp8_read_literal(bc, 6);
- if (vp8_read_bit(bc)) /* Apply sign */
+ if (vp8_read_bit(bc)) { /* Apply sign */
xd->mode_lf_deltas[i] = xd->mode_lf_deltas[i] * -1;
+ }
}
}
}
/* Buffer to buffer copy flags. */
pc->copy_buffer_to_gf = 0;
- if (!pc->refresh_golden_frame)
+ if (!pc->refresh_golden_frame) {
pc->copy_buffer_to_gf = vp8_read_literal(bc, 2);
+ }
#if CONFIG_ERROR_CONCEALMENT
/* Assume we shouldn't copy to the golden if the bit is missing */
pc->copy_buffer_to_arf = 0;
- if (!pc->refresh_alt_ref_frame)
+ if (!pc->refresh_alt_ref_frame) {
pc->copy_buffer_to_arf = vp8_read_literal(bc, 2);
+ }
#if CONFIG_ERROR_CONCEALMENT
/* Assume we shouldn't copy to the alt-ref if the bit is missing */
pbi->independent_partitions = 1;
/* read coef probability tree */
- for (i = 0; i < BLOCK_TYPES; ++i)
- for (j = 0; j < COEF_BANDS; ++j)
- for (k = 0; k < PREV_COEF_CONTEXTS; ++k)
+ for (i = 0; i < BLOCK_TYPES; ++i) {
+ for (j = 0; j < COEF_BANDS; ++j) {
+ for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
for (l = 0; l < ENTROPY_NODES; ++l) {
vp8_prob *const p = pc->fc.coef_probs[i][j][k] + l;
if (vp8_read(bc, vp8_coef_update_probs[i][j][k][l])) {
*p = (vp8_prob)vp8_read_literal(bc, 8);
}
- if (k > 0 && *p != pc->fc.coef_probs[i][j][k - 1][l])
+ if (k > 0 && *p != pc->fc.coef_probs[i][j][k - 1][l]) {
pbi->independent_partitions = 0;
+ }
}
+ }
+ }
+ }
}
/* clear out the coeff buffer */
unsigned int thread;
vp8mt_decode_mb_rows(pbi, xd);
vp8_yv12_extend_frame_borders(yv12_fb_new);
- for (thread = 0; thread < pbi->decoding_thread_count; ++thread)
+ for (thread = 0; thread < pbi->decoding_thread_count; ++thread) {
corrupt_tokens |= pbi->mb_row_di[thread].mbd.corrupted;
+ }
} else
#endif
{
yv12_fb_new->corrupted |= corrupt_tokens;
if (!pbi->decoded_key_frame) {
- if (pc->frame_type == KEY_FRAME && !yv12_fb_new->corrupted)
+ if (pc->frame_type == KEY_FRAME && !yv12_fb_new->corrupted) {
pbi->decoded_key_frame = 1;
- else
+ } else {
vpx_internal_error(&pbi->common.error, VPX_CODEC_CORRUPT_FRAME,
"A stream must start with a complete key frame");
+ }
}
/* vpx_log("Decoder: Frame Decoded, Size Roughly:%d bytes
} while (--i > 3);
if (!(x & 0xFFF0) || vp8_read(r, p[MVPbits + 3])) x += 8;
- } else /* small */
+ } else { /* small */
x = vp8_treed_read(r, vp8_small_mvtree, p + MVPshort);
+ }
if (x && vp8_read(r, p[MVPsign])) x = -x;
pbi->common.mb_no_coeff_skip = (int)vp8_read_bit(bc);
pbi->prob_skip_false = 0;
- if (pbi->common.mb_no_coeff_skip)
+ if (pbi->common.mb_no_coeff_skip) {
pbi->prob_skip_false = (vp8_prob)vp8_read_literal(bc, 8);
+ }
if (pbi->common.frame_type != KEY_FRAME) {
pbi->prob_intra = (vp8_prob)vp8_read_literal(bc, 8);
if (!(k & 3)) {
/* On L edge, get from MB to left of us */
- if (left_mb->mbmi.mode != SPLITMV)
+ if (left_mb->mbmi.mode != SPLITMV) {
leftmv.as_int = left_mb->mbmi.mv.as_int;
- else
+ } else {
leftmv.as_int = (left_mb->bmi + k + 4 - 1)->mv.as_int;
- } else
+ }
+ } else {
leftmv.as_int = (mi->bmi + k - 1)->mv.as_int;
+ }
if (!(k >> 2)) {
/* On top edge, get from MB above us */
- if (above_mb->mbmi.mode != SPLITMV)
+ if (above_mb->mbmi.mode != SPLITMV) {
abovemv.as_int = above_mb->mbmi.mv.as_int;
- else
+ } else {
abovemv.as_int = (above_mb->bmi + k + 16 - 4)->mv.as_int;
- } else
+ }
+ } else {
abovemv.as_int = (mi->bmi + k - 4)->mv.as_int;
+ }
prob = get_sub_mv_ref_prob(leftmv.as_int, abovemv.as_int);
}
*cntx += 2;
- } else
+ } else {
cnt[CNT_INTRA] += 2;
+ }
}
/* Process above left */
}
*cntx += 1;
- } else
+ } else {
cnt[CNT_INTRA] += 1;
+ }
}
if (vp8_read(bc, vp8_mode_contexts[cnt[CNT_INTRA]][0])) {
/* Is segmentation enabled */
if (x->segmentation_enabled && x->update_mb_segmentation_map) {
/* If so then read the segment id. */
- if (vp8_read(r, x->mb_segment_tree_probs[0]))
+ if (vp8_read(r, x->mb_segment_tree_probs[0])) {
mi->segment_id =
(unsigned char)(2 + vp8_read(r, x->mb_segment_tree_probs[2]));
- else
+ } else {
mi->segment_id =
(unsigned char)(vp8_read(r, x->mb_segment_tree_probs[1]));
+ }
}
}
* this frame (reset to 0 above by default)
* By default on a key frame reset all MBs to segment 0
*/
- if (pbi->mb.update_mb_segmentation_map)
+ if (pbi->mb.update_mb_segmentation_map) {
read_mb_features(&pbi->mbc[8], &mi->mbmi, &pbi->mb);
- else if (pbi->common.frame_type == KEY_FRAME)
+ } else if (pbi->common.frame_type == KEY_FRAME) {
mi->mbmi.segment_id = 0;
+ }
/* Read the macroblock coeff skip flag if this feature is in use,
* else default to 0 */
- if (pbi->common.mb_no_coeff_skip)
+ if (pbi->common.mb_no_coeff_skip) {
mi->mbmi.mb_skip_coeff = vp8_read(&pbi->mbc[8], pbi->prob_skip_false);
- else
+ } else {
mi->mbmi.mb_skip_coeff = 0;
+ }
mi->mbmi.is_4x4 = 0;
- if (pbi->common.frame_type == KEY_FRAME)
+ if (pbi->common.frame_type == KEY_FRAME) {
read_kf_modes(pbi, mi);
- else
+ } else {
read_mb_modes_mv(pbi, mi, &mi->mbmi);
+ }
}
void vp8_decode_mode_mvs(VP8D_COMP *pbi) {
VP8_COMMON *cm = &pbi->common;
int ref_fb_idx;
- if (ref_frame_flag == VP8_LAST_FRAME)
+ if (ref_frame_flag == VP8_LAST_FRAME) {
ref_fb_idx = cm->lst_fb_idx;
- else if (ref_frame_flag == VP8_GOLD_FRAME)
+ } else if (ref_frame_flag == VP8_GOLD_FRAME) {
ref_fb_idx = cm->gld_fb_idx;
- else if (ref_frame_flag == VP8_ALTR_FRAME)
+ } else if (ref_frame_flag == VP8_ALTR_FRAME) {
ref_fb_idx = cm->alt_fb_idx;
- else {
+ } else {
vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR,
"Invalid reference frame");
return pbi->common.error.error_code;
int *ref_fb_ptr = NULL;
int free_fb;
- if (ref_frame_flag == VP8_LAST_FRAME)
+ if (ref_frame_flag == VP8_LAST_FRAME) {
ref_fb_ptr = &cm->lst_fb_idx;
- else if (ref_frame_flag == VP8_GOLD_FRAME)
+ } else if (ref_frame_flag == VP8_GOLD_FRAME) {
ref_fb_ptr = &cm->gld_fb_idx;
- else if (ref_frame_flag == VP8_ALTR_FRAME)
+ } else if (ref_frame_flag == VP8_ALTR_FRAME) {
ref_fb_ptr = &cm->alt_fb_idx;
- else {
+ } else {
vpx_internal_error(&pbi->common.error, VPX_CODEC_ERROR,
"Invalid reference frame");
return pbi->common.error.error_code;
static int get_free_fb(VP8_COMMON *cm) {
int i;
- for (i = 0; i < NUM_YV12_BUFFERS; ++i)
+ for (i = 0; i < NUM_YV12_BUFFERS; ++i) {
if (cm->fb_idx_ref_cnt[i] == 0) break;
+ }
assert(i < NUM_YV12_BUFFERS);
cm->fb_idx_ref_cnt[i] = 1;
if (cm->copy_buffer_to_arf) {
int new_fb = 0;
- if (cm->copy_buffer_to_arf == 1)
+ if (cm->copy_buffer_to_arf == 1) {
new_fb = cm->lst_fb_idx;
- else if (cm->copy_buffer_to_arf == 2)
+ } else if (cm->copy_buffer_to_arf == 2) {
new_fb = cm->gld_fb_idx;
- else
+ } else {
err = -1;
+ }
ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->alt_fb_idx, new_fb);
}
if (cm->copy_buffer_to_gf) {
int new_fb = 0;
- if (cm->copy_buffer_to_gf == 1)
+ if (cm->copy_buffer_to_gf == 1) {
new_fb = cm->lst_fb_idx;
- else if (cm->copy_buffer_to_gf == 2)
+ } else if (cm->copy_buffer_to_gf == 2) {
new_fb = cm->alt_fb_idx;
- else
+ } else {
err = -1;
+ }
ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->gld_fb_idx, new_fb);
}
- if (cm->refresh_golden_frame)
+ if (cm->refresh_golden_frame) {
ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->gld_fb_idx, cm->new_fb_idx);
+ }
- if (cm->refresh_alt_ref_frame)
+ if (cm->refresh_alt_ref_frame) {
ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->alt_fb_idx, cm->new_fb_idx);
+ }
if (cm->refresh_last_frame) {
ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->lst_fb_idx, cm->new_fb_idx);
cm->frame_to_show = &cm->yv12_fb[cm->lst_fb_idx];
- } else
+ } else {
cm->frame_to_show = &cm->yv12_fb[cm->new_fb_idx];
+ }
cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
*/
cm->yv12_fb[cm->lst_fb_idx].corrupted = 1;
- if (cm->fb_idx_ref_cnt[cm->new_fb_idx] > 0)
+ if (cm->fb_idx_ref_cnt[cm->new_fb_idx] > 0) {
cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
+ }
goto decode_exit;
}
retcode = vp8_decode_frame(pbi);
if (retcode < 0) {
- if (cm->fb_idx_ref_cnt[cm->new_fb_idx] > 0)
+ if (cm->fb_idx_ref_cnt[cm->new_fb_idx] > 0) {
cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
+ }
pbi->common.error.error_code = VPX_CODEC_ERROR;
goto decode_exit;
if (!pbi) return VPX_CODEC_ERROR;
#if CONFIG_MULTITHREAD
- if (pbi->b_multithreaded_rd)
+ if (pbi->b_multithreaded_rd) {
vp8mt_de_alloc_temp_buffers(pbi, pbi->common.mb_rows);
+ }
vp8_decoder_remove_threads(pbi);
#endif
/*Caution: For some b_mode, it needs 8 pixels (4 above + 4
* above-right).*/
- if (i < 4 && pbi->common.filter_level)
+ if (i < 4 && pbi->common.filter_level) {
Above = xd->recon_above[0] + b->offset;
- else
+ } else {
Above = dst - dst_stride;
+ }
if (i % 4 == 0 && pbi->common.filter_level) {
yleft = xd->recon_left[0] + i;
left_stride = dst_stride;
}
- if ((i == 4 || i == 8 || i == 12) && pbi->common.filter_level)
+ if ((i == 4 || i == 8 || i == 12) && pbi->common.filter_level) {
top_left = *(xd->recon_left[0] + i - 1);
- else
+ } else {
top_left = Above[-1];
+ }
vp8_intra4x4_predict(Above, yleft, left_stride, b_mode, dst, dst_stride,
top_left);
/* select bool coder for current partition */
xd->current_bc = &pbi->mbc[mb_row % num_part];
- if (mb_row > 0)
+ if (mb_row > 0) {
last_row_current_mb_col = &pbi->mt_current_mb_col[mb_row - 1];
- else
+ } else {
last_row_current_mb_col = &first_row_no_sync_above;
+ }
current_mb_col = &pbi->mt_current_mb_col[mb_row];
MODE_INFO *next = xd->mode_info_context + 1;
if (next->mbmi.ref_frame == INTRA_FRAME) {
- for (i = 0; i < 16; ++i)
+ for (i = 0; i < 16; ++i) {
pbi->mt_yleft_col[mb_row][i] =
xd->dst.y_buffer[i * recon_y_stride + 15];
+ }
for (i = 0; i < 8; ++i) {
pbi->mt_uleft_col[mb_row][i] =
xd->dst.u_buffer[i * recon_uv_stride + 7];
pbi->mt_vabove_row[mb_row + 1][lastuv - 1];
}
}
- } else
+ } else {
vp8_extend_mb_row(yv12_fb_new, xd->dst.y_buffer + 16,
xd->dst.u_buffer + 8, xd->dst.v_buffer + 8);
+ }
/* last MB of row is ready just after extension is done */
protected_write(&pbi->pmutex[mb_row], current_mb_col, mb_col + nsync);
if (protected_read(&pbi->mt_mutex, &pbi->b_multithreaded_rd) == 0) break;
if (sem_wait(&pbi->h_event_start_decoding[ithread]) == 0) {
- if (protected_read(&pbi->mt_mutex, &pbi->b_multithreaded_rd) == 0)
+ if (protected_read(&pbi->mt_mutex, &pbi->b_multithreaded_rd) == 0) {
break;
- else {
+ } else {
MACROBLOCKD *xd = &mbrd->mbd;
xd->left_context = &mb_row_left_context;
core_count = (pbi->max_threads > 8) ? 8 : pbi->max_threads;
/* limit decoding threads to the available cores */
- if (core_count > pbi->common.processor_core_count)
+ if (core_count > pbi->common.processor_core_count) {
core_count = pbi->common.processor_core_count;
+ }
if (core_count > 1) {
pbi->b_multithreaded_rd = 1;
/* our internal buffers are always multiples of 16 */
if ((width & 0xf) != 0) width += 16 - (width & 0xf);
- if (width < 640)
+ if (width < 640) {
pbi->sync_range = 1;
- else if (width <= 1280)
+ } else if (width <= 1280) {
pbi->sync_range = 8;
- else if (width <= 2560)
+ } else if (width <= 2560) {
pbi->sync_range = 16;
- else
+ } else {
pbi->sync_range = 32;
+ }
uv_width = width >> 1;
/* Initialize the loop filter for this frame. */
vp8_loop_filter_frame_init(pc, &pbi->mb, filter_level);
- } else
+ } else {
vp8_setup_intra_recon_top_line(yv12_fb_new);
+ }
setup_decoding_thread_data(pbi, xd, pbi->mb_row_di,
pbi->decoding_thread_count);
- for (i = 0; i < pbi->decoding_thread_count; ++i)
+ for (i = 0; i < pbi->decoding_thread_count; ++i) {
sem_post(&pbi->h_event_start_decoding[i]);
+ }
mt_decode_mb_rows(pbi, xd, 0);
rfct[LAST_FRAME] + rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME];
/* Calculate the probabilities used to code the ref frame based on usage */
- if (!(cpi->prob_intra_coded = rf_intra * 255 / (rf_intra + rf_inter)))
+ if (!(cpi->prob_intra_coded = rf_intra * 255 / (rf_intra + rf_inter))) {
cpi->prob_intra_coded = 1;
+ }
cpi->prob_last_coded = rf_inter ? (rfct[LAST_FRAME] * 255) / rf_inter : 128;
active_section = 9;
#endif
- if (cpi->mb.e_mbd.update_mb_segmentation_map)
+ if (cpi->mb.e_mbd.update_mb_segmentation_map) {
write_mb_features(w, mi, &cpi->mb.e_mbd);
+ }
- if (pc->mb_no_coeff_skip)
+ if (pc->mb_no_coeff_skip) {
vp8_encode_bool(w, m->mbmi.mb_skip_coeff, prob_skip_false);
+ }
if (rf == INTRA_FRAME) {
vp8_write(w, 0, cpi->prob_intra_coded);
if (mode == B_PRED) {
int j = 0;
- do
+ do {
write_bmode(w, m->bmi[j].as_mode, pc->fc.bmode_prob);
- while (++j < 16);
+ } while (++j < 16);
}
write_uv_mode(w, mi->uv_mode, pc->fc.uv_mode_prob);
blockmode = cpi->mb.partition_info->bmi[j].mode;
blockmv = cpi->mb.partition_info->bmi[j].mv;
#if CONFIG_DEBUG
- while (j != L[++k])
+ while (j != L[++k]) {
if (k >= 16) assert(0);
+ }
#else
while (j != L[++k])
;
while (++mb_col < c->mb_cols) {
const int ym = m->mbmi.mode;
- if (cpi->mb.e_mbd.update_mb_segmentation_map)
+ if (cpi->mb.e_mbd.update_mb_segmentation_map) {
write_mb_features(bc, &m->mbmi, &cpi->mb.e_mbd);
+ }
- if (c->mb_no_coeff_skip)
+ if (c->mb_no_coeff_skip) {
vp8_encode_bool(bc, m->mbmi.mb_skip_coeff, prob_skip_false);
+ }
kfwrite_ymode(bc, ym, vp8_kf_ymode_prob);
probs = (const unsigned int(*)[MAX_ENTROPY_TOKENS])x->coef_counts[i][j];
/* Reset to default probabilities at key frames */
- if (cpi->common.frame_type == KEY_FRAME)
+ if (cpi->common.frame_type == KEY_FRAME) {
probs = default_coef_counts[i][j];
+ }
sum_probs_over_prev_coef_context(probs, prev_coef_count_sum);
const int s = prob_update_savings(ct, oldp, newp, upd);
if (cpi->common.frame_type != KEY_FRAME ||
- (cpi->common.frame_type == KEY_FRAME && newp != oldp))
+ (cpi->common.frame_type == KEY_FRAME && newp != oldp)) {
prev_coef_savings[t] += s;
+ }
} while (++t < ENTROPY_NODES);
} while (++k < PREV_COEF_CONTEXTS);
k = 0;
* to get the equal probabilities across the prev coef
* contexts.
*/
- if (prev_coef_savings[k] > 0 || cpi->common.frame_type == KEY_FRAME)
+ if (prev_coef_savings[k] > 0 || cpi->common.frame_type == KEY_FRAME) {
savings += prev_coef_savings[k];
+ }
} while (++k < ENTROPY_NODES);
} while (++j < COEF_BANDS);
} while (++i < BLOCK_TYPES);
savings += (oldtotal - newtotal) / 256;
}
- if (cpi->oxcf.error_resilient_mode & VPX_ERROR_RESILIENT_PARTITIONS)
+ if (cpi->oxcf.error_resilient_mode & VPX_ERROR_RESILIENT_PARTITIONS) {
savings += independent_coef_context_savings(cpi);
- else
+ } else {
savings += default_coef_context_savings(cpi);
+ }
return savings;
}
*/
if ((cpi->oxcf.error_resilient_mode &
VPX_ERROR_RESILIENT_PARTITIONS) &&
- cpi->common.frame_type == KEY_FRAME && newp != *Pold)
+ cpi->common.frame_type == KEY_FRAME && newp != *Pold) {
u = 1;
+ }
#if CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING
cpi->update_probs[i][j][k][t] = u;
vp8_write_bit(bc, 0);
vp8_write_bit(bc, pc->clamp_type);
- } else
+ } else {
vp8_start_encode(bc, cx_data, cx_data_end);
+ }
/* Signal whether or not Segmentation is enabled */
vp8_write_bit(bc, xd->segmentation_enabled);
#if !(CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING)
if (cpi->oxcf.error_resilient_mode & VPX_ERROR_RESILIENT_PARTITIONS) {
- if (pc->frame_type == KEY_FRAME)
+ if (pc->frame_type == KEY_FRAME) {
pc->refresh_entropy_probs = 1;
- else
+ } else {
pc->refresh_entropy_probs = 0;
+ }
}
#endif
vp8_start_encode(&cpi->bc[1], cx_data, cx_data_end);
#if CONFIG_MULTITHREAD
- if (cpi->b_multi_threaded)
+ if (cpi->b_multi_threaded) {
pack_mb_row_tokens(cpi, &cpi->bc[1]);
- else
+ } else
#endif // CONFIG_MULTITHREAD
vp8_pack_tokens(&cpi->bc[1], cpi->tok, cpi->tok_count);
void vp8_encode_value(BOOL_CODER *br, int data, int bits) {
int bit;
- for (bit = bits - 1; bit >= 0; bit--)
+ for (bit = bits - 1; bit >= 0; bit--) {
vp8_encode_bool(br, (1 & (data >> bit)), 0x80);
+ }
}
static int validate_buffer(const unsigned char *start, size_t len,
const unsigned char *end,
struct vpx_internal_error_info *error) {
- if (start + len > start && start + len < end)
+ if (start + len > start && start + len < end) {
return 1;
- else
+ } else {
vpx_internal_error(error, VPX_CODEC_CORRUPT_FRAME,
"Truncated packet or corrupt partition ");
+ }
return 0;
}
running_avg_y[c] = mc_running_avg_y[c];
col_sum[c] += diff;
} else {
- if (absdiff >= 4 + shift_inc1 && absdiff <= 7)
+ if (absdiff >= 4 + shift_inc1 && absdiff <= 7) {
adjustment = adj_val[0];
- else if (absdiff >= 8 && absdiff <= 15)
+ } else if (absdiff >= 8 && absdiff <= 15) {
adjustment = adj_val[1];
- else
+ } else {
adjustment = adj_val[2];
+ }
if (diff > 0) {
- if ((sig[c] + adjustment) > 255)
+ if ((sig[c] + adjustment) > 255) {
running_avg_y[c] = 255;
- else
+ } else {
running_avg_y[c] = sig[c] + adjustment;
+ }
col_sum[c] += adjustment;
} else {
- if ((sig[c] - adjustment) < 0)
+ if ((sig[c] - adjustment) < 0) {
running_avg_y[c] = 0;
- else
+ } else {
running_avg_y[c] = sig[c] - adjustment;
+ }
col_sum[c] -= adjustment;
}
if (adjustment > delta) adjustment = delta;
if (diff > 0) {
// Bring denoised signal down.
- if (running_avg_y[c] - adjustment < 0)
+ if (running_avg_y[c] - adjustment < 0) {
running_avg_y[c] = 0;
- else
+ } else {
running_avg_y[c] = running_avg_y[c] - adjustment;
+ }
col_sum[c] -= adjustment;
} else if (diff < 0) {
// Bring denoised signal up.
- if (running_avg_y[c] + adjustment > 255)
+ if (running_avg_y[c] + adjustment > 255) {
running_avg_y[c] = 255;
- else
+ } else {
running_avg_y[c] = running_avg_y[c] + adjustment;
+ }
col_sum[c] += adjustment;
}
}
running_avg_uv[c] = mc_running_avg_uv[c];
sum_diff += diff;
} else {
- if (absdiff >= 4 && absdiff <= 7)
+ if (absdiff >= 4 && absdiff <= 7) {
adjustment = adj_val[0];
- else if (absdiff >= 8 && absdiff <= 15)
+ } else if (absdiff >= 8 && absdiff <= 15) {
adjustment = adj_val[1];
- else
+ } else {
adjustment = adj_val[2];
+ }
if (diff > 0) {
- if ((sig[c] + adjustment) > 255)
+ if ((sig[c] + adjustment) > 255) {
running_avg_uv[c] = 255;
- else
+ } else {
running_avg_uv[c] = sig[c] + adjustment;
+ }
sum_diff += adjustment;
} else {
- if ((sig[c] - adjustment) < 0)
+ if ((sig[c] - adjustment) < 0) {
running_avg_uv[c] = 0;
- else
+ } else {
running_avg_uv[c] = sig[c] - adjustment;
+ }
sum_diff -= adjustment;
}
}
if (adjustment > delta) adjustment = delta;
if (diff > 0) {
// Bring denoised signal down.
- if (running_avg_uv[c] - adjustment < 0)
+ if (running_avg_uv[c] - adjustment < 0) {
running_avg_uv[c] = 0;
- else
+ } else {
running_avg_uv[c] = running_avg_uv[c] - adjustment;
+ }
sum_diff -= adjustment;
} else if (diff < 0) {
// Bring denoised signal up.
- if (running_avg_uv[c] + adjustment > 255)
+ if (running_avg_uv[c] + adjustment > 255) {
running_avg_uv[c] = 255;
- else
+ } else {
running_avg_uv[c] = running_avg_uv[c] + adjustment;
+ }
sum_diff += adjustment;
}
}
// we will always choose zero_mv for denoising if
// zero_mv_see <= best_sse (i.e., sse_diff <= 0).
if ((unsigned int)(mv_row * mv_row + mv_col * mv_col) <=
- NOISE_MOTION_THRESHOLD)
+ NOISE_MOTION_THRESHOLD) {
sse_diff_thresh = (int)SSE_DIFF_THRESHOLD;
+ }
if (frame == INTRA_FRAME || sse_diff <= sse_diff_thresh) {
/*
denoiser->denoise_pars.scale_motion_thresh * NOISE_MOTION_THRESHOLD;
if (motion_magnitude2 <
- denoiser->denoise_pars.scale_increase_filter * NOISE_MOTION_THRESHOLD)
+ denoiser->denoise_pars.scale_increase_filter * NOISE_MOTION_THRESHOLD) {
x->increase_denoising = 1;
+ }
sse_thresh = denoiser->denoise_pars.scale_sse_thresh * SSE_THRESHOLD;
- if (x->increase_denoising)
+ if (x->increase_denoising) {
sse_thresh = denoiser->denoise_pars.scale_sse_thresh * SSE_THRESHOLD_HIGH;
+ }
- if (best_sse > sse_thresh || motion_magnitude2 > motion_threshold)
+ if (best_sse > sse_thresh || motion_magnitude2 > motion_threshold) {
decision = COPY_BLOCK;
+ }
// If block is considered skin, don't denoise if the block
// (1) is selected as non-zero motion for current frame, or
// in a row.
// TODO(marpan): Parameter "x" should be varied with framerate.
// In particualar, should be reduced for layers (base layer/LAST).
- if (x->is_skin && (consec_zero_last < 2 || motion_magnitude2 > 0))
+ if (x->is_skin && (consec_zero_last < 2 || motion_magnitude2 > 0)) {
decision = COPY_BLOCK;
+ }
if (decision == FILTER_BLOCK) {
saved_pre = filter_xd->pre;
cpi->activity_avg = (unsigned int)(activity_sum / cpi->common.MBs);
#endif
- if (cpi->activity_avg < VP8_ACTIVITY_AVG_MIN)
+ if (cpi->activity_avg < VP8_ACTIVITY_AVG_MIN) {
cpi->activity_avg = VP8_ACTIVITY_AVG_MIN;
+ }
/* Experimental code: return fixed value normalized for several clips */
if (ALT_ACT_MEASURE) cpi->activity_avg = 100000;
const int *last_row_current_mb_col;
int *current_mb_col = &cpi->mt_current_mb_col[mb_row];
- if ((cpi->b_multi_threaded != 0) && (mb_row != 0))
+ if ((cpi->b_multi_threaded != 0) && (mb_row != 0)) {
last_row_current_mb_col = &cpi->mt_current_mb_col[mb_row - 1];
- else
+ } else {
last_row_current_mb_col = &rightmost_col;
+ }
#endif
#if (CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING)
/* Code to set segment id in xd->mbmi.segment_id for current MB
* (with range checking)
*/
- if (cpi->segmentation_map[map_index + mb_col] <= 3)
+ if (cpi->segmentation_map[map_index + mb_col] <= 3) {
xd->mode_info_context->mbmi.segment_id =
cpi->segmentation_map[map_index + mb_col];
- else
+ } else {
xd->mode_info_context->mbmi.segment_id = 0;
+ }
vp8cx_mb_init_quantizer(cpi, x, 1);
- } else
+ } else {
/* Set to Segment 0 by default */
xd->mode_info_context->mbmi.segment_id = 0;
+ }
x->active_ptr = cpi->active_map + map_index + mb_col;
if (xd->mode_info_context->mbmi.mode == ZEROMV &&
xd->mode_info_context->mbmi.ref_frame == LAST_FRAME) {
// Increment, check for wrap-around.
- if (cpi->consec_zero_last[map_index + mb_col] < 255)
+ if (cpi->consec_zero_last[map_index + mb_col] < 255) {
cpi->consec_zero_last[map_index + mb_col] += 1;
- if (cpi->consec_zero_last_mvbias[map_index + mb_col] < 255)
+ }
+ if (cpi->consec_zero_last_mvbias[map_index + mb_col] < 255) {
cpi->consec_zero_last_mvbias[map_index + mb_col] += 1;
+ }
} else {
cpi->consec_zero_last[map_index + mb_col] = 0;
cpi->consec_zero_last_mvbias[map_index + mb_col] = 0;
}
- if (x->zero_last_dot_suppress)
+ if (x->zero_last_dot_suppress) {
cpi->consec_zero_last_mvbias[map_index + mb_col] = 0;
+ }
}
/* Special case code for cyclic refresh
* been refreshed then mark it as a candidate for cleanup
* next time (marked 0) else mark it as dirty (1).
*/
- if (xd->mode_info_context->mbmi.segment_id)
+ if (xd->mode_info_context->mbmi.segment_id) {
cpi->cyclic_refresh_map[map_index + mb_col] = -1;
- else if ((xd->mode_info_context->mbmi.mode == ZEROMV) &&
- (xd->mode_info_context->mbmi.ref_frame == LAST_FRAME)) {
- if (cpi->cyclic_refresh_map[map_index + mb_col] == 1)
+ } else if ((xd->mode_info_context->mbmi.mode == ZEROMV) &&
+ (xd->mode_info_context->mbmi.ref_frame == LAST_FRAME)) {
+ if (cpi->cyclic_refresh_map[map_index + mb_col] == 1) {
cpi->cyclic_refresh_map[map_index + mb_col] = 0;
- } else
+ }
+ } else {
cpi->cyclic_refresh_map[map_index + mb_col] = 1;
+ }
}
}
xd->dst.u_buffer + 8, xd->dst.v_buffer + 8);
#if CONFIG_MULTITHREAD
- if (cpi->b_multi_threaded != 0)
+ if (cpi->b_multi_threaded != 0) {
protected_write(&cpi->pmutex[mb_row], current_mb_col, rightmost_col);
+ }
#endif
/* this is to account for the border */
/* Special case treatment when GF and ARF are not sensible options
* for reference
*/
- if (cpi->ref_frame_flags == VP8_LAST_FRAME)
+ if (cpi->ref_frame_flags == VP8_LAST_FRAME) {
vp8_calc_ref_frame_costs(x->ref_frame_cost, cpi->prob_intra_coded, 255,
128);
- else if ((cpi->oxcf.number_of_layers > 1) &&
- (cpi->ref_frame_flags == VP8_GOLD_FRAME))
+ } else if ((cpi->oxcf.number_of_layers > 1) &&
+ (cpi->ref_frame_flags == VP8_GOLD_FRAME)) {
vp8_calc_ref_frame_costs(x->ref_frame_cost, cpi->prob_intra_coded, 1, 255);
- else if ((cpi->oxcf.number_of_layers > 1) &&
- (cpi->ref_frame_flags == VP8_ALTR_FRAME))
+ } else if ((cpi->oxcf.number_of_layers > 1) &&
+ (cpi->ref_frame_flags == VP8_ALTR_FRAME)) {
vp8_calc_ref_frame_costs(x->ref_frame_cost, cpi->prob_intra_coded, 1, 1);
- else
+ } else {
vp8_calc_ref_frame_costs(x->ref_frame_cost, cpi->prob_intra_coded,
cpi->prob_last_coded, cpi->prob_gf_coded);
+ }
xd->fullpixel_mask = 0xffffffff;
if (cm->full_pixel) xd->fullpixel_mask = 0xfffffff8;
totalrate = 0;
if (cpi->compressor_speed == 2) {
- if (cpi->oxcf.cpu_used < 0)
+ if (cpi->oxcf.cpu_used < 0) {
cpi->Speed = -(cpi->oxcf.cpu_used);
- else
+ } else {
vp8_auto_select_speed(cpi);
+ }
}
/* Functions setup for all frame types so we can use MC in AltRef */
if (xd->segmentation_enabled) {
for (i = 0; i < cpi->encoding_thread_count; ++i) {
- for (j = 0; j < 4; ++j)
+ for (j = 0; j < 4; ++j) {
segment_counts[j] += cpi->mb_row_ei[i].segment_counts[j];
+ }
}
}
}
cpi->mb.skip_true_count += cpi->mb_row_ei[i].mb.skip_true_count;
- for (mode_count = 0; mode_count < VP8_YMODES; ++mode_count)
+ for (mode_count = 0; mode_count < VP8_YMODES; ++mode_count) {
cpi->mb.ymode_count[mode_count] +=
cpi->mb_row_ei[i].mb.ymode_count[mode_count];
+ }
- for (mode_count = 0; mode_count < VP8_UV_MODES; ++mode_count)
+ for (mode_count = 0; mode_count < VP8_UV_MODES; ++mode_count) {
cpi->mb.uv_mode_count[mode_count] +=
cpi->mb_row_ei[i].mb.uv_mode_count[mode_count];
+ }
for (c_idx = 0; c_idx < MVvals; ++c_idx) {
cpi->mb.MVcount[0][c_idx] += cpi->mb_row_ei[i].mb.MVcount[0][c_idx];
cpi->mb.prediction_error += cpi->mb_row_ei[i].mb.prediction_error;
cpi->mb.intra_error += cpi->mb_row_ei[i].mb.intra_error;
- for (c_idx = 0; c_idx < MAX_REF_FRAMES; ++c_idx)
+ for (c_idx = 0; c_idx < MAX_REF_FRAMES; ++c_idx) {
cpi->mb.count_mb_ref_frame_usage[c_idx] +=
cpi->mb_row_ei[i].mb.count_mb_ref_frame_usage[c_idx];
+ }
- for (c_idx = 0; c_idx < MAX_ERROR_BINS; ++c_idx)
+ for (c_idx = 0; c_idx < MAX_ERROR_BINS; ++c_idx) {
cpi->mb.error_bins[c_idx] += cpi->mb_row_ei[i].mb.error_bins[c_idx];
+ }
/* add up counts for each thread */
sum_coef_counts(x, &cpi->mb_row_ei[i].mb);
tot_count = segment_counts[2] + segment_counts[3];
- if (tot_count > 0)
+ if (tot_count > 0) {
xd->mb_segment_tree_probs[2] = (segment_counts[2] * 255) / tot_count;
+ }
/* Zero probabilities not allowed */
for (i = 0; i < MB_FEATURE_TREE_PROBS; ++i) {
cpi->mb.count_mb_ref_frame_usage[GOLDEN_FRAME] +
cpi->mb.count_mb_ref_frame_usage[ALTREF_FRAME];
- if (tot_modes)
+ if (tot_modes) {
cpi->this_frame_percent_intra =
cpi->mb.count_mb_ref_frame_usage[INTRA_FRAME] * 100 / tot_modes;
+ }
}
#if !CONFIG_REALTIME_ONLY
a = act + 4 * cpi->activity_avg;
b = 4 * act + cpi->activity_avg;
- if (act > cpi->activity_avg)
+ if (act > cpi->activity_avg) {
x->act_zbin_adj = (int)(((int64_t)b + (a >> 1)) / a) - 1;
- else
+ } else {
x->act_zbin_adj = 1 - (int)(((int64_t)a + (b >> 1)) / b);
+ }
#endif
}
MACROBLOCKD *xd = &x->e_mbd;
int rate;
- if (cpi->sf.RD && cpi->compressor_speed != 2)
+ if (cpi->sf.RD && cpi->compressor_speed != 2) {
vp8_rd_pick_intra_mode(x, &rate);
- else
+ } else {
vp8_pick_intra_mode(x, &rate);
+ }
if (cpi->oxcf.tuning == VP8_TUNE_SSIM) {
adjust_act_zbin(cpi, x);
vp8_update_zbin_extra(cpi, x);
}
- if (x->e_mbd.mode_info_context->mbmi.mode == B_PRED)
+ if (x->e_mbd.mode_info_context->mbmi.mode == B_PRED) {
vp8_encode_intra4x4mby(x);
- else
+ } else {
vp8_encode_intra16x16mby(x);
+ }
vp8_encode_intra16x16mbuv(x);
x->skip = 0;
- if (xd->segmentation_enabled)
+ if (xd->segmentation_enabled) {
x->encode_breakout =
cpi->segment_encode_breakout[xd->mode_info_context->mbmi.segment_id];
- else
+ } else {
x->encode_breakout = cpi->oxcf.encode_breakout;
+ }
#if CONFIG_TEMPORAL_DENOISING
/* Reset the best sse mode/mv for each macroblock. */
if (xd->mode_info_context->mbmi.ref_frame != INTRA_FRAME) {
if (xd->mode_info_context->mbmi.mode == ZEROMV) {
if (xd->mode_info_context->mbmi.ref_frame != LAST_FRAME &&
- cpi->oxcf.number_of_layers == 1)
+ cpi->oxcf.number_of_layers == 1) {
x->zbin_mode_boost = GF_ZEROMV_ZBIN_BOOST;
- else
+ } else {
x->zbin_mode_boost = LF_ZEROMV_ZBIN_BOOST;
- } else if (xd->mode_info_context->mbmi.mode == SPLITMV)
+ }
+ } else if (xd->mode_info_context->mbmi.mode == SPLITMV) {
x->zbin_mode_boost = 0;
- else
+ } else {
x->zbin_mode_boost = MV_ZBIN_BOOST;
+ }
}
}
} else {
int ref_fb_idx;
- if (xd->mode_info_context->mbmi.ref_frame == LAST_FRAME)
+ if (xd->mode_info_context->mbmi.ref_frame == LAST_FRAME) {
ref_fb_idx = cpi->common.lst_fb_idx;
- else if (xd->mode_info_context->mbmi.ref_frame == GOLDEN_FRAME)
+ } else if (xd->mode_info_context->mbmi.ref_frame == GOLDEN_FRAME) {
ref_fb_idx = cpi->common.gld_fb_idx;
- else
+ } else {
ref_fb_idx = cpi->common.alt_fb_idx;
+ }
xd->pre.y_buffer = cpi->common.yv12_fb[ref_fb_idx].y_buffer + recon_yoffset;
xd->pre.u_buffer =
if (!x->skip) {
vp8_encode_inter16x16(x);
- } else
+ } else {
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);
+ }
}
if (!x->skip) {
vp8_tokenize_mb(cpi, x, t);
- if (xd->mode_info_context->mbmi.mode != B_PRED)
+ if (xd->mode_info_context->mbmi.mode != B_PRED) {
vp8_inverse_transform_mby(xd);
+ }
vp8_dequant_idct_add_uv_block(xd->qcoeff + 16 * 16, xd->dequant_uv,
xd->dst.u_buffer, xd->dst.v_buffer,
}
/* do 2nd order transform on the dc block */
- if (x->e_mbd.mode_info_context->mbmi.mode != SPLITMV)
+ if (x->e_mbd.mode_info_context->mbmi.mode != SPLITMV) {
x->short_walsh4x4(&x->block[24].src_diff[0], &x->block[24].coeff[0], 8);
+ }
}
static void transform_mby(MACROBLOCK *x) {
/* Now set up a Viterbi trellis to evaluate alternative roundings. */
rdmult = mb->rdmult * err_mult;
- if (mb->e_mbd.mode_info_context->mbmi.ref_frame == INTRA_FRAME)
+ if (mb->e_mbd.mode_info_context->mbmi.ref_frame == INTRA_FRAME) {
rdmult = (rdmult * 9) >> 4;
+ }
rddiv = mb->rddiv;
best_mask[0] = best_mask[1] = 0;
rate1 = tokens[next][1].rate;
if ((abs(x) * dequant_ptr[rc] > abs(coeff_ptr[rc])) &&
- (abs(x) * dequant_ptr[rc] < abs(coeff_ptr[rc]) + dequant_ptr[rc]))
+ (abs(x) * dequant_ptr[rc] < abs(coeff_ptr[rc]) + dequant_ptr[rc])) {
shortcut = 1;
- else
+ } else {
shortcut = 0;
+ }
if (shortcut) {
sz = -(x < 0);
int i = 0;
cost = vp8_cost_one(p[mvpis_short]);
- do
+ do {
cost += vp8_cost_bit(p[MVPbits + i], (x >> i) & 1);
- while (++i < 3);
+ } while (++i < 3);
i = mvlong_width - 1; /* Skip bit 3, which is sometimes implicit */
- do
+ do {
cost += vp8_cost_bit(p[MVPbits + i], (x >> i) & 1);
- while (--i > 3);
+ } while (--i > 3);
if (x & 0xFFF0) cost += vp8_cost_bit(p[MVPbits + 3], (x >> 3) & 1);
}
is_short_ct[1] += c; /* Long vector */
/* bit 3 not always encoded. */
- do
+ do {
bit_ct[k][(a >> k) & 1] += c;
- while (--k >= 0);
+ } while (--k >= 0);
}
} while (++j <= mv_max);
}
vp8_tree_probs_from_distribution(8, vp8_small_mvencodings, vp8_small_mvtree,
p, short_bct, short_ct, 256, 1);
- do
+ do {
calc_prob(Pnew + MVPshort + j, short_bct[j]);
- while (++j < mvnum_short - 1);
+ } while (++j < mvnum_short - 1);
}
{
int j = 0;
- do
+ do {
calc_prob(Pnew + MVPbits + j, bit_ct[j]);
- while (++j < mvlong_width);
+ } while (++j < mvlong_width);
}
update(w, is_short_ct, Pcur + mvpis_short, Pnew[mvpis_short], *Pupdate++,
int j = 0;
- do
-
+ do {
update(w, short_bct[j], cur_p + j, new_p[j], *Pupdate++, updated);
- while (++j < mvnum_short - 1);
+ } while (++j < mvnum_short - 1);
}
{
int j = 0;
- do
-
+ do {
update(w, bit_ct[j], cur_p + j, new_p[j], *Pupdate++, updated);
- while (++j < mvlong_width);
+ } while (++j < mvlong_width);
}
}
&vp8_mv_update_probs[1], cpi->mb.MVcount[1], 1,
&flags[1]);
- if (flags[0] || flags[1])
+ if (flags[0] || flags[1]) {
vp8_build_component_cost_table(
cpi->mb.mvcost, (const MV_CONTEXT *)cpi->common.fc.mvc, flags);
+ }
#ifdef VP8_ENTROPY_STATS
active_section = 5;
/* Code to set segment id in xd->mbmi.segment_id for
* current MB (with range checking)
*/
- if (cpi->segmentation_map[map_index + mb_col] <= 3)
+ if (cpi->segmentation_map[map_index + mb_col] <= 3) {
xd->mode_info_context->mbmi.segment_id =
cpi->segmentation_map[map_index + mb_col];
- else
+ } else {
xd->mode_info_context->mbmi.segment_id = 0;
+ }
vp8cx_mb_init_quantizer(cpi, x, 1);
- } else
+ } else {
/* Set to Segment 0 by default */
xd->mode_info_context->mbmi.segment_id = 0;
+ }
x->active_ptr = cpi->active_map + map_index + mb_col;
if (xd->mode_info_context->mbmi.mode == ZEROMV &&
xd->mode_info_context->mbmi.ref_frame == LAST_FRAME) {
// Increment, check for wrap-around.
- if (cpi->consec_zero_last[map_index + mb_col] < 255)
+ if (cpi->consec_zero_last[map_index + mb_col] < 255) {
cpi->consec_zero_last[map_index + mb_col] += 1;
- if (cpi->consec_zero_last_mvbias[map_index + mb_col] < 255)
+ }
+ if (cpi->consec_zero_last_mvbias[map_index + mb_col] < 255) {
cpi->consec_zero_last_mvbias[map_index + mb_col] += 1;
+ }
} else {
cpi->consec_zero_last[map_index + mb_col] = 0;
cpi->consec_zero_last_mvbias[map_index + mb_col] = 0;
}
- if (x->zero_last_dot_suppress)
+ if (x->zero_last_dot_suppress) {
cpi->consec_zero_last_mvbias[map_index + mb_col] = 0;
+ }
}
/* Special case code for cyclic refresh
* candidate for cleanup next time (marked 0) else
* mark it as dirty (1).
*/
- if (mbmi->segment_id)
+ if (mbmi->segment_id) {
cpi->cyclic_refresh_map[map_index + mb_col] = -1;
- else if ((mbmi->mode == ZEROMV) &&
- (mbmi->ref_frame == LAST_FRAME)) {
- if (cpi->cyclic_refresh_map[map_index + mb_col] == 1)
+ } else if ((mbmi->mode == ZEROMV) &&
+ (mbmi->ref_frame == LAST_FRAME)) {
+ if (cpi->cyclic_refresh_map[map_index + mb_col] == 1) {
cpi->cyclic_refresh_map[map_index + mb_col] = 0;
- } else
+ }
+ } else {
cpi->cyclic_refresh_map[map_index + mb_col] = 1;
+ }
}
}
int rc = 0;
/* don't allocate more threads than cores available */
- if (cpi->oxcf.multi_threaded > cm->processor_core_count)
+ if (cpi->oxcf.multi_threaded > cm->processor_core_count) {
th_count = cm->processor_core_count - 1;
+ }
/* we have th_count + 1 (main) threads processing one row each */
/* no point to have more threads than the sync range allows */
double this_err = this_frame->ssim_weighted_pred_err;
double modified_err;
- if (this_err > av_err)
+ if (this_err > av_err) {
modified_err = av_err * pow((this_err / DOUBLE_DIVIDE_CHECK(av_err)), POW1);
- else
+ } else {
modified_err = av_err * pow((this_err / DOUBLE_DIVIDE_CHECK(av_err)), POW2);
+ }
return modified_err;
}
while (n < further_steps) {
n++;
- if (num00)
+ if (num00) {
num00--;
- else {
+ } else {
tmp_err = cpi->diamond_search_sad(x, b, d, &ref_mv_full, &tmp_mv,
step_param + n, x->sadperbit16, &num00,
&v_fn_ptr, x->mvcost, ref_mv);
- if (tmp_err < INT_MAX - new_mv_mode_penalty)
+ if (tmp_err < INT_MAX - new_mv_mode_penalty) {
tmp_err += new_mv_mode_penalty;
+ }
if (tmp_err < *best_motion_err) {
*best_motion_err = tmp_err;
d->bmi.mv.as_mv.row = 0;
d->bmi.mv.as_mv.col = 0;
- if (raw_motion_error < cpi->oxcf.encode_breakout)
+ if (raw_motion_error < cpi->oxcf.encode_breakout) {
goto skip_motion_search;
+ }
/* Test last reference frame using the previous best mv as the
* starting point (best reference) for the search
/* Does the Row vector point inwards or outwards */
if (mb_row < cm->mb_rows / 2) {
- if (d->bmi.mv.as_mv.row > 0)
+ if (d->bmi.mv.as_mv.row > 0) {
sum_in_vectors--;
- else if (d->bmi.mv.as_mv.row < 0)
+ } else if (d->bmi.mv.as_mv.row < 0) {
sum_in_vectors++;
+ }
} else if (mb_row > cm->mb_rows / 2) {
- if (d->bmi.mv.as_mv.row > 0)
+ if (d->bmi.mv.as_mv.row > 0) {
sum_in_vectors++;
- else if (d->bmi.mv.as_mv.row < 0)
+ } else if (d->bmi.mv.as_mv.row < 0) {
sum_in_vectors--;
+ }
}
/* Does the Row vector point inwards or outwards */
if (mb_col < cm->mb_cols / 2) {
- if (d->bmi.mv.as_mv.col > 0)
+ if (d->bmi.mv.as_mv.col > 0) {
sum_in_vectors--;
- else if (d->bmi.mv.as_mv.col < 0)
+ } else if (d->bmi.mv.as_mv.col < 0) {
sum_in_vectors++;
+ }
} else if (mb_col > cm->mb_cols / 2) {
- if (d->bmi.mv.as_mv.col > 0)
+ if (d->bmi.mv.as_mv.col > 0) {
sum_in_vectors++;
- else if (d->bmi.mv.as_mv.col < 0)
+ } else if (d->bmi.mv.as_mv.col < 0) {
sum_in_vectors--;
+ }
}
}
}
FILE *recon_file;
sprintf(filename, "enc%04d.yuv", (int)cm->current_video_frame);
- if (cm->current_video_frame == 0)
+ if (cm->current_video_frame == 0) {
recon_file = fopen(filename, "wb");
- else
+ } else {
recon_file = fopen(filename, "ab");
+ }
(void)fwrite(lst_yv12->buffer_alloc, lst_yv12->frame_size, 1, recon_file);
fclose(recon_file);
*/
static double bitcost(double prob) {
- if (prob > 0.000122)
+ if (prob > 0.000122) {
return -log(prob) / log(2.0);
- else
+ } else {
return 13.0;
+ }
}
static int64_t estimate_modemvcost(VP8_COMP *cpi, FIRSTPASS_STATS *fpstats) {
int mv_cost;
double speed_correction = 1.0;
int overhead_bits_per_mb;
- if (section_target_bandwitdh <= 0)
+ if (section_target_bandwitdh <= 0) {
return cpi->twopass.maxq_max_limit; /* Highest value allowed */
+ }
target_norm_bits_per_mb = (section_target_bandwitdh < (1 << 20))
? (512 * section_target_bandwitdh) / num_mbs
rolling_ratio =
(double)cpi->rolling_actual_bits / (double)cpi->rolling_target_bits;
- if (rolling_ratio < 0.95)
+ if (rolling_ratio < 0.95) {
cpi->twopass.est_max_qcorrection_factor -= 0.005;
- else if (rolling_ratio > 1.05)
+ } else if (rolling_ratio > 1.05) {
cpi->twopass.est_max_qcorrection_factor += 0.005;
+ }
cpi->twopass.est_max_qcorrection_factor =
(cpi->twopass.est_max_qcorrection_factor < 0.1)
* (reduced compression expected)
*/
if ((cpi->compressor_speed == 3) || (cpi->compressor_speed == 1)) {
- if (cpi->oxcf.cpu_used <= 5)
+ if (cpi->oxcf.cpu_used <= 5) {
speed_correction = 1.04 + (cpi->oxcf.cpu_used * 0.04);
- else
+ } else {
speed_correction = 1.25;
+ }
}
/* Estimate of overhead bits per mb */
* (reduced compression expected)
*/
if ((cpi->compressor_speed == 3) || (cpi->compressor_speed == 1)) {
- if (cpi->oxcf.cpu_used <= 5)
+ if (cpi->oxcf.cpu_used <= 5) {
speed_correction = 1.04 + (cpi->oxcf.cpu_used * 0.04);
- else
+ } else {
speed_correction = 1.25;
+ }
}
/* II ratio correction factor for clip as a whole */
* (reduced compression expected)
*/
if ((cpi->compressor_speed == 3) || (cpi->compressor_speed == 1)) {
- if (cpi->oxcf.cpu_used <= 5)
+ if (cpi->oxcf.cpu_used <= 5) {
speed_correction = 1.04 + (cpi->oxcf.cpu_used * 0.04);
- else
+ } else {
speed_correction = 1.25;
+ }
}
/* Try and pick a Q that can encode the content at the given rate. */
* vs target bits
* This is clamped to the range 0.1 to 10.0
*/
- if (cpi->long_rolling_target_bits <= 0)
+ if (cpi->long_rolling_target_bits <= 0) {
current_spend_ratio = 10.0;
- else {
+ } else {
current_spend_ratio = (double)cpi->long_rolling_actual_bits /
(double)cpi->long_rolling_target_bits;
current_spend_ratio =
* (reduced compression expected)
*/
if ((cpi->compressor_speed == 3) || (cpi->compressor_speed == 1)) {
- if (cpi->oxcf.cpu_used <= 5)
+ if (cpi->oxcf.cpu_used <= 5) {
speed_correction = 1.04 + (cpi->oxcf.cpu_used * 0.04);
- else
+ } else {
speed_correction = 1.25;
+ }
}
/* Combine the various factors calculated above */
/* High % motion -> somewhat higher decay rate */
motion_decay = (1.0 - (motion_pct / 20.0));
- if (motion_decay < prediction_decay_rate)
+ if (motion_decay < prediction_decay_rate) {
prediction_decay_rate = motion_decay;
+ }
/* Adjustment to decay rate based on speed of motion */
{
sqrt((this_mv_rabs * this_mv_rabs) + (this_mv_cabs * this_mv_cabs)) /
250.0;
distance_factor = ((distance_factor > 1.0) ? 0.0 : (1.0 - distance_factor));
- if (distance_factor < prediction_decay_rate)
+ if (distance_factor < prediction_decay_rate) {
prediction_decay_rate = distance_factor;
+ }
}
return prediction_decay_rate;
double frame_boost;
/* Underlying boost factor is based on inter intra error ratio */
- if (this_frame->intra_error > cpi->twopass.gf_intra_err_min)
+ if (this_frame->intra_error > cpi->twopass.gf_intra_err_min) {
frame_boost = (IIFACTOR * this_frame->intra_error /
DOUBLE_DIVIDE_CHECK(this_frame->coded_error));
- else
+ } else {
frame_boost = (IIFACTOR * cpi->twopass.gf_intra_err_min /
DOUBLE_DIVIDE_CHECK(this_frame->coded_error));
+ }
/* Increase boost for frames where new data coming into frame
* (eg zoom out). Slightly reduce boost if there is a net balance
* of motion out of the frame (zoom in).
* The range for this_frame_mv_in_out is -1.0 to +1.0
*/
- if (this_frame_mv_in_out > 0.0)
+ if (this_frame_mv_in_out > 0.0) {
frame_boost += frame_boost * (this_frame_mv_in_out * 2.0);
- /* In extreme case boost is halved */
- else
+ /* In extreme case boost is halved */
+ } else {
frame_boost += frame_boost * (this_frame_mv_in_out / 2.0);
+ }
/* Clip to maximum */
if (frame_boost > GF_RMAX) frame_boost = GF_RMAX;
int64_t df_buffer_level = cpi->oxcf.drop_frames_water_mark *
(cpi->oxcf.optimal_buffer_level / 100);
- if (cpi->buffer_level > df_buffer_level)
+ if (cpi->buffer_level > df_buffer_level) {
max_boost =
((double)((cpi->buffer_level - df_buffer_level) * 2 / 3) * 16.0) /
DOUBLE_DIVIDE_CHECK((double)cpi->av_per_frame_bandwidth);
- else
+ } else {
max_boost = 0.0;
+ }
} else if (cpi->buffer_level > 0) {
max_boost = ((double)(cpi->buffer_level * 2 / 3) * 16.0) /
DOUBLE_DIVIDE_CHECK((double)cpi->av_per_frame_bandwidth);
group_bits =
(int)((double)cpi->twopass.kf_group_bits *
(gf_group_err / (double)cpi->twopass.kf_group_error_left));
- } else
+ } else {
group_bits = 0;
+ }
/* Boost for arf frame */
#if NEW_BOOST
Boost += (i * 50);
/* Set max and minimum boost and hence minimum allocation */
- if (Boost > ((cpi->baseline_gf_interval + 1) * 200))
+ if (Boost > ((cpi->baseline_gf_interval + 1) * 200)) {
Boost = ((cpi->baseline_gf_interval + 1) * 200);
- else if (Boost < 125)
+ } else if (Boost < 125) {
Boost = 125;
+ }
allocation_chunks = (i * 100) + Boost;
/* For even length filter there is one more frame backward
* than forward: e.g. len=6 ==> bbbAff, len=7 ==> bbbAfff.
*/
- if (frames_bwd < half_gf_int)
+ if (frames_bwd < half_gf_int) {
frames_bwd += (cpi->oxcf.arnr_max_frames + 1) & 0x1;
+ }
break;
}
cpi->twopass.gf_group_bits =
(int64_t)(cpi->twopass.kf_group_bits *
(gf_group_err / cpi->twopass.kf_group_error_left));
- } else
+ } else {
cpi->twopass.gf_group_bits = 0;
+ }
cpi->twopass.gf_group_bits =
(cpi->twopass.gf_group_bits < 0)
* variability limit (cpi->oxcf.two_pass_vbrmax_section)
*/
if (cpi->twopass.gf_group_bits >
- (int64_t)max_bits * cpi->baseline_gf_interval)
+ (int64_t)max_bits * cpi->baseline_gf_interval) {
cpi->twopass.gf_group_bits = (int64_t)max_bits * cpi->baseline_gf_interval;
+ }
/* Reset the file position */
reset_fpf_position(cpi, start_pos);
Boost += (cpi->baseline_gf_interval * 50);
/* Set max and minimum boost and hence minimum allocation */
- if (Boost > ((cpi->baseline_gf_interval + 1) * 200))
+ if (Boost > ((cpi->baseline_gf_interval + 1) * 200)) {
Boost = ((cpi->baseline_gf_interval + 1) * 200);
- else if (Boost < 125)
+ } else if (Boost < 125) {
Boost = 125;
+ }
allocation_chunks = ((cpi->baseline_gf_interval + 1) * 100) + Boost;
}
Boost = (cpi->gfu_boost * GFQ_ADJUSTMENT) / 100;
/* Set max and minimum boost and hence minimum allocation */
- if (Boost > (cpi->baseline_gf_interval * 150))
+ if (Boost > (cpi->baseline_gf_interval * 150)) {
Boost = (cpi->baseline_gf_interval * 150);
- else if (Boost < 125)
+ } else if (Boost < 125) {
Boost = 125;
+ }
allocation_chunks = (cpi->baseline_gf_interval * 100) + (Boost - 100);
}
/* Apply an additional limit for CBR */
if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) {
- if (cpi->twopass.gf_bits > (int)(cpi->buffer_level >> 1))
+ if (cpi->twopass.gf_bits > (int)(cpi->buffer_level >> 1)) {
cpi->twopass.gf_bits = (int)(cpi->buffer_level >> 1);
+ }
}
/* Dont allow a negative value for gf_bits */
* frame of the group (except in Key frame case where this has
* already happened)
*/
- if (!cpi->source_alt_ref_pending && cpi->common.frame_type != KEY_FRAME)
+ if (!cpi->source_alt_ref_pending && cpi->common.frame_type != KEY_FRAME) {
cpi->twopass.gf_group_error_left =
(int)(gf_group_err - gf_first_frame_err);
- else
+ } else {
cpi->twopass.gf_group_error_left = (int)gf_group_err;
+ }
cpi->twopass.gf_group_bits -=
cpi->twopass.gf_bits - cpi->min_frame_bandwidth;
(int)(cpi->twopass.gf_group_bits * pct_extra) / 100;
cpi->twopass.gf_group_bits -= cpi->twopass.alt_extra_bits;
cpi->twopass.alt_extra_bits /= ((cpi->baseline_gf_interval - 1) >> 1);
- } else
+ } else {
cpi->twopass.alt_extra_bits = 0;
- } else
+ }
+ } else {
cpi->twopass.alt_extra_bits = 0;
+ }
}
/* Adjustments based on a measure of complexity of the section */
DOUBLE_DIVIDE_CHECK(sectionstats.coded_error);
cpi->twopass.section_max_qfactor = 1.0 - ((Ratio - 10.0) * 0.025);
- if (cpi->twopass.section_max_qfactor < 0.80)
+ if (cpi->twopass.section_max_qfactor < 0.80) {
cpi->twopass.section_max_qfactor = 0.80;
+ }
reset_fpf_position(cpi, start_pos);
}
modified_err = calculate_modified_err(cpi, this_frame);
/* What portion of the remaining GF group error is used by this frame */
- if (cpi->twopass.gf_group_error_left > 0)
+ if (cpi->twopass.gf_group_error_left > 0) {
err_fraction = modified_err / cpi->twopass.gf_group_error_left;
- else
+ } else {
err_fraction = 0.0;
+ }
/* How many of those bits available for allocation should we give it? */
target_frame_size = (int)((double)cpi->twopass.gf_group_bits * err_fraction);
/* Clip to target size to 0 - max_bits (or cpi->twopass.gf_group_bits)
* at the top end.
*/
- if (target_frame_size < 0)
+ if (target_frame_size < 0) {
target_frame_size = 0;
- else {
+ } else {
if (target_frame_size > max_bits) target_frame_size = max_bits;
- if (target_frame_size > cpi->twopass.gf_group_bits)
+ if (target_frame_size > cpi->twopass.gf_group_bits) {
target_frame_size = (int)cpi->twopass.gf_group_bits;
+ }
}
/* Adjust error and bits remaining */
overhead_bits);
/* Move active_worst_quality but in a damped way */
- if (tmp_q > cpi->active_worst_quality)
+ if (tmp_q > cpi->active_worst_quality) {
cpi->active_worst_quality++;
- else if (tmp_q < cpi->active_worst_quality)
+ } else if (tmp_q < cpi->active_worst_quality) {
cpi->active_worst_quality--;
+ }
cpi->active_worst_quality =
((cpi->active_worst_quality * 3) + tmp_q + 2) / 4;
if (next_iiratio > RMAX) next_iiratio = RMAX;
/* Cumulative effect of decay in prediction quality */
- if (local_next_frame.pcnt_inter > 0.85)
+ if (local_next_frame.pcnt_inter > 0.85) {
decay_accumulator = decay_accumulator * local_next_frame.pcnt_inter;
- else
+ } else {
decay_accumulator =
decay_accumulator * ((0.85 + local_next_frame.pcnt_inter) / 2.0);
+ }
/* Keep a running total */
boost_score += (decay_accumulator * next_iiratio);
/* If there is tolerable prediction for at least the next 3 frames
* then break out else discard this pottential key frame and move on
*/
- if (boost_score > 5.0 && (i > 3))
+ if (boost_score > 5.0 && (i > 3)) {
is_viable_kf = 1;
- else {
+ } else {
/* Reset the file position */
reset_fpf_position(cpi, start_pos);
/* If we don't have a real key frame within the next two
* forcekeyframeevery intervals then break out of the loop.
*/
- if (cpi->twopass.frames_to_key >= 2 * (int)cpi->key_frame_frequency)
+ if (cpi->twopass.frames_to_key >= 2 * (int)cpi->key_frame_frequency) {
break;
- } else
+ }
+ } else {
cpi->twopass.frames_to_key++;
+ }
i++;
}
reset_fpf_position(cpi, current_pos);
cpi->next_key_frame_forced = 1;
- } else
+ } else {
cpi->next_key_frame_forced = 0;
+ }
/* Special case for the last frame of the file */
if (cpi->twopass.stats_in >= cpi->twopass.stats_in_end) {
/* Clip based on maximum per frame rate defined by the user. */
max_grp_bits = (int64_t)max_bits * (int64_t)cpi->twopass.frames_to_key;
- if (cpi->twopass.kf_group_bits > max_grp_bits)
+ if (cpi->twopass.kf_group_bits > max_grp_bits) {
cpi->twopass.kf_group_bits = max_grp_bits;
+ }
/* Additional special case for CBR if buffer is getting full. */
if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) {
min_group_bits =
av_group_bits + (int64_t)(buffer_lvl - high_water_mark);
- if (cpi->twopass.kf_group_bits < min_group_bits)
+ if (cpi->twopass.kf_group_bits < min_group_bits) {
cpi->twopass.kf_group_bits = min_group_bits;
+ }
}
/* We are above optimal but below the maximum */
else if (cpi->twopass.kf_group_bits < av_group_bits) {
}
}
}
- } else
+ } else {
cpi->twopass.kf_group_bits = 0;
+ }
/* Reset the first pass file position */
reset_fpf_position(cpi, start_position);
if (EOF == input_stats(cpi, &next_frame)) break;
- if (next_frame.intra_error > cpi->twopass.kf_intra_err_min)
+ if (next_frame.intra_error > cpi->twopass.kf_intra_err_min) {
r = (IIKFACTOR2 * next_frame.intra_error /
DOUBLE_DIVIDE_CHECK(next_frame.coded_error));
- else
+ } else {
r = (IIKFACTOR2 * cpi->twopass.kf_intra_err_min /
DOUBLE_DIVIDE_CHECK(next_frame.coded_error));
+ }
if (r > RMAX) r = RMAX;
DOUBLE_DIVIDE_CHECK(sectionstats.coded_error);
cpi->twopass.section_max_qfactor = 1.0 - ((Ratio - 10.0) * 0.025);
- if (cpi->twopass.section_max_qfactor < 0.80)
+ if (cpi->twopass.section_max_qfactor < 0.80) {
cpi->twopass.section_max_qfactor = 0.80;
+ }
}
/* When using CBR apply additional buffer fullness related upper limits */
int df_buffer_level = (int)(cpi->oxcf.drop_frames_water_mark *
(cpi->oxcf.optimal_buffer_level / 100));
- if (cpi->buffer_level > df_buffer_level)
+ if (cpi->buffer_level > df_buffer_level) {
max_boost =
((double)((cpi->buffer_level - df_buffer_level) * 2 / 3) * 16.0) /
DOUBLE_DIVIDE_CHECK((double)cpi->av_per_frame_bandwidth);
- else
+ } else {
max_boost = 0.0;
+ }
} else if (cpi->buffer_level > 0) {
max_boost = ((double)(cpi->buffer_level * 2 / 3) * 16.0) /
DOUBLE_DIVIDE_CHECK((double)cpi->av_per_frame_bandwidth);
/* bigger frame sizes need larger kf boosts, smaller frames smaller
* boosts...
*/
- if ((lst_yv12->y_width * lst_yv12->y_height) > (320 * 240))
+ if ((lst_yv12->y_width * lst_yv12->y_height) > (320 * 240)) {
kf_boost += 2 * (lst_yv12->y_width * lst_yv12->y_height) / (320 * 240);
- else if ((lst_yv12->y_width * lst_yv12->y_height) < (320 * 240))
+ } else if ((lst_yv12->y_width * lst_yv12->y_height) < (320 * 240)) {
kf_boost -= 4 * (320 * 240) / (lst_yv12->y_width * lst_yv12->y_height);
+ }
/* Min KF boost */
kf_boost = (int)((double)kf_boost * 100.0) >> 4; /* Scale 16 to 100 */
/* Apply an additional limit for CBR */
if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) {
- if (cpi->twopass.kf_bits > (int)((3 * cpi->buffer_level) >> 2))
+ if (cpi->twopass.kf_bits > (int)((3 * cpi->buffer_level) >> 2)) {
cpi->twopass.kf_bits = (int)((3 * cpi->buffer_level) >> 2);
+ }
}
/* If the key frame is actually easier than the average for the
double effective_size_ratio;
if ((cpi->common.Width != cpi->oxcf.Width) ||
- (cpi->common.Height != cpi->oxcf.Height))
+ (cpi->common.Height != cpi->oxcf.Height)) {
last_kf_resampled = 1;
+ }
/* Set back to unscaled by defaults */
cpi->common.horiz_scale = NORMAL;
/* Dont turn to resampling in easy sections just because they
* have been assigned a small number of bits
*/
- if (bits_per_frame < av_bits_per_frame)
+ if (bits_per_frame < av_bits_per_frame) {
bits_per_frame = av_bits_per_frame;
+ }
}
/* bits_per_frame should comply with our minimum */
- if (bits_per_frame <
- (cpi->oxcf.target_bandwidth * cpi->oxcf.two_pass_vbrmin_section / 100))
+ if (bits_per_frame < (cpi->oxcf.target_bandwidth *
+ cpi->oxcf.two_pass_vbrmin_section / 100)) {
bits_per_frame = (cpi->oxcf.target_bandwidth *
cpi->oxcf.two_pass_vbrmin_section / 100);
+ }
/* Work out if spatial resampling is necessary */
kf_q = estimate_kf_group_q(cpi, err_per_frame, (int)bits_per_frame,
cpi->oxcf.optimal_buffer_level / 100)) ||
(last_kf_resampled &&
(projected_buffer_level < (cpi->oxcf.resample_up_water_mark *
- cpi->oxcf.optimal_buffer_level / 100))))
+ cpi->oxcf.optimal_buffer_level / 100)))) {
resample_trigger = 1;
- else
+ } else {
resample_trigger = 0;
+ }
} else {
int64_t clip_bits = (int64_t)(
cpi->twopass.total_stats.count * cpi->oxcf.target_bandwidth /
* bits
*/
if ((last_kf_resampled && (kf_q > cpi->worst_quality)) ||
- ((kf_q > cpi->worst_quality) && (over_spend > clip_bits / 20)))
+ ((kf_q > cpi->worst_quality) && (over_spend > clip_bits / 20))) {
resample_trigger = 1;
- else
+ } else {
resample_trigger = 0;
+ }
}
if (resample_trigger) {
if (ctx->buf) {
unsigned int i;
- for (i = 0; i < ctx->max_sz; ++i)
+ for (i = 0; i < ctx->max_sz; ++i) {
vp8_yv12_de_alloc_frame_buffer(&ctx->buf[i].img);
+ }
free(ctx->buf);
}
free(ctx);
unsigned int i;
/* Clamp the lookahead queue depth */
- if (depth < 1)
+ if (depth < 1) {
depth = 1;
- else if (depth > MAX_LAG_BUFFERS)
+ } else if (depth > MAX_LAG_BUFFERS) {
depth = MAX_LAG_BUFFERS;
+ }
/* Keep last frame in lookahead buffer by increasing depth by 1.*/
depth += 1;
ctx->max_sz = depth;
ctx->buf = calloc(depth, sizeof(*ctx->buf));
if (!ctx->buf) goto bail;
- for (i = 0; i < depth; ++i)
+ for (i = 0; i < depth; ++i) {
if (vp8_yv12_alloc_frame_buffer(&ctx->buf[i].img, width, height,
- VP8BORDERINPIXELS))
+ VP8BORDERINPIXELS)) {
goto bail;
+ }
+ }
}
return ctx;
bail:
} else if (direction == PEEK_BACKWARD) {
assert(index == 1);
- if (ctx->read_idx == 0)
+ if (ctx->read_idx == 0) {
index = ctx->max_sz - 1;
- else
+ } else {
index = ctx->read_idx - index;
+ }
buf = ctx->buf + index;
}
static int mv_err_cost(int_mv *mv, int_mv *ref, int *mvcost[2],
int error_per_bit) {
/* Ignore mv costing if mvcost is NULL */
- if (mvcost)
+ if (mvcost) {
return ((mvcost[0][(mv->as_mv.row - ref->as_mv.row) >> 1] +
mvcost[1][(mv->as_mv.col - ref->as_mv.col) >> 1]) *
error_per_bit +
128) >>
8;
+ }
return 0;
}
int error_per_bit) {
/* Calculate sad error cost on full pixel basis. */
/* Ignore mv costing if mvsadcost is NULL */
- if (mvsadcost)
+ if (mvsadcost) {
return ((mvsadcost[0][(mv->as_mv.row - ref->as_mv.row)] +
mvsadcost[1][(mv->as_mv.col - ref->as_mv.col)]) *
error_per_bit +
128) >>
8;
+ }
return 0;
}
bestmv->as_mv.col = bc * 2;
if ((abs(bestmv->as_mv.col - ref_mv->as_mv.col) > (MAX_FULL_PEL_VAL << 3)) ||
- (abs(bestmv->as_mv.row - ref_mv->as_mv.row) > (MAX_FULL_PEL_VAL << 3)))
+ (abs(bestmv->as_mv.row - ref_mv->as_mv.row) > (MAX_FULL_PEL_VAL << 3))) {
return INT_MAX;
+ }
return besterr;
}
}
}
- if (best_site == -1)
+ if (best_site == -1) {
goto cal_neighbors;
- else {
+ } else {
br += hex[best_site].row;
bc += hex[best_site].col;
k = best_site;
}
}
- if (best_site == -1)
+ if (best_site == -1) {
break;
- else {
+ } else {
br += next_chkpts[k][best_site].row;
bc += next_chkpts[k][best_site].col;
k += 5 + best_site;
- if (k >= 12)
+ if (k >= 12) {
k -= 12;
- else if (k >= 6)
+ } else if (k >= 6) {
k -= 6;
+ }
}
}
}
}
- if (best_site == -1)
+ if (best_site == -1) {
break;
- else {
+ } else {
br += neighbors[best_site].row;
bc += neighbors[best_site].col;
}
best_mv->as_mv.col += ss[best_site].mv.col;
best_address += ss[best_site].offset;
last_site = best_site;
- } else if (best_address == in_what)
+ } else if (best_address == in_what) {
(*num00)++;
+ }
}
this_mv.as_mv.row = best_mv->as_mv.row << 3;
for (j = 0; j < x->searches_per_step; j += 4) {
const unsigned char *block_offset[4];
- for (t = 0; t < 4; ++t)
+ for (t = 0; t < 4; ++t) {
block_offset[t] = ss[i + t].offset + best_address;
+ }
fn_ptr->sdx4df(what, what_stride, block_offset, in_what_stride,
sad_array);
best_mv->as_mv.col += ss[best_site].mv.col;
best_address += ss[best_site].offset;
last_site = best_site;
- } else if (best_address == in_what)
+ } else if (best_address == in_what) {
(*num00)++;
+ }
}
this_mv.as_mv.row = best_mv->as_mv.row * 8;
}
}
- if (best_site == -1)
+ if (best_site == -1) {
break;
- else {
+ } else {
ref_mv->as_mv.row += neighbors[best_site].row;
ref_mv->as_mv.col += neighbors[best_site].col;
best_address += (neighbors[best_site].row) * in_what_stride +
}
}
- if (best_site == -1)
+ if (best_site == -1) {
break;
- else {
+ } else {
ref_mv->as_mv.row += neighbors[best_site].row;
ref_mv->as_mv.col += neighbors[best_site].col;
best_address += (neighbors[best_site].row) * in_what_stride +
lc->starting_buffer_level =
rescale((int)(oxcf->starting_buffer_level), lc->target_bandwidth, 1000);
- if (oxcf->optimal_buffer_level == 0)
+ if (oxcf->optimal_buffer_level == 0) {
lc->optimal_buffer_level = lc->target_bandwidth / 8;
- else
+ } else {
lc->optimal_buffer_level =
rescale((int)(oxcf->optimal_buffer_level), lc->target_bandwidth, 1000);
+ }
- if (oxcf->maximum_buffer_size == 0)
+ if (oxcf->maximum_buffer_size == 0) {
lc->maximum_buffer_size = lc->target_bandwidth / 8;
- else
+ } else {
lc->maximum_buffer_size =
rescale((int)(oxcf->maximum_buffer_size), lc->target_bandwidth, 1000);
+ }
/* Work out the average size of a frame within this layer */
- if (layer > 0)
+ if (layer > 0) {
lc->avg_frame_size_for_layer =
(int)((cpi->oxcf.target_bitrate[layer] -
cpi->oxcf.target_bitrate[layer - 1]) *
1000 / (lc->framerate - prev_layer_framerate));
+ }
lc->active_worst_quality = cpi->oxcf.worst_allowed_q;
lc->active_best_quality = cpi->oxcf.best_allowed_q;
if (cpi->cyclic_refresh_map[i] == 0) {
seg_map[i] = 1;
block_count--;
- } else if (cpi->cyclic_refresh_map[i] < 0)
+ } else if (cpi->cyclic_refresh_map[i] < 0) {
cpi->cyclic_refresh_map[i]++;
+ }
i++;
if (i == mbs_in_frame) i = 0;
cpi->mb.e_mbd.mode_lf_deltas[0] = 4; /* BPRED */
- if (cpi->oxcf.Mode == MODE_REALTIME)
+ if (cpi->oxcf.Mode == MODE_REALTIME) {
cpi->mb.e_mbd.mode_lf_deltas[1] = -12; /* Zero */
- else
+ } else {
cpi->mb.e_mbd.mode_lf_deltas[1] = -2; /* Zero */
+ }
cpi->mb.e_mbd.mode_lf_deltas[2] = 2; /* New mv */
cpi->mb.e_mbd.mode_lf_deltas[3] = 4; /* Split mv */
if (cpi->ref_frame_flags & VP8_ALTR_FRAME) ref_frames++;
/* Convert speed to continuous range, with clamping */
- if (Mode == 0)
+ if (Mode == 0) {
Speed = 0;
- else if (Mode == 2)
+ } else if (Mode == 2) {
Speed = RT(Speed);
- else {
+ } else {
if (Speed > 5) Speed = 5;
Speed = GOOD(Speed);
}
sum += cpi->mb.error_bins[i];
if (10 * sum >=
- (unsigned int)(cpi->Speed - 6) * (total_mbs - total_skip))
+ (unsigned int)(cpi->Speed - 6) * (total_mbs - total_skip)) {
break;
+ }
}
i--;
cpi->find_fractional_mv_step = vp8_skip_fractional_mv_step;
}
- if (cpi->sf.optimize_coefficients == 1 && cpi->pass != 1)
+ if (cpi->sf.optimize_coefficients == 1 && cpi->pass != 1) {
cpi->mb.optimize = 1;
- else
+ } else {
cpi->mb.optimize = 0;
+ }
- if (cpi->common.full_pixel)
+ if (cpi->common.full_pixel) {
cpi->find_fractional_mv_step = vp8_skip_fractional_mv_step;
+ }
#ifdef SPEEDSTATS
frames_at_speed[cpi->Speed]++;
cpi->lookahead = vp8_lookahead_init(cpi->oxcf.Width, cpi->oxcf.Height,
cpi->oxcf.lag_in_frames);
- if (!cpi->lookahead)
+ if (!cpi->lookahead) {
vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
"Failed to allocate lag buffers");
+ }
#if VP8_TEMPORAL_ALT_REF
if (vp8_yv12_alloc_frame_buffer(&cpi->alt_ref_buffer, width, height,
- VP8BORDERINPIXELS))
+ VP8BORDERINPIXELS)) {
vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
"Failed to allocate altref buffer");
+ }
#endif
}
int prev_mb_rows = cm->mb_rows;
#endif
- if (vp8_alloc_frame_buffers(cm, width, height))
+ if (vp8_alloc_frame_buffers(cm, width, height)) {
vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
"Failed to allocate frame buffers");
+ }
- if (vp8_alloc_partition_data(cpi))
+ 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);
if ((height & 0xf) != 0) height += 16 - (height & 0xf);
if (vp8_yv12_alloc_frame_buffer(&cpi->pick_lf_lvl_frame, width, height,
- VP8BORDERINPIXELS))
+ VP8BORDERINPIXELS)) {
vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
"Failed to allocate last frame buffer");
+ }
if (vp8_yv12_alloc_frame_buffer(&cpi->scaled_source, width, height,
- VP8BORDERINPIXELS))
+ VP8BORDERINPIXELS)) {
vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
"Failed to allocate scaled source buffer");
+ }
vpx_free(cpi->tok);
memset(cpi->active_map, 1, (cm->mb_rows * cm->mb_cols));
#if CONFIG_MULTITHREAD
- if (width < 640)
+ if (width < 640) {
cpi->mt_sync_range = 1;
- else if (width <= 1280)
+ } else if (width <= 1280) {
cpi->mt_sync_range = 4;
- else if (width <= 2560)
+ } else if (width <= 2560) {
cpi->mt_sync_range = 8;
- else
+ } else {
cpi->mt_sync_range = 16;
+ }
if (cpi->oxcf.multi_threaded > 1) {
int i;
if (cpi->oxcf.noise_sensitivity > 0) {
vp8_denoiser_free(&cpi->denoiser);
if (vp8_denoiser_allocate(&cpi->denoiser, width, height, cm->mb_rows,
- cm->mb_cols, cpi->oxcf.noise_sensitivity))
+ cm->mb_cols, cpi->oxcf.noise_sensitivity)) {
vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
"Failed to allocate denoiser");
+ }
}
#endif
}
int vp8_reverse_trans(int x) {
int i;
- for (i = 0; i < 64; ++i)
+ for (i = 0; i < 64; ++i) {
if (q_trans[i] >= x) return i;
+ }
return 63;
}
/* Special conditions when altr ref frame enabled in lagged compress mode */
if (cpi->oxcf.play_alternate && cpi->oxcf.lag_in_frames) {
- if (cpi->max_gf_interval > cpi->oxcf.lag_in_frames - 1)
+ if (cpi->max_gf_interval > cpi->oxcf.lag_in_frames - 1) {
cpi->max_gf_interval = cpi->oxcf.lag_in_frames - 1;
+ }
- if (cpi->twopass.static_scene_max_gf_interval > cpi->oxcf.lag_in_frames - 1)
+ if (cpi->twopass.static_scene_max_gf_interval >
+ cpi->oxcf.lag_in_frames - 1) {
cpi->twopass.static_scene_max_gf_interval = cpi->oxcf.lag_in_frames - 1;
+ }
}
- if (cpi->max_gf_interval > cpi->twopass.static_scene_max_gf_interval)
+ if (cpi->max_gf_interval > cpi->twopass.static_scene_max_gf_interval) {
cpi->max_gf_interval = cpi->twopass.static_scene_max_gf_interval;
+ }
}
static void init_config(VP8_COMP *cpi, VP8_CONFIG *oxcf) {
lc->starting_buffer_level = rescale(
(int)oxcf->starting_buffer_level_in_ms, lc->target_bandwidth, 1000);
- if (oxcf->optimal_buffer_level == 0)
+ if (oxcf->optimal_buffer_level == 0) {
lc->optimal_buffer_level = lc->target_bandwidth / 8;
- else
+ } else {
lc->optimal_buffer_level = rescale(
(int)oxcf->optimal_buffer_level_in_ms, lc->target_bandwidth, 1000);
+ }
- if (oxcf->maximum_buffer_size == 0)
+ if (oxcf->maximum_buffer_size == 0) {
lc->maximum_buffer_size = lc->target_bandwidth / 8;
- else
+ } else {
lc->maximum_buffer_size = rescale((int)oxcf->maximum_buffer_size_in_ms,
lc->target_bandwidth, 1000);
+ }
/* Work out the average size of a frame within this layer */
- if (i > 0)
+ if (i > 0) {
lc->avg_frame_size_for_layer =
(int)((oxcf->target_bitrate[i] - oxcf->target_bitrate[i - 1]) *
1000 / (lc->framerate - prev_layer_framerate));
+ }
prev_layer_framerate = lc->framerate;
}
cpi->oxcf.cq_level = q_trans[cpi->oxcf.cq_level];
if (oxcf->fixed_q >= 0) {
- if (oxcf->worst_allowed_q < 0)
+ if (oxcf->worst_allowed_q < 0) {
cpi->oxcf.fixed_q = q_trans[0];
- else
+ } else {
cpi->oxcf.fixed_q = q_trans[oxcf->worst_allowed_q];
+ }
- if (oxcf->alt_q < 0)
+ if (oxcf->alt_q < 0) {
cpi->oxcf.alt_q = q_trans[0];
- else
+ } else {
cpi->oxcf.alt_q = q_trans[oxcf->alt_q];
+ }
- if (oxcf->key_q < 0)
+ if (oxcf->key_q < 0) {
cpi->oxcf.key_q = q_trans[0];
- else
+ } else {
cpi->oxcf.key_q = q_trans[oxcf->key_q];
+ }
- if (oxcf->gold_q < 0)
+ if (oxcf->gold_q < 0) {
cpi->oxcf.gold_q = q_trans[0];
- else
+ } else {
cpi->oxcf.gold_q = q_trans[oxcf->gold_q];
+ }
}
cpi->baseline_gf_interval =
cpi->oxcf.token_partitions = 3;
#endif
- if (cpi->oxcf.token_partitions >= 0 && cpi->oxcf.token_partitions <= 3)
+ if (cpi->oxcf.token_partitions >= 0 && cpi->oxcf.token_partitions <= 3) {
cm->multi_token_partition = (TOKEN_PARTITION)cpi->oxcf.token_partitions;
+ }
setup_features(cpi);
{
int i;
- for (i = 0; i < MAX_MB_SEGMENTS; ++i)
+ for (i = 0; i < MAX_MB_SEGMENTS; ++i) {
cpi->segment_encode_breakout[i] = cpi->oxcf.encode_breakout;
+ }
}
/* At the moment the first order values may not be > MAXQ */
(int)cpi->oxcf.starting_buffer_level, cpi->oxcf.target_bandwidth, 1000);
/* Set or reset optimal and maximum buffer levels. */
- if (cpi->oxcf.optimal_buffer_level == 0)
+ if (cpi->oxcf.optimal_buffer_level == 0) {
cpi->oxcf.optimal_buffer_level = cpi->oxcf.target_bandwidth / 8;
- else
+ } else {
cpi->oxcf.optimal_buffer_level = rescale(
(int)cpi->oxcf.optimal_buffer_level, cpi->oxcf.target_bandwidth, 1000);
+ }
- if (cpi->oxcf.maximum_buffer_size == 0)
+ if (cpi->oxcf.maximum_buffer_size == 0) {
cpi->oxcf.maximum_buffer_size = cpi->oxcf.target_bandwidth / 8;
- else
+ } else {
cpi->oxcf.maximum_buffer_size = rescale((int)cpi->oxcf.maximum_buffer_size,
cpi->oxcf.target_bandwidth, 1000);
+ }
// Under a configuration change, where maximum_buffer_size may change,
// keep buffer level clipped to the maximum allowed buffer size.
if (cpi->bits_off_target > cpi->oxcf.maximum_buffer_size) {
cm->Height = (vs - 1 + cpi->oxcf.Height * vr) / vs;
}
- if (last_w != cpi->oxcf.Width || last_h != cpi->oxcf.Height)
+ if (last_w != cpi->oxcf.Width || last_h != cpi->oxcf.Height) {
cpi->force_next_frame_intra = 1;
+ }
if (((cm->Width + 15) & ~15) != cm->yv12_fb[cm->lst_fb_idx].y_width ||
((cm->Height + 15) & ~15) != cm->yv12_fb[cm->lst_fb_idx].y_height ||
cpi->oxcf.allow_lag = 0;
}
/* Limit on lag buffers as these are not currently dynamically allocated */
- else if (cpi->oxcf.lag_in_frames > MAX_LAG_BUFFERS)
+ else if (cpi->oxcf.lag_in_frames > MAX_LAG_BUFFERS) {
cpi->oxcf.lag_in_frames = MAX_LAG_BUFFERS;
+ }
/* YX Temp */
cpi->alt_ref_source = NULL;
int width = (cpi->oxcf.Width + 15) & ~15;
int height = (cpi->oxcf.Height + 15) & ~15;
if (vp8_denoiser_allocate(&cpi->denoiser, width, height, cm->mb_rows,
- cm->mb_cols, cpi->oxcf.noise_sensitivity))
+ cm->mb_cols, cpi->oxcf.noise_sensitivity)) {
vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
"Failed to allocate denoiser");
+ }
}
}
#endif
if (cpi->cyclic_refresh_mode_enabled) {
CHECK_MEM_ERROR(cpi->cyclic_refresh_map,
vpx_calloc((cpi->common.mb_rows * cpi->common.mb_cols), 1));
- } else
+ } else {
cpi->cyclic_refresh_map = (signed char *)NULL;
+ }
CHECK_MEM_ERROR(cpi->consec_zero_last,
vpx_calloc(cm->mb_rows * cm->mb_cols, 1));
pkt.data.psnr.samples[0] += width * height;
pkt.data.psnr.samples[3] = width * height;
- for (i = 0; i < 4; ++i)
+ for (i = 0; i < 4; ++i) {
pkt.data.psnr.psnr[i] = vpx_sse_to_psnr(pkt.data.psnr.samples[i], 255.0,
(double)(pkt.data.psnr.sse[i]));
+ }
vpx_codec_pkt_list_add(cpi->output_pkt_list, &pkt);
}
VP8_COMMON *cm = &cpi->common;
int ref_fb_idx;
- if (ref_frame_flag == VP8_LAST_FRAME)
+ if (ref_frame_flag == VP8_LAST_FRAME) {
ref_fb_idx = cm->lst_fb_idx;
- else if (ref_frame_flag == VP8_GOLD_FRAME)
+ } else if (ref_frame_flag == VP8_GOLD_FRAME) {
ref_fb_idx = cm->gld_fb_idx;
- else if (ref_frame_flag == VP8_ALTR_FRAME)
+ } else if (ref_frame_flag == VP8_ALTR_FRAME) {
ref_fb_idx = cm->alt_fb_idx;
- else
+ } else {
return -1;
+ }
vp8_yv12_copy_frame(&cm->yv12_fb[ref_fb_idx], sd);
int ref_fb_idx;
- if (ref_frame_flag == VP8_LAST_FRAME)
+ if (ref_frame_flag == VP8_LAST_FRAME) {
ref_fb_idx = cm->lst_fb_idx;
- else if (ref_frame_flag == VP8_GOLD_FRAME)
+ } else if (ref_frame_flag == VP8_GOLD_FRAME) {
ref_fb_idx = cm->gld_fb_idx;
- else if (ref_frame_flag == VP8_ALTR_FRAME)
+ } else if (ref_frame_flag == VP8_ALTR_FRAME) {
ref_fb_idx = cm->alt_fb_idx;
- else
+ } else {
return -1;
+ }
vp8_yv12_copy_frame(sd, &cm->yv12_fb[ref_fb_idx]);
int UNINITIALIZED_IS_SAFE(vr), UNINITIALIZED_IS_SAFE(vs);
int tmp_height;
- if (cm->vert_scale == 3)
+ if (cm->vert_scale == 3) {
tmp_height = 9;
- else
+ } else {
tmp_height = 11;
+ }
Scale2Ratio(cm->horiz_scale, &hr, &hs);
Scale2Ratio(cm->vert_scale, &vr, &vs);
vp8_yv12_extend_frame_borders(&cpi->scaled_source);
cpi->Source = &cpi->scaled_source;
#endif
- } else
+ } else {
cpi->Source = sd;
+ }
}
static int resize_key_frame(VP8_COMP *cpi) {
}
#if CONFIG_MULTITHREAD
- if (cpi->b_multi_threaded)
+ if (cpi->b_multi_threaded) {
sem_post(&cpi->h_event_end_lpf); /* signal that we have set filter_level */
+ }
#endif
// No need to apply loop-filter if the encoded frame does not update
}
/* Current default encoder behaviour for the altref sign bias */
- if (cpi->source_alt_ref_active)
+ if (cpi->source_alt_ref_active) {
cpi->common.ref_frame_sign_bias[ALTREF_FRAME] = 1;
- else
+ } else {
cpi->common.ref_frame_sign_bias[ALTREF_FRAME] = 0;
+ }
/* Check to see if a key frame is signaled
* For two pass with auto key frame enabled cm->frame_type may already
/* The reset to decimation 0 is only done here for one pass.
* Once it is set two pass leaves decimation on till the next kf.
*/
- if ((cpi->buffer_level > drop_mark) && (cpi->decimation_factor > 0))
+ if ((cpi->buffer_level > drop_mark) && (cpi->decimation_factor > 0)) {
cpi->decimation_factor--;
+ }
- if (cpi->buffer_level > drop_mark75 && cpi->decimation_factor > 0)
+ if (cpi->buffer_level > drop_mark75 && cpi->decimation_factor > 0) {
cpi->decimation_factor = 1;
- else if (cpi->buffer_level < drop_mark25 &&
- (cpi->decimation_factor == 2 || cpi->decimation_factor == 3)) {
+ } else if (cpi->buffer_level < drop_mark25 &&
+ (cpi->decimation_factor == 2 || cpi->decimation_factor == 3)) {
cpi->decimation_factor = 3;
} else if (cpi->buffer_level < drop_mark50 &&
(cpi->decimation_factor == 1 || cpi->decimation_factor == 2)) {
cpi->decimation_count--;
cpi->bits_off_target += cpi->av_per_frame_bandwidth;
- if (cpi->bits_off_target > cpi->oxcf.maximum_buffer_size)
+ if (cpi->bits_off_target > cpi->oxcf.maximum_buffer_size) {
cpi->bits_off_target = cpi->oxcf.maximum_buffer_size;
+ }
#if CONFIG_MULTI_RES_ENCODING
vp8_store_drop_frame_info(cpi);
for (i = cpi->current_layer + 1; i < cpi->oxcf.number_of_layers; ++i) {
LAYER_CONTEXT *lc = &cpi->layer_context[i];
lc->bits_off_target += (int)(lc->target_bandwidth / lc->framerate);
- if (lc->bits_off_target > lc->maximum_buffer_size)
+ if (lc->bits_off_target > lc->maximum_buffer_size) {
lc->bits_off_target = lc->maximum_buffer_size;
+ }
lc->buffer_level = lc->bits_off_target;
}
}
return;
- } else
+ } else {
cpi->decimation_count = cpi->decimation_factor;
- } else
+ }
+ } else {
cpi->decimation_count = 0;
+ }
/* Decide how big to make the frame */
if (!vp8_pick_frame_size(cpi)) {
cpi->oxcf.optimal_buffer_level) /
Adjustment);
- if (buff_lvl_step)
+ if (buff_lvl_step) {
Adjustment =
(int)((cpi->buffer_level - cpi->oxcf.optimal_buffer_level) /
buff_lvl_step);
- else
+ } else {
Adjustment = 0;
+ }
}
cpi->active_worst_quality -= Adjustment;
- if (cpi->active_worst_quality < cpi->active_best_quality)
+ if (cpi->active_worst_quality < cpi->active_best_quality) {
cpi->active_worst_quality = cpi->active_best_quality;
+ }
}
}
if (cm->frame_type == KEY_FRAME) {
if (cpi->pass == 2) {
- if (cpi->gfu_boost > 600)
+ if (cpi->gfu_boost > 600) {
cpi->active_best_quality = kf_low_motion_minq[Q];
- else
+ } else {
cpi->active_best_quality = kf_high_motion_minq[Q];
+ }
/* Special case for key frames forced because we have reached
* the maximum key frame interval. Here force the Q to a range
* based on the ambient Q to reduce the risk of popping
*/
if (cpi->this_key_frame_forced) {
- if (cpi->active_best_quality > cpi->avg_frame_qindex * 7 / 8)
+ if (cpi->active_best_quality > cpi->avg_frame_qindex * 7 / 8) {
cpi->active_best_quality = cpi->avg_frame_qindex * 7 / 8;
- else if (cpi->active_best_quality<cpi->avg_frame_qindex>> 2)
+ } else if (cpi->active_best_quality<cpi->avg_frame_qindex>> 2) {
cpi->active_best_quality = cpi->avg_frame_qindex >> 2;
+ }
}
}
/* One pass more conservative */
- else
+ else {
cpi->active_best_quality = kf_high_motion_minq[Q];
+ }
}
else if (cpi->oxcf.number_of_layers == 1 &&
}
if (cpi->pass == 2) {
- if (cpi->gfu_boost > 1000)
+ if (cpi->gfu_boost > 1000) {
cpi->active_best_quality = gf_low_motion_minq[Q];
- else if (cpi->gfu_boost < 400)
+ } else if (cpi->gfu_boost < 400) {
cpi->active_best_quality = gf_high_motion_minq[Q];
- else
+ } else {
cpi->active_best_quality = gf_mid_motion_minq[Q];
+ }
/* Constrained quality use slightly lower active best. */
if (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) {
}
}
/* One pass more conservative */
- else
+ else {
cpi->active_best_quality = gf_high_motion_minq[Q];
+ }
} else {
cpi->active_best_quality = inter_minq[Q];
* frames then use the user passed in cq value not the auto
* cq value.
*/
- if (cpi->rolling_actual_bits < cpi->min_frame_bandwidth)
+ if (cpi->rolling_actual_bits < cpi->min_frame_bandwidth) {
cpi->active_best_quality = cpi->oxcf.cq_level;
- else
+ } else {
cpi->active_best_quality = cpi->cq_target_quality;
+ }
}
}
/* Note that the use of >= here elliminates the risk of a devide
* by 0 error in the else if clause
*/
- if (cpi->buffer_level >= cpi->oxcf.maximum_buffer_size)
+ if (cpi->buffer_level >= cpi->oxcf.maximum_buffer_size) {
cpi->active_best_quality = cpi->best_quality;
- else if (cpi->buffer_level > cpi->oxcf.optimal_buffer_level) {
+ } else if (cpi->buffer_level > cpi->oxcf.optimal_buffer_level) {
int Fraction =
(int)(((cpi->buffer_level - cpi->oxcf.optimal_buffer_level) * 128) /
(cpi->oxcf.maximum_buffer_size -
}
/* Clip the active best and worst quality values to limits */
- if (cpi->active_worst_quality > cpi->worst_quality)
+ if (cpi->active_worst_quality > cpi->worst_quality) {
cpi->active_worst_quality = cpi->worst_quality;
+ }
- if (cpi->active_best_quality < cpi->best_quality)
+ if (cpi->active_best_quality < cpi->best_quality) {
cpi->active_best_quality = cpi->best_quality;
+ }
- if (cpi->active_worst_quality < cpi->active_best_quality)
+ if (cpi->active_worst_quality < cpi->active_best_quality) {
cpi->active_worst_quality = cpi->active_best_quality;
+ }
/* Determine initial Q to try */
Q = vp8_regulate_q(cpi, cpi->this_frame_target);
#if !CONFIG_REALTIME_ONLY
/* Set highest allowed value for Zbin over quant */
- if (cm->frame_type == KEY_FRAME)
+ if (cm->frame_type == KEY_FRAME) {
zbin_oq_high = 0;
- else if ((cpi->oxcf.number_of_layers == 1) &&
- ((cm->refresh_alt_ref_frame ||
- (cm->refresh_golden_frame && !cpi->source_alt_ref_active)))) {
+ } else if ((cpi->oxcf.number_of_layers == 1) &&
+ ((cm->refresh_alt_ref_frame ||
+ (cm->refresh_golden_frame && !cpi->source_alt_ref_active)))) {
zbin_oq_high = 16;
- } else
+ } else {
zbin_oq_high = ZBIN_OQ_MAX;
+ }
#endif
/* Setup background Q adjustment for error resilient mode.
// Special case for screen_content_mode with golden frame updates.
int disable_cr_gf =
(cpi->oxcf.screen_content_mode == 2 && cm->refresh_golden_frame);
- if (cpi->current_layer == 0 && cpi->force_maxqp == 0 && !disable_cr_gf)
+ if (cpi->current_layer == 0 && cpi->force_maxqp == 0 && !disable_cr_gf) {
cyclic_background_refresh(cpi, Q, 0);
- else
+ } else {
disable_segmentation(cpi);
+ }
}
vp8_compute_frame_size_bounds(cpi, &frame_under_shoot_limit,
if (cm->frame_type != KEY_FRAME) {
if (cpi->common.refresh_alt_ref_frame) {
- if (cpi->last_skip_false_probs[2] != 0)
+ if (cpi->last_skip_false_probs[2] != 0) {
cpi->prob_skip_false = cpi->last_skip_false_probs[2];
+ }
/*
if(cpi->last_skip_false_probs[2]!=0 && abs(Q-
cpi->prob_skip_false ) / 2;
*/
} else if (cpi->common.refresh_golden_frame) {
- if (cpi->last_skip_false_probs[1] != 0)
+ if (cpi->last_skip_false_probs[1] != 0) {
cpi->prob_skip_false = cpi->last_skip_false_probs[1];
+ }
/*
if(cpi->last_skip_false_probs[1]!=0 && abs(Q-
cpi->prob_skip_false ) / 2;
*/
} else {
- if (cpi->last_skip_false_probs[0] != 0)
+ if (cpi->last_skip_false_probs[0] != 0) {
cpi->prob_skip_false = cpi->last_skip_false_probs[0];
+ }
/*
if(cpi->last_skip_false_probs[0]!=0 && abs(Q-
if (cpi->prob_skip_false > 250) cpi->prob_skip_false = 250;
- if (cpi->oxcf.number_of_layers == 1 && cpi->is_src_frame_alt_ref)
+ if (cpi->oxcf.number_of_layers == 1 && cpi->is_src_frame_alt_ref) {
cpi->prob_skip_false = 1;
+ }
}
#if 0
*/
Q = vp8_regulate_q(cpi, cpi->this_frame_target);
if (cpi->cyclic_refresh_mode_enabled) {
- if (cpi->current_layer == 0)
+ if (cpi->current_layer == 0) {
cyclic_background_refresh(cpi, Q, 0);
- else
+ } else {
disable_segmentation(cpi);
+ }
}
// Reset the zero_last counter to 0 on key frame.
memset(cpi->consec_zero_last, 0, cm->mb_rows * cm->mb_cols);
* vp8_update_rate_correction_factors() this loop.
*/
active_worst_qchanged = 1;
- } else
+ } else {
active_worst_qchanged = 0;
+ }
#if !CONFIG_REALTIME_ONLY
/* Special case handling for forced key frames */
}
/* Clamp Q to upper and lower limits: */
- if (Q > q_high)
+ if (Q > q_high) {
Q = q_high;
- else if (Q < q_low)
+ } else if (Q < q_low) {
Q = q_low;
+ }
Loop = Q != last_q;
}
q_low = (Q < q_high) ? (Q + 1) : q_high;
/* If we are using over quant do the same for zbin_oq_low */
- if (cpi->mb.zbin_over_quant > 0)
+ if (cpi->mb.zbin_over_quant > 0) {
zbin_oq_low = (cpi->mb.zbin_over_quant < zbin_oq_high)
? (cpi->mb.zbin_over_quant + 1)
: zbin_oq_high;
+ }
if (undershoot_seen) {
/* Update rate_correction_factor unless
* cpi->active_worst_quality has changed.
*/
- if (!active_worst_qchanged)
+ if (!active_worst_qchanged) {
vp8_update_rate_correction_factors(cpi, 1);
+ }
Q = (q_high + q_low + 1) / 2;
/* Adjust cpi->zbin_over_quant (only allowed when Q
* is max)
*/
- if (Q < MAXQ)
+ if (Q < MAXQ) {
cpi->mb.zbin_over_quant = 0;
- else {
+ } else {
zbin_oq_low = (cpi->mb.zbin_over_quant < zbin_oq_high)
? (cpi->mb.zbin_over_quant + 1)
: zbin_oq_high;
/* Update rate_correction_factor unless
* cpi->active_worst_quality has changed.
*/
- if (!active_worst_qchanged)
+ if (!active_worst_qchanged) {
vp8_update_rate_correction_factors(cpi, 0);
+ }
Q = vp8_regulate_q(cpi, cpi->this_frame_target);
}
/* Frame is too small */
else {
- if (cpi->mb.zbin_over_quant == 0)
+ if (cpi->mb.zbin_over_quant == 0) {
/* Lower q_high if not using over quant */
q_high = (Q > q_low) ? (Q - 1) : q_low;
- else
+ } else {
/* else lower zbin_oq_high */
zbin_oq_high = (cpi->mb.zbin_over_quant > zbin_oq_low)
? (cpi->mb.zbin_over_quant - 1)
: zbin_oq_low;
+ }
if (overshoot_seen) {
/* Update rate_correction_factor unless
* cpi->active_worst_quality has changed.
*/
- if (!active_worst_qchanged)
+ if (!active_worst_qchanged) {
vp8_update_rate_correction_factors(cpi, 1);
+ }
Q = (q_high + q_low) / 2;
/* Adjust cpi->zbin_over_quant (only allowed when Q
* is max)
*/
- if (Q < MAXQ)
+ if (Q < MAXQ) {
cpi->mb.zbin_over_quant = 0;
- else
+ } else {
cpi->mb.zbin_over_quant = (zbin_oq_high + zbin_oq_low) / 2;
+ }
} else {
/* Update rate_correction_factor unless
* cpi->active_worst_quality has changed.
*/
- if (!active_worst_qchanged)
+ if (!active_worst_qchanged) {
vp8_update_rate_correction_factors(cpi, 0);
+ }
Q = vp8_regulate_q(cpi, cpi->this_frame_target);
}
/* Clamp Q to upper and lower limits: */
- if (Q > q_high)
+ if (Q > q_high) {
Q = q_high;
- else if (Q < q_low)
+ } else if (Q < q_low) {
Q = q_low;
+ }
/* Clamp cpi->zbin_over_quant */
cpi->mb.zbin_over_quant = (cpi->mb.zbin_over_quant < zbin_oq_low)
if (cm->frame_type != KEY_FRAME) {
for (mb_row = 0; mb_row < cm->mb_rows + 1; ++mb_row) {
for (mb_col = 0; mb_col < cm->mb_cols + 1; ++mb_col) {
- if (tmp->mbmi.ref_frame != INTRA_FRAME)
+ if (tmp->mbmi.ref_frame != INTRA_FRAME) {
cpi->lfmv[mb_col + mb_row * (cm->mode_info_stride + 1)].as_int =
tmp->mbmi.mv.as_int;
+ }
cpi->lf_ref_frame_sign_bias[mb_col +
mb_row * (cm->mode_info_stride + 1)] =
if (cm->frame_type != KEY_FRAME) {
for (mb_row = 0; mb_row < cm->mb_rows; ++mb_row) {
for (mb_col = 0; mb_col < cm->mb_cols; ++mb_col) {
- if (tmp->mbmi.mode == ZEROMV && tmp->mbmi.ref_frame == LAST_FRAME)
+ if (tmp->mbmi.mode == ZEROMV && tmp->mbmi.ref_frame == LAST_FRAME) {
cpi->zeromv_count++;
+ }
tmp++;
}
tmp++;
* This is done after completing the compression of a frame when all
* modes etc. are finalized but before loop filter
*/
- if (cpi->oxcf.number_of_layers == 1)
+ if (cpi->oxcf.number_of_layers == 1) {
vp8_update_gf_useage_maps(cpi, cm, &cpi->mb);
+ }
if (cm->frame_type == KEY_FRAME) cm->refresh_last_frame = 1;
* cm->refresh_golden_frame is set we copy the old GF over to the ARF buffer
* This is purely an encoder decision at present.
*/
- if (!cpi->oxcf.error_resilient_mode && cm->refresh_golden_frame)
+ if (!cpi->oxcf.error_resilient_mode && cm->refresh_golden_frame) {
cm->copy_buffer_to_arf = 2;
- else
+ } else {
cm->copy_buffer_to_arf = 0;
+ }
cm->frame_to_show = &cm->yv12_fb[cm->new_fb_idx];
if (cpi->oxcf.number_of_layers > 1) {
unsigned int i;
- for (i = cpi->current_layer + 1; i < cpi->oxcf.number_of_layers; ++i)
+ for (i = cpi->current_layer + 1; i < cpi->oxcf.number_of_layers; ++i) {
cpi->layer_context[i].total_byte_count += (*size);
+ }
}
if (!active_worst_qchanged) vp8_update_rate_correction_factors(cpi, 2);
}
/* Keep a record of ambient average Q. */
- if (cm->frame_type != KEY_FRAME)
+ if (cm->frame_type != KEY_FRAME) {
cpi->avg_frame_qindex =
(2 + 3 * cpi->avg_frame_qindex + cm->base_qindex) >> 2;
+ }
/* Keep a record from which we can calculate the average Q excluding
* GF updates and key frames
/* Update the buffer level variable. */
/* Non-viewable frames are a special case and are treated as pure overhead. */
- if (!cm->show_frame)
+ if (!cm->show_frame) {
cpi->bits_off_target -= cpi->projected_frame_size;
- else
+ } else {
cpi->bits_off_target +=
cpi->av_per_frame_bandwidth - cpi->projected_frame_size;
+ }
/* Clip the buffer level to the maximum specified buffer size */
- if (cpi->bits_off_target > cpi->oxcf.maximum_buffer_size)
+ if (cpi->bits_off_target > cpi->oxcf.maximum_buffer_size) {
cpi->bits_off_target = cpi->oxcf.maximum_buffer_size;
+ }
// If the frame dropper is not enabled, don't let the buffer level go below
// some threshold, given here by -|maximum_buffer_size|. For now we only do
// this for screen content input.
if (cpi->drop_frames_allowed == 0 && cpi->oxcf.screen_content_mode &&
- cpi->bits_off_target < -cpi->oxcf.maximum_buffer_size)
+ cpi->bits_off_target < -cpi->oxcf.maximum_buffer_size) {
cpi->bits_off_target = -cpi->oxcf.maximum_buffer_size;
+ }
/* Rolling monitors of whether we are over or underspending used to
* help regulate min and Max Q in two pass.
lc->bits_off_target += bits_off_for_this_layer;
/* Clip buffer level to maximum buffer size for the layer */
- if (lc->bits_off_target > lc->maximum_buffer_size)
+ if (lc->bits_off_target > lc->maximum_buffer_size) {
lc->bits_off_target = lc->maximum_buffer_size;
+ }
lc->total_actual_bits += cpi->projected_frame_size;
lc->total_target_vs_actual += bits_off_for_this_layer;
#endif
- if (cm->refresh_golden_frame == 1)
+ if (cm->refresh_golden_frame == 1) {
cm->frame_flags = cm->frame_flags | FRAMEFLAGS_GOLDEN;
- else
+ } else {
cm->frame_flags = cm->frame_flags & ~FRAMEFLAGS_GOLDEN;
+ }
- if (cm->refresh_alt_ref_frame == 1)
+ if (cm->refresh_alt_ref_frame == 1) {
cm->frame_flags = cm->frame_flags | FRAMEFLAGS_ALTREF;
- else
+ } else {
cm->frame_flags = cm->frame_flags & ~FRAMEFLAGS_ALTREF;
+ }
- if (cm->refresh_last_frame & cm->refresh_golden_frame) /* both refreshed */
+ if (cm->refresh_last_frame & cm->refresh_golden_frame) { /* both refreshed */
cpi->gold_is_last = 1;
- else if (cm->refresh_last_frame ^ cm->refresh_golden_frame)
+ } else if (cm->refresh_last_frame ^ cm->refresh_golden_frame) {
/* 1 refreshed but not the other */
cpi->gold_is_last = 0;
+ }
- if (cm->refresh_last_frame & cm->refresh_alt_ref_frame) /* both refreshed */
+ if (cm->refresh_last_frame & cm->refresh_alt_ref_frame) { /* both refreshed */
cpi->alt_is_last = 1;
- else if (cm->refresh_last_frame ^ cm->refresh_alt_ref_frame)
+ } else if (cm->refresh_last_frame ^ cm->refresh_alt_ref_frame) {
/* 1 refreshed but not the other */
cpi->alt_is_last = 0;
+ }
- if (cm->refresh_alt_ref_frame & cm->refresh_golden_frame) /* both refreshed */
+ if (cm->refresh_alt_ref_frame &
+ cm->refresh_golden_frame) { /* both refreshed */
cpi->gold_is_alt = 1;
- else if (cm->refresh_alt_ref_frame ^ cm->refresh_golden_frame)
+ } else if (cm->refresh_alt_ref_frame ^ cm->refresh_golden_frame) {
/* 1 refreshed but not the other */
cpi->gold_is_alt = 0;
+ }
cpi->ref_frame_flags = VP8_ALTR_FRAME | VP8_GOLD_FRAME | VP8_LAST_FRAME;
if (!cpi->oxcf.error_resilient_mode) {
if (cpi->oxcf.play_alternate && cm->refresh_alt_ref_frame &&
- (cm->frame_type != KEY_FRAME))
+ (cm->frame_type != KEY_FRAME)) {
/* Update the alternate reference frame stats as appropriate. */
update_alt_ref_frame_stats(cpi);
- else
+ } else {
/* Update the Golden frame stats as appropriate. */
update_golden_frame_stats(cpi);
+ }
}
if (cm->frame_type == KEY_FRAME) {
}
if (vp8_lookahead_push(cpi->lookahead, sd, time_stamp, end_time, frame_flags,
- cpi->active_map_enabled ? cpi->active_map : NULL))
+ cpi->active_map_enabled ? cpi->active_map : NULL)) {
res = -1;
+ }
vpx_usec_timer_mark(&timer);
cpi->time_receive_data += vpx_usec_timer_elapsed(&timer);
/* Read last frame source if we are encoding first pass. */
if (cpi->pass == 1 && cm->current_video_frame > 0) {
if ((cpi->last_source =
- vp8_lookahead_peek(cpi->lookahead, 1, PEEK_BACKWARD)) == NULL)
+ vp8_lookahead_peek(cpi->lookahead, 1, PEEK_BACKWARD)) == NULL) {
return -1;
+ }
}
if ((cpi->source = vp8_lookahead_pop(cpi->lookahead, flush))) {
this_duration = cpi->source->ts_end - cpi->last_end_time_stamp_seen;
last_duration = cpi->last_end_time_stamp_seen - cpi->last_time_stamp_seen;
/* do a step update if the duration changes by 10% */
- if (last_duration)
+ if (last_duration) {
step = (int)(((this_duration - last_duration) * 10 / last_duration));
+ }
}
if (this_duration) {
- if (step)
+ if (step) {
cpi->ref_framerate = 10000000.0 / this_duration;
- else {
+ } else {
double avg_duration, interval;
/* Average this frame's rate into the last second's average
LAYER_CONTEXT *lc = &cpi->layer_context[i];
lc->framerate = cpi->ref_framerate / cpi->oxcf.rate_decimator[i];
}
- } else
+ } else {
vp8_new_framerate(cpi, cpi->ref_framerate);
+ }
}
cpi->last_time_stamp_seen = cpi->source->ts_start;
duration2 = (unsigned int)((double)duration / 2);
if (cm->frame_type != KEY_FRAME) {
- if (cpi->avg_encode_time == 0)
+ if (cpi->avg_encode_time == 0) {
cpi->avg_encode_time = duration;
- else
+ } else {
cpi->avg_encode_time = (7 * cpi->avg_encode_time + duration) >> 3;
+ }
}
if (duration2) {
{
- if (cpi->avg_pick_mode_time == 0)
+ if (cpi->avg_pick_mode_time == 0) {
cpi->avg_pick_mode_time = duration2;
- else
+ } else {
cpi->avg_pick_mode_time =
(7 * cpi->avg_pick_mode_time + duration2) >> 3;
+ }
}
}
}
int vp8_get_preview_raw_frame(VP8_COMP *cpi, YV12_BUFFER_CONFIG *dest,
vp8_ppflags_t *flags) {
- if (cpi->common.refresh_alt_ref_frame)
+ if (cpi->common.refresh_alt_ref_frame) {
return -1;
- else {
+ } else {
int ret;
#if CONFIG_POSTPROC
if (cpi->cyclic_refresh_mode_enabled) return -1;
// Check number of rows and columns match
- if (cpi->common.mb_rows != (int)rows || cpi->common.mb_cols != (int)cols)
+ if (cpi->common.mb_rows != (int)rows || cpi->common.mb_cols != (int)cols) {
return -1;
+ }
// Range check the delta Q values and convert the external Q range values
// to internal ones.
if ((abs(delta_q[0]) > range) || (abs(delta_q[1]) > range) ||
- (abs(delta_q[2]) > range) || (abs(delta_q[3]) > range))
+ (abs(delta_q[2]) > range) || (abs(delta_q[3]) > range)) {
return -1;
+ }
// Range check the delta lf values
if ((abs(delta_lf[0]) > range) || (abs(delta_lf[1]) > range) ||
- (abs(delta_lf[2]) > range) || (abs(delta_lf[3]) > range))
+ (abs(delta_lf[2]) > range) || (abs(delta_lf[3]) > range)) {
return -1;
+ }
if (!map) {
disable_segmentation(cpi);
}
// Translate the external delta q values to internal values.
- for (i = 0; i < MAX_MB_SEGMENTS; ++i)
+ for (i = 0; i < MAX_MB_SEGMENTS; ++i) {
internal_delta_q[i] =
(delta_q[i] >= 0) ? q_trans[delta_q[i]] : -q_trans[-delta_q[i]];
+ }
/* Set the segmentation Map */
set_segmentation_map(cpi, map);
if (map) {
memcpy(cpi->active_map, map, rows * cols);
cpi->active_map_enabled = 1;
- } else
+ } else {
cpi->active_map_enabled = 0;
+ }
return 0;
} else {
int vp8_set_internal_size(VP8_COMP *cpi, VPX_SCALING horiz_mode,
VPX_SCALING vert_mode) {
- if (horiz_mode <= ONETWO)
+ if (horiz_mode <= ONETWO) {
cpi->common.horiz_scale = horiz_mode;
- else
+ } else {
return -1;
+ }
- if (vert_mode <= ONETWO)
+ if (vert_mode <= ONETWO) {
cpi->common.vert_scale = vert_mode;
- else
+ } else {
return -1;
+ }
return 0;
}
for (; i < 5; ++i) {
int skin_color_diff = evaluate_skin_color_difference(cb, cr, i);
if (skin_color_diff < skin_threshold[i + 1]) {
- if (y < 60 && skin_color_diff > 3 * (skin_threshold[i + 1] >> 2))
+ if (y < 60 && skin_color_diff > 3 * (skin_threshold[i + 1] >> 2)) {
return 0;
- else if (consec_zeromv > 25 &&
- skin_color_diff > (skin_threshold[i + 1] >> 1))
+ } else if (consec_zeromv > 25 &&
+ skin_color_diff > (skin_threshold[i + 1] >> 1)) {
return 0;
- else
+ } else {
return 1;
+ }
}
// Exit if difference is much large than the threshold.
if (skin_color_diff > (skin_threshold[i + 1] << 3)) {
sse2 = VP8_UVSSE(x);
- if (sse2 * 2 < x->encode_breakout)
+ if (sse2 * 2 < x->encode_breakout) {
x->skip = 1;
- else
+ } else {
x->skip = 0;
+ }
}
}
}
if ((this_mode != NEWMV) || !(cpi->sf.half_pixel_search) ||
- cpi->common.full_pixel == 1)
+ cpi->common.full_pixel == 1) {
*distortion2 =
vp8_get_inter_mbpred_error(x, &cpi->fn_ptr[BLOCK_16X16], sse, mv);
+ }
this_rd = RDCOST(x->rdmult, x->rddiv, rate2, *distortion2);
mic -= 1;
mv_l = mic->mbmi.mv;
- if (mic->mbmi.ref_frame != INTRA_FRAME)
- if (abs(mv_l.as_mv.row) < 8 && abs(mv_l.as_mv.col) < 8)
+ if (mic->mbmi.ref_frame != INTRA_FRAME) {
+ if (abs(mv_l.as_mv.row) < 8 && abs(mv_l.as_mv.col) < 8) {
local_motion_check++;
+ }
+ }
/* above-left mb */
mic -= x->e_mbd.mode_info_stride;
mv_al = mic->mbmi.mv;
- if (mic->mbmi.ref_frame != INTRA_FRAME)
- if (abs(mv_al.as_mv.row) < 8 && abs(mv_al.as_mv.col) < 8)
+ if (mic->mbmi.ref_frame != INTRA_FRAME) {
+ if (abs(mv_al.as_mv.row) < 8 && abs(mv_al.as_mv.col) < 8) {
local_motion_check++;
+ }
+ }
/* above mb */
mic += 1;
mv_a = mic->mbmi.mv;
- if (mic->mbmi.ref_frame != INTRA_FRAME)
- if (abs(mv_a.as_mv.row) < 8 && abs(mv_a.as_mv.col) < 8)
+ if (mic->mbmi.ref_frame != INTRA_FRAME) {
+ if (abs(mv_a.as_mv.row) < 8 && abs(mv_a.as_mv.col) < 8) {
local_motion_check++;
+ }
+ }
if (((!x->e_mbd.mb_to_top_edge || !x->e_mbd.mb_to_left_edge) &&
local_motion_check > 0) ||
- local_motion_check > 2)
+ local_motion_check > 2) {
*rd_adjustment = 80;
- else if (local_motion_check > 0)
+ } else if (local_motion_check > 0) {
*rd_adjustment = 90;
+ }
}
}
* likely to be chosen */
x->rd_thresh_mult[mode_index] += 4;
- if (x->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
+ if (x->rd_thresh_mult[mode_index] > MAX_THRESHMULT) {
x->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
+ }
x->rd_threshes[mode_index] =
(cpi->rd_baseline_thresh[mode_index] >> 7) *
* an unfiltered alternative */
if (cpi->is_src_frame_alt_ref && (cpi->oxcf.arnr_max_frames == 0)) {
if (this_mode != ZEROMV ||
- x->e_mbd.mode_info_context->mbmi.ref_frame != ALTREF_FRAME)
+ x->e_mbd.mode_info_context->mbmi.ref_frame != ALTREF_FRAME) {
continue;
+ }
}
switch (this_mode) {
while (n < further_steps) {
n++;
- if (num00)
+ if (num00) {
num00--;
- else {
+ } else {
thissme = cpi->diamond_search_sad(
x, b, d, &mvp_full, &d->bmi.mv, step_param + n, sadpb,
&num00, &cpi->fn_ptr[BLOCK_16X16], x->mvcost, &best_ref_mv);
x->mv_row_min = tmp_row_min;
x->mv_row_max = tmp_row_max;
- if (bestsme < INT_MAX)
+ if (bestsme < INT_MAX) {
cpi->find_fractional_mv_step(
x, b, d, &d->bmi.mv, &best_ref_mv, x->errorperbit,
&cpi->fn_ptr[BLOCK_16X16], cpi->mb.mvcost, &distortion2, &sse);
+ }
}
mode_mv[NEWMV].as_int = d->bmi.mv.as_int;
if (((mode_mv[this_mode].as_mv.row >> 3) < x->mv_row_min) ||
((mode_mv[this_mode].as_mv.row >> 3) > x->mv_row_max) ||
((mode_mv[this_mode].as_mv.col >> 3) < x->mv_col_min) ||
- ((mode_mv[this_mode].as_mv.col >> 3) > x->mv_col_max))
+ ((mode_mv[this_mode].as_mv.col >> 3) > x->mv_col_max)) {
continue;
+ }
rate2 += vp8_cost_mv_ref(this_mode, mdcounts);
x->e_mbd.mode_info_context->mbmi.mv.as_int = mode_mv[this_mode].as_int;
else {
x->rd_thresh_mult[mode_index] += 4;
- if (x->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
+ if (x->rd_thresh_mult[mode_index] > MAX_THRESHMULT) {
x->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
+ }
x->rd_threshes[mode_index] = (cpi->rd_baseline_thresh[mode_index] >> 7) *
x->rd_thresh_mult[mode_index];
// labeling on there being significant denoising in the scene
if (cpi->oxcf.noise_sensitivity == 4) {
if (cpi->denoiser.nmse_source_diff >
- 70 * cpi->denoiser.threshold_aggressive_mode / 100)
+ 70 * cpi->denoiser.threshold_aggressive_mode / 100) {
is_noisy = 1;
+ }
} else {
if (cpi->mse_source_denoised > 1000) is_noisy = 1;
}
/* set to the best mb mode, this copy can be skip if x->skip since it
* already has the right content */
- if (!x->skip)
+ if (!x->skip) {
memcpy(&x->e_mbd.mode_info_context->mbmi, &best_mbmode,
sizeof(MB_MODE_INFO));
+ }
if (best_mbmode.mode <= B_PRED) {
/* set mode_info_context->mbmi.uv_mode */
}
if (sign_bias !=
- cpi->common.ref_frame_sign_bias[xd->mode_info_context->mbmi.ref_frame])
+ cpi->common.ref_frame_sign_bias[xd->mode_info_context->mbmi.ref_frame]) {
best_ref_mv.as_int = best_ref_mv_sb[!sign_bias].as_int;
+ }
update_mvcount(x, &best_ref_mv);
}
int min_filter_level;
if (cpi->source_alt_ref_active && cpi->common.refresh_golden_frame &&
- !cpi->common.refresh_alt_ref_frame)
+ !cpi->common.refresh_alt_ref_frame) {
min_filter_level = 0;
- else {
- if (base_qindex <= 6)
+ } else {
+ if (base_qindex <= 6) {
min_filter_level = 0;
- else if (base_qindex <= 16)
+ } else if (base_qindex <= 16) {
min_filter_level = 1;
- else
+ } else {
min_filter_level = (base_qindex / 8);
+ }
}
return min_filter_level;
int max_filter_level = MAX_LOOP_FILTER;
(void)base_qindex;
- if (cpi->twopass.section_intra_rating > 8)
+ if (cpi->twopass.section_intra_rating > 8) {
max_filter_level = MAX_LOOP_FILTER * 3 / 4;
+ }
return max_filter_level;
}
/* Replace unfiltered frame buffer with a new one */
cm->frame_to_show = &cpi->pick_lf_lvl_frame;
- if (cm->frame_type == KEY_FRAME)
+ if (cm->frame_type == KEY_FRAME) {
cm->sharpness_level = 0;
- else
+ } else {
cm->sharpness_level = cpi->oxcf.Sharpness;
+ }
if (cm->sharpness_level != cm->last_sharpness_level) {
vp8_loop_filter_update_sharpness(&cm->lf_info, cm->sharpness_level);
/* Start the search at the previous frame filter level unless it is
* now out of range.
*/
- if (cm->filter_level < min_filter_level)
+ if (cm->filter_level < min_filter_level) {
cm->filter_level = min_filter_level;
- else if (cm->filter_level > max_filter_level)
+ } else if (cm->filter_level > max_filter_level) {
cm->filter_level = max_filter_level;
+ }
filt_val = cm->filter_level;
best_filt_val = filt_val;
if (filt_err < best_err) {
best_err = filt_err;
best_filt_val = filt_val;
- } else
+ } else {
break;
+ }
/* Adjust filter level */
filt_val -= 1 + (filt_val > 10);
best_err = filt_err - (filt_err >> 10);
best_filt_val = filt_val;
- } else
+ } else {
break;
+ }
/* Adjust filter level */
filt_val += 1 + (filt_val > 10);
/* Replace unfiltered frame buffer with a new one */
cm->frame_to_show = &cpi->pick_lf_lvl_frame;
- if (cm->frame_type == KEY_FRAME)
+ if (cm->frame_type == KEY_FRAME) {
cm->sharpness_level = 0;
- else
+ } else {
cm->sharpness_level = cpi->oxcf.Sharpness;
+ }
/* Start the search at the previous frame filter level unless it is
* now out of range.
*/
filt_mid = cm->filter_level;
- if (filt_mid < min_filter_level)
+ if (filt_mid < min_filter_level) {
filt_mid = min_filter_level;
- else if (filt_mid > max_filter_level)
+ } else if (filt_mid > max_filter_level) {
filt_mid = max_filter_level;
+ }
/* Define the initial step size */
filter_step = (filt_mid < 16) ? 4 : filt_mid / 4;
while (filter_step > 0) {
Bias = (best_err >> (15 - (filt_mid / 8))) * filter_step;
- if (cpi->twopass.section_intra_rating < 20)
+ if (cpi->twopass.section_intra_rating < 20) {
Bias = Bias * cpi->twopass.section_intra_rating / 20;
+ }
filt_high = ((filt_mid + filter_step) > max_filter_level)
? max_filter_level
filt_err = vp8_calc_ss_err(sd, cm->frame_to_show);
ss_err[filt_low] = filt_err;
- } else
+ } else {
filt_err = ss_err[filt_low];
+ }
/* If value is close to the best so far then bias towards a
* lower loop filter value.
filt_err = vp8_calc_ss_err(sd, cm->frame_to_show);
ss_err[filt_high] = filt_err;
- } else
+ } else {
filt_err = ss_err[filt_high];
+ }
/* Was it better than the previous best? */
if (filt_err < (best_err - Bias)) {
cpi->common.filter_level = cpi->common.base_qindex * 3 / 8;
/* Provisional interval before next GF */
- if (cpi->auto_gold)
+ if (cpi->auto_gold) {
cpi->frames_till_gf_update_due = cpi->baseline_gf_interval;
- else
+ } else {
cpi->frames_till_gf_update_due = DEFAULT_GF_INTERVAL;
+ }
cpi->common.refresh_golden_frame = 1;
cpi->common.refresh_alt_ref_frame = 1;
* chosen such that the maximum product of Bpm and MBs fits 31 bits. The
* largest Bpm takes 20 bits.
*/
- if (MBs > (1 << 11))
+ if (MBs > (1 << 11)) {
return (Bpm >> BPER_MB_NORMBITS) * MBs;
- else
+ } else {
return (Bpm * MBs) >> BPER_MB_NORMBITS;
+ }
}
static void calc_iframe_target_size(VP8_COMP *cpi) {
*/
target = cpi->oxcf.starting_buffer_level / 2;
- if (target > cpi->oxcf.target_bandwidth * 3 / 2)
+ if (target > cpi->oxcf.target_bandwidth * 3 / 2) {
target = cpi->oxcf.target_bandwidth * 3 / 2;
+ }
} else {
/* if this keyframe was forced, use a more recent Q estimate */
int Q = (cpi->common.frame_flags & FRAMEFLAGS_KEY) ? cpi->avg_frame_qindex
kf_boost = kf_boost * kf_boost_qadjustment[Q] / 100;
/* frame separation adjustment ( down) */
- if (cpi->frames_since_key < cpi->output_framerate / 2)
+ if (cpi->frames_since_key < cpi->output_framerate / 2) {
kf_boost =
(int)(kf_boost * cpi->frames_since_key / (cpi->output_framerate / 2));
+ }
/* Minimal target size is |2* per_frame_bandwidth|. */
if (kf_boost < 16) kf_boost = 16;
int pct_gf_active = (100 * cpi->gf_active_count) /
(cpi->common.mb_rows * cpi->common.mb_cols);
- if (tot_mbs)
+ if (tot_mbs) {
gf_frame_useage = (cpi->recent_ref_frame_usage[GOLDEN_FRAME] +
cpi->recent_ref_frame_usage[ALTREF_FRAME]) *
100 / tot_mbs;
+ }
if (pct_gf_active > gf_frame_useage) gf_frame_useage = pct_gf_active;
}
/* Apply an upper limit based on Q for 1 pass encodes */
- if (Boost > kf_gf_boost_qlimits[Q] && (cpi->pass == 0))
+ if (Boost > kf_gf_boost_qlimits[Q] && (cpi->pass == 0)) {
Boost = kf_gf_boost_qlimits[Q];
- /* Apply lower limits to boost. */
- else if (Boost < 110)
+ /* Apply lower limits to boost. */
+ } else if (Boost < 110) {
Boost = 110;
+ }
/* Note the boost used */
cpi->last_boost = Boost;
if (cpi->last_boost >= 1500) cpi->frames_till_gf_update_due++;
- if (gf_interval_table[gf_frame_useage] > cpi->frames_till_gf_update_due)
+ if (gf_interval_table[gf_frame_useage] > cpi->frames_till_gf_update_due) {
cpi->frames_till_gf_update_due = gf_interval_table[gf_frame_useage];
+ }
- if (cpi->frames_till_gf_update_due > cpi->max_gf_interval)
+ if (cpi->frames_till_gf_update_due > cpi->max_gf_interval) {
cpi->frames_till_gf_update_due = cpi->max_gf_interval;
+ }
}
- } else
+ } else {
cpi->frames_till_gf_update_due = cpi->baseline_gf_interval;
+ }
/* ARF on or off */
if (cpi->pass != 2) {
int min_frame_target;
int old_per_frame_bandwidth = cpi->per_frame_bandwidth;
- if (cpi->current_layer > 0)
+ if (cpi->current_layer > 0) {
cpi->per_frame_bandwidth =
cpi->layer_context[cpi->current_layer].avg_frame_size_for_layer;
+ }
min_frame_target = 0;
if (cpi->pass == 2) {
min_frame_target = cpi->min_frame_bandwidth;
- if (min_frame_target < (cpi->av_per_frame_bandwidth >> 5))
+ if (min_frame_target < (cpi->av_per_frame_bandwidth >> 5)) {
min_frame_target = cpi->av_per_frame_bandwidth >> 5;
- } else if (min_frame_target < cpi->per_frame_bandwidth / 4)
+ }
+ } else if (min_frame_target < cpi->per_frame_bandwidth / 4) {
min_frame_target = cpi->per_frame_bandwidth / 4;
+ }
/* Special alt reference frame case */
if ((cpi->common.refresh_alt_ref_frame) &&
? cpi->kf_bitrate_adjustment
: cpi->kf_overspend_bits;
- if (Adjustment > (cpi->per_frame_bandwidth - min_frame_target))
+ if (Adjustment > (cpi->per_frame_bandwidth - min_frame_target)) {
Adjustment = (cpi->per_frame_bandwidth - min_frame_target);
+ }
cpi->kf_overspend_bits -= Adjustment;
*/
cpi->this_frame_target = cpi->per_frame_bandwidth - Adjustment;
- if (cpi->this_frame_target < min_frame_target)
+ if (cpi->this_frame_target < min_frame_target) {
cpi->this_frame_target = min_frame_target;
- } else
+ }
+ } else {
cpi->this_frame_target = cpi->per_frame_bandwidth;
+ }
/* If appropriate make an adjustment to recover bits spent on a
* recent GF
? cpi->non_gf_bitrate_adjustment
: cpi->gf_overspend_bits;
- if (Adjustment > (cpi->this_frame_target - min_frame_target))
+ if (Adjustment > (cpi->this_frame_target - min_frame_target)) {
Adjustment = (cpi->this_frame_target - min_frame_target);
+ }
cpi->gf_overspend_bits -= Adjustment;
cpi->this_frame_target -= Adjustment;
/* % Adjustment limited to the range 1% to 10% */
Adjustment = (cpi->last_boost - 100) >> 5;
- if (Adjustment < 1)
+ if (Adjustment < 1) {
Adjustment = 1;
- else if (Adjustment > 10)
+ } else if (Adjustment > 10) {
Adjustment = 10;
+ }
/* Convert to bits */
Adjustment = (cpi->this_frame_target * Adjustment) / 100;
- if (Adjustment > (cpi->this_frame_target - min_frame_target))
+ if (Adjustment > (cpi->this_frame_target - min_frame_target)) {
Adjustment = (cpi->this_frame_target - min_frame_target);
+ }
if (cpi->frames_since_golden == (cpi->current_gf_interval >> 1)) {
Adjustment = (cpi->current_gf_interval - 1) * Adjustment;
// Limit adjustment to 10% of current target.
- if (Adjustment > (10 * cpi->this_frame_target) / 100)
+ if (Adjustment > (10 * cpi->this_frame_target) / 100) {
Adjustment = (10 * cpi->this_frame_target) / 100;
+ }
cpi->this_frame_target += Adjustment;
- } else
+ } else {
cpi->this_frame_target -= Adjustment;
+ }
}
}
}
* be recovered over a longer time span via other buffer / rate control
* mechanisms.
*/
- if (cpi->this_frame_target < min_frame_target)
+ if (cpi->this_frame_target < min_frame_target) {
cpi->this_frame_target = min_frame_target;
+ }
- if (!cpi->common.refresh_alt_ref_frame)
+ if (!cpi->common.refresh_alt_ref_frame) {
/* Note the baseline target data rate for this inter frame. */
cpi->inter_frame_target = cpi->this_frame_target;
+ }
/* One Pass specific code */
if (cpi->pass == 0) {
(int)(100 * -cpi->bits_off_target / (cpi->total_byte_count * 8));
}
- if (percent_low > cpi->oxcf.under_shoot_pct)
+ if (percent_low > cpi->oxcf.under_shoot_pct) {
percent_low = cpi->oxcf.under_shoot_pct;
- else if (percent_low < 0)
+ } else if (percent_low < 0) {
percent_low = 0;
+ }
/* lower the target bandwidth for this frame. */
cpi->this_frame_target -= (cpi->this_frame_target * percent_low) / 200;
(int)((100 * cpi->bits_off_target) / (cpi->total_byte_count * 8));
}
- if (percent_high > cpi->oxcf.over_shoot_pct)
+ if (percent_high > cpi->oxcf.over_shoot_pct) {
percent_high = cpi->oxcf.over_shoot_pct;
- else if (percent_high < 0)
+ } else if (percent_high < 0) {
percent_high = 0;
+ }
cpi->this_frame_target += (cpi->this_frame_target * percent_high) / 200;
cpi->active_best_quality = cpi->best_quality;
/* Worst quality obviously must not be better than best quality */
- if (cpi->active_worst_quality <= cpi->active_best_quality)
+ if (cpi->active_worst_quality <= cpi->active_best_quality) {
cpi->active_worst_quality = cpi->active_best_quality + 1;
+ }
if (cpi->active_worst_quality > 127) cpi->active_worst_quality = 127;
}
/* Update the buffer level variable. */
cpi->bits_off_target += cpi->av_per_frame_bandwidth;
- if (cpi->bits_off_target > cpi->oxcf.maximum_buffer_size)
+ if (cpi->bits_off_target > cpi->oxcf.maximum_buffer_size) {
cpi->bits_off_target = (int)cpi->oxcf.maximum_buffer_size;
+ }
cpi->buffer_level = cpi->bits_off_target;
if (cpi->oxcf.number_of_layers > 1) {
for (i = cpi->current_layer + 1; i < cpi->oxcf.number_of_layers; ++i) {
LAYER_CONTEXT *lc = &cpi->layer_context[i];
lc->bits_off_target += (int)(lc->target_bandwidth / lc->framerate);
- if (lc->bits_off_target > lc->maximum_buffer_size)
+ if (lc->bits_off_target > lc->maximum_buffer_size) {
lc->bits_off_target = lc->maximum_buffer_size;
+ }
lc->buffer_level = lc->bits_off_target;
}
}
int pct_gf_active = (100 * cpi->gf_active_count) /
(cpi->common.mb_rows * cpi->common.mb_cols);
- if (tot_mbs)
+ if (tot_mbs) {
gf_frame_useage = (cpi->recent_ref_frame_usage[GOLDEN_FRAME] +
cpi->recent_ref_frame_usage[ALTREF_FRAME]) *
100 / tot_mbs;
+ }
if (pct_gf_active > gf_frame_useage) gf_frame_useage = pct_gf_active;
* low or the GF useage is high
*/
if ((cpi->pass == 0) &&
- (cpi->this_frame_percent_intra < 15 || gf_frame_useage >= 5))
+ (cpi->this_frame_percent_intra < 15 || gf_frame_useage >= 5)) {
cpi->common.refresh_golden_frame = 1;
- /* Two pass GF descision */
- else if (cpi->pass == 2)
+ /* Two pass GF descision */
+ } else if (cpi->pass == 2) {
cpi->common.refresh_golden_frame = 1;
+ }
}
#if 0
}
/* Avoid loss of precision but avoid overflow */
- if ((bits_in_section >> 7) > allocation_chunks)
+ if ((bits_in_section >> 7) > allocation_chunks) {
cpi->this_frame_target =
Boost * (bits_in_section / allocation_chunks);
- else
+ } else {
cpi->this_frame_target =
(Boost * bits_in_section) / allocation_chunks;
+ }
}
- } else
+ } else {
cpi->this_frame_target =
(estimate_bits_at_q(1, Q, cpi->common.MBs, 1.0) *
cpi->last_boost) /
100;
+ }
}
/* If there is an active ARF at this location use the minimum
if (cpi->common.frame_type == KEY_FRAME) {
rate_correction_factor = cpi->key_frame_rate_correction_factor;
} else {
- if (cpi->oxcf.number_of_layers == 1 &&
- (cpi->common.refresh_alt_ref_frame || cpi->common.refresh_golden_frame))
+ if (cpi->oxcf.number_of_layers == 1 && (cpi->common.refresh_alt_ref_frame ||
+ cpi->common.refresh_golden_frame)) {
rate_correction_factor = cpi->gf_rate_correction_factor;
- else
+ } else {
rate_correction_factor = cpi->rate_correction_factor;
+ }
}
/* Work out how big we would have expected the frame to be at this Q
}
/* Work out a size correction factor. */
- if (projected_size_based_on_q > 0)
+ if (projected_size_based_on_q > 0) {
correction_factor =
(100 * cpi->projected_frame_size) / projected_size_based_on_q;
+ }
/* More heavily damped adjustment used if we have been oscillating
* either side of target
((rate_correction_factor * correction_factor) / 100);
/* Keep rate_correction_factor within limits */
- if (rate_correction_factor > MAX_BPB_FACTOR)
+ if (rate_correction_factor > MAX_BPB_FACTOR) {
rate_correction_factor = MAX_BPB_FACTOR;
+ }
} else if (correction_factor < 99) {
/* We are not already at the best allowable quality */
correction_factor =
((rate_correction_factor * correction_factor) / 100);
/* Keep rate_correction_factor within limits */
- if (rate_correction_factor < MIN_BPB_FACTOR)
+ if (rate_correction_factor < MIN_BPB_FACTOR) {
rate_correction_factor = MIN_BPB_FACTOR;
+ }
}
- if (cpi->common.frame_type == KEY_FRAME)
+ if (cpi->common.frame_type == KEY_FRAME) {
cpi->key_frame_rate_correction_factor = rate_correction_factor;
- else {
- if (cpi->oxcf.number_of_layers == 1 &&
- (cpi->common.refresh_alt_ref_frame || cpi->common.refresh_golden_frame))
+ } else {
+ if (cpi->oxcf.number_of_layers == 1 && (cpi->common.refresh_alt_ref_frame ||
+ cpi->common.refresh_golden_frame)) {
cpi->gf_rate_correction_factor = rate_correction_factor;
- else
+ } else {
cpi->rate_correction_factor = rate_correction_factor;
+ }
}
}
double correction_factor;
/* Select the appropriate correction factor based upon type of frame. */
- if (cpi->common.frame_type == KEY_FRAME)
+ if (cpi->common.frame_type == KEY_FRAME) {
correction_factor = cpi->key_frame_rate_correction_factor;
- else {
+ } else {
if (cpi->oxcf.number_of_layers == 1 &&
(cpi->common.refresh_alt_ref_frame ||
- cpi->common.refresh_golden_frame))
+ cpi->common.refresh_golden_frame)) {
correction_factor = cpi->gf_rate_correction_factor;
- else
+ } else {
correction_factor = cpi->rate_correction_factor;
+ }
}
/* Calculate required scaling factor based on target frame size and
* size of frame produced using previous Q
*/
- if (target_bits_per_frame >= (INT_MAX >> BPER_MB_NORMBITS))
+ if (target_bits_per_frame >= (INT_MAX >> BPER_MB_NORMBITS)) {
/* Case where we would overflow int */
target_bits_per_mb = (target_bits_per_frame / cpi->common.MBs)
<< BPER_MB_NORMBITS;
- else
+ } else {
target_bits_per_mb =
(target_bits_per_frame << BPER_MB_NORMBITS) / cpi->common.MBs;
+ }
i = cpi->active_best_quality;
correction_factor * vp8_bits_per_mb[cpi->common.frame_type][i]);
if (bits_per_mb_at_this_q <= target_bits_per_mb) {
- if ((target_bits_per_mb - bits_per_mb_at_this_q) <= last_error)
+ if ((target_bits_per_mb - bits_per_mb_at_this_q) <= last_error) {
Q = i;
- else
+ } else {
Q = i - 1;
+ }
break;
- } else
+ } else {
last_error = bits_per_mb_at_this_q - target_bits_per_mb;
+ }
} while (++i <= cpi->active_worst_quality);
/* If we are at MAXQ then enable Q over-run which seeks to claw
double Factor = 0.99;
double factor_adjustment = 0.01 / 256.0;
- if (cpi->common.frame_type == KEY_FRAME)
+ if (cpi->common.frame_type == KEY_FRAME) {
zbin_oqmax = 0;
- else if (cpi->oxcf.number_of_layers == 1 &&
- (cpi->common.refresh_alt_ref_frame ||
- (cpi->common.refresh_golden_frame &&
- !cpi->source_alt_ref_active)))
+ } else if (cpi->oxcf.number_of_layers == 1 &&
+ (cpi->common.refresh_alt_ref_frame ||
+ (cpi->common.refresh_golden_frame &&
+ !cpi->source_alt_ref_active))) {
zbin_oqmax = 16;
- else
+ } else {
zbin_oqmax = ZBIN_OQ_MAX;
+ }
/*{
double Factor =
while (cpi->mb.zbin_over_quant < zbin_oqmax) {
cpi->mb.zbin_over_quant++;
- if (cpi->mb.zbin_over_quant > zbin_oqmax)
+ if (cpi->mb.zbin_over_quant > zbin_oqmax) {
cpi->mb.zbin_over_quant = zbin_oqmax;
+ }
/* Adjust bits_per_mb_at_this_q estimate */
bits_per_mb_at_this_q = (int)(Factor * bits_per_mb_at_this_q);
int key_freq = cpi->oxcf.key_freq > 0 ? cpi->oxcf.key_freq : 1;
av_key_frame_frequency = 1 + (int)cpi->output_framerate * 2;
- if (cpi->oxcf.auto_key && av_key_frame_frequency > key_freq)
+ if (cpi->oxcf.auto_key && av_key_frame_frequency > key_freq) {
av_key_frame_frequency = key_freq;
+ }
cpi->prior_key_frame_distance[KEY_FRAME_CONTEXT - 1] =
av_key_frame_frequency;
* KEY_FRAME_CONTEXT keyframes
*/
for (i = 0; i < KEY_FRAME_CONTEXT; ++i) {
- if (i < KEY_FRAME_CONTEXT - 1)
+ if (i < KEY_FRAME_CONTEXT - 1) {
cpi->prior_key_frame_distance[i] = cpi->prior_key_frame_distance[i + 1];
- else
+ } else {
cpi->prior_key_frame_distance[i] = last_kf_interval;
+ }
av_key_frame_frequency +=
prior_key_frame_weight[i] * cpi->prior_key_frame_distance[i];
*/
overspend = (cpi->projected_frame_size - cpi->per_frame_bandwidth);
- if (cpi->oxcf.number_of_layers > 1)
+ if (cpi->oxcf.number_of_layers > 1) {
cpi->kf_overspend_bits += overspend;
- else {
+ } else {
cpi->kf_overspend_bits += overspend * 7 / 8;
cpi->gf_overspend_bits += overspend * 1 / 8;
}
int vp8_pick_frame_size(VP8_COMP *cpi) {
VP8_COMMON *cm = &cpi->common;
- if (cm->frame_type == KEY_FRAME)
+ if (cm->frame_type == KEY_FRAME) {
calc_iframe_target_size(cpi);
- else {
+ } else {
calc_pframe_target_size(cpi);
/* Check if we're dropping the frame: */
// undershoots significantly, and then we end up dropping every other
// frame because the QP/rate_correction_factor may have been too low
// before the drop and then takes too long to come up.
- if (target_size >= (INT_MAX >> BPER_MB_NORMBITS))
+ if (target_size >= (INT_MAX >> BPER_MB_NORMBITS)) {
target_bits_per_mb = (target_size / cpi->common.MBs)
<< BPER_MB_NORMBITS;
- else
+ } else {
target_bits_per_mb =
(target_size << BPER_MB_NORMBITS) / cpi->common.MBs;
+ }
// Rate correction factor based on target_size_per_mb and max_QP.
new_correction_factor =
(double)target_bits_per_mb /
(double)vp8_bits_per_mb[INTER_FRAME][cpi->worst_quality];
- if (new_correction_factor > cpi->rate_correction_factor)
+ if (new_correction_factor > cpi->rate_correction_factor) {
cpi->rate_correction_factor =
VPXMIN(2.0 * cpi->rate_correction_factor, new_correction_factor);
- if (cpi->rate_correction_factor > MAX_BPB_FACTOR)
+ }
+ if (cpi->rate_correction_factor > MAX_BPB_FACTOR) {
cpi->rate_correction_factor = MAX_BPB_FACTOR;
+ }
return 1;
} else {
cpi->force_maxqp = 0;
p[BLOCK_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES]) {
int i, j, k;
- for (i = 0; i < BLOCK_TYPES; ++i)
- for (j = 0; j < COEF_BANDS; ++j)
- for (k = 0; k < PREV_COEF_CONTEXTS; ++k)
-
+ for (i = 0; i < BLOCK_TYPES; ++i) {
+ for (j = 0; j < COEF_BANDS; ++j) {
+ for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
/* check for pt=0 and band > 1 if block type 0
* and 0 if blocktype 1
*/
- if (k == 0 && j > (i == 0))
+ if (k == 0 && j > (i == 0)) {
vp8_cost_tokens2(c[i][j][k], p[i][j][k], vp8_coef_tree, 2);
- else
+ } else {
vp8_cost_tokens(c[i][j][k], p[i][j][k], vp8_coef_tree);
+ }
+ }
+ }
+ }
}
static const int rd_iifactor[32] = { 4, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0,
}
if (cpi->pass == 2 && (cpi->common.frame_type != KEY_FRAME)) {
- if (cpi->twopass.next_iiratio > 31)
+ if (cpi->twopass.next_iiratio > 31) {
cpi->RDMULT += (cpi->RDMULT * rd_iifactor[31]) >> 4;
- else
+ } else {
cpi->RDMULT +=
(cpi->RDMULT * rd_iifactor[cpi->twopass.next_iiratio]) >> 4;
+ }
}
cpi->mb.errorperbit = (cpi->RDMULT / 110);
/* build token cost array for the type of frame we have now */
FRAME_CONTEXT *l = &cpi->lfc_n;
- if (cpi->common.refresh_alt_ref_frame)
+ if (cpi->common.refresh_alt_ref_frame) {
l = &cpi->lfc_a;
- else if (cpi->common.refresh_golden_frame)
+ } else if (cpi->common.refresh_golden_frame) {
l = &cpi->lfc_g;
+ }
fill_token_costs(cpi->mb.token_costs,
(const vp8_prob(*)[8][3][11])l->coef_probs);
int offset;
int pre_stride = x->e_mbd.pre.uv_stride;
- if (mv_row < 0)
+ if (mv_row < 0) {
mv_row -= 1;
- else
+ } else {
mv_row += 1;
+ }
- if (mv_col < 0)
+ if (mv_col < 0) {
mv_col -= 1;
- else
+ } else {
mv_col += 1;
+ }
mv_row /= 2;
mv_col /= 2;
pt = vp8_prev_token_class[t];
}
- if (c < 16)
+ if (c < 16) {
cost += mb->token_costs[type][vp8_coef_bands[c]][pt][DCT_EOB_TOKEN];
+ }
pt = (c != !type); /* is eob first coefficient; */
*a = *l = pt;
ta = (ENTROPY_CONTEXT *)&t_above;
tl = (ENTROPY_CONTEXT *)&t_left;
- for (b = 0; b < 16; ++b)
+ for (b = 0; b < 16; ++b) {
cost += cost_coeffs(mb, x->block + b, PLANE_TYPE_Y_NO_DC,
ta + vp8_block2above[b], tl + vp8_block2left[b]);
+ }
cost += cost_coeffs(mb, x->block + 24, PLANE_TYPE_Y2,
ta + vp8_block2above[24], tl + vp8_block2left[24]);
ta = (ENTROPY_CONTEXT *)&t_above;
tl = (ENTROPY_CONTEXT *)&t_left;
- for (b = 16; b < 24; ++b)
+ for (b = 16; b < 24; ++b) {
cost += cost_coeffs(mb, x->block + b, PLANE_TYPE_UV,
ta + vp8_block2above[b], tl + vp8_block2left[b]);
+ }
return cost;
}
if (labelings[i] != which_label) continue;
- if (col && labelings[i] == labelings[i - 1])
+ if (col && labelings[i] == labelings[i - 1]) {
m = LEFT4X4;
- else if (row && labelings[i] == labelings[i - 4])
+ } else if (row && labelings[i] == labelings[i - 4]) {
m = ABOVE4X4;
- else {
+ } else {
/* the only time we should do costing for new motion vector
* or mode is when we are on a new label (jbb May 08, 2007)
*/
int b;
MACROBLOCKD *x = &mb->e_mbd;
- for (b = 0; b < 16; ++b)
- if (labels[b] == which_label)
+ for (b = 0; b < 16; ++b) {
+ if (labels[b] == which_label) {
cost += cost_coeffs(mb, x->block + b, PLANE_TYPE_Y_WITH_DC,
ta + vp8_block2above[b], tl + vp8_block2left[b]);
+ }
+ }
return cost;
}
if (cpi->compressor_speed) {
if (segmentation == BLOCK_8X16 || segmentation == BLOCK_16X8) {
bsi->mvp.as_int = bsi->sv_mvp[i].as_int;
- if (i == 1 && segmentation == BLOCK_16X8)
+ if (i == 1 && segmentation == BLOCK_16X8) {
bsi->mvp.as_int = bsi->sv_mvp[2].as_int;
+ }
step_param = bsi->sv_istep[i];
}
*/
if (segmentation == BLOCK_4X4 && i > 0) {
bsi->mvp.as_int = x->e_mbd.block[i - 1].bmi.mv.as_int;
- if (i == 4 || i == 8 || i == 12)
+ if (i == 4 || i == 8 || i == 12) {
bsi->mvp.as_int = x->e_mbd.block[i - 4].bmi.mv.as_int;
+ }
step_param = 2;
}
}
while (n < further_steps) {
n++;
- if (num00)
+ if (num00) {
num00--;
- else {
+ } else {
thissme = cpi->diamond_search_sad(
x, c, e, &mvp_full, &temp_mv, step_param + n, sadpb, &num00,
v_fn_ptr, x->mvcost, bsi->ref_mv);
static void vp8_cal_step_param(int sr, int *sp) {
int step = 0;
- if (sr > MAX_FIRST_STEP)
+ if (sr > MAX_FIRST_STEP) {
sr = MAX_FIRST_STEP;
- else if (sr < 1)
+ } else if (sr < 1) {
sr = 1;
+ }
while (sr >>= 1) step++;
if (here->mbmi.ref_frame == near_ref[near_sadidx[i]]) {
mv.as_int = near_mvs[near_sadidx[i]].as_int;
find = 1;
- if (i < 3)
+ if (i < 3) {
*sr = 3;
- else
+ } else {
*sr = 2;
+ }
break;
}
}
if (xd->mb_to_right_edge == 0) near_sad[6] = INT_MAX;
if (xd->mb_to_bottom_edge == 0) near_sad[7] = INT_MAX;
- if (near_sad[4] != INT_MAX)
+ if (near_sad[4] != INT_MAX) {
near_sad[4] = cpi->fn_ptr[BLOCK_16X16].sdf(
src_y_ptr, b->src_stride, pre_y_buffer - pre_y_stride * 16,
pre_y_stride);
- if (near_sad[5] != INT_MAX)
+ }
+ if (near_sad[5] != INT_MAX) {
near_sad[5] = cpi->fn_ptr[BLOCK_16X16].sdf(
src_y_ptr, b->src_stride, pre_y_buffer - 16, pre_y_stride);
+ }
near_sad[3] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride,
pre_y_buffer, pre_y_stride);
- if (near_sad[6] != INT_MAX)
+ if (near_sad[6] != INT_MAX) {
near_sad[6] = cpi->fn_ptr[BLOCK_16X16].sdf(
src_y_ptr, b->src_stride, pre_y_buffer + 16, pre_y_stride);
- if (near_sad[7] != INT_MAX)
+ }
+ if (near_sad[7] != INT_MAX) {
near_sad[7] = cpi->fn_ptr[BLOCK_16X16].sdf(
src_y_ptr, b->src_stride, pre_y_buffer + pre_y_stride * 16,
pre_y_stride);
+ }
}
if (cpi->common.last_frame_type != KEY_FRAME) {
if (x->e_mbd.mode_info_context->mbmi.ref_frame) {
for (i = 16; i < 24; ++i) tteob += x->e_mbd.eobs[i];
- } else
+ } else {
tteob += uv_intra_tteob;
+ }
if (tteob == 0) {
rd->rate2 -= (rd->rate_y + rd->rate_uv);
/* Calculate the final RD estimate for this mode */
this_rd = RDCOST(x->rdmult, x->rddiv, rd->rate2, rd->distortion2);
if (this_rd < INT_MAX &&
- x->e_mbd.mode_info_context->mbmi.ref_frame == INTRA_FRAME)
+ x->e_mbd.mode_info_context->mbmi.ref_frame == INTRA_FRAME) {
this_rd += intra_rd_penalty;
+ }
}
return this_rd;
}
*/
if (cpi->is_src_frame_alt_ref && (cpi->oxcf.arnr_max_frames == 0)) {
if (this_mode != ZEROMV ||
- x->e_mbd.mode_info_context->mbmi.ref_frame != ALTREF_FRAME)
+ x->e_mbd.mode_info_context->mbmi.ref_frame != ALTREF_FRAME) {
continue;
+ }
}
/* everything but intra */
*/
x->rd_thresh_mult[mode_index] += 4;
- if (x->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
+ if (x->rd_thresh_mult[mode_index] > MAX_THRESHMULT) {
x->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
+ }
x->rd_threshes[mode_index] =
(cpi->rd_baseline_thresh[mode_index] >> 7) *
* Increase zbin size to supress noise
*/
if (x->zbin_mode_boost_enabled) {
- if (this_ref_frame == INTRA_FRAME)
+ if (this_ref_frame == INTRA_FRAME) {
x->zbin_mode_boost = 0;
- else {
+ } else {
if (vp8_mode_order[mode_index] == ZEROMV) {
- if (this_ref_frame != LAST_FRAME)
+ if (this_ref_frame != LAST_FRAME) {
x->zbin_mode_boost = GF_ZEROMV_ZBIN_BOOST;
- else
+ } else {
x->zbin_mode_boost = LF_ZEROMV_ZBIN_BOOST;
- } else if (vp8_mode_order[mode_index] == SPLITMV)
+ }
+ } else if (vp8_mode_order[mode_index] == SPLITMV) {
x->zbin_mode_boost = 0;
- else
+ } else {
x->zbin_mode_boost = MV_ZBIN_BOOST;
+ }
}
vp8_update_zbin_extra(cpi, x);
while (n < further_steps) {
n++;
- if (num00)
+ if (num00) {
num00--;
- else {
+ } else {
thissme = cpi->diamond_search_sad(
x, b, d, &mvp_full, &d->bmi.mv, step_param + n, sadpb, &num00,
&cpi->fn_ptr[BLOCK_16X16], x->mvcost, &best_ref_mv);
* mode.
*/
if (((this_mode == NEARMV) || (this_mode == NEARESTMV)) &&
- (mode_mv[this_mode].as_int == 0))
+ (mode_mv[this_mode].as_int == 0)) {
continue;
+ }
case ZEROMV:
if (((mode_mv[this_mode].as_mv.row >> 3) < x->mv_row_min) ||
((mode_mv[this_mode].as_mv.row >> 3) > x->mv_row_max) ||
((mode_mv[this_mode].as_mv.col >> 3) < x->mv_col_min) ||
- ((mode_mv[this_mode].as_mv.col >> 3) > x->mv_col_max))
+ ((mode_mv[this_mode].as_mv.col >> 3) > x->mv_col_max)) {
continue;
+ }
vp8_set_mbmode_and_mvs(x, this_mode, &mode_mv[this_mode]);
this_rd = evaluate_inter_mode_rd(mdcounts, &rd, &disable_skip, cpi, x);
else {
x->rd_thresh_mult[mode_index] += 4;
- if (x->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
+ if (x->rd_thresh_mult[mode_index] > MAX_THRESHMULT) {
x->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
+ }
}
x->rd_threshes[mode_index] = (cpi->rd_baseline_thresh[mode_index] >> 7) *
x->rd_thresh_mult[mode_index];
sizeof(MB_MODE_INFO));
if (best_mode.mbmode.mode == B_PRED) {
- for (i = 0; i < 16; ++i)
+ for (i = 0; i < 16; ++i) {
xd->mode_info_context->bmi[i].as_mode = best_mode.bmodes[i].as_mode;
+ }
}
if (best_mode.mbmode.mode == SPLITMV) {
- for (i = 0; i < 16; ++i)
+ for (i = 0; i < 16; ++i) {
xd->mode_info_context->bmi[i].mv.as_int = best_mode.bmodes[i].mv.as_int;
+ }
memcpy(x->partition_info, &best_mode.partition, sizeof(PARTITION_INFO));
}
if (sign_bias !=
- cpi->common.ref_frame_sign_bias[xd->mode_info_context->mbmi.ref_frame])
+ cpi->common.ref_frame_sign_bias[xd->mode_info_context->mbmi.ref_frame]) {
best_ref_mv.as_int = best_ref_mv_sb[!sign_bias].as_int;
+ }
rd_update_mvcount(x, &best_ref_mv);
}
unsigned char *plane[4][3],
unsigned int recon_yoffset,
unsigned int recon_uvoffset) {
- if (cpi->ref_frame_flags & VP8_LAST_FRAME)
+ if (cpi->ref_frame_flags & VP8_LAST_FRAME) {
get_plane_pointers(&cpi->common.yv12_fb[cpi->common.lst_fb_idx],
plane[LAST_FRAME], recon_yoffset, recon_uvoffset);
+ }
- if (cpi->ref_frame_flags & VP8_GOLD_FRAME)
+ if (cpi->ref_frame_flags & VP8_GOLD_FRAME) {
get_plane_pointers(&cpi->common.yv12_fb[cpi->common.gld_fb_idx],
plane[GOLDEN_FRAME], recon_yoffset, recon_uvoffset);
+ }
- if (cpi->ref_frame_flags & VP8_ALTR_FRAME)
+ if (cpi->ref_frame_flags & VP8_ALTR_FRAME) {
get_plane_pointers(&cpi->common.yv12_fb[cpi->common.alt_fb_idx],
plane[ALTREF_FRAME], recon_yoffset, recon_uvoffset);
+ }
}
static INLINE void get_reference_search_order(const VP8_COMP *cpi,
frames_to_blur_backward = num_frames_backward;
- if (frames_to_blur_backward >= max_frames)
+ if (frames_to_blur_backward >= max_frames) {
frames_to_blur_backward = max_frames - 1;
+ }
frames_to_blur = frames_to_blur_backward + 1;
break;
frames_to_blur_forward = num_frames_forward;
- if (frames_to_blur_forward >= max_frames)
+ if (frames_to_blur_forward >= max_frames) {
frames_to_blur_forward = max_frames - 1;
+ }
frames_to_blur = frames_to_blur_forward + 1;
break;
frames_to_blur_forward = num_frames_forward;
frames_to_blur_backward = num_frames_backward;
- if (frames_to_blur_forward > frames_to_blur_backward)
+ if (frames_to_blur_forward > frames_to_blur_backward) {
frames_to_blur_forward = frames_to_blur_backward;
+ }
- if (frames_to_blur_backward > frames_to_blur_forward)
+ if (frames_to_blur_backward > frames_to_blur_forward) {
frames_to_blur_backward = frames_to_blur_forward;
+ }
/* When max_frames is even we have 1 more frame backward than forward */
- if (frames_to_blur_forward > (max_frames - 1) / 2)
+ if (frames_to_blur_forward > (max_frames - 1) / 2) {
frames_to_blur_forward = ((max_frames - 1) / 2);
+ }
- if (frames_to_blur_backward > (max_frames / 2))
+ if (frames_to_blur_backward > (max_frames / 2)) {
frames_to_blur_backward = (max_frames / 2);
+ }
frames_to_blur = frames_to_blur_backward + frames_to_blur_forward + 1;
break;
plane_type = 0;
}
- for (b = 0; b < 16; ++b)
+ for (b = 0; b < 16; ++b) {
stuff1st_order_b(t, A + vp8_block2above[b], L + vp8_block2left[b],
plane_type, cpi, x);
+ }
- for (b = 16; b < 24; ++b)
+ for (b = 16; b < 24; ++b) {
stuff1st_order_buv(t, A + vp8_block2above[b], L + vp8_block2left[b], cpi,
x);
+ }
}
void vp8_fix_contexts(MACROBLOCKD *x) {
/* Clear entropy contexts for Y2 blocks */
const vp8_tree_index j = T[i];
const int d = c + vp8_cost_bit(p, i & 1);
- if (j <= 0)
+ if (j <= 0) {
C[-j] = d;
- else
+ } else {
cost(C, T, P, j, d);
+ }
} while (++i & 1);
}
void vp8_cost_tokens(int *c, const vp8_prob *p, vp8_tree t) {
int has_2nd_order = (x->e_mbd.mode_info_context->mbmi.mode != B_PRED &&
x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
- for (i = 0; i < 24 + has_2nd_order; ++i)
+ for (i = 0; i < 24 + has_2nd_order; ++i) {
x->quantize_b(&x->block[i], &x->e_mbd.block[i]);
+ }
}
void vp8_quantize_mbuv(MACROBLOCK *x) {
/* Select the baseline MB Q index. */
if (xd->segmentation_enabled) {
/* Abs Value */
- if (xd->mb_segement_abs_delta == SEGMENT_ABSDATA)
+ if (xd->mb_segement_abs_delta == SEGMENT_ABSDATA) {
QIndex = xd->segment_feature_data[MB_LVL_ALT_Q][xd->mode_info_context
->mbmi.segment_id];
- /* Delta Value */
- else {
+ /* Delta Value */
+ } else {
QIndex = cpi->common.base_qindex +
xd->segment_feature_data[MB_LVL_ALT_Q][xd->mode_info_context
->mbmi.segment_id];
/* Clamp to valid range */
QIndex = (QIndex >= 0) ? ((QIndex <= MAXQ) ? QIndex : MAXQ) : 0;
}
- } else
+ } else {
QIndex = cpi->common.base_qindex;
+ }
/* This initialization should be called at least once. Use ok_to_skip to
* decide if it is ok to skip.
if (Q < 4) {
new_delta_q = 4 - Q;
- } else
+ } else {
new_delta_q = 0;
+ }
update |= cm->y2dc_delta_q != new_delta_q;
cm->y2dc_delta_q = new_delta_q;
vpx_codec_alg_priv_t *ctx, const struct vpx_internal_error_info *error) {
vpx_codec_err_t res;
- if ((res = error->error_code))
+ if ((res = error->error_code)) {
ctx->base.err_detail = error->has_detail ? error->detail : NULL;
+ }
return res;
}
unsigned int i;
RANGE_CHECK_HI(cfg, ts_periodicity, 16);
- for (i = 1; i < cfg->ts_number_layers; ++i)
+ for (i = 1; i < cfg->ts_number_layers; ++i) {
if (cfg->ts_target_bitrate[i] <= cfg->ts_target_bitrate[i - 1] &&
cfg->rc_target_bitrate > 0)
ERROR("ts_target_bitrate entries are not strictly increasing");
+ }
RANGE_CHECK(cfg, ts_rate_decimator[cfg->ts_number_layers - 1], 1, 1);
- for (i = cfg->ts_number_layers - 2; i > 0; i--)
+ for (i = cfg->ts_number_layers - 2; i > 0; i--) {
if (cfg->ts_rate_decimator[i - 1] != 2 * cfg->ts_rate_decimator[i])
ERROR("ts_rate_decimator factors are not powers of 2");
+ }
RANGE_CHECK_HI(cfg, ts_layer_id[i], cfg->ts_number_layers - 1);
}
return VPX_CODEC_MEM_ERROR;
}
- if (mr_cfg)
+ if (mr_cfg) {
ctx->priv->enc.total_encoders = mr_cfg->mr_total_resolutions;
- else
+ } else {
ctx->priv->enc.total_encoders = 1;
+ }
once(vp8_initialize_enc);
new_qc = MODE_REALTIME;
#endif
- if (deadline == VPX_DL_REALTIME)
+ if (deadline == VPX_DL_REALTIME) {
new_qc = MODE_REALTIME;
- else if (ctx->cfg.g_pass == VPX_RC_FIRST_PASS)
+ } else if (ctx->cfg.g_pass == VPX_RC_FIRST_PASS) {
new_qc = MODE_FIRSTPASS;
- else if (ctx->cfg.g_pass == VPX_RC_LAST_PASS)
+ } else if (ctx->cfg.g_pass == VPX_RC_LAST_PASS) {
new_qc =
(new_qc == MODE_BESTQUALITY) ? MODE_SECONDPASS_BEST : MODE_SECONDPASS;
+ }
if (ctx->oxcf.Mode != new_qc) {
ctx->oxcf.Mode = new_qc;
int comp_data_state = 0;
/* Set up internal flags */
- if (ctx->base.init_flags & VPX_CODEC_USE_PSNR)
+ if (ctx->base.init_flags & VPX_CODEC_USE_PSNR) {
((VP8_COMP *)ctx->cpi)->b_calculate_psnr = 1;
+ }
- if (ctx->base.init_flags & VPX_CODEC_USE_OUTPUT_PARTITION)
+ if (ctx->base.init_flags & VPX_CODEC_USE_OUTPUT_PARTITION) {
((VP8_COMP *)ctx->cpi)->output_partition = 1;
+ }
/* Convert API flags to internal codec lib flags */
lib_flags = (flags & VPX_EFLAG_FORCE_KF) ? FRAMEFLAGS_KEY : 0;
ctx->cpi, &lib_flags, &size, cx_data, cx_data_end, &dst_time_stamp,
&dst_end_time_stamp, !img);
- if (comp_data_state == VPX_CODEC_CORRUPT_FRAME)
+ if (comp_data_state == VPX_CODEC_CORRUPT_FRAME) {
return VPX_CODEC_CORRUPT_FRAME;
- else if (comp_data_state == -1)
+ } else if (comp_data_state == -1) {
break;
+ }
if (size) {
vpx_codec_pts_t round, delta;
ctx->cfg.g_timebase.num / 10000000);
pkt.data.frame.flags = lib_flags << 16;
- if (lib_flags & FRAMEFLAGS_KEY)
+ if (lib_flags & FRAMEFLAGS_KEY) {
pkt.data.frame.flags |= VPX_FRAME_IS_KEY;
+ }
if (!cpi->common.show_frame) {
pkt.data.frame.flags |= VPX_FRAME_IS_INVISIBLE;
pkt.data.frame.sz = cpi->partition_sz[i];
pkt.data.frame.partition_id = i;
/* don't set the fragment bit for the last partition */
- if (i == (num_partitions - 1))
+ if (i == (num_partitions - 1)) {
pkt.data.frame.flags &= ~VPX_FRAME_IS_FRAGMENT;
+ }
vpx_codec_pkt_list_add(&ctx->pkt_list.head, &pkt);
}
#if CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING
image2yuvconfig(&frame->img, &sd);
vp8_set_reference(ctx->cpi, frame->frame_type, &sd);
return VPX_CODEC_OK;
- } else
+ } else {
return VPX_CODEC_INVALID_PARAM;
+ }
}
static vpx_codec_err_t vp8e_get_reference(vpx_codec_alg_priv_t *ctx,
image2yuvconfig(&frame->img, &sd);
vp8_get_reference(ctx->cpi, frame->frame_type, &sd);
return VPX_CODEC_OK;
- } else
+ } else {
return VPX_CODEC_INVALID_PARAM;
+ }
}
static vpx_codec_err_t vp8e_set_previewpp(vpx_codec_alg_priv_t *ctx,
if (data) {
ctx->preview_ppcfg = *((vp8_postproc_cfg_t *)data);
return VPX_CODEC_OK;
- } else
+ } else {
return VPX_CODEC_INVALID_PARAM;
+ }
#else
(void)ctx;
(void)args;
ctx->preview_img.h = sd.y_height;
return &ctx->preview_img;
- } else
+ } else {
return NULL;
+ }
}
static vpx_codec_err_t vp8e_set_frame_flags(vpx_codec_alg_priv_t *ctx,
vpx_roi_map_t *roi = (vpx_roi_map_t *)data;
if (!vp8_set_roimap(ctx->cpi, roi->roi_map, roi->rows, roi->cols,
- roi->delta_q, roi->delta_lf, roi->static_threshold))
+ roi->delta_q, roi->delta_lf, roi->static_threshold)) {
return VPX_CODEC_OK;
- else
+ } else {
return VPX_CODEC_INVALID_PARAM;
- } else
+ }
+ } else {
return VPX_CODEC_INVALID_PARAM;
+ }
}
static vpx_codec_err_t vp8e_set_activemap(vpx_codec_alg_priv_t *ctx,
if (data) {
vpx_active_map_t *map = (vpx_active_map_t *)data;
- if (!vp8_set_active_map(ctx->cpi, map->active_map, map->rows, map->cols))
+ if (!vp8_set_active_map(ctx->cpi, map->active_map, map->rows, map->cols)) {
return VPX_CODEC_OK;
- else
+ } else {
return VPX_CODEC_INVALID_PARAM;
- } else
+ }
+ } else {
return VPX_CODEC_INVALID_PARAM;
+ }
}
static vpx_codec_err_t vp8e_set_scalemode(vpx_codec_alg_priv_t *ctx,
/*force next frame a key frame to effect scaling mode */
ctx->next_frame_flag |= FRAMEFLAGS_KEY;
return VPX_CODEC_OK;
- } else
+ } else {
return VPX_CODEC_INVALID_PARAM;
- } else
+ }
+ } else {
return VPX_CODEC_INVALID_PARAM;
+ }
}
static vpx_codec_ctrl_fn_map_t vp8e_ctf_maps[] = {
si->is_kf = 1;
/* vet via sync code */
- if (clear[3] != 0x9d || clear[4] != 0x01 || clear[5] != 0x2a)
+ if (clear[3] != 0x9d || clear[4] != 0x01 || clear[5] != 0x2a) {
return VPX_CODEC_UNSUP_BITSTREAM;
+ }
si->w = (clear[6] | (clear[7] << 8)) & 0x3fff;
si->h = (clear[8] | (clear[9] << 8)) & 0x3fff;
vpx_codec_stream_info_t *si) {
unsigned int sz;
- if (si->sz >= sizeof(vp8_stream_info_t))
+ if (si->sz >= sizeof(vp8_stream_info_t)) {
sz = sizeof(vp8_stream_info_t);
- else
+ } else {
sz = sizeof(vpx_codec_stream_info_t);
+ }
memcpy(si, &ctx->si, sz);
si->sz = sz;
vpx_codec_alg_priv_t *ctx, const struct vpx_internal_error_info *error) {
vpx_codec_err_t res;
- if ((res = error->error_code))
+ if ((res = error->error_code)) {
ctx->base.err_detail = error->has_detail ? error->detail : NULL;
+ }
return res;
}
"Invalid frame height");
}
- if (vp8_alloc_frame_buffers(pc, pc->Width, pc->Height))
+ if (vp8_alloc_frame_buffers(pc, pc->Width, pc->Height)) {
vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate frame buffers");
+ }
xd->pre = pc->yv12_fb[pc->lst_fb_idx];
xd->dst = pc->yv12_fb[pc->new_fb_idx];
#endif
#if CONFIG_MULTITHREAD
- if (pbi->b_multithreaded_rd)
+ if (pbi->b_multithreaded_rd) {
vp8mt_alloc_temp_buffers(pbi, pc->Width, prev_mb_rows);
+ }
#else
(void)prev_mb_rows;
#endif
return vp8dx_set_reference(ctx->yv12_frame_buffers.pbi[0],
frame->frame_type, &sd);
- } else
+ } else {
return VPX_CODEC_INVALID_PARAM;
+ }
}
static vpx_codec_err_t vp8_get_reference(vpx_codec_alg_priv_t *ctx,
return vp8dx_get_reference(ctx->yv12_frame_buffers.pbi[0],
frame->frame_type, &sd);
- } else
+ } else {
return VPX_CODEC_INVALID_PARAM;
+ }
}
static vpx_codec_err_t vp8_set_postproc(vpx_codec_alg_priv_t *ctx,
ctx->postproc_cfg_set = 1;
ctx->postproc_cfg = *((vp8_postproc_cfg_t *)data);
return VPX_CODEC_OK;
- } else
+ } else {
return VPX_CODEC_INVALID_PARAM;
+ }
#else
(void)ctx;
pbi->common.refresh_last_frame * (int)VP8_LAST_FRAME;
return VPX_CODEC_OK;
- } else
+ } else {
return VPX_CODEC_INVALID_PARAM;
+ }
}
extern int vp8dx_references_buffer(VP8_COMMON *oci, int ref_frame);
(vp8dx_references_buffer(oci, LAST_FRAME) ? VP8_LAST_FRAME : 0);
return VPX_CODEC_OK;
- } else
+ } else {
return VPX_CODEC_INVALID_PARAM;
+ }
}
static vpx_codec_err_t vp8_get_frame_corrupted(vpx_codec_alg_priv_t *ctx,
if (frame == NULL) return VPX_CODEC_ERROR;
*corrupted = frame->corrupted;
return VPX_CODEC_OK;
- } else
+ } else {
return VPX_CODEC_INVALID_PARAM;
+ }
}
static vpx_codec_err_t vp8_set_decryptor(vpx_codec_alg_priv_t *ctx,