Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/hevc_filter.c')
-rw-r--r--libavcodec/hevc_filter.c79
1 files changed, 45 insertions, 34 deletions
diff --git a/libavcodec/hevc_filter.c b/libavcodec/hevc_filter.c
index bb1e360dd4..a2b4f68a62 100644
--- a/libavcodec/hevc_filter.c
+++ b/libavcodec/hevc_filter.c
@@ -1,24 +1,24 @@
/*
- * HEVC video decoder
+ * HEVC video Decoder
*
* Copyright (C) 2012 - 2013 Guillaume Martres
* Copyright (C) 2013 Seppo Tomperi
* Copyright (C) 2013 Wassim Hamidouche
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -28,6 +28,7 @@
#include "cabac_functions.h"
#include "golomb.h"
#include "hevc.h"
+#include "bit_depth_template.c"
#define LUMA 0
#define CB 1
@@ -50,7 +51,9 @@ 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
};
- int qp, qp_i, offset, idxt;
+ int qp_i, offset;
+ int qp;
+ int idxt;
// slice qp offset is not used for deblocking
if (c_idx == 1)
@@ -73,7 +76,7 @@ static int chroma_tc(HEVCContext *s, int qp_y, int c_idx, int tc_offset)
static int get_qPy_pred(HEVCContext *s, int xC, int yC,
int xBase, int yBase, int log2_cb_size)
{
- HEVCLocalContext *lc = &s->HEVClc;
+ 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;
@@ -87,7 +90,9 @@ static int get_qPy_pred(HEVCContext *s, int xC, int yC,
(xQgBase & ctb_size_mask);
int availableB = (yBase & ctb_size_mask) &&
(yQgBase & ctb_size_mask);
- int qPy_pred, qPy_a, qPy_b;
+ int qPy_pred;
+ int qPy_a;
+ int qPy_b;
// qPy_pred
if (lc->first_qp_group) {
@@ -156,12 +161,12 @@ void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC,
{
int qp_y = get_qPy_pred(s, xC, yC, xBase, yBase, log2_cb_size);
- if (s->HEVClc.tu.cu_qp_delta != 0) {
+ 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) %
+ 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;
+ s->HEVClc->qp_y = qp_y;
}
static int get_qPy(HEVCContext *s, int xC, int yC)
@@ -208,13 +213,14 @@ static void sao_filter_CTB(HEVCContext *s, int x, int y)
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 left_tile_edge = 0, up_tile_edge = 0;
+ 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[3] = y_ctb == s->sps->ctb_height - 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;
@@ -326,26 +332,28 @@ static int get_pcm(HEVCContext *s, int x, int y)
return s->is_pcm[y_pu * s->sps->min_pu_width + x_pu];
}
-#define TC_CALC(qp, bs) \
- tctable[av_clip((qp) + DEFAULT_INTRA_TC_OFFSET * ((bs) - 1) + \
- (tc_offset >> 1 << 1), \
- 0, MAX_QP + DEFAULT_INTRA_TC_OFFSET)]
+#define TC_CALC(qp, bs) tctable[av_clip((qp) + DEFAULT_INTRA_TC_OFFSET * ((bs) - 1) + ((tc_offset >> 1) << 1), 0, MAX_QP + DEFAULT_INTRA_TC_OFFSET)]
static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
{
uint8_t *src;
- int x, y, x_end, y_end, chroma;
- int c_tc[2], beta[2], tc[2];
+ int x, y;
+ int chroma;
+ int c_tc[2];
+ int beta[2];
+ int tc[2];
uint8_t no_p[2] = { 0 };
uint8_t no_q[2] = { 0 };
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 cur_tc_offset = s->deblock[ctb].tc_offset;
int cur_beta_offset = s->deblock[ctb].beta_offset;
- int tc_offset, left_tc_offset, beta_offset, left_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;
@@ -374,8 +382,8 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
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)];
+ 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)];
@@ -407,7 +415,7 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
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);
@@ -439,8 +447,8 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
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)];
+ 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)];
@@ -479,13 +487,13 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
}
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 qp1 = bs1 == 2 ? (get_qPy(s, x + 8, y - 1) + get_qPy(s, x + 8, 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[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)];
+ 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)];
if (pcmf) {
no_p[0] = get_pcm(s, x, y - 1);
no_p[1] = get_pcm(s, x + 8, y - 1);
@@ -551,7 +559,8 @@ static int boundary_strength(HEVCContext *s, MvField *curr,
}
} else { // 1 MV
Mv A, B;
- int ref_A, ref_B;
+ int ref_A;
+ int ref_B;
if (curr->pred_flag[0]) {
A = curr->mv[0];
@@ -594,7 +603,8 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
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 i, j, bs;
+ int i, j;
+ int bs;
if (y0 > 0 && (y0 & 7) == 0) {
int yp_pu = (y0 - 1) >> log2_min_pu_size;
@@ -738,7 +748,8 @@ void ff_hevc_hls_filters(HEVCContext *s, int x_ctb, int y_ctb, int ctb_size)
ff_hevc_hls_filter(s, x_ctb - ctb_size, y_ctb - ctb_size);
if (y_ctb && x_ctb >= s->sps->width - ctb_size) {
ff_hevc_hls_filter(s, x_ctb, y_ctb - ctb_size);
- ff_thread_report_progress(&s->ref->tf, y_ctb - ctb_size, 0);
+ if (s->threads_type == FF_THREAD_FRAME )
+ ff_thread_report_progress(&s->ref->tf, y_ctb - ctb_size, 0);
}
if (x_ctb && y_ctb >= s->sps->height - ctb_size)
ff_hevc_hls_filter(s, x_ctb - ctb_size, y_ctb);