Browse code

ffplay: move output_picture() code to queue_picture()

Move output_picture() code to queue_picture(), and remove it.
Simplify code path.

Stefano Sabatini authored on 2011/04/22 18:54:31
Showing 1 changed files
... ...
@@ -1359,13 +1359,30 @@ static void alloc_picture(void *opaque)
1359 1359
     SDL_UnlockMutex(is->pictq_mutex);
1360 1360
 }
1361 1361
 
1362
-/**
1363
- *
1364
- * @param pts the dts of the pkt / pts of the frame and guessed if not known
1365
- */
1366
-static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, int64_t pos)
1362
+static int queue_picture(VideoState *is, AVFrame *src_frame, double pts1, int64_t pos)
1367 1363
 {
1368 1364
     VideoPicture *vp;
1365
+    double frame_delay, pts = pts1;
1366
+
1367
+    /* compute the exact PTS for the picture if it is omitted in the stream
1368
+     * pts1 is the dts of the pkt / pts of the frame */
1369
+    if (pts != 0) {
1370
+        /* update video clock with pts, if present */
1371
+        is->video_clock = pts;
1372
+    } else {
1373
+        pts = is->video_clock;
1374
+    }
1375
+    /* update video clock for next frame */
1376
+    frame_delay = av_q2d(is->video_st->codec->time_base);
1377
+    /* for MPEG2, the frame can be repeated, so we update the
1378
+       clock accordingly */
1379
+    frame_delay += src_frame->repeat_pict * (frame_delay * 0.5);
1380
+    is->video_clock += frame_delay;
1381
+
1382
+#if defined(DEBUG_SYNC) && 0
1383
+    printf("frame_type=%c clock=%0.3f pts=%0.3f\n",
1384
+           av_get_pict_type_char(src_frame->pict_type), pts, pts1);
1385
+#endif
1369 1386
 
1370 1387
     /* wait until we have space to put a new picture */
1371 1388
     SDL_LockMutex(is->pictq_mutex);
... ...
@@ -1469,36 +1486,6 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, int64_t
1469 1469
     return 0;
1470 1470
 }
1471 1471
 
1472
-/**
1473
- * compute the exact PTS for the picture if it is omitted in the stream
1474
- * @param pts1 the dts of the pkt / pts of the frame
1475
- */
1476
-static int output_picture(VideoState *is, AVFrame *src_frame, double pts1, int64_t pos)
1477
-{
1478
-    double frame_delay, pts;
1479
-
1480
-    pts = pts1;
1481
-
1482
-    if (pts != 0) {
1483
-        /* update video clock with pts, if present */
1484
-        is->video_clock = pts;
1485
-    } else {
1486
-        pts = is->video_clock;
1487
-    }
1488
-    /* update video clock for next frame */
1489
-    frame_delay = av_q2d(is->video_st->codec->time_base);
1490
-    /* for MPEG2, the frame can be repeated, so we update the
1491
-       clock accordingly */
1492
-    frame_delay += src_frame->repeat_pict * (frame_delay * 0.5);
1493
-    is->video_clock += frame_delay;
1494
-
1495
-#if defined(DEBUG_SYNC) && 0
1496
-    printf("frame_type=%c clock=%0.3f pts=%0.3f\n",
1497
-           av_get_pict_type_char(src_frame->pict_type), pts, pts1);
1498
-#endif
1499
-    return queue_picture(is, src_frame, pts, pos);
1500
-}
1501
-
1502 1472
 static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacket *pkt)
1503 1473
 {
1504 1474
     int len1, got_picture, i;
... ...
@@ -1853,7 +1840,7 @@ static int video_thread(void *arg)
1853 1853
 
1854 1854
         pts = pts_int*av_q2d(is->video_st->time_base);
1855 1855
 
1856
-        ret = output_picture(is, frame, pts, pos);
1856
+        ret = queue_picture(is, frame, pts, pos);
1857 1857
 #if !CONFIG_AVFILTER
1858 1858
         av_free_packet(&pkt);
1859 1859
 #endif