* 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 {
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) {
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;
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;
}
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];
}
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;
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);
}
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];
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
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++;