diff options
author | Vittorio Giovara <vittorio.giovara@gmail.com> | 2014-02-20 05:38:32 +0400 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2014-02-20 21:58:38 +0400 |
commit | f777504f640260337974848c7d5d7a3f064bbb45 (patch) | |
tree | dc90b315e1390f57d4dd96d45cd5b822e3ae2e3d /libavcodec/h264.c | |
parent | 5c79d2e12d13959fc6aed92d102c25194a06de05 (diff) |
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>
Diffstat (limited to 'libavcodec/h264.c')
-rw-r--r-- | libavcodec/h264.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 9cc32e9dec..7a81a71426 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3840,8 +3840,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0) get_se_golomb(&h->gb); /* slice_qs_delta */ 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(&h->gb); if (tmp > 2) { @@ -3854,10 +3854,12 @@ static int decode_slice_header(H264Context *h, H264Context *h0) h->deblocking_filter ^= 1; // 1<->0 if (h->deblocking_filter) { - h->slice_alpha_c0_offset += get_se_golomb(&h->gb) << 1; - h->slice_beta_offset += get_se_golomb(&h->gb) << 1; - if (h->slice_alpha_c0_offset > 104U || - h->slice_beta_offset > 104U) { + 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) { 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); @@ -3894,7 +3896,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0) } } } - h->qp_thresh = 15 + 52 - + h->qp_thresh = 15 + FFMIN(h->slice_alpha_c0_offset, h->slice_beta_offset) - FFMAX3(0, h->pps.chroma_qp_index_offset[0], @@ -3956,7 +3958,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0) h->ref_count[0], h->ref_count[1], h->qscale, h->deblocking_filter, - h->slice_alpha_c0_offset / 2 - 26, h->slice_beta_offset / 2 - 26, + 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") : ""); |