FFmpeg
h2656_inter_template.c
Go to the documentation of this file.
1 /*
2  * inter prediction template for HEVC/VVC
3  *
4  * Copyright (C) 2022 Nuo Mi
5  * Copyright (C) 2024 Wu Jianhua
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #define CHROMA_EXTRA_BEFORE 1
25 #define CHROMA_EXTRA 3
26 #define LUMA_EXTRA_BEFORE 3
27 #define LUMA_EXTRA 7
28 
29 static void FUNC(put_pixels)(int16_t *dst,
30  const uint8_t *_src, const ptrdiff_t _src_stride,
31  const int height, const int8_t *hf, const int8_t *vf, const int width)
32 {
33  const pixel *src = (const pixel *)_src;
34  const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
35 
36  for (int y = 0; y < height; y++) {
37  for (int x = 0; x < width; x++)
38  dst[x] = src[x] << (14 - BIT_DEPTH);
39  src += src_stride;
40  dst += MAX_PB_SIZE;
41  }
42 }
43 
44 static void FUNC(put_uni_pixels)(uint8_t *_dst, const ptrdiff_t _dst_stride,
45  const uint8_t *_src, const ptrdiff_t _src_stride, const int height,
46  const int8_t *hf, const int8_t *vf, const int width)
47 {
48  const pixel *src = (const pixel *)_src;
49  pixel *dst = (pixel *)_dst;
50  const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
51  const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
52 
53  for (int y = 0; y < height; y++) {
54  memcpy(dst, src, width * sizeof(pixel));
55  src += src_stride;
56  dst += dst_stride;
57  }
58 }
59 
60 static void FUNC(put_uni_w_pixels)(uint8_t *_dst, const ptrdiff_t _dst_stride,
61  const uint8_t *_src, const ptrdiff_t _src_stride, const int height,
62  const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf,
63  const int width)
64 {
65  const pixel *src = (const pixel *)_src;
66  pixel *dst = (pixel *)_dst;
67  const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
68  const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
69  const int shift = denom + 14 - BIT_DEPTH;
70 #if BIT_DEPTH < 14
71  const int offset = 1 << (shift - 1);
72 #else
73  const int offset = 0;
74 #endif
75  const int ox = _ox * (1 << (BIT_DEPTH - 8));
76 
77  for (int y = 0; y < height; y++) {
78  for (int x = 0; x < width; x++) {
79  const int v = (src[x] << (14 - BIT_DEPTH));
80  dst[x] = av_clip_pixel(((v * wx + offset) >> shift) + ox);
81  }
82  src += src_stride;
83  dst += dst_stride;
84  }
85 }
86 
87 #define LUMA_FILTER(src, stride) \
88  (filter[0] * src[x - 3 * stride] + \
89  filter[1] * src[x - 2 * stride] + \
90  filter[2] * src[x - stride] + \
91  filter[3] * src[x ] + \
92  filter[4] * src[x + stride] + \
93  filter[5] * src[x + 2 * stride] + \
94  filter[6] * src[x + 3 * stride] + \
95  filter[7] * src[x + 4 * stride])
96 
97 static void FUNC(put_luma_h)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
98  const int height, const int8_t *hf, const int8_t *vf, const int width)
99 {
100  const pixel *src = (const pixel*)_src;
101  const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
102  const int8_t *filter = hf;
103 
104  for (int y = 0; y < height; y++) {
105  for (int x = 0; x < width; x++)
106  dst[x] = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
107  src += src_stride;
108  dst += MAX_PB_SIZE;
109  }
110 }
111 
112 static void FUNC(put_luma_v)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
113  const int height, const int8_t *hf, const int8_t *vf, const int width)
114 {
115  const pixel *src = (pixel*)_src;
116  const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
117  const int8_t *filter = vf;
118 
119  for (int y = 0; y < height; y++) {
120  for (int x = 0; x < width; x++)
121  dst[x] = LUMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8);
122  src += src_stride;
123  dst += MAX_PB_SIZE;
124  }
125 }
126 
127 static void FUNC(put_luma_hv)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
128  const int height, const int8_t *hf, const int8_t *vf, const int width)
129 {
130  int16_t tmp_array[(MAX_PB_SIZE + LUMA_EXTRA) * MAX_PB_SIZE];
131  int16_t *tmp = tmp_array;
132  const pixel *src = (const pixel*)_src;
133  const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
134  const int8_t *filter = hf;
135 
136  src -= LUMA_EXTRA_BEFORE * src_stride;
137  for (int y = 0; y < height + LUMA_EXTRA; y++) {
138  for (int x = 0; x < width; x++)
139  tmp[x] = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
140  src += src_stride;
141  tmp += MAX_PB_SIZE;
142  }
143 
144  tmp = tmp_array + LUMA_EXTRA_BEFORE * MAX_PB_SIZE;
145  filter = vf;
146  for (int y = 0; y < height; y++) {
147  for (int x = 0; x < width; x++)
148  dst[x] = LUMA_FILTER(tmp, MAX_PB_SIZE) >> 6;
149  tmp += MAX_PB_SIZE;
150  dst += MAX_PB_SIZE;
151  }
152 }
153 
154 static void FUNC(put_uni_luma_h)(uint8_t *_dst, const ptrdiff_t _dst_stride,
155  const uint8_t *_src, const ptrdiff_t _src_stride,
156  const int height, const int8_t *hf, const int8_t *vf, const int width)
157 {
158  const pixel *src = (const pixel*)_src;
159  pixel *dst = (pixel *)_dst;
160  const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
161  const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
162  const int8_t *filter = hf;
163  const int shift = 14 - BIT_DEPTH;
164 #if BIT_DEPTH < 14
165  const int offset = 1 << (shift - 1);
166 #else
167  const int offset = 0;
168 #endif
169 
170  for (int y = 0; y < height; y++) {
171  for (int x = 0; x < width; x++) {
172  const int val = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
173  dst[x] = av_clip_pixel((val + offset) >> shift);
174  }
175  src += src_stride;
176  dst += dst_stride;
177  }
178 }
179 
180 static void FUNC(put_uni_luma_v)(uint8_t *_dst, const ptrdiff_t _dst_stride,
181  const uint8_t *_src, const ptrdiff_t _src_stride,
182  const int height, const int8_t *hf, const int8_t *vf, const int width)
183 {
184 
185  const pixel *src = (const pixel*)_src;
186  pixel *dst = (pixel *)_dst;
187  const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
188  const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
189  const int8_t *filter = vf;
190  const int shift = 14 - BIT_DEPTH;
191 #if BIT_DEPTH < 14
192  const int offset = 1 << (shift - 1);
193 #else
194  const int offset = 0;
195 #endif
196 
197  for (int y = 0; y < height; y++) {
198  for (int x = 0; x < width; x++) {
199  const int val = LUMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8);
200  dst[x] = av_clip_pixel((val + offset) >> shift);
201  }
202  src += src_stride;
203  dst += dst_stride;
204  }
205 }
206 
207 static void FUNC(put_uni_luma_hv)(uint8_t *_dst, const ptrdiff_t _dst_stride,
208  const uint8_t *_src, const ptrdiff_t _src_stride,
209  const int height, const int8_t *hf, const int8_t *vf, const int width)
210 {
211  int16_t tmp_array[(MAX_PB_SIZE + LUMA_EXTRA) * MAX_PB_SIZE];
212  int16_t *tmp = tmp_array;
213  const pixel *src = (const pixel*)_src;
214  pixel *dst = (pixel *)_dst;
215  const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
216  const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
217  const int8_t *filter = hf;
218  const int shift = 14 - BIT_DEPTH;
219 #if BIT_DEPTH < 14
220  const int offset = 1 << (shift - 1);
221 #else
222  const int offset = 0;
223 #endif
224 
225  src -= LUMA_EXTRA_BEFORE * src_stride;
226  for (int y = 0; y < height + LUMA_EXTRA; y++) {
227  for (int x = 0; x < width; x++)
228  tmp[x] = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
229  src += src_stride;
230  tmp += MAX_PB_SIZE;
231  }
232 
233  tmp = tmp_array + LUMA_EXTRA_BEFORE * MAX_PB_SIZE;
234  filter = vf;
235 
236  for (int y = 0; y < height; y++) {
237  for (int x = 0; x < width; x++) {
238  const int val = LUMA_FILTER(tmp, MAX_PB_SIZE) >> 6;
239  dst[x] = av_clip_pixel((val + offset) >> shift);
240  }
241  tmp += MAX_PB_SIZE;
242  dst += dst_stride;
243  }
244 
245 }
246 
247 static void FUNC(put_uni_luma_w_h)(uint8_t *_dst, const ptrdiff_t _dst_stride,
248  const uint8_t *_src, const ptrdiff_t _src_stride, int height,
249  const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf,
250  const int width)
251 {
252  const pixel *src = (const pixel*)_src;
253  pixel *dst = (pixel *)_dst;
254  const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
255  const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
256  const int8_t *filter = hf;
257  const int ox = _ox * (1 << (BIT_DEPTH - 8));
258  const int shift = denom + 14 - BIT_DEPTH;
259 #if BIT_DEPTH < 14
260  const int offset = 1 << (shift - 1);
261 #else
262  const int offset = 0;
263 #endif
264 
265  for (int y = 0; y < height; y++) {
266  for (int x = 0; x < width; x++)
267  dst[x] = av_clip_pixel((((LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox);
268  src += src_stride;
269  dst += dst_stride;
270  }
271 }
272 
273 static void FUNC(put_uni_luma_w_v)(uint8_t *_dst, const ptrdiff_t _dst_stride,
274  const uint8_t *_src, const ptrdiff_t _src_stride, const int height,
275  const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf,
276  const int width)
277 {
278  const pixel *src = (const pixel*)_src;
279  pixel *dst = (pixel *)_dst;
280  const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
281  const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
282  const int8_t *filter = vf;
283  const int ox = _ox * (1 << (BIT_DEPTH - 8));
284  const int shift = denom + 14 - BIT_DEPTH;
285 #if BIT_DEPTH < 14
286  const int offset = 1 << (shift - 1);
287 #else
288  const int offset = 0;
289 #endif
290 
291  for (int y = 0; y < height; y++) {
292  for (int x = 0; x < width; x++)
293  dst[x] = av_clip_pixel((((LUMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox);
294  src += src_stride;
295  dst += dst_stride;
296  }
297 }
298 
299 static void FUNC(put_uni_luma_w_hv)(uint8_t *_dst, const ptrdiff_t _dst_stride,
300  const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int denom,
301  const int wx, const int _ox, const int8_t *hf, const int8_t *vf, const int width)
302 {
303  int16_t tmp_array[(MAX_PB_SIZE + LUMA_EXTRA) * MAX_PB_SIZE];
304  int16_t *tmp = tmp_array;
305  const pixel *src = (const pixel*)_src;
306  pixel *dst = (pixel *)_dst;
307  const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
308  const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
309  const int8_t *filter = hf;
310  const int ox = _ox * (1 << (BIT_DEPTH - 8));
311  const int shift = denom + 14 - BIT_DEPTH;
312 #if BIT_DEPTH < 14
313  const int offset = 1 << (shift - 1);
314 #else
315  const int offset = 0;
316 #endif
317 
318  src -= LUMA_EXTRA_BEFORE * src_stride;
319  for (int y = 0; y < height + LUMA_EXTRA; y++) {
320  for (int x = 0; x < width; x++)
321  tmp[x] = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
322  src += src_stride;
323  tmp += MAX_PB_SIZE;
324  }
325 
326  tmp = tmp_array + LUMA_EXTRA_BEFORE * MAX_PB_SIZE;
327  filter = vf;
328  for (int y = 0; y < height; y++) {
329  for (int x = 0; x < width; x++)
330  dst[x] = av_clip_pixel((((LUMA_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx + offset) >> shift) + ox);
331  tmp += MAX_PB_SIZE;
332  dst += dst_stride;
333  }
334 }
335 
336 #define CHROMA_FILTER(src, stride) \
337  (filter[0] * src[x - stride] + \
338  filter[1] * src[x] + \
339  filter[2] * src[x + stride] + \
340  filter[3] * src[x + 2 * stride])
341 
342 static void FUNC(put_chroma_h)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
343  const int height, const int8_t *hf, const int8_t *vf, const int width)
344 {
345  const pixel *src = (const pixel *)_src;
346  const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
347  const int8_t *filter = hf;
348 
349  for (int y = 0; y < height; y++) {
350  for (int x = 0; x < width; x++)
351  dst[x] = CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
352  src += src_stride;
353  dst += MAX_PB_SIZE;
354  }
355 }
356 
357 static void FUNC(put_chroma_v)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
358  const int height, const int8_t *hf, const int8_t *vf, const int width)
359 {
360  const pixel *src = (const pixel *)_src;
361  const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
362  const int8_t *filter = vf;
363 
364  for (int y = 0; y < height; y++) {
365  for (int x = 0; x < width; x++)
366  dst[x] = CHROMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8);
367  src += src_stride;
368  dst += MAX_PB_SIZE;
369  }
370 }
371 
372 static void FUNC(put_chroma_hv)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
373  const int height, const int8_t *hf, const int8_t *vf, const int width)
374 {
375  int16_t tmp_array[(MAX_PB_SIZE + CHROMA_EXTRA) * MAX_PB_SIZE];
376  int16_t *tmp = tmp_array;
377  const pixel *src = (const pixel *)_src;
378  const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
379  const int8_t *filter = hf;
380 
381  src -= CHROMA_EXTRA_BEFORE * src_stride;
382 
383  for (int y = 0; y < height + CHROMA_EXTRA; y++) {
384  for (int x = 0; x < width; x++)
385  tmp[x] = CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
386  src += src_stride;
387  tmp += MAX_PB_SIZE;
388  }
389 
390  tmp = tmp_array + CHROMA_EXTRA_BEFORE * MAX_PB_SIZE;
391  filter = vf;
392 
393  for (int y = 0; y < height; y++) {
394  for (int x = 0; x < width; x++)
395  dst[x] = CHROMA_FILTER(tmp, MAX_PB_SIZE) >> 6;
396  tmp += MAX_PB_SIZE;
397  dst += MAX_PB_SIZE;
398  }
399 }
400 
401 static void FUNC(put_uni_chroma_h)(uint8_t *_dst, const ptrdiff_t _dst_stride,
402  const uint8_t *_src, const ptrdiff_t _src_stride,
403  const int height, const int8_t *hf, const int8_t *vf, const int width)
404 {
405  const pixel *src = (const pixel *)_src;
406  pixel *dst = (pixel *)_dst;
407  const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
408  const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
409  const int8_t *filter = hf;
410  const int shift = 14 - BIT_DEPTH;
411 #if BIT_DEPTH < 14
412  const int offset = 1 << (shift - 1);
413 #else
414  const int offset = 0;
415 #endif
416 
417  for (int y = 0; y < height; y++) {
418  for (int x = 0; x < width; x++)
419  dst[x] = av_clip_pixel(((CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8)) + offset) >> shift);
420  src += src_stride;
421  dst += dst_stride;
422  }
423 }
424 
425 static void FUNC(put_uni_chroma_v)(uint8_t *_dst, const ptrdiff_t _dst_stride,
426  const uint8_t *_src, const ptrdiff_t _src_stride,
427  const int height, const int8_t *hf, const int8_t *vf, const int width)
428 {
429  const pixel *src = (const pixel *)_src;
430  pixel *dst = (pixel *)_dst;
431  const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
432  const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
433  const int8_t *filter = vf;
434  const int shift = 14 - BIT_DEPTH;
435 #if BIT_DEPTH < 14
436  const int offset = 1 << (shift - 1);
437 #else
438  const int offset = 0;
439 #endif
440 
441  for (int y = 0; y < height; y++) {
442  for (int x = 0; x < width; x++)
443  dst[x] = av_clip_pixel(((CHROMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8)) + offset) >> shift);
444  src += src_stride;
445  dst += dst_stride;
446  }
447 }
448 
449 static void FUNC(put_uni_chroma_hv)(uint8_t *_dst, const ptrdiff_t _dst_stride,
450  const uint8_t *_src, const ptrdiff_t _src_stride,
451  const int height, const int8_t *hf, const int8_t *vf, const int width)
452 {
453  int16_t tmp_array[(MAX_PB_SIZE + CHROMA_EXTRA) * MAX_PB_SIZE];
454  int16_t *tmp = tmp_array;
455  const pixel *src = (const pixel *)_src;
456  pixel *dst = (pixel *)_dst;
457  const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
458  const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
459  const int8_t *filter = hf;
460  const int shift = 14 - BIT_DEPTH;
461 #if BIT_DEPTH < 14
462  const int offset = 1 << (shift - 1);
463 #else
464  const int offset = 0;
465 #endif
466 
467  src -= CHROMA_EXTRA_BEFORE * src_stride;
468 
469  for (int y = 0; y < height + CHROMA_EXTRA; y++) {
470  for (int x = 0; x < width; x++)
471  tmp[x] = CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
472  src += src_stride;
473  tmp += MAX_PB_SIZE;
474  }
475 
476  tmp = tmp_array + CHROMA_EXTRA_BEFORE * MAX_PB_SIZE;
477  filter = vf;
478 
479  for (int y = 0; y < height; y++) {
480  for (int x = 0; x < width; x++)
481  dst[x] = av_clip_pixel(((CHROMA_FILTER(tmp, MAX_PB_SIZE) >> 6) + offset) >> shift);
482  tmp += MAX_PB_SIZE;
483  dst += dst_stride;
484  }
485 }
486 
487 static void FUNC(put_uni_chroma_w_h)(uint8_t *_dst, ptrdiff_t _dst_stride,
488  const uint8_t *_src, ptrdiff_t _src_stride, int height, int denom, int wx, int ox,
489  const int8_t *hf, const int8_t *vf, int width)
490 {
491  const pixel *src = (const pixel *)_src;
492  pixel *dst = (pixel *)_dst;
493  const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
494  const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
495  const int8_t *filter = hf;
496  const int shift = denom + 14 - BIT_DEPTH;
497 #if BIT_DEPTH < 14
498  const int offset = 1 << (shift - 1);
499 #else
500  const int offset = 0;
501 #endif
502 
503  ox = ox * (1 << (BIT_DEPTH - 8));
504  for (int y = 0; y < height; y++) {
505  for (int x = 0; x < width; x++) {
506  dst[x] = av_clip_pixel((((CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox);
507  }
508  dst += dst_stride;
509  src += src_stride;
510  }
511 }
512 
513 static void FUNC(put_uni_chroma_w_v)(uint8_t *_dst, const ptrdiff_t _dst_stride,
514  const uint8_t *_src, const ptrdiff_t _src_stride, const int height,
515  const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf,
516  const int width)
517 {
518  const pixel *src = (const pixel *)_src;
519  pixel *dst = (pixel *)_dst;
520  const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
521  const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
522  const int8_t *filter = vf;
523  const int shift = denom + 14 - BIT_DEPTH;
524  const int ox = _ox * (1 << (BIT_DEPTH - 8));
525 #if BIT_DEPTH < 14
526  int offset = 1 << (shift - 1);
527 #else
528  int offset = 0;
529 #endif
530 
531  for (int y = 0; y < height; y++) {
532  for (int x = 0; x < width; x++) {
533  dst[x] = av_clip_pixel((((CHROMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox);
534  }
535  dst += dst_stride;
536  src += src_stride;
537  }
538 }
539 
540 static void FUNC(put_uni_chroma_w_hv)(uint8_t *_dst, ptrdiff_t _dst_stride,
541  const uint8_t *_src, ptrdiff_t _src_stride, int height, int denom, int wx, int ox,
542  const int8_t *hf, const int8_t *vf, int width)
543 {
544  int16_t tmp_array[(MAX_PB_SIZE + CHROMA_EXTRA) * MAX_PB_SIZE];
545  int16_t *tmp = tmp_array;
546  const pixel *src = (const pixel *)_src;
547  pixel *dst = (pixel *)_dst;
548  const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
549  const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
550  const int8_t *filter = hf;
551  const int shift = denom + 14 - BIT_DEPTH;
552 #if BIT_DEPTH < 14
553  const int offset = 1 << (shift - 1);
554 #else
555  const int offset = 0;
556 #endif
557 
558  src -= CHROMA_EXTRA_BEFORE * src_stride;
559 
560  for (int y = 0; y < height + CHROMA_EXTRA; y++) {
561  for (int x = 0; x < width; x++)
562  tmp[x] = CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
563  src += src_stride;
564  tmp += MAX_PB_SIZE;
565  }
566 
567  tmp = tmp_array + CHROMA_EXTRA_BEFORE * MAX_PB_SIZE;
568  filter = vf;
569 
570  ox = ox * (1 << (BIT_DEPTH - 8));
571  for (int y = 0; y < height; y++) {
572  for (int x = 0; x < width; x++)
573  dst[x] = av_clip_pixel((((CHROMA_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx + offset) >> shift) + ox);
574  tmp += MAX_PB_SIZE;
575  dst += dst_stride;
576  }
577 }
put_uni_luma_w_v
static void FUNC() put_uni_luma_w_v(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf, const int width)
Definition: h2656_inter_template.c:273
BIT_DEPTH
#define BIT_DEPTH
Definition: aom_film_grain.c:61
put_luma_h
static void FUNC() put_luma_h(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int8_t *hf, const int8_t *vf, const int width)
Definition: h2656_inter_template.c:97
CHROMA_FILTER
#define CHROMA_FILTER(src, stride)
Definition: h2656_inter_template.c:336
put_uni_w_pixels
static void FUNC() put_uni_w_pixels(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf, const int width)
Definition: h2656_inter_template.c:60
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
CHROMA_EXTRA_BEFORE
#define CHROMA_EXTRA_BEFORE
Definition: h2656_inter_template.c:24
put_uni_chroma_w_h
static void FUNC() put_uni_chroma_w_h(uint8_t *_dst, ptrdiff_t _dst_stride, const uint8_t *_src, ptrdiff_t _src_stride, int height, int denom, int wx, int ox, const int8_t *hf, const int8_t *vf, int width)
Definition: h2656_inter_template.c:487
put_uni_chroma_w_v
static void FUNC() put_uni_chroma_w_v(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf, const int width)
Definition: h2656_inter_template.c:513
filter
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
Definition: filter_design.txt:228
put_uni_luma_w_h
static void FUNC() put_uni_luma_w_h(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *_src, const ptrdiff_t _src_stride, int height, const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf, const int width)
Definition: h2656_inter_template.c:247
put_uni_luma_v
static void FUNC() put_uni_luma_v(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int8_t *hf, const int8_t *vf, const int width)
Definition: h2656_inter_template.c:180
val
static double val(void *priv, double ch)
Definition: aeval.c:78
put_uni_chroma_v
static void FUNC() put_uni_chroma_v(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int8_t *hf, const int8_t *vf, const int width)
Definition: h2656_inter_template.c:425
put_uni_luma_hv
static void FUNC() put_uni_luma_hv(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int8_t *hf, const int8_t *vf, const int width)
Definition: h2656_inter_template.c:207
put_chroma_v
static void FUNC() put_chroma_v(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int8_t *hf, const int8_t *vf, const int width)
Definition: h2656_inter_template.c:357
width
#define width
put_uni_chroma_h
static void FUNC() put_uni_chroma_h(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int8_t *hf, const int8_t *vf, const int width)
Definition: h2656_inter_template.c:401
LUMA_EXTRA
#define LUMA_EXTRA
Definition: h2656_inter_template.c:27
put_uni_chroma_w_hv
static void FUNC() put_uni_chroma_w_hv(uint8_t *_dst, ptrdiff_t _dst_stride, const uint8_t *_src, ptrdiff_t _src_stride, int height, int denom, int wx, int ox, const int8_t *hf, const int8_t *vf, int width)
Definition: h2656_inter_template.c:540
pixel
uint8_t pixel
Definition: tiny_ssim.c:41
put_luma_v
static void FUNC() put_luma_v(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int8_t *hf, const int8_t *vf, const int width)
Definition: h2656_inter_template.c:112
LUMA_EXTRA_BEFORE
#define LUMA_EXTRA_BEFORE
Definition: h2656_inter_template.c:26
shift
static int shift(int a, int b)
Definition: bonk.c:261
put_uni_luma_h
static void FUNC() put_uni_luma_h(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int8_t *hf, const int8_t *vf, const int width)
Definition: h2656_inter_template.c:154
height
#define height
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
put_uni_chroma_hv
static void FUNC() put_uni_chroma_hv(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int8_t *hf, const int8_t *vf, const int width)
Definition: h2656_inter_template.c:449
MAX_PB_SIZE
#define MAX_PB_SIZE
Definition: hevcdsp.h:32
put_pixels
static void FUNC() put_pixels(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int8_t *hf, const int8_t *vf, const int width)
Definition: h2656_inter_template.c:29
put_uni_pixels
static void FUNC() put_uni_pixels(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int8_t *hf, const int8_t *vf, const int width)
Definition: h2656_inter_template.c:44
CHROMA_EXTRA
#define CHROMA_EXTRA
Definition: h2656_inter_template.c:25
put_luma_hv
static void FUNC() put_luma_hv(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int8_t *hf, const int8_t *vf, const int width)
Definition: h2656_inter_template.c:127
av_clip_pixel
#define av_clip_pixel(a)
Definition: bit_depth_template.c:98
FUNC
#define FUNC(a)
Definition: bit_depth_template.c:104
put_chroma_h
static void FUNC() put_chroma_h(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int8_t *hf, const int8_t *vf, const int width)
Definition: h2656_inter_template.c:342
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
put_chroma_hv
static void FUNC() put_chroma_hv(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int8_t *hf, const int8_t *vf, const int width)
Definition: h2656_inter_template.c:372
put_uni_luma_w_hv
static void FUNC() put_uni_luma_w_hv(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf, const int width)
Definition: h2656_inter_template.c:299
LUMA_FILTER
#define LUMA_FILTER(src, stride)
Definition: h2656_inter_template.c:87