39 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
40 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4,
41 5, 5, 6, 6, 7, 8, 9, 10, 11, 13, 14, 16, 18, 20, 22, 24
45 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8,
46 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36,
47 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64
52 static const int qp_c[] = {
53 29, 30, 31, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37
55 int qp, qp_i,
offset, idxt;
63 qp_i = av_clip(qp_y + offset, 0, 57);
72 qp = av_clip(qp_i, 0, 51);
85 int xQgBase = xBase - (xBase & MinCuQpDeltaSizeMask);
86 int yQgBase = yBase - (yBase & MinCuQpDeltaSizeMask);
90 int availableA = (xBase & ctb_size_mask) &&
91 (xQgBase & ctb_size_mask);
92 int availableB = (yBase & ctb_size_mask) &&
93 (yQgBase & ctb_size_mask);
94 int qPy_pred, qPy_a, qPy_b;
108 qPy_a = s->
qp_y_tab[(x_cb - 1) + y_cb * min_cb_width];
114 qPy_b = s->
qp_y_tab[x_cb + (y_cb - 1) * min_cb_width];
119 return (qPy_a + qPy_b + 1) >> 1;
137 int x = xC >> log2_min_cb_size;
138 int y = yC >> log2_min_cb_size;
143 int width,
int height,
int stride_dst,
int stride_src)
147 for (i = 0; i <
height; i++) {
148 memcpy(dst, src, width);
168 int len = min_pu_size >> hshift;
169 for (y = y_min; y < y_max; y++) {
170 for (x = x_min; x < x_max; x++) {
175 for (n = 0; n < (min_pu_size >> vshift); n++) {
176 memcpy(src, dst, len);
186 #define CTB(tab, x, y) ((tab)[(y) * s->sps->ctb_width + (x)])
198 uint8_t vert_edge[] = { 0, 0 };
199 uint8_t horiz_edge[] = { 0, 0 };
200 uint8_t diag_edge[] = { 0, 0, 0, 0 };
204 uint8_t restore = no_tile_filter || !lfase;
210 edges[0] = x_ctb == 0;
211 edges[1] = y_ctb == 0;
232 if (!edges[0] && !edges[1]) {
235 if (!edges[1] && !edges[2]) {
238 if (!edges[2] && !edges[3]) {
241 if (!edges[0] && !edges[3]) {
246 for (c_idx = 0; c_idx < 3; c_idx++) {
262 stride_src, stride_dst,
275 if (
CTB(s->
sao, x_ctb , y_ctb-1).type_idx[c_idx] == 0)
292 memcpy( dst + height * stride_dst - (bottom_left << s->
sps->
pixel_shift),
298 (width + 1 + left_pixels) << s->
sps->
pixel_shift, height, stride_dst, stride_src);
300 stride_src, stride_dst,
323 x_pu = x >> log2_min_pu_size;
324 y_pu = y >> log2_min_pu_size;
331 #define TC_CALC(qp, bs) \
332 tctable[av_clip((qp) + DEFAULT_INTRA_TC_OFFSET * ((bs) - 1) + \
333 (tc_offset >> 1 << 1), \
334 0, MAX_QP + DEFAULT_INTRA_TC_OFFSET)]
346 int x_end, x_end2, y_end;
347 int ctb_size = 1 << log2_ctb_size;
348 int ctb = (x0 >> log2_ctb_size) +
352 int left_tc_offset, left_beta_offset;
353 int tc_offset, beta_offset;
363 left_beta_offset = 0;
366 x_end = x0 + ctb_size;
369 y_end = y0 + ctb_size;
373 tc_offset = cur_tc_offset;
374 beta_offset = cur_beta_offset;
379 for (y = y0; y < y_end; y += 8) {
381 for (x = x0 ? x0 : 8; x < x_end; x += 8) {
385 const int qp = (
get_qPy(s, x - 1, y) +
get_qPy(s, x, y) + 1) >> 1;
389 tc[0] = bs0 ?
TC_CALC(qp, bs0) : 0;
390 tc[1] = bs1 ?
TC_CALC(qp, bs1) : 0;
393 no_p[0] =
get_pcm(s, x - 1, y);
394 no_p[1] =
get_pcm(s, x - 1, y + 4);
396 no_q[1] =
get_pcm(s, x, y + 4);
399 beta, tc, no_p, no_q);
403 beta, tc, no_p, no_q);
411 for (x = x0 ? x0 - 8 : 0; x < x_end2; x += 8) {
415 const int qp = (
get_qPy(s, x, y - 1) +
get_qPy(s, x, y) + 1) >> 1;
417 tc_offset = x >= x0 ? cur_tc_offset : left_tc_offset;
418 beta_offset = x >= x0 ? cur_beta_offset : left_beta_offset;
421 tc[0] = bs0 ?
TC_CALC(qp, bs0) : 0;
422 tc[1] = bs1 ?
TC_CALC(qp, bs1) : 0;
425 no_p[0] =
get_pcm(s, x, y - 1);
426 no_p[1] =
get_pcm(s, x + 4, y - 1);
428 no_q[1] =
get_pcm(s, x + 4, y);
431 beta, tc, no_p, no_q);
435 beta, tc, no_p, no_q);
440 for (chroma = 1; chroma <= 2; chroma++) {
445 for (y = y0; y < y_end; y += (8 *
v)) {
446 for (x = x0 ? x0 : 8 * h; x < x_end; x += (8 * h)) {
450 if ((bs0 == 2) || (bs1 == 2)) {
451 const int qp0 = (
get_qPy(s, x - 1, y) +
get_qPy(s, x, y) + 1) >> 1;
452 const int qp1 = (
get_qPy(s, x - 1, y + (4 * v)) +
get_qPy(s, x, y + (4 * v)) + 1) >> 1;
454 c_tc[0] = (bs0 == 2) ?
chroma_tc(s, qp0, chroma, tc_offset) : 0;
455 c_tc[1] = (bs1 == 2) ?
chroma_tc(s, qp1, chroma, tc_offset) : 0;
458 no_p[0] =
get_pcm(s, x - 1, y);
459 no_p[1] =
get_pcm(s, x - 1, y + (4 * v));
461 no_q[1] =
get_pcm(s, x, y + (4 * v));
476 tc_offset = x0 ? left_tc_offset : cur_tc_offset;
479 x_end2 = x_end - 8 * h;
480 for (x = x0 ? x0 - 8 * h : 0; x < x_end2; x += (8 * h)) {
483 if ((bs0 == 2) || (bs1 == 2)) {
484 const int qp0 = bs0 == 2 ? (
get_qPy(s, x, y - 1) +
get_qPy(s, x, y) + 1) >> 1 : 0;
485 const int qp1 = bs1 == 2 ? (
get_qPy(s, x + (4 * h), y - 1) +
get_qPy(s, x + (4 * h), y) + 1) >> 1 : 0;
487 c_tc[0] = bs0 == 2 ?
chroma_tc(s, qp0, chroma, tc_offset) : 0;
488 c_tc[1] = bs1 == 2 ?
chroma_tc(s, qp1, chroma, cur_tc_offset) : 0;
491 no_p[0] =
get_pcm(s, x, y - 1);
492 no_p[1] =
get_pcm(s, x + (4 * h), y - 1);
494 no_q[1] =
get_pcm(s, x + (4 * h), y);
554 ref_B = neigh_refPicList[0].
list[neigh->
ref_idx[0]];
557 ref_B = neigh_refPicList[1].
list[neigh->
ref_idx[1]];
560 if (ref_A == ref_B) {
581 int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * min_pu_width +
583 int boundary_upper, boundary_left;
586 boundary_upper = y0 > 0 && !(y0 & 7);
587 if (boundary_upper &&
596 if (boundary_upper) {
600 int yp_pu = (y0 - 1) >> log2_min_pu_size;
601 int yq_pu = y0 >> log2_min_pu_size;
602 int yp_tu = (y0 - 1) >> log2_min_tu_size;
603 int yq_tu = y0 >> log2_min_tu_size;
605 for (i = 0; i < (1 << log2_trafo_size); i += 4) {
606 int x_pu = (x0 + i) >> log2_min_pu_size;
607 int x_tu = (x0 + i) >> log2_min_tu_size;
608 MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu];
609 MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu];
615 else if (curr_cbf_luma || top_cbf_luma)
624 boundary_left = x0 > 0 && !(x0 & 7);
638 int xp_pu = (x0 - 1) >> log2_min_pu_size;
639 int xq_pu = x0 >> log2_min_pu_size;
640 int xp_tu = (x0 - 1) >> log2_min_tu_size;
641 int xq_tu = x0 >> log2_min_tu_size;
643 for (i = 0; i < (1 << log2_trafo_size); i += 4) {
644 int y_pu = (y0 + i) >> log2_min_pu_size;
645 int y_tu = (y0 + i) >> log2_min_tu_size;
646 MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu];
647 MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu];
653 else if (curr_cbf_luma || left_cbf_luma)
661 if (log2_trafo_size > log2_min_pu_size && !is_intra) {
665 for (j = 8; j < (1 << log2_trafo_size); j += 8) {
666 int yp_pu = (y0 + j - 1) >> log2_min_pu_size;
667 int yq_pu = (y0 + j) >> log2_min_pu_size;
669 for (i = 0; i < (1 << log2_trafo_size); i += 4) {
670 int x_pu = (x0 + i) >> log2_min_pu_size;
671 MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu];
672 MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu];
680 for (j = 0; j < (1 << log2_trafo_size); j += 4) {
681 int y_pu = (y0 + j) >> log2_min_pu_size;
683 for (i = 8; i < (1 << log2_trafo_size); i += 8) {
684 int xp_pu = (x0 + i - 1) >> log2_min_pu_size;
685 int xq_pu = (x0 + i) >> log2_min_pu_size;
686 MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu];
687 MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu];
702 int x_end = x >= s->
sps->
width - ctb_size;
705 int y_end = y >= s->
sps->
height - ctb_size;
715 if (x_end && y_end) {
726 int x_end = x_ctb >= s->
sps->
width - ctb_size;
727 int y_end = y_ctb >= s->
sps->
height - ctb_size;