00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "avformat.h"
00023 #include "rawdec.h"
00024
00025
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);
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);
00039 avio_skip(s->pb, 2);
00040 unk1 = avio_rl16(s->pb);
00041 unk2 = avio_rl16(s->pb);
00042 avio_skip(s->pb, 22);
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",
00070 .value = CODEC_ID_MJPEG,
00071 .priv_class = &ff_rawvideo_demuxer_class,
00072 };