* 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 "internal.h"
#include <strings.h>
typedef struct {
if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0){
*pfirst_index =
*plast_index = 1;
- if(url_exist(buf))
+ if (avio_check(buf, AVIO_FLAG_READ) > 0)
return 0;
return -1;
}
- if (url_exist(buf))
+ if (avio_check(buf, AVIO_FLAG_READ) > 0)
break;
}
if (first_index == 5)
if (av_get_frame_filename(buf, sizeof(buf), path,
last_index + range1) < 0)
goto fail;
- if (!url_exist(buf))
+ if (avio_check(buf, AVIO_FLAG_READ) <= 0)
break;
range = range1;
/* just in case... */
return 0;
}
+enum CodecID ff_guess_image2_codec(const char *filename)
+{
+ return av_str2id(img_tags, filename);
+}
+
+#if FF_API_GUESS_IMG2_CODEC
enum CodecID av_guess_image2_codec(const char *filename){
return av_str2id(img_tags, filename);
}
+#endif
static int read_header(AVFormatContext *s1, AVFormatParameters *ap)
{
s->path, s->img_number)<0 && s->img_number > 1)
return AVERROR(EIO);
for(i=0; i<3; i++){
- if (avio_open(&f[i], filename, URL_RDONLY) < 0) {
+ if (avio_open(&f[i], filename, AVIO_FLAG_READ) < 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;
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;
}
return AVERROR(EIO);
}
for(i=0; i<3; i++){
- if (avio_open(&pb[i], filename, URL_WRONLY) < 0) {
+ if (avio_open(&pb[i], filename, AVIO_FLAG_WRITE) < 0) {
av_log(s, AV_LOG_ERROR, "Could not open file : %s\n",filename);
return AVERROR(EIO);
}
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);
- put_flush_packet(pb[1]);
- put_flush_packet(pb[2]);
+ avio_flush(pb[1]);
+ avio_flush(pb[2]);
avio_close(pb[1]);
avio_close(pb[2]);
}else{
if(pkt->size < 8 || AV_RL32(pkt->data+4) != MKTAG('j','p','2','c'))
goto error;
avio_wb32(pb[0], 12);
- put_tag (pb[0], "jP ");
+ ffio_wfourcc(pb[0], "jP ");
avio_wb32(pb[0], 0x0D0A870A); // signature
avio_wb32(pb[0], 20);
- put_tag (pb[0], "ftyp");
- put_tag (pb[0], "jp2 ");
+ ffio_wfourcc(pb[0], "ftyp");
+ ffio_wfourcc(pb[0], "jp2 ");
avio_wb32(pb[0], 0);
- put_tag (pb[0], "jp2 ");
+ 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 &&
}
avio_write(pb[0], pkt->data, pkt->size);
}
- put_flush_packet(pb[0]);
+ avio_flush(pb[0]);
if (!img->is_pipe) {
avio_close(pb[0]);
}