diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-11-02 03:31:49 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-11-02 03:44:54 +0400 |
commit | f578e5d9376a20243f4286776f79a1e1c33b12cd (patch) | |
tree | 64e66bed1735b7264a017a91d3946dd25441d9b5 /libavcodec/hevc_filter.c | |
parent | 38612379bffe371d2e21b876b80c335bb468c2fa (diff) |
avcodec/hevc: Adjust white-spaces to reduce difference to 064698d381e1e7790f21b0199a8930ea04e2e942
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/hevc_filter.c')
-rw-r--r-- | libavcodec/hevc_filter.c | 303 |
1 files changed, 183 insertions, 120 deletions
diff --git a/libavcodec/hevc_filter.c b/libavcodec/hevc_filter.c index 0a6d7c9fb5..a2b4f68a62 100644 --- a/libavcodec/hevc_filter.c +++ b/libavcodec/hevc_filter.c @@ -35,20 +35,22 @@ #define CR 2 static const uint8_t tctable[54] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, // QP 0...18 - 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, // QP 19...37 - 5, 5, 6, 6, 7, 8, 9,10,11,13,14,16,18,20,22,24 // QP 38...53 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, // QP 0...18 + 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, // QP 19...37 + 5, 5, 6, 6, 7, 8, 9, 10, 11, 13, 14, 16, 18, 20, 22, 24 // QP 38...53 }; static const uint8_t betatable[52] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, // QP 0...18 - 9,10,11,12,13,14,15,16,17,18,20,22,24,26,28,30,32,34,36, // QP 19...37 - 38,40,42,44,46,48,50,52,54,56,58,60,62,64 // QP 38...51 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, // QP 0...18 + 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, // QP 19...37 + 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64 // QP 38...51 }; static int chroma_tc(HEVCContext *s, int qp_y, int c_idx, int tc_offset) { - static const int qp_c[] = { 29, 30, 31, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37 }; + static const int qp_c[] = { + 29, 30, 31, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37 + }; int qp_i, offset; int qp; int idxt; @@ -71,19 +73,23 @@ static int chroma_tc(HEVCContext *s, int qp_y, int c_idx, int tc_offset) return tctable[idxt]; } -static int get_qPy_pred(HEVCContext *s, int xC, int yC, int xBase, int yBase, int log2_cb_size) +static int get_qPy_pred(HEVCContext *s, int xC, int yC, + int xBase, int yBase, int log2_cb_size) { HEVCLocalContext *lc = s->HEVClc; int ctb_size_mask = (1 << s->sps->log2_ctb_size) - 1; - int MinCuQpDeltaSizeMask = (1 << (s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth)) - 1; - int xQgBase = xBase - ( xBase & MinCuQpDeltaSizeMask ); - int yQgBase = yBase - ( yBase & MinCuQpDeltaSizeMask ); + int MinCuQpDeltaSizeMask = (1 << (s->sps->log2_ctb_size - + s->pps->diff_cu_qp_delta_depth)) - 1; + int xQgBase = xBase - (xBase & MinCuQpDeltaSizeMask); + int yQgBase = yBase - (yBase & MinCuQpDeltaSizeMask); int min_cb_width = s->sps->min_cb_width; int min_cb_height = s->sps->min_cb_height; int x_cb = xQgBase >> s->sps->log2_min_cb_size; int y_cb = yQgBase >> s->sps->log2_min_cb_size; - int availableA = (xBase & ctb_size_mask) && (xQgBase & ctb_size_mask); - int availableB = (yBase & ctb_size_mask) && (yQgBase & ctb_size_mask); + int availableA = (xBase & ctb_size_mask) && + (xQgBase & ctb_size_mask); + int availableB = (yBase & ctb_size_mask) && + (yQgBase & ctb_size_mask); int qPy_pred; int qPy_a; int qPy_b; @@ -94,31 +100,32 @@ static int get_qPy_pred(HEVCContext *s, int xC, int yC, int xBase, int yBase, in qPy_pred = s->sh.slice_qp; } else { qPy_pred = lc->qp_y; - if (log2_cb_size < s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth) { + if (log2_cb_size < s->sps->log2_ctb_size - + s->pps->diff_cu_qp_delta_depth) { static const int offsetX[8][8] = { - {-1, 1, 3, 1, 7, 1, 3, 1}, - { 0, 0, 0, 0, 0, 0, 0, 0}, - { 1, 3, 1, 3, 1, 3, 1, 3}, - { 2, 2, 2, 2, 2, 2, 2, 2}, - { 3, 5, 7, 5, 3, 5, 7, 5}, - { 4, 4, 4, 4, 4, 4, 4, 4}, - { 5, 7, 5, 7, 5, 7, 5, 7}, - { 6, 6, 6, 6, 6, 6, 6, 6} + { -1, 1, 3, 1, 7, 1, 3, 1 }, + { 0, 0, 0, 0, 0, 0, 0, 0 }, + { 1, 3, 1, 3, 1, 3, 1, 3 }, + { 2, 2, 2, 2, 2, 2, 2, 2 }, + { 3, 5, 7, 5, 3, 5, 7, 5 }, + { 4, 4, 4, 4, 4, 4, 4, 4 }, + { 5, 7, 5, 7, 5, 7, 5, 7 }, + { 6, 6, 6, 6, 6, 6, 6, 6 } }; static const int offsetY[8][8] = { - { 7, 0, 1, 2, 3, 4, 5, 6}, - { 0, 1, 2, 3, 4, 5, 6, 7}, - { 1, 0, 3, 2, 5, 4, 7, 6}, - { 0, 1, 2, 3, 4, 5, 6, 7}, - { 3, 0, 1, 2, 7, 4, 5, 6}, - { 0, 1, 2, 3, 4, 5, 6, 7}, - { 1, 0, 3, 2, 5, 4, 7, 6}, - { 0, 1, 2, 3, 4, 5, 6, 7} + { 7, 0, 1, 2, 3, 4, 5, 6 }, + { 0, 1, 2, 3, 4, 5, 6, 7 }, + { 1, 0, 3, 2, 5, 4, 7, 6 }, + { 0, 1, 2, 3, 4, 5, 6, 7 }, + { 3, 0, 1, 2, 7, 4, 5, 6 }, + { 0, 1, 2, 3, 4, 5, 6, 7 }, + { 1, 0, 3, 2, 5, 4, 7, 6 }, + { 0, 1, 2, 3, 4, 5, 6, 7 } }; int xC0b = (xC - (xC & ctb_size_mask)) >> s->sps->log2_min_cb_size; int yC0b = (yC - (yC & ctb_size_mask)) >> s->sps->log2_min_cb_size; - int idxX = (xQgBase & ctb_size_mask) >> s->sps->log2_min_cb_size; - int idxY = (yQgBase & ctb_size_mask) >> s->sps->log2_min_cb_size; + int idxX = (xQgBase & ctb_size_mask) >> s->sps->log2_min_cb_size; + int idxY = (yQgBase & ctb_size_mask) >> s->sps->log2_min_cb_size; int idx_mask = ctb_size_mask >> s->sps->log2_min_cb_size; int x, y; @@ -149,13 +156,15 @@ static int get_qPy_pred(HEVCContext *s, int xC, int yC, int xBase, int yBase, in return (qPy_a + qPy_b + 1) >> 1; } -void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC, int xBase, int yBase, int log2_cb_size) +void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC, + int xBase, int yBase, int log2_cb_size) { int qp_y = get_qPy_pred(s, xC, yC, xBase, yBase, log2_cb_size); if (s->HEVClc->tu.cu_qp_delta != 0) { int off = s->sps->qp_bd_offset; - s->HEVClc->qp_y = ((qp_y + s->HEVClc->tu.cu_qp_delta + 52 + 2 * off) % (52 + off)) - off; + s->HEVClc->qp_y = ((qp_y + s->HEVClc->tu.cu_qp_delta + 52 + 2 * off) % + (52 + off)) - off; } else s->HEVClc->qp_y = qp_y; } @@ -168,11 +177,12 @@ static int get_qPy(HEVCContext *s, int xC, int yC) return s->qp_y_tab[x + y * s->sps->min_cb_width]; } -static void copy_CTB(uint8_t *dst, uint8_t *src, int width, int height, int stride) +static void copy_CTB(uint8_t *dst, uint8_t *src, + int width, int height, int stride) { int i; - for(i=0; i< height; i++){ + for (i = 0; i < height; i++) { memcpy(dst, src, width); dst += stride; src += stride; @@ -187,28 +197,29 @@ static void sao_filter_CTB(HEVCContext *s, int x, int y) // TODO: skip CBs when (cu_transquant_bypass_flag || (pcm_loop_filter_disable_flag && pcm_flag)) int c_idx = 0; int class = 1, class_index; - int edges[4]; // 0 left 1 top 2 right 3 bottom + int edges[4]; // 0 left 1 top 2 right 3 bottom SAOParams *sao[4]; int classes[4]; int x_shift = 0, y_shift = 0; - int x_ctb = x>>s->sps->log2_ctb_size; - int y_ctb = y>>s->sps->log2_ctb_size; + int x_ctb = x >> s->sps->log2_ctb_size; + int y_ctb = y >> s->sps->log2_ctb_size; int ctb_addr_rs = y_ctb * s->sps->ctb_width + x_ctb; int ctb_addr_ts = s->pps->ctb_addr_rs_to_ts[ctb_addr_rs]; // flags indicating unfilterable edges - uint8_t vert_edge[] = {0,0,0,0}; - uint8_t horiz_edge[] = {0,0,0,0}; - uint8_t diag_edge[] = {0,0,0,0}; + uint8_t vert_edge[] = { 0, 0, 0, 0 }; + uint8_t horiz_edge[] = { 0, 0, 0, 0 }; + uint8_t diag_edge[] = { 0, 0, 0, 0 }; uint8_t lfase[3]; // current, above, left - uint8_t no_tile_filter = s->pps->tiles_enabled_flag && !s->pps->loop_filter_across_tiles_enabled_flag; + uint8_t no_tile_filter = s->pps->tiles_enabled_flag && + !s->pps->loop_filter_across_tiles_enabled_flag; uint8_t left_tile_edge = 0; uint8_t up_tile_edge = 0; sao[0] = &CTB(s->sao, x_ctb, y_ctb); edges[0] = x_ctb == 0; edges[1] = y_ctb == 0; - edges[2] = x_ctb == (s->sps->ctb_width - 1); + edges[2] = x_ctb == (s->sps->ctb_width - 1); edges[3] = y_ctb == (s->sps->ctb_height - 1); lfase[0] = CTB(s->filter_slice_edges, x_ctb, y_ctb); classes[0] = 0; @@ -249,10 +260,12 @@ static void sao_filter_CTB(HEVCContext *s, int x, int y) diag_edge[3] = diag_edge[0]; // Does left CTB comes after above CTB? - if(CTB(s->tab_slice_address, x_ctb - 1, y_ctb) > CTB(s->tab_slice_address, x_ctb, y_ctb - 1)) { + if (CTB(s->tab_slice_address, x_ctb - 1, y_ctb) > + CTB(s->tab_slice_address, x_ctb, y_ctb - 1)) { diag_edge[2] = !lfase[2] || left_tile_edge || up_tile_edge; diag_edge[1] = diag_edge[2]; - } else if(CTB(s->tab_slice_address, x_ctb - 1, y_ctb) < CTB(s->tab_slice_address, x_ctb, y_ctb - 1)) { + } else if (CTB(s->tab_slice_address, x_ctb - 1, y_ctb) < + CTB(s->tab_slice_address, x_ctb, y_ctb - 1)) { diag_edge[1] = !lfase[1] || left_tile_edge || up_tile_edge; diag_edge[2] = diag_edge[1]; } else { @@ -286,10 +299,21 @@ static void sao_filter_CTB(HEVCContext *s, int x, int y) switch (sao[class_index]->type_idx[c_idx]) { case SAO_BAND: - s->hevcdsp.sao_band_filter[classes[class_index]](dst, src, stride, sao[class_index], edges, width, height, c_idx); - break; + s->hevcdsp.sao_band_filter[classes[class_index]](dst, src, + stride, + sao[class_index], + edges, width, + height, c_idx); + break; case SAO_EDGE: - s->hevcdsp.sao_edge_filter[classes[class_index]](dst, src, stride, sao[class_index], edges, width, height, c_idx, vert_edge[classes[class_index]], horiz_edge[classes[class_index]], diag_edge[classes[class_index]]); + s->hevcdsp.sao_edge_filter[classes[class_index]](dst, src, + stride, + sao[class_index], + edges, width, + height, c_idx, + vert_edge[classes[class_index]], + horiz_edge[classes[class_index]], + diag_edge[classes[class_index]]); break; } } @@ -318,33 +342,35 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0) int c_tc[2]; int beta[2]; int tc[2]; - uint8_t no_p[2] = {0}; - uint8_t no_q[2] = {0}; + uint8_t no_p[2] = { 0 }; + uint8_t no_q[2] = { 0 }; - int log2_ctb_size = s->sps->log2_ctb_size; + int log2_ctb_size = s->sps->log2_ctb_size; int x_end, y_end; - int ctb_size = 1<<log2_ctb_size; - int ctb = (x0 >> log2_ctb_size) + (y0 >> log2_ctb_size) * s->sps->ctb_width; + int ctb_size = 1 << log2_ctb_size; + int ctb = (x0 >> log2_ctb_size) + + (y0 >> log2_ctb_size) * s->sps->ctb_width; int cur_tc_offset = s->deblock[ctb].tc_offset; int cur_beta_offset = s->deblock[ctb].beta_offset; int left_tc_offset, left_beta_offset; int tc_offset, beta_offset; - int pcmf = (s->sps->pcm_enabled_flag && s->sps->pcm.loop_filter_disable_flag) || - s->pps->transquant_bypass_enable_flag; + int pcmf = (s->sps->pcm_enabled_flag && + s->sps->pcm.loop_filter_disable_flag) || + s->pps->transquant_bypass_enable_flag; if (x0) { - left_tc_offset = s->deblock[ctb-1].tc_offset; - left_beta_offset = s->deblock[ctb-1].beta_offset; + left_tc_offset = s->deblock[ctb - 1].tc_offset; + left_beta_offset = s->deblock[ctb - 1].beta_offset; } - x_end = x0+ctb_size; + x_end = x0 + ctb_size; if (x_end > s->sps->width) x_end = s->sps->width; - y_end = y0+ctb_size; + y_end = y0 + ctb_size; if (y_end > s->sps->height) y_end = s->sps->height; - tc_offset = cur_tc_offset; + tc_offset = cur_tc_offset; beta_offset = cur_beta_offset; // vertical filtering luma @@ -353,22 +379,26 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0) const int bs0 = s->vertical_bs[(x >> 3) + (y >> 2) * s->bs_width]; const int bs1 = s->vertical_bs[(x >> 3) + ((y + 4) >> 2) * s->bs_width]; if (bs0 || bs1) { - const int qp0 = (get_qPy(s, x - 1, y) + get_qPy(s, x, y) + 1) >> 1; + const int qp0 = (get_qPy(s, x - 1, y) + get_qPy(s, x, y) + 1) >> 1; const int qp1 = (get_qPy(s, x - 1, y + 4) + get_qPy(s, x, y + 4) + 1) >> 1; beta[0] = betatable[av_clip(qp0 + ((beta_offset >> 1) << 1), 0, MAX_QP)]; beta[1] = betatable[av_clip(qp1 + ((beta_offset >> 1) << 1), 0, MAX_QP)]; - tc[0] = bs0 ? TC_CALC(qp0, bs0) : 0; - tc[1] = bs1 ? TC_CALC(qp1, bs1) : 0; - src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->sps->pixel_shift)]; + tc[0] = bs0 ? TC_CALC(qp0, bs0) : 0; + tc[1] = bs1 ? TC_CALC(qp1, bs1) : 0; + src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->sps->pixel_shift)]; if (pcmf) { no_p[0] = get_pcm(s, x - 1, y); no_p[1] = get_pcm(s, x - 1, y + 4); no_q[0] = get_pcm(s, x, y); no_q[1] = get_pcm(s, x, y + 4); - s->hevcdsp.hevc_v_loop_filter_luma_c(src, s->frame->linesize[LUMA], beta, tc, no_p, no_q); + s->hevcdsp.hevc_v_loop_filter_luma_c(src, + s->frame->linesize[LUMA], + beta, tc, no_p, no_q); } else - s->hevcdsp.hevc_v_loop_filter_luma(src, s->frame->linesize[LUMA], beta, tc, no_p, no_q); + s->hevcdsp.hevc_v_loop_filter_luma(src, + s->frame->linesize[LUMA], + beta, tc, no_p, no_q); } } } @@ -376,24 +406,28 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0) // vertical filtering chroma for (chroma = 1; chroma <= 2; chroma++) { for (y = y0; y < y_end; y += 16) { - for (x = x0 ? x0:16; x < x_end; x += 16) { - const int bs0 = s->vertical_bs[(x >> 3) + (y >> 2) * s->bs_width]; + for (x = x0 ? x0 : 16; x < x_end; x += 16) { + const int bs0 = s->vertical_bs[(x >> 3) + (y >> 2) * s->bs_width]; const int bs1 = s->vertical_bs[(x >> 3) + ((y + 8) >> 2) * s->bs_width]; if ((bs0 == 2) || (bs1 == 2)) { - const int qp0 = (get_qPy(s, x - 1, y) + get_qPy(s, x, y) + 1) >> 1; + const int qp0 = (get_qPy(s, x - 1, y) + get_qPy(s, x, y) + 1) >> 1; const int qp1 = (get_qPy(s, x - 1, y + 8) + get_qPy(s, x, y + 8) + 1) >> 1; c_tc[0] = (bs0 == 2) ? chroma_tc(s, qp0, chroma, tc_offset) : 0; c_tc[1] = (bs1 == 2) ? chroma_tc(s, qp1, chroma, tc_offset) : 0; - src = &s->frame->data[chroma][(y / 2) * s->frame->linesize[chroma] + ((x / 2) << s->sps->pixel_shift)]; + src = &s->frame->data[chroma][(y / 2) * s->frame->linesize[chroma] + ((x / 2) << s->sps->pixel_shift)]; if (pcmf) { no_p[0] = get_pcm(s, x - 1, y); no_p[1] = get_pcm(s, x - 1, y + 8); no_q[0] = get_pcm(s, x, y); no_q[1] = get_pcm(s, x, y + 8); - s->hevcdsp.hevc_v_loop_filter_chroma_c(src, s->frame->linesize[chroma], c_tc, no_p, no_q); + s->hevcdsp.hevc_v_loop_filter_chroma_c(src, + s->frame->linesize[chroma], + c_tc, no_p, no_q); } else - s->hevcdsp.hevc_v_loop_filter_chroma(src, s->frame->linesize[chroma], c_tc, no_p, no_q); + s->hevcdsp.hevc_v_loop_filter_chroma(src, + s->frame->linesize[chroma], + c_tc, no_p, no_q); } } } @@ -410,22 +444,26 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0) const int qp0 = (get_qPy(s, x, y - 1) + get_qPy(s, x, y) + 1) >> 1; const int qp1 = (get_qPy(s, x + 4, y - 1) + get_qPy(s, x + 4, y) + 1) >> 1; - tc_offset = x >= x0 ? cur_tc_offset : left_tc_offset; + tc_offset = x >= x0 ? cur_tc_offset : left_tc_offset; beta_offset = x >= x0 ? cur_beta_offset : left_beta_offset; - beta[0] = betatable[av_clip(qp0 + ((beta_offset >> 1) << 1), 0, MAX_QP)]; - beta[1] = betatable[av_clip(qp1 + ((beta_offset >> 1) << 1), 0, MAX_QP)]; - tc[0] = bs0 ? TC_CALC(qp0, bs0) : 0; - tc[1] = bs1 ? TC_CALC(qp1, bs1) : 0; - src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->sps->pixel_shift)]; + beta[0] = betatable[av_clip(qp0 + ((beta_offset >> 1) << 1), 0, MAX_QP)]; + beta[1] = betatable[av_clip(qp1 + ((beta_offset >> 1) << 1), 0, MAX_QP)]; + tc[0] = bs0 ? TC_CALC(qp0, bs0) : 0; + tc[1] = bs1 ? TC_CALC(qp1, bs1) : 0; + src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->sps->pixel_shift)]; if (pcmf) { no_p[0] = get_pcm(s, x, y - 1); no_p[1] = get_pcm(s, x + 4, y - 1); no_q[0] = get_pcm(s, x, y); no_q[1] = get_pcm(s, x + 4, y); - s->hevcdsp.hevc_h_loop_filter_luma_c(src, s->frame->linesize[LUMA], beta, tc, no_p, no_q); + s->hevcdsp.hevc_h_loop_filter_luma_c(src, + s->frame->linesize[LUMA], + beta, tc, no_p, no_q); } else - s->hevcdsp.hevc_h_loop_filter_luma(src, s->frame->linesize[LUMA], beta, tc, no_p, no_q); + s->hevcdsp.hevc_h_loop_filter_luma(src, + s->frame->linesize[LUMA], + beta, tc, no_p, no_q); } } } @@ -441,29 +479,33 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0) bs0 = 0; bs1 = s->horizontal_bs[(x + 8 + y * s->bs_width) >> 2]; } else if (x >= x_end - 8) { - bs0 = s->horizontal_bs[(x + y * s->bs_width) >> 2]; + bs0 = s->horizontal_bs[(x + y * s->bs_width) >> 2]; bs1 = 0; } else { - bs0 = s->horizontal_bs[(x + y * s->bs_width) >> 2]; + bs0 = s->horizontal_bs[(x + y * s->bs_width) >> 2]; bs1 = s->horizontal_bs[(x + 8 + y * s->bs_width) >> 2]; } if ((bs0 == 2) || (bs1 == 2)) { - const int qp0 = (bs0 == 2) ? ((get_qPy(s, x, y - 1) + get_qPy(s, x, y) + 1) >> 1) : 0; + const int qp0 = (bs0 == 2) ? ((get_qPy(s, x, y - 1) + get_qPy(s, x, y) + 1) >> 1) : 0; const int qp1 = (bs1 == 2) ? ((get_qPy(s, x + 8, y - 1) + get_qPy(s, x + 8, y) + 1) >> 1) : 0; tc_offset = x >= x0 ? cur_tc_offset : left_tc_offset; - c_tc[0] = (bs0 == 2) ? chroma_tc(s, qp0, chroma, tc_offset) : 0; + c_tc[0] = (bs0 == 2) ? chroma_tc(s, qp0, chroma, tc_offset) : 0; c_tc[1] = (bs1 == 2) ? chroma_tc(s, qp1, chroma, cur_tc_offset) : 0; - src = &s->frame->data[chroma][(y / 2) * s->frame->linesize[chroma] + ((x / 2) << s->sps->pixel_shift)]; + src = &s->frame->data[chroma][(y / 2) * s->frame->linesize[chroma] + ((x / 2) << s->sps->pixel_shift)]; if (pcmf) { no_p[0] = get_pcm(s, x, y - 1); no_p[1] = get_pcm(s, x + 8, y - 1); no_q[0] = get_pcm(s, x, y); no_q[1] = get_pcm(s, x + 8, y); - s->hevcdsp.hevc_h_loop_filter_chroma_c(src, s->frame->linesize[chroma], c_tc, no_p, no_q); + s->hevcdsp.hevc_h_loop_filter_chroma_c(src, + s->frame->linesize[chroma], + c_tc, no_p, no_q); } else - s->hevcdsp.hevc_h_loop_filter_chroma(src, s->frame->linesize[chroma], c_tc, no_p, no_q); + s->hevcdsp.hevc_h_loop_filter_chroma(src, + s->frame->linesize[chroma], + c_tc, no_p, no_q); } } } @@ -472,7 +514,8 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0) static int boundary_strength(HEVCContext *s, MvField *curr, uint8_t curr_cbf_luma, MvField *neigh, - uint8_t neigh_cbf_luma, RefPicList *neigh_refPicList, + uint8_t neigh_cbf_luma, + RefPicList *neigh_refPicList, int tu_border) { int mvs = curr->pred_flag[0] + curr->pred_flag[1]; @@ -487,7 +530,7 @@ static int boundary_strength(HEVCContext *s, MvField *curr, if (mvs == neigh->pred_flag[0] + neigh->pred_flag[1]) { if (mvs == 2) { // same L0 and L1 - if (s->ref->refPicList[0].list[curr->ref_idx[0]] == neigh_refPicList[0].list[neigh->ref_idx[0]] && + if (s->ref->refPicList[0].list[curr->ref_idx[0]] == neigh_refPicList[0].list[neigh->ref_idx[0]] && s->ref->refPicList[0].list[curr->ref_idx[0]] == s->ref->refPicList[1].list[curr->ref_idx[1]] && neigh_refPicList[0].list[neigh->ref_idx[0]] == neigh_refPicList[1].list[neigh->ref_idx[1]]) { if ((abs(neigh->mv[0].x - curr->mv[0].x) >= 4 || abs(neigh->mv[0].y - curr->mv[0].y) >= 4 || @@ -520,18 +563,18 @@ static int boundary_strength(HEVCContext *s, MvField *curr, int ref_B; if (curr->pred_flag[0]) { - A = curr->mv[0]; + A = curr->mv[0]; ref_A = s->ref->refPicList[0].list[curr->ref_idx[0]]; } else { - A = curr->mv[1]; + A = curr->mv[1]; ref_A = s->ref->refPicList[1].list[curr->ref_idx[1]]; } if (neigh->pred_flag[0]) { - B = neigh->mv[0]; + B = neigh->mv[0]; ref_B = neigh_refPicList[0].list[neigh->ref_idx[0]]; } else { - B = neigh->mv[1]; + B = neigh->mv[1]; ref_B = neigh_refPicList[1].list[neigh->ref_idx[1]]; } @@ -548,24 +591,26 @@ static int boundary_strength(HEVCContext *s, MvField *curr, return 1; } -void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, int log2_trafo_size, - int slice_or_tiles_up_boundary, int slice_or_tiles_left_boundary) +void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, + int log2_trafo_size, + int slice_or_tiles_up_boundary, + int slice_or_tiles_left_boundary) { MvField *tab_mvf = s->ref->tab_mvf; int log2_min_pu_size = s->sps->log2_min_pu_size; int log2_min_tu_size = s->sps->log2_min_tb_size; int min_pu_width = s->sps->min_pu_width; int min_tu_width = s->sps->min_tb_width; - int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * min_pu_width + (x0 >> log2_min_pu_size)].is_intra; - + int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * min_pu_width + + (x0 >> log2_min_pu_size)].is_intra; int i, j; int bs; if (y0 > 0 && (y0 & 7) == 0) { int yp_pu = (y0 - 1) >> log2_min_pu_size; - int yq_pu = y0 >> log2_min_pu_size; + int yq_pu = y0 >> log2_min_pu_size; int yp_tu = (y0 - 1) >> log2_min_tu_size; - int yq_tu = y0 >> log2_min_tu_size; + int yq_tu = y0 >> log2_min_tu_size; for (i = 0; i < (1 << log2_trafo_size); i += 4) { int x_pu = (x0 + i) >> log2_min_pu_size; @@ -574,12 +619,18 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, int l MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu]; uint8_t top_cbf_luma = s->cbf_luma[yp_tu * min_tu_width + x_tu]; uint8_t curr_cbf_luma = s->cbf_luma[yq_tu * min_tu_width + x_tu]; - RefPicList* top_refPicList = ff_hevc_get_ref_list(s, s->ref, x0 + i, y0 - 1); - - bs = boundary_strength(s, curr, curr_cbf_luma, top, top_cbf_luma, top_refPicList, 1); - if (!s->sh.slice_loop_filter_across_slices_enabled_flag && (slice_or_tiles_up_boundary & 1) && (y0 % (1 << s->sps->log2_ctb_size)) == 0) + RefPicList *top_refPicList = ff_hevc_get_ref_list(s, s->ref, + x0 + i, y0 - 1); + + bs = boundary_strength(s, curr, curr_cbf_luma, + top, top_cbf_luma, top_refPicList, 1); + if (!s->sh.slice_loop_filter_across_slices_enabled_flag && + (slice_or_tiles_up_boundary & 1) && + (y0 % (1 << s->sps->log2_ctb_size)) == 0) bs = 0; - else if (!s->pps->loop_filter_across_tiles_enabled_flag && (slice_or_tiles_up_boundary & 2) && (y0 % (1 << s->sps->log2_ctb_size)) == 0) + else if (!s->pps->loop_filter_across_tiles_enabled_flag && + (slice_or_tiles_up_boundary & 2) && + (y0 % (1 << s->sps->log2_ctb_size)) == 0) bs = 0; if (y0 == 0 || s->sh.disable_deblocking_filter_flag == 1) bs = 0; @@ -596,17 +647,19 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, int l int yp_tu = (y0 + j - 1) >> log2_min_tu_size; int yq_tu = (y0 + j) >> log2_min_tu_size; - - for (i = 0; i < (1<<log2_trafo_size); i += 4) { + for (i = 0; i < (1 << log2_trafo_size); i += 4) { int x_pu = (x0 + i) >> log2_min_pu_size; int x_tu = (x0 + i) >> log2_min_tu_size; MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu]; MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu]; uint8_t top_cbf_luma = s->cbf_luma[yp_tu * min_tu_width + x_tu]; uint8_t curr_cbf_luma = s->cbf_luma[yq_tu * min_tu_width + x_tu]; - RefPicList* top_refPicList = ff_hevc_get_ref_list(s, s->ref, x0 + i, y0 + j - 1); + RefPicList *top_refPicList = ff_hevc_get_ref_list(s, s->ref, + x0 + i, + y0 + j - 1); - bs = boundary_strength(s, curr, curr_cbf_luma, top, top_cbf_luma, top_refPicList, 0); + bs = boundary_strength(s, curr, curr_cbf_luma, + top, top_cbf_luma, top_refPicList, 0); if (s->sh.disable_deblocking_filter_flag == 1) bs = 0; if (bs) @@ -622,19 +675,25 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, int l int xq_tu = x0 >> log2_min_tu_size; for (i = 0; i < (1 << log2_trafo_size); i += 4) { - int y_pu = (y0 + i) >> log2_min_pu_size; - int y_tu = (y0 + i) >> log2_min_tu_size; + int y_pu = (y0 + i) >> log2_min_pu_size; + int y_tu = (y0 + i) >> log2_min_tu_size; MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu]; MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu]; uint8_t left_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xp_tu]; uint8_t curr_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xq_tu]; - RefPicList* left_refPicList = ff_hevc_get_ref_list(s, s->ref, x0 - 1, y0 + i); - - bs = boundary_strength(s, curr, curr_cbf_luma, left, left_cbf_luma, left_refPicList, 1); - if (!s->sh.slice_loop_filter_across_slices_enabled_flag && (slice_or_tiles_left_boundary & 1) && (x0 % (1 << s->sps->log2_ctb_size)) == 0) + RefPicList *left_refPicList = ff_hevc_get_ref_list(s, s->ref, + x0 - 1, y0 + i); + + bs = boundary_strength(s, curr, curr_cbf_luma, + left, left_cbf_luma, left_refPicList, 1); + if (!s->sh.slice_loop_filter_across_slices_enabled_flag && + (slice_or_tiles_left_boundary & 1) && + (x0 % (1 << s->sps->log2_ctb_size)) == 0) bs = 0; - else if (!s->pps->loop_filter_across_tiles_enabled_flag && (slice_or_tiles_left_boundary & 2) && (x0 % (1 << s->sps->log2_ctb_size)) == 0) + else if (!s->pps->loop_filter_across_tiles_enabled_flag && + (slice_or_tiles_left_boundary & 2) && + (x0 % (1 << s->sps->log2_ctb_size)) == 0) bs = 0; if (x0 == 0 || s->sh.disable_deblocking_filter_flag == 1) bs = 0; @@ -651,16 +710,19 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, int l for (i = 8; i < (1 << log2_trafo_size); i += 8) { int xp_pu = (x0 + i - 1) >> log2_min_pu_size; - int xq_pu = (x0 + i) >> log2_min_pu_size; + int xq_pu = (x0 + i) >> log2_min_pu_size; int xp_tu = (x0 + i - 1) >> log2_min_tu_size; - int xq_tu = (x0 + i) >> log2_min_tu_size; + int xq_tu = (x0 + i) >> log2_min_tu_size; MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu]; MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu]; uint8_t left_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xp_tu]; uint8_t curr_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xq_tu]; - RefPicList* left_refPicList = ff_hevc_get_ref_list(s, s->ref, x0 + i - 1, y0 + j); + RefPicList *left_refPicList = ff_hevc_get_ref_list(s, s->ref, + x0 + i - 1, + y0 + j); - bs = boundary_strength(s, curr, curr_cbf_luma, left, left_cbf_luma, left_refPicList, 0); + bs = boundary_strength(s, curr, curr_cbf_luma, + left, left_cbf_luma, left_refPicList, 0); if (s->sh.disable_deblocking_filter_flag == 1) bs = 0; if (bs) @@ -668,6 +730,7 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, int l } } } + #undef LUMA #undef CB #undef CR |