FFmpeg  4.4.6
hevc_filter.c
Go to the documentation of this file.
1 /*
2  * HEVC video decoder
3  *
4  * Copyright (C) 2012 - 2013 Guillaume Martres
5  * Copyright (C) 2013 Seppo Tomperi
6  * Copyright (C) 2013 Wassim Hamidouche
7  *
8  * This file is part of FFmpeg.
9  *
10  * FFmpeg is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * FFmpeg is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with FFmpeg; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  */
24 
25 #include "libavutil/common.h"
26 #include "libavutil/internal.h"
27 
28 #include "cabac_functions.h"
29 #include "hevcdec.h"
30 
31 #include "bit_depth_template.c"
32 
33 #define LUMA 0
34 #define CB 1
35 #define CR 2
36 
37 static const uint8_t tctable[54] = {
38  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, // QP 0...18
39  1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, // QP 19...37
40  5, 5, 6, 6, 7, 8, 9, 10, 11, 13, 14, 16, 18, 20, 22, 24 // QP 38...53
41 };
42 
43 static const uint8_t betatable[52] = {
44  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, // QP 0...18
45  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, // QP 19...37
46  38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64 // QP 38...51
47 };
48 
49 static int chroma_tc(HEVCContext *s, int qp_y, int c_idx, int tc_offset)
50 {
51  static const int qp_c[] = {
52  29, 30, 31, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37
53  };
54  int qp, qp_i, offset, idxt;
55 
56  // slice qp offset is not used for deblocking
57  if (c_idx == 1)
58  offset = s->ps.pps->cb_qp_offset;
59  else
60  offset = s->ps.pps->cr_qp_offset;
61 
62  qp_i = av_clip(qp_y + offset, 0, 57);
63  if (s->ps.sps->chroma_format_idc == 1) {
64  if (qp_i < 30)
65  qp = qp_i;
66  else if (qp_i > 43)
67  qp = qp_i - 6;
68  else
69  qp = qp_c[qp_i - 30];
70  } else {
71  qp = av_clip(qp_i, 0, 51);
72  }
73 
74  idxt = av_clip(qp + DEFAULT_INTRA_TC_OFFSET + tc_offset, 0, 53);
75  return tctable[idxt];
76 }
77 
78 static int get_qPy_pred(HEVCContext *s, int xBase, int yBase, int log2_cb_size)
79 {
80  HEVCLocalContext *lc = s->HEVClc;
81  int ctb_size_mask = (1 << s->ps.sps->log2_ctb_size) - 1;
82  int MinCuQpDeltaSizeMask = (1 << (s->ps.sps->log2_ctb_size -
83  s->ps.pps->diff_cu_qp_delta_depth)) - 1;
84  int xQgBase = xBase - (xBase & MinCuQpDeltaSizeMask);
85  int yQgBase = yBase - (yBase & MinCuQpDeltaSizeMask);
86  int min_cb_width = s->ps.sps->min_cb_width;
87  int x_cb = xQgBase >> s->ps.sps->log2_min_cb_size;
88  int y_cb = yQgBase >> s->ps.sps->log2_min_cb_size;
89  int availableA = (xBase & ctb_size_mask) &&
90  (xQgBase & ctb_size_mask);
91  int availableB = (yBase & ctb_size_mask) &&
92  (yQgBase & ctb_size_mask);
93  int qPy_pred, qPy_a, qPy_b;
94 
95  // qPy_pred
96  if (lc->first_qp_group || (!xQgBase && !yQgBase)) {
98  qPy_pred = s->sh.slice_qp;
99  } else {
100  qPy_pred = lc->qPy_pred;
101  }
102 
103  // qPy_a
104  if (availableA == 0)
105  qPy_a = qPy_pred;
106  else
107  qPy_a = s->qp_y_tab[(x_cb - 1) + y_cb * min_cb_width];
108 
109  // qPy_b
110  if (availableB == 0)
111  qPy_b = qPy_pred;
112  else
113  qPy_b = s->qp_y_tab[x_cb + (y_cb - 1) * min_cb_width];
114 
115  av_assert2(qPy_a >= -s->ps.sps->qp_bd_offset && qPy_a < 52);
116  av_assert2(qPy_b >= -s->ps.sps->qp_bd_offset && qPy_b < 52);
117 
118  return (qPy_a + qPy_b + 1) >> 1;
119 }
120 
121 void ff_hevc_set_qPy(HEVCContext *s, int xBase, int yBase, int log2_cb_size)
122 {
123  int qp_y = get_qPy_pred(s, xBase, yBase, log2_cb_size);
124 
125  if (s->HEVClc->tu.cu_qp_delta != 0) {
126  int off = s->ps.sps->qp_bd_offset;
127  s->HEVClc->qp_y = FFUMOD(qp_y + s->HEVClc->tu.cu_qp_delta + 52 + 2 * off,
128  52 + off) - off;
129  } else
130  s->HEVClc->qp_y = qp_y;
131 }
132 
133 static int get_qPy(HEVCContext *s, int xC, int yC)
134 {
135  int log2_min_cb_size = s->ps.sps->log2_min_cb_size;
136  int x = xC >> log2_min_cb_size;
137  int y = yC >> log2_min_cb_size;
138  return s->qp_y_tab[x + y * s->ps.sps->min_cb_width];
139 }
140 
141 static void copy_CTB(uint8_t *dst, const uint8_t *src, int width, int height,
142  ptrdiff_t stride_dst, ptrdiff_t stride_src)
143 {
144 int i, j;
145 
146  if (((intptr_t)dst | (intptr_t)src | stride_dst | stride_src) & 15) {
147  for (i = 0; i < height; i++) {
148  for (j = 0; j < width - 7; j+=8)
149  AV_COPY64U(dst+j, src+j);
150  dst += stride_dst;
151  src += stride_src;
152  }
153  if (width&7) {
154  dst += ((width>>3)<<3) - stride_dst * height;
155  src += ((width>>3)<<3) - stride_src * height;
156  width &= 7;
157  for (i = 0; i < height; i++) {
158  for (j = 0; j < width; j++)
159  dst[j] = src[j];
160  dst += stride_dst;
161  src += stride_src;
162  }
163  }
164  } else {
165  for (i = 0; i < height; i++) {
166  for (j = 0; j < width; j+=16)
167  AV_COPY128(dst+j, src+j);
168  dst += stride_dst;
169  src += stride_src;
170  }
171  }
172 }
173 
174 static void copy_pixel(uint8_t *dst, const uint8_t *src, int pixel_shift)
175 {
176  if (pixel_shift)
177  *(uint16_t *)dst = *(uint16_t *)src;
178  else
179  *dst = *src;
180 }
181 
182 static void copy_vert(uint8_t *dst, const uint8_t *src,
183  int pixel_shift, int height,
184  ptrdiff_t stride_dst, ptrdiff_t stride_src)
185 {
186  int i;
187  if (pixel_shift == 0) {
188  for (i = 0; i < height; i++) {
189  *dst = *src;
190  dst += stride_dst;
191  src += stride_src;
192  }
193  } else {
194  for (i = 0; i < height; i++) {
195  *(uint16_t *)dst = *(uint16_t *)src;
196  dst += stride_dst;
197  src += stride_src;
198  }
199  }
200 }
201 
202 static void copy_CTB_to_hv(HEVCContext *s, const uint8_t *src,
203  ptrdiff_t stride_src, int x, int y, int width, int height,
204  int c_idx, int x_ctb, int y_ctb)
205 {
206  int sh = s->ps.sps->pixel_shift;
207  int w = s->ps.sps->width >> s->ps.sps->hshift[c_idx];
208  int h = s->ps.sps->height >> s->ps.sps->vshift[c_idx];
209 
210  /* copy horizontal edges */
211  memcpy(s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb) * w + x) << sh),
212  src, width << sh);
213  memcpy(s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb + 1) * w + x) << sh),
214  src + stride_src * (height - 1), width << sh);
215 
216  /* copy vertical edges */
217  copy_vert(s->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb) * h + y) << sh), src, sh, height, 1 << sh, stride_src);
218 
219  copy_vert(s->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb + 1) * h + y) << sh), src + ((width - 1) << sh), sh, height, 1 << sh, stride_src);
220 }
221 
223  uint8_t *src1, const uint8_t *dst1,
224  ptrdiff_t stride_src, ptrdiff_t stride_dst,
225  int x0, int y0, int width, int height, int c_idx)
226 {
227  if ( s->ps.pps->transquant_bypass_enable_flag ||
228  (s->ps.sps->pcm.loop_filter_disable_flag && s->ps.sps->pcm_enabled_flag)) {
229  int x, y;
230  int min_pu_size = 1 << s->ps.sps->log2_min_pu_size;
231  int hshift = s->ps.sps->hshift[c_idx];
232  int vshift = s->ps.sps->vshift[c_idx];
233  int x_min = ((x0 ) >> s->ps.sps->log2_min_pu_size);
234  int y_min = ((y0 ) >> s->ps.sps->log2_min_pu_size);
235  int x_max = ((x0 + width ) >> s->ps.sps->log2_min_pu_size);
236  int y_max = ((y0 + height) >> s->ps.sps->log2_min_pu_size);
237  int len = (min_pu_size >> hshift) << s->ps.sps->pixel_shift;
238  for (y = y_min; y < y_max; y++) {
239  for (x = x_min; x < x_max; x++) {
240  if (s->is_pcm[y * s->ps.sps->min_pu_width + x]) {
241  int n;
242  uint8_t *src = src1 + (((y << s->ps.sps->log2_min_pu_size) - y0) >> vshift) * stride_src + ((((x << s->ps.sps->log2_min_pu_size) - x0) >> hshift) << s->ps.sps->pixel_shift);
243  const uint8_t *dst = dst1 + (((y << s->ps.sps->log2_min_pu_size) - y0) >> vshift) * stride_dst + ((((x << s->ps.sps->log2_min_pu_size) - x0) >> hshift) << s->ps.sps->pixel_shift);
244  for (n = 0; n < (min_pu_size >> vshift); n++) {
245  memcpy(src, dst, len);
246  src += stride_src;
247  dst += stride_dst;
248  }
249  }
250  }
251  }
252  }
253 }
254 
255 #define CTB(tab, x, y) ((tab)[(y) * s->ps.sps->ctb_width + (x)])
256 
257 static void sao_filter_CTB(HEVCContext *s, int x, int y)
258 {
259  static const uint8_t sao_tab[8] = { 0, 1, 2, 2, 3, 3, 4, 4 };
260  HEVCLocalContext *lc = s->HEVClc;
261  int c_idx;
262  int edges[4]; // 0 left 1 top 2 right 3 bottom
263  int x_ctb = x >> s->ps.sps->log2_ctb_size;
264  int y_ctb = y >> s->ps.sps->log2_ctb_size;
265  int ctb_addr_rs = y_ctb * s->ps.sps->ctb_width + x_ctb;
266  int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs];
267  SAOParams *sao = &CTB(s->sao, x_ctb, y_ctb);
268  // flags indicating unfilterable edges
269  uint8_t vert_edge[] = { 0, 0 };
270  uint8_t horiz_edge[] = { 0, 0 };
271  uint8_t diag_edge[] = { 0, 0, 0, 0 };
272  uint8_t lfase = CTB(s->filter_slice_edges, x_ctb, y_ctb);
273  uint8_t no_tile_filter = s->ps.pps->tiles_enabled_flag &&
274  !s->ps.pps->loop_filter_across_tiles_enabled_flag;
275  uint8_t restore = no_tile_filter || !lfase;
276  uint8_t left_tile_edge = 0;
277  uint8_t right_tile_edge = 0;
278  uint8_t up_tile_edge = 0;
279  uint8_t bottom_tile_edge = 0;
280 
281  edges[0] = x_ctb == 0;
282  edges[1] = y_ctb == 0;
283  edges[2] = x_ctb == s->ps.sps->ctb_width - 1;
284  edges[3] = y_ctb == s->ps.sps->ctb_height - 1;
285 
286  if (restore) {
287  if (!edges[0]) {
288  left_tile_edge = no_tile_filter && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs-1]];
289  vert_edge[0] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb - 1, y_ctb)) || left_tile_edge;
290  }
291  if (!edges[2]) {
292  right_tile_edge = no_tile_filter && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs+1]];
293  vert_edge[1] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb + 1, y_ctb)) || right_tile_edge;
294  }
295  if (!edges[1]) {
296  up_tile_edge = no_tile_filter && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs - s->ps.sps->ctb_width]];
297  horiz_edge[0] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb, y_ctb - 1)) || up_tile_edge;
298  }
299  if (!edges[3]) {
300  bottom_tile_edge = no_tile_filter && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs + s->ps.sps->ctb_width]];
301  horiz_edge[1] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb, y_ctb + 1)) || bottom_tile_edge;
302  }
303  if (!edges[0] && !edges[1]) {
304  diag_edge[0] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb - 1, y_ctb - 1)) || left_tile_edge || up_tile_edge;
305  }
306  if (!edges[1] && !edges[2]) {
307  diag_edge[1] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb + 1, y_ctb - 1)) || right_tile_edge || up_tile_edge;
308  }
309  if (!edges[2] && !edges[3]) {
310  diag_edge[2] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb + 1, y_ctb + 1)) || right_tile_edge || bottom_tile_edge;
311  }
312  if (!edges[0] && !edges[3]) {
313  diag_edge[3] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb - 1, y_ctb + 1)) || left_tile_edge || bottom_tile_edge;
314  }
315  }
316 
317  for (c_idx = 0; c_idx < (s->ps.sps->chroma_format_idc ? 3 : 1); c_idx++) {
318  int x0 = x >> s->ps.sps->hshift[c_idx];
319  int y0 = y >> s->ps.sps->vshift[c_idx];
320  ptrdiff_t stride_src = s->frame->linesize[c_idx];
321  int ctb_size_h = (1 << (s->ps.sps->log2_ctb_size)) >> s->ps.sps->hshift[c_idx];
322  int ctb_size_v = (1 << (s->ps.sps->log2_ctb_size)) >> s->ps.sps->vshift[c_idx];
323  int width = FFMIN(ctb_size_h, (s->ps.sps->width >> s->ps.sps->hshift[c_idx]) - x0);
324  int height = FFMIN(ctb_size_v, (s->ps.sps->height >> s->ps.sps->vshift[c_idx]) - y0);
325  int tab = sao_tab[(FFALIGN(width, 8) >> 3) - 1];
326  uint8_t *src = &s->frame->data[c_idx][y0 * stride_src + (x0 << s->ps.sps->pixel_shift)];
327  ptrdiff_t stride_dst;
328  uint8_t *dst;
329 
330  switch (sao->type_idx[c_idx]) {
331  case SAO_BAND:
332  copy_CTB_to_hv(s, src, stride_src, x0, y0, width, height, c_idx,
333  x_ctb, y_ctb);
334  if (s->ps.pps->transquant_bypass_enable_flag ||
335  (s->ps.sps->pcm.loop_filter_disable_flag && s->ps.sps->pcm_enabled_flag)) {
336  dst = lc->edge_emu_buffer;
337  stride_dst = 2*MAX_PB_SIZE;
338  copy_CTB(dst, src, width << s->ps.sps->pixel_shift, height, stride_dst, stride_src);
339  s->hevcdsp.sao_band_filter[tab](src, dst, stride_src, stride_dst,
340  sao->offset_val[c_idx], sao->band_position[c_idx],
341  width, height);
342  restore_tqb_pixels(s, src, dst, stride_src, stride_dst,
343  x, y, width, height, c_idx);
344  } else {
345  s->hevcdsp.sao_band_filter[tab](src, src, stride_src, stride_src,
346  sao->offset_val[c_idx], sao->band_position[c_idx],
347  width, height);
348  }
349  sao->type_idx[c_idx] = SAO_APPLIED;
350  break;
351  case SAO_EDGE:
352  {
353  int w = s->ps.sps->width >> s->ps.sps->hshift[c_idx];
354  int h = s->ps.sps->height >> s->ps.sps->vshift[c_idx];
355  int left_edge = edges[0];
356  int top_edge = edges[1];
357  int right_edge = edges[2];
358  int bottom_edge = edges[3];
359  int sh = s->ps.sps->pixel_shift;
360  int left_pixels, right_pixels;
361 
362  stride_dst = 2*MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE;
363  dst = lc->edge_emu_buffer + stride_dst + AV_INPUT_BUFFER_PADDING_SIZE;
364 
365  if (!top_edge) {
366  int left = 1 - left_edge;
367  int right = 1 - right_edge;
368  const uint8_t *src1[2];
369  uint8_t *dst1;
370  int src_idx, pos;
371 
372  dst1 = dst - stride_dst - (left << sh);
373  src1[0] = src - stride_src - (left << sh);
374  src1[1] = s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb - 1) * w + x0 - left) << sh);
375  pos = 0;
376  if (left) {
377  src_idx = (CTB(s->sao, x_ctb-1, y_ctb-1).type_idx[c_idx] ==
378  SAO_APPLIED);
379  copy_pixel(dst1, src1[src_idx], sh);
380  pos += (1 << sh);
381  }
382  src_idx = (CTB(s->sao, x_ctb, y_ctb-1).type_idx[c_idx] ==
383  SAO_APPLIED);
384  memcpy(dst1 + pos, src1[src_idx] + pos, width << sh);
385  if (right) {
386  pos += width << sh;
387  src_idx = (CTB(s->sao, x_ctb+1, y_ctb-1).type_idx[c_idx] ==
388  SAO_APPLIED);
389  copy_pixel(dst1 + pos, src1[src_idx] + pos, sh);
390  }
391  }
392  if (!bottom_edge) {
393  int left = 1 - left_edge;
394  int right = 1 - right_edge;
395  const uint8_t *src1[2];
396  uint8_t *dst1;
397  int src_idx, pos;
398 
399  dst1 = dst + height * stride_dst - (left << sh);
400  src1[0] = src + height * stride_src - (left << sh);
401  src1[1] = s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb + 2) * w + x0 - left) << sh);
402  pos = 0;
403  if (left) {
404  src_idx = (CTB(s->sao, x_ctb-1, y_ctb+1).type_idx[c_idx] ==
405  SAO_APPLIED);
406  copy_pixel(dst1, src1[src_idx], sh);
407  pos += (1 << sh);
408  }
409  src_idx = (CTB(s->sao, x_ctb, y_ctb+1).type_idx[c_idx] ==
410  SAO_APPLIED);
411  memcpy(dst1 + pos, src1[src_idx] + pos, width << sh);
412  if (right) {
413  pos += width << sh;
414  src_idx = (CTB(s->sao, x_ctb+1, y_ctb+1).type_idx[c_idx] ==
415  SAO_APPLIED);
416  copy_pixel(dst1 + pos, src1[src_idx] + pos, sh);
417  }
418  }
419  left_pixels = 0;
420  if (!left_edge) {
421  if (CTB(s->sao, x_ctb-1, y_ctb).type_idx[c_idx] == SAO_APPLIED) {
422  copy_vert(dst - (1 << sh),
423  s->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb - 1) * h + y0) << sh),
424  sh, height, stride_dst, 1 << sh);
425  } else {
426  left_pixels = 1;
427  }
428  }
429  right_pixels = 0;
430  if (!right_edge) {
431  if (CTB(s->sao, x_ctb+1, y_ctb).type_idx[c_idx] == SAO_APPLIED) {
432  copy_vert(dst + (width << sh),
433  s->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb + 2) * h + y0) << sh),
434  sh, height, stride_dst, 1 << sh);
435  } else {
436  right_pixels = 1;
437  }
438  }
439 
440  copy_CTB(dst - (left_pixels << sh),
441  src - (left_pixels << sh),
442  (width + left_pixels + right_pixels) << sh,
443  height, stride_dst, stride_src);
444 
445  copy_CTB_to_hv(s, src, stride_src, x0, y0, width, height, c_idx,
446  x_ctb, y_ctb);
447  s->hevcdsp.sao_edge_filter[tab](src, dst, stride_src, sao->offset_val[c_idx],
448  sao->eo_class[c_idx], width, height);
449  s->hevcdsp.sao_edge_restore[restore](src, dst,
450  stride_src, stride_dst,
451  sao,
452  edges, width,
453  height, c_idx,
454  vert_edge,
455  horiz_edge,
456  diag_edge);
457  restore_tqb_pixels(s, src, dst, stride_src, stride_dst,
458  x, y, width, height, c_idx);
459  sao->type_idx[c_idx] = SAO_APPLIED;
460  break;
461  }
462  }
463  }
464 }
465 
466 static int get_pcm(HEVCContext *s, int x, int y)
467 {
468  int log2_min_pu_size = s->ps.sps->log2_min_pu_size;
469  int x_pu, y_pu;
470 
471  if (x < 0 || y < 0)
472  return 2;
473 
474  x_pu = x >> log2_min_pu_size;
475  y_pu = y >> log2_min_pu_size;
476 
477  if (x_pu >= s->ps.sps->min_pu_width || y_pu >= s->ps.sps->min_pu_height)
478  return 2;
479  return s->is_pcm[y_pu * s->ps.sps->min_pu_width + x_pu];
480 }
481 
482 #define TC_CALC(qp, bs) \
483  tctable[av_clip((qp) + DEFAULT_INTRA_TC_OFFSET * ((bs) - 1) + \
484  (tc_offset & -2), \
485  0, MAX_QP + DEFAULT_INTRA_TC_OFFSET)]
486 
487 static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
488 {
489  uint8_t *src;
490  int x, y;
491  int chroma, beta;
492  int32_t c_tc[2], tc[2];
493  uint8_t no_p[2] = { 0 };
494  uint8_t no_q[2] = { 0 };
495 
496  int log2_ctb_size = s->ps.sps->log2_ctb_size;
497  int x_end, x_end2, y_end;
498  int ctb_size = 1 << log2_ctb_size;
499  int ctb = (x0 >> log2_ctb_size) +
500  (y0 >> log2_ctb_size) * s->ps.sps->ctb_width;
501  int cur_tc_offset = s->deblock[ctb].tc_offset;
502  int cur_beta_offset = s->deblock[ctb].beta_offset;
503  int left_tc_offset, left_beta_offset;
504  int tc_offset, beta_offset;
505  int pcmf = (s->ps.sps->pcm_enabled_flag &&
506  s->ps.sps->pcm.loop_filter_disable_flag) ||
507  s->ps.pps->transquant_bypass_enable_flag;
508 
509  if (x0) {
510  left_tc_offset = s->deblock[ctb - 1].tc_offset;
511  left_beta_offset = s->deblock[ctb - 1].beta_offset;
512  } else {
513  left_tc_offset = 0;
514  left_beta_offset = 0;
515  }
516 
517  x_end = x0 + ctb_size;
518  if (x_end > s->ps.sps->width)
519  x_end = s->ps.sps->width;
520  y_end = y0 + ctb_size;
521  if (y_end > s->ps.sps->height)
522  y_end = s->ps.sps->height;
523 
524  tc_offset = cur_tc_offset;
525  beta_offset = cur_beta_offset;
526 
527  x_end2 = x_end;
528  if (x_end2 != s->ps.sps->width)
529  x_end2 -= 8;
530  for (y = y0; y < y_end; y += 8) {
531  // vertical filtering luma
532  for (x = x0 ? x0 : 8; x < x_end; x += 8) {
533  const int bs0 = s->vertical_bs[(x + y * s->bs_width) >> 2];
534  const int bs1 = s->vertical_bs[(x + (y + 4) * s->bs_width) >> 2];
535  if (bs0 || bs1) {
536  const int qp = (get_qPy(s, x - 1, y) + get_qPy(s, x, y) + 1) >> 1;
537 
538  beta = betatable[av_clip(qp + beta_offset, 0, MAX_QP)];
539 
540  tc[0] = bs0 ? TC_CALC(qp, bs0) : 0;
541  tc[1] = bs1 ? TC_CALC(qp, bs1) : 0;
542  src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->ps.sps->pixel_shift)];
543  if (pcmf) {
544  no_p[0] = get_pcm(s, x - 1, y);
545  no_p[1] = get_pcm(s, x - 1, y + 4);
546  no_q[0] = get_pcm(s, x, y);
547  no_q[1] = get_pcm(s, x, y + 4);
548  s->hevcdsp.hevc_v_loop_filter_luma_c(src,
549  s->frame->linesize[LUMA],
550  beta, tc, no_p, no_q);
551  } else
552  s->hevcdsp.hevc_v_loop_filter_luma(src,
553  s->frame->linesize[LUMA],
554  beta, tc, no_p, no_q);
555  }
556  }
557 
558  if(!y)
559  continue;
560 
561  // horizontal filtering luma
562  for (x = x0 ? x0 - 8 : 0; x < x_end2; x += 8) {
563  const int bs0 = s->horizontal_bs[( x + y * s->bs_width) >> 2];
564  const int bs1 = s->horizontal_bs[((x + 4) + y * s->bs_width) >> 2];
565  if (bs0 || bs1) {
566  const int qp = (get_qPy(s, x, y - 1) + get_qPy(s, x, y) + 1) >> 1;
567 
568  tc_offset = x >= x0 ? cur_tc_offset : left_tc_offset;
569  beta_offset = x >= x0 ? cur_beta_offset : left_beta_offset;
570 
571  beta = betatable[av_clip(qp + beta_offset, 0, MAX_QP)];
572  tc[0] = bs0 ? TC_CALC(qp, bs0) : 0;
573  tc[1] = bs1 ? TC_CALC(qp, bs1) : 0;
574  src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->ps.sps->pixel_shift)];
575  if (pcmf) {
576  no_p[0] = get_pcm(s, x, y - 1);
577  no_p[1] = get_pcm(s, x + 4, y - 1);
578  no_q[0] = get_pcm(s, x, y);
579  no_q[1] = get_pcm(s, x + 4, y);
580  s->hevcdsp.hevc_h_loop_filter_luma_c(src,
581  s->frame->linesize[LUMA],
582  beta, tc, no_p, no_q);
583  } else
584  s->hevcdsp.hevc_h_loop_filter_luma(src,
585  s->frame->linesize[LUMA],
586  beta, tc, no_p, no_q);
587  }
588  }
589  }
590 
591  if (s->ps.sps->chroma_format_idc) {
592  for (chroma = 1; chroma <= 2; chroma++) {
593  int h = 1 << s->ps.sps->hshift[chroma];
594  int v = 1 << s->ps.sps->vshift[chroma];
595 
596  // vertical filtering chroma
597  for (y = y0; y < y_end; y += (8 * v)) {
598  for (x = x0 ? x0 : 8 * h; x < x_end; x += (8 * h)) {
599  const int bs0 = s->vertical_bs[(x + y * s->bs_width) >> 2];
600  const int bs1 = s->vertical_bs[(x + (y + (4 * v)) * s->bs_width) >> 2];
601 
602  if ((bs0 == 2) || (bs1 == 2)) {
603  const int qp0 = (get_qPy(s, x - 1, y) + get_qPy(s, x, y) + 1) >> 1;
604  const int qp1 = (get_qPy(s, x - 1, y + (4 * v)) + get_qPy(s, x, y + (4 * v)) + 1) >> 1;
605 
606  c_tc[0] = (bs0 == 2) ? chroma_tc(s, qp0, chroma, tc_offset) : 0;
607  c_tc[1] = (bs1 == 2) ? chroma_tc(s, qp1, chroma, tc_offset) : 0;
608  src = &s->frame->data[chroma][(y >> s->ps.sps->vshift[chroma]) * s->frame->linesize[chroma] + ((x >> s->ps.sps->hshift[chroma]) << s->ps.sps->pixel_shift)];
609  if (pcmf) {
610  no_p[0] = get_pcm(s, x - 1, y);
611  no_p[1] = get_pcm(s, x - 1, y + (4 * v));
612  no_q[0] = get_pcm(s, x, y);
613  no_q[1] = get_pcm(s, x, y + (4 * v));
614  s->hevcdsp.hevc_v_loop_filter_chroma_c(src,
615  s->frame->linesize[chroma],
616  c_tc, no_p, no_q);
617  } else
618  s->hevcdsp.hevc_v_loop_filter_chroma(src,
619  s->frame->linesize[chroma],
620  c_tc, no_p, no_q);
621  }
622  }
623 
624  if(!y)
625  continue;
626 
627  // horizontal filtering chroma
628  tc_offset = x0 ? left_tc_offset : cur_tc_offset;
629  x_end2 = x_end;
630  if (x_end != s->ps.sps->width)
631  x_end2 = x_end - 8 * h;
632  for (x = x0 ? x0 - 8 * h : 0; x < x_end2; x += (8 * h)) {
633  const int bs0 = s->horizontal_bs[( x + y * s->bs_width) >> 2];
634  const int bs1 = s->horizontal_bs[((x + 4 * h) + y * s->bs_width) >> 2];
635  if ((bs0 == 2) || (bs1 == 2)) {
636  const int qp0 = bs0 == 2 ? (get_qPy(s, x, y - 1) + get_qPy(s, x, y) + 1) >> 1 : 0;
637  const int qp1 = bs1 == 2 ? (get_qPy(s, x + (4 * h), y - 1) + get_qPy(s, x + (4 * h), y) + 1) >> 1 : 0;
638 
639  c_tc[0] = bs0 == 2 ? chroma_tc(s, qp0, chroma, tc_offset) : 0;
640  c_tc[1] = bs1 == 2 ? chroma_tc(s, qp1, chroma, cur_tc_offset) : 0;
641  src = &s->frame->data[chroma][(y >> s->ps.sps->vshift[1]) * s->frame->linesize[chroma] + ((x >> s->ps.sps->hshift[1]) << s->ps.sps->pixel_shift)];
642  if (pcmf) {
643  no_p[0] = get_pcm(s, x, y - 1);
644  no_p[1] = get_pcm(s, x + (4 * h), y - 1);
645  no_q[0] = get_pcm(s, x, y);
646  no_q[1] = get_pcm(s, x + (4 * h), y);
647  s->hevcdsp.hevc_h_loop_filter_chroma_c(src,
648  s->frame->linesize[chroma],
649  c_tc, no_p, no_q);
650  } else
651  s->hevcdsp.hevc_h_loop_filter_chroma(src,
652  s->frame->linesize[chroma],
653  c_tc, no_p, no_q);
654  }
655  }
656  }
657  }
658  }
659 }
660 
661 static int boundary_strength(HEVCContext *s, MvField *curr, MvField *neigh,
662  RefPicList *neigh_refPicList)
663 {
664  if (curr->pred_flag == PF_BI && neigh->pred_flag == PF_BI) {
665  // same L0 and L1
666  if (s->ref->refPicList[0].list[curr->ref_idx[0]] == neigh_refPicList[0].list[neigh->ref_idx[0]] &&
667  s->ref->refPicList[0].list[curr->ref_idx[0]] == s->ref->refPicList[1].list[curr->ref_idx[1]] &&
668  neigh_refPicList[0].list[neigh->ref_idx[0]] == neigh_refPicList[1].list[neigh->ref_idx[1]]) {
669  if ((FFABS(neigh->mv[0].x - curr->mv[0].x) >= 4 || FFABS(neigh->mv[0].y - curr->mv[0].y) >= 4 ||
670  FFABS(neigh->mv[1].x - curr->mv[1].x) >= 4 || FFABS(neigh->mv[1].y - curr->mv[1].y) >= 4) &&
671  (FFABS(neigh->mv[1].x - curr->mv[0].x) >= 4 || FFABS(neigh->mv[1].y - curr->mv[0].y) >= 4 ||
672  FFABS(neigh->mv[0].x - curr->mv[1].x) >= 4 || FFABS(neigh->mv[0].y - curr->mv[1].y) >= 4))
673  return 1;
674  else
675  return 0;
676  } else if (neigh_refPicList[0].list[neigh->ref_idx[0]] == s->ref->refPicList[0].list[curr->ref_idx[0]] &&
677  neigh_refPicList[1].list[neigh->ref_idx[1]] == s->ref->refPicList[1].list[curr->ref_idx[1]]) {
678  if (FFABS(neigh->mv[0].x - curr->mv[0].x) >= 4 || FFABS(neigh->mv[0].y - curr->mv[0].y) >= 4 ||
679  FFABS(neigh->mv[1].x - curr->mv[1].x) >= 4 || FFABS(neigh->mv[1].y - curr->mv[1].y) >= 4)
680  return 1;
681  else
682  return 0;
683  } else if (neigh_refPicList[1].list[neigh->ref_idx[1]] == s->ref->refPicList[0].list[curr->ref_idx[0]] &&
684  neigh_refPicList[0].list[neigh->ref_idx[0]] == s->ref->refPicList[1].list[curr->ref_idx[1]]) {
685  if (FFABS(neigh->mv[1].x - curr->mv[0].x) >= 4 || FFABS(neigh->mv[1].y - curr->mv[0].y) >= 4 ||
686  FFABS(neigh->mv[0].x - curr->mv[1].x) >= 4 || FFABS(neigh->mv[0].y - curr->mv[1].y) >= 4)
687  return 1;
688  else
689  return 0;
690  } else {
691  return 1;
692  }
693  } else if ((curr->pred_flag != PF_BI) && (neigh->pred_flag != PF_BI)){ // 1 MV
694  Mv A, B;
695  int ref_A, ref_B;
696 
697  if (curr->pred_flag & 1) {
698  A = curr->mv[0];
699  ref_A = s->ref->refPicList[0].list[curr->ref_idx[0]];
700  } else {
701  A = curr->mv[1];
702  ref_A = s->ref->refPicList[1].list[curr->ref_idx[1]];
703  }
704 
705  if (neigh->pred_flag & 1) {
706  B = neigh->mv[0];
707  ref_B = neigh_refPicList[0].list[neigh->ref_idx[0]];
708  } else {
709  B = neigh->mv[1];
710  ref_B = neigh_refPicList[1].list[neigh->ref_idx[1]];
711  }
712 
713  if (ref_A == ref_B) {
714  if (FFABS(A.x - B.x) >= 4 || FFABS(A.y - B.y) >= 4)
715  return 1;
716  else
717  return 0;
718  } else
719  return 1;
720  }
721 
722  return 1;
723 }
724 
726  int log2_trafo_size)
727 {
728  HEVCLocalContext *lc = s->HEVClc;
729  MvField *tab_mvf = s->ref->tab_mvf;
730  int log2_min_pu_size = s->ps.sps->log2_min_pu_size;
731  int log2_min_tu_size = s->ps.sps->log2_min_tb_size;
732  int min_pu_width = s->ps.sps->min_pu_width;
733  int min_tu_width = s->ps.sps->min_tb_width;
734  int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * min_pu_width +
735  (x0 >> log2_min_pu_size)].pred_flag == PF_INTRA;
736  int boundary_upper, boundary_left;
737  int i, j, bs;
738 
739  boundary_upper = y0 > 0 && !(y0 & 7);
740  if (boundary_upper &&
741  ((!s->sh.slice_loop_filter_across_slices_enabled_flag &&
743  (y0 % (1 << s->ps.sps->log2_ctb_size)) == 0) ||
744  (!s->ps.pps->loop_filter_across_tiles_enabled_flag &&
746  (y0 % (1 << s->ps.sps->log2_ctb_size)) == 0)))
747  boundary_upper = 0;
748 
749  if (boundary_upper) {
750  RefPicList *rpl_top = (lc->boundary_flags & BOUNDARY_UPPER_SLICE) ?
751  ff_hevc_get_ref_list(s, s->ref, x0, y0 - 1) :
752  s->ref->refPicList;
753  int yp_pu = (y0 - 1) >> log2_min_pu_size;
754  int yq_pu = y0 >> log2_min_pu_size;
755  int yp_tu = (y0 - 1) >> log2_min_tu_size;
756  int yq_tu = y0 >> log2_min_tu_size;
757 
758  for (i = 0; i < (1 << log2_trafo_size); i += 4) {
759  int x_pu = (x0 + i) >> log2_min_pu_size;
760  int x_tu = (x0 + i) >> log2_min_tu_size;
761  MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu];
762  MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu];
763  uint8_t top_cbf_luma = s->cbf_luma[yp_tu * min_tu_width + x_tu];
764  uint8_t curr_cbf_luma = s->cbf_luma[yq_tu * min_tu_width + x_tu];
765 
766  if (curr->pred_flag == PF_INTRA || top->pred_flag == PF_INTRA)
767  bs = 2;
768  else if (curr_cbf_luma || top_cbf_luma)
769  bs = 1;
770  else
771  bs = boundary_strength(s, curr, top, rpl_top);
772  s->horizontal_bs[((x0 + i) + y0 * s->bs_width) >> 2] = bs;
773  }
774  }
775 
776  // bs for vertical TU boundaries
777  boundary_left = x0 > 0 && !(x0 & 7);
778  if (boundary_left &&
779  ((!s->sh.slice_loop_filter_across_slices_enabled_flag &&
781  (x0 % (1 << s->ps.sps->log2_ctb_size)) == 0) ||
782  (!s->ps.pps->loop_filter_across_tiles_enabled_flag &&
784  (x0 % (1 << s->ps.sps->log2_ctb_size)) == 0)))
785  boundary_left = 0;
786 
787  if (boundary_left) {
788  RefPicList *rpl_left = (lc->boundary_flags & BOUNDARY_LEFT_SLICE) ?
789  ff_hevc_get_ref_list(s, s->ref, x0 - 1, y0) :
790  s->ref->refPicList;
791  int xp_pu = (x0 - 1) >> log2_min_pu_size;
792  int xq_pu = x0 >> log2_min_pu_size;
793  int xp_tu = (x0 - 1) >> log2_min_tu_size;
794  int xq_tu = x0 >> log2_min_tu_size;
795 
796  for (i = 0; i < (1 << log2_trafo_size); i += 4) {
797  int y_pu = (y0 + i) >> log2_min_pu_size;
798  int y_tu = (y0 + i) >> log2_min_tu_size;
799  MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu];
800  MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu];
801  uint8_t left_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xp_tu];
802  uint8_t curr_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xq_tu];
803 
804  if (curr->pred_flag == PF_INTRA || left->pred_flag == PF_INTRA)
805  bs = 2;
806  else if (curr_cbf_luma || left_cbf_luma)
807  bs = 1;
808  else
809  bs = boundary_strength(s, curr, left, rpl_left);
810  s->vertical_bs[(x0 + (y0 + i) * s->bs_width) >> 2] = bs;
811  }
812  }
813 
814  if (log2_trafo_size > log2_min_pu_size && !is_intra) {
815  RefPicList *rpl = s->ref->refPicList;
816 
817  // bs for TU internal horizontal PU boundaries
818  for (j = 8; j < (1 << log2_trafo_size); j += 8) {
819  int yp_pu = (y0 + j - 1) >> log2_min_pu_size;
820  int yq_pu = (y0 + j) >> log2_min_pu_size;
821 
822  for (i = 0; i < (1 << log2_trafo_size); i += 4) {
823  int x_pu = (x0 + i) >> log2_min_pu_size;
824  MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu];
825  MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu];
826 
827  bs = boundary_strength(s, curr, top, rpl);
828  s->horizontal_bs[((x0 + i) + (y0 + j) * s->bs_width) >> 2] = bs;
829  }
830  }
831 
832  // bs for TU internal vertical PU boundaries
833  for (j = 0; j < (1 << log2_trafo_size); j += 4) {
834  int y_pu = (y0 + j) >> log2_min_pu_size;
835 
836  for (i = 8; i < (1 << log2_trafo_size); i += 8) {
837  int xp_pu = (x0 + i - 1) >> log2_min_pu_size;
838  int xq_pu = (x0 + i) >> log2_min_pu_size;
839  MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu];
840  MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu];
841 
842  bs = boundary_strength(s, curr, left, rpl);
843  s->vertical_bs[((x0 + i) + (y0 + j) * s->bs_width) >> 2] = bs;
844  }
845  }
846  }
847 }
848 
849 #undef LUMA
850 #undef CB
851 #undef CR
852 
853 void ff_hevc_hls_filter(HEVCContext *s, int x, int y, int ctb_size)
854 {
855  int x_end = x >= s->ps.sps->width - ctb_size;
856  int skip = 0;
857  if (s->avctx->skip_loop_filter >= AVDISCARD_ALL ||
858  (s->avctx->skip_loop_filter >= AVDISCARD_NONKEY && !IS_IDR(s)) ||
859  (s->avctx->skip_loop_filter >= AVDISCARD_NONINTRA &&
860  s->sh.slice_type != HEVC_SLICE_I) ||
861  (s->avctx->skip_loop_filter >= AVDISCARD_BIDIR &&
862  s->sh.slice_type == HEVC_SLICE_B) ||
863  (s->avctx->skip_loop_filter >= AVDISCARD_NONREF &&
864  ff_hevc_nal_is_nonref(s->nal_unit_type)))
865  skip = 1;
866 
867  if (!skip)
868  deblocking_filter_CTB(s, x, y);
869  if (s->ps.sps->sao_enabled && !skip) {
870  int y_end = y >= s->ps.sps->height - ctb_size;
871  if (y && x)
872  sao_filter_CTB(s, x - ctb_size, y - ctb_size);
873  if (x && y_end)
874  sao_filter_CTB(s, x - ctb_size, y);
875  if (y && x_end) {
876  sao_filter_CTB(s, x, y - ctb_size);
877  if (s->threads_type & FF_THREAD_FRAME )
878  ff_thread_report_progress(&s->ref->tf, y, 0);
879  }
880  if (x_end && y_end) {
881  sao_filter_CTB(s, x , y);
882  if (s->threads_type & FF_THREAD_FRAME )
883  ff_thread_report_progress(&s->ref->tf, y + ctb_size, 0);
884  }
885  } else if (s->threads_type & FF_THREAD_FRAME && x_end)
886  ff_thread_report_progress(&s->ref->tf, y + ctb_size - 4, 0);
887 }
888 
889 void ff_hevc_hls_filters(HEVCContext *s, int x_ctb, int y_ctb, int ctb_size)
890 {
891  int x_end = x_ctb >= s->ps.sps->width - ctb_size;
892  int y_end = y_ctb >= s->ps.sps->height - ctb_size;
893  if (y_ctb && x_ctb)
894  ff_hevc_hls_filter(s, x_ctb - ctb_size, y_ctb - ctb_size, ctb_size);
895  if (y_ctb && x_end)
896  ff_hevc_hls_filter(s, x_ctb, y_ctb - ctb_size, ctb_size);
897  if (x_ctb && y_end)
898  ff_hevc_hls_filter(s, x_ctb - ctb_size, y_ctb, ctb_size);
899 }
#define A(x)
Definition: vp56_arith.h:28
uint8_t
int32_t
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Definition: avassert.h:64
#define FF_THREAD_FRAME
Decode more than one frame at once.
Definition: avcodec.h:1788
Context Adaptive Binary Arithmetic Coder inline functions.
#define s(width, name)
Definition: cbs_vp9.c:257
common internal and external API header
#define FFMIN(a, b)
Definition: common.h:105
#define av_clip
Definition: common.h:122
#define FFUMOD(a, b)
Definition: common.h:64
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
Definition: avcodec.h:215
@ AVDISCARD_ALL
discard all
Definition: avcodec.h:236
@ AVDISCARD_NONKEY
discard all frames except keyframes
Definition: avcodec.h:235
@ AVDISCARD_BIDIR
discard all bidirectional frames
Definition: avcodec.h:233
@ AVDISCARD_NONINTRA
discard all non intra frames
Definition: avcodec.h:234
@ AVDISCARD_NONREF
discard all non reference
Definition: avcodec.h:232
for(j=16;j >0;--j)
static void copy_pixel(uint8_t *dst, const uint8_t *src, int pixel_shift)
Definition: hevc_filter.c:174
#define LUMA
Definition: hevc_filter.c:33
static const uint8_t betatable[52]
Definition: hevc_filter.c:43
#define TC_CALC(qp, bs)
Definition: hevc_filter.c:482
static void copy_vert(uint8_t *dst, const uint8_t *src, int pixel_shift, int height, ptrdiff_t stride_dst, ptrdiff_t stride_src)
Definition: hevc_filter.c:182
static int get_qPy(HEVCContext *s, int xC, int yC)
Definition: hevc_filter.c:133
void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, int log2_trafo_size)
Definition: hevc_filter.c:725
static const uint8_t tctable[54]
Definition: hevc_filter.c:37
void ff_hevc_set_qPy(HEVCContext *s, int xBase, int yBase, int log2_cb_size)
Definition: hevc_filter.c:121
static int get_pcm(HEVCContext *s, int x, int y)
Definition: hevc_filter.c:466
void ff_hevc_hls_filters(HEVCContext *s, int x_ctb, int y_ctb, int ctb_size)
Definition: hevc_filter.c:889
static int get_qPy_pred(HEVCContext *s, int xBase, int yBase, int log2_cb_size)
Definition: hevc_filter.c:78
static void sao_filter_CTB(HEVCContext *s, int x, int y)
Definition: hevc_filter.c:257
#define CTB(tab, x, y)
Definition: hevc_filter.c:255
static void copy_CTB(uint8_t *dst, const uint8_t *src, int width, int height, ptrdiff_t stride_dst, ptrdiff_t stride_src)
Definition: hevc_filter.c:141
static void copy_CTB_to_hv(HEVCContext *s, const uint8_t *src, ptrdiff_t stride_src, int x, int y, int width, int height, int c_idx, int x_ctb, int y_ctb)
Definition: hevc_filter.c:202
void ff_hevc_hls_filter(HEVCContext *s, int x, int y, int ctb_size)
Definition: hevc_filter.c:853
static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
Definition: hevc_filter.c:487
static int chroma_tc(HEVCContext *s, int qp_y, int c_idx, int tc_offset)
Definition: hevc_filter.c:49
static int boundary_strength(HEVCContext *s, MvField *curr, MvField *neigh, RefPicList *neigh_refPicList)
Definition: hevc_filter.c:661
static void restore_tqb_pixels(HEVCContext *s, uint8_t *src1, const uint8_t *dst1, ptrdiff_t stride_src, ptrdiff_t stride_dst, int x0, int y0, int width, int height, int c_idx)
Definition: hevc_filter.c:222
RefPicList * ff_hevc_get_ref_list(HEVCContext *s, HEVCFrame *ref, int x0, int y0)
Definition: hevc_refs.c:57
#define BOUNDARY_UPPER_SLICE
Definition: hevcdec.h:461
#define IS_IDR(s)
Definition: hevcdec.h:78
#define BOUNDARY_LEFT_TILE
Definition: hevcdec.h:460
@ PF_BI
Definition: hevcdec.h:171
@ PF_INTRA
Definition: hevcdec.h:168
#define MAX_QP
Definition: hevcdec.h:52
@ SAO_BAND
Definition: hevcdec.h:214
@ SAO_EDGE
Definition: hevcdec.h:215
@ SAO_APPLIED
Definition: hevcdec.h:216
static av_always_inline int ff_hevc_nal_is_nonref(enum HEVCNALUnitType type)
Definition: hevcdec.h:638
#define DEFAULT_INTRA_TC_OFFSET
Definition: hevcdec.h:53
#define BOUNDARY_UPPER_TILE
Definition: hevcdec.h:462
#define BOUNDARY_LEFT_SLICE
Definition: hevcdec.h:459
#define MAX_PB_SIZE
Definition: hevcdsp.h:32
#define B
Definition: huffyuvdsp.h:32
int i
Definition: input.c:407
#define AV_COPY128(d, s)
Definition: intreadwrite.h:609
#define AV_COPY64U(d, s)
Definition: intreadwrite.h:576
@ HEVC_SLICE_I
Definition: hevc.h:98
@ HEVC_SLICE_B
Definition: hevc.h:96
common internal API header
uint8_t w
Definition: llviddspenc.c:39
#define FFALIGN(x, a)
Definition: macros.h:48
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
#define tc
Definition: regdef.h:69
unsigned int pos
Definition: spdifenc.c:412
uint8_t edge_emu_buffer[(MAX_PB_SIZE+7) *EDGE_EMU_BUFFER_STRIDE *2]
Definition: hevcdec.h:449
TransformUnit tu
Definition: hevcdec.h:440
uint8_t first_qp_group
Definition: hevcdec.h:430
int boundary_flags
Definition: hevcdec.h:465
int8_t pred_flag
Definition: hevcdec.h:348
Mv mv[2]
Definition: hevcdec.h:346
int8_t ref_idx[2]
Definition: hevcdec.h:347
Definition: hevcdec.h:340
int16_t x
horizontal component of motion vector
Definition: hevcdec.h:341
int16_t y
vertical component of motion vector
Definition: hevcdec.h:342
int list[HEVC_MAX_REFS]
Definition: hevcdec.h:241
int eo_class[3]
sao_eo_class
Definition: hevcdsp.h:40
uint8_t type_idx[3]
sao_type_idx
Definition: hevcdsp.h:44
int16_t offset_val[3][5]
SaoOffsetVal.
Definition: hevcdsp.h:42
uint8_t band_position[3]
sao_band_position
Definition: hevcdsp.h:38
uint8_t is_cu_qp_delta_coded
Definition: hevcdec.h:379
#define src1
Definition: h264pred.c:140
#define src
Definition: vp8dsp.c:255
#define height
#define width
static const struct twinvq_data tab
if(ret< 0)
Definition: vf_mcdeint.c:282
static const uint8_t offset[127][2]
Definition: vf_spp.c:107
static av_always_inline void chroma(WaveformContext *s, AVFrame *in, AVFrame *out, int component, int intensity, int offset_y, int offset_x, int column, int mirror, int jobnr, int nb_jobs)
Definition: vf_waveform.c:1624
int len