37 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
38 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4,
39 5, 5, 6, 6, 7, 8, 9, 10, 11, 13, 14, 16, 18, 20, 22, 24
43 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8,
44 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36,
45 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64
50 static const int qp_c[] = {
51 29, 30, 31, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37
53 int qp, qp_i, offset, idxt;
74 int xBase,
int yBase,
int log2_cb_size)
80 int xQgBase = xBase - (xBase & MinCuQpDeltaSizeMask);
81 int yQgBase = yBase - (yBase & MinCuQpDeltaSizeMask);
86 int availableA = (xBase & ctb_size_mask) &&
87 (xQgBase & ctb_size_mask);
88 int availableB = (yBase & ctb_size_mask) &&
89 (yQgBase & ctb_size_mask);
90 int qPy_pred, qPy_a, qPy_b;
98 if (log2_cb_size < s->sps->log2_ctb_size -
100 static const int offsetX[8][8] = {
101 { -1, 1, 3, 1, 7, 1, 3, 1 },
102 { 0, 0, 0, 0, 0, 0, 0, 0 },
103 { 1, 3, 1, 3, 1, 3, 1, 3 },
104 { 2, 2, 2, 2, 2, 2, 2, 2 },
105 { 3, 5, 7, 5, 3, 5, 7, 5 },
106 { 4, 4, 4, 4, 4, 4, 4, 4 },
107 { 5, 7, 5, 7, 5, 7, 5, 7 },
108 { 6, 6, 6, 6, 6, 6, 6, 6 }
110 static const int offsetY[8][8] = {
111 { 7, 0, 1, 2, 3, 4, 5, 6 },
112 { 0, 1, 2, 3, 4, 5, 6, 7 },
113 { 1, 0, 3, 2, 5, 4, 7, 6 },
114 { 0, 1, 2, 3, 4, 5, 6, 7 },
115 { 3, 0, 1, 2, 7, 4, 5, 6 },
116 { 0, 1, 2, 3, 4, 5, 6, 7 },
117 { 1, 0, 3, 2, 5, 4, 7, 6 },
118 { 0, 1, 2, 3, 4, 5, 6, 7 }
127 x =
FFMIN(xC0b + offsetX[idxX][idxY], min_cb_width - 1);
128 y =
FFMIN(yC0b + (offsetY[idxX][idxY] & idx_mask), min_cb_height - 1);
131 offsetX[idxX][idxY] == -1) {
135 qPy_pred = s->
qp_y_tab[y * min_cb_width + x];
143 qPy_a = s->
qp_y_tab[(x_cb - 1) + y_cb * min_cb_width];
149 qPy_b = s->
qp_y_tab[x_cb + (y_cb - 1) * min_cb_width];
151 return (qPy_a + qPy_b + 1) >> 1;
155 int xBase,
int yBase,
int log2_cb_size)
157 int qp_y =
get_qPy_pred(s, xC, yC, xBase, yBase, log2_cb_size);
170 int x = xC >> log2_min_cb_size;
171 int y = yC >> log2_min_cb_size;
180 for (i = 0; i <
height; i++) {
181 memcpy(dst, src, width);
187 #define CTB(tab, x, y) ((tab)[(y) * s->sps->ctb_width + (x)]) 194 int class = 1, class_index;
198 int x_shift = 0, y_shift = 0;
205 uint8_t vert_edge[] = { 0, 0, 0, 0 };
206 uint8_t horiz_edge[] = { 0, 0, 0, 0 };
207 uint8_t diag_edge[] = { 0, 0, 0, 0 };
211 uint8_t left_tile_edge = 0, up_tile_edge = 0;
213 sao[0] = &
CTB(s->
sao, x_ctb, y_ctb);
214 edges[0] = x_ctb == 0;
215 edges[1] = y_ctb == 0;
223 sao[
class] = &
CTB(s->
sao, x_ctb - 1, y_ctb);
225 vert_edge[2] = vert_edge[0];
234 sao[
class] = &
CTB(s->
sao, x_ctb, y_ctb - 1);
236 horiz_edge[1] = horiz_edge[0];
244 sao[
class] = &
CTB(s->
sao, x_ctb - 1, y_ctb - 1);
250 vert_edge[3] = vert_edge[1];
252 horiz_edge[3] = horiz_edge[2];
254 diag_edge[3] = diag_edge[0];
259 diag_edge[2] = !lfase[2] || left_tile_edge || up_tile_edge;
260 diag_edge[1] = diag_edge[2];
263 diag_edge[1] = !lfase[1] || left_tile_edge || up_tile_edge;
264 diag_edge[2] = diag_edge[1];
267 diag_edge[2] = left_tile_edge || up_tile_edge;
268 diag_edge[1] = diag_edge[2];
273 for (c_idx = 0; c_idx < 3; c_idx++) {
274 int chroma = c_idx ? 1 : 0;
275 int x0 = x >> chroma;
276 int y0 = y >> chroma;
286 int offset = (y_shift >> chroma) * stride + ((x_shift >> chroma) << s->
sps->
pixel_shift);
288 copy_CTB(dst - offset, src - offset,
289 (edges[2] ? width + (x_shift >> chroma) : width) << s->
sps->
pixel_shift,
290 (edges[3] ? height + (y_shift >> chroma) : height), stride);
292 for (class_index = 0; class_index <
class; class_index++) {
294 switch (sao[class_index]->type_idx[c_idx]) {
308 vert_edge[classes[class_index]],
309 horiz_edge[classes[class_index]],
310 diag_edge[classes[class_index]]);
325 x_pu = x >> log2_min_pu_size;
326 y_pu = y >> log2_min_pu_size;
333 #define TC_CALC(qp, bs) \ 334 tctable[av_clip((qp) + DEFAULT_INTRA_TC_OFFSET * ((bs) - 1) + \ 335 (tc_offset >> 1 << 1), \ 336 0, MAX_QP + DEFAULT_INTRA_TC_OFFSET)] 341 int x, y, x_end, y_end, chroma;
342 int c_tc[2], tc[2], beta;
347 int ctb_size = 1 << log2_ctb_size;
348 int ctb = (x0 >> log2_ctb_size) +
352 int tc_offset, left_tc_offset, beta_offset, left_beta_offset;
362 x_end = x0 + ctb_size;
365 y_end = y0 + ctb_size;
369 tc_offset = cur_tc_offset;
370 beta_offset = cur_beta_offset;
373 for (y = y0; y < y_end; y += 8) {
374 for (x = x0 ? x0 : 8; x < x_end; x += 8) {
378 const int qp = (
get_qPy(s, x - 1, y) +
get_qPy(s, x, y) + 1) >> 1;
382 tc[0] = bs0 ?
TC_CALC(qp, bs0) : 0;
383 tc[1] = bs1 ?
TC_CALC(qp, bs1) : 0;
386 no_p[0] =
get_pcm(s, x - 1, y);
387 no_p[1] =
get_pcm(s, x - 1, y + 4);
389 no_q[1] =
get_pcm(s, x, y + 4);
392 beta, tc, no_p, no_q);
396 beta, tc, no_p, no_q);
402 for (chroma = 1; chroma <= 2; chroma++) {
403 for (y = y0; y < y_end; y += 16) {
404 for (x = x0 ? x0 : 16; x < x_end; x += 16) {
407 if ((bs0 == 2) || (bs1 == 2)) {
408 const int qp0 = (
get_qPy(s, x - 1, y) +
get_qPy(s, x, y) + 1) >> 1;
409 const int qp1 = (
get_qPy(s, x - 1, y + 8) +
get_qPy(s, x, y + 8) + 1) >> 1;
411 c_tc[0] = (bs0 == 2) ?
chroma_tc(s, qp0, chroma, tc_offset) : 0;
412 c_tc[1] = (bs1 == 2) ?
chroma_tc(s, qp1, chroma, tc_offset) : 0;
415 no_p[0] =
get_pcm(s, x - 1, y);
416 no_p[1] =
get_pcm(s, x - 1, y + 8);
418 no_q[1] =
get_pcm(s, x, y + 8);
434 for (y = y0 ? y0 : 8; y < y_end; y += 8) {
435 for (x = x0 ? x0 - 8 : 0; x < x_end; x += 8) {
439 const int qp = (
get_qPy(s, x, y - 1) +
get_qPy(s, x, y) + 1) >> 1;
441 tc_offset = x >= x0 ? cur_tc_offset : left_tc_offset;
442 beta_offset = x >= x0 ? cur_beta_offset : left_beta_offset;
445 tc[0] = bs0 ?
TC_CALC(qp, bs0) : 0;
446 tc[1] = bs1 ?
TC_CALC(qp, bs1) : 0;
449 no_p[0] =
get_pcm(s, x, y - 1);
450 no_p[1] =
get_pcm(s, x + 4, y - 1);
452 no_q[1] =
get_pcm(s, x + 4, y);
455 beta, tc, no_p, no_q);
459 beta, tc, no_p, no_q);
465 for (chroma = 1; chroma <= 2; chroma++) {
466 for (y = y0 ? y0 : 16; y < y_end; y += 16) {
467 for (x = x0 - 8; x < x_end; x += 16) {
474 }
else if (x >= x_end - 8) {
482 if ((bs0 == 2) || (bs1 == 2)) {
483 const int qp0 = bs0 == 2 ? (
get_qPy(s, x, y - 1) +
get_qPy(s, x, y) + 1) >> 1 : 0;
484 const int qp1 = bs1 == 2 ? (
get_qPy(s, x + 8, y - 1) +
get_qPy(s, x + 8, y) + 1) >> 1 : 0;
486 tc_offset = x >= x0 ? cur_tc_offset : left_tc_offset;
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 + 8, y - 1);
494 no_q[1] =
get_pcm(s, x + 8, y);
519 if (curr_cbf_luma || neigh_cbf_luma)
529 if ((abs(neigh->
mv[0].
x - curr->
mv[0].
x) >= 4 || abs(neigh->
mv[0].
y - curr->
mv[0].
y) >= 4 ||
530 abs(neigh->
mv[1].
x - curr->
mv[1].
x) >= 4 || abs(neigh->
mv[1].
y - curr->
mv[1].
y) >= 4) &&
531 (abs(neigh->
mv[1].
x - curr->
mv[0].
x) >= 4 || abs(neigh->
mv[1].
y - curr->
mv[0].
y) >= 4 ||
532 abs(neigh->
mv[0].
x - curr->
mv[1].
x) >= 4 || abs(neigh->
mv[0].
y - curr->
mv[1].
y) >= 4))
538 if (abs(neigh->
mv[0].
x - curr->
mv[0].
x) >= 4 || abs(neigh->
mv[0].
y - curr->
mv[0].
y) >= 4 ||
539 abs(neigh->
mv[1].
x - curr->
mv[1].
x) >= 4 || abs(neigh->
mv[1].
y - curr->
mv[1].
y) >= 4)
545 if (abs(neigh->
mv[1].
x - curr->
mv[0].
x) >= 4 || abs(neigh->
mv[1].
y - curr->
mv[0].
y) >= 4 ||
546 abs(neigh->
mv[0].
x - curr->
mv[1].
x) >= 4 || abs(neigh->
mv[0].
y - curr->
mv[1].
y) >= 4)
567 ref_B = neigh_refPicList[0].
list[neigh->
ref_idx[0]];
570 ref_B = neigh_refPicList[1].
list[neigh->
ref_idx[1]];
573 if (ref_A == ref_B) {
574 if (abs(A.
x - B.
x) >= 4 || abs(A.
y - B.
y) >= 4)
595 int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * min_pu_width +
597 int boundary_upper, boundary_left;
600 boundary_upper = y0 > 0 && !(y0 & 7);
601 if (boundary_upper &&
610 if (boundary_upper) {
615 int yp_pu = (y0 - 1) >> log2_min_pu_size;
616 int yq_pu = y0 >> log2_min_pu_size;
617 int yp_tu = (y0 - 1) >> log2_min_tu_size;
618 int yq_tu = y0 >> log2_min_tu_size;
620 for (i = 0; i < (1 << log2_trafo_size); i += 4) {
621 int x_pu = (x0 + i) >> log2_min_pu_size;
622 int x_tu = (x0 + i) >> log2_min_tu_size;
623 MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu];
624 MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu];
629 top, top_cbf_luma, rpl_top, 1);
639 for (j = 8; j < (1 << log2_trafo_size); j += 8) {
640 int yp_pu = (y0 + j - 1) >> log2_min_pu_size;
641 int yq_pu = (y0 + j) >> log2_min_pu_size;
642 int yp_tu = (y0 + j - 1) >> log2_min_tu_size;
643 int yq_tu = (y0 + j) >> log2_min_tu_size;
645 for (i = 0; i < (1 << log2_trafo_size); i += 4) {
646 int x_pu = (x0 + i) >> log2_min_pu_size;
647 int x_tu = (x0 + i) >> log2_min_tu_size;
648 MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu];
649 MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu];
654 top, top_cbf_luma, rpl, 0);
662 boundary_left = x0 > 0 && !(x0 & 7);
677 int xp_pu = (x0 - 1) >> log2_min_pu_size;
678 int xq_pu = x0 >> log2_min_pu_size;
679 int xp_tu = (x0 - 1) >> log2_min_tu_size;
680 int xq_tu = x0 >> log2_min_tu_size;
682 for (i = 0; i < (1 << log2_trafo_size); i += 4) {
683 int y_pu = (y0 + i) >> log2_min_pu_size;
684 int y_tu = (y0 + i) >> log2_min_tu_size;
685 MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu];
686 MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu];
692 left, left_cbf_luma, rpl_left, 1);
699 if (log2_trafo_size > log2_min_pu_size && !is_intra) {
702 for (j = 0; j < (1 << log2_trafo_size); j += 4) {
703 int y_pu = (y0 + j) >> log2_min_pu_size;
704 int y_tu = (y0 + j) >> log2_min_tu_size;
706 for (i = 8; i < (1 << log2_trafo_size); i += 8) {
707 int xp_pu = (x0 + i - 1) >> log2_min_pu_size;
708 int xq_pu = (x0 + i) >> log2_min_pu_size;
709 int xp_tu = (x0 + i - 1) >> log2_min_tu_size;
710 int xq_tu = (x0 + i) >> log2_min_tu_size;
711 MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu];
712 MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu];
717 left, left_cbf_luma, rpl, 0);
740 if (y_ctb && x_ctb >= s->
sps->
width - ctb_size) {
744 if (x_ctb && y_ctb >= s->
sps->
height - ctb_size)
unsigned int log2_min_cb_size
void(* hevc_h_loop_filter_luma_c)(uint8_t *pix, ptrdiff_t stride, int beta, int *tc, uint8_t *no_p, uint8_t *no_q)
void(* hevc_h_loop_filter_chroma_c)(uint8_t *pix, ptrdiff_t stride, int *tc, uint8_t *no_p, uint8_t *no_q)
int16_t x
horizontal component of motion vector
void(* hevc_v_loop_filter_chroma)(uint8_t *pix, ptrdiff_t stride, int *tc, uint8_t *no_p, uint8_t *no_q)
static int get_qPy_pred(HEVCContext *s, int xC, int yC, int xBase, int yBase, int log2_cb_size)
static void copy_CTB(uint8_t *dst, uint8_t *src, int width, int height, int stride)
static void sao_filter_CTB(HEVCContext *s, int x, int y)
void ff_hevc_hls_filter(HEVCContext *s, int x, int y)
void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, int log2_trafo_size)
void(* sao_band_filter[4])(uint8_t *dst, uint8_t *src, ptrdiff_t stride, struct SAOParams *sao, int *borders, int width, int height, int c_idx)
void(* hevc_h_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride, int beta, int *tc, uint8_t *no_p, uint8_t *no_q)
static const uint8_t tctable[54]
uint8_t loop_filter_disable_flag
static const uint8_t betatable[52]
uint8_t transquant_bypass_enable_flag
#define BOUNDARY_UPPER_SLICE
void(* sao_edge_filter[4])(uint8_t *dst, uint8_t *src, ptrdiff_t stride, struct SAOParams *sao, int *borders, int width, int height, int c_idx, uint8_t vert_edge, uint8_t horiz_edge, uint8_t diag_edge)
void ff_hevc_hls_filters(HEVCContext *s, int x_ctb, int y_ctb, int ctb_size)
static av_always_inline av_const int av_clip_c(int a, int amin, int amax)
Clip a signed integer value into the amin-amax range.
unsigned int log2_ctb_size
void(* hevc_h_loop_filter_chroma)(uint8_t *pix, ptrdiff_t stride, int *tc, uint8_t *no_p, uint8_t *no_q)
uint8_t tiles_enabled_flag
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.
Context Adaptive Binary Arithmetic Coder inline functions.
if(ac->has_optimized_func)
int * ctb_addr_rs_to_ts
CtbAddrRSToTS.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
unsigned int log2_min_pu_size
int16_t y
vertical component of motion vector
uint8_t loop_filter_across_tiles_enabled_flag
void(* hevc_v_loop_filter_chroma_c)(uint8_t *pix, ptrdiff_t stride, int *tc, uint8_t *no_p, uint8_t *no_q)
unsigned int log2_min_tb_size
static int get_qPy(HEVCContext *s, int xC, int yC)
static int boundary_strength(HEVCContext *s, MvField *curr, uint8_t curr_cbf_luma, MvField *neigh, uint8_t neigh_cbf_luma, RefPicList *neigh_refPicList, int tu_border)
static int get_pcm(HEVCContext *s, int x, int y)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define DEFAULT_INTRA_TC_OFFSET
RefPicList * ff_hevc_get_ref_list(HEVCContext *s, HEVCFrame *frame, int x0, int y0)
void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC, int xBase, int yBase, int log2_cb_size)
static int chroma_tc(HEVCContext *s, int qp_y, int c_idx, int tc_offset)
common internal and external API header
#define BOUNDARY_LEFT_SLICE
int32_t * tab_slice_address
void(* hevc_v_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride, int beta, int *tc, uint8_t *no_p, uint8_t *no_q)
uint8_t * filter_slice_edges
int diff_cu_qp_delta_depth
#define BOUNDARY_LEFT_TILE
void(* hevc_v_loop_filter_luma_c)(uint8_t *pix, ptrdiff_t stride, int beta, int *tc, uint8_t *no_p, uint8_t *no_q)
static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
#define BOUNDARY_UPPER_TILE