X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fiff.c;h=f388ca9e32f4d7cfb2c0dc760b0e985077523f00;hb=be9c00615b5c2cb858b9905854726ebe578c007b;hp=fcb3ff6b26e4b8594b21784e509fc49634688ede;hpb=65d213ec86019dd1dbc847ca7dde75dc7bd68b82;p=ffmpeg diff --git a/libavformat/iff.c b/libavformat/iff.c index fcb3ff6b26e..f388ca9e32f 100644 --- a/libavformat/iff.c +++ b/libavformat/iff.c @@ -4,20 +4,20 @@ * Copyright (c) 2010 Peter Ross * Copyright (c) 2010 Sebastian Vater * - * 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 */ @@ -30,7 +30,7 @@ */ #include "libavutil/intreadwrite.h" -#include "libavcodec/iff.h" +#include "libavutil/dict.h" #include "avformat.h" #define ID_8SVX MKTAG('8','S','V','X') @@ -102,12 +102,12 @@ static int get_metadata(AVFormatContext *s, if (!buf) return AVERROR(ENOMEM); - if (get_buffer(s->pb, buf, data_size) < 0) { + if (avio_read(s->pb, buf, data_size) < 0) { av_free(buf); return AVERROR(EIO); } buf[data_size] = 0; - av_metadata_set2(&s->metadata, tag, buf, AV_METADATA_DONT_STRDUP_VAL); + av_dict_set(&s->metadata, tag, buf, AV_DICT_DONT_STRDUP_VAL); return 0; } @@ -125,7 +125,7 @@ static int iff_read_header(AVFormatContext *s, AVFormatParameters *ap) { IffDemuxContext *iff = s->priv_data; - ByteIOContext *pb = s->pb; + AVIOContext *pb = s->pb; AVStream *st; uint32_t chunk_id, data_size; int compression = -1; @@ -135,17 +135,17 @@ static int iff_read_header(AVFormatContext *s, return AVERROR(ENOMEM); st->codec->channels = 1; - url_fskip(pb, 8); + avio_skip(pb, 8); // codec_tag used by ByteRun1 decoder to distinguish progressive (PBM) and interlaced (ILBM) content - st->codec->codec_tag = get_le32(pb); + st->codec->codec_tag = avio_rl32(pb); - while(!url_feof(pb)) { + while(!pb->eof_reached) { uint64_t orig_pos; int res; const char *metadata_tag = NULL; - chunk_id = get_le32(pb); - data_size = get_be32(pb); - orig_pos = url_ftell(pb); + chunk_id = avio_rl32(pb); + data_size = avio_rb32(pb); + orig_pos = avio_tell(pb); switch(chunk_id) { case ID_VHDR: @@ -153,23 +153,23 @@ static int iff_read_header(AVFormatContext *s, if (data_size < 14) return AVERROR_INVALIDDATA; - url_fskip(pb, 12); - st->codec->sample_rate = get_be16(pb); + avio_skip(pb, 12); + st->codec->sample_rate = avio_rb16(pb); if (data_size >= 16) { - url_fskip(pb, 1); - compression = get_byte(pb); + avio_skip(pb, 1); + compression = avio_r8(pb); } break; case ID_BODY: - iff->body_pos = url_ftell(pb); + iff->body_pos = avio_tell(pb); iff->body_size = data_size; break; case ID_CHAN: if (data_size < 4) return AVERROR_INVALIDDATA; - st->codec->channels = (get_be32(pb) < 6) ? 1 : 2; + st->codec->channels = (avio_rb32(pb) < 6) ? 1 : 2; break; case ID_CMAP: @@ -177,7 +177,7 @@ static int iff_read_header(AVFormatContext *s, st->codec->extradata = av_malloc(data_size); if (!st->codec->extradata) return AVERROR(ENOMEM); - if (get_buffer(pb, st->codec->extradata, data_size) < 0) + if (avio_read(pb, st->codec->extradata, data_size) < 0) return AVERROR(EIO); break; @@ -185,18 +185,18 @@ static int iff_read_header(AVFormatContext *s, st->codec->codec_type = AVMEDIA_TYPE_VIDEO; if (data_size <= 8) return AVERROR_INVALIDDATA; - st->codec->width = get_be16(pb); - st->codec->height = get_be16(pb); - url_fskip(pb, 4); // x, y offset - st->codec->bits_per_coded_sample = get_byte(pb); + st->codec->width = avio_rb16(pb); + st->codec->height = avio_rb16(pb); + avio_skip(pb, 4); // x, y offset + st->codec->bits_per_coded_sample = avio_r8(pb); if (data_size >= 11) { - url_fskip(pb, 1); // masking - compression = get_byte(pb); + avio_skip(pb, 1); // masking + compression = avio_r8(pb); } if (data_size >= 16) { - url_fskip(pb, 3); // paddding, transparent - st->sample_aspect_ratio.num = get_byte(pb); - st->sample_aspect_ratio.den = get_byte(pb); + avio_skip(pb, 3); // paddding, transparent + st->sample_aspect_ratio.num = avio_r8(pb); + st->sample_aspect_ratio.den = avio_r8(pb); } break; @@ -220,14 +220,14 @@ static int iff_read_header(AVFormatContext *s, if (metadata_tag) { if ((res = get_metadata(s, metadata_tag, data_size)) < 0) { - av_log(s, AV_LOG_ERROR, "iff: cannot allocate metadata tag %s!", metadata_tag); + av_log(s, AV_LOG_ERROR, "cannot allocate metadata tag %s!", metadata_tag); return res; } } - url_fskip(pb, data_size - (url_ftell(pb) - orig_pos) + (data_size & 1)); + avio_skip(pb, data_size - (avio_tell(pb) - orig_pos) + (data_size & 1)); } - url_fseek(pb, iff->body_pos, SEEK_SET); + avio_seek(pb, iff->body_pos, SEEK_SET); switch(st->codec->codec_type) { case AVMEDIA_TYPE_AUDIO: @@ -244,7 +244,7 @@ static int iff_read_header(AVFormatContext *s, st->codec->codec_id = CODEC_ID_8SVX_EXP; break; default: - av_log(s, AV_LOG_ERROR, "iff: unknown compression method\n"); + av_log(s, AV_LOG_ERROR, "unknown compression method\n"); return -1; } @@ -256,7 +256,7 @@ static int iff_read_header(AVFormatContext *s, case AVMEDIA_TYPE_VIDEO: switch (compression) { case BITMAP_RAW: - st->codec->codec_id = CODEC_ID_IFF_ILBM; + st->codec->codec_id = CODEC_ID_IFF_ILBM; break; case BITMAP_BYTERUN1: st->codec->codec_id = CODEC_ID_IFF_BYTERUN1; @@ -277,7 +277,7 @@ static int iff_read_packet(AVFormatContext *s, AVPacket *pkt) { IffDemuxContext *iff = s->priv_data; - ByteIOContext *pb = s->pb; + AVIOContext *pb = s->pb; AVStream *st = s->streams[0]; int ret; @@ -287,9 +287,9 @@ static int iff_read_packet(AVFormatContext *s, if(st->codec->channels == 2) { uint8_t sample_buffer[PACKET_SIZE]; - ret = get_buffer(pb, sample_buffer, PACKET_SIZE); + ret = avio_read(pb, sample_buffer, PACKET_SIZE); if(av_new_packet(pkt, PACKET_SIZE) < 0) { - av_log(s, AV_LOG_ERROR, "iff: cannot allocate packet \n"); + av_log(s, AV_LOG_ERROR, "cannot allocate packet\n"); return AVERROR(ENOMEM); } interleave_stereo(sample_buffer, pkt->data, PACKET_SIZE); @@ -315,11 +315,11 @@ static int iff_read_packet(AVFormatContext *s, return ret; } -AVInputFormat iff_demuxer = { - "IFF", - NULL_IF_CONFIG_SMALL("IFF format"), - sizeof(IffDemuxContext), - iff_probe, - iff_read_header, - iff_read_packet, +AVInputFormat ff_iff_demuxer = { + .name = "IFF", + .long_name = NULL_IF_CONFIG_SMALL("IFF format"), + .priv_data_size = sizeof(IffDemuxContext), + .read_probe = iff_probe, + .read_header = iff_read_header, + .read_packet = iff_read_packet, };