* MTV demuxer.
*/
+#include "libavutil/bswap.h"
#include "avformat.h"
-#include "bswap.h"
#define MTV_ASUBCHUNK_DATA_SIZE 500
#define MTV_HEADER_SIZE 512
static int mtv_probe(AVProbeData *p)
{
- if(p->buf_size < 3)
- return 0;
-
/* Magic is 'AMV' */
if(*(p->buf) != 'A' || *(p->buf+1) != 'M' || *(p->buf+2) != 'V')
static int mtv_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
MTVDemuxContext *mtv = s->priv_data;
- ByteIOContext *pb = &s->pb;
+ ByteIOContext *pb = s->pb;
AVStream *st;
/* FIXME Add sanity check here */
- /* first packet is allways audio*/
+ /* first packet is always audio*/
mtv->audio_packet_count = 1;
st = av_new_stream(s, VIDEO_SID);
if(!st)
- return AVERROR_NOMEM;
+ return AVERROR(ENOMEM);
av_set_pts_info(st, 64, 1, mtv->video_fps);
st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_RAWVIDEO;
+ st->codec->codec_tag = MKTAG('R', 'G', 'B', mtv->img_bpp);
st->codec->width = mtv->img_width;
st->codec->height = mtv->img_height;
st->codec->bits_per_sample = mtv->img_bpp;
st = av_new_stream(s, AUDIO_SID);
if(!st)
- return AVERROR_NOMEM;
+ return AVERROR(ENOMEM);
av_set_pts_info(st, 64, 1, AUDIO_SAMPLING_RATE);
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_MP3;
st->codec->bit_rate = mtv->audio_br;
- st->need_parsing=1;
+ st->need_parsing = AVSTREAM_PARSE_FULL;
/* Jump over header */
if(url_fseek(pb, MTV_HEADER_SIZE, SEEK_SET) != MTV_HEADER_SIZE)
- return AVERROR_IO;
+ return AVERROR(EIO);
- return(0);
+ return 0;
}
static int mtv_read_packet(AVFormatContext *s, AVPacket *pkt)
{
MTVDemuxContext *mtv = s->priv_data;
- ByteIOContext *pb = &s->pb;
+ ByteIOContext *pb = s->pb;
int ret;
#ifndef WORDS_BIGENDIAN
int i;
ret = av_get_packet(pb, pkt, MTV_ASUBCHUNK_DATA_SIZE);
if(ret != MTV_ASUBCHUNK_DATA_SIZE)
- return AVERROR_IO;
+ return AVERROR(EIO);
mtv->audio_packet_count++;
pkt->stream_index = AUDIO_SID;
{
ret = av_get_packet(pb, pkt, mtv->img_segment_size);
if(ret != mtv->img_segment_size)
- return AVERROR_IO;
+ return AVERROR(EIO);
#ifndef WORDS_BIGENDIAN
pkt->stream_index = VIDEO_SID;
}
- return(ret);
+ return ret;
}
AVInputFormat mtv_demuxer = {
"MTV",
- "MTV format",
+ NULL_IF_CONFIG_SMALL("MTV format"),
sizeof(MTVDemuxContext),
mtv_probe,
mtv_read_header,