X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fmm.c;h=d25c978ac41d12d31512e1ee6f42935af6aa1711;hb=14c98973f5822f5ada53c4cc40c0bcf71744d812;hp=cb0917a7abdbeec8880c662108f52f6ee1c7fd2e;hpb=ba87f0801d77c21eb1e4891ca1f846500bbb0939;p=ffmpeg diff --git a/libavformat/mm.c b/libavformat/mm.c index cb0917a7abd..d25c978ac41 100644 --- a/libavformat/mm.c +++ b/libavformat/mm.c @@ -2,20 +2,20 @@ * American Laser Games MM Format Demuxer * Copyright (c) 2006 Peter Ross * - * 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 */ @@ -33,6 +33,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "internal.h" #define MM_PREAMBLE_SIZE 6 @@ -80,32 +81,31 @@ static int probe(AVProbeData *p) return AVPROBE_SCORE_MAX / 2; } -static int read_header(AVFormatContext *s, - AVFormatParameters *ap) +static int read_header(AVFormatContext *s) { MmDemuxContext *mm = s->priv_data; - ByteIOContext *pb = s->pb; + AVIOContext *pb = s->pb; AVStream *st; unsigned int type, length; unsigned int frame_rate, width, height; - type = get_le16(pb); - length = get_le32(pb); + type = avio_rl16(pb); + length = avio_rl32(pb); if (type != MM_TYPE_HEADER) return AVERROR_INVALIDDATA; /* read header */ - get_le16(pb); /* total number of chunks */ - frame_rate = get_le16(pb); - get_le16(pb); /* ibm-pc video bios mode */ - width = get_le16(pb); - height = get_le16(pb); - url_fseek(pb, length - 10, SEEK_CUR); /* unknown data */ + avio_rl16(pb); /* total number of chunks */ + frame_rate = avio_rl16(pb); + avio_rl16(pb); /* ibm-pc video bios mode */ + width = avio_rl16(pb); + height = avio_rl16(pb); + avio_skip(pb, length - 10); /* unknown data */ /* video stream */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; @@ -113,11 +113,11 @@ static int read_header(AVFormatContext *s, st->codec->codec_tag = 0; /* no fourcc */ st->codec->width = width; st->codec->height = height; - av_set_pts_info(st, 64, 1, frame_rate); + avpriv_set_pts_info(st, 64, 1, frame_rate); /* audio stream */ if (length == MM_HEADER_LEN_AV) { - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; @@ -125,7 +125,7 @@ static int read_header(AVFormatContext *s, st->codec->codec_id = CODEC_ID_PCM_U8; st->codec->channels = 1; st->codec->sample_rate = 8000; - av_set_pts_info(st, 64, 1, 8000); /* 8000 hz */ + avpriv_set_pts_info(st, 64, 1, 8000); /* 8000 hz */ } mm->audio_pts = 0; @@ -137,13 +137,13 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) { MmDemuxContext *mm = s->priv_data; - ByteIOContext *pb = s->pb; + AVIOContext *pb = s->pb; unsigned char preamble[MM_PREAMBLE_SIZE]; unsigned int type, length; while(1) { - if (get_buffer(pb, preamble, MM_PREAMBLE_SIZE) != MM_PREAMBLE_SIZE) { + if (avio_read(pb, preamble, MM_PREAMBLE_SIZE) != MM_PREAMBLE_SIZE) { return AVERROR(EIO); } @@ -162,7 +162,7 @@ static int read_packet(AVFormatContext *s, if (av_new_packet(pkt, length + MM_PREAMBLE_SIZE)) return AVERROR(ENOMEM); memcpy(pkt->data, preamble, MM_PREAMBLE_SIZE); - if (get_buffer(pb, pkt->data + MM_PREAMBLE_SIZE, length) != length) + if (avio_read(pb, pkt->data + MM_PREAMBLE_SIZE, length) != length) return AVERROR(EIO); pkt->size = length + MM_PREAMBLE_SIZE; pkt->stream_index = 0; @@ -181,18 +181,16 @@ static int read_packet(AVFormatContext *s, default : av_log(s, AV_LOG_INFO, "unknown chunk type 0x%x\n", type); - url_fseek(pb, length, SEEK_CUR); + avio_skip(pb, length); } } - - return 0; } -AVInputFormat mm_demuxer = { - "mm", - NULL_IF_CONFIG_SMALL("American Laser Games MM format"), - sizeof(MmDemuxContext), - probe, - read_header, - read_packet, +AVInputFormat ff_mm_demuxer = { + .name = "mm", + .long_name = NULL_IF_CONFIG_SMALL("American Laser Games MM format"), + .priv_data_size = sizeof(MmDemuxContext), + .read_probe = probe, + .read_header = read_header, + .read_packet = read_packet, };