Skip to content

Commit bc66787

Browse files
committed
replace revcd pred with aligned array
1 parent 6687f24 commit bc66787

File tree

4 files changed

+188
-17
lines changed

4 files changed

+188
-17
lines changed

src/dec/eco.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,8 @@ pub(crate) fn evcd_eco_unit(
11061106
EVC_TRACE(&mut bs.tracer, core.mv[REFP_1][MV_Y]);
11071107
EVC_TRACE(&mut bs.tracer, " )\n");
11081108

1109-
evc_mc(
1109+
let (pred0, pred1) = core.pred.split_at_mut(1);
1110+
evc_mc2(
11101111
x as i16,
11111112
y as i16,
11121113
w as i16,
@@ -1116,7 +1117,8 @@ pub(crate) fn evcd_eco_unit(
11161117
&core.refi,
11171118
&core.mv,
11181119
refp,
1119-
&mut core.pred,
1120+
&mut pred0[0].data,
1121+
&mut pred1[0].data,
11201122
);
11211123
} else {
11221124
let avail_cu = evc_get_avail_intra(
@@ -1156,7 +1158,7 @@ pub(crate) fn evcd_eco_unit(
11561158
&core.nb.data[tbl_nb_siz_offset[Y_C]..tbl_nb_siz_offset[Y_C] + (cuh << 1) as usize],
11571159
core.nb.data[tbl_nb_siz_offset[Y_C] + (cuh << 1) as usize],
11581160
&core.nb.data[tbl_nb_siz_offset[Y_C] + (cuh << 1) as usize + 1..],
1159-
&mut core.pred[0].data[Y_C],
1161+
&mut core.pred[0].data[tbl_cu_dim_offset[Y_C]..],
11601162
core.ipm[0],
11611163
cuw as usize,
11621164
cuh as usize,
@@ -1166,7 +1168,7 @@ pub(crate) fn evcd_eco_unit(
11661168
&core.nb.data[tbl_nb_siz_offset[U_C]..tbl_nb_siz_offset[U_C] + cuh as usize],
11671169
core.nb.data[tbl_nb_siz_offset[U_C] + cuh as usize],
11681170
&core.nb.data[tbl_nb_siz_offset[U_C] + cuh as usize + 1..],
1169-
&mut core.pred[0].data[U_C],
1171+
&mut core.pred[0].data[tbl_cu_dim_offset[U_C]..],
11701172
core.ipm[1],
11711173
cuw as usize >> 1,
11721174
cuh as usize >> 1,
@@ -1175,7 +1177,7 @@ pub(crate) fn evcd_eco_unit(
11751177
&core.nb.data[tbl_nb_siz_offset[V_C]..tbl_nb_siz_offset[V_C] + cuh as usize],
11761178
core.nb.data[tbl_nb_siz_offset[V_C] + cuh as usize],
11771179
&core.nb.data[tbl_nb_siz_offset[V_C] + cuh as usize + 1..],
1178-
&mut core.pred[0].data[V_C],
1180+
&mut core.pred[0].data[tbl_cu_dim_offset[V_C]..],
11791181
core.ipm[1],
11801182
cuw as usize >> 1,
11811183
cuh as usize >> 1,
@@ -1187,21 +1189,21 @@ pub(crate) fn evcd_eco_unit(
11871189
Y_C,
11881190
cuw as usize,
11891191
cuh as usize,
1190-
&core.pred[0].data[Y_C],
1192+
&core.pred[0].data[tbl_cu_dim_offset[Y_C]..],
11911193
);
11921194
TRACE_PRED(
11931195
&mut bs.tracer,
11941196
U_C,
11951197
cuw as usize >> 1,
11961198
cuh as usize >> 1,
1197-
&core.pred[0].data[U_C],
1199+
&core.pred[0].data[tbl_cu_dim_offset[U_C]..],
11981200
);
11991201
TRACE_PRED(
12001202
&mut bs.tracer,
12011203
V_C,
12021204
cuw as usize >> 1,
12031205
cuh as usize >> 1,
1204-
&core.pred[0].data[V_C],
1206+
&core.pred[0].data[tbl_cu_dim_offset[V_C]..],
12051207
);
12061208

12071209
/* reconstruction */

src/dec/mod.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,9 @@ pub(crate) struct EvcdCore {
3939
/* coefficient buffer of current CU */
4040
coef: Aligned<[i16; MAX_CU_DIM + (MAX_CU_DIM >> 1)]>, //[N_C][MAX_CU_DIM]
4141
/* pred buffer of current CU: [1] is used for bi-pred. */
42-
//pred: [Aligned<[pel; MAX_CU_DIM + (MAX_CU_DIM >> 1)]>; 2], //[2][N_C][MAX_CU_DIM]
42+
pred: [Aligned<[pel; MAX_CU_DIM + (MAX_CU_DIM >> 1)]>; 2], //[2][N_C][MAX_CU_DIM]
4343
/* neighbor pixel buffer for intra prediction: left*2 + top_left + top*2 */
4444
nb: Aligned<[pel; (MAX_CU_SIZE << 3) + 3 + 1]>, // [N_C][MAX_CU_SIZE*4+1];
45-
pred: [CUBuffer<pel>; 2], //[2][N_C][MAX_CU_DIM]
46-
//nb: NBBuffer<pel>, // [N_C][MAX_CU_SIZE*4+1];
4745

4846
/* prediction mode of current CU: INTRA, INTER, ... */
4947
pred_mode: PredMode,
@@ -82,8 +80,8 @@ impl EvcdCore {
8280
fn new() -> Self {
8381
EvcdCore {
8482
coef: Aligned::uninitialized(),
85-
pred: [CUBuffer::default(), CUBuffer::default()], //[Aligned::uninitialized(); 2],
86-
nb: Aligned::uninitialized(), //NBBuffer::default(), //
83+
pred: [Aligned::uninitialized(), Aligned::uninitialized()],
84+
nb: Aligned::uninitialized(),
8785
pred_mode: PredMode::default(),
8886
ipm: [IntraPredDir::default(); 2],
8987
inter_dir: InterPredDir::default(),

src/mc.rs

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use super::def::*;
22
use super::picman::*;
33
use super::plane::*;
44
use super::region::*;
5+
use super::tbl::*;
56
use super::util::*;
67
use crate::api::frame::Aligned;
78

@@ -547,3 +548,173 @@ pub(crate) fn evc_mc(
547548
}
548549
}
549550
}
551+
552+
pub(crate) fn evc_mc2(
553+
x: i16,
554+
y: i16,
555+
pic_w: i16,
556+
pic_h: i16,
557+
cuw: i16,
558+
cuh: i16,
559+
refi: &[i8],
560+
mv: &[[i16; MV_D]; REFP_NUM],
561+
refp: &Vec<Vec<EvcRefP>>,
562+
pred0: &mut [pel],
563+
pred1: &mut [pel],
564+
) {
565+
let mut bidx = 0;
566+
let mut mv_t = [[0i16; MV_D]; REFP_NUM];
567+
568+
//store it to pass it to interpolation function for deriving correct interpolation filter
569+
let mv_before_clipping = [
570+
[mv[REFP_0][MV_X], mv[REFP_0][MV_Y]],
571+
[mv[REFP_1][MV_X], mv[REFP_1][MV_Y]],
572+
];
573+
574+
mv_clip(x, y, pic_w, pic_h, cuw, cuh, refi, mv, &mut mv_t);
575+
576+
if REFI_IS_VALID(refi[REFP_0]) {
577+
/* forward */
578+
if let Some(ref_pic) = &refp[refi[REFP_0] as usize][REFP_0].pic {
579+
let qpel_gmv_x = (x << 2) + mv_t[REFP_0][MV_X];
580+
let qpel_gmv_y = (y << 2) + mv_t[REFP_0][MV_Y];
581+
let pic = ref_pic.borrow();
582+
let planes = &pic.frame.borrow().planes;
583+
584+
evc_mc_l(
585+
mv_before_clipping[REFP_0][MV_X],
586+
mv_before_clipping[REFP_0][MV_Y],
587+
&planes[Y_C],
588+
qpel_gmv_x,
589+
qpel_gmv_y,
590+
&mut pred0[tbl_cu_dim_offset[Y_C]..],
591+
cuw,
592+
cuh,
593+
);
594+
evc_mc_c(
595+
mv_before_clipping[REFP_0][MV_X],
596+
mv_before_clipping[REFP_0][MV_Y],
597+
&planes[U_C],
598+
qpel_gmv_x,
599+
qpel_gmv_y,
600+
&mut pred0[tbl_cu_dim_offset[U_C]..],
601+
cuw >> 1,
602+
cuh >> 1,
603+
);
604+
evc_mc_c(
605+
mv_before_clipping[REFP_0][MV_X],
606+
mv_before_clipping[REFP_0][MV_Y],
607+
&planes[V_C],
608+
qpel_gmv_x,
609+
qpel_gmv_y,
610+
&mut pred0[tbl_cu_dim_offset[V_C]..],
611+
cuw >> 1,
612+
cuh >> 1,
613+
);
614+
615+
bidx += 1;
616+
}
617+
}
618+
619+
/* check identical motion */
620+
if REFI_IS_VALID(refi[REFP_0]) && REFI_IS_VALID(refi[REFP_1]) {
621+
if let (Some(pic0), Some(pic1)) = (
622+
&refp[refi[REFP_0] as usize][REFP_0].pic,
623+
&refp[refi[REFP_1] as usize][REFP_1].pic,
624+
) {
625+
if pic0.borrow().poc == pic1.borrow().poc
626+
&& mv_t[REFP_0][MV_X] == mv_t[REFP_1][MV_X]
627+
&& mv_t[REFP_0][MV_Y] == mv_t[REFP_1][MV_Y]
628+
{
629+
return;
630+
}
631+
}
632+
}
633+
634+
if REFI_IS_VALID(refi[REFP_1]) {
635+
/* backward */
636+
if let Some(ref_pic) = &refp[refi[REFP_1] as usize][REFP_1].pic {
637+
let qpel_gmv_x = (x << 2) + mv_t[REFP_1][MV_X];
638+
let qpel_gmv_y = (y << 2) + mv_t[REFP_1][MV_Y];
639+
let pic = ref_pic.borrow();
640+
let planes = &pic.frame.borrow().planes;
641+
642+
evc_mc_l(
643+
mv_before_clipping[REFP_1][MV_X],
644+
mv_before_clipping[REFP_1][MV_Y],
645+
&planes[Y_C],
646+
qpel_gmv_x,
647+
qpel_gmv_y,
648+
if bidx == 0 {
649+
&mut pred0[tbl_cu_dim_offset[Y_C]..]
650+
} else {
651+
&mut pred1[tbl_cu_dim_offset[Y_C]..]
652+
},
653+
cuw,
654+
cuh,
655+
);
656+
evc_mc_c(
657+
mv_before_clipping[REFP_1][MV_X],
658+
mv_before_clipping[REFP_1][MV_Y],
659+
&planes[U_C],
660+
qpel_gmv_x,
661+
qpel_gmv_y,
662+
if bidx == 0 {
663+
&mut pred0[tbl_cu_dim_offset[U_C]..]
664+
} else {
665+
&mut pred1[tbl_cu_dim_offset[U_C]..]
666+
},
667+
cuw >> 1,
668+
cuh >> 1,
669+
);
670+
evc_mc_c(
671+
mv_before_clipping[REFP_1][MV_X],
672+
mv_before_clipping[REFP_1][MV_Y],
673+
&planes[V_C],
674+
qpel_gmv_x,
675+
qpel_gmv_y,
676+
if bidx == 0 {
677+
&mut pred0[tbl_cu_dim_offset[V_C]..]
678+
} else {
679+
&mut pred1[tbl_cu_dim_offset[V_C]..]
680+
},
681+
cuw >> 1,
682+
cuh >> 1,
683+
);
684+
685+
bidx += 1;
686+
}
687+
}
688+
689+
if bidx == 2 {
690+
let mut p0 = &mut pred0[tbl_cu_dim_offset[Y_C]..];
691+
let mut p1 = &pred1[tbl_cu_dim_offset[Y_C]..];
692+
for _ in 0..cuh {
693+
for x in 0..cuw as usize {
694+
p0[x] = (p0[x] + p1[x] + 1) >> 1;
695+
}
696+
p0 = &mut p0[cuw as usize..];
697+
p1 = &p1[cuw as usize..];
698+
}
699+
700+
let mut p0 = &mut pred0[tbl_cu_dim_offset[U_C]..];
701+
let mut p1 = &pred1[tbl_cu_dim_offset[U_C]..];
702+
for _ in 0..cuh >> 1 {
703+
for x in 0..cuw as usize >> 1 {
704+
p0[x] = (p0[x] + p1[x] + 1) >> 1;
705+
}
706+
p0 = &mut p0[cuw as usize >> 1..];
707+
p1 = &p1[cuw as usize >> 1..];
708+
}
709+
710+
let mut p0 = &mut pred0[tbl_cu_dim_offset[V_C]..];
711+
let mut p1 = &pred1[tbl_cu_dim_offset[V_C]..];
712+
for _ in 0..cuh >> 1 {
713+
for x in 0..cuw as usize >> 1 {
714+
p0[x] = (p0[x] + p1[x] + 1) >> 1;
715+
}
716+
p0 = &mut p0[cuw as usize >> 1..];
717+
p1 = &p1[cuw as usize >> 1..];
718+
}
719+
}
720+
}

src/recon.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub(crate) fn evc_recon_yuv(
8383
mut cuw: usize,
8484
mut cuh: usize,
8585
coef: &[i16],
86-
pred: &Vec<Vec<pel>>, //[[pel; MAX_CU_DIM]; N_C],
86+
pred: &[pel],
8787
nnz: &[bool; N_C],
8888
planes: &mut [Plane<pel>; N_C],
8989
) {
@@ -92,7 +92,7 @@ pub(crate) fn evc_recon_yuv(
9292
evc_recon_plane_region(
9393
tracer,
9494
&coef[tbl_cu_dim_offset[Y_C]..],
95-
&pred[Y_C],
95+
&pred[tbl_cu_dim_offset[Y_C]..],
9696
nnz[Y_C],
9797
x,
9898
y,
@@ -112,7 +112,7 @@ pub(crate) fn evc_recon_yuv(
112112
evc_recon_plane_region(
113113
tracer,
114114
&coef[tbl_cu_dim_offset[U_C]..],
115-
&pred[U_C],
115+
&pred[tbl_cu_dim_offset[U_C]..],
116116
nnz[U_C],
117117
x,
118118
y,
@@ -126,7 +126,7 @@ pub(crate) fn evc_recon_yuv(
126126
evc_recon_plane_region(
127127
tracer,
128128
&coef[tbl_cu_dim_offset[V_C]..],
129-
&pred[V_C],
129+
&pred[tbl_cu_dim_offset[V_C]..],
130130
nnz[V_C],
131131
x,
132132
y,

0 commit comments

Comments
 (0)