mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
hevc: more cosmetic(cherry picked from commit 9697abe41daa234602915f85bf6b1c0ca0252cff)
Decreases the difference to Anton Khirnovs patch v5 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
3c3ece24ea
commit
3106cbd321
@ -89,9 +89,9 @@ static int pic_arrays_init(HEVCContext *s)
|
|||||||
int pic_size_in_ctb = ((width >> log2_min_cb_size) + 1) *
|
int pic_size_in_ctb = ((width >> log2_min_cb_size) + 1) *
|
||||||
((height >> log2_min_cb_size) + 1);
|
((height >> log2_min_cb_size) + 1);
|
||||||
int ctb_count = s->sps->ctb_width * s->sps->ctb_height;
|
int ctb_count = s->sps->ctb_width * s->sps->ctb_height;
|
||||||
int pic_width_in_min_pu = width >> s->sps->log2_min_pu_size;
|
int min_pu_width = width >> s->sps->log2_min_pu_size;
|
||||||
int pic_height_in_min_pu = height >> s->sps->log2_min_pu_size;
|
int pic_height_in_min_pu = height >> s->sps->log2_min_pu_size;
|
||||||
int pic_size_in_min_pu = pic_width_in_min_pu * pic_height_in_min_pu;
|
int pic_size_in_min_pu = min_pu_width * pic_height_in_min_pu;
|
||||||
int pic_width_in_min_tu = width >> s->sps->log2_min_tb_size;
|
int pic_width_in_min_tu = width >> s->sps->log2_min_tb_size;
|
||||||
int pic_height_in_min_tu = height >> s->sps->log2_min_tb_size;
|
int pic_height_in_min_tu = height >> s->sps->log2_min_tb_size;
|
||||||
|
|
||||||
@ -116,8 +116,8 @@ static int pic_arrays_init(HEVCContext *s)
|
|||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
s->filter_slice_edges = av_malloc(ctb_count);
|
s->filter_slice_edges = av_malloc(ctb_count);
|
||||||
s->tab_slice_address = av_malloc(pic_size_in_ctb * sizeof(*s->tab_slice_address));
|
s->tab_slice_address = av_malloc(pic_size_in_ctb * sizeof(*s->tab_slice_address));
|
||||||
s->qp_y_tab = av_malloc(pic_size_in_ctb * sizeof(*s->qp_y_tab));
|
s->qp_y_tab = av_malloc(pic_size_in_ctb * sizeof(*s->qp_y_tab));
|
||||||
if (!s->qp_y_tab || !s->filter_slice_edges || !s->tab_slice_address)
|
if (!s->qp_y_tab || !s->filter_slice_edges || !s->tab_slice_address)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@ -128,12 +128,9 @@ static int pic_arrays_init(HEVCContext *s)
|
|||||||
|
|
||||||
s->tab_mvf_pool = av_buffer_pool_init(pic_size_in_min_pu * sizeof(MvField),
|
s->tab_mvf_pool = av_buffer_pool_init(pic_size_in_min_pu * sizeof(MvField),
|
||||||
av_buffer_alloc);
|
av_buffer_alloc);
|
||||||
if (!s->tab_mvf_pool)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
s->rpl_tab_pool = av_buffer_pool_init(ctb_count * sizeof(RefPicListTab),
|
s->rpl_tab_pool = av_buffer_pool_init(ctb_count * sizeof(RefPicListTab),
|
||||||
av_buffer_allocz);
|
av_buffer_allocz);
|
||||||
if (!s->rpl_tab_pool)
|
if (!s->tab_mvf_pool || !s->rpl_tab_pool)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -164,14 +161,12 @@ static void pred_weight_table(HEVCContext *s, GetBitContext *gb)
|
|||||||
s->sh.luma_offset_l0[i] = 0;
|
s->sh.luma_offset_l0[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s->sps->chroma_format_idc != 0) { //fix me ! invert "if" and "for"
|
if (s->sps->chroma_format_idc != 0) { // FIXME: invert "if" and "for"
|
||||||
for (i = 0; i < s->sh.nb_refs[L0]; i++) {
|
for (i = 0; i < s->sh.nb_refs[L0]; i++)
|
||||||
chroma_weight_l0_flag[i] = get_bits1(gb);
|
chroma_weight_l0_flag[i] = get_bits1(gb);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < s->sh.nb_refs[L0]; i++) {
|
for (i = 0; i < s->sh.nb_refs[L0]; i++)
|
||||||
chroma_weight_l0_flag[i] = 0;
|
chroma_weight_l0_flag[i] = 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (i = 0; i < s->sh.nb_refs[L0]; i++) {
|
for (i = 0; i < s->sh.nb_refs[L0]; i++) {
|
||||||
if (luma_weight_l0_flag[i]) {
|
if (luma_weight_l0_flag[i]) {
|
||||||
@ -185,7 +180,7 @@ static void pred_weight_table(HEVCContext *s, GetBitContext *gb)
|
|||||||
int delta_chroma_offset_l0 = get_se_golomb(gb);
|
int delta_chroma_offset_l0 = get_se_golomb(gb);
|
||||||
s->sh.chroma_weight_l0[i][j] = (1 << s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l0;
|
s->sh.chroma_weight_l0[i][j] = (1 << s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l0;
|
||||||
s->sh.chroma_offset_l0[i][j] = av_clip_c((delta_chroma_offset_l0 - ((128 * s->sh.chroma_weight_l0[i][j])
|
s->sh.chroma_offset_l0[i][j] = av_clip_c((delta_chroma_offset_l0 - ((128 * s->sh.chroma_weight_l0[i][j])
|
||||||
>> s->sh.chroma_log2_weight_denom) + 128), -128, 127);
|
>> s->sh.chroma_log2_weight_denom) + 128), -128, 127);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s->sh.chroma_weight_l0[i][0] = 1 << s->sh.chroma_log2_weight_denom;
|
s->sh.chroma_weight_l0[i][0] = 1 << s->sh.chroma_log2_weight_denom;
|
||||||
@ -203,13 +198,11 @@ static void pred_weight_table(HEVCContext *s, GetBitContext *gb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s->sps->chroma_format_idc != 0) {
|
if (s->sps->chroma_format_idc != 0) {
|
||||||
for (i = 0; i < s->sh.nb_refs[L1]; i++) {
|
for (i = 0; i < s->sh.nb_refs[L1]; i++)
|
||||||
chroma_weight_l1_flag[i] = get_bits1(gb);
|
chroma_weight_l1_flag[i] = get_bits1(gb);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < s->sh.nb_refs[L1]; i++) {
|
for (i = 0; i < s->sh.nb_refs[L1]; i++)
|
||||||
chroma_weight_l1_flag[i] = 0;
|
chroma_weight_l1_flag[i] = 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (i = 0; i < s->sh.nb_refs[L1]; i++) {
|
for (i = 0; i < s->sh.nb_refs[L1]; i++) {
|
||||||
if (luma_weight_l1_flag[i]) {
|
if (luma_weight_l1_flag[i]) {
|
||||||
@ -223,7 +216,7 @@ static void pred_weight_table(HEVCContext *s, GetBitContext *gb)
|
|||||||
int delta_chroma_offset_l1 = get_se_golomb(gb);
|
int delta_chroma_offset_l1 = get_se_golomb(gb);
|
||||||
s->sh.chroma_weight_l1[i][j] = (1 << s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l1;
|
s->sh.chroma_weight_l1[i][j] = (1 << s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l1;
|
||||||
s->sh.chroma_offset_l1[i][j] = av_clip_c((delta_chroma_offset_l1 - ((128 * s->sh.chroma_weight_l1[i][j])
|
s->sh.chroma_offset_l1[i][j] = av_clip_c((delta_chroma_offset_l1 - ((128 * s->sh.chroma_weight_l1[i][j])
|
||||||
>> s->sh.chroma_log2_weight_denom) + 128), -128, 127);
|
>> s->sh.chroma_log2_weight_denom) + 128), -128, 127);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s->sh.chroma_weight_l1[i][0] = 1 << s->sh.chroma_log2_weight_denom;
|
s->sh.chroma_weight_l1[i][0] = 1 << s->sh.chroma_log2_weight_denom;
|
||||||
@ -238,7 +231,7 @@ static void pred_weight_table(HEVCContext *s, GetBitContext *gb)
|
|||||||
static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb)
|
static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb)
|
||||||
{
|
{
|
||||||
const HEVCSPS *sps = s->sps;
|
const HEVCSPS *sps = s->sps;
|
||||||
int max_poc_lsb = 1 << sps->log2_max_poc_lsb;
|
int max_poc_lsb = 1 << sps->log2_max_poc_lsb;
|
||||||
int prev_delta_msb = 0;
|
int prev_delta_msb = 0;
|
||||||
int nb_sps = 0, nb_sh;
|
int nb_sps = 0, nb_sh;
|
||||||
int i;
|
int i;
|
||||||
@ -297,7 +290,7 @@ static int hls_slice_header(HEVCContext *s)
|
|||||||
sh->first_slice_in_pic_flag = get_bits1(gb);
|
sh->first_slice_in_pic_flag = get_bits1(gb);
|
||||||
if ((IS_IDR(s) || IS_BLA(s)) && sh->first_slice_in_pic_flag) {
|
if ((IS_IDR(s) || IS_BLA(s)) && sh->first_slice_in_pic_flag) {
|
||||||
s->seq_decode = (s->seq_decode + 1) & 0xff;
|
s->seq_decode = (s->seq_decode + 1) & 0xff;
|
||||||
s->max_ra = INT_MAX;
|
s->max_ra = INT_MAX;
|
||||||
if (IS_IDR(s))
|
if (IS_IDR(s))
|
||||||
ff_hevc_clear_refs(s);
|
ff_hevc_clear_refs(s);
|
||||||
}
|
}
|
||||||
@ -361,7 +354,7 @@ static int hls_slice_header(HEVCContext *s)
|
|||||||
sh->dependent_slice_segment_flag = get_bits1(gb);
|
sh->dependent_slice_segment_flag = get_bits1(gb);
|
||||||
|
|
||||||
slice_address_length = av_ceil_log2(s->sps->ctb_width *
|
slice_address_length = av_ceil_log2(s->sps->ctb_width *
|
||||||
s->sps->ctb_height);
|
s->sps->ctb_height);
|
||||||
sh->slice_segment_addr = get_bits(gb, slice_address_length);
|
sh->slice_segment_addr = get_bits(gb, slice_address_length);
|
||||||
if (sh->slice_segment_addr >= s->sps->ctb_width * s->sps->ctb_height) {
|
if (sh->slice_segment_addr >= s->sps->ctb_width * s->sps->ctb_height) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "Invalid slice segment address: %u.\n",
|
av_log(s->avctx, AV_LOG_ERROR, "Invalid slice segment address: %u.\n",
|
||||||
@ -375,8 +368,8 @@ static int hls_slice_header(HEVCContext *s)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sh->slice_segment_addr = sh->slice_addr = 0;
|
sh->slice_segment_addr = sh->slice_addr = 0;
|
||||||
s->slice_idx = 0;
|
s->slice_idx = 0;
|
||||||
s->slice_initialized = 0;
|
s->slice_initialized = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sh->dependent_slice_segment_flag) {
|
if (!sh->dependent_slice_segment_flag) {
|
||||||
@ -450,6 +443,7 @@ static int hls_slice_header(HEVCContext *s)
|
|||||||
s->poc = 0;
|
s->poc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 8.3.1 */
|
||||||
if (s->temporal_id == 0 &&
|
if (s->temporal_id == 0 &&
|
||||||
s->nal_unit_type != NAL_TRAIL_N &&
|
s->nal_unit_type != NAL_TRAIL_N &&
|
||||||
s->nal_unit_type != NAL_TSA_N &&
|
s->nal_unit_type != NAL_TSA_N &&
|
||||||
@ -462,8 +456,8 @@ static int hls_slice_header(HEVCContext *s)
|
|||||||
|
|
||||||
if (s->sps->sao_enabled) {
|
if (s->sps->sao_enabled) {
|
||||||
sh->slice_sample_adaptive_offset_flag[0] = get_bits1(gb);
|
sh->slice_sample_adaptive_offset_flag[0] = get_bits1(gb);
|
||||||
sh->slice_sample_adaptive_offset_flag[2] =
|
sh->slice_sample_adaptive_offset_flag[1] =
|
||||||
sh->slice_sample_adaptive_offset_flag[1] = get_bits1(gb);
|
sh->slice_sample_adaptive_offset_flag[2] = get_bits1(gb);
|
||||||
} else {
|
} else {
|
||||||
sh->slice_sample_adaptive_offset_flag[0] = 0;
|
sh->slice_sample_adaptive_offset_flag[0] = 0;
|
||||||
sh->slice_sample_adaptive_offset_flag[1] = 0;
|
sh->slice_sample_adaptive_offset_flag[1] = 0;
|
||||||
@ -542,6 +536,12 @@ static int hls_slice_header(HEVCContext *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sh->max_num_merge_cand = 5 - get_ue_golomb_long(gb);
|
sh->max_num_merge_cand = 5 - get_ue_golomb_long(gb);
|
||||||
|
if (sh->max_num_merge_cand < 1 || sh->max_num_merge_cand > 5) {
|
||||||
|
av_log(s->avctx, AV_LOG_ERROR,
|
||||||
|
"Invalid number of merging MVP candidates: %d.\n",
|
||||||
|
sh->max_num_merge_cand);
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sh->slice_qp_delta = get_se_golomb(gb);
|
sh->slice_qp_delta = get_se_golomb(gb);
|
||||||
@ -729,12 +729,12 @@ static void hls_sao_param(HEVCContext *s, int rx, int ry)
|
|||||||
#undef CTB
|
#undef CTB
|
||||||
|
|
||||||
|
|
||||||
static void hls_transform_unit(HEVCContext *s, int x0, int y0, int xBase, int yBase, int cb_xBase, int cb_yBase,
|
static void hls_transform_unit(HEVCContext *s, int x0, int y0,
|
||||||
int log2_cb_size, int log2_trafo_size, int trafo_depth, int blk_idx)
|
int xBase, int yBase, int cb_xBase, int cb_yBase,
|
||||||
|
int log2_cb_size, int log2_trafo_size,
|
||||||
|
int trafo_depth, int blk_idx)
|
||||||
{
|
{
|
||||||
HEVCLocalContext *lc = s->HEVClc;
|
HEVCLocalContext *lc = s->HEVClc;
|
||||||
int scan_idx = SCAN_DIAG;
|
|
||||||
int scan_idx_c = SCAN_DIAG;
|
|
||||||
|
|
||||||
if (lc->cu.pred_mode == MODE_INTRA) {
|
if (lc->cu.pred_mode == MODE_INTRA) {
|
||||||
int trafo_size = 1 << log2_trafo_size;
|
int trafo_size = 1 << log2_trafo_size;
|
||||||
@ -742,12 +742,12 @@ static void hls_transform_unit(HEVCContext *s, int x0, int y0, int xBase, int y
|
|||||||
|
|
||||||
s->hpc.intra_pred(s, x0, y0, log2_trafo_size, 0);
|
s->hpc.intra_pred(s, x0, y0, log2_trafo_size, 0);
|
||||||
if (log2_trafo_size > 2) {
|
if (log2_trafo_size > 2) {
|
||||||
trafo_size = trafo_size<<(s->sps->hshift[1]-1);
|
trafo_size = trafo_size << (s->sps->hshift[1] - 1);
|
||||||
ff_hevc_set_neighbour_available(s, x0, y0, trafo_size, trafo_size);
|
ff_hevc_set_neighbour_available(s, x0, y0, trafo_size, trafo_size);
|
||||||
s->hpc.intra_pred(s, x0, y0, log2_trafo_size - 1, 1);
|
s->hpc.intra_pred(s, x0, y0, log2_trafo_size - 1, 1);
|
||||||
s->hpc.intra_pred(s, x0, y0, log2_trafo_size - 1, 2);
|
s->hpc.intra_pred(s, x0, y0, log2_trafo_size - 1, 2);
|
||||||
} else if (blk_idx == 3) {
|
} else if (blk_idx == 3) {
|
||||||
trafo_size = trafo_size<<(s->sps->hshift[1]);
|
trafo_size = trafo_size << (s->sps->hshift[1]);
|
||||||
ff_hevc_set_neighbour_available(s, xBase, yBase, trafo_size, trafo_size);
|
ff_hevc_set_neighbour_available(s, xBase, yBase, trafo_size, trafo_size);
|
||||||
s->hpc.intra_pred(s, xBase, yBase, log2_trafo_size, 1);
|
s->hpc.intra_pred(s, xBase, yBase, log2_trafo_size, 1);
|
||||||
s->hpc.intra_pred(s, xBase, yBase, log2_trafo_size, 2);
|
s->hpc.intra_pred(s, xBase, yBase, log2_trafo_size, 2);
|
||||||
@ -757,6 +757,9 @@ static void hls_transform_unit(HEVCContext *s, int x0, int y0, int xBase, int y
|
|||||||
if (lc->tt.cbf_luma ||
|
if (lc->tt.cbf_luma ||
|
||||||
SAMPLE_CBF(lc->tt.cbf_cb[trafo_depth], x0, y0) ||
|
SAMPLE_CBF(lc->tt.cbf_cb[trafo_depth], x0, y0) ||
|
||||||
SAMPLE_CBF(lc->tt.cbf_cr[trafo_depth], x0, y0)) {
|
SAMPLE_CBF(lc->tt.cbf_cr[trafo_depth], x0, y0)) {
|
||||||
|
int scan_idx = SCAN_DIAG;
|
||||||
|
int scan_idx_c = SCAN_DIAG;
|
||||||
|
|
||||||
if (s->pps->cu_qp_delta_enabled_flag && !lc->tu.is_cu_qp_delta_coded) {
|
if (s->pps->cu_qp_delta_enabled_flag && !lc->tu.is_cu_qp_delta_coded) {
|
||||||
lc->tu.cu_qp_delta = ff_hevc_cu_qp_delta_abs(s);
|
lc->tu.cu_qp_delta = ff_hevc_cu_qp_delta_abs(s);
|
||||||
if (lc->tu.cu_qp_delta != 0)
|
if (lc->tu.cu_qp_delta != 0)
|
||||||
@ -802,17 +805,17 @@ static void hls_transform_unit(HEVCContext *s, int x0, int y0, int xBase, int y
|
|||||||
|
|
||||||
static void set_deblocking_bypass(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
static void set_deblocking_bypass(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
||||||
{
|
{
|
||||||
int cb_size = 1 << log2_cb_size;
|
int cb_size = 1 << log2_cb_size;
|
||||||
int log2_min_pu_size = s->sps->log2_min_pu_size;
|
int log2_min_pu_size = s->sps->log2_min_pu_size;
|
||||||
|
|
||||||
int pic_width_in_min_pu = s->sps->width >> s->sps->log2_min_pu_size;
|
int min_pu_width = s->sps->width >> s->sps->log2_min_pu_size;
|
||||||
int x_end = FFMIN(x0 + cb_size, s->sps->width);
|
int x_end = FFMIN(x0 + cb_size, s->sps->width);
|
||||||
int y_end = FFMIN(y0 + cb_size, s->sps->height);
|
int y_end = FFMIN(y0 + cb_size, s->sps->height);
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++)
|
for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++)
|
||||||
for (i = (x0 >> log2_min_pu_size); i < (x_end >> log2_min_pu_size); i++)
|
for (i = (x0 >> log2_min_pu_size); i < (x_end >> log2_min_pu_size); i++)
|
||||||
s->is_pcm[i + j * pic_width_in_min_pu] = 2;
|
s->is_pcm[i + j * min_pu_width] = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hls_transform_tree(HEVCContext *s, int x0, int y0, int xBase, int yBase, int cb_xBase, int cb_yBase,
|
static void hls_transform_tree(HEVCContext *s, int x0, int y0, int xBase, int yBase, int cb_xBase, int cb_yBase,
|
||||||
@ -1071,7 +1074,7 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0, int nPbW, int nP
|
|||||||
enum InterPredIdc inter_pred_idc = PRED_L0;
|
enum InterPredIdc inter_pred_idc = PRED_L0;
|
||||||
struct MvField current_mv = {{{ 0 }}};
|
struct MvField current_mv = {{{ 0 }}};
|
||||||
|
|
||||||
int pic_width_in_min_pu = s->sps->width >> s->sps->log2_min_pu_size;
|
int min_pu_width = s->sps->width >> s->sps->log2_min_pu_size;
|
||||||
|
|
||||||
MvField *tab_mvf = s->ref->tab_mvf;
|
MvField *tab_mvf = s->ref->tab_mvf;
|
||||||
RefPicList *refPicList = s->ref->refPicList;
|
RefPicList *refPicList = s->ref->refPicList;
|
||||||
@ -1104,7 +1107,7 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0, int nPbW, int nP
|
|||||||
|
|
||||||
for (i = 0; i < nPbW >> s->sps->log2_min_pu_size; i++)
|
for (i = 0; i < nPbW >> s->sps->log2_min_pu_size; i++)
|
||||||
for (j = 0; j < nPbH >> s->sps->log2_min_pu_size; j++)
|
for (j = 0; j < nPbH >> s->sps->log2_min_pu_size; j++)
|
||||||
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i] = current_mv;
|
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv;
|
||||||
} else { /* MODE_INTER */
|
} else { /* MODE_INTER */
|
||||||
lc->pu.merge_flag = ff_hevc_merge_flag_decode(s);
|
lc->pu.merge_flag = ff_hevc_merge_flag_decode(s);
|
||||||
if (lc->pu.merge_flag) {
|
if (lc->pu.merge_flag) {
|
||||||
@ -1120,7 +1123,7 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0, int nPbW, int nP
|
|||||||
|
|
||||||
for (i = 0; i < nPbW >> s->sps->log2_min_pu_size; i++)
|
for (i = 0; i < nPbW >> s->sps->log2_min_pu_size; i++)
|
||||||
for (j = 0; j < nPbH >> s->sps->log2_min_pu_size; j++)
|
for (j = 0; j < nPbH >> s->sps->log2_min_pu_size; j++)
|
||||||
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i] = current_mv;
|
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv;
|
||||||
} else {
|
} else {
|
||||||
ff_hevc_set_neighbour_available(s, x0, y0, nPbW, nPbH);
|
ff_hevc_set_neighbour_available(s, x0, y0, nPbW, nPbH);
|
||||||
if (s->sh.slice_type == B_SLICE)
|
if (s->sh.slice_type == B_SLICE)
|
||||||
@ -1166,7 +1169,7 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0, int nPbW, int nP
|
|||||||
|
|
||||||
for (i = 0; i < nPbW >> s->sps->log2_min_pu_size; i++)
|
for (i = 0; i < nPbW >> s->sps->log2_min_pu_size; i++)
|
||||||
for(j = 0; j < nPbH >> s->sps->log2_min_pu_size; j++)
|
for(j = 0; j < nPbH >> s->sps->log2_min_pu_size; j++)
|
||||||
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i] = current_mv;
|
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1319,13 +1322,13 @@ static int luma_intra_pred_mode(HEVCContext *s, int x0, int y0, int pu_size,
|
|||||||
HEVCLocalContext *lc = s->HEVClc;
|
HEVCLocalContext *lc = s->HEVClc;
|
||||||
int x_pu = x0 >> s->sps->log2_min_pu_size;
|
int x_pu = x0 >> s->sps->log2_min_pu_size;
|
||||||
int y_pu = y0 >> s->sps->log2_min_pu_size;
|
int y_pu = y0 >> s->sps->log2_min_pu_size;
|
||||||
int pic_width_in_min_pu = s->sps->width >> s->sps->log2_min_pu_size;
|
int min_pu_width = s->sps->width >> s->sps->log2_min_pu_size;
|
||||||
int size_in_pus = pu_size >> s->sps->log2_min_pu_size;
|
int size_in_pus = pu_size >> s->sps->log2_min_pu_size;
|
||||||
int x0b = x0 & ((1 << s->sps->log2_ctb_size) - 1);
|
int x0b = x0 & ((1 << s->sps->log2_ctb_size) - 1);
|
||||||
int y0b = y0 & ((1 << s->sps->log2_ctb_size) - 1);
|
int y0b = y0 & ((1 << s->sps->log2_ctb_size) - 1);
|
||||||
|
|
||||||
int cand_up = (lc->ctb_up_flag || y0b) ? s->tab_ipm[(y_pu-1)*pic_width_in_min_pu+x_pu] : INTRA_DC ;
|
int cand_up = (lc->ctb_up_flag || y0b) ? s->tab_ipm[(y_pu-1)*min_pu_width+x_pu] : INTRA_DC ;
|
||||||
int cand_left = (lc->ctb_left_flag || x0b) ? s->tab_ipm[y_pu*pic_width_in_min_pu+x_pu-1] : INTRA_DC ;
|
int cand_left = (lc->ctb_left_flag || x0b) ? s->tab_ipm[y_pu*min_pu_width+x_pu-1] : INTRA_DC ;
|
||||||
|
|
||||||
int y_ctb = (y0 >> (s->sps->log2_ctb_size)) << (s->sps->log2_ctb_size);
|
int y_ctb = (y0 >> (s->sps->log2_ctb_size)) << (s->sps->log2_ctb_size);
|
||||||
MvField *tab_mvf = s->ref->tab_mvf;
|
MvField *tab_mvf = s->ref->tab_mvf;
|
||||||
@ -1380,19 +1383,19 @@ static int luma_intra_pred_mode(HEVCContext *s, int x0, int y0, int pu_size,
|
|||||||
if(!size_in_pus)
|
if(!size_in_pus)
|
||||||
size_in_pus = 1;
|
size_in_pus = 1;
|
||||||
for (i = 0; i < size_in_pus; i++) {
|
for (i = 0; i < size_in_pus; i++) {
|
||||||
memset(&s->tab_ipm[(y_pu + i) * pic_width_in_min_pu + x_pu],
|
memset(&s->tab_ipm[(y_pu + i) * min_pu_width + x_pu],
|
||||||
intra_pred_mode, size_in_pus);
|
intra_pred_mode, size_in_pus);
|
||||||
|
|
||||||
for (j = 0; j < size_in_pus; j++) {
|
for (j = 0; j < size_in_pus; j++) {
|
||||||
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i].is_intra = 1;
|
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].is_intra = 1;
|
||||||
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i].pred_flag[0] = 0;
|
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].pred_flag[0] = 0;
|
||||||
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i].pred_flag[1] = 0;
|
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].pred_flag[1] = 0;
|
||||||
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i].ref_idx[0] = 0;
|
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].ref_idx[0] = 0;
|
||||||
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i].ref_idx[1] = 0;
|
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].ref_idx[1] = 0;
|
||||||
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i].mv[0].x = 0;
|
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].mv[0].x = 0;
|
||||||
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i].mv[0].y = 0;
|
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].mv[0].y = 0;
|
||||||
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i].mv[1].x = 0;
|
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].mv[1].x = 0;
|
||||||
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i].mv[1].y = 0;
|
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].mv[1].y = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1454,20 +1457,20 @@ static void intra_prediction_unit(HEVCContext *s, int x0, int y0, int log2_cb_si
|
|||||||
static void intra_prediction_unit_default_value(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
static void intra_prediction_unit_default_value(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
||||||
{
|
{
|
||||||
HEVCLocalContext *lc = s->HEVClc;
|
HEVCLocalContext *lc = s->HEVClc;
|
||||||
int pb_size = 1 << log2_cb_size;
|
int pb_size = 1 << log2_cb_size;
|
||||||
int size_in_pus = pb_size >> s->sps->log2_min_pu_size;
|
int size_in_pus = pb_size >> s->sps->log2_min_pu_size;
|
||||||
int pic_width_in_min_pu = s->sps->width >> s->sps->log2_min_pu_size;
|
int min_pu_width = s->sps->min_pu_width;
|
||||||
MvField *tab_mvf = s->ref->tab_mvf;
|
MvField *tab_mvf = s->ref->tab_mvf;
|
||||||
int x_pu = x0 >> s->sps->log2_min_pu_size;
|
int x_pu = x0 >> s->sps->log2_min_pu_size;
|
||||||
int y_pu = y0 >> s->sps->log2_min_pu_size;
|
int y_pu = y0 >> s->sps->log2_min_pu_size;
|
||||||
int j, k;
|
int j, k;
|
||||||
|
|
||||||
if (size_in_pus == 0)
|
if (size_in_pus == 0)
|
||||||
size_in_pus = 1;
|
size_in_pus = 1;
|
||||||
for (j = 0; j < size_in_pus; j++) {
|
for (j = 0; j < size_in_pus; j++) {
|
||||||
memset(&s->tab_ipm[(y_pu + j) * pic_width_in_min_pu + x_pu], INTRA_DC, size_in_pus);
|
memset(&s->tab_ipm[(y_pu + j) * min_pu_width + x_pu], INTRA_DC, size_in_pus);
|
||||||
for (k = 0; k <size_in_pus; k++)
|
for (k = 0; k < size_in_pus; k++)
|
||||||
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + k].is_intra = lc->cu.pred_mode == MODE_INTRA;
|
tab_mvf[(y_pu + j) * min_pu_width + x_pu + k].is_intra = lc->cu.pred_mode == MODE_INTRA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1477,19 +1480,19 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
|||||||
HEVCLocalContext *lc = s->HEVClc;
|
HEVCLocalContext *lc = s->HEVClc;
|
||||||
int log2_min_cb_size = s->sps->log2_min_cb_size;
|
int log2_min_cb_size = s->sps->log2_min_cb_size;
|
||||||
int length = cb_size >> log2_min_cb_size;
|
int length = cb_size >> log2_min_cb_size;
|
||||||
int min_cb_width = s->sps->width >> log2_min_cb_size;
|
int min_cb_width = s->sps->min_cb_width;
|
||||||
int x_cb = x0 >> log2_min_cb_size;
|
int x_cb = x0 >> log2_min_cb_size;
|
||||||
int y_cb = y0 >> log2_min_cb_size;
|
int y_cb = y0 >> log2_min_cb_size;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
lc->cu.x = x0;
|
lc->cu.x = x0;
|
||||||
lc->cu.y = y0;
|
lc->cu.y = y0;
|
||||||
lc->cu.rqt_root_cbf = 1;
|
lc->cu.rqt_root_cbf = 1;
|
||||||
|
|
||||||
lc->cu.pred_mode = MODE_INTRA;
|
lc->cu.pred_mode = MODE_INTRA;
|
||||||
lc->cu.part_mode = PART_2Nx2N;
|
lc->cu.part_mode = PART_2Nx2N;
|
||||||
lc->cu.intra_split_flag = 0;
|
lc->cu.intra_split_flag = 0;
|
||||||
lc->cu.pcm_flag = 0;
|
lc->cu.pcm_flag = 0;
|
||||||
SAMPLE_CTB(s->skip_flag, x_cb, y_cb) = 0;
|
SAMPLE_CTB(s->skip_flag, x_cb, y_cb) = 0;
|
||||||
for (x = 0; x < 4; x++)
|
for (x = 0; x < 4; x++)
|
||||||
lc->pu.intra_pred_mode[x] = 1;
|
lc->pu.intra_pred_mode[x] = 1;
|
||||||
@ -1525,7 +1528,7 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
|||||||
lc->cu.pred_mode = ff_hevc_pred_mode_decode(s);
|
lc->cu.pred_mode = ff_hevc_pred_mode_decode(s);
|
||||||
if (lc->cu.pred_mode != MODE_INTRA ||
|
if (lc->cu.pred_mode != MODE_INTRA ||
|
||||||
log2_cb_size == s->sps->log2_min_cb_size) {
|
log2_cb_size == s->sps->log2_min_cb_size) {
|
||||||
lc->cu.part_mode = ff_hevc_part_mode_decode(s, log2_cb_size);
|
lc->cu.part_mode = ff_hevc_part_mode_decode(s, log2_cb_size);
|
||||||
lc->cu.intra_split_flag = lc->cu.part_mode == PART_NxN &&
|
lc->cu.intra_split_flag = lc->cu.part_mode == PART_NxN &&
|
||||||
lc->cu.pred_mode == MODE_INTRA;
|
lc->cu.pred_mode == MODE_INTRA;
|
||||||
}
|
}
|
||||||
@ -1540,7 +1543,7 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
|||||||
int ret;
|
int ret;
|
||||||
intra_prediction_unit_default_value(s, x0, y0, log2_cb_size);
|
intra_prediction_unit_default_value(s, x0, y0, log2_cb_size);
|
||||||
ret = hls_pcm_sample(s, x0, y0, log2_cb_size);
|
ret = hls_pcm_sample(s, x0, y0, log2_cb_size);
|
||||||
if(s->sps->pcm.loop_filter_disable_flag)
|
if (s->sps->pcm.loop_filter_disable_flag)
|
||||||
set_deblocking_bypass(s, x0, y0, log2_cb_size);
|
set_deblocking_bypass(s, x0, y0, log2_cb_size);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -1594,8 +1597,8 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
|||||||
}
|
}
|
||||||
if (lc->cu.rqt_root_cbf) {
|
if (lc->cu.rqt_root_cbf) {
|
||||||
lc->cu.max_trafo_depth = lc->cu.pred_mode == MODE_INTRA ?
|
lc->cu.max_trafo_depth = lc->cu.pred_mode == MODE_INTRA ?
|
||||||
s->sps->max_transform_hierarchy_depth_intra + lc->cu.intra_split_flag :
|
s->sps->max_transform_hierarchy_depth_intra + lc->cu.intra_split_flag :
|
||||||
s->sps->max_transform_hierarchy_depth_inter;
|
s->sps->max_transform_hierarchy_depth_inter;
|
||||||
hls_transform_tree(s, x0, y0, x0, y0, x0, y0, log2_cb_size,
|
hls_transform_tree(s, x0, y0, x0, y0, x0, y0, log2_cb_size,
|
||||||
log2_cb_size, 0, 0);
|
log2_cb_size, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
@ -1621,14 +1624,16 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hls_coding_quadtree(HEVCContext *s, int x0, int y0, int log2_cb_size, int cb_depth)
|
static int hls_coding_quadtree(HEVCContext *s, int x0, int y0,
|
||||||
|
int log2_cb_size, int cb_depth)
|
||||||
{
|
{
|
||||||
HEVCLocalContext *lc = s->HEVClc;
|
HEVCLocalContext *lc = s->HEVClc;
|
||||||
|
const int cb_size = 1 << log2_cb_size;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
lc->ct.depth = cb_depth;
|
lc->ct.depth = cb_depth;
|
||||||
if ((x0 + (1 << log2_cb_size) <= s->sps->width) &&
|
if ((x0 + cb_size <= s->sps->width) &&
|
||||||
(y0 + (1 << log2_cb_size) <= s->sps->height) &&
|
(y0 + cb_size <= s->sps->height) &&
|
||||||
log2_cb_size > s->sps->log2_min_cb_size) {
|
log2_cb_size > s->sps->log2_min_cb_size) {
|
||||||
SAMPLE(s->split_cu_flag, x0, y0) =
|
SAMPLE(s->split_cu_flag, x0, y0) =
|
||||||
ff_hevc_split_coding_unit_flag_decode(s, cb_depth, x0, y0);
|
ff_hevc_split_coding_unit_flag_decode(s, cb_depth, x0, y0);
|
||||||
@ -1643,10 +1648,10 @@ static int hls_coding_quadtree(HEVCContext *s, int x0, int y0, int log2_cb_size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (SAMPLE(s->split_cu_flag, x0, y0)) {
|
if (SAMPLE(s->split_cu_flag, x0, y0)) {
|
||||||
|
const int cb_size_split = cb_size >> 1;
|
||||||
|
const int x1 = x0 + cb_size_split;
|
||||||
|
const int y1 = y0 + cb_size_split;
|
||||||
int more_data = 0;
|
int more_data = 0;
|
||||||
int cb_size = (1 << (log2_cb_size)) >> 1;
|
|
||||||
int x1 = x0 + cb_size;
|
|
||||||
int y1 = y0 + cb_size;
|
|
||||||
|
|
||||||
more_data = hls_coding_quadtree(s, x0, y0, log2_cb_size - 1, cb_depth + 1);
|
more_data = hls_coding_quadtree(s, x0, y0, log2_cb_size - 1, cb_depth + 1);
|
||||||
if (more_data < 0)
|
if (more_data < 0)
|
||||||
@ -1661,20 +1666,20 @@ static int hls_coding_quadtree(HEVCContext *s, int x0, int y0, int log2_cb_size,
|
|||||||
return hls_coding_quadtree(s, x1, y1, log2_cb_size - 1, cb_depth + 1);
|
return hls_coding_quadtree(s, x1, y1, log2_cb_size - 1, cb_depth + 1);
|
||||||
}
|
}
|
||||||
if (more_data)
|
if (more_data)
|
||||||
return ((x1 + cb_size) < s->sps->width ||
|
return ((x1 + cb_size_split) < s->sps->width ||
|
||||||
(y1 + cb_size) < s->sps->height);
|
(y1 + cb_size_split) < s->sps->height);
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
ret = hls_coding_unit(s, x0, y0, log2_cb_size);
|
ret = hls_coding_unit(s, x0, y0, log2_cb_size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
if ((!((x0 + (1 << log2_cb_size)) %
|
if ((!((x0 + cb_size) %
|
||||||
(1 << (s->sps->log2_ctb_size))) ||
|
(1 << (s->sps->log2_ctb_size))) ||
|
||||||
(x0 + (1 << log2_cb_size) >= s->sps->width)) &&
|
(x0 + cb_size >= s->sps->width)) &&
|
||||||
(!((y0 + (1 << log2_cb_size)) %
|
(!((y0 + cb_size) %
|
||||||
(1 << (s->sps->log2_ctb_size))) ||
|
(1 << (s->sps->log2_ctb_size))) ||
|
||||||
(y0 + (1 << log2_cb_size) >= s->sps->height))) {
|
(y0 + cb_size >= s->sps->height))) {
|
||||||
int end_of_slice_flag = ff_hevc_end_of_slice_flag_decode(s);
|
int end_of_slice_flag = ff_hevc_end_of_slice_flag_decode(s);
|
||||||
return !end_of_slice_flag;
|
return !end_of_slice_flag;
|
||||||
} else {
|
} else {
|
||||||
@ -1685,10 +1690,6 @@ static int hls_coding_quadtree(HEVCContext *s, int x0, int y0, int log2_cb_size,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 7.3.4
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void hls_decode_neighbour(HEVCContext *s, int x_ctb, int y_ctb, int ctb_addr_ts)
|
static void hls_decode_neighbour(HEVCContext *s, int x_ctb, int y_ctb, int ctb_addr_ts)
|
||||||
{
|
{
|
||||||
HEVCLocalContext *lc = s->HEVClc;
|
HEVCLocalContext *lc = s->HEVClc;
|
||||||
@ -1703,7 +1704,6 @@ static void hls_decode_neighbour(HEVCContext *s, int x_ctb, int y_ctb, int ctb_a
|
|||||||
|
|
||||||
s->tab_slice_address[ctb_addr_rs] = s->sh.slice_addr;
|
s->tab_slice_address[ctb_addr_rs] = s->sh.slice_addr;
|
||||||
|
|
||||||
|
|
||||||
if (s->pps->entropy_coding_sync_enabled_flag) {
|
if (s->pps->entropy_coding_sync_enabled_flag) {
|
||||||
if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0)
|
if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0)
|
||||||
lc->first_qp_group = 1;
|
lc->first_qp_group = 1;
|
||||||
@ -1712,7 +1712,7 @@ static void hls_decode_neighbour(HEVCContext *s, int x_ctb, int y_ctb, int ctb_a
|
|||||||
if (ctb_addr_ts && s->pps->tile_id[ctb_addr_ts] != s->pps->tile_id[ctb_addr_ts - 1]) {
|
if (ctb_addr_ts && s->pps->tile_id[ctb_addr_ts] != s->pps->tile_id[ctb_addr_ts - 1]) {
|
||||||
int idxX = s->pps->col_idxX[x_ctb >> s->sps->log2_ctb_size];
|
int idxX = s->pps->col_idxX[x_ctb >> s->sps->log2_ctb_size];
|
||||||
lc->start_of_tiles_x = x_ctb;
|
lc->start_of_tiles_x = x_ctb;
|
||||||
lc->end_of_tiles_x = x_ctb + (s->pps->column_width[idxX]<< s->sps->log2_ctb_size);
|
lc->end_of_tiles_x = x_ctb + (s->pps->column_width[idxX] << s->sps->log2_ctb_size);
|
||||||
lc->first_qp_group = 1;
|
lc->first_qp_group = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1722,19 +1722,19 @@ static void hls_decode_neighbour(HEVCContext *s, int x_ctb, int y_ctb, int ctb_a
|
|||||||
lc->end_of_tiles_y = FFMIN(y_ctb + ctb_size, s->sps->height);
|
lc->end_of_tiles_y = FFMIN(y_ctb + ctb_size, s->sps->height);
|
||||||
|
|
||||||
if (s->pps->tiles_enabled_flag) {
|
if (s->pps->tiles_enabled_flag) {
|
||||||
tile_left_boundary = ((x_ctb > 0) &&
|
tile_left_boundary = ((x_ctb > 0) &&
|
||||||
(s->pps->tile_id[ctb_addr_ts] == s->pps->tile_id[s->pps->ctb_addr_rs_to_ts[ctb_addr_rs-1]]));
|
(s->pps->tile_id[ctb_addr_ts] == s->pps->tile_id[s->pps->ctb_addr_rs_to_ts[ctb_addr_rs - 1]]));
|
||||||
slice_left_boundary = ((x_ctb > 0) &&
|
slice_left_boundary = ((x_ctb > 0) &&
|
||||||
(s->tab_slice_address[ctb_addr_rs] == s->tab_slice_address[ctb_addr_rs - 1]));
|
(s->tab_slice_address[ctb_addr_rs] == s->tab_slice_address[ctb_addr_rs - 1]));
|
||||||
tile_up_boundary = ((y_ctb > 0) &&
|
tile_up_boundary = ((y_ctb > 0) &&
|
||||||
(s->pps->tile_id[ctb_addr_ts] == s->pps->tile_id[s->pps->ctb_addr_rs_to_ts[ctb_addr_rs - s->sps->ctb_width]]));
|
(s->pps->tile_id[ctb_addr_ts] == s->pps->tile_id[s->pps->ctb_addr_rs_to_ts[ctb_addr_rs - s->sps->ctb_width]]));
|
||||||
slice_up_boundary = ((y_ctb > 0) &&
|
slice_up_boundary = ((y_ctb > 0) &&
|
||||||
(s->tab_slice_address[ctb_addr_rs] == s->tab_slice_address[ctb_addr_rs - s->sps->ctb_width]));
|
(s->tab_slice_address[ctb_addr_rs] == s->tab_slice_address[ctb_addr_rs - s->sps->ctb_width]));
|
||||||
} else {
|
} else {
|
||||||
tile_left_boundary =
|
tile_left_boundary =
|
||||||
tile_up_boundary = 1;
|
tile_up_boundary = 1;
|
||||||
slice_left_boundary = ctb_addr_in_slice > 0;
|
slice_left_boundary = ctb_addr_in_slice > 0;
|
||||||
slice_up_boundary = ctb_addr_in_slice >= s->sps->ctb_width;
|
slice_up_boundary = ctb_addr_in_slice >= s->sps->ctb_width;
|
||||||
}
|
}
|
||||||
lc->slice_or_tiles_left_boundary = (!slice_left_boundary) + (!tile_left_boundary << 1);
|
lc->slice_or_tiles_left_boundary = (!slice_left_boundary) + (!tile_left_boundary << 1);
|
||||||
lc->slice_or_tiles_up_boundary = (!slice_up_boundary + (!tile_up_boundary << 1));
|
lc->slice_or_tiles_up_boundary = (!slice_up_boundary + (!tile_up_boundary << 1));
|
||||||
@ -1969,31 +1969,29 @@ static int hls_nal_unit(HEVCContext *s)
|
|||||||
"nal_unit_type: %d, nuh_layer_id: %dtemporal_id: %d\n",
|
"nal_unit_type: %d, nuh_layer_id: %dtemporal_id: %d\n",
|
||||||
s->nal_unit_type, nuh_layer_id, s->temporal_id);
|
s->nal_unit_type, nuh_layer_id, s->temporal_id);
|
||||||
|
|
||||||
return (nuh_layer_id == 0);
|
return nuh_layer_id == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void restore_tqb_pixels(HEVCContext *s)
|
static void restore_tqb_pixels(HEVCContext *s)
|
||||||
{
|
{
|
||||||
int pic_width_in_min_pu = s->sps->width >> s->sps->log2_min_pu_size;
|
int min_pu_size = 1 << s->sps->log2_min_pu_size;
|
||||||
int pic_height_in_min_pu = s->sps->height >> s->sps->log2_min_pu_size;
|
|
||||||
int min_pu_size = 1 << s->sps->log2_min_pu_size;
|
|
||||||
int x, y, c_idx;
|
int x, y, c_idx;
|
||||||
|
|
||||||
for (c_idx = 0; c_idx < 3; c_idx++) {
|
for (c_idx = 0; c_idx < 3; c_idx++) {
|
||||||
ptrdiff_t stride = s->frame->linesize[c_idx];
|
ptrdiff_t stride = s->frame->linesize[c_idx];
|
||||||
int hshift = s->sps->hshift[c_idx];
|
int hshift = s->sps->hshift[c_idx];
|
||||||
int vshift = s->sps->vshift[c_idx];
|
int vshift = s->sps->vshift[c_idx];
|
||||||
for (y = 0; y < pic_height_in_min_pu; y++) {
|
for (y = 0; y < s->sps->min_pu_height; y++) {
|
||||||
for (x = 0; x < pic_width_in_min_pu; x++) {
|
for (x = 0; x < s->sps->min_pu_width; x++) {
|
||||||
if (s->is_pcm[y*pic_width_in_min_pu+x]) {
|
if (s->is_pcm[y * s->sps->min_pu_width + x]) {
|
||||||
int n;
|
int n;
|
||||||
int len = min_pu_size >> hshift;
|
int len = min_pu_size >> hshift;
|
||||||
uint8_t *src = &s->frame->data[c_idx][((y << s->sps->log2_min_pu_size) >> vshift) * stride + (((x << s->sps->log2_min_pu_size) >> hshift) << s->sps->pixel_shift)];
|
uint8_t *src = &s->frame->data[c_idx][((y << s->sps->log2_min_pu_size) >> vshift) * stride + (((x << s->sps->log2_min_pu_size) >> hshift) << s->sps->pixel_shift)];
|
||||||
uint8_t *dst = &s->sao_frame->data[c_idx][((y << s->sps->log2_min_pu_size) >> vshift) * stride + (((x << s->sps->log2_min_pu_size) >> hshift) << s->sps->pixel_shift)];
|
uint8_t *dst = &s->sao_frame->data[c_idx][((y << s->sps->log2_min_pu_size) >> vshift) * stride + (((x << s->sps->log2_min_pu_size) >> hshift) << s->sps->pixel_shift)];
|
||||||
for (n = 0;n < (min_pu_size >> vshift); n++) {
|
for (n = 0; n < (min_pu_size >> vshift); n++) {
|
||||||
memcpy(dst,src,len);
|
memcpy(dst, src, len);
|
||||||
src += stride;
|
src += stride;
|
||||||
dst += stride;
|
dst += stride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2004,22 +2002,18 @@ static void restore_tqb_pixels(HEVCContext *s)
|
|||||||
static int hevc_frame_start(HEVCContext *s)
|
static int hevc_frame_start(HEVCContext *s)
|
||||||
{
|
{
|
||||||
HEVCLocalContext *lc = s->HEVClc;
|
HEVCLocalContext *lc = s->HEVClc;
|
||||||
int pic_width_in_min_pu = s->sps->width >> s->sps->log2_min_pu_size;
|
|
||||||
int pic_height_in_min_pu = s->sps->height >> s->sps->log2_min_pu_size;
|
|
||||||
int pic_width_in_min_tu = s->sps->width >> s->sps->log2_min_tb_size;
|
|
||||||
int pic_height_in_min_tu = s->sps->height >> s->sps->log2_min_tb_size;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
memset(s->horizontal_bs, 0, 2 * s->bs_width * (s->bs_height + 1));
|
memset(s->horizontal_bs, 0, 2 * s->bs_width * (s->bs_height + 1));
|
||||||
memset(s->vertical_bs, 0, 2 * s->bs_width * (s->bs_height + 1));
|
memset(s->vertical_bs, 0, 2 * s->bs_width * (s->bs_height + 1));
|
||||||
memset(s->cbf_luma, 0, pic_width_in_min_tu * pic_height_in_min_tu);
|
memset(s->cbf_luma, 0, s->sps->min_tb_width * s->sps->min_tb_height);
|
||||||
memset(s->is_pcm, 0, pic_width_in_min_pu * pic_height_in_min_pu);
|
memset(s->is_pcm, 0, s->sps->min_pu_width * s->sps->min_pu_height);
|
||||||
|
|
||||||
lc->start_of_tiles_x = 0;
|
lc->start_of_tiles_x = 0;
|
||||||
s->is_decoded = 0;
|
s->is_decoded = 0;
|
||||||
|
|
||||||
if (s->pps->tiles_enabled_flag)
|
if (s->pps->tiles_enabled_flag)
|
||||||
lc->end_of_tiles_x = s->pps->column_width[0] << s->sps->log2_ctb_size;
|
lc->end_of_tiles_x = s->pps->column_width[0] << s->sps->log2_ctb_size;
|
||||||
|
|
||||||
ret = ff_hevc_set_new_ref(s, s->sps->sao_enabled ? &s->sao_frame : &s->frame,
|
ret = ff_hevc_set_new_ref(s, s->sps->sao_enabled ? &s->sao_frame : &s->frame,
|
||||||
s->poc);
|
s->poc);
|
||||||
@ -2057,7 +2051,7 @@ fail:
|
|||||||
static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
|
static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
|
||||||
{
|
{
|
||||||
HEVCLocalContext *lc = s->HEVClc;
|
HEVCLocalContext *lc = s->HEVClc;
|
||||||
GetBitContext *gb = &lc->gb;
|
GetBitContext *gb = &lc->gb;
|
||||||
int ctb_addr_ts;
|
int ctb_addr_ts;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -2068,7 +2062,7 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
|
|||||||
ret = hls_nal_unit(s);
|
ret = hls_nal_unit(s);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "Invalid NAL unit %d, skipping.\n",
|
av_log(s->avctx, AV_LOG_ERROR, "Invalid NAL unit %d, skipping.\n",
|
||||||
s->nal_unit_type);
|
s->nal_unit_type);
|
||||||
if (s->avctx->err_recognition & AV_EF_EXPLODE)
|
if (s->avctx->err_recognition & AV_EF_EXPLODE)
|
||||||
return ret;
|
return ret;
|
||||||
return 0;
|
return 0;
|
||||||
@ -2118,10 +2112,7 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (s->max_ra == INT_MAX) {
|
if (s->max_ra == INT_MAX) {
|
||||||
if (s->nal_unit_type == NAL_CRA_NUT ||
|
if (s->nal_unit_type == NAL_CRA_NUT || IS_BLA(s)) {
|
||||||
s->nal_unit_type == NAL_BLA_W_LP ||
|
|
||||||
s->nal_unit_type == NAL_BLA_N_LP ||
|
|
||||||
s->nal_unit_type == NAL_BLA_W_RADL) {
|
|
||||||
s->max_ra = s->poc;
|
s->max_ra = s->poc;
|
||||||
} else {
|
} else {
|
||||||
if (IS_IDR(s))
|
if (IS_IDR(s))
|
||||||
@ -2151,8 +2142,8 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
|
|||||||
s->sh.slice_type != I_SLICE) {
|
s->sh.slice_type != I_SLICE) {
|
||||||
ret = ff_hevc_slice_rpl(s);
|
ret = ff_hevc_slice_rpl(s);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(s->avctx, AV_LOG_WARNING, "Error constructing the reference "
|
av_log(s->avctx, AV_LOG_WARNING,
|
||||||
"lists for the current slice.\n");
|
"Error constructing the reference lists for the current slice.\n");
|
||||||
if (s->avctx->err_recognition & AV_EF_EXPLODE)
|
if (s->avctx->err_recognition & AV_EF_EXPLODE)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -2183,7 +2174,8 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
|
|||||||
case NAL_FD_NUT:
|
case NAL_FD_NUT:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
av_log(s->avctx, AV_LOG_INFO, "Skipping NAL unit %d\n", s->nal_unit_type);
|
av_log(s->avctx, AV_LOG_INFO,
|
||||||
|
"Skipping NAL unit %d\n", s->nal_unit_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -2265,9 +2257,9 @@ int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length,
|
|||||||
dst[di++] = src[si++];
|
dst[di++] = src[si++];
|
||||||
} else if (src[si] == 0 && src[si + 1] == 0) {
|
} else if (src[si] == 0 && src[si + 1] == 0) {
|
||||||
if (src[si + 2] == 3) { // escape
|
if (src[si + 2] == 3) { // escape
|
||||||
dst[di++] = 0;
|
dst[di++] = 0;
|
||||||
dst[di++] = 0;
|
dst[di++] = 0;
|
||||||
si += 3;
|
si += 3;
|
||||||
|
|
||||||
s->skipped_bytes++;
|
s->skipped_bytes++;
|
||||||
if (s->skipped_bytes_pos_size < s->skipped_bytes) {
|
if (s->skipped_bytes_pos_size < s->skipped_bytes) {
|
||||||
@ -2380,7 +2372,8 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
|
|||||||
goto fail;
|
goto fail;
|
||||||
hls_nal_unit(s);
|
hls_nal_unit(s);
|
||||||
|
|
||||||
if (s->nal_unit_type == NAL_EOS_NUT || s->nal_unit_type == NAL_EOB_NUT)
|
if (s->nal_unit_type == NAL_EOS_NUT ||
|
||||||
|
s->nal_unit_type == NAL_EOB_NUT)
|
||||||
s->eos = 1;
|
s->eos = 1;
|
||||||
|
|
||||||
buf += consumed;
|
buf += consumed;
|
||||||
@ -2395,7 +2388,8 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
|
|||||||
|
|
||||||
ret = decode_nal_unit(s, s->nals[i].data, s->nals[i].size);
|
ret = decode_nal_unit(s, s->nals[i].data, s->nals[i].size);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(s->avctx, AV_LOG_WARNING, "Error parsing NAL unit #%d.\n", i);
|
av_log(s->avctx, AV_LOG_WARNING,
|
||||||
|
"Error parsing NAL unit #%d.\n", i);
|
||||||
if (s->avctx->err_recognition & AV_EF_EXPLODE)
|
if (s->avctx->err_recognition & AV_EF_EXPLODE)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@ -2762,7 +2756,8 @@ static int hevc_decode_extradata(HEVCContext *s)
|
|||||||
// +2 for the nal size field
|
// +2 for the nal size field
|
||||||
int nalsize = bytestream2_peek_be16(&gb) + 2;
|
int nalsize = bytestream2_peek_be16(&gb) + 2;
|
||||||
if (bytestream2_get_bytes_left(&gb) < nalsize) {
|
if (bytestream2_get_bytes_left(&gb) < nalsize) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "Invalid NAL unit size in extradata.\n");
|
av_log(s->avctx, AV_LOG_ERROR,
|
||||||
|
"Invalid NAL unit size in extradata.\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -656,15 +656,15 @@ int ff_hevc_cu_transquant_bypass_flag_decode(HEVCContext *s)
|
|||||||
|
|
||||||
int ff_hevc_skip_flag_decode(HEVCContext *s, int x0, int y0, int x_cb, int y_cb)
|
int ff_hevc_skip_flag_decode(HEVCContext *s, int x0, int y0, int x_cb, int y_cb)
|
||||||
{
|
{
|
||||||
int min_cb_width = s->sps->width >> s->sps->log2_min_cb_size;
|
int min_cb_width = s->sps->min_cb_width;
|
||||||
int inc = 0;
|
int inc = 0;
|
||||||
int x0b = x0 & ((1 << s->sps->log2_ctb_size) - 1);
|
int x0b = x0 & ((1 << s->sps->log2_ctb_size) - 1);
|
||||||
int y0b = y0 & ((1 << s->sps->log2_ctb_size) - 1);
|
int y0b = y0 & ((1 << s->sps->log2_ctb_size) - 1);
|
||||||
|
|
||||||
if (s->HEVClc->ctb_left_flag || x0b)
|
if (s->HEVClc->ctb_left_flag || x0b)
|
||||||
inc = SAMPLE_CTB(s->skip_flag, x_cb-1, y_cb);
|
inc = !!SAMPLE_CTB(s->skip_flag, x_cb-1, y_cb);
|
||||||
if (s->HEVClc->ctb_up_flag || y0b)
|
if (s->HEVClc->ctb_up_flag || y0b)
|
||||||
inc += SAMPLE_CTB(s->skip_flag, x_cb, y_cb-1);
|
inc += !!SAMPLE_CTB(s->skip_flag, x_cb, y_cb-1);
|
||||||
|
|
||||||
return GET_CABAC(elem_offset[SKIP_FLAG] + inc);
|
return GET_CABAC(elem_offset[SKIP_FLAG] + inc);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user