Libav 0.7.1
|
00001 /* 00002 * RAW Ingenient MJPEG demuxer 00003 * Copyright (c) 2005 Alex Beregszaszi 00004 * 00005 * This file is part of Libav. 00006 * 00007 * Libav is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * Libav is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with Libav; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 00022 #include "avformat.h" 00023 #include "rawdec.h" 00024 00025 // http://www.artificis.hu/files/texts/ingenient.txt 00026 static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt) 00027 { 00028 int ret, size, w, h, unk1, unk2; 00029 00030 if (avio_rl32(s->pb) != MKTAG('M', 'J', 'P', 'G')) 00031 return AVERROR(EIO); // FIXME 00032 00033 size = avio_rl32(s->pb); 00034 00035 w = avio_rl16(s->pb); 00036 h = avio_rl16(s->pb); 00037 00038 avio_skip(s->pb, 8); // zero + size (padded?) 00039 avio_skip(s->pb, 2); 00040 unk1 = avio_rl16(s->pb); 00041 unk2 = avio_rl16(s->pb); 00042 avio_skip(s->pb, 22); // ASCII timestamp 00043 00044 av_log(s, AV_LOG_DEBUG, "Ingenient packet: size=%d, width=%d, height=%d, unk1=%d unk2=%d\n", 00045 size, w, h, unk1, unk2); 00046 00047 if (av_new_packet(pkt, size) < 0) 00048 return AVERROR(ENOMEM); 00049 00050 pkt->pos = avio_tell(s->pb); 00051 pkt->stream_index = 0; 00052 ret = avio_read(s->pb, pkt->data, size); 00053 if (ret < 0) { 00054 av_free_packet(pkt); 00055 return ret; 00056 } 00057 pkt->size = ret; 00058 return ret; 00059 } 00060 00061 AVInputFormat ff_ingenient_demuxer = { 00062 "ingenient", 00063 NULL_IF_CONFIG_SMALL("raw Ingenient MJPEG"), 00064 sizeof(FFRawVideoDemuxerContext), 00065 NULL, 00066 ff_raw_video_read_header, 00067 ingenient_read_packet, 00068 .flags= AVFMT_GENERIC_INDEX, 00069 .extensions = "cgi", // FIXME 00070 .value = CODEC_ID_MJPEG, 00071 .priv_class = &ff_rawvideo_demuxer_class, 00072 };