[Ffmpeg-cvslog] CVS: ffmpeg/libavformat avformat.h, 1.129, 1.130 utils.c, 1.162, 1.163
Michael Niedermayer CVS
michael
Mon Aug 15 16:22:45 CEST 2005
Update of /cvsroot/ffmpeg/ffmpeg/libavformat
In directory mail:/var2/tmp/cvs-serv21000/libavformat
Modified Files:
avformat.h utils.c
Log Message:
support fixing missing pts by parsing future frames
Index: avformat.h
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/avformat.h,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -d -r1.129 -r1.130
--- avformat.h 31 Jul 2005 10:51:04 -0000 1.129
+++ avformat.h 15 Aug 2005 14:22:43 -0000 1.130
@@ -5,8 +5,8 @@
extern "C" {
#endif
-#define LIBAVFORMAT_VERSION_INT ((49<<16)+(0<<8)+0)
-#define LIBAVFORMAT_VERSION 49.0.0
+#define LIBAVFORMAT_VERSION_INT ((49<<16)+(1<<8)+0)
+#define LIBAVFORMAT_VERSION 49.1.0
#define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT
#define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
@@ -332,6 +332,8 @@
/* number of times to loop output in formats that support it */
int loop_output;
+ int flags;
+#define AVFMT_FLAG_GENPTS 0x0001 ///< generate pts if missing even if it requires parsing future frames
} AVFormatContext;
typedef struct AVPacketList {
Index: utils.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/utils.c,v
retrieving revision 1.162
retrieving revision 1.163
diff -u -d -r1.162 -r1.163
--- utils.c 14 Aug 2005 16:37:29 -0000 1.162
+++ utils.c 15 Aug 2005 14:22:43 -0000 1.163
@@ -955,16 +955,66 @@
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
{
AVPacketList *pktl;
+ int eof=0;
+ const int genpts= s->flags & AVFMT_FLAG_GENPTS;
- pktl = s->packet_buffer;
- if (pktl) {
- /* read packet from packet buffer, if there is data */
- *pkt = pktl->pkt;
- s->packet_buffer = pktl->next;
- av_free(pktl);
- return 0;
- } else {
- return av_read_frame_internal(s, pkt);
+ for(;;){
+ pktl = s->packet_buffer;
+ if (pktl) {
+ AVPacket *next_pkt= &pktl->pkt;
+ AVStream *st= s->streams[ next_pkt->stream_index ];
+
+ if(genpts && next_pkt->dts != AV_NOPTS_VALUE){
+ while(pktl && next_pkt->pts == AV_NOPTS_VALUE){
+ if( pktl->pkt.stream_index == next_pkt->stream_index
+ && next_pkt->dts < pktl->pkt.dts
+ && pktl->pkt.pts != pktl->pkt.dts //not b frame
+ /*&& pktl->pkt.dts != AV_NOPTS_VALUE*/){
+ next_pkt->pts= pktl->pkt.dts;
+ }
+ pktl= pktl->next;
+ }
+ pktl = s->packet_buffer;
+ }
+
+ if( next_pkt->pts != AV_NOPTS_VALUE
+ || next_pkt->dts == AV_NOPTS_VALUE
+ || !genpts || eof){
+ /* read packet from packet buffer, if there is data */
+ *pkt = *next_pkt;
+ s->packet_buffer = pktl->next;
+ av_free(pktl);
+ return 0;
+ }
+ }
+ if(genpts){
+ AVPacketList **plast_pktl= &s->packet_buffer;
+ int ret= av_read_frame_internal(s, pkt);
+ if(ret<0){
+ if(pktl && ret != -EAGAIN){
+ eof=1;
+ continue;
+ }else
+ return ret;
+ }
+
+ /* duplicate the packet */
+ if (av_dup_packet(pkt) < 0)
+ return AVERROR_NOMEM;
+
+ while(*plast_pktl) plast_pktl= &(*plast_pktl)->next; //FIXME maybe maintain pointer to the last?
+
+ pktl = av_mallocz(sizeof(AVPacketList));
+ if (!pktl)
+ return AVERROR_NOMEM;
+
+ /* add the packet in the buffered packet list */
+ *plast_pktl = pktl;
+ pktl->pkt= *pkt;
+ }else{
+ assert(!s->packet_buffer);
+ return av_read_frame_internal(s, pkt);
+ }
}
}
More information about the ffmpeg-cvslog
mailing list