hc
2023-05-26 a23f51ed7a39e452c1037343a84d7db1ca2c5bd7
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*
 * Copyright 2020 Rockchip Electronics Co. LTD
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 
#ifndef __IEP2_H__
#define __IEP2_H__
 
#include <stdint.h>
 
#include "rk_type.h"
 
#include "iep2_pd.h"
#include "iep2_ff.h"
 
#define TILE_W                  16
#define TILE_H                  4
#define MVL                     28
#define MVR                     27
 
#define TEST_DBG                //printf
#define FLOOR(v, r)             (((v) / (r)) * (r))
 
#define RKCLIP(a, min, max)     ((a < min) ? (min) : ((a > max) ? max : a))
#define RKABS(a)                (RK_U32)(((a) >= 0) ? (a) : -(a))
#define RKMIN(a, b)             (((a) < (b)) ? (a) : (b))
#define RKMAX(a, b)             (((a) > (b)) ? (a) : (b))
 
struct iep2_addr {
    uint32_t y;
    uint32_t cbcr;
    uint32_t cr;
};
 
struct iep2_params {
    uint32_t src_fmt;
    uint32_t src_yuv_swap;
    uint32_t dst_fmt;
    uint32_t dst_yuv_swap;
    uint32_t tile_cols;
    uint32_t tile_rows;
    uint32_t src_y_stride;
    uint32_t src_uv_stride;
    uint32_t dst_y_stride;
 
    struct iep2_addr src[3]; // current, next, previous
    struct iep2_addr dst[2]; // top/bottom field reconstructed frame
    uint32_t mv_addr;
    uint32_t md_addr;
 
    uint32_t dil_mode;
    uint32_t dil_out_mode;
    uint32_t dil_field_order;
 
    uint32_t md_theta;
    uint32_t md_r;
    uint32_t md_lambda;
 
    uint32_t dect_resi_thr;
    uint32_t osd_area_num;
    uint32_t osd_gradh_thr;
    uint32_t osd_gradv_thr;
 
    uint32_t osd_pos_limit_en;
    uint32_t osd_pos_limit_num;
 
    uint32_t osd_limit_area[2];
 
    uint32_t osd_line_num;
    uint32_t osd_pec_thr;
 
    uint32_t osd_x_sta[8];
    uint32_t osd_x_end[8];
    uint32_t osd_y_sta[8];
    uint32_t osd_y_end[8];
 
    uint32_t me_pena;
    uint32_t mv_bonus;
    uint32_t mv_similar_thr;
    uint32_t mv_similar_num_thr0;
    int32_t me_thr_offset;
 
    uint32_t mv_left_limit;
    uint32_t mv_right_limit;
 
    int8_t mv_tru_list[8];
    uint32_t mv_tru_vld[8];
 
    uint32_t eedi_thr0;
 
    uint32_t ble_backtoma_num;
 
    uint32_t comb_cnt_thr;
    uint32_t comb_feature_thr;
    uint32_t comb_t_thr;
    uint32_t comb_osd_vld[8];
 
    uint32_t mtn_en;
    uint32_t mtn_tab[16];
 
    uint32_t pd_mode;
 
    uint32_t roi_en;
    uint32_t roi_layer_num;
    uint32_t roi_mode[8];
    uint32_t xsta[8];
    uint32_t xend[8];
    uint32_t ysta[8];
    uint32_t yend[8];
};
 
struct iep2_output {
    uint32_t mv_hist[MVL + MVR + 1];
    uint32_t dect_pd_tcnt;
    uint32_t dect_pd_bcnt;
    uint32_t dect_ff_cur_tcnt;
    uint32_t dect_ff_cur_bcnt;
    uint32_t dect_ff_nxt_tcnt;
    uint32_t dect_ff_nxt_bcnt;
    uint32_t dect_ff_ble_tcnt;
    uint32_t dect_ff_ble_bcnt;
    uint32_t dect_ff_nz;
    uint32_t dect_ff_comb_f;
    uint32_t dect_osd_cnt;
    uint32_t out_comb_cnt;
    uint32_t out_osd_comb_cnt;
    uint32_t ff_gradt_tcnt;
    uint32_t ff_gradt_bcnt;
    uint32_t x_sta[8];
    uint32_t x_end[8];
    uint32_t y_sta[8];
    uint32_t y_end[8];
};
 
struct iep2_api_ctx {
    struct iep2_params params;
    struct iep2_output output;
    struct iep2_ff_info ff_inf;
    struct iep2_pd_info pd_inf;
 
    MppBufferGroup memGroup;
    MppBuffer mv_buf;
    MppBuffer md_buf;
    int fd;
};
 
#endif