Skip to content

Commit

Permalink
removed new keyword from motion vector creation
Browse files Browse the repository at this point in the history
  • Loading branch information
brianxautumn committed Mar 6, 2017
1 parent d8ea8f3 commit dcadb64
Show file tree
Hide file tree
Showing 8 changed files with 347 additions and 366 deletions.
242 changes: 122 additions & 120 deletions builds/jsvpx.js

Large diffs are not rendered by default.

258 changes: 130 additions & 128 deletions builds/ogv-decoder-video-vp8.js

Large diffs are not rendered by default.

18 changes: 3 additions & 15 deletions vp8/common/blockd.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class MODE_INFO {
uv_mode: 0,
ref_frame: 0,
is_4x4: 0,
mv: new MotionVector(),
mv: MotionVector.create(),
partitioning: 0,
mb_skip_coeff: 0,
need_mc_border: 0,
Expand All @@ -59,26 +59,14 @@ class MODE_INFO {

this.bmi = null;

/*
var mvs = new Array(16);
var i = 16;
while (i--)
mvs[i] = new MotionVector();
//Only needed for spit mode, maybe can skip initialization unless splitt mode is on
this.bmi =
{
mvs: mvs,
modes: new Uint8Array(16)//16,'todo:enum prediction_mode')
};
*/

}

init_split_mode() {
var mvs = new Array(16);
var i = 16;
while (i--)
mvs[i] = new MotionVector();
mvs[i] = MotionVector.create();

//Only needed for spit mode, maybe can skip initialization unless splitt mode is on
this.bmi =
Expand Down
4 changes: 2 additions & 2 deletions vp8/common/findnearmv.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ var B_HE_PRED = 3; /* horizontal prediction */
function mv_bias(mb, sign_bias, ref_frame, mv) {

if (sign_bias[mb.mbmi.ref_frame] ^ sign_bias[ref_frame]) {
mv.x *= -1;
mv.y *= -1;
mv.as_row_col[0] *= -1;
mv.as_row_col[1] *= -1;
}

}
Expand Down
32 changes: 11 additions & 21 deletions vp8/common/mv.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,18 @@
class MotionVector {

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

}
}

Object.defineProperty(MotionVector.prototype, 'x', {
get: function () {
return this.internalStruct[0];
},
set: function (x) {
this.internalStruct[0] = x;
this.as_row_col = new Int16Array(2);
this.as_int = new Uint32Array(this.as_row_col.buffer);
}
});

Object.defineProperty(MotionVector.prototype, 'y', {
get: function () {
return this.internalStruct[1];
},
set: function (y) {
this.internalStruct[1] = y;
static create(){
var as_row_col = new Int16Array(2);
var as_int = new Uint32Array(as_row_col.buffer);
return {
'as_row_col' : as_row_col,
'as_int' : as_int
};
}
});
}

module.exports = MotionVector;
68 changes: 34 additions & 34 deletions vp8/common/reconinter.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ var memcpy = c_utils.memcpy;

//Keep from having to redeclare this
var chroma_mv = [
new MotionVector(),
new MotionVector(),
new MotionVector(),
new MotionVector()
MotionVector.create(),
MotionVector.create(),
MotionVector.create(),
MotionVector.create()
];


Expand Down Expand Up @@ -152,29 +152,29 @@ function build_4x4uvmvs(mbi, full_pixel) {



temp = mvs[b].x +
mvs[b + 1].x +
mvs[b + 4].x +
mvs[b + 5].x;
temp = mvs[b].as_row_col[0] +
mvs[b + 1].as_row_col[0] +
mvs[b + 4].as_row_col[0] +
mvs[b + 5].as_row_col[0];

if (temp < 0)
temp -= 4;
else
temp += 4;

chroma_mv_cache.x = (temp / 8 ) | 0;
chroma_mv_cache.as_row_col[0] = (temp / 8 ) | 0;

temp = mvs[b].y +
mvs[b + 1].y +
mvs[b + 4].y +
mvs[b + 5].y;
temp = mvs[b].as_row_col[1] +
mvs[b + 1].as_row_col[1] +
mvs[b + 4].as_row_col[1] +
mvs[b + 5].as_row_col[1];

if (temp < 0)
temp -= 4;
else
temp += 4;

chroma_mv_cache.y = (temp / 8) | 0;
chroma_mv_cache.as_row_col[1] = (temp / 8) | 0;

if (full_pixel === 1) {
chroma_mv_cache.as_int[0] &= 0xFFF8FFF8;
Expand Down Expand Up @@ -240,7 +240,7 @@ function build_mc_border(dst, dst_off, src, src_off, stride, x, y, b_w, b_h, w,
} while (--b_h);
}

var uvmv = new MotionVector();
var uvmv = MotionVector.create();

function predict_inter(ctx, img, coeffs, coeffs_off, mbi) {
var y, u , v;
Expand Down Expand Up @@ -318,10 +318,10 @@ function recon_1_block(output, output_off, reference, reference_off, stride, mv,

if (mv.as_int[0]) {

mx = mv.x & 7;
my = mv.y & 7;
mx = mv.as_row_col[0] & 7;
my = mv.as_row_col[1] & 7;

reference_off += ((mv.y >> 3) * stride) + (mv.x >> 3);
reference_off += ((mv.as_row_col[1] >> 3) * stride) + (mv.as_row_col[0] >> 3);



Expand Down Expand Up @@ -351,20 +351,20 @@ function recon_1_edge_block(output, output_off,
var b_h = 4;
var mx = 0, my = 0;

x += mv_.x >> 3;
y += mv_.y >> 3;
x += mv_.as_row_col[0] >> 3;
y += mv_.as_row_col[1] >> 3;



if (x < 2 || x + b_w - 1 + 3 >= w || y < 2 || y + b_h - 1 + 3 >= h) {

reference_off += (mv_.x >> 3) + (mv_.y >> 3) * stride;
reference_off += (mv_.as_row_col[0] >> 3) + (mv_.as_row_col[1] >> 3) * stride;
build_mc_border(emul_block, emul_block_off,
reference, reference_off - 2 - (stride << 1), stride,
x - 2, y - 2, b_w + 5, b_h + 5, w, h);
reference = emul_block;
reference_off = emul_block_off + (stride << 1) + 2;
reference_off -= (mv_.x >> 3) + (mv_.y >> 3) * stride;
reference_off -= (mv_.as_row_col[0] >> 3) + (mv_.as_row_col[1] >> 3) * stride;

}

Expand All @@ -373,11 +373,11 @@ function recon_1_edge_block(output, output_off,

if (mv_.as_int[0]) {

mx = mv_.x & 7;
my = mv_.y & 7;
mx = mv_.as_row_col[0] & 7;
my = mv_.as_row_col[1] & 7;


reference_off += ((mv_.y >> 3) * stride) + (mv_.x >> 3);
reference_off += ((mv_.as_row_col[1] >> 3) * stride) + (mv_.as_row_col[0] >> 3);



Expand All @@ -389,7 +389,7 @@ function recon_1_edge_block(output, output_off,
predict_off = output_off;

} else {
reference_off += ((mv_.y >> 3) * stride) + (mv_.x >> 3);
reference_off += ((mv_.as_row_col[1] >> 3) * stride) + (mv_.as_row_col[0] >> 3);
predict = reference;
predict_off = reference_off;

Expand All @@ -411,16 +411,16 @@ function vp8_build_inter16x16_predictors_mb(mbi, full_pixel) {
uvmv.as_int[0] = mbmi_cache.mv.as_int[0];

if (mbi.mbmi.need_mc_border === 1) {
var x = uvmv.x;
var y = uvmv.y;
uvmv.x = (x + 1 + ((x >> 31) << 1));
uvmv.y = (y + 1 + ((y >> 31) << 1));
uvmv.x /= 2;
uvmv.y /= 2;
var x = uvmv.as_row_col[0];
var y = uvmv.as_row_col[1] ;
uvmv.as_row_col[0] = (x + 1 + ((x >> 31) << 1));
uvmv.as_row_col[1] = (y + 1 + ((y >> 31) << 1));
uvmv.as_row_col[0] /= 2;
uvmv.as_row_col[1] /= 2;

} else {
uvmv.x = (uvmv.x + 1) >> 1;
uvmv.y = (uvmv.y + 1) >> 1;
uvmv.as_row_col[0] = (uvmv.as_row_col[0] + 1) >> 1;
uvmv.as_row_col[1] = (uvmv.as_row_col[1] + 1) >> 1;
}

if (full_pixel) {
Expand Down
1 change: 0 additions & 1 deletion vp8/decoder/decodeframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ var PLANE_PACKED = VPX_PLANE_PACKED;
var PLANE_Y = VPX_PLANE_Y;
var PLANE_U = VPX_PLANE_U;
var PLANE_V = VPX_PLANE_V;
var PLANE_ALPHA = VPX_PLANE_ALPHA;

var CURRENT_FRAME = 0;
var LAST_FRAME = 1;
Expand Down
Loading

0 comments on commit dcadb64

Please sign in to comment.