Merge commit 'cb167f2947f1a2c446bd8db196d0e64ef4a6d06b'
authorJames Almer <jamrial@gmail.com>
Mon, 30 Oct 2017 23:40:28 +0000 (20:40 -0300)
committerJames Almer <jamrial@gmail.com>
Mon, 30 Oct 2017 23:40:28 +0000 (20:40 -0300)
* commit 'cb167f2947f1a2c446bd8db196d0e64ef4a6d06b':
  h264_refs: validate the SPS pointer in ff_h264_execute_ref_pic_marking()

Merged-by: James Almer <jamrial@gmail.com>
1  2 
libavcodec/h264_refs.c

@@@ -786,37 -729,9 +792,38 @@@ int ff_h264_execute_ref_pic_marking(H26
          }
      }
  
 +    for (i = 0; i<h->short_ref_count; i++) {
 +        pic = h->short_ref[i];
 +        if (pic->invalid_gap) {
 +            int d = av_mod_uintp2(h->cur_pic_ptr->frame_num - pic->frame_num, h->ps.sps->log2_max_frame_num);
 +            if (d > h->ps.sps->ref_frame_count)
 +                remove_short(h, pic->frame_num, 0);
 +        }
 +    }
 +
      print_short_term(h);
      print_long_term(h);
 +
 +    for (i = 0; i < FF_ARRAY_ELEMS(h->ps.pps_list); i++) {
 +        if (h->ps.pps_list[i]) {
 +            const PPS *pps = (const PPS *)h->ps.pps_list[i]->data;
 +            pps_ref_count[0] = FFMAX(pps_ref_count[0], pps->ref_count[0]);
 +            pps_ref_count[1] = FFMAX(pps_ref_count[1], pps->ref_count[1]);
 +        }
 +    }
 +
 +    if (   err >= 0
 +        && h->long_ref_count==0
 +        && (   h->short_ref_count<=2
 +            || pps_ref_count[0] <= 1 + (h->picture_structure != PICT_FRAME) && pps_ref_count[1] <= 1)
 +        && pps_ref_count[0]<=2 + (h->picture_structure != PICT_FRAME) + (2*!h->has_recovery_point)
 +        && h->cur_pic_ptr->f->pict_type == AV_PICTURE_TYPE_I){
 +        h->cur_pic_ptr->recovered |= 1;
 +        if(!h->avctx->has_b_frames)
 +            h->frame_recovered |= FRAME_RECOVERED_SEI;
 +    }
 +
+ out:
      return (h->avctx->err_recognition & AV_EF_EXPLODE) ? err : 0;
  }