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;
76 int xBase,
int yBase,
int log2_cb_size)
82 int xQgBase = xBase - (xBase & MinCuQpDeltaSizeMask);
83 int yQgBase = yBase - (yBase & MinCuQpDeltaSizeMask);
87 int availableA = (xBase & ctb_size_mask) &&
88 (xQgBase & ctb_size_mask);
89 int availableB = (yBase & ctb_size_mask) &&
90 (yQgBase & ctb_size_mask);
91 int qPy_pred, qPy_a, qPy_b;
105 qPy_a = s->
qp_y_tab[(x_cb - 1) + y_cb * min_cb_width];
111 qPy_b = s->
qp_y_tab[x_cb + (y_cb - 1) * min_cb_width];
116 return (qPy_a + qPy_b + 1) >> 1;
120 int xBase,
int yBase,
int log2_cb_size)
122 int qp_y =
get_qPy_pred(s, xC, yC, xBase, yBase, log2_cb_size);
135 int x = xC >> log2_min_cb_size;
136 int y = yC >> log2_min_cb_size;
145 for (i = 0; i <
height; i++) {
146 memcpy(dst, src, width);
152 #define CTB(tab, x, y) ((tab)[(y) * s->sps->ctb_width + (x)])
159 int class = 1, class_index;
163 int x_shift = 0, y_shift = 0;
170 uint8_t vert_edge[] = { 0, 0, 0, 0 };
171 uint8_t horiz_edge[] = { 0, 0, 0, 0 };
172 uint8_t diag_edge[] = { 0, 0, 0, 0 };
179 sao[0] = &
CTB(s->
sao, x_ctb, y_ctb);
180 edges[0] = x_ctb == 0;
181 edges[1] = y_ctb == 0;
189 sao[
class] = &
CTB(s->
sao, x_ctb - 1, y_ctb);
191 vert_edge[2] = vert_edge[0];
200 sao[
class] = &
CTB(s->
sao, x_ctb, y_ctb - 1);
202 horiz_edge[1] = horiz_edge[0];
210 sao[
class] = &
CTB(s->
sao, x_ctb - 1, y_ctb - 1);
216 vert_edge[3] = vert_edge[1];
218 horiz_edge[3] = horiz_edge[2];
220 diag_edge[3] = diag_edge[0];
225 diag_edge[2] = !lfase[2] || left_tile_edge || up_tile_edge;
226 diag_edge[1] = diag_edge[2];
229 diag_edge[1] = !lfase[1] || left_tile_edge || up_tile_edge;
230 diag_edge[2] = diag_edge[1];
233 diag_edge[2] = left_tile_edge || up_tile_edge;
234 diag_edge[1] = diag_edge[2];
239 for (c_idx = 0; c_idx < 3; c_idx++) {
240 int chroma = c_idx ? 1 : 0;
241 int x0 = x >> chroma;
242 int y0 = y >> chroma;
254 copy_CTB(dst - offset, src - offset,
255 (edges[2] ? width + (x_shift >> chroma) : width) << s->
sps->
pixel_shift,
256 (edges[3] ? height + (y_shift >> chroma) : height), stride);
258 for (class_index = 0; class_index <
class; class_index++) {
260 switch (sao[class_index]->type_idx[c_idx]) {
274 vert_edge[classes[class_index]],
275 horiz_edge[classes[class_index]],
276 diag_edge[classes[class_index]]);
291 x_pu = x >> log2_min_pu_size;
292 y_pu = y >> log2_min_pu_size;
299 #define TC_CALC(qp, bs) \
300 tctable[av_clip((qp) + DEFAULT_INTRA_TC_OFFSET * ((bs) - 1) + \
301 (tc_offset >> 1 << 1), \
302 0, MAX_QP + DEFAULT_INTRA_TC_OFFSET)]
309 int c_tc[2], beta[2],
tc[2];
315 int ctb_size = 1 << log2_ctb_size;
316 int ctb = (x0 >> log2_ctb_size) +
320 int left_tc_offset, left_beta_offset;
321 int tc_offset, beta_offset;
331 x_end = x0 + ctb_size;
334 y_end = y0 + ctb_size;
338 tc_offset = cur_tc_offset;
339 beta_offset = cur_beta_offset;
342 for (y = y0; y < y_end; y += 8) {
343 for (x = x0 ? x0 : 8; x < x_end; x += 8) {
347 const int qp0 = (
get_qPy(s, x - 1, y) +
get_qPy(s, x, y) + 1) >> 1;
348 const int qp1 = (
get_qPy(s, x - 1, y + 4) +
get_qPy(s, x, y + 4) + 1) >> 1;
352 tc[0] = bs0 ?
TC_CALC(qp0, bs0) : 0;
353 tc[1] = bs1 ?
TC_CALC(qp1, bs1) : 0;
356 no_p[0] =
get_pcm(s, x - 1, y);
357 no_p[1] =
get_pcm(s, x - 1, y + 4);
359 no_q[1] =
get_pcm(s, x, y + 4);
362 beta, tc, no_p, no_q);
366 beta, tc, no_p, no_q);
372 for (chroma = 1; chroma <= 2; chroma++) {
373 for (y = y0; y < y_end; y += 16) {
374 for (x = x0 ? x0 : 16; x < x_end; x += 16) {
377 if ((bs0 == 2) || (bs1 == 2)) {
378 const int qp0 = (
get_qPy(s, x - 1, y) +
get_qPy(s, x, y) + 1) >> 1;
379 const int qp1 = (
get_qPy(s, x - 1, y + 8) +
get_qPy(s, x, y + 8) + 1) >> 1;
381 c_tc[0] = (bs0 == 2) ?
chroma_tc(s, qp0, chroma, tc_offset) : 0;
382 c_tc[1] = (bs1 == 2) ?
chroma_tc(s, qp1, chroma, tc_offset) : 0;
385 no_p[0] =
get_pcm(s, x - 1, y);
386 no_p[1] =
get_pcm(s, x - 1, y + 8);
388 no_q[1] =
get_pcm(s, x, y + 8);
404 for (y = y0 ? y0 : 8; y < y_end; y += 8) {
405 for (x = x0 ? x0 - 8 : 0; x < x_end; x += 8) {
409 const int qp0 = (
get_qPy(s, x, y - 1) +
get_qPy(s, x, y) + 1) >> 1;
410 const int qp1 = (
get_qPy(s, x + 4, y - 1) +
get_qPy(s, x + 4, y) + 1) >> 1;
412 tc_offset = x >= x0 ? cur_tc_offset : left_tc_offset;
413 beta_offset = x >= x0 ? cur_beta_offset : left_beta_offset;
417 tc[0] = bs0 ?
TC_CALC(qp0, bs0) : 0;
418 tc[1] = bs1 ?
TC_CALC(qp1, bs1) : 0;
421 no_p[0] =
get_pcm(s, x, y - 1);
422 no_p[1] =
get_pcm(s, x + 4, y - 1);
424 no_q[1] =
get_pcm(s, x + 4, y);
427 beta, tc, no_p, no_q);
431 beta, tc, no_p, no_q);
437 for (chroma = 1; chroma <= 2; chroma++) {
438 for (y = y0 ? y0 : 16; y < y_end; y += 16) {
439 for (x = x0 - 8; x < x_end; x += 16) {
446 }
else if (x >= x_end - 8) {
454 if ((bs0 == 2) || (bs1 == 2)) {
455 const int qp0 = bs0 == 2 ? (
get_qPy(s, x, y - 1) +
get_qPy(s, x, y) + 1) >> 1 : 0;
456 const int qp1 = bs1 == 2 ? (
get_qPy(s, x + 8, y - 1) +
get_qPy(s, x + 8, y) + 1) >> 1 : 0;
458 tc_offset = x >= x0 ? cur_tc_offset : left_tc_offset;
459 c_tc[0] = bs0 == 2 ?
chroma_tc(s, qp0, chroma, tc_offset) : 0;
460 c_tc[1] = bs1 == 2 ?
chroma_tc(s, qp1, chroma, cur_tc_offset) : 0;
463 no_p[0] =
get_pcm(s, x, y - 1);
464 no_p[1] =
get_pcm(s, x + 8, y - 1);
466 no_q[1] =
get_pcm(s, x + 8, y);
491 if (curr_cbf_luma || neigh_cbf_luma)
501 if ((abs(neigh->
mv[0].
x - curr->
mv[0].
x) >= 4 || abs(neigh->
mv[0].
y - curr->
mv[0].
y) >= 4 ||
502 abs(neigh->
mv[1].
x - curr->
mv[1].
x) >= 4 || abs(neigh->
mv[1].
y - curr->
mv[1].
y) >= 4) &&
503 (abs(neigh->
mv[1].
x - curr->
mv[0].
x) >= 4 || abs(neigh->
mv[1].
y - curr->
mv[0].
y) >= 4 ||
504 abs(neigh->
mv[0].
x - curr->
mv[1].
x) >= 4 || abs(neigh->
mv[0].
y - curr->
mv[1].
y) >= 4))
510 if (abs(neigh->
mv[0].
x - curr->
mv[0].
x) >= 4 || abs(neigh->
mv[0].
y - curr->
mv[0].
y) >= 4 ||
511 abs(neigh->
mv[1].
x - curr->
mv[1].
x) >= 4 || abs(neigh->
mv[1].
y - curr->
mv[1].
y) >= 4)
517 if (abs(neigh->
mv[1].
x - curr->
mv[0].
x) >= 4 || abs(neigh->
mv[1].
y - curr->
mv[0].
y) >= 4 ||
518 abs(neigh->
mv[0].
x - curr->
mv[1].
x) >= 4 || abs(neigh->
mv[0].
y - curr->
mv[1].
y) >= 4)
539 ref_B = neigh_refPicList[0].
list[neigh->
ref_idx[0]];
542 ref_B = neigh_refPicList[1].
list[neigh->
ref_idx[1]];
545 if (ref_A == ref_B) {
546 if (abs(A.
x - B.
x) >= 4 || abs(A.
y - B.
y) >= 4)
560 int slice_or_tiles_up_boundary,
561 int slice_or_tiles_left_boundary)
568 int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * min_pu_width +
572 if (y0 > 0 && (y0 & 7) == 0) {
573 int yp_pu = (y0 - 1) >> log2_min_pu_size;
574 int yq_pu = y0 >> log2_min_pu_size;
575 int yp_tu = (y0 - 1) >> log2_min_tu_size;
576 int yq_tu = y0 >> log2_min_tu_size;
578 for (i = 0; i < (1 << log2_trafo_size); i += 4) {
579 int x_pu = (x0 + i) >> log2_min_pu_size;
580 int x_tu = (x0 + i) >> log2_min_tu_size;
581 MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu];
582 MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu];
589 top, top_cbf_luma, top_refPicList, 1);
591 (slice_or_tiles_up_boundary & 1) &&
595 (slice_or_tiles_up_boundary & 2) &&
607 for (j = 8; j < (1 << log2_trafo_size); j += 8) {
608 int yp_pu = (y0 + j - 1) >> log2_min_pu_size;
609 int yq_pu = (y0 + j) >> log2_min_pu_size;
610 int yp_tu = (y0 + j - 1) >> log2_min_tu_size;
611 int yq_tu = (y0 + j) >> log2_min_tu_size;
613 for (i = 0; i < (1 << log2_trafo_size); i += 4) {
614 int x_pu = (x0 + i) >> log2_min_pu_size;
615 int x_tu = (x0 + i) >> log2_min_tu_size;
616 MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu];
617 MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu];
625 top, top_cbf_luma, top_refPicList, 0);
634 if (x0 > 0 && (x0 & 7) == 0) {
635 int xp_pu = (x0 - 1) >> log2_min_pu_size;
636 int xq_pu = x0 >> log2_min_pu_size;
637 int xp_tu = (x0 - 1) >> log2_min_tu_size;
638 int xq_tu = x0 >> log2_min_tu_size;
640 for (i = 0; i < (1 << log2_trafo_size); i += 4) {
641 int y_pu = (y0 + i) >> log2_min_pu_size;
642 int y_tu = (y0 + i) >> log2_min_tu_size;
643 MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu];
644 MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu];
652 left, left_cbf_luma, left_refPicList, 1);
654 (slice_or_tiles_left_boundary & 1) &&
658 (slice_or_tiles_left_boundary & 2) &&
669 if (log2_trafo_size > log2_min_pu_size && !is_intra)
670 for (j = 0; j < (1 << log2_trafo_size); j += 4) {
671 int y_pu = (y0 + j) >> log2_min_pu_size;
672 int y_tu = (y0 + j) >> log2_min_tu_size;
674 for (i = 8; i < (1 << log2_trafo_size); i += 8) {
675 int xp_pu = (x0 + i - 1) >> log2_min_pu_size;
676 int xq_pu = (x0 + i) >> log2_min_pu_size;
677 int xp_tu = (x0 + i - 1) >> log2_min_tu_size;
678 int xq_tu = (x0 + i) >> log2_min_tu_size;
679 MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu];
680 MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu];
688 left, left_cbf_luma, left_refPicList, 0);
712 if (y_ctb && x_ctb >= s->
sps->
width - ctb_size) {
717 if (x_ctb && y_ctb >= s->
sps->
height - ctb_size)