Merge commit 'a553c6a347d3d28d7ee44c3df3d5c4ee780dba23'
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 19 Nov 2013 02:48:15 +0000 (03:48 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 19 Nov 2013 02:56:53 +0000 (03:56 +0100)
* commit 'a553c6a347d3d28d7ee44c3df3d5c4ee780dba23':
  lavc: use buf[0] instead of data[0] in checks whether a frame is allocated

Conflicts:
libavcodec/h264_refs.c
libavcodec/mpegvideo.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/h264.c
libavcodec/h264_refs.c
libavcodec/mpegvideo.c
libavcodec/pthread_frame.c

@@@ -1848,9 -1765,9 +1848,9 @@@ static int decode_update_thread_context
      h->data_partitioning    = h1->data_partitioning;
      h->low_delay            = h1->low_delay;
  
 -    for (i = 0; i < MAX_PICTURE_COUNT; i++) {
 +    for (i = 0; h->DPB && i < MAX_PICTURE_COUNT; i++) {
          unref_picture(h, &h->DPB[i]);
-         if (h1->DPB[i].f.data[0] &&
+         if (h1->DPB[i].f.buf[0] &&
              (ret = ref_picture(h, &h->DPB[i], &h1->DPB[i])) < 0)
              return ret;
      }
@@@ -3641,18 -3521,12 +3641,18 @@@ static int decode_slice_header(H264Cont
           * Here, we're using that to see if we should mark previously
           * decode frames as "finished".
           * We have to do that before the "dummy" in-between frame allocation,
 -         * since that can modify s->current_picture_ptr. */
 +         * since that can modify h->cur_pic_ptr. */
          if (h0->first_field) {
              assert(h0->cur_pic_ptr);
-             assert(h0->cur_pic_ptr->f.data[0]);
+             assert(h0->cur_pic_ptr->f.buf[0]);
              assert(h0->cur_pic_ptr->reference != DELAYED_PIC_REF);
  
 +            /* Mark old field/frame as completed */
 +            if (h0->cur_pic_ptr->tf.owner == h0->avctx) {
 +                ff_thread_report_progress(&h0->cur_pic_ptr->tf, INT_MAX,
 +                                          last_pic_structure == PICT_BOTTOM_FIELD);
 +            }
 +
              /* figure out if we have a complementary field pair */
              if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
                  /* Previous field is unmatched. Don't display it, but let it
@@@ -304,14 -305,9 +306,14 @@@ int ff_h264_decode_ref_pic_list_reorder
      }
      for (list = 0; list < h->list_count; list++) {
          for (index = 0; index < h->ref_count[list]; index++) {
-             if (   !h->ref_list[list][index].f.data[0]
 -            if (!h->ref_list[list][index].f.buf[0]) {
 -                av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture\n");
 -                if (h->default_ref_list[list][0].f.buf[0])
++            if (   !h->ref_list[list][index].f.buf[0]
 +                || (!FIELD_PICTURE(h) && (h->ref_list[list][index].reference&3) != 3)) {
 +                int i;
 +                av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture, default is %d\n", h->default_ref_list[list][0].poc);
 +                for (i = 0; i < FF_ARRAY_ELEMS(h->last_pocs); i++)
 +                    h->last_pocs[i] = INT_MIN;
-                 if (h->default_ref_list[list][0].f.data[0]
++                if (h->default_ref_list[list][0].f.buf[0]
 +                    && !(!FIELD_PICTURE(h) && (h->default_ref_list[list][0].reference&3) != 3))
                      COPY_PICTURE(&h->ref_list[list][index], &h->default_ref_list[list][0]);
                  else
                      return -1;
@@@ -379,16 -368,11 +379,16 @@@ int ff_alloc_picture(MpegEncContext *s
  {
      int i, ret;
  
 +    if (pic->qscale_table_buf)
 +        if (   pic->alloc_mb_width  != s->mb_width
 +            || pic->alloc_mb_height != s->mb_height)
 +            free_picture_tables(pic);
 +
      if (shared) {
 -        assert(pic->f.data[0]);
 +        av_assert0(pic->f.data[0]);
          pic->shared = 1;
      } else {
-         av_assert0(!pic->f.data[0]);
 -        assert(!pic->f.buf[0]);
++        av_assert0(!pic->f.buf[0]);
  
          if (alloc_frame_buffer(s, pic) < 0)
              return -1;
@@@ -713,11 -672,9 +713,11 @@@ int ff_mpeg_update_thread_context(AVCod
      s->picture_number       = s1->picture_number;
      s->input_picture_number = s1->input_picture_number;
  
 +    av_assert0(!s->picture || s->picture != s1->picture);
 +    if(s->picture)
      for (i = 0; i < MAX_PICTURE_COUNT; i++) {
          ff_mpeg_unref_picture(s, &s->picture[i]);
-         if (s1->picture[i].f.data[0] &&
+         if (s1->picture[i].f.buf[0] &&
              (ret = ff_mpeg_ref_picture(s, &s->picture[i], &s1->picture[i])) < 0)
              return ret;
      }
@@@ -1422,9 -1401,7 +1422,9 @@@ void ff_release_unused_pictures(MpegEnc
  
  static inline int pic_is_unused(MpegEncContext *s, Picture *pic)
  {
-     if (pic->f.data[0] == NULL)
 +    if (pic == s->last_picture_ptr)
 +        return 0;
+     if (pic->f.buf[0] == NULL)
          return 1;
      if (pic->needs_realloc && !(pic->reference & DELAYED_PIC_REF))
          return 1;
@@@ -1437,7 -1414,7 +1437,7 @@@ static int find_unused_picture(MpegEncC
  
      if (shared) {
          for (i = 0; i < MAX_PICTURE_COUNT; i++) {
-             if (s->picture[i].f.data[0] == NULL && &s->picture[i] != s->last_picture_ptr)
 -            if (s->picture[i].f.buf[0] == NULL)
++            if (s->picture[i].f.buf[0] == NULL && &s->picture[i] != s->last_picture_ptr)
                  return i;
          }
      } else {
@@@ -1609,10 -1567,7 +1609,10 @@@ int ff_MPV_frame_start(MpegEncContext *
          int h_chroma_shift, v_chroma_shift;
          av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt,
                                           &h_chroma_shift, &v_chroma_shift);
-         if (s->pict_type == AV_PICTURE_TYPE_B && s->next_picture_ptr && s->next_picture_ptr->f.data[0])
 -        if (s->pict_type != AV_PICTURE_TYPE_I)
++        if (s->pict_type == AV_PICTURE_TYPE_B && s->next_picture_ptr && s->next_picture_ptr->f.buf[0])
 +            av_log(avctx, AV_LOG_DEBUG,
 +                   "allocating dummy last picture for B frame\n");
 +        else if (s->pict_type != AV_PICTURE_TYPE_I)
              av_log(avctx, AV_LOG_ERROR,
                     "warning: first frame is no keyframe\n");
          else if (s->picture_structure != PICT_FRAME)
          ff_thread_report_progress(&s->next_picture_ptr->tf, INT_MAX, 1);
      }
  
 +#if 0 // BUFREF-FIXME
 +    memset(s->last_picture.f.data, 0, sizeof(s->last_picture.f.data));
 +    memset(s->next_picture.f.data, 0, sizeof(s->next_picture.f.data));
 +#endif
      if (s->last_picture_ptr) {
          ff_mpeg_unref_picture(s, &s->last_picture);
-         if (s->last_picture_ptr->f.data[0] &&
+         if (s->last_picture_ptr->f.buf[0] &&
              (ret = ff_mpeg_ref_picture(s, &s->last_picture,
                                         s->last_picture_ptr)) < 0)
              return ret;
              return ret;
      }
  
 -    if (s->pict_type != AV_PICTURE_TYPE_I &&
 -        !(s->last_picture_ptr && s->last_picture_ptr->f.buf[0])) {
 -        av_log(s, AV_LOG_ERROR,
 -               "Non-reference picture received and no reference available\n");
 -        return AVERROR_INVALIDDATA;
 -    }
 +    av_assert0(s->pict_type == AV_PICTURE_TYPE_I || (s->last_picture_ptr &&
-                                                  s->last_picture_ptr->f.data[0]));
++                                                 s->last_picture_ptr->f.buf[0]));
  
      if (s->picture_structure!= PICT_FRAME) {
          int i;
Simple merge