Code cleanup.

Adding multiple16 function, removing redundant code, better formatting.

Change-Id: I50195b78ac8ab803e3d05c8fb05a7ca134fab386
This commit is contained in:
Dmitry Kovalev 2013-04-01 18:23:04 -07:00
parent e3955007df
commit 50e54c112d
10 changed files with 281 additions and 322 deletions

View File

@ -19,17 +19,16 @@
#include "vp9/common/vp9_systemdependent.h" #include "vp9/common/vp9_systemdependent.h"
void vp9_update_mode_info_border(VP9_COMMON *cpi, MODE_INFO *mi_base) { void vp9_update_mode_info_border(VP9_COMMON *cpi, MODE_INFO *mi) {
int stride = cpi->mode_info_stride; const int stride = cpi->mode_info_stride;
int i; int i;
// Clear down top border row // Clear down top border row
vpx_memset(mi_base, 0, sizeof(MODE_INFO) * cpi->mode_info_stride); vpx_memset(mi, 0, sizeof(MODE_INFO) * stride);
// Clear left border column // Clear left border column
for (i = 1; i < cpi->mb_rows + 1; i++) { for (i = 1; i < cpi->mb_rows + 1; i++)
vpx_memset(&mi_base[i * stride], 0, sizeof(MODE_INFO)); vpx_memset(&mi[i * stride], 0, sizeof(MODE_INFO));
}
} }
void vp9_update_mode_info_in_image(VP9_COMMON *cpi, MODE_INFO *mi) { void vp9_update_mode_info_in_image(VP9_COMMON *cpi, MODE_INFO *mi) {
@ -46,7 +45,7 @@ void vp9_update_mode_info_in_image(VP9_COMMON *cpi, MODE_INFO *mi) {
} }
} }
void vp9_de_alloc_frame_buffers(VP9_COMMON *oci) { void vp9_free_frame_buffers(VP9_COMMON *oci) {
int i; int i;
for (i = 0; i < NUM_YV12_BUFFERS; i++) for (i = 0; i < NUM_YV12_BUFFERS; i++)
@ -67,19 +66,18 @@ void vp9_de_alloc_frame_buffers(VP9_COMMON *oci) {
int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) { int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) {
int i; int i;
int aligned_width, aligned_height;
vp9_de_alloc_frame_buffers(oci); // Our internal buffers are always multiples of 16
const int aligned_width = multiple16(width);
const int aligned_height = multiple16(height);
/* our internal buffers are always multiples of 16 */ vp9_free_frame_buffers(oci);
aligned_width = (width + 15) & ~15;
aligned_height = (height + 15) & ~15;
for (i = 0; i < NUM_YV12_BUFFERS; i++) { for (i = 0; i < NUM_YV12_BUFFERS; i++) {
oci->fb_idx_ref_cnt[i] = 0; oci->fb_idx_ref_cnt[i] = 0;
if (vp8_yv12_alloc_frame_buffer(&oci->yv12_fb[i], width, height, if (vp8_yv12_alloc_frame_buffer(&oci->yv12_fb[i], width, height,
VP9BORDERINPIXELS) < 0) { VP9BORDERINPIXELS) < 0) {
vp9_de_alloc_frame_buffers(oci); vp9_free_frame_buffers(oci);
return 1; return 1;
} }
} }
@ -97,13 +95,13 @@ int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) {
if (vp8_yv12_alloc_frame_buffer(&oci->temp_scale_frame, width, 16, if (vp8_yv12_alloc_frame_buffer(&oci->temp_scale_frame, width, 16,
VP9BORDERINPIXELS) < 0) { VP9BORDERINPIXELS) < 0) {
vp9_de_alloc_frame_buffers(oci); vp9_free_frame_buffers(oci);
return 1; return 1;
} }
if (vp8_yv12_alloc_frame_buffer(&oci->post_proc_buffer, width, height, if (vp8_yv12_alloc_frame_buffer(&oci->post_proc_buffer, width, height,
VP9BORDERINPIXELS) < 0) { VP9BORDERINPIXELS) < 0) {
vp9_de_alloc_frame_buffers(oci); vp9_free_frame_buffers(oci);
return 1; return 1;
} }
@ -114,7 +112,7 @@ int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) {
oci->mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MODE_INFO)); oci->mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MODE_INFO));
if (!oci->mip) { if (!oci->mip) {
vp9_de_alloc_frame_buffers(oci); vp9_free_frame_buffers(oci);
return 1; return 1;
} }
@ -125,7 +123,7 @@ int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) {
oci->prev_mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MODE_INFO)); oci->prev_mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MODE_INFO));
if (!oci->prev_mip) { if (!oci->prev_mip) {
vp9_de_alloc_frame_buffers(oci); vp9_free_frame_buffers(oci);
return 1; return 1;
} }
@ -135,7 +133,7 @@ int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) {
vpx_calloc(sizeof(ENTROPY_CONTEXT_PLANES) * (3 + oci->mb_cols), 1); vpx_calloc(sizeof(ENTROPY_CONTEXT_PLANES) * (3 + oci->mb_cols), 1);
if (!oci->above_context) { if (!oci->above_context) {
vp9_de_alloc_frame_buffers(oci); vp9_free_frame_buffers(oci);
return 1; return 1;
} }
@ -200,20 +198,18 @@ void vp9_create_common(VP9_COMMON *oci) {
oci->clr_type = REG_YUV; oci->clr_type = REG_YUV;
oci->clamp_type = RECON_CLAMP_REQUIRED; oci->clamp_type = RECON_CLAMP_REQUIRED;
/* Initialise reference frame sign bias structure to defaults */ // Initialize reference frame sign bias structure to defaults
vpx_memset(oci->ref_frame_sign_bias, 0, sizeof(oci->ref_frame_sign_bias)); vpx_memset(oci->ref_frame_sign_bias, 0, sizeof(oci->ref_frame_sign_bias));
oci->kf_ymode_probs_update = 0; oci->kf_ymode_probs_update = 0;
} }
void vp9_remove_common(VP9_COMMON *oci) { void vp9_remove_common(VP9_COMMON *oci) {
vp9_de_alloc_frame_buffers(oci); vp9_free_frame_buffers(oci);
} }
void vp9_initialize_common() { void vp9_initialize_common() {
vp9_coef_tree_initialize(); vp9_coef_tree_initialize();
vp9_entropy_mode_init(); vp9_entropy_mode_init();
vp9_entropy_mv_init(); vp9_entropy_mv_init();
} }

View File

@ -14,13 +14,15 @@
#include "vp9/common/vp9_onyxc_int.h" #include "vp9/common/vp9_onyxc_int.h"
void vp9_create_common(VP9_COMMON *oci); void vp9_update_mode_info_border(VP9_COMMON *cpi, MODE_INFO *mi);
void vp9_remove_common(VP9_COMMON *oci);
void vp9_de_alloc_frame_buffers(VP9_COMMON *oci);
int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height);
void vp9_setup_version(VP9_COMMON *oci);
void vp9_update_mode_info_border(VP9_COMMON *cpi, MODE_INFO *mi_base);
void vp9_update_mode_info_in_image(VP9_COMMON *cpi, MODE_INFO *mi); void vp9_update_mode_info_in_image(VP9_COMMON *cpi, MODE_INFO *mi);
void vp9_create_common(VP9_COMMON *oci);
void vp9_remove_common(VP9_COMMON *oci);
int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height);
void vp9_free_frame_buffers(VP9_COMMON *oci);
void vp9_setup_version(VP9_COMMON *oci);
#endif // VP9_COMMON_VP9_ALLOCCOMMON_H_ #endif // VP9_COMMON_VP9_ALLOCCOMMON_H_

View File

@ -652,25 +652,28 @@ static void update_blockd_bmi(MACROBLOCKD *xd) {
} }
static TX_SIZE get_uv_tx_size(const MACROBLOCKD *xd) { static TX_SIZE get_uv_tx_size(const MACROBLOCKD *xd) {
TX_SIZE tx_size_uv; MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi;
if (xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_SB64X64) { const TX_SIZE size = mbmi->txfm_size;
tx_size_uv = xd->mode_info_context->mbmi.txfm_size; const MB_PREDICTION_MODE mode = mbmi->mode;
} else if (xd->mode_info_context->mbmi.sb_type == BLOCK_SIZE_SB32X32) {
if (xd->mode_info_context->mbmi.txfm_size == TX_32X32) switch (mbmi->sb_type) {
tx_size_uv = TX_16X16; case BLOCK_SIZE_SB64X64:
return size;
case BLOCK_SIZE_SB32X32:
if (size == TX_32X32)
return TX_16X16;
else else
tx_size_uv = xd->mode_info_context->mbmi.txfm_size; return size;
} else { default:
if (xd->mode_info_context->mbmi.txfm_size == TX_16X16) if (size == TX_16X16)
tx_size_uv = TX_8X8; return TX_8X8;
else if (xd->mode_info_context->mbmi.txfm_size == TX_8X8 && else if (size == TX_8X8 && (mode == I8X8_PRED || mode == SPLITMV))
(xd->mode_info_context->mbmi.mode == I8X8_PRED || return TX_4X4;
xd->mode_info_context->mbmi.mode == SPLITMV))
tx_size_uv = TX_4X4;
else else
tx_size_uv = xd->mode_info_context->mbmi.txfm_size; return size;
} }
return tx_size_uv;
return size;
} }
#if CONFIG_CODE_NONZEROCOUNT #if CONFIG_CODE_NONZEROCOUNT

View File

@ -55,4 +55,8 @@ static INLINE int clamp(int value, int low, int high) {
return value < low ? low : (value > high ? high : value); return value < low ? low : (value > high ? high : value);
} }
static INLINE int multiple16(int value) {
return (value + 15) & ~15;
}
#endif // VP9_COMMON_VP9_COMMON_H_ #endif // VP9_COMMON_VP9_COMMON_H_

View File

@ -88,10 +88,14 @@ const nmv_context vp9_default_nmv_context = {
}; };
MV_JOINT_TYPE vp9_get_mv_joint(MV mv) { MV_JOINT_TYPE vp9_get_mv_joint(MV mv) {
if (mv.row == 0 && mv.col == 0) return MV_JOINT_ZERO; if (mv.row == 0 && mv.col == 0)
else if (mv.row == 0 && mv.col != 0) return MV_JOINT_HNZVZ; return MV_JOINT_ZERO;
else if (mv.row != 0 && mv.col == 0) return MV_JOINT_HZVNZ; else if (mv.row == 0 && mv.col != 0)
else return MV_JOINT_HNZVNZ; return MV_JOINT_HNZVZ;
else if (mv.row != 0 && mv.col == 0)
return MV_JOINT_HZVNZ;
else
return MV_JOINT_HNZVNZ;
} }
#define mv_class_base(c) ((c) ? (CLASS0_SIZE << (c + 2)) : 0) #define mv_class_base(c) ((c) ? (CLASS0_SIZE << (c + 2)) : 0)
@ -137,7 +141,8 @@ static void increment_nmv_component(int v,
int incr, int incr,
int usehp) { int usehp) {
int s, z, c, o, d, e, f; int s, z, c, o, d, e, f;
if (!incr) return; if (!incr)
return;
assert (v != 0); /* should not be zero */ assert (v != 0); /* should not be zero */
s = v < 0; s = v < 0;
mvcomp->sign[s] += incr; mvcomp->sign[s] += incr;
@ -152,8 +157,8 @@ static void increment_nmv_component(int v,
if (c == MV_CLASS_0) { if (c == MV_CLASS_0) {
mvcomp->class0[d] += incr; mvcomp->class0[d] += incr;
} else { } else {
int i, b; int i;
b = c + CLASS0_BITS - 1; /* number of bits */ int b = c + CLASS0_BITS - 1; // number of bits
for (i = 0; i < b; ++i) for (i = 0; i < b; ++i)
mvcomp->bits[i][((d >> i) & 1)] += incr; mvcomp->bits[i][((d >> i) & 1)] += incr;
} }
@ -204,25 +209,22 @@ static void counts_to_context(nmv_component_counts *mvcomp, int usehp) {
void vp9_increment_nmv(const MV *mv, const MV *ref, nmv_context_counts *mvctx, void vp9_increment_nmv(const MV *mv, const MV *ref, nmv_context_counts *mvctx,
int usehp) { int usehp) {
MV_JOINT_TYPE j = vp9_get_mv_joint(*mv); const MV_JOINT_TYPE type = vp9_get_mv_joint(*mv);
mvctx->joints[j]++; mvctx->joints[type]++;
usehp = usehp && vp9_use_nmv_hp(ref); usehp = usehp && vp9_use_nmv_hp(ref);
if (j == MV_JOINT_HZVNZ || j == MV_JOINT_HNZVNZ) { if (type == MV_JOINT_HZVNZ || type == MV_JOINT_HNZVNZ)
increment_nmv_component_count(mv->row, &mvctx->comps[0], 1, usehp); increment_nmv_component_count(mv->row, &mvctx->comps[0], 1, usehp);
}
if (j == MV_JOINT_HNZVZ || j == MV_JOINT_HNZVNZ) { if (type == MV_JOINT_HNZVZ || type == MV_JOINT_HNZVNZ)
increment_nmv_component_count(mv->col, &mvctx->comps[1], 1, usehp); increment_nmv_component_count(mv->col, &mvctx->comps[1], 1, usehp);
}
} }
static void adapt_prob(vp9_prob *dest, vp9_prob prep, static void adapt_prob(vp9_prob *dest, vp9_prob prep, unsigned int ct[2]) {
unsigned int ct[2]) { const int count = MIN(ct[0] + ct[1], MV_COUNT_SAT);
int count = ct[0] + ct[1];
if (count) { if (count) {
vp9_prob newp = get_binary_prob(ct[0], ct[1]); const vp9_prob newp = get_binary_prob(ct[0], ct[1]);
count = count > MV_COUNT_SAT ? MV_COUNT_SAT : count; const int factor = MV_MAX_UPDATE_FACTOR * count / MV_COUNT_SAT;
*dest = weighted_prob(prep, newp, *dest = weighted_prob(prep, newp, factor);
MV_MAX_UPDATE_FACTOR * count / MV_COUNT_SAT);
} else { } else {
*dest = prep; *dest = prep;
} }
@ -253,10 +255,12 @@ void vp9_counts_to_nmv_context(
branch_ct_joint, branch_ct_joint,
nmv_count->joints, 0); nmv_count->joints, 0);
for (i = 0; i < 2; ++i) { for (i = 0; i < 2; ++i) {
prob->comps[i].sign = get_binary_prob(nmv_count->comps[i].sign[0], const uint32_t s0 = nmv_count->comps[i].sign[0];
nmv_count->comps[i].sign[1]); const uint32_t s1 = nmv_count->comps[i].sign[1];
branch_ct_sign[i][0] = nmv_count->comps[i].sign[0];
branch_ct_sign[i][1] = nmv_count->comps[i].sign[1]; prob->comps[i].sign = get_binary_prob(s0, s1);
branch_ct_sign[i][0] = s0;
branch_ct_sign[i][1] = s1;
vp9_tree_probs_from_distribution(vp9_mv_class_tree, vp9_tree_probs_from_distribution(vp9_mv_class_tree,
prob->comps[i].classes, prob->comps[i].classes,
branch_ct_classes[i], branch_ct_classes[i],
@ -266,10 +270,12 @@ void vp9_counts_to_nmv_context(
branch_ct_class0[i], branch_ct_class0[i],
nmv_count->comps[i].class0, 0); nmv_count->comps[i].class0, 0);
for (j = 0; j < MV_OFFSET_BITS; ++j) { for (j = 0; j < MV_OFFSET_BITS; ++j) {
prob->comps[i].bits[j] = get_binary_prob(nmv_count->comps[i].bits[j][0], const uint32_t b0 = nmv_count->comps[i].bits[j][0];
nmv_count->comps[i].bits[j][1]); const uint32_t b1 = nmv_count->comps[i].bits[j][1];
branch_ct_bits[i][j][0] = nmv_count->comps[i].bits[j][0];
branch_ct_bits[i][j][1] = nmv_count->comps[i].bits[j][1]; prob->comps[i].bits[j] = get_binary_prob(b0, b1);
branch_ct_bits[i][j][0] = b0;
branch_ct_bits[i][j][1] = b1;
} }
} }
for (i = 0; i < 2; ++i) { for (i = 0; i < 2; ++i) {
@ -286,16 +292,18 @@ void vp9_counts_to_nmv_context(
} }
if (usehp) { if (usehp) {
for (i = 0; i < 2; ++i) { for (i = 0; i < 2; ++i) {
prob->comps[i].class0_hp = const uint32_t c0_hp0 = nmv_count->comps[i].class0_hp[0];
get_binary_prob(nmv_count->comps[i].class0_hp[0], const uint32_t c0_hp1 = nmv_count->comps[i].class0_hp[1];
nmv_count->comps[i].class0_hp[1]); const uint32_t hp0 = nmv_count->comps[i].hp[0];
branch_ct_class0_hp[i][0] = nmv_count->comps[i].class0_hp[0]; const uint32_t hp1 = nmv_count->comps[i].hp[1];
branch_ct_class0_hp[i][1] = nmv_count->comps[i].class0_hp[1];
prob->comps[i].hp = get_binary_prob(nmv_count->comps[i].hp[0], prob->comps[i].class0_hp = get_binary_prob(c0_hp0, c0_hp1);
nmv_count->comps[i].hp[1]); branch_ct_class0_hp[i][0] = c0_hp0;
branch_ct_hp[i][0] = nmv_count->comps[i].hp[0]; branch_ct_class0_hp[i][1] = c0_hp1;
branch_ct_hp[i][1] = nmv_count->comps[i].hp[1];
prob->comps[i].hp = get_binary_prob(hp0, hp1);
branch_ct_hp[i][0] = hp0;
branch_ct_hp[i][1] = hp1;
} }
} }
} }

View File

@ -191,7 +191,8 @@ void segment_via_mode_info(VP9_COMMON *oci, int how) {
// give new labels to regions // give new labels to regions
for (i = 1; i < label; i++) for (i = 1; i < label; i++)
if (labels[i].next->count > min_mbs_in_region && labels[labels[i].next->label].label == 0) { if (labels[i].next->count > min_mbs_in_region &&
labels[labels[i].next->label].label == 0) {
segment_info *cs = &segments[label_count]; segment_info *cs = &segments[label_count];
cs->label = label_count; cs->label = label_count;
labels[labels[i].next->label].label = label_count++; labels[labels[i].next->label].label = label_count++;
@ -204,24 +205,21 @@ void segment_via_mode_info(VP9_COMMON *oci, int how) {
cs->sum_x = 0; cs->sum_x = 0;
cs->sum_y = 0; cs->sum_y = 0;
cs->pixels = 0; cs->pixels = 0;
} }
lp = labeling; lp = labeling;
// this is just to gather stats... // this is just to gather stats...
for (i = 0; i < oci->mb_rows; i++, lp += pitch) { for (i = 0; i < oci->mb_rows; i++, lp += pitch) {
for (j = 0; j < oci->mb_cols; j++) { for (j = 0; j < oci->mb_cols; j++) {
segment_info *cs; const int old_lab = labels[lp[j]].next->label;
int oldlab = labels[lp[j]].next->label; const int lab = labels[old_lab].label;
int lab = labels[oldlab].label; segment_info *cs = &segments[lab];
lp[j] = lab;
cs = &segments[lab]; cs->min_x = MIN(cs->min_x, j);
cs->max_x = MAX(cs->max_x, j);
cs->min_x = (j < cs->min_x ? j : cs->min_x); cs->min_y = MIN(cs->min_y, i);
cs->max_x = (j > cs->max_x ? j : cs->max_x); cs->max_y = MAX(cs->max_y, i);
cs->min_y = (i < cs->min_y ? i : cs->min_y);
cs->max_y = (i > cs->max_y ? i : cs->max_y);
cs->sum_x += j; cs->sum_x += j;
cs->sum_y += i; cs->sum_y += i;
cs->pixels++; cs->pixels++;

View File

@ -19,8 +19,7 @@ static INLINE int8_t signed_char_clamp(int t) {
return (int8_t) t; return (int8_t) t;
} }
// should we apply any filter at all: 11111111 yes, 00000000 no
/* should we apply any filter at all ( 11111111 yes, 00000000 no) */
static INLINE int8_t filter_mask(uint8_t limit, uint8_t blimit, static INLINE int8_t filter_mask(uint8_t limit, uint8_t blimit,
uint8_t p3, uint8_t p2, uint8_t p3, uint8_t p2,
uint8_t p1, uint8_t p0, uint8_t p1, uint8_t p0,
@ -34,11 +33,10 @@ static INLINE int8_t filter_mask(uint8_t limit, uint8_t blimit,
mask |= (abs(q2 - q1) > limit) * -1; mask |= (abs(q2 - q1) > limit) * -1;
mask |= (abs(q3 - q2) > limit) * -1; mask |= (abs(q3 - q2) > limit) * -1;
mask |= (abs(p0 - q0) * 2 + abs(p1 - q1) / 2 > blimit) * -1; mask |= (abs(p0 - q0) * 2 + abs(p1 - q1) / 2 > blimit) * -1;
mask = ~mask; return ~mask;
return mask;
} }
/* is there high variance internal edge ( 11111111 yes, 00000000 no) */ // is there high variance internal edge: 11111111 yes, 00000000 no
static INLINE int8_t hevmask(uint8_t thresh, uint8_t p1, uint8_t p0, static INLINE int8_t hevmask(uint8_t thresh, uint8_t p1, uint8_t p0,
uint8_t q0, uint8_t q1) { uint8_t q0, uint8_t q1) {
int8_t hev = 0; int8_t hev = 0;
@ -81,25 +79,23 @@ static INLINE void filter(int8_t mask, uint8_t hev, uint8_t *op1,
*op1 = signed_char_clamp(ps1 + filter) ^ 0x80; *op1 = signed_char_clamp(ps1 + filter) ^ 0x80;
} }
void vp9_loop_filter_horizontal_edge_c(uint8_t *s, void vp9_loop_filter_horizontal_edge_c(uint8_t *s, int p /* pitch */,
int p, /* pitch */ const uint8_t *blimit,
const unsigned char *blimit, const uint8_t *limit,
const unsigned char *limit, const uint8_t *thresh,
const unsigned char *thresh,
int count) { int count) {
int hev = 0; /* high edge variance */
int8_t mask = 0;
int i = 0; int i = 0;
/* loop filter designed to work using chars so that we can make maximum use // loop filter designed to work using chars so that we can make maximum use
* of 8 bit simd instructions. // of 8 bit simd instructions.
*/
do { do {
mask = filter_mask(limit[0], blimit[0], const int8_t mask = filter_mask(limit[0], blimit[0],
s[-4 * p], s[-3 * p], s[-2 * p], s[-1 * p], s[-4 * p], s[-3 * p], s[-2 * p], s[-1 * p],
s[0 * p], s[1 * p], s[2 * p], s[3 * p]); s[0 * p], s[1 * p], s[2 * p], s[3 * p]);
hev = hevmask(thresh[0], s[-2 * p], s[-1 * p], s[0 * p], s[1 * p]); // high edge variance
const int8_t hev = hevmask(thresh[0],
s[-2 * p], s[-1 * p], s[0 * p], s[1 * p]);
filter(mask, hev, s - 2 * p, s - 1 * p, s, s + 1 * p); filter(mask, hev, s - 2 * p, s - 1 * p, s, s + 1 * p);
@ -107,32 +103,27 @@ void vp9_loop_filter_horizontal_edge_c(uint8_t *s,
} while (++i < count * 8); } while (++i < count * 8);
} }
void vp9_loop_filter_vertical_edge_c(uint8_t *s, void vp9_loop_filter_vertical_edge_c(uint8_t *s, int pitch,
int p, const uint8_t *blimit,
const unsigned char *blimit, const uint8_t *limit,
const unsigned char *limit, const uint8_t *thresh,
const unsigned char *thresh,
int count) { int count) {
int hev = 0; /* high edge variance */
int8_t mask = 0;
int i = 0; int i = 0;
/* loop filter designed to work using chars so that we can make maximum use // loop filter designed to work using chars so that we can make maximum use
* of 8 bit simd instructions. // of 8 bit simd instructions.
*/
do { do {
mask = filter_mask(limit[0], blimit[0], const int8_t mask = filter_mask(limit[0], blimit[0],
s[-4], s[-3], s[-2], s[-1], s[-4], s[-3], s[-2], s[-1],
s[0], s[1], s[2], s[3]); s[0], s[1], s[2], s[3]);
hev = hevmask(thresh[0], s[-2], s[-1], s[0], s[1]); // high edge variance
const int8_t hev = hevmask(thresh[0], s[-2], s[-1], s[0], s[1]);
filter(mask, hev, s - 2, s - 1, s, s + 1); filter(mask, hev, s - 2, s - 1, s, s + 1);
s += pitch;
s += p;
} while (++i < count * 8); } while (++i < count * 8);
} }
static INLINE signed char flatmask4(uint8_t thresh, static INLINE int8_t flatmask4(uint8_t thresh,
uint8_t p3, uint8_t p2, uint8_t p3, uint8_t p2,
uint8_t p1, uint8_t p0, uint8_t p1, uint8_t p0,
uint8_t q0, uint8_t q1, uint8_t q0, uint8_t q1,
@ -144,8 +135,7 @@ static INLINE signed char flatmask4(uint8_t thresh,
flat |= (abs(q0 - q2) > thresh) * -1; flat |= (abs(q0 - q2) > thresh) * -1;
flat |= (abs(p3 - p0) > thresh) * -1; flat |= (abs(p3 - p0) > thresh) * -1;
flat |= (abs(q3 - q0) > thresh) * -1; flat |= (abs(q3 - q0) > thresh) * -1;
flat = ~flat; return ~flat;
return flat;
} }
static INLINE signed char flatmask5(uint8_t thresh, static INLINE signed char flatmask5(uint8_t thresh,
uint8_t p4, uint8_t p3, uint8_t p2, uint8_t p4, uint8_t p3, uint8_t p2,
@ -213,28 +203,25 @@ static INLINE void mbfilter(int8_t mask, uint8_t hev, uint8_t flat,
} }
} }
void vp9_mbloop_filter_horizontal_edge_c(uint8_t *s, void vp9_mbloop_filter_horizontal_edge_c(uint8_t *s, int p,
int p, const uint8_t *blimit,
const unsigned char *blimit, const uint8_t *limit,
const unsigned char *limit, const uint8_t *thresh,
const unsigned char *thresh,
int count) { int count) {
int8_t hev = 0; /* high edge variance */
int8_t mask = 0;
int8_t flat = 0;
int i = 0; int i = 0;
/* loop filter designed to work using chars so that we can make maximum use // loop filter designed to work using chars so that we can make maximum use
* of 8 bit simd instructions. // of 8 bit simd instructions.
*/
do { do {
mask = filter_mask(limit[0], blimit[0], const int8_t mask = filter_mask(limit[0], blimit[0],
s[-4 * p], s[-3 * p], s[-2 * p], s[-1 * p], s[-4 * p], s[-3 * p], s[-2 * p], s[-1 * p],
s[ 0 * p], s[ 1 * p], s[ 2 * p], s[ 3 * p]); s[ 0 * p], s[ 1 * p], s[ 2 * p], s[ 3 * p]);
hev = hevmask(thresh[0], s[-2 * p], s[-1 * p], s[0 * p], s[1 * p]); const int8_t hev = hevmask(thresh[0],
s[-2 * p], s[-1 * p], s[0 * p], s[1 * p]);
flat = flatmask4(1, s[-4 * p], s[-3 * p], s[-2 * p], s[-1 * p], const int8_t flat = flatmask4(1,
s[-4 * p], s[-3 * p], s[-2 * p], s[-1 * p],
s[ 0 * p], s[ 1 * p], s[ 2 * p], s[ 3 * p]); s[ 0 * p], s[ 1 * p], s[ 2 * p], s[ 3 * p]);
mbfilter(mask, hev, flat, mbfilter(mask, hev, flat,
s - 4 * p, s - 3 * p, s - 2 * p, s - 1 * p, s - 4 * p, s - 3 * p, s - 2 * p, s - 1 * p,
@ -245,35 +232,29 @@ void vp9_mbloop_filter_horizontal_edge_c(uint8_t *s,
} }
void vp9_mbloop_filter_vertical_edge_c(uint8_t *s, void vp9_mbloop_filter_vertical_edge_c(uint8_t *s, int pitch,
int p, const uint8_t *blimit,
const unsigned char *blimit, const uint8_t *limit,
const unsigned char *limit, const uint8_t *thresh,
const unsigned char *thresh,
int count) { int count) {
int8_t hev = 0; /* high edge variance */
int8_t mask = 0;
int8_t flat = 0;
int i = 0; int i = 0;
do { do {
mask = filter_mask(limit[0], blimit[0], const int8_t mask = filter_mask(limit[0], blimit[0],
s[-4], s[-3], s[-2], s[-1], s[-4], s[-3], s[-2], s[-1],
s[0], s[1], s[2], s[3]); s[0], s[1], s[2], s[3]);
hev = hevmask(thresh[0], s[-2], s[-1], s[0], s[1]); const int8_t hev = hevmask(thresh[0], s[-2], s[-1], s[0], s[1]);
flat = flatmask4(1, const int8_t flat = flatmask4(1, s[-4], s[-3], s[-2], s[-1],
s[-4], s[-3], s[-2], s[-1],
s[ 0], s[ 1], s[ 2], s[ 3]); s[ 0], s[ 1], s[ 2], s[ 3]);
mbfilter(mask, hev, flat, mbfilter(mask, hev, flat, s - 4, s - 3, s - 2, s - 1,
s - 4, s - 3, s - 2, s - 1,
s, s + 1, s + 2, s + 3); s, s + 1, s + 2, s + 3);
s += p; s += pitch;
} while (++i < count * 8); } while (++i < count * 8);
} }
/* should we apply any filter at all ( 11111111 yes, 00000000 no) */ // should we apply any filter at all: 11111111 yes, 00000000 no
static INLINE int8_t simple_filter_mask(uint8_t blimit, static INLINE int8_t simple_filter_mask(uint8_t blimit,
uint8_t p1, uint8_t p0, uint8_t p1, uint8_t p0,
uint8_t q0, uint8_t q1) { uint8_t q0, uint8_t q1) {
@ -301,31 +282,24 @@ static INLINE void simple_filter(int8_t mask,
*op0 = signed_char_clamp(p0 + filter2) ^ 0x80; *op0 = signed_char_clamp(p0 + filter2) ^ 0x80;
} }
void vp9_loop_filter_simple_horizontal_edge_c(uint8_t *s, void vp9_loop_filter_simple_horizontal_edge_c(uint8_t *s, int p,
int p, const uint8_t *blimit) {
const unsigned char *blimit) {
int8_t mask = 0;
int i = 0; int i = 0;
do { do {
mask = simple_filter_mask(blimit[0], const int8_t mask = simple_filter_mask(blimit[0], s[-2 * p], s[-1 * p],
s[-2 * p], s[-1 * p],
s[0 * p], s[1 * p]); s[0 * p], s[1 * p]);
simple_filter(mask, simple_filter(mask, s - 2 * p, s - 1 * p, s, s + 1 * p);
s - 2 * p, s - 1 * p,
s, s + 1 * p);
++s; ++s;
} while (++i < 16); } while (++i < 16);
} }
void vp9_loop_filter_simple_vertical_edge_c(uint8_t *s, void vp9_loop_filter_simple_vertical_edge_c(uint8_t *s, int p,
int p, const uint8_t *blimit) {
const unsigned char *blimit) {
int8_t mask = 0;
int i = 0; int i = 0;
do { do {
mask = simple_filter_mask(blimit[0], s[-2], s[-1], s[0], s[1]); const int8_t mask = simple_filter_mask(blimit[0], s[-2], s[-1], s[0], s[1]);
simple_filter(mask, s - 2, s - 1, s, s + 1); simple_filter(mask, s - 2, s - 1, s, s + 1);
s += p; s += p;
} while (++i < 16); } while (++i < 16);
@ -367,87 +341,82 @@ void vp9_loop_filter_bv_c(uint8_t*y_ptr, uint8_t *u_ptr,
lfi->blim, lfi->lim, lfi->hev_thr, 1); lfi->blim, lfi->lim, lfi->hev_thr, 1);
} }
/* Horizontal MB filtering */ // Horizontal MB filtering
void vp9_loop_filter_mbh_c(uint8_t *y_ptr, uint8_t *u_ptr, void vp9_loop_filter_mbh_c(uint8_t *y, uint8_t *u, uint8_t *v,
uint8_t *v_ptr, int y_stride, int uv_stride, int y_stride, int uv_stride,
struct loop_filter_info *lfi) { struct loop_filter_info *lfi) {
vp9_mbloop_filter_horizontal_edge_c(y_ptr, y_stride, vp9_mbloop_filter_horizontal_edge_c(y, y_stride,
lfi->mblim, lfi->lim, lfi->hev_thr, 2); lfi->mblim, lfi->lim, lfi->hev_thr, 2);
if (u_ptr) if (u)
vp9_mbloop_filter_horizontal_edge_c(u_ptr, uv_stride, vp9_mbloop_filter_horizontal_edge_c(u, uv_stride,
lfi->mblim, lfi->lim, lfi->hev_thr, 1); lfi->mblim, lfi->lim, lfi->hev_thr, 1);
if (v_ptr) if (v)
vp9_mbloop_filter_horizontal_edge_c(v_ptr, uv_stride, vp9_mbloop_filter_horizontal_edge_c(v, uv_stride,
lfi->mblim, lfi->lim, lfi->hev_thr, 1); lfi->mblim, lfi->lim, lfi->hev_thr, 1);
} }
/* Horizontal B Filtering */ // Horizontal B Filtering
void vp9_loop_filter_bh_c(uint8_t *y_ptr, uint8_t *u_ptr, void vp9_loop_filter_bh_c(uint8_t *y, uint8_t *u, uint8_t *v,
uint8_t *v_ptr, int y_stride, int uv_stride, int y_stride, int uv_stride,
struct loop_filter_info *lfi) { struct loop_filter_info *lfi) {
vp9_loop_filter_horizontal_edge_c(y_ptr + 4 * y_stride, y_stride, vp9_loop_filter_horizontal_edge_c(y + 4 * y_stride, y_stride,
lfi->blim, lfi->lim, lfi->hev_thr, 2); lfi->blim, lfi->lim, lfi->hev_thr, 2);
vp9_loop_filter_horizontal_edge_c(y_ptr + 8 * y_stride, y_stride, vp9_loop_filter_horizontal_edge_c(y + 8 * y_stride, y_stride,
lfi->blim, lfi->lim, lfi->hev_thr, 2); lfi->blim, lfi->lim, lfi->hev_thr, 2);
vp9_loop_filter_horizontal_edge_c(y_ptr + 12 * y_stride, y_stride, vp9_loop_filter_horizontal_edge_c(y + 12 * y_stride, y_stride,
lfi->blim, lfi->lim, lfi->hev_thr, 2); lfi->blim, lfi->lim, lfi->hev_thr, 2);
if (u_ptr) if (u)
vp9_loop_filter_horizontal_edge_c(u_ptr + 4 * uv_stride, uv_stride, vp9_loop_filter_horizontal_edge_c(u + 4 * uv_stride, uv_stride,
lfi->blim, lfi->lim, lfi->hev_thr, 1); lfi->blim, lfi->lim, lfi->hev_thr, 1);
if (v_ptr) if (v)
vp9_loop_filter_horizontal_edge_c(v_ptr + 4 * uv_stride, uv_stride, vp9_loop_filter_horizontal_edge_c(v + 4 * uv_stride, uv_stride,
lfi->blim, lfi->lim, lfi->hev_thr, 1); lfi->blim, lfi->lim, lfi->hev_thr, 1);
} }
void vp9_loop_filter_bh8x8_c(uint8_t *y_ptr, uint8_t *u_ptr, void vp9_loop_filter_bh8x8_c(uint8_t *y, uint8_t *u, uint8_t *v,
uint8_t *v_ptr, int y_stride, int uv_stride, int y_stride, int uv_stride,
struct loop_filter_info *lfi) { struct loop_filter_info *lfi) {
vp9_mbloop_filter_horizontal_edge_c( vp9_mbloop_filter_horizontal_edge_c(y + 8 * y_stride, y_stride,
y_ptr + 8 * y_stride, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2); lfi->blim, lfi->lim, lfi->hev_thr, 2);
if (u_ptr) if (u)
vp9_loop_filter_horizontal_edge_c(u_ptr + 4 * uv_stride, uv_stride, vp9_loop_filter_horizontal_edge_c(u + 4 * uv_stride, uv_stride,
lfi->blim, lfi->lim, lfi->hev_thr, 1); lfi->blim, lfi->lim, lfi->hev_thr, 1);
if (v_ptr) if (v)
vp9_loop_filter_horizontal_edge_c(v_ptr + 4 * uv_stride, uv_stride, vp9_loop_filter_horizontal_edge_c(v + 4 * uv_stride, uv_stride,
lfi->blim, lfi->lim, lfi->hev_thr, 1); lfi->blim, lfi->lim, lfi->hev_thr, 1);
} }
void vp9_loop_filter_bhs_c(uint8_t *y_ptr, int y_stride, void vp9_loop_filter_bhs_c(uint8_t *y, int y_stride, const uint8_t *blimit) {
const unsigned char *blimit) { vp9_loop_filter_simple_horizontal_edge_c(y + 4 * y_stride, y_stride, blimit);
vp9_loop_filter_simple_horizontal_edge_c(y_ptr + 4 * y_stride, vp9_loop_filter_simple_horizontal_edge_c(y + 8 * y_stride, y_stride, blimit);
y_stride, blimit); vp9_loop_filter_simple_horizontal_edge_c(y + 12 * y_stride, y_stride, blimit);
vp9_loop_filter_simple_horizontal_edge_c(y_ptr + 8 * y_stride,
y_stride, blimit);
vp9_loop_filter_simple_horizontal_edge_c(y_ptr + 12 * y_stride,
y_stride, blimit);
} }
void vp9_loop_filter_bv8x8_c(uint8_t *y_ptr, uint8_t *u_ptr, void vp9_loop_filter_bv8x8_c(uint8_t *y, uint8_t *u, uint8_t *v,
uint8_t *v_ptr, int y_stride, int uv_stride, int y_stride, int uv_stride,
struct loop_filter_info *lfi) { struct loop_filter_info *lfi) {
vp9_mbloop_filter_vertical_edge_c( vp9_mbloop_filter_vertical_edge_c(y + 8, y_stride,
y_ptr + 8, y_stride, lfi->blim, lfi->lim, lfi->hev_thr, 2); lfi->blim, lfi->lim, lfi->hev_thr, 2);
if (u_ptr) if (u)
vp9_loop_filter_vertical_edge_c(u_ptr + 4, uv_stride, vp9_loop_filter_vertical_edge_c(u + 4, uv_stride,
lfi->blim, lfi->lim, lfi->hev_thr, 1); lfi->blim, lfi->lim, lfi->hev_thr, 1);
if (v_ptr) if (v)
vp9_loop_filter_vertical_edge_c(v_ptr + 4, uv_stride, vp9_loop_filter_vertical_edge_c(v + 4, uv_stride,
lfi->blim, lfi->lim, lfi->hev_thr, 1); lfi->blim, lfi->lim, lfi->hev_thr, 1);
} }
void vp9_loop_filter_bvs_c(uint8_t *y_ptr, int y_stride, void vp9_loop_filter_bvs_c(uint8_t *y, int y_stride, const uint8_t *blimit) {
const unsigned char *blimit) { vp9_loop_filter_simple_vertical_edge_c(y + 4, y_stride, blimit);
vp9_loop_filter_simple_vertical_edge_c(y_ptr + 4, y_stride, blimit); vp9_loop_filter_simple_vertical_edge_c(y + 8, y_stride, blimit);
vp9_loop_filter_simple_vertical_edge_c(y_ptr + 8, y_stride, blimit); vp9_loop_filter_simple_vertical_edge_c(y + 12, y_stride, blimit);
vp9_loop_filter_simple_vertical_edge_c(y_ptr + 12, y_stride, blimit);
} }
static INLINE void wide_mbfilter(int8_t mask, uint8_t hev, static INLINE void wide_mbfilter(int8_t mask, uint8_t hev,
@ -551,36 +520,28 @@ static INLINE void wide_mbfilter(int8_t mask, uint8_t hev,
} }
} }
void vp9_mb_lpf_horizontal_edge_w void vp9_mb_lpf_horizontal_edge_w(uint8_t *s, int p,
( const uint8_t *blimit,
unsigned char *s, const uint8_t *limit,
int p, const uint8_t *thresh,
const unsigned char *blimit, int count) {
const unsigned char *limit,
const unsigned char *thresh,
int count
) {
signed char hev = 0; /* high edge variance */
signed char mask = 0;
signed char flat = 0;
signed char flat2 = 0;
int i = 0; int i = 0;
/* loop filter designed to work using chars so that we can make maximum use // loop filter designed to work using chars so that we can make maximum use
* of 8 bit simd instructions. // of 8 bit simd instructions.
*/
do { do {
mask = filter_mask(limit[0], blimit[0], const int8_t mask = filter_mask(limit[0], blimit[0],
s[-4 * p], s[-3 * p], s[-2 * p], s[-1 * p], s[-4 * p], s[-3 * p], s[-2 * p], s[-1 * p],
s[ 0 * p], s[ 1 * p], s[ 2 * p], s[ 3 * p]); s[ 0 * p], s[ 1 * p], s[ 2 * p], s[ 3 * p]);
hev = hevmask(thresh[0], s[-2 * p], s[-1 * p], s[0 * p], s[1 * p]); const int8_t hev = hevmask(thresh[0],
s[-2 * p], s[-1 * p], s[0 * p], s[1 * p]);
flat = flatmask4(1, const int8_t flat = flatmask4(1,
s[-4 * p], s[-3 * p], s[-2 * p], s[-1 * p], s[-4 * p], s[-3 * p], s[-2 * p], s[-1 * p],
s[ 0 * p], s[ 1 * p], s[ 2 * p], s[ 3 * p]); s[ 0 * p], s[ 1 * p], s[ 2 * p], s[ 3 * p]);
flat2 = flatmask5(1, const int8_t flat2 = flatmask5(1,
s[-8 * p], s[-7 * p], s[-6 * p], s[-5 * p], s[-1 * p], s[-8 * p], s[-7 * p], s[-6 * p], s[-5 * p], s[-1 * p],
s[ 0 * p], s[ 4 * p], s[ 5 * p], s[ 6 * p], s[ 7 * p]); s[ 0 * p], s[ 4 * p], s[ 5 * p], s[ 6 * p], s[ 7 * p]);
@ -593,32 +554,22 @@ void vp9_mb_lpf_horizontal_edge_w
++s; ++s;
} while (++i < count * 8); } while (++i < count * 8);
} }
void vp9_mb_lpf_vertical_edge_w void vp9_mb_lpf_vertical_edge_w(uint8_t *s, int p,
( const uint8_t *blimit,
unsigned char *s, const uint8_t *limit,
int p, const uint8_t *thresh,
const unsigned char *blimit, int count) {
const unsigned char *limit,
const unsigned char *thresh,
int count
) {
signed char hev = 0; /* high edge variance */
signed char mask = 0;
signed char flat = 0;
signed char flat2 = 0;
int i = 0; int i = 0;
do { do {
mask = filter_mask(limit[0], blimit[0], const int8_t mask = filter_mask(limit[0], blimit[0],
s[-4], s[-3], s[-2], s[-1], s[-4], s[-3], s[-2], s[-1],
s[0], s[1], s[2], s[3]); s[0], s[1], s[2], s[3]);
hev = hevmask(thresh[0], s[-2], s[-1], s[0], s[1]); const int8_t hev = hevmask(thresh[0], s[-2], s[-1], s[0], s[1]);
flat = flatmask4(1, const int8_t flat = flatmask4(1, s[-4], s[-3], s[-2], s[-1],
s[-4], s[-3], s[-2], s[-1],
s[ 0], s[ 1], s[ 2], s[ 3]); s[ 0], s[ 1], s[ 2], s[ 3]);
flat2 = flatmask5(1, const int8_t flat2 = flatmask5(1, s[-8], s[-7], s[-6], s[-5], s[-1],
s[-8], s[-7], s[-6], s[-5], s[-1],
s[ 0], s[ 4], s[ 5], s[ 6], s[ 7]); s[ 0], s[ 4], s[ 5], s[ 6], s[ 7]);
wide_mbfilter(mask, hev, flat, flat2, wide_mbfilter(mask, hev, flat, flat2,
@ -630,32 +581,33 @@ void vp9_mb_lpf_vertical_edge_w
} while (++i < count * 8); } while (++i < count * 8);
} }
void vp9_lpf_mbv_w_c(unsigned char *y_ptr, unsigned char *u_ptr, void vp9_lpf_mbv_w_c(uint8_t *y, uint8_t *u, uint8_t *v,
unsigned char *v_ptr, int y_stride, int uv_stride, int y_stride, int uv_stride,
struct loop_filter_info *lfi) { struct loop_filter_info *lfi) {
vp9_mb_lpf_vertical_edge_w(y_ptr, y_stride, vp9_mb_lpf_vertical_edge_w(y, y_stride,
lfi->mblim, lfi->lim, lfi->hev_thr, 2); lfi->mblim, lfi->lim, lfi->hev_thr, 2);
if (u_ptr) if (u)
vp9_mbloop_filter_vertical_edge_c(u_ptr, uv_stride, vp9_mbloop_filter_vertical_edge_c(u, uv_stride,
lfi->mblim, lfi->lim, lfi->hev_thr, 1); lfi->mblim, lfi->lim, lfi->hev_thr, 1);
if (v_ptr) if (v)
vp9_mbloop_filter_vertical_edge_c(v_ptr, uv_stride, vp9_mbloop_filter_vertical_edge_c(v, uv_stride,
lfi->mblim, lfi->lim, lfi->hev_thr, 1); lfi->mblim, lfi->lim, lfi->hev_thr, 1);
} }
void vp9_lpf_mbh_w_c(unsigned char *y_ptr, unsigned char *u_ptr,
unsigned char *v_ptr, int y_stride, int uv_stride, void vp9_lpf_mbh_w_c(uint8_t *y, uint8_t *u, uint8_t *v,
struct loop_filter_info *lfi) { int y_stride, int uv_stride,
vp9_mb_lpf_horizontal_edge_w(y_ptr, y_stride, struct loop_filter_info *lfi) {
lfi->mblim, lfi->lim, lfi->hev_thr, 2); vp9_mb_lpf_horizontal_edge_w(y, y_stride,
lfi->mblim, lfi->lim, lfi->hev_thr, 2);
if (u_ptr)
vp9_mbloop_filter_horizontal_edge_c(u_ptr, uv_stride, if (u)
lfi->mblim, lfi->lim, lfi->hev_thr, 1); vp9_mbloop_filter_horizontal_edge_c(u, uv_stride,
lfi->mblim, lfi->lim, lfi->hev_thr, 1);
if (v_ptr)
vp9_mbloop_filter_horizontal_edge_c(v_ptr, uv_stride, if (v)
vp9_mbloop_filter_horizontal_edge_c(v, uv_stride,
lfi->mblim, lfi->lim, lfi->hev_thr, 1); lfi->mblim, lfi->lim, lfi->hev_thr, 1);
} }

View File

@ -1308,9 +1308,8 @@ static void read_coef_probs(VP9D_COMP *pbi, BOOL_DECODER* const bc) {
static void update_frame_size(VP9D_COMP *pbi) { static void update_frame_size(VP9D_COMP *pbi) {
VP9_COMMON *cm = &pbi->common; VP9_COMMON *cm = &pbi->common;
/* our internal buffers are always multiples of 16 */ const int width = multiple16(cm->width);
const int width = (cm->width + 15) & ~15; const int height = multiple16(cm->height);
const int height = (cm->height + 15) & ~15;
cm->mb_rows = height >> 4; cm->mb_rows = height >> 4;
cm->mb_cols = width >> 4; cm->mb_cols = width >> 4;

View File

@ -326,7 +326,7 @@ static void dealloc_compressor_data(VP9_COMP *cpi) {
vpx_free(cpi->active_map); vpx_free(cpi->active_map);
cpi->active_map = 0; cpi->active_map = 0;
vp9_de_alloc_frame_buffers(&cpi->common); vp9_free_frame_buffers(&cpi->common);
vp8_yv12_de_alloc_frame_buffer(&cpi->last_frame_uf); vp8_yv12_de_alloc_frame_buffer(&cpi->last_frame_uf);
vp8_yv12_de_alloc_frame_buffer(&cpi->scaled_source); vp8_yv12_de_alloc_frame_buffer(&cpi->scaled_source);
@ -960,9 +960,8 @@ void vp9_alloc_compressor_data(VP9_COMP *cpi) {
static void update_frame_size(VP9_COMP *cpi) { static void update_frame_size(VP9_COMP *cpi) {
VP9_COMMON *cm = &cpi->common; VP9_COMMON *cm = &cpi->common;
/* our internal buffers are always multiples of 16 */ const int aligned_width = multiple16(cm->width);
int aligned_width = (cm->width + 15) & ~15; const int aligned_height = multiple16(cm->height);
int aligned_height = (cm->height + 15) & ~15;
cm->mb_rows = aligned_height >> 4; cm->mb_rows = aligned_height >> 4;
cm->mb_cols = aligned_width >> 4; cm->mb_cols = aligned_width >> 4;

View File

@ -10,17 +10,15 @@
#ifndef VP9_VP9_IFACE_COMMON_H_ #ifndef VP9_VP9_IFACE_COMMON_H_
#define VP9_VP9_IFACE_COMMON_H_ #define VP9_VP9_IFACE_COMMON_H_
static void yuvconfig2image(vpx_image_t *img, static void yuvconfig2image(vpx_image_t *img, const YV12_BUFFER_CONFIG *yv12,
const YV12_BUFFER_CONFIG *yv12,
void *user_priv) { void *user_priv) {
/** vpx_img_wrap() doesn't allow specifying independent strides for /** vpx_img_wrap() doesn't allow specifying independent strides for
* the Y, U, and V planes, nor other alignment adjustments that * the Y, U, and V planes, nor other alignment adjustments that
* might be representable by a YV12_BUFFER_CONFIG, so we just * might be representable by a YV12_BUFFER_CONFIG, so we just
* initialize all the fields.*/ * initialize all the fields.*/
img->fmt = yv12->clrtype == REG_YUV ? img->fmt = yv12->clrtype == REG_YUV ? VPX_IMG_FMT_I420 : VPX_IMG_FMT_VPXI420;
VPX_IMG_FMT_I420 : VPX_IMG_FMT_VPXI420;
img->w = yv12->y_stride; img->w = yv12->y_stride;
img->h = (yv12->y_height + 2 * VP9BORDERINPIXELS + 15) & ~15; img->h = multiple16(yv12->y_height + 2 * VP9BORDERINPIXELS);
img->d_w = yv12->y_width; img->d_w = yv12->y_width;
img->d_h = yv12->y_height; img->d_h = yv12->y_height;
img->x_chroma_shift = 1; img->x_chroma_shift = 1;
@ -40,4 +38,4 @@ static void yuvconfig2image(vpx_image_t *img,
img->self_allocd = 0; img->self_allocd = 0;
} }
#endif #endif // VP9_VP9_IFACE_COMMON_H_