1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
use super::def::*;
use super::plane::*;
use super::region::*;
use super::tracer::*;
use super::util::*;
fn evc_recon_plane_region(
tracer: &mut Option<Tracer>,
coef: &[i16],
pred: &[pel],
is_coef: bool,
x: usize,
y: usize,
cuw: usize,
cuh: usize,
rec: &mut PlaneRegionMut<'_, pel>,
ch_type: usize,
) {
if !is_coef {
/* just copy pred to rec */
for j in 0..cuh {
for i in 0..cuw {
rec[y + j][x + i] = EVC_CLIP3(0, (1 << BIT_DEPTH) - 1, pred[j * cuw + i]);
}
}
//#if SIMD_CLIP
// clip_simd(rec, s_rec, rec, s_rec, cuw, cuh, adapt_clip_min[adapt_clip_comp], adapt_clip_max[adapt_clip_comp]);
//#endif
} else
/* add b/w pred and coef and copy it into rec */
{
for j in 0..cuh {
for i in 0..cuw {
let t0 = coef[j * cuw + i] as i32 + pred[j * cuw + i] as i32;
rec[y + j][x + i] = EVC_CLIP3(0i32, ((1 << BIT_DEPTH) - 1) as i32, t0) as u16;
}
}
//#if SIMD_CLIP
// clip_simd(rec, s_rec, rec, s_rec, cuw, cuh, adapt_clip_min[adapt_clip_comp], adapt_clip_max[adapt_clip_comp]);
//#endif
}
TRACE_RECO_PLANE_REGION(tracer, ch_type, x, y, cuw, cuh, rec);
}
pub(crate) fn evc_recon(
tracer: &mut Option<Tracer>,
coef: &[i16],
pred: &[pel],
is_coef: bool,
cuw: usize,
cuh: usize,
rec: &mut [pel],
ch_type: usize,
) {
if !is_coef {
/* just copy pred to rec */
for j in 0..cuh {
for i in 0..cuw {
rec[j * cuw + i] = EVC_CLIP3(0, (1 << BIT_DEPTH) - 1, pred[j * cuw + i]);
}
}
//#if SIMD_CLIP
// clip_simd(rec, s_rec, rec, s_rec, cuw, cuh, adapt_clip_min[adapt_clip_comp], adapt_clip_max[adapt_clip_comp]);
//#endif
} else
/* add b/w pred and coef and copy it into rec */
{
for j in 0..cuh {
for i in 0..cuw {
let t0 = coef[j * cuw + i] as i32 + pred[j * cuw + i] as i32;
rec[j * cuw + i] = EVC_CLIP3(0i32, ((1 << BIT_DEPTH) - 1) as i32, t0) as u16;
}
}
//#if SIMD_CLIP
// clip_simd(rec, s_rec, rec, s_rec, cuw, cuh, adapt_clip_min[adapt_clip_comp], adapt_clip_max[adapt_clip_comp]);
//#endif
}
TRACE_RECO(tracer, ch_type, cuw, cuh, rec);
}
pub(crate) fn evc_recon_yuv(
tracer: &mut Option<Tracer>,
mut x: usize,
mut y: usize,
mut cuw: usize,
mut cuh: usize,
coef: &Vec<Vec<i16>>, //[[i16; MAX_CU_DIM]; N_C],
pred: &Vec<Vec<pel>>, //[[pel; MAX_CU_DIM]; N_C],
nnz: &[bool; N_C],
planes: &mut [Plane<pel>; N_C],
tree_cons: &TREE_CONS,
) {
if evc_check_luma(tree_cons) {
/* Y */
let rec = &mut planes[Y_C].as_region_mut();
evc_recon_plane_region(
tracer, &coef[Y_C], &pred[Y_C], nnz[Y_C], x, y, cuw, cuh, rec, Y_C,
);
}
if evc_check_chroma(tree_cons) {
/* chroma */
x >>= 1;
y >>= 1;
cuw >>= 1;
cuh >>= 1;
{
let rec = &mut planes[U_C].as_region_mut();
evc_recon_plane_region(
tracer, &coef[U_C], &pred[U_C], nnz[U_C], x, y, cuw, cuh, rec, U_C,
);
}
{
let rec = &mut planes[V_C].as_region_mut();
evc_recon_plane_region(
tracer, &coef[V_C], &pred[V_C], nnz[V_C], x, y, cuw, cuh, rec, V_C,
);
}
}
}