Browse code

ffplay: fix frame_delay calculation in new avfilter code

Signed-off-by: Marton Balint <cus@passwd.hu>

Marton Balint authored on 2012/06/07 06:06:23
Showing 1 changed files
... ...
@@ -1540,9 +1540,6 @@ static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacke
1540 1540
             SDL_UnlockMutex(is->pictq_mutex);
1541 1541
         }
1542 1542
 
1543
-        if (ret)
1544
-            is->frame_last_returned_time = av_gettime() / 1000000.0;
1545
-
1546 1543
         return ret;
1547 1544
     }
1548 1545
     return 0;
... ...
@@ -1679,10 +1676,6 @@ static int video_thread(void *arg)
1679 1679
             continue;
1680 1680
         }
1681 1681
 
1682
-        is->frame_last_filter_delay = av_gettime() / 1000000.0 - is->frame_last_returned_time;
1683
-        if (fabs(is->frame_last_filter_delay) > AV_NOSYNC_THRESHOLD / 10.0)
1684
-            is->frame_last_filter_delay = 0;
1685
-
1686 1682
 #if CONFIG_AVFILTER
1687 1683
         if (   last_w != is->video_st->codec->width
1688 1684
             || last_h != is->video_st->codec->height
... ...
@@ -1725,12 +1718,18 @@ static int video_thread(void *arg)
1725 1725
         av_free_packet(&pkt);
1726 1726
 
1727 1727
         while (ret >= 0) {
1728
+            is->frame_last_returned_time = av_gettime() / 1000000.0;
1729
+
1728 1730
             ret = av_buffersink_get_buffer_ref(filt_out, &picref, 0);
1729 1731
             if (ret < 0) {
1730 1732
                 ret = 0;
1731 1733
                 break;
1732 1734
             }
1733 1735
 
1736
+            is->frame_last_filter_delay = av_gettime() / 1000000.0 - is->frame_last_returned_time;
1737
+            if (fabs(is->frame_last_filter_delay) > AV_NOSYNC_THRESHOLD / 10.0)
1738
+                is->frame_last_filter_delay = 0;
1739
+
1734 1740
             avfilter_fill_frame_from_video_buffer_ref(frame, picref);
1735 1741
 
1736 1742
             pts_int = picref->pts;