Merge commit 'b09ad37c83841c399abb7f2503a2ab214d0c2d48'
authorHendrik Leppkes <h.leppkes@gmail.com>
Thu, 17 Dec 2015 12:00:37 +0000 (13:00 +0100)
committerHendrik Leppkes <h.leppkes@gmail.com>
Thu, 17 Dec 2015 12:07:08 +0000 (13:07 +0100)
* commit 'b09ad37c83841c399abb7f2503a2ab214d0c2d48':
  h264: derive the delay from the level when it's not present

Merged without changing the strict_std_compliance check, as it breaks FATE
and changes decoding behavior.

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

@@@ -906,44 -851,12 +906,37 @@@ static void decode_postinit(H264Contex
      // FIXME do something with unavailable reference frames
  
      /* Sort B-frames into display order */
-     if (h->sps.bitstream_restriction_flag &&
-         h->avctx->has_b_frames < h->sps.num_reorder_frames) {
-         h->avctx->has_b_frames = h->sps.num_reorder_frames;
-         h->low_delay           = 0;
-     }
-     if (h->avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT &&
-         !h->sps.bitstream_restriction_flag) {
-         h->avctx->has_b_frames = MAX_DELAYED_PIC_COUNT - 1;
-         h->low_delay           = 0;
+     if (h->sps.bitstream_restriction_flag ||
 -        h->avctx->strict_std_compliance >= FF_COMPLIANCE_NORMAL) {
++        h->avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT) {
+         h->avctx->has_b_frames = FFMAX(h->avctx->has_b_frames, h->sps.num_reorder_frames);
      }
+     h->low_delay = !h->avctx->has_b_frames;
  
 +    for (i = 0; 1; i++) {
 +        if(i == MAX_DELAYED_PIC_COUNT || cur->poc < h->last_pocs[i]){
 +            if(i)
 +                h->last_pocs[i-1] = cur->poc;
 +            break;
 +        } else if(i) {
 +            h->last_pocs[i-1]= h->last_pocs[i];
 +        }
 +    }
 +    out_of_order = MAX_DELAYED_PIC_COUNT - i;
 +    if(   cur->f->pict_type == AV_PICTURE_TYPE_B
 +       || (h->last_pocs[MAX_DELAYED_PIC_COUNT-2] > INT_MIN && h->last_pocs[MAX_DELAYED_PIC_COUNT-1] - h->last_pocs[MAX_DELAYED_PIC_COUNT-2] > 2))
 +        out_of_order = FFMAX(out_of_order, 1);
 +    if (out_of_order == MAX_DELAYED_PIC_COUNT) {
 +        av_log(h->avctx, AV_LOG_VERBOSE, "Invalid POC %d<%d\n", cur->poc, h->last_pocs[0]);
 +        for (i = 1; i < MAX_DELAYED_PIC_COUNT; i++)
 +            h->last_pocs[i] = INT_MIN;
 +        h->last_pocs[0] = cur->poc;
 +        cur->mmco_reset = 1;
 +    } else if(h->avctx->has_b_frames < out_of_order && !h->sps.bitstream_restriction_flag){
 +        av_log(h->avctx, AV_LOG_VERBOSE, "Increasing reorder buffer to %d\n", out_of_order);
 +        h->avctx->has_b_frames = out_of_order;
 +        h->low_delay = 0;
 +    }
 +
      pics = 0;
      while (h->delayed_pic[pics])
          pics++;
Simple merge