Libav 0.7.1
|
00001 /* 00002 * Copyright (c) 2009 Michael Niedermayer 00003 * 00004 * This file is part of Libav. 00005 * 00006 * Libav is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * Libav is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with Libav; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 00021 #include "avformat.h" 00022 00023 00024 static int probe(AVProbeData *p) 00025 { 00026 // the single file i have starts with that, i dont know if others do too 00027 if( p->buf[0] == 1 00028 && p->buf[1] == 1 00029 && p->buf[2] == 3 00030 && p->buf[3] == 0xB8 00031 && p->buf[4] == 0x80 00032 && p->buf[5] == 0x60 00033 ) 00034 return AVPROBE_SCORE_MAX-2; 00035 00036 return 0; 00037 } 00038 00039 static int read_header(AVFormatContext *s, AVFormatParameters *ap) 00040 { 00041 AVStream *st; 00042 00043 st = av_new_stream(s, 0); 00044 if (!st) 00045 return AVERROR(ENOMEM); 00046 00047 st->codec->codec_type = AVMEDIA_TYPE_VIDEO; 00048 st->codec->codec_id = CODEC_ID_MPEG4; 00049 st->need_parsing = AVSTREAM_PARSE_FULL; 00050 av_set_pts_info(st, 64, 1, 90000); 00051 00052 return 0; 00053 00054 } 00055 00056 static int read_packet(AVFormatContext *s, AVPacket *pkt) 00057 { 00058 int ret, size, pts, type; 00059 retry: 00060 type= avio_rb16(s->pb); // 257 or 258 00061 size= avio_rb16(s->pb); 00062 00063 avio_rb16(s->pb); //some flags, 0x80 indicates end of frame 00064 avio_rb16(s->pb); //packet number 00065 pts=avio_rb32(s->pb); 00066 avio_rb32(s->pb); //6A 13 E3 88 00067 00068 size -= 12; 00069 if(size<1) 00070 return -1; 00071 00072 if(type==258){ 00073 avio_skip(s->pb, size); 00074 goto retry; 00075 } 00076 00077 ret= av_get_packet(s->pb, pkt, size); 00078 00079 pkt->pts= pts; 00080 pkt->pos-=16; 00081 00082 pkt->stream_index = 0; 00083 00084 return ret; 00085 } 00086 00087 AVInputFormat ff_iv8_demuxer = { 00088 "iv8", 00089 NULL_IF_CONFIG_SMALL("A format generated by IndigoVision 8000 video server"), 00090 0, 00091 probe, 00092 read_header, 00093 read_packet, 00094 .flags= AVFMT_GENERIC_INDEX, 00095 .value = CODEC_ID_MPEG4, 00096 };