]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit 'a1926a29fb4325afa46842883f197c74d4535c36'
authorHendrik Leppkes <h.leppkes@gmail.com>
Mon, 24 Aug 2015 08:29:26 +0000 (10:29 +0200)
committerHendrik Leppkes <h.leppkes@gmail.com>
Mon, 24 Aug 2015 08:29:26 +0000 (10:29 +0200)
* commit 'a1926a29fb4325afa46842883f197c74d4535c36':
  hevc: avoid invalid shifts of negative values

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
1  2 
libavcodec/hevc.c

index d8da18d95a405241745ddd2874a28ee9c9abdbe1,6395563ab2454c4263a06c9b63a99d6a6666f67b..3f1a2bb8acdd3fba440211ee7c38ab24f22bbd46
@@@ -1331,14 -1494,15 +1331,14 @@@ static void luma_mc_uni(HEVCContext *s
  
      x_off += mv->x >> 2;
      y_off += mv->y >> 2;
-     src   += y_off * srcstride + x_off * (1 << s->ps.sps->pixel_shift);
+     src   += y_off * srcstride + (x_off * (1 << s->ps.sps->pixel_shift));
  
 -    if (x_off < extra_left || y_off < extra_top ||
 -        x_off >= pic_width - block_w - ff_hevc_qpel_extra_after[mx] ||
 -        y_off >= pic_height - block_h - ff_hevc_qpel_extra_after[my]) {
 +    if (x_off < QPEL_EXTRA_BEFORE || y_off < QPEL_EXTRA_AFTER ||
 +        x_off >= pic_width - block_w - QPEL_EXTRA_AFTER ||
 +        y_off >= pic_height - block_h - QPEL_EXTRA_AFTER) {
          const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift;
 -        int offset = extra_top * srcstride + (extra_left << s->ps.sps->pixel_shift);
 -        int buf_offset = extra_top *
 -                         edge_emu_stride + (extra_left << s->ps.sps->pixel_shift);
 +        int offset     = QPEL_EXTRA_BEFORE * srcstride       + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift);
 +        int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift);
  
          s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src - offset,
                                   edge_emu_stride, srcstride,
   * @param y_off vertical position of block from origin (0, 0)
   * @param block_w width of block
   * @param block_h height of block
 + * @param chroma_weight weighting factor applied to the chroma prediction
 + * @param chroma_offset additive offset applied to the chroma prediction value
   */
 -static void chroma_mc(HEVCContext *s, int16_t *dst1, int16_t *dst2,
 -                      ptrdiff_t dststride, AVFrame *ref, const Mv *mv,
 -                      int x_off, int y_off, int block_w, int block_h)
 +
 +static void chroma_mc_uni(HEVCContext *s, uint8_t *dst0,
 +                          ptrdiff_t dststride, uint8_t *src0, ptrdiff_t srcstride, int reflist,
 +                          int x_off, int y_off, int block_w, int block_h, struct MvField *current_mv, int chroma_weight, int chroma_offset)
  {
 -    HEVCLocalContext *lc = &s->HEVClc;
 -    uint8_t *src1        = ref->data[1];
 -    uint8_t *src2        = ref->data[2];
 -    ptrdiff_t src1stride = ref->linesize[1];
 -    ptrdiff_t src2stride = ref->linesize[2];
 -    int pic_width        = s->ps.sps->width >> 1;
 -    int pic_height       = s->ps.sps->height >> 1;
 -
 -    int mx = mv->x & 7;
 -    int my = mv->y & 7;
 -
 -    x_off += mv->x >> 3;
 -    y_off += mv->y >> 3;
 -    src1  += y_off * src1stride + (x_off * (1 << s->ps.sps->pixel_shift));
 -    src2  += y_off * src2stride + (x_off * (1 << s->ps.sps->pixel_shift));
 +    HEVCLocalContext *lc = s->HEVClc;
 +    int pic_width        = s->ps.sps->width >> s->ps.sps->hshift[1];
 +    int pic_height       = s->ps.sps->height >> s->ps.sps->vshift[1];
 +    const Mv *mv         = &current_mv->mv[reflist];
 +    int weight_flag      = (s->sh.slice_type == P_SLICE && s->ps.pps->weighted_pred_flag) ||
 +                           (s->sh.slice_type == B_SLICE && s->ps.pps->weighted_bipred_flag);
 +    int idx              = ff_hevc_pel_weight[block_w];
 +    int hshift           = s->ps.sps->hshift[1];
 +    int vshift           = s->ps.sps->vshift[1];
 +    intptr_t mx          = av_mod_uintp2(mv->x, 2 + hshift);
 +    intptr_t my          = av_mod_uintp2(mv->y, 2 + vshift);
 +    intptr_t _mx         = mx << (1 - hshift);
 +    intptr_t _my         = my << (1 - vshift);
 +
 +    x_off += mv->x >> (2 + hshift);
 +    y_off += mv->y >> (2 + vshift);
-     src0  += y_off * srcstride + x_off * (1 << s->ps.sps->pixel_shift);
++    src0  += y_off * srcstride + (x_off * (1 << s->ps.sps->pixel_shift));
  
      if (x_off < EPEL_EXTRA_BEFORE || y_off < EPEL_EXTRA_AFTER ||
          x_off >= pic_width - block_w - EPEL_EXTRA_AFTER ||