# HG changeset patch # User michael # Date 1264269930 0 # Node ID 776dba50775c47f6a73ed81aa9d6d870074777f5 # Parent 8754b8361dc945d855b638099888a631fe3ad722 Move +52 from the loop filter to the alpha/beta offsets in the context. This should fix a segfault, also it might be faster on systems where the +52 wasnt free. diff -r 8754b8361dc9 -r 776dba50775c dxva2_h264.c --- a/dxva2_h264.c Sat Jan 23 18:04:09 2010 +0000 +++ b/dxva2_h264.c Sat Jan 23 18:05:30 2010 +0000 @@ -225,8 +225,8 @@ slice->num_ref_idx_l0_active_minus1 = h->ref_count[0] - 1; if (h->list_count > 1) slice->num_ref_idx_l1_active_minus1 = h->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 = h->slice_alpha_c0_offset / 2 - 26; + slice->slice_beta_offset_div2 = h->slice_beta_offset / 2 - 26; slice->Reserved8Bits = 0; for (list = 0; list < 2; list++) { diff -r 8754b8361dc9 -r 776dba50775c h264.c --- a/h264.c Sat Jan 23 18:04:09 2010 +0000 +++ b/h264.c Sat Jan 23 18:05:30 2010 +0000 @@ -2032,8 +2032,8 @@ } h->deblocking_filter = 1; - h->slice_alpha_c0_offset = 0; - h->slice_beta_offset = 0; + h->slice_alpha_c0_offset = 52; + h->slice_beta_offset = 52; if( h->pps.deblocking_filter_parameters_present ) { tmp= get_ue_golomb_31(&s->gb); if(tmp > 2){ @@ -2045,8 +2045,13 @@ h->deblocking_filter^= 1; // 1<->0 if( h->deblocking_filter ) { - h->slice_alpha_c0_offset = get_se_golomb(&s->gb) << 1; - h->slice_beta_offset = get_se_golomb(&s->gb) << 1; + h->slice_alpha_c0_offset += get_se_golomb(&s->gb) << 1; + h->slice_beta_offset += get_se_golomb(&s->gb) << 1; + if( h->slice_alpha_c0_offset > 104U + || h->slice_beta_offset > 104U){ + av_log(s->avctx, AV_LOG_ERROR, "deblocking filter parameters %d %d out of range\n", h->slice_alpha_c0_offset, h->slice_beta_offset); + return -1; + } } } @@ -2071,7 +2076,7 @@ return 1; // deblocking switched inside frame } } - h->qp_thresh= 15 - FFMIN(h->slice_alpha_c0_offset, h->slice_beta_offset) - FFMAX3(0, h->pps.chroma_qp_index_offset[0], h->pps.chroma_qp_index_offset[1]); + h->qp_thresh= 15 + 52 - FFMIN(h->slice_alpha_c0_offset, h->slice_beta_offset) - FFMAX3(0, h->pps.chroma_qp_index_offset[0], h->pps.chroma_qp_index_offset[1]); #if 0 //FMO if( h->pps.num_slice_groups > 1 && h->pps.mb_slice_group_map_type >= 3 && h->pps.mb_slice_group_map_type <= 5) @@ -2132,7 +2137,7 @@ s->current_picture_ptr->field_poc[0], s->current_picture_ptr->field_poc[1], h->ref_count[0], h->ref_count[1], s->qscale, - h->deblocking_filter, h->slice_alpha_c0_offset/2, h->slice_beta_offset/2, + h->deblocking_filter, h->slice_alpha_c0_offset/2-26, h->slice_beta_offset/2-26, h->use_weight, h->use_weight==1 && h->use_weight_chroma ? "c" : "", h->slice_type == FF_B_TYPE ? (h->direct_spatial_mv_pred ? "SPAT" : "TEMP") : "" diff -r 8754b8361dc9 -r 776dba50775c h264_loopfilter.c --- a/h264_loopfilter.c Sat Jan 23 18:04:09 2010 +0000 +++ b/h264_loopfilter.c Sat Jan 23 18:05:30 2010 +0000 @@ -100,9 +100,9 @@ }; static void av_noinline filter_mb_edgev( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h) { - const unsigned int index_a = 52 + qp + h->slice_alpha_c0_offset; + const unsigned int index_a = qp + h->slice_alpha_c0_offset; const int alpha = alpha_table[index_a]; - const int beta = (beta_table+52)[qp + h->slice_beta_offset]; + const int beta = beta_table[qp + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 ) { @@ -117,9 +117,9 @@ } } static void av_noinline filter_mb_edgecv( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) { - const unsigned int index_a = 52 + qp + h->slice_alpha_c0_offset; + const unsigned int index_a = qp + h->slice_alpha_c0_offset; const int alpha = alpha_table[index_a]; - const int beta = (beta_table+52)[qp + h->slice_beta_offset]; + const int beta = beta_table[qp + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 ) { @@ -137,8 +137,8 @@ static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int bsi, int qp ) { int i; int index_a = qp + h->slice_alpha_c0_offset; - int alpha = (alpha_table+52)[index_a]; - int beta = (beta_table+52)[qp + h->slice_beta_offset]; + int alpha = alpha_table[index_a]; + int beta = beta_table[qp + h->slice_beta_offset]; for( i = 0; i < 8; i++, pix += stride) { const int bS_index = (i >> 1) * bsi; @@ -147,7 +147,7 @@ } if( bS[bS_index] < 4 ) { - const int tc0 = (tc0_table+52)[index_a][bS[bS_index]]; + const int tc0 = tc0_table[index_a][bS[bS_index]]; const int p0 = pix[-1]; const int p1 = pix[-2]; const int p2 = pix[-3]; @@ -226,8 +226,8 @@ static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int bsi, int qp ) { int i; int index_a = qp + h->slice_alpha_c0_offset; - int alpha = (alpha_table+52)[index_a]; - int beta = (beta_table+52)[qp + h->slice_beta_offset]; + int alpha = alpha_table[index_a]; + int beta = beta_table[qp + h->slice_beta_offset]; for( i = 0; i < 4; i++, pix += stride) { const int bS_index = i*bsi; @@ -236,7 +236,7 @@ } if( bS[bS_index] < 4 ) { - const int tc = (tc0_table+52)[index_a][bS[bS_index]] + 1; + const int tc = tc0_table[index_a][bS[bS_index]] + 1; const int p0 = pix[-1]; const int p1 = pix[-2]; const int q0 = pix[0]; @@ -270,9 +270,9 @@ } static void av_noinline filter_mb_edgeh( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) { - const unsigned int index_a = 52 + qp + h->slice_alpha_c0_offset; + const unsigned int index_a = qp + h->slice_alpha_c0_offset; const int alpha = alpha_table[index_a]; - const int beta = (beta_table+52)[qp + h->slice_beta_offset]; + const int beta = beta_table[qp + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 ) { @@ -288,9 +288,9 @@ } static void av_noinline filter_mb_edgech( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) { - const unsigned int index_a = 52 + qp + h->slice_alpha_c0_offset; + const unsigned int index_a = qp + h->slice_alpha_c0_offset; const int alpha = alpha_table[index_a]; - const int beta = (beta_table+52)[qp + h->slice_beta_offset]; + const int beta = beta_table[qp + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 ) { @@ -332,7 +332,7 @@ qp1 = (qp + qp1 + 1) >> 1; qpc0 = (qpc + qpc0 + 1) >> 1; qpc1 = (qpc + qpc1 + 1) >> 1; - qp_thresh = 15 - h->slice_alpha_c0_offset; + qp_thresh = 15+52 - h->slice_alpha_c0_offset; if(qp <= qp_thresh && qp0 <= qp_thresh && qp1 <= qp_thresh && qpc <= qp_thresh && qpc0 <= qp_thresh && qpc1 <= qp_thresh) return; diff -r 8754b8361dc9 -r 776dba50775c vaapi_h264.c --- a/vaapi_h264.c Sat Jan 23 18:04:09 2010 +0000 +++ b/vaapi_h264.c Sat Jan 23 18:05:30 2010 +0000 @@ -317,8 +317,8 @@ slice_param->cabac_init_idc = h->cabac_init_idc; slice_param->slice_qp_delta = s->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->slice_alpha_c0_offset_div2 = h->slice_alpha_c0_offset / 2 - 26; + slice_param->slice_beta_offset_div2 = h->slice_beta_offset / 2 - 26; slice_param->luma_log2_weight_denom = h->luma_log2_weight_denom; slice_param->chroma_log2_weight_denom = h->chroma_log2_weight_denom;