changeset 4846:841ecebff8c8 libavcodec

timestamps generation improvement when parsing avi patch by Joakim \ elupus chez ecce dot se / original thread: date: 03/19/2007 01:47 AM subject: [Ffmpeg-devel] [RFC] Improvement for the odd timestamp generation when parser is in use.
author benoit
date Fri, 13 Apr 2007 07:50:04 +0000
parents 78bb9129231b
children 1a8865f72b04
files avcodec.h parser.c
diffstat 2 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/avcodec.h	Thu Apr 12 15:37:23 2007 +0000
+++ b/avcodec.h	Fri Apr 13 07:50:04 2007 +0000
@@ -37,8 +37,8 @@
 #define AV_STRINGIFY(s)         AV_TOSTRING(s)
 #define AV_TOSTRING(s) #s
 
-#define LIBAVCODEC_VERSION_INT  ((51<<16)+(40<<8)+2)
-#define LIBAVCODEC_VERSION      51.40.2
+#define LIBAVCODEC_VERSION_INT  ((51<<16)+(40<<8)+3)
+#define LIBAVCODEC_VERSION      51.40.3
 #define LIBAVCODEC_BUILD        LIBAVCODEC_VERSION_INT
 
 #define LIBAVCODEC_IDENT        "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
@@ -2940,6 +2940,9 @@
 
     int flags;
 #define PARSER_FLAG_COMPLETE_FRAMES           0x0001
+
+    int64_t offset;      ///< byte offset from starting packet start
+    int64_t last_offset;
 } AVCodecParserContext;
 
 typedef struct AVCodecParser {
--- a/parser.c	Thu Apr 12 15:37:23 2007 +0000
+++ b/parser.c	Fri Apr 13 07:50:04 2007 +0000
@@ -124,6 +124,7 @@
             s->fetch_timestamp=0;
             s->last_pts = pts;
             s->last_dts = dts;
+            s->last_offset = 0;
             s->cur_frame_pts[k] =
             s->cur_frame_dts[k] = AV_NOPTS_VALUE;
         }
@@ -138,6 +139,7 @@
         s->frame_offset = s->last_frame_offset;
         s->pts = s->last_pts;
         s->dts = s->last_dts;
+        s->offset = s->last_offset;
 
         /* offset of the next frame */
         s->last_frame_offset = s->cur_offset + index;
@@ -156,6 +158,7 @@
 
         s->last_pts = s->cur_frame_pts[k];
         s->last_dts = s->cur_frame_dts[k];
+        s->last_offset = s->last_frame_offset - s->cur_frame_offset[k];
 
         /* some parsers tell us the packet size even before seeing the first byte of the next packet,
            so the next pts/dts is in the next chunk */