📄 idxgen_kc.cpp
字号:
#include "idb_kernelc.hpp"
#include "mpeg.hpp"
#include "idb_kernelc2.hpp"
KERNELDEF(idxGen, KERNELS_DIR "idxgen_kc.uc");
// *******************
// idxGen_kc : generate indices for loading source images
// *******************
kernel idxGen(ostream<uint> indices, // indices into src image
uc<int>& uc_size, // ls16bits: image width
// ms16bits: image height
uc<int>& uc_params) // ls16bits: num macroblocks
// ms16bits: edges: 0 - neither
// 1 - right
// 2 - bottom
// 3 - bottom right
{
// process parameters from uc regs
byte4 unpack = 0x88883120;
int size = commclperm(ucid(), 0, uc_size);
double<int> size2 = shuffled(size, unpack);
int width = lo(size2);
int height = hi(size2);
int parms = commclperm(ucid(), 0, uc_params);
double<int> params2 = shuffled(parms, unpack);
int cnt = lo(params2);
int type = hi(params2);
uc<int> uc_cnt;
int dummy = commclperm(ucid(), cnt, uc_cnt, 0, uc_cnt);
// calculate x values for each cluster for last mb (others are cid(), cid8)
int base_loc = 0;
int right_side = ((type == 1) | (type == 3));
int right_margin = (width & 0xf);
right_margin = select(itocc((right_margin>0) & right_side), right_margin,16);
right_margin = right_margin - 1;
int cid8 = cid() + 8;
expand<int> x(2);
x[0] = select(itocc(cid() <= right_margin), cid(), right_margin);
x[1] = select(itocc(cid8 <= right_margin), cid8, right_margin);
// calculate start value of each row
int bottom_row = ((type == 2) | (type == 3));
int bottom_margin = (height & 0xf);
bottom_margin = select(itocc((bottom_margin>0)&bottom_row),bottom_margin,16);
expand<int> y(15);
y[0] = select(itocc(1 < bottom_margin), width, 0);
y[1] = select(itocc(2 < bottom_margin), width, 0);
y[2] = select(itocc(3 < bottom_margin), width, 0);
y[3] = select(itocc(4 < bottom_margin), width, 0);
y[4] = select(itocc(5 < bottom_margin), width, 0);
y[5] = select(itocc(6 < bottom_margin), width, 0);
y[6] = select(itocc(7 < bottom_margin), width, 0);
y[7] = select(itocc(8 < bottom_margin), width, 0);
y[8] = select(itocc(9 < bottom_margin), width, 0);
y[9] = select(itocc(10 < bottom_margin), width, 0);
y[10] = select(itocc(11 < bottom_margin), width, 0);
y[11] = select(itocc(12 < bottom_margin), width, 0);
y[12] = select(itocc(13 < bottom_margin), width, 0);
y[13] = select(itocc(14 < bottom_margin), width, 0);
y[14] = select(itocc(15 < bottom_margin), width, 0);
loop_count(uc_cnt) {
// is this the last (rightmost) macroblock?
cc last_iter = itocc(cnt == 1);
int first = select(last_iter, x[0], cid());
int second = select(last_iter, x[1], cid8);
// output values
int loc = base_loc;
indices << loc + first << loc + second; loc = loc + y[0];
indices << loc + first << loc + second; loc = loc + y[1];
indices << loc + first << loc + second; loc = loc + y[2];
indices << loc + first << loc + second; loc = loc + y[3];
indices << loc + first << loc + second; loc = loc + y[4];
indices << loc + first << loc + second; loc = loc + y[5];
indices << loc + first << loc + second; loc = loc + y[6];
indices << loc + first << loc + second; loc = loc + y[7];
indices << loc + first << loc + second; loc = loc + y[8];
indices << loc + first << loc + second; loc = loc + y[9];
indices << loc + first << loc + second; loc = loc + y[10];
indices << loc + first << loc + second; loc = loc + y[11];
indices << loc + first << loc + second; loc = loc + y[12];
indices << loc + first << loc + second; loc = loc + y[13];
indices << loc + first << loc + second; loc = loc + y[14];
indices << loc + first << loc + second;
// update vars
cnt = cnt - 1;
base_loc = base_loc + 16;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -