38 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
39 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4,
40 5, 5, 6, 6, 7, 8, 9, 10, 11, 13, 14, 16, 18, 20, 22, 24
44 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8,
45 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36,
46 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64
51 static const int qp_c[] = {
52 29, 30, 31, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37
54 int qp, qp_i,
offset, idxt;
58 offset =
s->ps.pps->cb_qp_offset;
60 offset =
s->ps.pps->cr_qp_offset;
63 if (
s->ps.sps->chroma_format_idc == 1) {
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;
98 qPy_pred =
s->sh.slice_qp;
107 qPy_a =
s->qp_y_tab[(x_cb - 1) + y_cb * min_cb_width];
113 qPy_b =
s->qp_y_tab[x_cb + (y_cb - 1) * min_cb_width];
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);
118 return (qPy_a + qPy_b + 1) >> 1;
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,
130 s->HEVClc->qp_y = qp_y;
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];
142 ptrdiff_t stride_dst, ptrdiff_t stride_src)
146 if (((intptr_t)dst | (intptr_t)
src | stride_dst | stride_src) & 15) {
148 for (j = 0; j <
width - 7; j+=8)
158 for (j = 0; j <
width; j++)
166 for (j = 0; j <
width; j+=16)
177 *(uint16_t *)dst = *(uint16_t *)
src;
183 int pixel_shift,
int height,
184 ptrdiff_t stride_dst, ptrdiff_t stride_src)
187 if (pixel_shift == 0) {
195 *(uint16_t *)dst = *(uint16_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)
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];
211 memcpy(
s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb) *
w + x) << sh),
213 memcpy(
s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb + 1) *
w + x) << sh),
217 copy_vert(
s->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb) *
h + y) << sh),
src, sh,
height, 1 << sh, stride_src);
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);
224 ptrdiff_t stride_src, ptrdiff_t stride_dst,
227 if (
s->ps.pps->transquant_bypass_enable_flag ||
228 (
s->ps.sps->pcm.loop_filter_disable_flag &&
s->ps.sps->pcm_enabled_flag)) {
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]) {
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++) {
255 #define CTB(tab, x, y) ((tab)[(y) * s->ps.sps->ctb_width + (x)])
259 static const uint8_t sao_tab[8] = { 0, 1, 2, 2, 3, 3, 4, 4 };
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];
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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);
326 uint8_t *
src = &
s->frame->data[c_idx][y0 * stride_src + (x0 <<
s->ps.sps->pixel_shift)];
327 ptrdiff_t stride_dst;
334 if (
s->ps.pps->transquant_bypass_enable_flag ||
335 (
s->ps.sps->pcm.loop_filter_disable_flag &&
s->ps.sps->pcm_enabled_flag)) {
339 s->hevcdsp.sao_band_filter[
tab](
src, dst, stride_src, stride_dst,
345 s->hevcdsp.sao_band_filter[
tab](
src,
src, stride_src, stride_src,
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;
366 int left = 1 - left_edge;
367 int right = 1 - right_edge;
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);
377 src_idx = (
CTB(
s->sao, x_ctb-1, y_ctb-1).type_idx[c_idx] ==
382 src_idx = (
CTB(
s->sao, x_ctb, y_ctb-1).type_idx[c_idx] ==
387 src_idx = (
CTB(
s->sao, x_ctb+1, y_ctb-1).type_idx[c_idx] ==
393 int left = 1 - left_edge;
394 int right = 1 - right_edge;
399 dst1 = dst +
height * stride_dst - (left << sh);
401 src1[1] =
s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb + 2) *
w + x0 - left) << sh);
404 src_idx = (
CTB(
s->sao, x_ctb-1, y_ctb+1).type_idx[c_idx] ==
409 src_idx = (
CTB(
s->sao, x_ctb, y_ctb+1).type_idx[c_idx] ==
414 src_idx = (
CTB(
s->sao, x_ctb+1, y_ctb+1).type_idx[c_idx] ==
423 s->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb - 1) *
h + y0) << sh),
424 sh,
height, stride_dst, 1 << sh);
433 s->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb + 2) *
h + y0) << sh),
434 sh,
height, stride_dst, 1 << sh);
441 src - (left_pixels << sh),
442 (
width + left_pixels + right_pixels) << sh,
443 height, stride_dst, stride_src);
449 s->hevcdsp.sao_edge_restore[restore](
src, dst,
450 stride_src, stride_dst,
468 int log2_min_pu_size =
s->ps.sps->log2_min_pu_size;
474 x_pu = x >> log2_min_pu_size;
475 y_pu = y >> log2_min_pu_size;
477 if (x_pu >=
s->ps.sps->min_pu_width || y_pu >=
s->ps.sps->min_pu_height)
479 return s->is_pcm[y_pu *
s->ps.sps->min_pu_width + x_pu];
482 #define TC_CALC(qp, bs) \
483 tctable[av_clip((qp) + DEFAULT_INTRA_TC_OFFSET * ((bs) - 1) + \
485 0, MAX_QP + DEFAULT_INTRA_TC_OFFSET)]
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;
510 left_tc_offset =
s->deblock[ctb - 1].tc_offset;
511 left_beta_offset =
s->deblock[ctb - 1].beta_offset;
514 left_beta_offset = 0;
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;
524 tc_offset = cur_tc_offset;
525 beta_offset = cur_beta_offset;
528 if (x_end2 !=
s->ps.sps->width)
530 for (y = y0; y < y_end; y += 8) {
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];
542 src = &
s->frame->data[
LUMA][y *
s->frame->linesize[
LUMA] + (x <<
s->ps.sps->pixel_shift)];
548 s->hevcdsp.hevc_v_loop_filter_luma_c(
src,
549 s->frame->linesize[
LUMA],
550 beta,
tc, no_p, no_q);
552 s->hevcdsp.hevc_v_loop_filter_luma(
src,
553 s->frame->linesize[
LUMA],
554 beta,
tc, no_p, no_q);
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];
568 tc_offset = x >= x0 ? cur_tc_offset : left_tc_offset;
569 beta_offset = x >= x0 ? cur_beta_offset : left_beta_offset;
574 src = &
s->frame->data[
LUMA][y *
s->frame->linesize[
LUMA] + (x <<
s->ps.sps->pixel_shift)];
580 s->hevcdsp.hevc_h_loop_filter_luma_c(
src,
581 s->frame->linesize[
LUMA],
582 beta,
tc, no_p, no_q);
584 s->hevcdsp.hevc_h_loop_filter_luma(
src,
585 s->frame->linesize[
LUMA],
586 beta,
tc, no_p, no_q);
591 if (
s->ps.sps->chroma_format_idc) {
593 int h = 1 <<
s->ps.sps->hshift[
chroma];
594 int v = 1 <<
s->ps.sps->vshift[
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];
602 if ((bs0 == 2) || (bs1 == 2)) {
604 const int qp1 = (
get_qPy(
s, x - 1, y + (4 * v)) +
get_qPy(
s, x, y + (4 * v)) + 1) >> 1;
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)];
611 no_p[1] =
get_pcm(
s, x - 1, y + (4 * v));
613 no_q[1] =
get_pcm(
s, x, y + (4 * v));
614 s->hevcdsp.hevc_v_loop_filter_chroma_c(
src,
618 s->hevcdsp.hevc_v_loop_filter_chroma(
src,
628 tc_offset = x0 ? left_tc_offset : cur_tc_offset;
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;
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)];
644 no_p[1] =
get_pcm(
s, x + (4 *
h), y - 1);
647 s->hevcdsp.hevc_h_loop_filter_chroma_c(
src,
651 s->hevcdsp.hevc_h_loop_filter_chroma(
src,
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]] &&
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]]) {
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]]) {
699 ref_A =
s->ref->refPicList[0].list[curr->
ref_idx[0]];
702 ref_A =
s->ref->refPicList[1].list[curr->
ref_idx[1]];
707 ref_B = neigh_refPicList[0].
list[neigh->
ref_idx[0]];
710 ref_B = neigh_refPicList[1].
list[neigh->
ref_idx[1]];
713 if (ref_A == ref_B) {
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 +
736 int boundary_upper, boundary_left;
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)))
749 if (boundary_upper) {
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;
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];
768 else if (curr_cbf_luma || top_cbf_luma)
772 s->horizontal_bs[((x0 +
i) + y0 *
s->bs_width) >> 2] = bs;
777 boundary_left = x0 > 0 && !(x0 & 7);
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)))
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;
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];
806 else if (curr_cbf_luma || left_cbf_luma)
810 s->vertical_bs[(x0 + (y0 +
i) *
s->bs_width) >> 2] = bs;
814 if (log2_trafo_size > log2_min_pu_size && !is_intra) {
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;
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];
828 s->horizontal_bs[((x0 +
i) + (y0 + j) *
s->bs_width) >> 2] = bs;
833 for (j = 0; j < (1 << log2_trafo_size); j += 4) {
834 int y_pu = (y0 + j) >> log2_min_pu_size;
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];
843 s->vertical_bs[((x0 +
i) + (y0 + j) *
s->bs_width) >> 2] = bs;
855 int x_end = x >=
s->ps.sps->width - ctb_size;
869 if (
s->ps.sps->sao_enabled && !skip) {
870 int y_end = y >=
s->ps.sps->height - ctb_size;
880 if (x_end && y_end) {
891 int x_end = x_ctb >=
s->ps.sps->width - ctb_size;
892 int y_end = y_ctb >=
s->ps.sps->height - ctb_size;
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define FF_THREAD_FRAME
Decode more than one frame at once.
Context Adaptive Binary Arithmetic Coder inline functions.
common internal and external API header
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
@ AVDISCARD_ALL
discard all
@ AVDISCARD_NONKEY
discard all frames except keyframes
@ AVDISCARD_BIDIR
discard all bidirectional frames
@ AVDISCARD_NONINTRA
discard all non intra frames
@ AVDISCARD_NONREF
discard all non reference
static void copy_pixel(uint8_t *dst, const uint8_t *src, int pixel_shift)
static const uint8_t betatable[52]
static void copy_vert(uint8_t *dst, const uint8_t *src, int pixel_shift, int height, ptrdiff_t stride_dst, ptrdiff_t stride_src)
static int get_qPy(HEVCContext *s, int xC, int yC)
void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, int log2_trafo_size)
static const uint8_t tctable[54]
void ff_hevc_set_qPy(HEVCContext *s, int xBase, int yBase, int log2_cb_size)
static int get_pcm(HEVCContext *s, int x, int y)
void ff_hevc_hls_filters(HEVCContext *s, int x_ctb, int y_ctb, int ctb_size)
static int get_qPy_pred(HEVCContext *s, int xBase, int yBase, int log2_cb_size)
static void sao_filter_CTB(HEVCContext *s, int x, int y)
static void copy_CTB(uint8_t *dst, const uint8_t *src, int width, int height, ptrdiff_t stride_dst, ptrdiff_t stride_src)
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)
void ff_hevc_hls_filter(HEVCContext *s, int x, int y, int ctb_size)
static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
static int chroma_tc(HEVCContext *s, int qp_y, int c_idx, int tc_offset)
static int boundary_strength(HEVCContext *s, MvField *curr, MvField *neigh, RefPicList *neigh_refPicList)
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)
RefPicList * ff_hevc_get_ref_list(HEVCContext *s, HEVCFrame *ref, int x0, int y0)
#define BOUNDARY_UPPER_SLICE
#define BOUNDARY_LEFT_TILE
static av_always_inline int ff_hevc_nal_is_nonref(enum HEVCNALUnitType type)
#define DEFAULT_INTRA_TC_OFFSET
#define BOUNDARY_UPPER_TILE
#define BOUNDARY_LEFT_SLICE
common internal API header
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
uint8_t edge_emu_buffer[(MAX_PB_SIZE+7) *EDGE_EMU_BUFFER_STRIDE *2]
int16_t x
horizontal component of motion vector
int16_t y
vertical component of motion vector
int eo_class[3]
sao_eo_class
uint8_t type_idx[3]
sao_type_idx
int16_t offset_val[3][5]
SaoOffsetVal.
uint8_t band_position[3]
sao_band_position
static const struct twinvq_data tab
static const uint8_t offset[127][2]