[Ffmpeg-cvslog] CVS: ffmpeg/libavformat 4xm.c, 1.17, 1.18 amr.c, 1.6, 1.7 asf.c, 1.79, 1.80 au.c, 1.19, 1.20 avformat.h, 1.119, 1.120 avidec.c, 1.71, 1.72 electronicarts.c, 1.1, 1.2 ffm.c, 1.41, 1.42 flic.c, 1.5, 1.6 flvdec.c, 1.18, 1.19 idcin.c, 1.5, 1.6 idroq.c, 1.8, 1.9 ipmovie.c, 1.11, 1.12 matroska.c, 1.12, 1.13 mov.c, 1.84, 1.85 mp3.c, 1.7, 1.8 mpegts.c, 1.28, 1.29 nsvdec.c, 1.7, 1.8 nut.c, 1.48, 1.49 psxstr.c, 1.7, 1.8 raw.c, 1.53, 1.54 rm.c, 1.46, 1.47 segafilm.c, 1.7, 1.8 sierravmd.c, 1.6, 1.7 sol.c, 1.2, 1.3 swf.c, 1.24, 1.25 utils.c, 1.148, 1.149 wc3movie.c, 1.10, 1.11 westwood.c, 1.6, 1.7 yuv4mpeg.c, 1.22, 1.23

Michael Niedermayer CVS michael
Thu May 26 22:17:16 CEST 2005


Update of /cvsroot/ffmpeg/ffmpeg/libavformat
In directory mail:/var2/tmp/cvs-serv10676

Modified Files:
	4xm.c amr.c asf.c au.c avformat.h avidec.c electronicarts.c 
	ffm.c flic.c flvdec.c idcin.c idroq.c ipmovie.c matroska.c 
	mov.c mp3.c mpegts.c nsvdec.c nut.c psxstr.c raw.c rm.c 
	segafilm.c sierravmd.c sol.c swf.c utils.c wc3movie.c 
	westwood.c yuv4mpeg.c 
Log Message:
AVPacket.pos


Index: 4xm.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/4xm.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- 4xm.c	30 Apr 2005 21:43:57 -0000	1.17
+++ 4xm.c	26 May 2005 20:17:11 -0000	1.18
@@ -277,6 +277,7 @@
                 return AVERROR_IO;
             pkt->stream_index = fourxm->video_stream_index;
             pkt->pts = fourxm->video_pts;
+            pkt->pos = url_ftell(&s->pb);
             memcpy(pkt->data, header, 8);
             ret = get_buffer(&s->pb, &pkt->data[8], size);
 
@@ -293,16 +294,13 @@
             size-=8;
 
             if (track_number == fourxm->selected_track) {
-                if (av_new_packet(pkt, size))
+                ret= av_get_packet(&s->pb, pkt, size);
+                if(ret<0)
                     return AVERROR_IO;
                 pkt->stream_index = 
                     fourxm->tracks[fourxm->selected_track].stream_index;
                 pkt->pts = fourxm->audio_pts;
-                ret = get_buffer(&s->pb, pkt->data, size);
-                if (ret < 0)
-                    av_free_packet(pkt);
-                else
-                    packet_read = 1;
+                packet_read = 1;
 
                 /* pts accounting */
                 audio_frame_count = size;

Index: amr.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/amr.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- amr.c	24 Apr 2005 11:15:35 -0000	1.6
+++ amr.c	26 May 2005 20:17:11 -0000	1.7
@@ -154,7 +154,7 @@
             return AVERROR_IO;
         }
         pkt->stream_index = 0;
-        
+        pkt->pos= url_ftell(&s->pb);
         pkt->data[0]=toc;
     
         read = get_buffer(&s->pb, pkt->data+1, size);
@@ -189,6 +189,7 @@
         }
     
         pkt->stream_index = 0;
+        pkt->pos= url_ftell(&s->pb);
         pkt->data[0]=toc;
     
         read = get_buffer(&s->pb, pkt->data+1, size-1);

Index: asf.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/asf.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- asf.c	30 Apr 2005 21:43:58 -0000	1.79
+++ asf.c	26 May 2005 20:17:11 -0000	1.80
@@ -604,6 +604,7 @@
 	    asf_st->seq = asf->packet_seq;
 	    asf_st->pkt.pts = asf->packet_frag_timestamp;
 	    asf_st->pkt.stream_index = asf->stream_index;
+            asf_st->pkt.pos = 
             asf_st->packet_pos= asf->packet_pos;            
 //printf("new packet: stream:%d key:%d packet_key:%d audio:%d size:%d\n", 
 //asf->stream_index, asf->packet_key_frame, asf_st->pkt.flags & PKT_FLAG_KEY,

Index: au.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/au.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- au.c	22 Oct 2004 01:51:17 -0000	1.19
+++ au.c	26 May 2005 20:17:11 -0000	1.20
@@ -161,13 +161,11 @@
 
     if (url_feof(&s->pb))
         return AVERROR_IO;
-    if (av_new_packet(pkt, MAX_SIZE))
+    ret= av_get_packet(&s->pb, pkt, MAX_SIZE);
+    if (ret < 0)
         return AVERROR_IO;
     pkt->stream_index = 0;
 
-    ret = get_buffer(&s->pb, pkt->data, pkt->size);
-    if (ret < 0)
-        av_free_packet(pkt);
     /* note: we need to modify the packet size here to handle the last
        packet */
     pkt->size = ret;

Index: avformat.h
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/avformat.h,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -d -r1.119 -r1.120
--- avformat.h	30 Apr 2005 21:43:58 -0000	1.119
+++ avformat.h	26 May 2005 20:17:11 -0000	1.120
@@ -5,7 +5,7 @@
 extern "C" {
 #endif
 
-#define LIBAVFORMAT_BUILD       4624
+#define LIBAVFORMAT_BUILD       4625
 
 #define LIBAVFORMAT_VERSION_INT FFMPEG_VERSION_INT
 #define LIBAVFORMAT_VERSION     FFMPEG_VERSION
@@ -28,17 +28,16 @@
 #endif
 
 typedef struct AVPacket {
-    int64_t pts; /* presentation time stamp in AV_TIME_BASE units (or
-                    pts_den units in muxers or demuxers) */
-    int64_t dts; /* decompression time stamp in AV_TIME_BASE units (or
-                    pts_den units in muxers or demuxers) */
+    int64_t pts;                            ///< presentation time stamp in time_base units
+    int64_t dts;                            ///< decompression time stamp in time_base units
     uint8_t *data;
     int   size;
     int   stream_index;
     int   flags;
-    int   duration; /* presentation duration (0 if not available) */
+    int   duration;                         ///< presentation duration in time_base units (0 if not available)
     void  (*destruct)(struct AVPacket *);
     void  *priv;
+    int64_t pos;                            ///< byte position in stream, -1 if unknown
 } AVPacket; 
 #define PKT_FLAG_KEY   0x0001
 
@@ -49,6 +48,7 @@
 {
     pkt->pts   = AV_NOPTS_VALUE;
     pkt->dts   = AV_NOPTS_VALUE;
+    pkt->pos   = -1;
     pkt->duration = 0;
     pkt->flags = 0;
     pkt->stream_index = 0;
@@ -56,6 +56,7 @@
 }
 
 int av_new_packet(AVPacket *pkt, int size);
+int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size);
 int av_dup_packet(AVPacket *pkt);
 
 /**

Index: avidec.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/avidec.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- avidec.c	19 May 2005 00:06:26 -0000	1.71
+++ avidec.c	26 May 2005 20:17:11 -0000	1.72
@@ -423,8 +423,7 @@
 
         if(size > ast->remaining)
             size= ast->remaining;
-        av_new_packet(pkt, size);
-        get_buffer(pb, pkt->data, size);
+        av_get_packet(pb, pkt, size);
         
         if (avi->dv_demux) {
             dstr = pkt->destruct;

Index: electronicarts.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/electronicarts.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- electronicarts.c	16 Oct 2004 19:33:57 -0000	1.1
+++ electronicarts.c	26 May 2005 20:17:11 -0000	1.2
@@ -234,13 +234,10 @@
         switch (chunk_type) {
         /* audio data */
         case SCDl_TAG:
-            if (av_new_packet(pkt, chunk_size))
+            ret = av_get_packet(pb, pkt, chunk_size);
+            if (ret != chunk_size)
                 ret = AVERROR_IO;
             else {
-                ret = get_buffer(pb, pkt->data, chunk_size);
-                if (ret != chunk_size)
-                    ret = AVERROR_IO;
-                else {
                     pkt->stream_index = ea->audio_stream_index;
                     pkt->pts = 90000;
                     pkt->pts *= ea->audio_frame_counter;
@@ -250,7 +247,6 @@
                      * on stereo; chunk also has 12-byte header */
                     ea->audio_frame_counter += ((chunk_size - 12) * 2) /
                         ea->num_channels;
-                }
             }
 
             packet_read = 1;

Index: ffm.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/ffm.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- ffm.c	19 May 2005 00:06:26 -0000	1.41
+++ ffm.c	26 May 2005 20:17:11 -0000	1.42
@@ -603,6 +603,7 @@
 
         av_new_packet(pkt, size);
         pkt->stream_index = ffm->header[0];
+        pkt->pos = url_ftell(&s->pb); 
         if (ffm->header[1] & FLAG_KEY_FRAME)
             pkt->flags |= PKT_FLAG_KEY;
 

Index: flic.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/flic.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- flic.c	12 Jan 2005 00:16:25 -0000	1.5
+++ flic.c	26 May 2005 20:17:11 -0000	1.6
@@ -178,6 +178,7 @@
             }
             pkt->stream_index = flic->video_stream_index;
             pkt->pts = flic->pts;
+            pkt->pos = url_ftell(pb); 
             memcpy(pkt->data, preamble, FLIC_PREAMBLE_SIZE);
             ret = get_buffer(pb, pkt->data + FLIC_PREAMBLE_SIZE, 
                 size - FLIC_PREAMBLE_SIZE);

Index: flvdec.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/flvdec.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- flvdec.c	30 Apr 2005 21:43:58 -0000	1.18
+++ flvdec.c	26 May 2005 20:17:11 -0000	1.19
@@ -147,12 +147,8 @@
             }
     }
 
-    if (av_new_packet(pkt, size) < 0)
-        return AVERROR_IO;
-
-    ret = get_buffer(&s->pb, pkt->data, size);
+    ret= av_get_packet(&s->pb, pkt, size);
     if (ret <= 0) {
-        av_free_packet(pkt);
         return AVERROR_IO;
     }
     /* note: we need to modify the packet size here to handle the last

Index: idcin.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/idcin.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- idcin.c	19 Jun 2004 03:59:34 -0000	1.5
+++ idcin.c	26 May 2005 20:17:11 -0000	1.6
@@ -255,26 +255,22 @@
         /* skip the number of decoded bytes (always equal to width * height) */
         url_fseek(pb, 4, SEEK_CUR);
         chunk_size -= 4;
-        if (av_new_packet(pkt, chunk_size))
-            ret = AVERROR_IO;
+        ret= av_get_packet(pb, pkt, chunk_size); 
+        if (ret != chunk_size)
+            return AVERROR_IO;
         pkt->stream_index = idcin->video_stream_index;
         pkt->pts = idcin->pts;
-        ret = get_buffer(pb, pkt->data, chunk_size);
-        if (ret != chunk_size)
-            ret = AVERROR_IO;
     } else {
         /* send out the audio chunk */
         if (idcin->current_audio_chunk)
             chunk_size = idcin->audio_chunk_size2;
         else
             chunk_size = idcin->audio_chunk_size1;
-        if (av_new_packet(pkt, chunk_size))
+        ret= av_get_packet(pb, pkt, chunk_size);
+        if (ret != chunk_size)
             return AVERROR_IO;
         pkt->stream_index = idcin->audio_stream_index;
         pkt->pts = idcin->pts;
-        ret = get_buffer(&s->pb, pkt->data, chunk_size);
-        if (ret != chunk_size)
-            ret = AVERROR_IO;
 
         idcin->current_audio_chunk ^= 1;
         idcin->pts += FRAME_PTS_INC;

Index: idroq.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/idroq.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- idroq.c	12 Jan 2005 00:16:25 -0000	1.8
+++ idroq.c	26 May 2005 20:17:11 -0000	1.9
@@ -221,13 +221,11 @@
             url_fseek(pb, codebook_offset, SEEK_SET);
 
             /* load up the packet */
-            if (av_new_packet(pkt, chunk_size))
+            ret= av_get_packet(pb, pkt, chunk_size);
+            if (ret != chunk_size)
                 return AVERROR_IO;
             pkt->stream_index = roq->video_stream_index;
             pkt->pts = roq->video_pts;
-            ret = get_buffer(pb, pkt->data, chunk_size);
-            if (ret != chunk_size)
-                ret = AVERROR_IO;
 
             roq->video_pts += roq->frame_pts_inc;
             packet_read = 1;
@@ -254,6 +252,7 @@
                 roq->audio_frame_count += (chunk_size / roq->audio_channels);
             }
 
+            pkt->pos= url_ftell(pb);
             ret = get_buffer(pb, pkt->data + RoQ_CHUNK_PREAMBLE_SIZE,
                 chunk_size);
             if (ret != chunk_size)

Index: ipmovie.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/ipmovie.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- ipmovie.c	19 Jun 2004 14:51:46 -0000	1.11
+++ ipmovie.c	26 May 2005 20:17:11 -0000	1.12
@@ -140,16 +140,11 @@
         audio_pts *= s->audio_frame_count;
         audio_pts /= s->audio_sample_rate;
 
-        if (av_new_packet(pkt, s->audio_chunk_size))
-            return CHUNK_NOMEM;
+        if (s->audio_chunk_size != av_get_packet(pb, pkt, s->audio_chunk_size))
+            return CHUNK_EOF;
 
         pkt->stream_index = s->audio_stream_index;
         pkt->pts = audio_pts;
-        if (get_buffer(pb, pkt->data, s->audio_chunk_size) != 
-            s->audio_chunk_size) {
-            av_free_packet(pkt);
-            return CHUNK_EOF;
-        }
 
         /* audio frame maintenance */
         if (s->audio_type != CODEC_ID_INTERPLAY_DPCM)
@@ -171,6 +166,7 @@
         if (av_new_packet(pkt, s->decode_map_chunk_size + s->video_chunk_size))
             return CHUNK_NOMEM;
 
+        pkt->pos= s->decode_map_chunk_offset;
         url_fseek(pb, s->decode_map_chunk_offset, SEEK_SET);
         s->decode_map_chunk_offset = 0;
 

Index: matroska.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/matroska.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- matroska.c	13 May 2005 18:10:23 -0000	1.12
+++ matroska.c	26 May 2005 20:17:11 -0000	1.13
@@ -2366,6 +2366,7 @@
                 uint32_t *lace_size = NULL;
                 int n, track, flags, laces = 0;
                 uint64_t num;
+                int64_t pos= url_ftell(&matroska->ctx->pb);
 
                 if ((res = ebml_read_binary(matroska, &id, &data, &size)) < 0)
                     break;
@@ -2507,6 +2508,7 @@
                             matroska->tracks[track]->stream_index;
 
                         pkt->pts = timecode / 1000000; /* ns to ms */
+                        pkt->pos= pos;
 
                         matroska_queue_packet(matroska, pkt);
                     }

Index: mov.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/mov.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- mov.c	21 May 2005 10:41:52 -0000	1.84
+++ mov.c	26 May 2005 20:17:11 -0000	1.85
@@ -253,9 +253,6 @@
     int time_scale;
     long current_sample;
     long left_in_chunk; /* how many samples before next chunk */
-    /* specific MPEG4 header which is added at the beginning of the stream */
-    unsigned int header_len;
-    uint8_t *header_data;
     MOV_esds_t esds;
 } MOVStreamContext;
 
@@ -1672,7 +1669,6 @@
         av_freep(&sc->sample_to_chunk);
         av_freep(&sc->sample_sizes);
         av_freep(&sc->keyframes);
-        av_freep(&sc->header_data);
         av_freep(&sc->stts_data);        
         av_freep(&sc->ctts_data);        
         av_freep(&sc);
@@ -1974,18 +1970,7 @@
         return -1;
     url_fseek(&s->pb, offset, SEEK_SET);
 
-    //av_log(NULL, AV_LOG_DEBUG, "READCHUNK hlen: %d  %d off: %Ld   pos:%Ld\n", size, sc->header_len, offset, url_ftell(&s->pb));
-    if (sc->header_len > 0) {
-        av_new_packet(pkt, size + sc->header_len);
-        memcpy(pkt->data, sc->header_data, sc->header_len);
-        get_buffer(&s->pb, pkt->data + sc->header_len, size);
-        /* free header */
-        av_freep(&sc->header_data);
-        sc->header_len = 0;
-    } else {
-        av_new_packet(pkt, size);
-        get_buffer(&s->pb, pkt->data, pkt->size);
-    }
+    av_get_packet(&s->pb, pkt, size);
     pkt->stream_index = sc->ffindex;
     
     // If the keyframes table exists, mark any samples that are in the table as key frames.

Index: mp3.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/mp3.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- mp3.c	19 May 2005 00:06:27 -0000	1.7
+++ mp3.c	26 May 2005 20:17:11 -0000	1.8
@@ -297,13 +297,10 @@
     
     size= MP3_PACKET_SIZE;
 
-    if (av_new_packet(pkt, size) < 0)
-        return AVERROR_IO;
+    ret= av_get_packet(&s->pb, pkt, size);
 
     pkt->stream_index = 0;
-    ret = get_buffer(&s->pb, pkt->data, size);
     if (ret <= 0) {
-        av_free_packet(pkt);
         return AVERROR_IO;
     }
     /* note: we need to modify the packet size here to handle the last

Index: mpegts.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/mpegts.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- mpegts.c	6 May 2005 16:14:29 -0000	1.28
+++ mpegts.c	26 May 2005 20:17:11 -0000	1.29
@@ -1234,6 +1234,7 @@
 
     if (av_new_packet(pkt, TS_PACKET_SIZE) < 0)
         return -ENOMEM;
+    pkt->pos= url_ftell(&s->pb);
     ret = read_packet(&s->pb, pkt->data, ts->raw_packet_size);
     if (ret < 0) {
         av_free_packet(pkt);

Index: nsvdec.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/nsvdec.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- nsvdec.c	30 Apr 2005 21:43:58 -0000	1.7
+++ nsvdec.c	26 May 2005 20:17:11 -0000	1.8
@@ -592,8 +592,7 @@
     if (vsize/* && st[NSV_ST_VIDEO]*/) {
         nst = st[NSV_ST_VIDEO]->priv_data;
         pkt = &nsv->ahead[NSV_ST_VIDEO];
-        av_new_packet(pkt, vsize);
-        get_buffer(pb, pkt->data, vsize);
+        av_get_packet(pb, pkt, vsize);
         pkt->stream_index = st[NSV_ST_VIDEO]->index;//NSV_ST_VIDEO;
         pkt->dts = nst->frame_offset++;
         pkt->flags |= PKT_FLAG_KEY; /* stupid format has no way to tell XXX: try the index */
@@ -633,9 +632,7 @@
                 PRINT(("NSV RAWAUDIO: bps %d, nchan %d, srate %ld\n", bps, channels, samplerate));
             }
         }
-        av_new_packet(pkt, asize);
-        if (asize)
-            get_buffer(pb, pkt->data, asize);
+        av_get_packet(pb, pkt, asize);
         pkt->stream_index = st[NSV_ST_AUDIO]->index;//NSV_ST_AUDIO;
         //pkt->dts = nst->frame_offset;
         //if (nst->sample_size)

Index: nut.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/nut.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- nut.c	30 Apr 2005 21:43:58 -0000	1.48
+++ nut.c	26 May 2005 20:17:11 -0000	1.49
@@ -1236,8 +1236,7 @@
         return 1;
     }
 
-    av_new_packet(pkt, size);
-    get_buffer(bc, pkt->data, size);
+    av_get_packet(bc, pkt, size);
     pkt->stream_index = stream_id;
     if (key_frame)
 	pkt->flags |= PKT_FLAG_KEY;

Index: psxstr.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/psxstr.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- psxstr.c	24 Feb 2005 19:08:50 -0000	1.7
+++ psxstr.c	26 May 2005 20:17:12 -0000	1.8
@@ -283,6 +283,7 @@
                     if (av_new_packet(pkt, frame_size))
                         return AVERROR_IO;
 
+                    pkt->pos= url_ftell(pb) - RAW_CD_SECTOR_SIZE;
                     pkt->stream_index = 
                         str->channels[channel].video_stream_index;
                //     pkt->pts = str->pts;

Index: raw.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/raw.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- raw.c	6 May 2005 21:28:55 -0000	1.53
+++ raw.c	26 May 2005 20:17:12 -0000	1.54
@@ -88,13 +88,10 @@
     
     size= RAW_PACKET_SIZE;
 
-    if (av_new_packet(pkt, size) < 0)
-        return AVERROR_IO;
+    ret= av_get_packet(&s->pb, pkt, size);
 
     pkt->stream_index = 0;
-    ret = get_buffer(&s->pb, pkt->data, size);
     if (ret <= 0) {
-        av_free_packet(pkt);
         return AVERROR_IO;
     }
     /* note: we need to modify the packet size here to handle the last
@@ -111,7 +108,8 @@
 
     if (av_new_packet(pkt, size) < 0)
         return AVERROR_IO;
-
+    
+    pkt->pos= url_ftell(&s->pb);
     pkt->stream_index = 0;
     ret = get_partial_buffer(&s->pb, pkt->data, size);
     if (ret <= 0) {
@@ -618,18 +616,10 @@
     if (packet_size < 0)
         return -1;
 
-    if (av_new_packet(pkt, packet_size) < 0)
-        return AVERROR_IO;
+    ret= av_get_packet(&s->pb, pkt, packet_size);
 
     pkt->stream_index = 0;
-#if 0
-    /* bypass buffered I/O */
-    ret = url_read(url_fileno(&s->pb), pkt->data, pkt->size);
-#else
-    ret = get_buffer(&s->pb, pkt->data, pkt->size);
-#endif
-    if (ret != pkt->size) {
-        av_free_packet(pkt);
+    if (ret != packet_size) {
         return AVERROR_IO;
     } else {
         return 0;

Index: rm.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/rm.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- rm.c	30 Apr 2005 21:43:59 -0000	1.46
+++ rm.c	26 May 2005 20:17:12 -0000	1.47
@@ -812,11 +812,9 @@
     if (rm->old_format) {
         /* just read raw bytes */
         len = RAW_PACKET_SIZE;
-        av_new_packet(pkt, len);
+        len= av_get_packet(pb, pkt, len);
         pkt->stream_index = 0;
-        len = get_buffer(pb, pkt->data, len);
         if (len <= 0) {
-            av_free_packet(pkt);
             return AVERROR_IO;
         }
         pkt->size = len;
@@ -860,9 +858,8 @@
             goto resync;
         }
         
-        av_new_packet(pkt, len);
+        av_get_packet(pb, pkt, len);
         pkt->stream_index = i;
-        get_buffer(pb, pkt->data, len);
 
 #if 0
         if (st->codec.codec_type == CODEC_TYPE_VIDEO) {

Index: segafilm.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/segafilm.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- segafilm.c	12 Jan 2005 00:16:25 -0000	1.7
+++ segafilm.c	26 May 2005 20:17:12 -0000	1.8
@@ -233,6 +233,7 @@
             return AVERROR_NOMEM;
         if(pkt->size < 10)
             return -1;
+        pkt->pos= url_ftell(pb);
         ret = get_buffer(pb, pkt->data, 10);
         /* skip the non-spec CVID bytes */
         url_fseek(pb, film->cvid_extra_bytes, SEEK_CUR);
@@ -254,6 +255,7 @@
             film->stereo_buffer = av_malloc(film->stereo_buffer_size);
         }
 
+        pkt->pos= url_ftell(pb);
         ret = get_buffer(pb, film->stereo_buffer, sample->sample_size);
         if (ret != sample->sample_size)
             ret = AVERROR_IO;
@@ -272,9 +274,7 @@
             }
         }
     } else {
-        if (av_new_packet(pkt, sample->sample_size))
-            return AVERROR_NOMEM;
-        ret = get_buffer(pb, pkt->data, sample->sample_size);
+        ret= av_get_packet(pb, pkt, sample->sample_size);
         if (ret != sample->sample_size)
             ret = AVERROR_IO;
     }

Index: sierravmd.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/sierravmd.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- sierravmd.c	4 Feb 2005 18:58:59 -0000	1.6
+++ sierravmd.c	26 May 2005 20:17:12 -0000	1.7
@@ -269,6 +269,7 @@
 
     if (av_new_packet(pkt, frame->frame_size + BYTES_PER_FRAME_RECORD))
         return AVERROR_NOMEM;
+    pkt->pos= url_ftell(pb);
     memcpy(pkt->data, frame->frame_record, BYTES_PER_FRAME_RECORD);
     ret = get_buffer(pb, pkt->data + BYTES_PER_FRAME_RECORD, 
         frame->frame_size);

Index: sol.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/sol.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- sol.c	18 Oct 2004 09:43:39 -0000	1.2
+++ sol.c	26 May 2005 20:17:12 -0000	1.3
@@ -131,13 +131,9 @@
 
     if (url_feof(&s->pb))
         return -EIO;
-    if (av_new_packet(pkt, MAX_SIZE))
-        return -EIO;
+    ret= av_get_packet(&s->pb, pkt, MAX_SIZE);
     pkt->stream_index = 0;
 
-    ret = get_buffer(&s->pb, pkt->data, pkt->size);
-    if (ret < 0)
-        av_free_packet(pkt);
     /* note: we need to modify the packet size here to handle the last
        packet */
     pkt->size = ret;

Index: swf.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/swf.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- swf.c	30 Apr 2005 21:43:59 -0000	1.24
+++ swf.c	26 May 2005 20:17:12 -0000	1.25
@@ -858,10 +858,9 @@
                 if (st->id == 0) {
                     if ( get_le16(pb) == swf->ch_id ) {
                         frame = get_le16(pb);
-                        av_new_packet(pkt, len-4);
+                        av_get_packet(pb, pkt, len-4);
                         pkt->pts = frame * swf->ms_per_frame;
                         pkt->stream_index = st->index;
-                        get_buffer(pb, pkt->data, pkt->size);
                         return pkt->size;
                     } else {
                         url_fskip(pb, len-2);
@@ -874,9 +873,8 @@
             for( i=0; i<s->nb_streams; i++ ) {
         	st = s->streams[i];
                 if (st->id == 1) {
-                    av_new_packet(pkt, len);
+                    av_get_packet(pb, pkt, len);
                     pkt->stream_index = st->index;
-                    get_buffer(pb, pkt->data, pkt->size);
                     return pkt->size;
                 }
             }

Index: utils.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/utils.c,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -d -r1.148 -r1.149
--- utils.c	22 May 2005 08:47:09 -0000	1.148
+++ utils.c	26 May 2005 20:17:12 -0000	1.149
@@ -195,6 +195,31 @@
     return 0;
 }
 
+/**
+ * Allocate and read the payload of a packet and intialized its fields to default values.
+ *
+ * @param pkt packet
+ * @param size wanted payload size
+ * @return >0 (read size) if OK. AVERROR_xxx otherwise.
+ */
+int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size)
+{
+    int ret= av_new_packet(pkt, size);
+
+    if(ret<0)
+        return ret;
+
+    pkt->pos= url_ftell(s);
+
+    ret= get_buffer(s, pkt->data, size);
+    if(ret<=0)
+        av_free_packet(pkt);
+    else
+        pkt->size= ret;
+
+    return ret;
+}
+
 /* This is a hack - the packet memory allocation stuff is broken. The
    packet is allocated if it was not really allocated */
 int av_dup_packet(AVPacket *pkt)

Index: wc3movie.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/wc3movie.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- wc3movie.c	12 Jan 2005 00:16:25 -0000	1.10
+++ wc3movie.c	26 May 2005 20:17:12 -0000	1.11
@@ -318,11 +318,9 @@
 
         case VGA__TAG:
             /* send out video chunk */
-            if (av_new_packet(pkt, size))
-                ret = AVERROR_IO;
+            ret= av_get_packet(pb, pkt, size);
             pkt->stream_index = wc3->video_stream_index;
             pkt->pts = wc3->pts;
-            ret = get_buffer(pb, pkt->data, size);
             if (ret != size)
                 ret = AVERROR_IO;
             packet_read = 1;
@@ -349,11 +347,9 @@
 
         case AUDI_TAG:
             /* send out audio chunk */
-            if (av_new_packet(pkt, size))
-                ret = AVERROR_IO;
+            ret= av_get_packet(pb, pkt, size);
             pkt->stream_index = wc3->audio_stream_index;
             pkt->pts = wc3->pts;
-            ret = get_buffer(pb, pkt->data, size);
             if (ret != size)
                 ret = AVERROR_IO;
 

Index: westwood.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/westwood.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- westwood.c	19 Jun 2004 03:59:34 -0000	1.6
+++ westwood.c	26 May 2005 20:17:12 -0000	1.7
@@ -170,15 +170,12 @@
         return AVERROR_INVALIDDATA;
 
     chunk_size = LE_16(&preamble[0]);
-    if (av_new_packet(pkt, chunk_size))
+    ret= av_get_packet(pb, pkt, chunk_size);
+    if (ret != chunk_size)
         return AVERROR_IO;
     pkt->stream_index = wsaud->audio_stream_index;
     pkt->pts = wsaud->audio_frame_counter;
     pkt->pts /= wsaud->audio_samplerate;
-    if ((ret = get_buffer(pb, pkt->data, chunk_size)) != chunk_size) {
-        av_free_packet(pkt);
-        ret = AVERROR_IO;
-    }
 
     /* 2 samples/byte, 1 or 2 samples per frame depending on stereo */
     wsaud->audio_frame_counter += (chunk_size * 2) / wsaud->audio_channels;
@@ -322,11 +319,8 @@
 
     if ((chunk_type == SND2_TAG) || (chunk_type == VQFR_TAG)) {
 
-        if (av_new_packet(pkt, chunk_size))
-            return AVERROR_IO;
-        ret = get_buffer(pb, pkt->data, chunk_size);
+        av_get_packet(pb, pkt, chunk_size);
         if (ret != chunk_size) {
-            av_free_packet(pkt);
             ret = AVERROR_IO;
         }
 

Index: yuv4mpeg.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/yuv4mpeg.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- yuv4mpeg.c	30 Apr 2005 21:43:59 -0000	1.22
+++ yuv4mpeg.c	26 May 2005 20:17:12 -0000	1.23
@@ -356,17 +356,11 @@
     if (packet_size < 0)
         return -1;
 
-    if (av_new_packet(pkt, packet_size) < 0)
+    if (av_get_packet(&s->pb, pkt, packet_size) != packet_size)
         return AVERROR_IO;
 
     pkt->stream_index = 0;
-    ret = get_buffer(&s->pb, pkt->data, pkt->size);
-    if (ret != pkt->size) {
-        av_free_packet(pkt);
-        return AVERROR_IO;
-    } else {
-        return 0;
-    }
+    return 0;
 }
 
 static int yuv4_read_close(AVFormatContext *s)





More information about the ffmpeg-cvslog mailing list