]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/img2.c
avio: deprecate url_get_filename().
[ffmpeg] / libavformat / img2.c
index 9583eea5df73a6e61eedc94de64c0b6c1281f87c..bad58550c2ddeb34d0a8086356e86f076ac6fd57 100644 (file)
@@ -3,26 +3,27 @@
  * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
  * Copyright (c) 2004 Michael Niedermayer
  *
- * This file is part of FFmpeg.
+ * This file is part of Libav.
  *
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include "libavutil/intreadwrite.h"
 #include "libavutil/avstring.h"
 #include "avformat.h"
+#include "avio_internal.h"
 #include <strings.h>
 
 typedef struct {
@@ -255,7 +256,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
     char filename[1024];
     int i;
     int size[3]={0}, ret[3]={0};
-    ByteIOContext *f[3];
+    AVIOContext *f[3];
     AVCodecContext *codec= s1->streams[0]->codec;
 
     if (!s->is_pipe) {
@@ -269,13 +270,13 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
                                   s->path, s->img_number)<0 && s->img_number > 1)
             return AVERROR(EIO);
         for(i=0; i<3; i++){
-            if (url_fopen(&f[i], filename, URL_RDONLY) < 0) {
+            if (avio_open(&f[i], filename, URL_RDONLY) < 0) {
                 if(i==1)
                     break;
                 av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n",filename);
                 return AVERROR(EIO);
             }
-            size[i]= url_fsize(f[i]);
+            size[i]= avio_size(f[i]);
 
             if(codec->codec_id != CODEC_ID_RAWVIDEO)
                 break;
@@ -286,7 +287,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
             infer_size(&codec->width, &codec->height, size[0]);
     } else {
         f[0] = s1->pb;
-        if (url_feof(f[0]))
+        if (f[0]->eof_reached)
             return AVERROR(EIO);
         size[0]= 4096;
     }
@@ -298,9 +299,9 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
     pkt->size= 0;
     for(i=0; i<3; i++){
         if(size[i]){
-            ret[i]= get_buffer(f[i], pkt->data + pkt->size, size[i]);
+            ret[i]= avio_read(f[i], pkt->data + pkt->size, size[i]);
             if (!s->is_pipe)
-                url_fclose(f[i]);
+                avio_close(f[i]);
             if(ret[i]>0)
                 pkt->size += ret[i];
         }
@@ -339,7 +340,7 @@ static int write_header(AVFormatContext *s)
 static int write_packet(AVFormatContext *s, AVPacket *pkt)
 {
     VideoData *img = s->priv_data;
-    ByteIOContext *pb[3];
+    AVIOContext *pb[3];
     char filename[1024];
     AVCodecContext *codec= s->streams[ pkt->stream_index ]->codec;
     int i;
@@ -353,7 +354,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
             return AVERROR(EIO);
         }
         for(i=0; i<3; i++){
-            if (url_fopen(&pb[i], filename, URL_WRONLY) < 0) {
+            if (avio_open(&pb[i], filename, URL_WRONLY) < 0) {
                 av_log(s, AV_LOG_ERROR, "Could not open file : %s\n",filename);
                 return AVERROR(EIO);
             }
@@ -368,13 +369,13 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 
     if(codec->codec_id == CODEC_ID_RAWVIDEO){
         int ysize = codec->width * codec->height;
-        put_buffer(pb[0], pkt->data        , ysize);
-        put_buffer(pb[1], pkt->data + ysize, (pkt->size - ysize)/2);
-        put_buffer(pb[2], pkt->data + ysize +(pkt->size - ysize)/2, (pkt->size - ysize)/2);
-        put_flush_packet(pb[1]);
-        put_flush_packet(pb[2]);
-        url_fclose(pb[1]);
-        url_fclose(pb[2]);
+        avio_write(pb[0], pkt->data        , ysize);
+        avio_write(pb[1], pkt->data + ysize, (pkt->size - ysize)/2);
+        avio_write(pb[2], pkt->data + ysize +(pkt->size - ysize)/2, (pkt->size - ysize)/2);
+        avio_flush(pb[1]);
+        avio_flush(pb[2]);
+        avio_close(pb[1]);
+        avio_close(pb[2]);
     }else{
         if(av_str2id(img_tags, s->filename) == CODEC_ID_JPEG2000){
             AVStream *st = s->streams[0];
@@ -382,15 +383,15 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
                AV_RL32(st->codec->extradata+4) == MKTAG('j','p','2','h')){
                 if(pkt->size < 8 || AV_RL32(pkt->data+4) != MKTAG('j','p','2','c'))
                     goto error;
-                put_be32(pb[0], 12);
-                put_tag (pb[0], "jP  ");
-                put_be32(pb[0], 0x0D0A870A); // signature
-                put_be32(pb[0], 20);
-                put_tag (pb[0], "ftyp");
-                put_tag (pb[0], "jp2 ");
-                put_be32(pb[0], 0);
-                put_tag (pb[0], "jp2 ");
-                put_buffer(pb[0], st->codec->extradata, st->codec->extradata_size);
+                avio_wb32(pb[0], 12);
+                ffio_wfourcc(pb[0], "jP  ");
+                avio_wb32(pb[0], 0x0D0A870A); // signature
+                avio_wb32(pb[0], 20);
+                ffio_wfourcc(pb[0], "ftyp");
+                ffio_wfourcc(pb[0], "jp2 ");
+                avio_wb32(pb[0], 0);
+                ffio_wfourcc(pb[0], "jp2 ");
+                avio_write(pb[0], st->codec->extradata, st->codec->extradata_size);
             }else if(pkt->size < 8 ||
                      (!st->codec->extradata_size &&
                       AV_RL32(pkt->data+4) != MKTAG('j','P',' ',' '))){ // signature
@@ -399,11 +400,11 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
                 return -1;
             }
         }
-        put_buffer(pb[0], pkt->data, pkt->size);
+        avio_write(pb[0], pkt->data, pkt->size);
     }
-    put_flush_packet(pb[0]);
+    avio_flush(pb[0]);
     if (!img->is_pipe) {
-        url_fclose(pb[0]);
+        avio_close(pb[0]);
     }
 
     img->img_number++;