clamp_abs_lvl_seg.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # HG changeset patch
  2. # User Gerald Squelart <gsquelart@mozilla.com>
  3. # Parent b9e641a34c2fb9e6f3d3a02200bc2d800b6ca168
  4. Bug 1224363 - Clamp seg_lvl also in abs-value mode - r=rillian
  5. Even when the segment feature data is in absolute mode, it is still read as a
  6. 6-bit value with an added sign, so it could have values between -63 and +63.
  7. Later, this signed value is used without checks as a filter level, which is
  8. used to access an entry in an array of size MAX_LOOP_FILTER+1=64.
  9. This patch just extends the existing clamping (that was done only to relative-
  10. mode data) to absolute mode data, before it is blindly 'memset' in
  11. lfi->lvl[seg][0], which was where the out-of-bound filter_value was read in
  12. subsequent vp8_loop_filter_row_simple.
  13. diff --git a/media/libvpx/vp8/common/loopfilter.c b/media/libvpx/vp8/common/loopfilter.c
  14. --- a/media/libvpx/vp8/common/loopfilter.c
  15. +++ b/media/libvpx/vp8/common/loopfilter.c
  16. @@ -136,18 +136,18 @@ void vp8_loop_filter_frame_init(VP8_COMM
  17. /* Abs value */
  18. if (mbd->mb_segement_abs_delta == SEGMENT_ABSDATA)
  19. {
  20. lvl_seg = mbd->segment_feature_data[MB_LVL_ALT_LF][seg];
  21. }
  22. else /* Delta Value */
  23. {
  24. lvl_seg += mbd->segment_feature_data[MB_LVL_ALT_LF][seg];
  25. - lvl_seg = (lvl_seg > 0) ? ((lvl_seg > 63) ? 63: lvl_seg) : 0;
  26. }
  27. + lvl_seg = (lvl_seg > 0) ? ((lvl_seg > 63) ? 63: lvl_seg) : 0;
  28. }
  29. if (!mbd->mode_ref_lf_delta_enabled)
  30. {
  31. /* we could get rid of this if we assume that deltas are set to
  32. * zero when not in use; encoder always uses deltas
  33. */
  34. memset(lfi->lvl[seg][0], lvl_seg, 4 * 4 );