Skip to content

Commit

Permalink
changed the as_int to a direct array reference on mv
Browse files Browse the repository at this point in the history
  • Loading branch information
brianxautumn committed Mar 6, 2017
1 parent e96030b commit d8ea8f3
Show file tree
Hide file tree
Showing 7 changed files with 282 additions and 290 deletions.
218 changes: 109 additions & 109 deletions builds/jsvpx.js

Large diffs are not rendered by default.

224 changes: 112 additions & 112 deletions builds/ogv-decoder-video-vp8.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vp8/common/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ function filter_block(return_off,

//reference_off += ((mv_.y >> 3) * stride) + (mv_.x >> 3);

if (mv_.as_int)
if (mv_.as_int[0])
{
filter_block2d(output, output_off, stride, reference, reference_off, stride, 4, 4, mv_.x & 7, mv_.y & 7,
filters);
Expand Down
11 changes: 1 addition & 10 deletions vp8/common/mv.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class MotionVector {

constructor() {
this.internalStruct = new Int16Array(2);
this.internalStruct32 = new Uint32Array(this.internalStruct.buffer);
this.as_int = new Uint32Array(this.internalStruct.buffer);

}
}
Expand All @@ -27,13 +27,4 @@ Object.defineProperty(MotionVector.prototype, 'y', {
}
});

Object.defineProperty(MotionVector.prototype, 'as_int', {
get: function () {
return this.internalStruct32[0];
},
set: function (as_int) {
this.internalStruct32[0] = as_int;
}
});

module.exports = MotionVector;
18 changes: 9 additions & 9 deletions vp8/common/reconinter.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function build_4x4uvmvs(mbi, full_pixel) {
chroma_mv_cache.y = (temp / 8) | 0;

if (full_pixel === 1) {
chroma_mv_cache.as_int &= 0xFFF8FFF8;
chroma_mv_cache.as_int[0] &= 0xFFF8FFF8;

}

Expand Down Expand Up @@ -316,7 +316,7 @@ function recon_1_block(output, output_off, reference, reference_off, stride, mv,
var predict_off = reference_off;
var mx = 0, my = 0;

if (mv.as_int) {
if (mv.as_int[0]) {

mx = mv.x & 7;
my = mv.y & 7;
Expand Down Expand Up @@ -371,7 +371,7 @@ function recon_1_edge_block(output, output_off,



if (mv_.as_int) {
if (mv_.as_int[0]) {

mx = mv_.x & 7;
my = mv_.y & 7;
Expand Down Expand Up @@ -408,7 +408,7 @@ function vp8_build_inter16x16_predictors_mb(mbi, full_pixel) {

var mbmi_cache = mbi.mbmi;

uvmv.as_int = mbmi_cache.mv.as_int;
uvmv.as_int[0] = mbmi_cache.mv.as_int[0];

if (mbi.mbmi.need_mc_border === 1) {
var x = uvmv.x;
Expand All @@ -424,13 +424,13 @@ function vp8_build_inter16x16_predictors_mb(mbi, full_pixel) {
}

if (full_pixel) {
uvmv.as_int &= 0xFFF8FFF8;
uvmv.as_int[0] &= 0xFFF8FFF8;
}

chroma_mv[0].as_int =
chroma_mv[1].as_int =
chroma_mv[2].as_int =
chroma_mv[3].as_int = uvmv.as_int;
chroma_mv[0].as_int[0] =
chroma_mv[1].as_int[0] =
chroma_mv[2].as_int[0] =
chroma_mv[3].as_int[0] = uvmv.as_int[0];

}

Expand Down
23 changes: 12 additions & 11 deletions vp8/common/vp8_loopfilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ function vp8_loop_filter_row_simple(ctx, row) {
for (col = 0; col < ctx.mb_cols; col++) {


/* TODO: only need to recalculate every MB if segmentation is
* enabled.
*/
// TODO: only need to recalculate every MB if segmentation is
// enabled.

calculate_filter_parameters(ctx, mbi[mbi_off], edge_limit,
interior_limit, hev_threshold);

Expand All @@ -80,11 +80,11 @@ function vp8_loop_filter_row_simple(ctx, row) {
{
//vp8_loop_filter_simple_bv vp8_loop_filter_bvs_c
vp8_loop_filter_bvs_c(y, y_off, stride, b_limit);
/*
filter_v_edge_simple(y, y_off + 4, stride, b_limit);
filter_v_edge_simple(y, y_off + 8, stride, b_limit);
filter_v_edge_simple(y, y_off + 12, stride, b_limit);
*/

//filter_v_edge_simple(y, y_off + 4, stride, b_limit);
//filter_v_edge_simple(y, y_off + 8, stride, b_limit);
//filter_v_edge_simple(y, y_off + 12, stride, b_limit);

}

if (row > 0)
Expand Down Expand Up @@ -133,9 +133,9 @@ function vp8_loop_filter_row_normal(ctx, row, start_col, num_cols) {
{
//var edge_limit = [0], interior_limit = [0], hev_threshold = [0];
var edge_limit = edge_limit_cache, interior_limit = interior_limit_cache, hev_threshold = hev_threshold_cache;
/* TODO: only need to recalculate every MB if segmentation is
* enabled.
*/
// TODO: only need to recalculate every MB if segmentation is
// enabled.

calculate_filter_parameters(ctx, mbi[mbi_off], edge_limit,
interior_limit, hev_threshold);
edge_limit = edge_limit[0], interior_limit = interior_limit[0], hev_threshold = hev_threshold[0];
Expand Down Expand Up @@ -196,6 +196,7 @@ function vp8_loop_filter_row_normal(ctx, row, start_col, num_cols) {
v_off += 8;
mbi_off++;
}

}

function calculate_filter_parameters(ctx,
Expand Down
76 changes: 38 additions & 38 deletions vp8/decoder/decodemv.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ function decode_split_mv(mi, left_mb, above_mb, hdr, best_mv, bool) {


do {
blockmv.as_int = 0;
left_mv.as_int = 0;
above_mv.as_int = 0;
blockmv.as_int[0] = 0;
left_mv.as_int[0] = 0;
above_mv.as_int[0] = 0;

var subblock_mode;//='prediction_mode'

Expand All @@ -239,49 +239,49 @@ function decode_split_mv(mi, left_mb, above_mb, hdr, best_mv, bool) {
/* Decode the next MV */
if (!(k & 3)) {
if (left_mb.mbmi.y_mode === SPLITMV){
left_mv.as_int = left_mb.bmi.mvs[k + 3].as_int;
left_mv.as_int[0] = left_mb.bmi.mvs[k + 3].as_int[0];
}else{
left_mv.as_int = left_mb.mbmi.mv.as_int;
left_mv.as_int[0] = left_mb.mbmi.mv.as_int[0];
}

} else {
left_mv.as_int = mi.bmi.mvs[k - 1].as_int;
left_mv.as_int[0] = mi.bmi.mvs[k - 1].as_int[0];
}


if (!(k >> 2)) {
if (above_mb.mbmi.y_mode === SPLITMV) {
above_mv.as_int = above_mb.bmi.mvs[k + 12].as_int;
above_mv.as_int[0] = above_mb.bmi.mvs[k + 12].as_int[0];
} else {
above_mv.as_int = above_mb.mbmi.mv.as_int;
above_mv.as_int[0] = above_mb.mbmi.mv.as_int[0];
}

} else {
above_mv.as_int = mi.bmi.mvs[k - 4].as_int;
above_mv.as_int[0] = mi.bmi.mvs[k - 4].as_int[0];
}

prob = get_sub_mv_ref_prob(left_mv.as_int, above_mv.as_int);
prob = get_sub_mv_ref_prob(left_mv.as_int[0], above_mv.as_int[0]);

if (vpx_read(bool, prob[0])) {
if (vpx_read(bool, prob[1])) {
//blockmv.as_int = 0;
//blockmv.as_int[0] = 0;
if (vpx_read(bool, prob[2])) {
read_mv(bool, blockmv, hdr.mv_probs);
blockmv.x = (blockmv.x + best_mv.x);
blockmv.y = (blockmv.y + best_mv.y);
}
} else {
blockmv.as_int = above_mv.as_int;
blockmv.as_int[0] = above_mv.as_int[0];
}
} else {
blockmv.as_int = left_mv.as_int;
blockmv.as_int[0] = left_mv.as_int[0];
}

var fill_count = mbsplit_fill_count[s];
/* Fill the MV's for this partition */
for (; k < 16; k++)
if (j === partition[k]) {
mvs[k].as_int = blockmv.as_int;
mvs[k].as_int[0] = blockmv.as_int[0];

}

Expand Down Expand Up @@ -427,16 +427,16 @@ function read_mb_modes_mv(pbi, mi, this_off, bool, bounds) {
var cntx_off = 0;

/* Zero accumulators */
nmv[0].as_int = nmv[1].as_int = nmv[2].as_int = 0;
nmv[0].as_int[0] = nmv[1].as_int[0] = nmv[2].as_int[0] = 0;
cnt[0] = cnt[1] = cnt[2] = cnt[3] = 0;



var aboveleft_ = mi[aboveleft_off];
/* Process above */
if (above.mbmi.ref_frame !== INTRA_FRAME) {
if (above.mbmi.mv.as_int) {
nmv[++mv_off].as_int = above.mbmi.mv.as_int;
if (above.mbmi.mv.as_int[0]) {
nmv[++mv_off].as_int[0] = above.mbmi.mv.as_int[0];
mv_bias(above, sign_bias, this_.mbmi.ref_frame, nmv[mv_off]);
++cntx_off;

Expand All @@ -446,14 +446,14 @@ function read_mb_modes_mv(pbi, mi, this_off, bool, bounds) {

/* Process left */
if (left_.mbmi.ref_frame !== INTRA_FRAME) {
if (left_.mbmi.mv.as_int) {
if (left_.mbmi.mv.as_int[0]) {
var this_mv = this_mv_tmp;

this_mv.as_int = left_.mbmi.mv.as_int;
this_mv.as_int[0] = left_.mbmi.mv.as_int[0];
mv_bias(left_, sign_bias, this_.mbmi.ref_frame, this_mv);

if (this_mv.as_int !== nmv[mv_off].as_int) {
nmv[++mv_off].as_int = this_mv.as_int;
if (this_mv.as_int[0] !== nmv[mv_off].as_int[0]) {
nmv[++mv_off].as_int[0] = this_mv.as_int[0];
++cntx_off;
}
cntx[cntx_off] += 2;
Expand All @@ -464,15 +464,15 @@ function read_mb_modes_mv(pbi, mi, this_off, bool, bounds) {
/* Process above left */
if (aboveleft_.mbmi.ref_frame !== INTRA_FRAME) {

if (aboveleft_.mbmi.mv.as_int) {
if (aboveleft_.mbmi.mv.as_int[0]) {
var this_mv = this_mv_tmp;

this_mv.as_int = aboveleft_.mbmi.mv.as_int;
this_mv.as_int[0] = aboveleft_.mbmi.mv.as_int[0];
mv_bias(aboveleft_, sign_bias, this_.mbmi.ref_frame,
this_mv);

if (this_mv.as_int !== nmv[mv_off].as_int) {
nmv[(++mv_off)].as_int = this_mv.as_int;
if (this_mv.as_int[0] !== nmv[mv_off].as_int[0]) {
nmv[(++mv_off)].as_int[0] = this_mv.as_int[0];
++cntx_off;
}

Expand All @@ -484,7 +484,7 @@ function read_mb_modes_mv(pbi, mi, this_off, bool, bounds) {
/* If we have three distinct MV's ... */
if (cnt[CNT_SPLITMV]) {
/* See if above-left MV can be merged with NEAREST */
if (nmv[mv_off].as_int === near_mvs[CNT_NEAREST].as_int)//.raw
if (nmv[mv_off].as_int[0] === near_mvs[CNT_NEAREST].as_int[0])//.raw
cnt[CNT_NEAREST] += 1;
}

Expand All @@ -498,17 +498,17 @@ function read_mb_modes_mv(pbi, mi, this_off, bool, bounds) {
tmp = cnt[CNT_NEAREST];
cnt[CNT_NEAREST] = cnt[CNT_NEAR];
cnt[CNT_NEAR] = tmp;
tmp = near_mvs[CNT_NEAREST].as_int;
near_mvs[CNT_NEAREST].as_int = near_mvs[CNT_NEAR].as_int;
near_mvs[CNT_NEAR].as_int = tmp;
tmp = near_mvs[CNT_NEAREST].as_int[0];
near_mvs[CNT_NEAREST].as_int[0] = near_mvs[CNT_NEAR].as_int[0];
near_mvs[CNT_NEAR].as_int[0] = tmp;
}

var near_index;
/* Use near_mvs[CNT_BEST] to store the "best" MV. Note that this
* storage shares the same address as near_mvs[CNT_ZEROZERO].
*/
if (cnt[CNT_NEAREST] >= cnt[CNT_BEST]) {
near_mvs[CNT_BEST].as_int = near_mvs[CNT_NEAREST].as_int;
near_mvs[CNT_BEST].as_int[0] = near_mvs[CNT_NEAREST].as_int[0];
//near_mvs[CNT_BEST].y = near_mvs[CNT_NEAREST].y;
}

Expand Down Expand Up @@ -536,10 +536,10 @@ function read_mb_modes_mv(pbi, mi, this_off, bool, bounds) {


//Reset, dont redeclare
chroma_mv[0].as_int = 0;
chroma_mv[1].as_int = 0;
chroma_mv[2].as_int = 0;
chroma_mv[3].as_int = 0;
chroma_mv[0].as_int[0] = 0;
chroma_mv[1].as_int[0] = 0;
chroma_mv[2].as_int[0] = 0;
chroma_mv[3].as_int[0] = 0;


//clamped_best_mv = clamp_mv(near_mvs[BEST], bounds);
Expand All @@ -549,7 +549,7 @@ function read_mb_modes_mv(pbi, mi, this_off, bool, bounds) {


decode_split_mv(this_, left_, above, hdr, clamped_best_mv, bool);//&clamped_best_mv
this_.mbmi.mv.as_int = this_.bmi.mvs[15].as_int;
this_.mbmi.mv.as_int[0] = this_.bmi.mvs[15].as_int[0];

var this_mvs = this_.bmi.mvs;
for (b = 0; b < 16; b++) {
Expand Down Expand Up @@ -595,20 +595,20 @@ function read_mb_modes_mv(pbi, mi, this_off, bool, bounds) {
}
} else {
//nearmv
this_.mbmi.mv.as_int = near_mvs[NEAR].as_int;
this_.mbmi.mv.as_int[0] = near_mvs[NEAR].as_int[0];
vp8_clamp_mv2(this_.mbmi.mv, bounds);
this_.mbmi.y_mode = NEARMV;
}
} else {
this_.mbmi.y_mode = NEARESTMV;
this_.mbmi.mv.as_int = near_mvs[NEAREST].as_int;
this_.mbmi.mv.as_int[0] = near_mvs[NEAREST].as_int[0];
vp8_clamp_mv2(this_.mbmi.mv, bounds);


}
} else {
this_.mbmi.y_mode = ZEROMV;
this_.mbmi.mv.as_int = 0;
this_.mbmi.mv.as_int[0] = 0;
}


Expand Down

0 comments on commit d8ea8f3

Please sign in to comment.