OSDN Git Service

Merge commit '9cbf2d78f0a9c19129e7a70b2281a450d386c6d9'
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 6 Jan 2014 16:00:01 +0000 (17:00 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 6 Jan 2014 16:01:20 +0000 (17:01 +0100)
* commit '9cbf2d78f0a9c19129e7a70b2281a450d386c6d9':
  pthread_frame: unref decoded frames on failure

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

@@@ -152,23 -144,23 +152,30 @@@ static attribute_align_arg void *frame_
          p->got_frame = 0;
          p->result = codec->decode(avctx, p->frame, &p->got_frame, &p->avpkt);
  
+         if ((p->result < 0 || !p->got_frame) && p->frame->buf[0]) {
+             if (avctx->internal->allocate_progress)
+                 av_log(avctx, AV_LOG_ERROR, "A frame threaded decoder did not "
+                        "free the frame on failure. This is a bug, please report it.\n");
+             av_frame_unref(p->frame);
+         }
          if (p->state == STATE_SETTING_UP) ff_thread_finish_setup(avctx);
  
 +        pthread_mutex_lock(&p->progress_mutex);
 +#if 0 //BUFREF-FIXME
 +        for (i = 0; i < MAX_BUFFERS; i++)
 +            if (p->progress_used[i] && (p->got_frame || p->result<0 || avctx->codec_id != AV_CODEC_ID_H264)) {
 +                p->progress[i][0] = INT_MAX;
 +                p->progress[i][1] = INT_MAX;
 +            }
 +#endif
          p->state = STATE_INPUT_READY;
  
 -        pthread_mutex_lock(&p->progress_mutex);
 +        pthread_cond_broadcast(&p->progress_cond);
          pthread_cond_signal(&p->output_cond);
          pthread_mutex_unlock(&p->progress_mutex);
 -
 -        pthread_mutex_unlock(&p->mutex);
      }
 +    pthread_mutex_unlock(&p->mutex);
  
      return NULL;
  }