Libav
hevcpred_template.c
Go to the documentation of this file.
1 /*
2  * HEVC video decoder
3  *
4  * Copyright (C) 2012 - 2013 Guillaume Martres
5  *
6  * This file is part of Libav.
7  *
8  * Libav is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * Libav is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with Libav; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include "libavutil/pixdesc.h"
24 
25 #include "hevc.h"
26 
27 #include "bit_depth_template.c"
28 
29 #define POS(x, y) src[(x) + stride * (y)]
30 
31 static av_always_inline void FUNC(intra_pred)(HEVCContext *s, int x0, int y0,
32  int log2_size, int c_idx)
33 {
34 #define PU(x) \
35  ((x) >> s->sps->log2_min_pu_size)
36 #define MVF(x, y) \
37  (s->ref->tab_mvf[(x) + (y) * min_pu_width])
38 #define MVF_PU(x, y) \
39  MVF(PU(x0 + ((x) << hshift)), PU(y0 + ((y) << vshift)))
40 #define IS_INTRA(x, y) \
41  MVF_PU(x, y).is_intra
42 #define MIN_TB_ADDR_ZS(x, y) \
43  s->pps->min_tb_addr_zs[(y) * s->sps->min_tb_width + (x)]
44 
45 #define EXTEND(ptr, val, len) \
46 do { \
47  pixel4 pix = PIXEL_SPLAT_X4(val); \
48  for (i = 0; i < (len); i += 4) \
49  AV_WN4P(ptr + i, pix); \
50 } while (0)
51 
52 #define EXTEND_LEFT_CIP(ptr, start, length) \
53  for (i = (start); i > (start) - (length); i--) \
54  if (!IS_INTRA(i - 1, -1)) \
55  ptr[i - 1] = ptr[i]
56 #define EXTEND_RIGHT_CIP(ptr, start, length) \
57  for (i = (start); i < (start) + (length); i++) \
58  if (!IS_INTRA(i, -1)) \
59  ptr[i] = ptr[i - 1]
60 #define EXTEND_UP_CIP(ptr, start, length) \
61  for (i = (start); i > (start) - (length); i--) \
62  if (!IS_INTRA(-1, i - 1)) \
63  ptr[i - 1] = ptr[i]
64 #define EXTEND_UP_CIP_0(ptr, start, length) \
65  for (i = (start); i > (start) - (length); i--) \
66  ptr[i - 1] = ptr[i]
67 #define EXTEND_DOWN_CIP(ptr, start, length) \
68  for (i = (start); i < (start) + (length); i++) \
69  if (!IS_INTRA(-1, i)) \
70  ptr[i] = ptr[i - 1]
71  HEVCLocalContext *lc = &s->HEVClc;
72  int i;
73  int hshift = s->sps->hshift[c_idx];
74  int vshift = s->sps->vshift[c_idx];
75  int size = (1 << log2_size);
76  int size_in_luma = size << hshift;
77  int size_in_tbs = size_in_luma >> s->sps->log2_min_tb_size;
78  int x = x0 >> hshift;
79  int y = y0 >> vshift;
80  int x_tb = x0 >> s->sps->log2_min_tb_size;
81  int y_tb = y0 >> s->sps->log2_min_tb_size;
82  int cur_tb_addr = MIN_TB_ADDR_ZS(x_tb, y_tb);
83 
84  ptrdiff_t stride = s->frame->linesize[c_idx] / sizeof(pixel);
85  pixel *src = (pixel*)s->frame->data[c_idx] + x + y * stride;
86 
87  int min_pu_width = s->sps->min_pu_width;
88 
89  enum IntraPredMode mode = c_idx ? lc->pu.intra_pred_mode_c :
91 
92  pixel left_array[2 * MAX_TB_SIZE + 1];
93  pixel filtered_left_array[2 * MAX_TB_SIZE + 1];
94  pixel top_array[2 * MAX_TB_SIZE + 1];
95  pixel filtered_top_array[2 * MAX_TB_SIZE + 1];
96 
97  pixel *left = left_array + 1;
98  pixel *top = top_array + 1;
99  pixel *filtered_left = filtered_left_array + 1;
100  pixel *filtered_top = filtered_top_array + 1;
101 
102  int cand_bottom_left = lc->na.cand_bottom_left && cur_tb_addr > MIN_TB_ADDR_ZS(x_tb - 1, y_tb + size_in_tbs);
103  int cand_left = lc->na.cand_left;
104  int cand_up_left = lc->na.cand_up_left;
105  int cand_up = lc->na.cand_up;
106  int cand_up_right = lc->na.cand_up_right && cur_tb_addr > MIN_TB_ADDR_ZS(x_tb + size_in_tbs, y_tb - 1);
107 
108  int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma, s->sps->height) -
109  (y0 + size_in_luma)) >> vshift;
110  int top_right_size = (FFMIN(x0 + 2 * size_in_luma, s->sps->width) -
111  (x0 + size_in_luma)) >> hshift;
112 
113  if (s->pps->constrained_intra_pred_flag == 1) {
114  int size_in_luma_pu = PU(size_in_luma);
115  int on_pu_edge_x = !(x0 & ((1 << s->sps->log2_min_pu_size) - 1));
116  int on_pu_edge_y = !(y0 & ((1 << s->sps->log2_min_pu_size) - 1));
117  if (!size_in_luma_pu)
118  size_in_luma_pu++;
119  if (cand_bottom_left == 1 && on_pu_edge_x) {
120  int x_left_pu = PU(x0 - 1);
121  int y_bottom_pu = PU(y0 + size_in_luma);
122  int max = FFMIN(size_in_luma_pu, s->sps->min_pu_height - y_bottom_pu);
123  cand_bottom_left = 0;
124  for (i = 0; i < max; i++)
125  cand_bottom_left |= MVF(x_left_pu, y_bottom_pu + i).is_intra;
126  }
127  if (cand_left == 1 && on_pu_edge_x) {
128  int x_left_pu = PU(x0 - 1);
129  int y_left_pu = PU(y0);
130  int max = FFMIN(size_in_luma_pu, s->sps->min_pu_height - y_left_pu);
131  cand_left = 0;
132  for (i = 0; i < max; i++)
133  cand_left |= MVF(x_left_pu, y_left_pu + i).is_intra;
134  }
135  if (cand_up_left == 1) {
136  int x_left_pu = PU(x0 - 1);
137  int y_top_pu = PU(y0 - 1);
138  cand_up_left = MVF(x_left_pu, y_top_pu).is_intra;
139  }
140  if (cand_up == 1 && on_pu_edge_y) {
141  int x_top_pu = PU(x0);
142  int y_top_pu = PU(y0 - 1);
143  int max = FFMIN(size_in_luma_pu, s->sps->min_pu_width - x_top_pu);
144  cand_up = 0;
145  for (i = 0; i < max; i++)
146  cand_up |= MVF(x_top_pu + i, y_top_pu).is_intra;
147  }
148  if (cand_up_right == 1 && on_pu_edge_y) {
149  int y_top_pu = PU(y0 - 1);
150  int x_right_pu = PU(x0 + size_in_luma);
151  int max = FFMIN(size_in_luma_pu, s->sps->min_pu_width - x_right_pu);
152  cand_up_right = 0;
153  for (i = 0; i < max; i++)
154  cand_up_right |= MVF(x_right_pu + i, y_top_pu).is_intra;
155  }
156  for (i = 0; i < 2 * MAX_TB_SIZE; i++) {
157  left[i] = 128;
158  top[i] = 128;
159  }
160  }
161  if (cand_bottom_left) {
162  for (i = size; i < size + bottom_left_size; i++)
163  left[i] = POS(-1, i);
164  EXTEND(left + size + bottom_left_size, POS(-1, size + bottom_left_size - 1),
165  size - bottom_left_size);
166  }
167  if (cand_left)
168  for (i = size - 1; i >= 0; i--)
169  left[i] = POS(-1, i);
170  if (cand_up_left) {
171  left[-1] = POS(-1, -1);
172  top[-1] = left[-1];
173  }
174  if (cand_up)
175  memcpy(top, src - stride, size * sizeof(pixel));
176  if (cand_up_right) {
177  memcpy(top + size, src - stride + size, size * sizeof(pixel));
178  EXTEND(top + size + top_right_size, POS(size + top_right_size - 1, -1),
179  size - top_right_size);
180  }
181 
182  if (s->pps->constrained_intra_pred_flag == 1) {
183  if (cand_bottom_left || cand_left || cand_up_left || cand_up || cand_up_right) {
184  int size_max_x = x0 + ((2 * size) << hshift) < s->sps->width ?
185  2 * size : (s->sps->width - x0) >> hshift;
186  int size_max_y = y0 + ((2 * size) << vshift) < s->sps->height ?
187  2 * size : (s->sps->height - y0) >> vshift;
188  int j = size + (cand_bottom_left? bottom_left_size: 0) -1;
189  if (!cand_up_right) {
190  size_max_x = x0 + ((size) << hshift) < s->sps->width ?
191  size : (s->sps->width - x0) >> hshift;
192  }
193  if (!cand_bottom_left) {
194  size_max_y = y0 + (( size) << vshift) < s->sps->height ?
195  size : (s->sps->height - y0) >> vshift;
196  }
197  if (cand_bottom_left || cand_left || cand_up_left) {
198  while (j > -1 && !IS_INTRA(-1, j))
199  j--;
200  if (!IS_INTRA(-1, j)) {
201  j = 0;
202  while (j < size_max_x && !IS_INTRA(j, -1))
203  j++;
204  EXTEND_LEFT_CIP(top, j, j + 1);
205  left[-1] = top[-1];
206  j = 0;
207  }
208  } else {
209  j = 0;
210  while (j < size_max_x && !IS_INTRA(j, -1))
211  j++;
212  if (j > 0)
213  if (x0 > 0) {
214  EXTEND_LEFT_CIP(top, j, j + 1);
215  } else {
216  EXTEND_LEFT_CIP(top, j, j);
217  top[-1] = top[0];
218  }
219  left[-1] = top[-1];
220  j = 0;
221  }
222  if (cand_bottom_left || cand_left) {
223  EXTEND_DOWN_CIP(left, j, size_max_y - j);
224  }
225  if (!cand_left)
226  EXTEND(left, left[-1], size);
227  if (!cand_bottom_left)
228  EXTEND(left + size, left[size - 1], size);
229  if (x0 != 0 && y0 != 0) {
230  EXTEND_UP_CIP(left, size_max_y - 1, size_max_y);
231  } else if (x0 == 0) {
232  EXTEND_UP_CIP_0(left, size_max_y - 1, size_max_y);
233  } else {
234  EXTEND_UP_CIP(left, size_max_y - 1, size_max_y - 1);
235  }
236  top[-1] = left[-1];
237  if (y0 != 0) {
238  EXTEND_RIGHT_CIP(top, 0, size_max_x);
239  }
240  }
241  }
242  // Infer the unavailable samples
243  if (!cand_bottom_left) {
244  if (cand_left) {
245  EXTEND(left + size, left[size - 1], size);
246  } else if (cand_up_left) {
247  EXTEND(left, left[-1], 2 * size);
248  cand_left = 1;
249  } else if (cand_up) {
250  left[-1] = top[0];
251  EXTEND(left, left[-1], 2 * size);
252  cand_up_left = 1;
253  cand_left = 1;
254  } else if (cand_up_right) {
255  EXTEND(top, top[size], size);
256  left[-1] = top[size];
257  EXTEND(left, left[-1], 2 * size);
258  cand_up = 1;
259  cand_up_left = 1;
260  cand_left = 1;
261  } else { // No samples available
262  left[-1] = (1 << (BIT_DEPTH - 1));
263  EXTEND(top, left[-1], 2 * size);
264  EXTEND(left, left[-1], 2 * size);
265  }
266  }
267 
268  if (!cand_left)
269  EXTEND(left, left[size], size);
270  if (!cand_up_left) {
271  left[-1] = left[0];
272  }
273  if (!cand_up)
274  EXTEND(top, left[-1], size);
275  if (!cand_up_right)
276  EXTEND(top + size, top[size - 1], size);
277 
278  top[-1] = left[-1];
279 
280  // Filtering process
281  if (c_idx == 0 && mode != INTRA_DC && size != 4) {
282  int intra_hor_ver_dist_thresh[] = { 7, 1, 0 };
283  int min_dist_vert_hor = FFMIN(FFABS((int)mode - 26),
284  FFABS((int)mode - 10));
285  if (min_dist_vert_hor > intra_hor_ver_dist_thresh[log2_size - 3]) {
286  int threshold = 1 << (BIT_DEPTH - 5);
287  if (s->sps->sps_strong_intra_smoothing_enable_flag &&
288  log2_size == 5 &&
289  FFABS(top[-1] + top[63] - 2 * top[31]) < threshold &&
290  FFABS(left[-1] + left[63] - 2 * left[31]) < threshold) {
291  // We can't just overwrite values in top because it could be
292  // a pointer into src
293  filtered_top[-1] = top[-1];
294  filtered_top[63] = top[63];
295  for (i = 0; i < 63; i++)
296  filtered_top[i] = ((64 - (i + 1)) * top[-1] +
297  (i + 1) * top[63] + 32) >> 6;
298  for (i = 0; i < 63; i++)
299  left[i] = ((64 - (i + 1)) * left[-1] +
300  (i + 1) * left[63] + 32) >> 6;
301  top = filtered_top;
302  } else {
303  filtered_left[2 * size - 1] = left[2 * size - 1];
304  filtered_top[2 * size - 1] = top[2 * size - 1];
305  for (i = 2 * size - 2; i >= 0; i--)
306  filtered_left[i] = (left[i + 1] + 2 * left[i] +
307  left[i - 1] + 2) >> 2;
308  filtered_top[-1] =
309  filtered_left[-1] = (left[0] + 2 * left[-1] + top[0] + 2) >> 2;
310  for (i = 2 * size - 2; i >= 0; i--)
311  filtered_top[i] = (top[i + 1] + 2 * top[i] +
312  top[i - 1] + 2) >> 2;
313  left = filtered_left;
314  top = filtered_top;
315  }
316  }
317  }
318 
319  switch (mode) {
320  case INTRA_PLANAR:
321  s->hpc.pred_planar[log2_size - 2]((uint8_t *)src, (uint8_t *)top,
322  (uint8_t *)left, stride);
323  break;
324  case INTRA_DC:
325  s->hpc.pred_dc((uint8_t *)src, (uint8_t *)top,
326  (uint8_t *)left, stride, log2_size, c_idx);
327  break;
328  default:
329  s->hpc.pred_angular[log2_size - 2]((uint8_t *)src, (uint8_t *)top,
330  (uint8_t *)left, stride, c_idx,
331  mode);
332  break;
333  }
334 }
335 
336 #define INTRA_PRED(size) \
337 static void FUNC(intra_pred_ ## size)(HEVCContext *s, int x0, int y0, int c_idx) \
338 { \
339  FUNC(intra_pred)(s, x0, y0, size, c_idx); \
340 }
341 
342 INTRA_PRED(2)
343 INTRA_PRED(3)
344 INTRA_PRED(4)
345 INTRA_PRED(5)
346 
347 #undef INTRA_PRED
348 
349 static av_always_inline void FUNC(pred_planar)(uint8_t *_src, const uint8_t *_top,
350  const uint8_t *_left, ptrdiff_t stride,
351  int trafo_size)
352 {
353  int x, y;
354  pixel *src = (pixel *)_src;
355  const pixel *top = (const pixel *)_top;
356  const pixel *left = (const pixel *)_left;
357  int size = 1 << trafo_size;
358  for (y = 0; y < size; y++)
359  for (x = 0; x < size; x++)
360  POS(x, y) = ((size - 1 - x) * left[y] + (x + 1) * top[size] +
361  (size - 1 - y) * top[x] + (y + 1) * left[size] + size) >> (trafo_size + 1);
362 }
363 
364 #define PRED_PLANAR(size)\
365 static void FUNC(pred_planar_ ## size)(uint8_t *src, const uint8_t *top, \
366  const uint8_t *left, ptrdiff_t stride) \
367 { \
368  FUNC(pred_planar)(src, top, left, stride, size + 2); \
369 }
370 
371 PRED_PLANAR(0)
372 PRED_PLANAR(1)
373 PRED_PLANAR(2)
374 PRED_PLANAR(3)
375 
376 #undef PRED_PLANAR
377 
378 static void FUNC(pred_dc)(uint8_t *_src, const uint8_t *_top,
379  const uint8_t *_left,
380  ptrdiff_t stride, int log2_size, int c_idx)
381 {
382  int i, j, x, y;
383  int size = (1 << log2_size);
384  pixel *src = (pixel *)_src;
385  const pixel *top = (const pixel *)_top;
386  const pixel *left = (const pixel *)_left;
387  int dc = size;
388  pixel4 a;
389  for (i = 0; i < size; i++)
390  dc += left[i] + top[i];
391 
392  dc >>= log2_size + 1;
393 
394  a = PIXEL_SPLAT_X4(dc);
395 
396  for (i = 0; i < size; i++)
397  for (j = 0; j < size / 4; j++)
398  AV_WN4PA(&POS(j * 4, i), a);
399 
400  if (c_idx == 0 && size < 32) {
401  POS(0, 0) = (left[0] + 2 * dc + top[0] + 2) >> 2;
402  for (x = 1; x < size; x++)
403  POS(x, 0) = (top[x] + 3 * dc + 2) >> 2;
404  for (y = 1; y < size; y++)
405  POS(0, y) = (left[y] + 3 * dc + 2) >> 2;
406  }
407 }
408 
410  const uint8_t *_top,
411  const uint8_t *_left,
412  ptrdiff_t stride, int c_idx,
413  int mode, int size)
414 {
415  int x, y;
416  pixel *src = (pixel *)_src;
417  const pixel *top = (const pixel *)_top;
418  const pixel *left = (const pixel *)_left;
419 
420  static const int intra_pred_angle[] = {
421  32, 26, 21, 17, 13, 9, 5, 2, 0, -2, -5, -9, -13, -17, -21, -26, -32,
422  -26, -21, -17, -13, -9, -5, -2, 0, 2, 5, 9, 13, 17, 21, 26, 32
423  };
424  static const int inv_angle[] = {
425  -4096, -1638, -910, -630, -482, -390, -315, -256, -315, -390, -482,
426  -630, -910, -1638, -4096
427  };
428 
429  int angle = intra_pred_angle[mode - 2];
430  pixel ref_array[3 * MAX_TB_SIZE + 1];
431  pixel *ref_tmp = ref_array + size;
432  const pixel *ref;
433  int last = (size * angle) >> 5;
434 
435  if (mode >= 18) {
436  ref = top - 1;
437  if (angle < 0 && last < -1) {
438  for (x = 0; x <= size; x++)
439  ref_tmp[x] = top[x - 1];
440  for (x = last; x <= -1; x++)
441  ref_tmp[x] = left[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)];
442  ref = ref_tmp;
443  }
444 
445  for (y = 0; y < size; y++) {
446  int idx = ((y + 1) * angle) >> 5;
447  int fact = ((y + 1) * angle) & 31;
448  if (fact) {
449  for (x = 0; x < size; x++) {
450  POS(x, y) = ((32 - fact) * ref[x + idx + 1] +
451  fact * ref[x + idx + 2] + 16) >> 5;
452  }
453  } else {
454  for (x = 0; x < size; x++)
455  POS(x, y) = ref[x + idx + 1];
456  }
457  }
458  if (mode == 26 && c_idx == 0 && size < 32) {
459  for (y = 0; y < size; y++)
460  POS(0, y) = av_clip_pixel(top[0] + ((left[y] - left[-1]) >> 1));
461  }
462  } else {
463  ref = left - 1;
464  if (angle < 0 && last < -1) {
465  for (x = 0; x <= size; x++)
466  ref_tmp[x] = left[x - 1];
467  for (x = last; x <= -1; x++)
468  ref_tmp[x] = top[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)];
469  ref = ref_tmp;
470  }
471 
472  for (x = 0; x < size; x++) {
473  int idx = ((x + 1) * angle) >> 5;
474  int fact = ((x + 1) * angle) & 31;
475  if (fact) {
476  for (y = 0; y < size; y++) {
477  POS(x, y) = ((32 - fact) * ref[y + idx + 1] +
478  fact * ref[y + idx + 2] + 16) >> 5;
479  }
480  } else {
481  for (y = 0; y < size; y++)
482  POS(x, y) = ref[y + idx + 1];
483  }
484  }
485  if (mode == 10 && c_idx == 0 && size < 32) {
486  for (x = 0; x < size; x++)
487  POS(x, 0) = av_clip_pixel(left[0] + ((top[x] - top[-1]) >> 1));
488  }
489  }
490 }
491 
492 static void FUNC(pred_angular_0)(uint8_t *src, const uint8_t *top,
493  const uint8_t *left,
494  ptrdiff_t stride, int c_idx, int mode)
495 {
496  FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 2);
497 }
498 
499 static void FUNC(pred_angular_1)(uint8_t *src, const uint8_t *top,
500  const uint8_t *left,
501  ptrdiff_t stride, int c_idx, int mode)
502 {
503  FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 3);
504 }
505 
506 static void FUNC(pred_angular_2)(uint8_t *src, const uint8_t *top,
507  const uint8_t *left,
508  ptrdiff_t stride, int c_idx, int mode)
509 {
510  FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 4);
511 }
512 
513 static void FUNC(pred_angular_3)(uint8_t *src, const uint8_t *top,
514  const uint8_t *left,
515  ptrdiff_t stride, int c_idx, int mode)
516 {
517  FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 5);
518 }
519 
520 #undef EXTEND_LEFT_CIP
521 #undef EXTEND_RIGHT_CIP
522 #undef EXTEND_UP_CIP
523 #undef EXTEND_DOWN_CIP
524 #undef IS_INTRA
525 #undef MVF_PU
526 #undef MVF
527 #undef PU
528 #undef EXTEND
529 #undef MIN_TB_ADDR_ZS
530 #undef POS
NeighbourAvailable na
Definition: hevc.h:741
int size
#define MIN_TB_ADDR_ZS(x, y)
#define av_always_inline
Definition: attributes.h:40
#define BIT_DEPTH
PredictionUnit pu
Definition: hevc.h:740
#define INTRA_PRED(size)
#define pixel4
int cand_up_right
Definition: hevc.h:635
int stride
Definition: mace.c:144
#define av_clip_pixel(a)
#define EXTEND_RIGHT_CIP(ptr, start, length)
uint8_t
int cand_up_left
Definition: hevc.h:634
#define MAX_TB_SIZE
Definition: hevc.h:57
#define EXTEND(ptr, val, len)
static void FUNC() pred_angular_2(uint8_t *src, const uint8_t *top, const uint8_t *left, ptrdiff_t stride, int c_idx, int mode)
static void FUNC() pred_angular_3(uint8_t *src, const uint8_t *top, const uint8_t *left, ptrdiff_t stride, int c_idx, int mode)
#define FUNC(a)
#define PRED_PLANAR(size)
static void FUNC() pred_dc(uint8_t *_src, const uint8_t *_top, const uint8_t *_left, ptrdiff_t stride, int log2_size, int c_idx)
#define EXTEND_DOWN_CIP(ptr, start, length)
#define PU(x)
#define pixel
static av_always_inline void FUNC() intra_pred(HEVCContext *s, int x0, int y0, int log2_size, int c_idx)
TransformUnit tu
Definition: hevc.h:727
#define POS(x, y)
IntraPredMode
Definition: hevc.h:205
Definition: hevc.h:207
uint8_t intra_pred_mode_c
Definition: hevc.h:645
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> dc
#define EXTEND_UP_CIP_0(ptr, start, length)
#define MVF(x, y)
#define EXTEND_UP_CIP(ptr, start, length)
int cand_bottom_left
Definition: hevc.h:631
static av_always_inline void FUNC() pred_planar(uint8_t *_src, const uint8_t *_top, const uint8_t *_left, ptrdiff_t stride, int trafo_size)
#define IS_INTRA(x, y)
#define EXTEND_LEFT_CIP(ptr, start, length)
int cur_intra_pred_mode
Definition: hevc.h:652
#define AV_WN4PA
#define FFABS(a)
Definition: common.h:52
static void FUNC() pred_angular_1(uint8_t *src, const uint8_t *top, const uint8_t *left, ptrdiff_t stride, int c_idx, int mode)
static av_always_inline void FUNC() pred_angular(uint8_t *_src, const uint8_t *_top, const uint8_t *_left, ptrdiff_t stride, int c_idx, int mode, int size)
static void FUNC() pred_angular_0(uint8_t *src, const uint8_t *top, const uint8_t *left, ptrdiff_t stride, int c_idx, int mode)
#define FFMIN(a, b)
Definition: common.h:57
#define PIXEL_SPLAT_X4(x)