X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fsiff.c;h=cdb64528e528c999bc083347779ed660dae6dfcd;hb=5a9ee3152b6e69166c7819f07a4992bd22052917;hp=c8f892b8d53dcca2161e66f0971a31908035cd24;hpb=f094b6627db5d7e32bf03361ec060fa28b59564c;p=ffmpeg diff --git a/libavformat/siff.c b/libavformat/siff.c index c8f892b8d53..cdb64528e52 100644 --- a/libavformat/siff.c +++ b/libavformat/siff.c @@ -1,24 +1,25 @@ /* * Beam Software SIFF demuxer - * Copyright (c) 2007 Konstantin Shishkov. + * Copyright (c) 2007 Konstantin Shishkov * - * 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 "avformat.h" enum SIFFTags{ @@ -59,11 +60,12 @@ typedef struct SIFFContext{ static int siff_probe(AVProbeData *p) { + uint32_t tag = AV_RL32(p->buf + 8); /* check file header */ - if (AV_RL32(p->buf) == TAG_SIFF) - return AVPROBE_SCORE_MAX; - else + if (AV_RL32(p->buf) != TAG_SIFF || + (tag != TAG_VBV1 && tag != TAG_SOUN)) return 0; + return AVPROBE_SCORE_MAX; } static int create_audio_stream(AVFormatContext *s, SIFFContext *c) @@ -72,51 +74,51 @@ static int create_audio_stream(AVFormatContext *s, SIFFContext *c) ast = av_new_stream(s, 0); if (!ast) return -1; - ast->codec->codec_type = CODEC_TYPE_AUDIO; + ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->codec->codec_id = CODEC_ID_PCM_U8; ast->codec->channels = 1; - ast->codec->bits_per_sample = c->bits; + ast->codec->bits_per_coded_sample = c->bits; ast->codec->sample_rate = c->rate; ast->codec->frame_size = c->block_align; av_set_pts_info(ast, 16, 1, c->rate); return 0; } -static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, ByteIOContext *pb) +static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, AVIOContext *pb) { AVStream *st; int width, height; - if (get_le32(pb) != TAG_VBHD){ + if (avio_rl32(pb) != TAG_VBHD){ av_log(s, AV_LOG_ERROR, "Header chunk is missing\n"); return -1; } - if(get_be32(pb) != 32){ + if(avio_rb32(pb) != 32){ av_log(s, AV_LOG_ERROR, "Header chunk size is incorrect\n"); return -1; } - if(get_le16(pb) != 1){ + if(avio_rl16(pb) != 1){ av_log(s, AV_LOG_ERROR, "Incorrect header version\n"); return -1; } - width = get_le16(pb); - height = get_le16(pb); - url_fskip(pb, 4); - c->frames = get_le16(pb); + width = avio_rl16(pb); + height = avio_rl16(pb); + avio_skip(pb, 4); + c->frames = avio_rl16(pb); if(!c->frames){ av_log(s, AV_LOG_ERROR, "File contains no frames ???\n"); return -1; } - c->bits = get_le16(pb); - c->rate = get_le16(pb); + c->bits = avio_rl16(pb); + c->rate = avio_rl16(pb); c->block_align = c->rate * (c->bits >> 3); - url_fskip(pb, 16); //zeroes + avio_skip(pb, 16); //zeroes st = av_new_stream(s, 0); if (!st) return -1; - st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_VB; st->codec->codec_tag = MKTAG('V', 'B', 'V', '1'); st->codec->width = width; @@ -133,33 +135,33 @@ static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, ByteIOContext *pb return 0; } -static int siff_parse_soun(AVFormatContext *s, SIFFContext *c, ByteIOContext *pb) +static int siff_parse_soun(AVFormatContext *s, SIFFContext *c, AVIOContext *pb) { - if (get_le32(pb) != TAG_SHDR){ + if (avio_rl32(pb) != TAG_SHDR){ av_log(s, AV_LOG_ERROR, "Header chunk is missing\n"); return -1; } - if(get_be32(pb) != 8){ + if(avio_rb32(pb) != 8){ av_log(s, AV_LOG_ERROR, "Header chunk size is incorrect\n"); return -1; } - url_fskip(pb, 4); //unknown value - c->rate = get_le16(pb); - c->bits = get_le16(pb); + avio_skip(pb, 4); //unknown value + c->rate = avio_rl16(pb); + c->bits = avio_rl16(pb); c->block_align = c->rate * (c->bits >> 3); return create_audio_stream(s, c); } static int siff_read_header(AVFormatContext *s, AVFormatParameters *ap) { - ByteIOContext *pb = s->pb; + AVIOContext *pb = s->pb; SIFFContext *c = s->priv_data; uint32_t tag; - if (get_le32(pb) != TAG_SIFF) + if (avio_rl32(pb) != TAG_SIFF) return -1; - url_fskip(pb, 4); //ignore size - tag = get_le32(pb); + avio_skip(pb, 4); //ignore size + tag = avio_rl32(pb); if (tag != TAG_VBV1 && tag != TAG_SOUN){ av_log(s, AV_LOG_ERROR, "Not a VBV file\n"); @@ -170,11 +172,11 @@ static int siff_read_header(AVFormatContext *s, AVFormatParameters *ap) return -1; if (tag == TAG_SOUN && siff_parse_soun(s, c, pb) < 0) return -1; - if (get_le32(pb) != MKTAG('B', 'O', 'D', 'Y')){ + if (avio_rl32(pb) != MKTAG('B', 'O', 'D', 'Y')){ av_log(s, AV_LOG_ERROR, "'BODY' chunk is missing\n"); return -1; } - url_fskip(pb, 4); //ignore size + avio_skip(pb, 4); //ignore size return 0; } @@ -188,12 +190,12 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt) if (c->cur_frame >= c->frames) return AVERROR(EIO); if (c->curstrm == -1){ - c->pktsize = get_le32(s->pb) - 4; - c->flags = get_le16(s->pb); + c->pktsize = avio_rl32(s->pb) - 4; + c->flags = avio_rl16(s->pb); c->gmcsize = (c->flags & VB_HAS_GMC) ? 4 : 0; if (c->gmcsize) - get_buffer(s->pb, c->gmc, c->gmcsize); - c->sndsize = (c->flags & VB_HAS_AUDIO) ? get_le32(s->pb): 0; + avio_read(s->pb, c->gmc, c->gmcsize); + c->sndsize = (c->flags & VB_HAS_AUDIO) ? avio_rl32(s->pb): 0; c->curstrm = !!(c->flags & VB_HAS_AUDIO); } @@ -204,7 +206,7 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt) AV_WL16(pkt->data, c->flags); if (c->gmcsize) memcpy(pkt->data + 2, c->gmc, c->gmcsize); - get_buffer(s->pb, pkt->data + 2 + c->gmcsize, size - c->gmcsize - 2); + avio_read(s->pb, pkt->data + 2 + c->gmcsize, size - c->gmcsize - 2); pkt->stream_index = 0; c->curstrm = -1; }else{ @@ -214,7 +216,7 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt) c->curstrm = 0; } if(!c->cur_frame || c->curstrm) - pkt->flags |= PKT_FLAG_KEY; + pkt->flags |= AV_PKT_FLAG_KEY; if (c->curstrm == -1) c->cur_frame++; }else{ @@ -225,12 +227,12 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt) return pkt->size; } -AVInputFormat siff_demuxer = { - "siff", - "Beam Software SIFF", - sizeof(SIFFContext), - siff_probe, - siff_read_header, - siff_read_packet, +AVInputFormat ff_siff_demuxer = { + .name = "siff", + .long_name = NULL_IF_CONFIG_SMALL("Beam Software SIFF"), + .priv_data_size = sizeof(SIFFContext), + .read_probe = siff_probe, + .read_header = siff_read_header, + .read_packet = siff_read_packet, .extensions = "vb,son" };