Commit 7d239316 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'e6c90ce9'

* commit 'e6c90ce9':
  h264: move loopfilter parameters into the per-slice context
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents ad6cee11 e6c90ce9
......@@ -232,8 +232,8 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice,
slice->num_ref_idx_l0_active_minus1 = sl->ref_count[0] - 1;
if (sl->list_count > 1)
slice->num_ref_idx_l1_active_minus1 = sl->ref_count[1] - 1;
slice->slice_alpha_c0_offset_div2 = h->slice_alpha_c0_offset / 2;
slice->slice_beta_offset_div2 = h->slice_beta_offset / 2;
slice->slice_alpha_c0_offset_div2 = sl->slice_alpha_c0_offset / 2;
slice->slice_beta_offset_div2 = sl->slice_beta_offset / 2;
slice->Reserved8Bits = 0;
for (list = 0; list < 2; list++) {
......@@ -281,10 +281,10 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice,
if (sl->slice_type == AV_PICTURE_TYPE_B)
slice->direct_spatial_mv_pred_flag = sl->direct_spatial_mv_pred;
slice->cabac_init_idc = h->pps.cabac ? h->cabac_init_idc : 0;
if (h->deblocking_filter < 2)
slice->disable_deblocking_filter_idc = 1 - h->deblocking_filter;
if (sl->deblocking_filter < 2)
slice->disable_deblocking_filter_idc = 1 - sl->deblocking_filter;
else
slice->disable_deblocking_filter_idc = h->deblocking_filter;
slice->disable_deblocking_filter_idc = sl->deblocking_filter;
slice->slice_id = h->current_slice - 1;
}
......
......@@ -346,6 +346,11 @@ typedef struct H264SliceContext {
int qp_thresh; ///< QP threshold to skip loopfilter
int last_qscale_diff;
// deblock
int deblocking_filter; ///< disable_deblocking_filter_idc with 1 <-> 0
int slice_alpha_c0_offset;
int slice_beta_offset;
// Weighted pred stuff
int use_weight;
int use_weight_chroma;
......@@ -568,11 +573,6 @@ typedef struct H264Context {
int is_complex;
// deblock
int deblocking_filter; ///< disable_deblocking_filter_idc with 1 <-> 0
int slice_alpha_c0_offset;
int slice_beta_offset;
// =============================================================
// Things below are not used in the MB or more inner code
......
......@@ -251,8 +251,8 @@ static av_always_inline void h264_filter_mb_fast_internal(H264Context *h,
int top_type = sl->top_type;
int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
int a = 52 + h->slice_alpha_c0_offset - qp_bd_offset;
int b = 52 + h->slice_beta_offset - qp_bd_offset;
int a = 52 + sl->slice_alpha_c0_offset - qp_bd_offset;
int b = 52 + sl->slice_beta_offset - qp_bd_offset;
int mb_type = h->cur_pic.mb_type[mb_xy];
int qp = h->cur_pic.qscale_table[mb_xy];
......@@ -725,8 +725,8 @@ void ff_h264_filter_mb(H264Context *h, H264SliceContext *sl,
int first_vertical_edge_done = 0;
int chroma = CHROMA(h) && !(CONFIG_GRAY && (h->flags&CODEC_FLAG_GRAY));
int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
int a = 52 + h->slice_alpha_c0_offset - qp_bd_offset;
int b = 52 + h->slice_beta_offset - qp_bd_offset;
int a = 52 + sl->slice_alpha_c0_offset - qp_bd_offset;
int b = 52 + sl->slice_beta_offset - qp_bd_offset;
if (FRAME_MBAFF(h)
// and current and left pair do not have the same interlaced type
......
......@@ -527,7 +527,7 @@ static av_always_inline void xchg_mb_border(H264Context *h, H264SliceContext *sl
}
}
if (h->deblocking_filter == 2) {
if (sl->deblocking_filter == 2) {
deblock_topleft = h->slice_table[h->mb_xy - 1 - h->mb_stride] == sl->slice_num;
deblock_top = sl->top_type;
} else {
......
......@@ -155,7 +155,7 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl)
}
} else {
if (IS_INTRA(mb_type)) {
if (h->deblocking_filter)
if (sl->deblocking_filter)
xchg_mb_border(h, sl, dest_y, dest_cb, dest_cr, linesize,
uvlinesize, 1, 0, SIMPLE, PIXEL_SHIFT);
......@@ -168,7 +168,7 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl)
transform_bypass, PIXEL_SHIFT,
block_offset, linesize, dest_y, 0);
if (h->deblocking_filter)
if (sl->deblocking_filter)
xchg_mb_border(h, sl, dest_y, dest_cb, dest_cr, linesize,
uvlinesize, 0, 0, SIMPLE, PIXEL_SHIFT);
} else if (is_h264) {
......@@ -339,7 +339,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext
}
} else {
if (IS_INTRA(mb_type)) {
if (h->deblocking_filter)
if (sl->deblocking_filter)
xchg_mb_border(h, sl, dest[0], dest[1], dest[2], linesize,
linesize, 1, 1, SIMPLE, PIXEL_SHIFT);
......@@ -348,7 +348,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext
transform_bypass, PIXEL_SHIFT,
block_offset, linesize, dest[p], p);
if (h->deblocking_filter)
if (sl->deblocking_filter)
xchg_mb_border(h, sl, dest[0], dest[1], dest[2], linesize,
linesize, 0, 1, SIMPLE, PIXEL_SHIFT);
} else {
......
......@@ -1878,9 +1878,9 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
sl->slice_type == AV_PICTURE_TYPE_SI)
get_se_golomb(&h->gb); /* slice_qs_delta */
h->deblocking_filter = 1;
h->slice_alpha_c0_offset = 0;
h->slice_beta_offset = 0;
sl->deblocking_filter = 1;
sl->slice_alpha_c0_offset = 0;
sl->slice_beta_offset = 0;
if (h->pps.deblocking_filter_parameters_present) {
tmp = get_ue_golomb_31(&h->gb);
if (tmp > 2) {
......@@ -1888,20 +1888,20 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
"deblocking_filter_idc %u out of range\n", tmp);
return AVERROR_INVALIDDATA;
}
h->deblocking_filter = tmp;
if (h->deblocking_filter < 2)
h->deblocking_filter ^= 1; // 1<->0
if (h->deblocking_filter) {
h->slice_alpha_c0_offset = get_se_golomb(&h->gb) * 2;
h->slice_beta_offset = get_se_golomb(&h->gb) * 2;
if (h->slice_alpha_c0_offset > 12 ||
h->slice_alpha_c0_offset < -12 ||
h->slice_beta_offset > 12 ||
h->slice_beta_offset < -12) {
sl->deblocking_filter = tmp;
if (sl->deblocking_filter < 2)
sl->deblocking_filter ^= 1; // 1<->0
if (sl->deblocking_filter) {
sl->slice_alpha_c0_offset = get_se_golomb(&h->gb) * 2;
sl->slice_beta_offset = get_se_golomb(&h->gb) * 2;
if (sl->slice_alpha_c0_offset > 12 ||
sl->slice_alpha_c0_offset < -12 ||
sl->slice_beta_offset > 12 ||
sl->slice_beta_offset < -12) {
av_log(h->avctx, AV_LOG_ERROR,
"deblocking filter parameters %d %d out of range\n",
h->slice_alpha_c0_offset, h->slice_beta_offset);
sl->slice_alpha_c0_offset, sl->slice_beta_offset);
return AVERROR_INVALIDDATA;
}
}
......@@ -1916,13 +1916,13 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
sl->slice_type_nos == AV_PICTURE_TYPE_B) ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONREF &&
h->nal_ref_idc == 0))
h->deblocking_filter = 0;
sl->deblocking_filter = 0;
if (h->deblocking_filter == 1 && h0->max_contexts > 1) {
if (sl->deblocking_filter == 1 && h0->max_contexts > 1) {
if (h->avctx->flags2 & CODEC_FLAG2_FAST) {
/* Cheat slightly for speed:
* Do not bother to deblock across slices. */
h->deblocking_filter = 2;
sl->deblocking_filter = 2;
} else {
h0->max_contexts = 1;
if (!h0->single_decode_warning) {
......@@ -1941,7 +1941,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
}
}
sl->qp_thresh = 15 -
FFMIN(h->slice_alpha_c0_offset, h->slice_beta_offset) -
FFMIN(sl->slice_alpha_c0_offset, sl->slice_beta_offset) -
FFMAX3(0,
h->pps.chroma_qp_index_offset[0],
h->pps.chroma_qp_index_offset[1]) +
......@@ -2012,8 +2012,8 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
h->cur_pic_ptr->field_poc[1],
sl->ref_count[0], sl->ref_count[1],
sl->qscale,
h->deblocking_filter,
h->slice_alpha_c0_offset, h->slice_beta_offset,
sl->deblocking_filter,
sl->slice_alpha_c0_offset, sl->slice_beta_offset,
sl->use_weight,
sl->use_weight == 1 && sl->use_weight_chroma ? "c" : "",
sl->slice_type == AV_PICTURE_TYPE_B ? (sl->direct_spatial_mv_pred ? "SPAT" : "TEMP") : "");
......@@ -2181,7 +2181,7 @@ static int fill_filter_caches(H264Context *h, H264SliceContext *sl, int mb_type)
top_type = h->cur_pic.mb_type[top_xy];
left_type[LTOP] = h->cur_pic.mb_type[left_xy[LTOP]];
left_type[LBOT] = h->cur_pic.mb_type[left_xy[LBOT]];
if (h->deblocking_filter == 2) {
if (sl->deblocking_filter == 2) {
if (h->slice_table[top_xy] != sl->slice_num)
top_type = 0;
if (h->slice_table[left_xy[LBOT]] != sl->slice_num)
......@@ -2279,7 +2279,7 @@ static void loop_filter(H264Context *h, H264SliceContext *sl, int start_x, int e
const int pixel_shift = h->pixel_shift;
const int block_h = 16 >> h->chroma_y_shift;
if (h->deblocking_filter) {
if (sl->deblocking_filter) {
for (mb_x = start_x; mb_x < end_x; mb_x++)
for (mb_y = end_mb_y - FRAME_MBAFF(h); mb_y <= end_mb_y; mb_y++) {
int mb_xy, mb_type;
......@@ -2359,7 +2359,7 @@ static void decode_finish_row(H264Context *h, H264SliceContext *sl)
int height = 16 << FRAME_MBAFF(h);
int deblock_border = (16 + 4) << FRAME_MBAFF(h);
if (h->deblocking_filter) {
if (sl->deblocking_filter) {
if ((top + height) >= pic_height)
height += deblock_border;
top -= deblock_border;
......
......@@ -336,9 +336,9 @@ static int vaapi_h264_decode_slice(AVCodecContext *avctx,
slice_param->num_ref_idx_l1_active_minus1 = sl->list_count > 1 ? sl->ref_count[1] - 1 : 0;
slice_param->cabac_init_idc = h->cabac_init_idc;
slice_param->slice_qp_delta = sl->qscale - h->pps.init_qp;
slice_param->disable_deblocking_filter_idc = h->deblocking_filter < 2 ? !h->deblocking_filter : h->deblocking_filter;
slice_param->slice_alpha_c0_offset_div2 = h->slice_alpha_c0_offset / 2;
slice_param->slice_beta_offset_div2 = h->slice_beta_offset / 2;
slice_param->disable_deblocking_filter_idc = sl->deblocking_filter < 2 ? !sl->deblocking_filter : sl->deblocking_filter;
slice_param->slice_alpha_c0_offset_div2 = sl->slice_alpha_c0_offset / 2;
slice_param->slice_beta_offset_div2 = sl->slice_beta_offset / 2;
slice_param->luma_log2_weight_denom = sl->luma_log2_weight_denom;
slice_param->chroma_log2_weight_denom = sl->chroma_log2_weight_denom;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment