Merge commit 'd528045558825f01472e9bee873f60c98d661e53'
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 22 May 2015 18:57:30 +0000 (20:57 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 22 May 2015 19:15:32 +0000 (21:15 +0200)
* commit 'd528045558825f01472e9bee873f60c98d661e53':
  mpegvideo: Have ff_mpeg_unref_picture use AVCodecContext directly

Conflicts:
libavcodec/mpegvideo.c
libavcodec/mpegvideo_enc.c

The memset is left in place

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/mpegvideo.c
libavcodec/mpegvideo.h
libavcodec/mpegvideo_enc.c

@@@ -706,10 -667,8 +706,10 @@@ fail
  /**
   * Deallocate a picture.
   */
- void ff_mpeg_unref_picture(MpegEncContext *s, Picture *pic)
+ void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *pic)
  {
 +    int off = offsetof(Picture, mb_mean) + sizeof(pic->mb_mean);
 +
      pic->tf.f = pic->f;
      /* WM Image / Screen codecs allocate internal buffers with different
       * dimensions / colorspaces; ignore user-defined callbacks for these. */
@@@ -991,10 -934,8 +991,10 @@@ int ff_mpeg_update_thread_context(AVCod
      s->coded_picture_number = s1->coded_picture_number;
      s->picture_number       = s1->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]);
+         ff_mpeg_unref_picture(s->avctx, &s->picture[i]);
          if (s1->picture[i].f->buf[0] &&
              (ret = ff_mpeg_ref_picture(s, &s->picture[i], &s1->picture[i])) < 0)
              return ret;
  
  #define UPDATE_PICTURE(pic)\
  do {\
-     ff_mpeg_unref_picture(s, &s->pic);\
+     ff_mpeg_unref_picture(s->avctx, &s->pic);\
 -    if (s1->pic.f->buf[0])\
 +    if (s1->pic.f && s1->pic.f->buf[0])\
          ret = ff_mpeg_ref_picture(s, &s->pic, &s1->pic);\
      else\
          ret = update_picture_tables(&s->pic, &s1->pic);\
@@@ -1931,12 -1819,8 +1931,12 @@@ int ff_mpv_frame_start(MpegEncContext *
          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);
+         ff_mpeg_unref_picture(s->avctx, &s->last_picture);
          if (s->last_picture_ptr->f->buf[0] &&
              (ret = ff_mpeg_ref_picture(s, &s->last_picture,
                                         s->last_picture_ptr)) < 0)
@@@ -3367,15 -2429,14 +3367,15 @@@ void ff_mpeg_flush(AVCodecContext *avct
          return;
  
      for (i = 0; i < MAX_PICTURE_COUNT; i++)
-         ff_mpeg_unref_picture(s, &s->picture[i]);
+         ff_mpeg_unref_picture(s->avctx, &s->picture[i]);
      s->current_picture_ptr = s->last_picture_ptr = s->next_picture_ptr = NULL;
  
-     ff_mpeg_unref_picture(s, &s->current_picture);
-     ff_mpeg_unref_picture(s, &s->last_picture);
-     ff_mpeg_unref_picture(s, &s->next_picture);
+     ff_mpeg_unref_picture(s->avctx, &s->current_picture);
+     ff_mpeg_unref_picture(s->avctx, &s->last_picture);
+     ff_mpeg_unref_picture(s->avctx, &s->next_picture);
  
      s->mb_x= s->mb_y= 0;
 +    s->closed_gop= 0;
  
      s->parse_context.state= -1;
      s->parse_context.frame_start_found= 0;
@@@ -903,8 -864,7 +903,8 @@@ void ff_wmv2_encode_mb(MpegEncContext 
                         int motion_x, int motion_y);
  
  int ff_mpeg_ref_picture(MpegEncContext *s, Picture *dst, Picture *src);
- void ff_mpeg_unref_picture(MpegEncContext *s, Picture *picture);
+ void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *picture);
  void ff_free_picture_tables(Picture *pic);
  
 +
  #endif /* AVCODEC_MPEGVIDEO_H */
@@@ -1910,14 -1755,7 +1910,14 @@@ vbv_retry
      } else {
          s->frame_bits = 0;
      }
 -    assert((s->frame_bits & 7) == 0);
 +
 +    /* release non-reference frames */
 +    for (i = 0; i < MAX_PICTURE_COUNT; i++) {
 +        if (!s->picture[i].reference)
-             ff_mpeg_unref_picture(s, &s->picture[i]);
++            ff_mpeg_unref_picture(s->avctx, &s->picture[i]);
 +    }
 +
 +    av_assert1((s->frame_bits & 7) == 0);
  
      pkt->size = s->frame_bits / 8;
      *got_packet = !!pkt->size;