Browse code

ffmpeg: Simplify decode loop condition to not use next_pts

Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>

Alexander Strange authored on 2011/05/10 14:53:46
Showing 1 changed files
... ...
@@ -1417,7 +1417,7 @@ static int output_packet(AVInputStream *ist, int ist_index,
1417 1417
     AVFormatContext *os;
1418 1418
     AVOutputStream *ost;
1419 1419
     int ret, i;
1420
-    int got_picture;
1420
+    int got_output;
1421 1421
     AVFrame picture;
1422 1422
     void *buffer_to_free;
1423 1423
     static unsigned int samples_size= 0;
... ...
@@ -1449,7 +1449,7 @@ static int output_packet(AVInputStream *ist, int ist_index,
1449 1449
         pkt_pts = av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q);
1450 1450
 
1451 1451
     //while we have more to decode or while the decoder did output something on EOF
1452
-    while (avpkt.size > 0 || (!pkt && ist->next_pts != ist->pts)) {
1452
+    while (avpkt.size > 0 || (!pkt && got_output)) {
1453 1453
         uint8_t *data_buf, *decoded_data_buf;
1454 1454
         int data_size, decoded_data_size;
1455 1455
     handle_eof:
... ...
@@ -1485,9 +1485,10 @@ static int output_packet(AVInputStream *ist, int ist_index,
1485 1485
                 avpkt.data += ret;
1486 1486
                 avpkt.size -= ret;
1487 1487
                 data_size   = ret;
1488
+                got_output  = decoded_data_size > 0;
1488 1489
                 /* Some bug in mpeg audio decoder gives */
1489 1490
                 /* decoded_data_size < 0, it seems they are overflows */
1490
-                if (decoded_data_size <= 0) {
1491
+                if (!got_output) {
1491 1492
                     /* no audio frame */
1492 1493
                     continue;
1493 1494
                 }
... ...
@@ -1504,11 +1505,11 @@ static int output_packet(AVInputStream *ist, int ist_index,
1504 1504
                     pkt_pts = AV_NOPTS_VALUE;
1505 1505
 
1506 1506
                     ret = avcodec_decode_video2(ist->st->codec,
1507
-                                                &picture, &got_picture, &avpkt);
1507
+                                                &picture, &got_output, &avpkt);
1508 1508
                     ist->st->quality= picture.quality;
1509 1509
                     if (ret < 0)
1510 1510
                         goto fail_decode;
1511
-                    if (!got_picture) {
1511
+                    if (!got_output) {
1512 1512
                         /* no picture yet */
1513 1513
                         goto discard_packet;
1514 1514
                     }
... ...
@@ -1523,10 +1524,10 @@ static int output_packet(AVInputStream *ist, int ist_index,
1523 1523
                     break;
1524 1524
             case AVMEDIA_TYPE_SUBTITLE:
1525 1525
                 ret = avcodec_decode_subtitle2(ist->st->codec,
1526
-                                               &subtitle, &got_picture, &avpkt);
1526
+                                               &subtitle, &got_output, &avpkt);
1527 1527
                 if (ret < 0)
1528 1528
                     goto fail_decode;
1529
-                if (!got_picture) {
1529
+                if (!got_output) {
1530 1530
                     goto discard_packet;
1531 1531
                 }
1532 1532
                 subtitle_to_free = &subtitle;