diff asf.c @ 2771:d52c718e83f9 libavformat

Use dynamically allocated ByteIOContext in AVFormatContext patch by: Bj«Órn Axelsson, bjorn d axelsson a intinor d se thread: [PATCH] Remove static ByteIOContexts, 06 nov 2007
author andoma
date Wed, 21 Nov 2007 07:41:00 +0000
parents 1e7edb0c6cfc
children f717dd23fc23
line wrap: on
line diff
--- a/asf.c	Mon Nov 19 20:28:11 2007 +0000
+++ b/asf.c	Wed Nov 21 07:41:00 2007 +0000
@@ -148,7 +148,7 @@
 {
     ASFContext *asf = s->priv_data;
     GUID g;
-    ByteIOContext *pb = &s->pb;
+    ByteIOContext *pb = s->pb;
     AVStream *st;
     ASFStream *asf_st;
     int size, i;
@@ -582,12 +582,12 @@
 static int asf_get_packet(AVFormatContext *s)
 {
     ASFContext *asf = s->priv_data;
-    ByteIOContext *pb = &s->pb;
+    ByteIOContext *pb = s->pb;
     uint32_t packet_length, padsize;
     int rsize = 8;
     int c, d, e, off;
 
-    off= (url_ftell(&s->pb) - s->data_offset) % asf->packet_size + 3;
+    off= (url_ftell(s->pb) - s->data_offset) % asf->packet_size + 3;
 
     c=d=e=-1;
     while(off-- > 0){
@@ -658,7 +658,7 @@
  */
 static int asf_read_frame_header(AVFormatContext *s){
     ASFContext *asf = s->priv_data;
-    ByteIOContext *pb = &s->pb;
+    ByteIOContext *pb = s->pb;
     int rsize = 1;
     int num = get_byte(pb);
     int64_t ts0, ts1;
@@ -731,7 +731,7 @@
 {
     ASFContext *asf = s->priv_data;
     ASFStream *asf_st = 0;
-    ByteIOContext *pb = &s->pb;
+    ByteIOContext *pb = s->pb;
     //static int pc = 0;
     for (;;) {
         if(url_feof(pb))
@@ -745,7 +745,7 @@
             /* fail safe */
             url_fskip(pb, ret);
 
-            asf->packet_pos= url_ftell(&s->pb);
+            asf->packet_pos= url_ftell(s->pb);
             if (asf->data_object_size != (uint64_t)-1 &&
                 (asf->packet_pos - asf->data_object_offset >= asf->data_object_size))
                 return AVERROR(EIO); /* Do not exceed the size of the data object */
@@ -968,7 +968,7 @@
 
     pos= (pos+asf->packet_size-1-s->data_offset)/asf->packet_size*asf->packet_size+ s->data_offset;
     *ppos= pos;
-    url_fseek(&s->pb, pos, SEEK_SET);
+    url_fseek(s->pb, pos, SEEK_SET);
 
 //printf("asf_read_pts\n");
     asf_reset_header(s);
@@ -1012,21 +1012,21 @@
     int i;
     int pct,ict;
 
-    current_pos = url_ftell(&s->pb);
+    current_pos = url_ftell(s->pb);
 
-    url_fseek(&s->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET);
-    get_guid(&s->pb, &g);
+    url_fseek(s->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET);
+    get_guid(s->pb, &g);
     if (!memcmp(&g, &index_guid, sizeof(GUID))) {
-        gsize = get_le64(&s->pb);
-        get_guid(&s->pb, &g);
-        itime=get_le64(&s->pb);
-        pct=get_le32(&s->pb);
-        ict=get_le32(&s->pb);
+        gsize = get_le64(s->pb);
+        get_guid(s->pb, &g);
+        itime=get_le64(s->pb);
+        pct=get_le32(s->pb);
+        ict=get_le32(s->pb);
         av_log(NULL, AV_LOG_DEBUG, "itime:0x%"PRIx64", pct:%d, ict:%d\n",itime,pct,ict);
 
         for (i=0;i<ict;i++){
-            int pktnum=get_le32(&s->pb);
-            int pktct =get_le16(&s->pb);
+            int pktnum=get_le32(s->pb);
+            int pktct =get_le16(s->pb);
             av_log(NULL, AV_LOG_DEBUG, "pktnum:%d, pktct:%d\n", pktnum, pktct);
 
             pos=s->data_offset + asf->packet_size*(int64_t)pktnum;
@@ -1036,7 +1036,7 @@
         }
         asf->index_read= 1;
     }
-    url_fseek(&s->pb, current_pos, SEEK_SET);
+    url_fseek(s->pb, current_pos, SEEK_SET);
 }
 
 static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flags)
@@ -1066,10 +1066,10 @@
 
     // various attempts to find key frame have failed so far
     //    asf_reset_header(s);
-    //    url_fseek(&s->pb, pos, SEEK_SET);
+    //    url_fseek(s->pb, pos, SEEK_SET);
     //    key_pos = pos;
     //     for(i=0;i<16;i++){
-    //         pos = url_ftell(&s->pb);
+    //         pos = url_ftell(s->pb);
     //         if (av_read_frame(s, &pkt) < 0){
     //             av_log(s, AV_LOG_INFO, "seek failed\n");
     //             return -1;
@@ -1087,7 +1087,7 @@
 
         /* do the seek */
         av_log(NULL, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos);
-        url_fseek(&s->pb, pos, SEEK_SET);
+        url_fseek(s->pb, pos, SEEK_SET);
     }
     asf_reset_header(s);
     return 0;