[FFmpeg-devel] [PATCH] Make DV (sub) demuxer set proper pkt->pos values.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Apr 30 11:57:23 CEST 2011


This makes the avi demuxer create packets with proper pos values
with the file from ticket #140.
---
 libavdevice/dv1394.c |    2 +-
 libavformat/avidec.c |    2 +-
 libavformat/dv.c     |    7 +++++--
 libavformat/dv.h     |    2 +-
 libavformat/mov.c    |    2 +-
 5 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/libavdevice/dv1394.c b/libavdevice/dv1394.c
index 588f356..a9bc058 100644
--- a/libavdevice/dv1394.c
+++ b/libavdevice/dv1394.c
@@ -202,7 +202,7 @@ restart_poll:
 
     size = dv_produce_packet(dv->dv_demux, pkt,
                              dv->ring + (dv->index * DV1394_PAL_FRAME_SIZE),
-                             DV1394_PAL_FRAME_SIZE);
+                             DV1394_PAL_FRAME_SIZE, -1);
     dv->index = (dv->index + 1) % DV1394_RING_FRAMES;
     dv->done++; dv->avail--;
 
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index e5e3726..9395dc2 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -946,7 +946,7 @@ resync:
         if (CONFIG_DV_DEMUXER && avi->dv_demux) {
             dstr = pkt->destruct;
             size = dv_produce_packet(avi->dv_demux, pkt,
-                                    pkt->data, pkt->size);
+                                    pkt->data, pkt->size, pkt->pos);
             pkt->destruct = dstr;
             pkt->flags |= AV_PKT_FLAG_KEY;
             if (size < 0)
diff --git a/libavformat/dv.c b/libavformat/dv.c
index 1e32125..750c950 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -316,7 +316,7 @@ int dv_get_packet(DVDemuxContext *c, AVPacket *pkt)
 }
 
 int dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
-                      uint8_t* buf, int buf_size)
+                      uint8_t* buf, int buf_size, int64_t pos)
 {
     int size, i;
     uint8_t *ppcm[4] = {0};
@@ -331,6 +331,7 @@ int dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
     /* FIXME: in case of no audio/bad audio we have to do something */
     size = dv_extract_audio_info(c, buf);
     for (i = 0; i < c->ach; i++) {
+       c->audio_pkt[i].pos  = pos;
        c->audio_pkt[i].size = size;
        c->audio_pkt[i].pts  = c->abytes * 30000*8 / c->ast[i]->codec->bit_rate;
        ppcm[i] = c->audio_buf[i];
@@ -354,6 +355,7 @@ int dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
     size = dv_extract_video_info(c, buf);
     av_init_packet(pkt);
     pkt->data         = buf;
+    pkt->pos          = pos;
     pkt->size         = size;
     pkt->flags       |= AV_PKT_FLAG_KEY;
     pkt->stream_index = c->vst->id;
@@ -452,13 +454,14 @@ static int dv_read_packet(AVFormatContext *s, AVPacket *pkt)
     size = dv_get_packet(c->dv_demux, pkt);
 
     if (size < 0) {
+        int64_t pos = avio_tell(s->pb);
         if (!c->dv_demux->sys)
             return AVERROR(EIO);
         size = c->dv_demux->sys->frame_size;
         if (avio_read(s->pb, c->buf, size) <= 0)
             return AVERROR(EIO);
 
-        size = dv_produce_packet(c->dv_demux, pkt, c->buf, size);
+        size = dv_produce_packet(c->dv_demux, pkt, c->buf, size, pos);
     }
 
     return size;
diff --git a/libavformat/dv.h b/libavformat/dv.h
index b8b43f1..ce240c0 100644
--- a/libavformat/dv.h
+++ b/libavformat/dv.h
@@ -33,7 +33,7 @@
 typedef struct DVDemuxContext DVDemuxContext;
 DVDemuxContext* dv_init_demux(AVFormatContext* s);
 int dv_get_packet(DVDemuxContext*, AVPacket *);
-int dv_produce_packet(DVDemuxContext*, AVPacket*, uint8_t*, int);
+int dv_produce_packet(DVDemuxContext*, AVPacket*, uint8_t*, int, int64_t);
 void dv_offset_reset(DVDemuxContext *c, int64_t frame_offset);
 
 typedef struct DVMuxContext DVMuxContext;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index fcb2735..cc12015 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2458,7 +2458,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
         }
 #if CONFIG_DV_DEMUXER
         if (mov->dv_demux && sc->dv_audio_container) {
-            dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size);
+            dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos);
             av_free(pkt->data);
             pkt->size = 0;
             ret = dv_get_packet(mov->dv_demux, pkt);
-- 
1.7.4.4



More information about the ffmpeg-devel mailing list