47 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
72 const int w = td->
w, h = td->
h;
73 const int xcenter = td->
xcenter;
74 const int ycenter = td->
ycenter;
75 const int start = (h * job ) / nb_jobs;
76 const int end = (h * (job+1)) / nb_jobs;
77 const int plane = td->
plane;
78 const int inlinesize = in->
linesize[plane];
79 const int outlinesize = out->
linesize[plane];
81 uint8_t *outrow = out->
data[plane] + start * outlinesize;
83 for (i = start; i <
end; i++, outrow += outlinesize) {
84 const int off_y = i - ycenter;
87 for (j = 0; j < w; j++) {
88 const int off_x = j - xcenter;
89 const int64_t radius_mult = td->
correction[j + i*w];
90 const int x = xcenter + ((radius_mult * off_x + (1<<23))>>24);
91 const int y = ycenter + ((radius_mult * off_y + (1<<23))>>24);
92 const char isvalid = x > 0 && x < w - 1 && y > 0 && y < h - 1;
93 *out++ = isvalid ? indata[y * inlinesize + x] : 0;
132 outlink->
w = rect->
width = inlink->
w;
133 outlink->
h = rect->
height = inlink->
h;
153 for (plane = 0; plane < rect->
nb_planes; ++plane) {
154 int hsub = plane == 1 || plane == 2 ? rect->
hsub : 0;
155 int vsub = plane == 1 || plane == 2 ? rect->
vsub : 0;
156 int hdiv = 1 << hsub;
157 int vdiv = 1 << vsub;
158 int w = rect->
width / hdiv;
159 int h = rect->
height / vdiv;
160 int xcenter = rect->
cx * w;
161 int ycenter = rect->
cy * h;
162 int k1 = rect->
k1 * (1<<24);
163 int k2 = rect->
k2 * (1<<24);
175 const int64_t r2inv = (4LL<<60) / (w * w + h * h);
180 for (j = 0; j < h; j++) {
181 const int off_y = j - ycenter;
182 const int off_y2 = off_y * off_y;
183 for (i = 0; i < w; i++) {
184 const int off_x = i - xcenter;
185 const int64_t r2 = ((off_x * off_x + off_y2) * r2inv + (1LL<<31)) >> 32;
186 const int64_t r4 = (r2 * r2 + (1<<27)) >> 28;
187 const int radius_mult = (r2 * k1 + r4 * k2 + (1LL<<27) + (1LL<<52))>>28;
188 rect->
correction[plane][j * w + i] = radius_mult;
220 .
name =
"lenscorrection",
224 .
inputs = lenscorrection_inputs,
225 .
outputs = lenscorrection_outputs,
226 .priv_class = &lenscorrection_class,