📄 block.c
字号:
top_u = &topcacheu[CACHE_SIZE];
top_v = &topcachev[CACHE_SIZE];
left_u = &leftcacheu[CACHE_SIZE];
left_v = &leftcachev[CACHE_SIZE];
if (mode == Intra_8x8_DC)
{
if ((t->mb.mb_neighbour & (MB_LEFT | MB_TOP)) == (MB_LEFT | MB_TOP))
{
mode = Intra_8x8_DC;
p_u = t->mb.src_u - t->edged_stride_uv;
p_v = t->mb.src_v - t->edged_stride_uv;
for(i = 0 ; i < 8 ; i ++)
{
top_u[i] = p_u[i];
top_v[i] = p_v[i];
}
p_u = t->mb.src_u - 1;
p_v = t->mb.src_v - 1;
for(i = 0 ; i < 8 ; i ++)
{
left_u[i] = p_u[0];
left_v[i] = p_v[0];
p_u += t->edged_stride_uv;
p_v += t->edged_stride_uv;
}
}
else if(t->mb.mb_neighbour & MB_LEFT)
{
mode = Intra_8x8_DCLEFT;
p_u = t->mb.src_u - 1;
p_v = t->mb.src_v - 1;
for(i = 0 ; i < 8 ; i ++)
{
left_u[i] = p_u[0];
left_v[i] = p_v[0];
p_u += t->edged_stride_uv;
p_v += t->edged_stride_uv;
}
}
else if(t->mb.mb_neighbour & MB_TOP)
{
mode = Intra_8x8_DCTOP;
p_u = t->mb.src_u - t->edged_stride_uv;
p_v = t->mb.src_v - t->edged_stride_uv;
for(i = 0 ; i < 8 ; i ++)
{
top_u[i] = p_u[i];
top_v[i] = p_v[i];
}
}
else
{
mode = Intra_8x8_DC128;
}
}
else
{
switch(mode)
{
case Intra_8x8_TOP:
p_u = t->mb.src_u - t->edged_stride_uv;
p_v = t->mb.src_v - t->edged_stride_uv;
for(i = 0 ; i < 8 ; i ++)
{
top_u[i] = p_u[i];
top_v[i] = p_v[i];
}
break;
case Intra_8x8_LEFT:
p_u = t->mb.src_u - 1;
p_v = t->mb.src_v - 1;
for(i = 0 ; i < 8 ; i ++)
{
left_u[i] = p_u[0];
left_v[i] = p_v[0];
p_u += t->edged_stride_uv;
p_v += t->edged_stride_uv;
}
break;
case Intra_8x8_PLANE:
p_u = t->mb.src_u - t->edged_stride_uv;
p_v = t->mb.src_v - t->edged_stride_uv;
for(i = -1 ; i < 8 ; i ++)
{
top_u[i] = p_u[i];
top_v[i] = p_v[i];
}
p_u -= 1;
p_v -= 1;
for(i = -1 ; i < 8 ; i ++)
{
left_u[i] = p_u[0];
p_u += t->edged_stride_uv;
left_v[i] = p_v[0];
p_v += t->edged_stride_uv;
}
break;
default:
assert(0);
break;
}
}
t->pred8x8[mode](pred_u, 8, top_u, left_u);
t->pred8x8[mode](pred_v, 8, top_v, left_v);
}
static void __inline
T264dec_mb_decode_i16x16_y(T264_t* t)
{
DECLARE_ALIGNED_MATRIX(dct, 1+16, 16, int16_t, CACHE_SIZE);
int32_t qp = t->qp_y;
int32_t i;
int16_t* curdct;
uint8_t* src;
src = t->mb.src_y;
T264dec_mb_decode_predict_i16x16_y(t, t->mb.mode_i16x16, t->mb.pred_i16x16, src);
unscan_zig_4x4( t->mb.dc4x4_z, dct + 256 );
t->iquant4x4dc(dct + 256, qp);
t->idct4x4dc(dct + 256);
curdct = dct;
for( i = 0; i < 16; i++ )
{
unscan_zig_4x4( t->mb.dct_y_z[luma_index[i]], curdct );
t->iquant4x4( curdct, qp );
curdct[0] = dct[256 + i];
t->idct4x4(curdct);
curdct += 16;
}
t->contract16to8add(dct, 16 / 4, 16 / 4, t->mb.pred_i16x16, src, t->edged_stride);
}
static void __inline
T264dec_mb_decode_i4x4_y(T264_t* t)
{
DECLARE_ALIGNED_MATRIX(pred, 4, 5, uint8_t, CACHE_SIZE);
DECLARE_ALIGNED_MATRIX(dct, 1, 16, int16_t, 16);
int32_t qp = t->qp_y;
int32_t i;
uint8_t* src;
for(i = 0 ; i < 16 ; i ++)
{
int32_t row = i / 4;
int32_t col = i % 4;
src = t->mb.src_y + (row * t->edged_stride << 2) + (col << 2);
T264dec_mb_decode_predict_i4x4_y(t, i, t->mb.mode_i4x4[luma_index[i]], pred, src);
unscan_zig_4x4(t->mb.dct_y_z[luma_index[i]], dct);
t->iquant4x4(dct, qp);
t->idct4x4(dct);
t->contract16to8add(dct, 4 / 4, 4 / 4, pred, src, t->edged_stride);
}
}
void
T264dec_mb_decode_intra_y(T264_t* t)
{
if (t->mb.mb_mode == I_4x4)
T264dec_mb_decode_i4x4_y(t);
else
T264dec_mb_decode_i16x16_y(t);
}
void
T264dec_mb_decode_uv(T264_t* t, uint8_t* pred_u, uint8_t* pred_v)
{
DECLARE_ALIGNED_MATRIX(dct, 10, 8, int16_t, CACHE_SIZE);
int32_t qp = t->qp_uv;
int32_t i, j;
int16_t* curdct;
uint8_t* start;
uint8_t* src;
start = pred_u;
src = t->mb.src_u;
for(j = 0 ; j < 2 ; j ++)
{
unscan_zig_2x2(t->mb.dc2x2_z[j], dct + 64);
t->iquant2x2dc(dct + 64, qp);
t->idct2x2dc(dct + 64);
curdct = dct;
for(i = 0 ; i < 4 ; i ++)
{
unscan_zig_4x4(t->mb.dct_uv_z[j][i], curdct);
t->iquant4x4(curdct, qp);
curdct[0] = dct[64 + i];
t->idct4x4(curdct);
curdct += 16;
}
t->contract16to8add(dct, 8 / 4, 8 / 4, start, src, t->edged_stride_uv);
//
// change to v
//
start = pred_v;
src = t->mb.src_v;
}
}
void
T264dec_mb_decode_intra_uv(T264_t* t)
{
T264dec_mb_decode_predict_i8x8_y(t, t->mb.mb_mode_uv, t->mb.pred_i8x8u, t->mb.pred_i8x8v);
T264dec_mb_decode_uv(t, t->mb.pred_i8x8u, t->mb.pred_i8x8v);
}
void
T264dec_mb_decode_interp_mc(T264_t* t, uint8_t* ref)
{
T264_vector_t vec;
uint8_t* tmp;
int32_t x, y;
int32_t i;
int32_t list_index = 0;
static const int8_t index[4][4][6] =
{
{{0, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0}, {1, 1, 0, 0, 0, 0}, {1, 0, 0, 0, 1, 0}},
{{0, 2, 0, 0, 0, 0}, {1, 2, 0, 0, 0, 0}, {1, 3, 0, 0, 0, 0}, {1, 2, 0, 0, 1, 0}},
{{2, 2, 0, 0, 0, 0}, {2, 3, 0, 0, 0, 0}, {3, 3, 0, 0, 0, 0}, {3, 2, 0, 0, 1, 0}},
{{2, 0, 0, 0, 0, 1}, {2, 1, 0, 0, 0, 1}, {3, 1, 0, 0, 0, 1}, {1, 2, 0, 1, 1, 0}}
};
switch(t->mb.mb_part)
{
case MB_16x16:
vec = t->mb.vec[0][0];
x = (vec.x & 3);
y = (vec.y & 3);
if (index[y][x][0] == index[y][x][1])
{
tmp = t->ref[list_index][vec.refno]->Y[index[y][x][0]] + ((t->mb.mb_y << 4) + (vec.y >> 2)) * t->edged_stride +
((t->mb.mb_x << 4) + (vec.x >> 2));
t->memcpy_stride_u(tmp, 16, 16, t->edged_stride, ref, 16);
}
else
{
t->pia[MB_16x16](t->ref[list_index][vec.refno]->Y[index[y][x][0]] + ((t->mb.mb_y << 4) + (vec.y >> 2) + index[y][x][3]) * t->edged_stride + (t->mb.mb_x << 4) + (vec.x >> 2) + index[y][x][2],
t->ref[list_index][vec.refno]->Y[index[y][x][1]] + ((t->mb.mb_y << 4) + (vec.y >> 2) + index[y][x][5]) * t->edged_stride + (t->mb.mb_x << 4) + (vec.x >> 2) + index[y][x][4],
t->edged_stride, t->edged_stride, ref, 16);
}
break;
case MB_16x8:
vec = t->mb.vec[0][0];
x = (vec.x & 3);
y = (vec.y & 3);
if (index[y][x][0] == index[y][x][1])
{
tmp = t->ref[list_index][vec.refno]->Y[index[y][x][0]] + ((t->mb.mb_y << 4) + (vec.y >> 2)) * t->edged_stride +
((t->mb.mb_x << 4) + (vec.x >> 2));
t->memcpy_stride_u(tmp, 16, 8, t->edged_stride, ref, 16);
}
else
{
t->pia[MB_16x8](t->ref[list_index][vec.refno]->Y[index[y][x][0]] + ((t->mb.mb_y << 4) + (vec.y >> 2) + index[y][x][3]) * t->edged_stride + (t->mb.mb_x << 4) + (vec.x >> 2) + index[y][x][2],
t->ref[list_index][vec.refno]->Y[index[y][x][1]] + ((t->mb.mb_y << 4) + (vec.y >> 2) + index[y][x][5]) * t->edged_stride + (t->mb.mb_x << 4) + (vec.x >> 2) + index[y][x][4],
t->edged_stride, t->edged_stride, ref, 16);
}
vec = t->mb.vec[0][8];
x = (vec.x & 3);
y = (vec.y & 3);
if (index[y][x][0] == index[y][x][1])
{
tmp = t->ref[list_index][vec.refno]->Y[index[y][x][0]] + ((t->mb.mb_y << 4) + (vec.y >> 2) + 8) * t->edged_stride +
((t->mb.mb_x << 4) + (vec.x >> 2));
t->memcpy_stride_u(tmp, 16, 8, t->edged_stride, ref + 16 * 8, 16);
}
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -