diff options
author | Vittorio Giovara <vittorio.giovara@gmail.com> | 2014-02-20 02:38:32 +0100 |
---|---|---|
committer | Reinhard Tartler <siretart@tauware.de> | 2014-02-28 23:07:40 -0500 |
commit | a6003760bd0749eed366c19a2ceb17b4678f9c37 (patch) | |
tree | af6c9d3588435122a03058c4a9fcabdbdb425050 /libavcodec/h264.c | |
parent | cf676c159b810d5126924aeab9abc8f8271881e0 (diff) | |
download | ffmpeg-a6003760bd0749eed366c19a2ceb17b4678f9c37.tar.gz |
h264: Lower bound check for slice offsets
And use the value from the specification.
Sample-Id: 00000451-google
Found-by: Mateusz j00ru Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
(cherry picked from commit f777504f640260337974848c7d5d7a3f064bbb45)
(cherry picked from commit 5bd083d0216d9ee649039c84999fb61386536ac1)
Conflicts:
libavcodec/h264.c
(cherry picked from commit 41380e017afcca3119acb560c08a60a97d416c3c)
Conflicts:
libavcodec/h264.c
Diffstat (limited to 'libavcodec/h264.c')
-rw-r--r-- | libavcodec/h264.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index ff7859ce2b..f3094b51cf 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3225,8 +3225,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ } h->deblocking_filter = 1; - h->slice_alpha_c0_offset = 52; - h->slice_beta_offset = 52; + h->slice_alpha_c0_offset = 0; + h->slice_beta_offset = 0; if( h->pps.deblocking_filter_parameters_present ) { tmp= get_ue_golomb_31(&s->gb); if(tmp > 2){ @@ -3237,12 +3237,16 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ if(h->deblocking_filter < 2) 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; - 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); + if (h->deblocking_filter) { + h->slice_alpha_c0_offset = get_se_golomb(&s->gb) * 2; + h->slice_beta_offset = get_se_golomb(&s->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) { + 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; } } @@ -3271,14 +3275,12 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ } } } - 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]) - + 6 * (h->sps.bit_depth_luma - 8); - -#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) - slice_group_change_cycle= get_bits(&s->gb, ?); -#endif + 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]) + + 6 * (h->sps.bit_depth_luma - 8); h0->last_slice_type = slice_type; h->slice_num = ++h0->current_slice; @@ -3333,7 +3335,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ 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-26, h->slice_beta_offset/2-26, + h->deblocking_filter, + h->slice_alpha_c0_offset, h->slice_beta_offset, h->use_weight, h->use_weight==1 && h->use_weight_chroma ? "c" : "", h->slice_type == AV_PICTURE_TYPE_B ? (h->direct_spatial_mv_pred ? "SPAT" : "TEMP") : "" |