Mercurial > libavformat.hg
comparison utils.c @ 743:af4e24d6310c libavformat
switch to native time bases
author | michael |
---|---|
date | Sat, 30 Apr 2005 21:43:59 +0000 |
parents | 119ac74d1c49 |
children | 95c9cef3c3db |
comparison
equal
deleted
inserted
replaced
742:21c1ae78f041 | 743:af4e24d6310c |
---|---|
630 | 630 |
631 *pnum = 0; | 631 *pnum = 0; |
632 *pden = 0; | 632 *pden = 0; |
633 switch(st->codec.codec_type) { | 633 switch(st->codec.codec_type) { |
634 case CODEC_TYPE_VIDEO: | 634 case CODEC_TYPE_VIDEO: |
635 *pnum = st->codec.frame_rate_base; | 635 if(st->codec.time_base.num*1000 <= st->codec.time_base.den){ |
636 *pden = st->codec.frame_rate; | 636 *pnum = st->time_base.num; |
637 *pden = st->time_base.den; | |
638 }else{ | |
639 *pnum = st->codec.time_base.num; | |
640 *pden = st->codec.time_base.den; | |
641 } | |
637 if (pc && pc->repeat_pict) { | 642 if (pc && pc->repeat_pict) { |
638 *pden *= 2; | 643 *pden *= 2; |
639 *pnum = (*pnum) * (2 + pc->repeat_pict); | 644 *pnum = (*pnum) * (2 + pc->repeat_pict); |
640 } | 645 } |
641 break; | 646 break; |
681 | 686 |
682 static void compute_pkt_fields(AVFormatContext *s, AVStream *st, | 687 static void compute_pkt_fields(AVFormatContext *s, AVStream *st, |
683 AVCodecParserContext *pc, AVPacket *pkt) | 688 AVCodecParserContext *pc, AVPacket *pkt) |
684 { | 689 { |
685 int num, den, presentation_delayed; | 690 int num, den, presentation_delayed; |
686 | |
687 /* handle wrapping */ | 691 /* handle wrapping */ |
688 if(st->cur_dts != AV_NOPTS_VALUE){ | 692 if(st->cur_dts != AV_NOPTS_VALUE){ |
689 if(pkt->pts != AV_NOPTS_VALUE) | 693 if(pkt->pts != AV_NOPTS_VALUE) |
690 pkt->pts= lsb2full(pkt->pts, st->cur_dts, st->pts_wrap_bits); | 694 pkt->pts= lsb2full(pkt->pts, st->cur_dts, st->pts_wrap_bits); |
691 if(pkt->dts != AV_NOPTS_VALUE) | 695 if(pkt->dts != AV_NOPTS_VALUE) |
787 break; | 791 break; |
788 default: | 792 default: |
789 break; | 793 break; |
790 } | 794 } |
791 } | 795 } |
792 | |
793 /* convert the packet time stamp units */ | |
794 if(pkt->pts != AV_NOPTS_VALUE) | |
795 pkt->pts = av_rescale(pkt->pts, AV_TIME_BASE * (int64_t)st->time_base.num, st->time_base.den); | |
796 if(pkt->dts != AV_NOPTS_VALUE) | |
797 pkt->dts = av_rescale(pkt->dts, AV_TIME_BASE * (int64_t)st->time_base.num, st->time_base.den); | |
798 | |
799 /* duration field */ | |
800 pkt->duration = av_rescale(pkt->duration, AV_TIME_BASE * (int64_t)st->time_base.num, st->time_base.den); | |
801 } | 796 } |
802 | 797 |
803 void av_destruct_packet_nofree(AVPacket *pkt) | 798 void av_destruct_packet_nofree(AVPacket *pkt) |
804 { | 799 { |
805 pkt->data = NULL; pkt->size = 0; | 800 pkt->data = NULL; pkt->size = 0; |
1064 ret = av_read_frame(s, pkt); | 1059 ret = av_read_frame(s, pkt); |
1065 if (ret < 0) | 1060 if (ret < 0) |
1066 break; | 1061 break; |
1067 if (pkt->stream_index == 0 && st->parser && | 1062 if (pkt->stream_index == 0 && st->parser && |
1068 (pkt->flags & PKT_FLAG_KEY)) { | 1063 (pkt->flags & PKT_FLAG_KEY)) { |
1069 int64_t dts= av_rescale(pkt->dts, st->time_base.den, AV_TIME_BASE*(int64_t)st->time_base.num); | 1064 av_add_index_entry(st, st->parser->frame_offset, pkt->dts, |
1070 av_add_index_entry(st, st->parser->frame_offset, dts, | |
1071 0, AVINDEX_KEYFRAME); | 1065 0, AVINDEX_KEYFRAME); |
1072 } | 1066 } |
1073 av_free_packet(pkt); | 1067 av_free_packet(pkt); |
1074 } | 1068 } |
1075 } | 1069 } |
1404 | 1398 |
1405 /* estimate the stream timings from the one of each components. Also | 1399 /* estimate the stream timings from the one of each components. Also |
1406 compute the global bitrate if possible */ | 1400 compute the global bitrate if possible */ |
1407 static void av_update_stream_timings(AVFormatContext *ic) | 1401 static void av_update_stream_timings(AVFormatContext *ic) |
1408 { | 1402 { |
1409 int64_t start_time, end_time, end_time1; | 1403 int64_t start_time, start_time1, end_time, end_time1; |
1410 int i; | 1404 int i; |
1411 AVStream *st; | 1405 AVStream *st; |
1412 | 1406 |
1413 start_time = MAXINT64; | 1407 start_time = MAXINT64; |
1414 end_time = MININT64; | 1408 end_time = MININT64; |
1415 for(i = 0;i < ic->nb_streams; i++) { | 1409 for(i = 0;i < ic->nb_streams; i++) { |
1416 st = ic->streams[i]; | 1410 st = ic->streams[i]; |
1417 if (st->start_time != AV_NOPTS_VALUE) { | 1411 if (st->start_time != AV_NOPTS_VALUE) { |
1418 if (st->start_time < start_time) | 1412 start_time1= av_rescale_q(st->start_time, st->time_base, AV_TIME_BASE_Q); |
1419 start_time = st->start_time; | 1413 if (start_time1 < start_time) |
1414 start_time = start_time1; | |
1420 if (st->duration != AV_NOPTS_VALUE) { | 1415 if (st->duration != AV_NOPTS_VALUE) { |
1421 end_time1 = st->start_time + st->duration; | 1416 end_time1 = start_time1 |
1417 + av_rescale_q(st->duration, st->time_base, AV_TIME_BASE_Q); | |
1422 if (end_time1 > end_time) | 1418 if (end_time1 > end_time) |
1423 end_time = end_time1; | 1419 end_time = end_time1; |
1424 } | 1420 } |
1425 } | 1421 } |
1426 } | 1422 } |
1445 | 1441 |
1446 av_update_stream_timings(ic); | 1442 av_update_stream_timings(ic); |
1447 for(i = 0;i < ic->nb_streams; i++) { | 1443 for(i = 0;i < ic->nb_streams; i++) { |
1448 st = ic->streams[i]; | 1444 st = ic->streams[i]; |
1449 if (st->start_time == AV_NOPTS_VALUE) { | 1445 if (st->start_time == AV_NOPTS_VALUE) { |
1450 st->start_time = ic->start_time; | 1446 if(ic->start_time != AV_NOPTS_VALUE) |
1451 st->duration = ic->duration; | 1447 st->start_time = av_rescale_q(ic->start_time, AV_TIME_BASE_Q, st->time_base); |
1448 if(ic->duration != AV_NOPTS_VALUE) | |
1449 st->duration = av_rescale_q(ic->duration, AV_TIME_BASE_Q, st->time_base); | |
1452 } | 1450 } |
1453 } | 1451 } |
1454 } | 1452 } |
1455 | 1453 |
1456 static void av_estimate_timings_from_bit_rate(AVFormatContext *ic) | 1454 static void av_estimate_timings_from_bit_rate(AVFormatContext *ic) |
1473 if (ic->duration == AV_NOPTS_VALUE && | 1471 if (ic->duration == AV_NOPTS_VALUE && |
1474 ic->bit_rate != 0 && | 1472 ic->bit_rate != 0 && |
1475 ic->file_size != 0) { | 1473 ic->file_size != 0) { |
1476 filesize = ic->file_size; | 1474 filesize = ic->file_size; |
1477 if (filesize > 0) { | 1475 if (filesize > 0) { |
1478 duration = (int64_t)((8 * AV_TIME_BASE * (double)filesize) / (double)ic->bit_rate); | |
1479 for(i = 0; i < ic->nb_streams; i++) { | 1476 for(i = 0; i < ic->nb_streams; i++) { |
1480 st = ic->streams[i]; | 1477 st = ic->streams[i]; |
1478 duration= av_rescale(8*filesize, st->time_base.den, ic->bit_rate*(int64_t)st->time_base.num); | |
1481 if (st->start_time == AV_NOPTS_VALUE || | 1479 if (st->start_time == AV_NOPTS_VALUE || |
1482 st->duration == AV_NOPTS_VALUE) { | 1480 st->duration == AV_NOPTS_VALUE) { |
1483 st->start_time = 0; | 1481 st->start_time = 0; |
1484 st->duration = duration; | 1482 st->duration = duration; |
1485 } | 1483 } |
1536 break; | 1534 break; |
1537 read_size += pkt->size; | 1535 read_size += pkt->size; |
1538 st = ic->streams[pkt->stream_index]; | 1536 st = ic->streams[pkt->stream_index]; |
1539 if (pkt->pts != AV_NOPTS_VALUE) { | 1537 if (pkt->pts != AV_NOPTS_VALUE) { |
1540 if (st->start_time == AV_NOPTS_VALUE) | 1538 if (st->start_time == AV_NOPTS_VALUE) |
1541 st->start_time = av_rescale(pkt->pts, st->time_base.num * (int64_t)AV_TIME_BASE, st->time_base.den); | 1539 st->start_time = pkt->pts; |
1542 } | 1540 } |
1543 av_free_packet(pkt); | 1541 av_free_packet(pkt); |
1544 } | 1542 } |
1545 | 1543 |
1546 /* we compute the minimum start_time and use it as default */ | |
1547 start_time = MAXINT64; | |
1548 for(i = 0; i < ic->nb_streams; i++) { | |
1549 st = ic->streams[i]; | |
1550 if (st->start_time != AV_NOPTS_VALUE && | |
1551 st->start_time < start_time) | |
1552 start_time = st->start_time; | |
1553 } | |
1554 if (start_time != MAXINT64) | |
1555 ic->start_time = start_time; | |
1556 | |
1557 /* estimate the end time (duration) */ | 1544 /* estimate the end time (duration) */ |
1558 /* XXX: may need to support wrapping */ | 1545 /* XXX: may need to support wrapping */ |
1559 filesize = ic->file_size; | 1546 filesize = ic->file_size; |
1560 offset = filesize - DURATION_MAX_READ_SIZE; | 1547 offset = filesize - DURATION_MAX_READ_SIZE; |
1561 if (offset < 0) | 1548 if (offset < 0) |
1579 if (ret != 0) | 1566 if (ret != 0) |
1580 break; | 1567 break; |
1581 read_size += pkt->size; | 1568 read_size += pkt->size; |
1582 st = ic->streams[pkt->stream_index]; | 1569 st = ic->streams[pkt->stream_index]; |
1583 if (pkt->pts != AV_NOPTS_VALUE) { | 1570 if (pkt->pts != AV_NOPTS_VALUE) { |
1584 end_time = av_rescale(pkt->pts, st->time_base.num * (int64_t)AV_TIME_BASE, st->time_base.den); | 1571 end_time = pkt->pts; |
1585 duration = end_time - st->start_time; | 1572 duration = end_time - st->start_time; |
1586 if (duration > 0) { | 1573 if (duration > 0) { |
1587 if (st->duration == AV_NOPTS_VALUE || | 1574 if (st->duration == AV_NOPTS_VALUE || |
1588 st->duration < duration) | 1575 st->duration < duration) |
1589 st->duration = duration; | 1576 st->duration = duration; |
1590 } | 1577 } |
1591 } | 1578 } |
1592 av_free_packet(pkt); | 1579 av_free_packet(pkt); |
1593 } | 1580 } |
1594 | 1581 |
1595 /* estimate total duration */ | 1582 fill_all_stream_timings(ic); |
1596 end_time = MININT64; | |
1597 for(i = 0;i < ic->nb_streams; i++) { | |
1598 st = ic->streams[i]; | |
1599 if (st->duration != AV_NOPTS_VALUE) { | |
1600 end_time1 = st->start_time + st->duration; | |
1601 if (end_time1 > end_time) | |
1602 end_time = end_time1; | |
1603 } | |
1604 } | |
1605 | |
1606 /* update start_time (new stream may have been created, so we do | |
1607 it at the end */ | |
1608 if (ic->start_time != AV_NOPTS_VALUE) { | |
1609 for(i = 0; i < ic->nb_streams; i++) { | |
1610 st = ic->streams[i]; | |
1611 if (st->start_time == AV_NOPTS_VALUE) | |
1612 st->start_time = ic->start_time; | |
1613 } | |
1614 } | |
1615 | |
1616 if (end_time != MININT64) { | |
1617 /* put dummy values for duration if needed */ | |
1618 for(i = 0;i < ic->nb_streams; i++) { | |
1619 st = ic->streams[i]; | |
1620 if (st->duration == AV_NOPTS_VALUE && | |
1621 st->start_time != AV_NOPTS_VALUE) | |
1622 st->duration = end_time - st->start_time; | |
1623 } | |
1624 ic->duration = end_time - ic->start_time; | |
1625 } | |
1626 | 1583 |
1627 url_fseek(&ic->pb, 0, SEEK_SET); | 1584 url_fseek(&ic->pb, 0, SEEK_SET); |
1628 } | 1585 } |
1629 | 1586 |
1630 static void av_estimate_timings(AVFormatContext *ic) | 1587 static void av_estimate_timings(AVFormatContext *ic) |
1751 AVPacket pkt1, *pkt; | 1708 AVPacket pkt1, *pkt; |
1752 AVPacketList *pktl=NULL, **ppktl; | 1709 AVPacketList *pktl=NULL, **ppktl; |
1753 int64_t last_dts[MAX_STREAMS]; | 1710 int64_t last_dts[MAX_STREAMS]; |
1754 int64_t best_duration[MAX_STREAMS]; | 1711 int64_t best_duration[MAX_STREAMS]; |
1755 | 1712 |
1713 for(i=0;i<ic->nb_streams;i++) { | |
1714 st = ic->streams[i]; | |
1715 if(st->codec.codec_type == CODEC_TYPE_VIDEO){ | |
1716 /* if(!st->time_base.num) | |
1717 st->time_base= */ | |
1718 if(!st->codec.time_base.num) | |
1719 st->codec.time_base= st->time_base; | |
1720 } | |
1721 } | |
1722 | |
1756 for(i=0;i<MAX_STREAMS;i++){ | 1723 for(i=0;i<MAX_STREAMS;i++){ |
1757 last_dts[i]= AV_NOPTS_VALUE; | 1724 last_dts[i]= AV_NOPTS_VALUE; |
1758 best_duration[i]= INT64_MAX; | 1725 best_duration[i]= INT64_MAX; |
1759 } | 1726 } |
1760 | 1727 |
1766 for(i=0;i<ic->nb_streams;i++) { | 1733 for(i=0;i<ic->nb_streams;i++) { |
1767 st = ic->streams[i]; | 1734 st = ic->streams[i]; |
1768 if (!has_codec_parameters(&st->codec)) | 1735 if (!has_codec_parameters(&st->codec)) |
1769 break; | 1736 break; |
1770 /* variable fps and no guess at the real fps */ | 1737 /* variable fps and no guess at the real fps */ |
1771 if( st->codec.frame_rate >= 1000LL*st->codec.frame_rate_base | 1738 if( st->codec.time_base.den >= 1000LL*st->codec.time_base.num |
1772 && best_duration[i]== INT64_MAX) | 1739 && best_duration[i]== INT64_MAX && st->codec.codec_type == CODEC_TYPE_VIDEO) |
1773 break; | 1740 break; |
1774 } | 1741 } |
1775 if (i == ic->nb_streams) { | 1742 if (i == ic->nb_streams) { |
1776 /* NOTE: if the format has no header, then we need to read | 1743 /* NOTE: if the format has no header, then we need to read |
1777 some packets to get most of the streams, so we cannot | 1744 some packets to get most of the streams, so we cannot |
1872 st = ic->streams[i]; | 1839 st = ic->streams[i]; |
1873 if (st->codec.codec_type == CODEC_TYPE_VIDEO) { | 1840 if (st->codec.codec_type == CODEC_TYPE_VIDEO) { |
1874 if(st->codec.codec_id == CODEC_ID_RAWVIDEO && !st->codec.codec_tag && !st->codec.bits_per_sample) | 1841 if(st->codec.codec_id == CODEC_ID_RAWVIDEO && !st->codec.codec_tag && !st->codec.bits_per_sample) |
1875 st->codec.codec_tag= avcodec_pix_fmt_to_codec_tag(st->codec.pix_fmt); | 1842 st->codec.codec_tag= avcodec_pix_fmt_to_codec_tag(st->codec.pix_fmt); |
1876 | 1843 |
1877 if(best_duration[i] < INT64_MAX && st->codec.frame_rate_base*1000 <= st->codec.frame_rate){ | 1844 if(best_duration[i] < INT64_MAX && st->codec.time_base.num*1000 <= st->codec.time_base.den){ |
1878 int int_fps; | 1845 int int_fps; |
1879 | 1846 |
1880 st->r_frame_rate= st->codec.frame_rate; | 1847 st->r_frame_rate.num= st->time_base.den; |
1881 st->r_frame_rate_base= av_rescale(best_duration[i], st->codec.frame_rate, AV_TIME_BASE); | 1848 st->r_frame_rate.den= st->time_base.num*best_duration[i]; |
1882 av_reduce(&st->r_frame_rate, &st->r_frame_rate_base, st->r_frame_rate, st->r_frame_rate_base, 1<<15); | 1849 av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, st->r_frame_rate.num, st->r_frame_rate.den, 1<<15); |
1883 | 1850 |
1884 int_fps= av_rescale(st->r_frame_rate, 1, st->r_frame_rate_base); | 1851 int_fps= av_rescale(st->r_frame_rate.num, 1, st->r_frame_rate.den); // 1/0 |
1885 | 1852 |
1886 if(int_fps>0 && av_rescale(st->r_frame_rate, 1, int_fps) == st->r_frame_rate_base){ | 1853 if(int_fps>0 && av_rescale(st->r_frame_rate.num, 1, int_fps) == st->r_frame_rate.den){ |
1887 st->r_frame_rate= int_fps; | 1854 st->r_frame_rate.num= int_fps; |
1888 st->r_frame_rate_base= 1; | 1855 st->r_frame_rate.den= 1; |
1889 } | 1856 } |
1890 } | 1857 } |
1891 | 1858 |
1892 /* set real frame rate info */ | 1859 /* set real frame rate info */ |
1893 /* compute the real frame rate for telecine */ | 1860 /* compute the real frame rate for telecine */ |
1896 st->codec.sub_id == 2) { | 1863 st->codec.sub_id == 2) { |
1897 if (st->codec_info_nb_frames >= 20) { | 1864 if (st->codec_info_nb_frames >= 20) { |
1898 float coded_frame_rate, est_frame_rate; | 1865 float coded_frame_rate, est_frame_rate; |
1899 est_frame_rate = ((double)st->codec_info_nb_frames * AV_TIME_BASE) / | 1866 est_frame_rate = ((double)st->codec_info_nb_frames * AV_TIME_BASE) / |
1900 (double)st->codec_info_duration ; | 1867 (double)st->codec_info_duration ; |
1901 coded_frame_rate = (double)st->codec.frame_rate / | 1868 coded_frame_rate = 1.0/av_q2d(st->codec.time_base); |
1902 (double)st->codec.frame_rate_base; | |
1903 #if 0 | 1869 #if 0 |
1904 printf("telecine: coded_frame_rate=%0.3f est_frame_rate=%0.3f\n", | 1870 printf("telecine: coded_frame_rate=%0.3f est_frame_rate=%0.3f\n", |
1905 coded_frame_rate, est_frame_rate); | 1871 coded_frame_rate, est_frame_rate); |
1906 #endif | 1872 #endif |
1907 /* if we detect that it could be a telecine, we | 1873 /* if we detect that it could be a telecine, we |
1908 signal it. It would be better to do it at a | 1874 signal it. It would be better to do it at a |
1909 higher level as it can change in a film */ | 1875 higher level as it can change in a film */ |
1910 if (coded_frame_rate >= 24.97 && | 1876 if (coded_frame_rate >= 24.97 && |
1911 (est_frame_rate >= 23.5 && est_frame_rate < 24.5)) { | 1877 (est_frame_rate >= 23.5 && est_frame_rate < 24.5)) { |
1912 st->r_frame_rate = 24000; | 1878 st->r_frame_rate = (AVRational){24000, 1001}; |
1913 st->r_frame_rate_base = 1001; | |
1914 } | 1879 } |
1915 } | 1880 } |
1916 } | 1881 } |
1917 /* if no real frame rate, use the codec one */ | 1882 /* if no real frame rate, use the codec one */ |
1918 if (!st->r_frame_rate){ | 1883 if (!st->r_frame_rate.num){ |
1919 st->r_frame_rate = st->codec.frame_rate; | 1884 st->r_frame_rate.num = st->codec.time_base.den; |
1920 st->r_frame_rate_base = st->codec.frame_rate_base; | 1885 st->r_frame_rate.den = st->codec.time_base.num; |
1921 } | 1886 } |
1922 } | 1887 } |
1923 } | 1888 } |
1924 | 1889 |
1925 av_estimate_timings(ic); | 1890 av_estimate_timings(ic); |
2096 av_frac_init(&st->pts, 0, 0, | 2061 av_frac_init(&st->pts, 0, 0, |
2097 (int64_t)st->time_base.num * st->codec.sample_rate); | 2062 (int64_t)st->time_base.num * st->codec.sample_rate); |
2098 break; | 2063 break; |
2099 case CODEC_TYPE_VIDEO: | 2064 case CODEC_TYPE_VIDEO: |
2100 av_frac_init(&st->pts, 0, 0, | 2065 av_frac_init(&st->pts, 0, 0, |
2101 (int64_t)st->time_base.num * st->codec.frame_rate); | 2066 (int64_t)st->time_base.num * st->codec.time_base.den); |
2102 break; | 2067 break; |
2103 default: | 2068 default: |
2104 break; | 2069 break; |
2105 } | 2070 } |
2106 } | 2071 } |
2115 // av_log(NULL, AV_LOG_DEBUG, "av_write_frame: pts:%lld dts:%lld cur_dts:%lld b:%d size:%d st:%d\n", pkt->pts, pkt->dts, st->cur_dts, b_frames, pkt->size, pkt->stream_index); | 2080 // av_log(NULL, AV_LOG_DEBUG, "av_write_frame: pts:%lld dts:%lld cur_dts:%lld b:%d size:%d st:%d\n", pkt->pts, pkt->dts, st->cur_dts, b_frames, pkt->size, pkt->stream_index); |
2116 | 2081 |
2117 /* if(pkt->pts == AV_NOPTS_VALUE && pkt->dts == AV_NOPTS_VALUE) | 2082 /* if(pkt->pts == AV_NOPTS_VALUE && pkt->dts == AV_NOPTS_VALUE) |
2118 return -1;*/ | 2083 return -1;*/ |
2119 | 2084 |
2120 if(pkt->pts != AV_NOPTS_VALUE) | |
2121 pkt->pts = av_rescale(pkt->pts, st->time_base.den, AV_TIME_BASE * (int64_t)st->time_base.num); | |
2122 if(pkt->dts != AV_NOPTS_VALUE) | |
2123 pkt->dts = av_rescale(pkt->dts, st->time_base.den, AV_TIME_BASE * (int64_t)st->time_base.num); | |
2124 | |
2125 /* duration field */ | 2085 /* duration field */ |
2126 pkt->duration = av_rescale(pkt->duration, st->time_base.den, AV_TIME_BASE * (int64_t)st->time_base.num); | |
2127 if (pkt->duration == 0) { | 2086 if (pkt->duration == 0) { |
2128 compute_frame_duration(&num, &den, st, NULL, pkt); | 2087 compute_frame_duration(&num, &den, st, NULL, pkt); |
2129 if (den && num) { | 2088 if (den && num) { |
2130 pkt->duration = av_rescale(1, num * (int64_t)st->time_base.den, den * (int64_t)st->time_base.num); | 2089 pkt->duration = av_rescale(1, num * (int64_t)st->time_base.den, den * (int64_t)st->time_base.num); |
2131 } | 2090 } |
2176 if (frame_size >= 0 && (pkt->size || st->pts.num!=st->pts.den>>1 || st->pts.val)) { | 2135 if (frame_size >= 0 && (pkt->size || st->pts.num!=st->pts.den>>1 || st->pts.val)) { |
2177 av_frac_add(&st->pts, (int64_t)st->time_base.den * frame_size); | 2136 av_frac_add(&st->pts, (int64_t)st->time_base.den * frame_size); |
2178 } | 2137 } |
2179 break; | 2138 break; |
2180 case CODEC_TYPE_VIDEO: | 2139 case CODEC_TYPE_VIDEO: |
2181 av_frac_add(&st->pts, (int64_t)st->time_base.den * st->codec.frame_rate_base); | 2140 av_frac_add(&st->pts, (int64_t)st->time_base.den * st->codec.time_base.num); |
2182 break; | 2141 break; |
2183 default: | 2142 default: |
2184 break; | 2143 break; |
2185 } | 2144 } |
2186 return 0; | 2145 return 0; |
2774 * Print on 'f' a nice dump of a packet | 2733 * Print on 'f' a nice dump of a packet |
2775 * @param f stream for output | 2734 * @param f stream for output |
2776 * @param pkt packet to dump | 2735 * @param pkt packet to dump |
2777 * @param dump_payload true if the payload must be displayed too | 2736 * @param dump_payload true if the payload must be displayed too |
2778 */ | 2737 */ |
2738 //FIXME needs to know the time_base | |
2779 void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload) | 2739 void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload) |
2780 { | 2740 { |
2781 fprintf(f, "stream #%d:\n", pkt->stream_index); | 2741 fprintf(f, "stream #%d:\n", pkt->stream_index); |
2782 fprintf(f, " keyframe=%d\n", ((pkt->flags & PKT_FLAG_KEY) != 0)); | 2742 fprintf(f, " keyframe=%d\n", ((pkt->flags & PKT_FLAG_KEY) != 0)); |
2783 fprintf(f, " duration=%0.3f\n", (double)pkt->duration / AV_TIME_BASE); | 2743 fprintf(f, " duration=%0.3f\n", (double)pkt->duration / AV_TIME_BASE); |