[FFmpeg-cvslog] r13725 - in trunk: libavformat/ffm.h libavformat/ffmdec.c libavformat/ffmenc.c tests/libav.regression.ref tests/seek.regression.ref

bcoudurier subversion
Mon Jun 9 09:43:15 CEST 2008


Author: bcoudurier
Date: Mon Jun  9 09:43:14 2008
New Revision: 13725

Log:
pass dts and pts through ffm, should fix streaming b frames

Modified:
   trunk/libavformat/ffm.h
   trunk/libavformat/ffmdec.c
   trunk/libavformat/ffmenc.c
   trunk/tests/libav.regression.ref
   trunk/tests/seek.regression.ref

Modified: trunk/libavformat/ffm.h
==============================================================================
--- trunk/libavformat/ffm.h	(original)
+++ trunk/libavformat/ffm.h	Mon Jun  9 09:43:14 2008
@@ -29,8 +29,9 @@
 #define PACKET_ID       0x666d
 
 /* each packet contains frames (which can span several packets */
-#define FRAME_HEADER_SIZE    8
+#define FRAME_HEADER_SIZE    16
 #define FLAG_KEY_FRAME       0x01
+#define FLAG_DTS             0x02
 
 enum {
     READ_HEADER,
@@ -41,11 +42,10 @@ typedef struct FFMContext {
     /* only reading mode */
     offset_t write_index, file_size;
     int read_state;
-    uint8_t header[FRAME_HEADER_SIZE];
+    uint8_t header[FRAME_HEADER_SIZE+4];
 
     /* read and write */
     int first_packet; /* true if first packet, needed to set the discontinuity tag */
-    int first_frame_in_packet; /* true if first frame in packet, needed to know if PTS information is valid */
     int packet_size;
     int frame_offset;
     int64_t pts;

Modified: trunk/libavformat/ffmdec.c
==============================================================================
--- trunk/libavformat/ffmdec.c	(original)
+++ trunk/libavformat/ffmdec.c	Mon Jun  9 09:43:14 2008
@@ -100,7 +100,6 @@ static int ffm_read_data(AVFormatContext
             get_be16(pb); /* PACKET_ID */
             fill_size = get_be16(pb);
             ffm->pts = get_be64(pb);
-            ffm->first_frame_in_packet = 1;
             frame_offset = get_be16(pb);
             get_buffer(pb, ffm->packet, ffm->packet_size - FFM_HEADER_SIZE);
             ffm->packet_end = ffm->packet + (ffm->packet_size - FFM_HEADER_SIZE - fill_size);
@@ -361,7 +360,7 @@ static int ffm_read_packet(AVFormatConte
 
     switch(ffm->read_state) {
     case READ_HEADER:
-        if (!ffm_is_avail_data(s, FRAME_HEADER_SIZE)) {
+        if (!ffm_is_avail_data(s, FRAME_HEADER_SIZE+4)) {
             return AVERROR(EAGAIN);
         }
         dprintf(s, "pos=%08"PRIx64" spos=%"PRIx64", write_index=%"PRIx64" size=%"PRIx64"\n",
@@ -369,6 +368,9 @@ static int ffm_read_packet(AVFormatConte
         if (ffm_read_data(s, ffm->header, FRAME_HEADER_SIZE, 1) !=
             FRAME_HEADER_SIZE)
             return AVERROR(EAGAIN);
+        if (ffm->header[1] & FLAG_DTS)
+            if (ffm_read_data(s, ffm->header+16, 4, 1) != 4)
+                return AVERROR(EAGAIN);
 #if 0
         av_hexdump_log(s, AV_LOG_DEBUG, ffm->header, FRAME_HEADER_SIZE);
 #endif
@@ -400,11 +402,11 @@ static int ffm_read_packet(AVFormatConte
             av_free_packet(pkt);
             return AVERROR(EAGAIN);
         }
-        if (ffm->first_frame_in_packet)
-        {
-            pkt->pts = ffm->pts;
-            ffm->first_frame_in_packet = 0;
-        }
+        pkt->pts = AV_RB64(ffm->header+8);
+        if (ffm->header[1] & FLAG_DTS)
+            pkt->dts = pkt->pts - AV_RB32(ffm->header+16);
+        else
+            pkt->dts = pkt->pts;
         pkt->duration = duration;
         break;
     }

Modified: trunk/libavformat/ffmenc.c
==============================================================================
--- trunk/libavformat/ffmenc.c	(original)
+++ trunk/libavformat/ffmenc.c	Mon Jun  9 09:43:14 2008
@@ -197,6 +197,7 @@ static int ffm_write_packet(AVFormatCont
     AVStream *st = s->streams[pkt->stream_index];
     int64_t pts;
     uint8_t header[FRAME_HEADER_SIZE];
+    int header_size = FRAME_HEADER_SIZE;
 
     pts = s->timestamp + pkt->pts;
     /* packet size & key_frame */
@@ -206,7 +207,13 @@ static int ffm_write_packet(AVFormatCont
         header[1] |= FLAG_KEY_FRAME;
     AV_WB24(header+2, pkt->size);
     AV_WB24(header+5, pkt->duration);
-    ffm_write_data(s, header, FRAME_HEADER_SIZE, pts, 1);
+    AV_WB64(header+8, pts);
+    if (pkt->pts != pkt->dts) {
+        header[1] |= FLAG_DTS;
+        AV_WB32(header+16, pkt->pts - pkt->dts);
+        header_size += 4;
+    }
+    ffm_write_data(s, header, header_size, pts, 1);
     ffm_write_data(s, pkt->data, pkt->size, pts, 0);
 
     return 0;

Modified: trunk/tests/libav.regression.ref
==============================================================================
--- trunk/tests/libav.regression.ref	(original)
+++ trunk/tests/libav.regression.ref	Mon Jun  9 09:43:14 2008
@@ -15,9 +15,9 @@ bdb7484c68db722f66ba1630cf79844c *./test
 d6fdeb9f7083cc827f9510c6c4517dc0 *./tests/data/b-libav.swf
 335771 ./tests/data/b-libav.swf
 ./tests/data/b-libav.swf CRC=0xe14e8847
-bf28235fdc3bdd77faf251a239b6bc58 *./tests/data/b-libav.ffm
+bbdd9a4904eceb530b1a9ae02c48d76f *./tests/data/b-libav.ffm
 380928 ./tests/data/b-libav.ffm
-./tests/data/b-libav.ffm CRC=0xca8f6870
+./tests/data/b-libav.ffm CRC=0x2b71a386
 f8ad5bd78f4d012a8ce9570aa395ac54 *./tests/data/b-libav.flv
 335833 ./tests/data/b-libav.flv
 ./tests/data/b-libav.flv CRC=0xe14e8847

Modified: trunk/tests/seek.regression.ref
==============================================================================
--- trunk/tests/seek.regression.ref	(original)
+++ trunk/tests/seek.regression.ref	Mon Jun  9 09:43:14 2008
@@ -2830,7 +2830,7 @@ ret: 0 st:-1 ts:-0.645825 flags:1
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:-1 size:144000 flags:1
 ----------------
 tests/data/b-libav.ffm
-ret: 0 st: 0 dts:0.040000 pts:0.040000 pos:8192 size:24795 flags:1
+ret: 0 st: 0 dts:-0.040000 pts:0.000000 pos:8192 size:24795 flags:1
 ret: 0 st:-1 ts:-1.000000 flags:0
 ret: 0 st: 1 dts:0.940408 pts:0.940408 pos:380928 size:209 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
@@ -2838,15 +2838,15 @@ ret: 0 st: 1 dts:0.940408 pts:0.940408 p
 ret: 0 st: 0 ts:0.788334 flags:0
 ret: 0 st: 1 dts:0.731429 pts:0.731429 pos:307200 size:209 flags:1
 ret: 0 st: 0 ts:-0.317499 flags:1
-ret: 0 st: 0 dts:0.040000 pts:0.040000 pos:8192 size:24795 flags:1
+ret: 0 st: 0 dts:-0.040000 pts:0.000000 pos:8192 size:24795 flags:1
 ret: 0 st: 1 ts:2.576668 flags:0
 ret: 0 st: 1 dts:0.888163 pts:0.888163 pos:356352 size:209 flags:1
 ret: 0 st: 1 ts:1.470835 flags:1
 ret: 0 st: 1 dts:0.940408 pts:0.940408 pos:380928 size:209 flags:1
 ret: 0 st:-1 ts:0.365002 flags:0
-ret: 0 st: 0 dts:0.339592 pts:0.339592 pos:147456 size:12220 flags:0
+ret: 0 st: 1 dts:0.313469 pts:0.313469 pos:147456 size:209 flags:1
 ret: 0 st:-1 ts:-0.740831 flags:1
-ret: 0 st: 0 dts:0.040000 pts:0.040000 pos:8192 size:24795 flags:1
+ret: 0 st: 0 dts:-0.040000 pts:0.000000 pos:8192 size:24795 flags:1
 ret: 0 st: 0 ts:2.153336 flags:0
 ret: 0 st: 1 dts:0.888163 pts:0.888163 pos:356352 size:209 flags:1
 ret: 0 st: 0 ts:1.047503 flags:1
@@ -2874,15 +2874,15 @@ ret: 0 st: 1 dts:0.940408 pts:0.940408 p
 ret: 0 st: 0 ts:0.883340 flags:0
 ret: 0 st: 1 dts:0.809796 pts:0.809796 pos:331776 size:209 flags:1
 ret: 0 st: 0 ts:-0.222493 flags:1
-ret: 0 st: 0 dts:0.040000 pts:0.040000 pos:8192 size:24795 flags:1
+ret: 0 st: 0 dts:-0.040000 pts:0.000000 pos:8192 size:24795 flags:1
 ret: 0 st: 1 ts:2.671674 flags:0
 ret: 0 st: 1 dts:0.888163 pts:0.888163 pos:356352 size:209 flags:1
 ret: 0 st: 1 ts:1.565841 flags:1
 ret: 0 st: 1 dts:0.940408 pts:0.940408 pos:380928 size:209 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
-ret: 0 st: 1 dts:0.365714 pts:0.365714 pos:167936 size:209 flags:1
+ret: 0 st: 0 dts:0.400000 pts:0.440000 pos:172032 size:12546 flags:0
 ret: 0 st:-1 ts:-0.645825 flags:1
-ret: 0 st: 0 dts:0.040000 pts:0.040000 pos:8192 size:24795 flags:1
+ret: 0 st: 0 dts:-0.040000 pts:0.000000 pos:8192 size:24795 flags:1
 ----------------
 tests/data/b-libav.flv
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:199 size:31385 flags:1




More information about the ffmpeg-cvslog mailing list