Revision 84c63c01

View differences:

libavformat/raw.c
1 1
/* 
2 2
 * RAW encoder and decoder
3 3
 * Copyright (c) 2001 Fabrice Bellard.
4
 * Copyright (c) 2005 Alex Beregszaszi
4 5
 *
5 6
 * This library is free software; you can redistribute it and/or
6 7
 * modify it under the terms of the GNU Lesser General Public
......
120 121
    return ret;
121 122
}
122 123

  
124
// http://www.artificis.hu/files/texts/ingenient.txt
125
static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
126
{
127
    int ret, size, w, h, unk1, unk2;
128
    
129
    if (get_le32(&s->pb) != MKTAG('M', 'J', 'P', 'G'))
130
	return AVERROR_IO; // FIXME
131

  
132
    size = get_le32(&s->pb);
133
    
134
    w = get_le16(&s->pb);
135
    h = get_le16(&s->pb);
136
    
137
    url_fskip(&s->pb, 8); // zero + size (padded?)
138
    url_fskip(&s->pb, 2);
139
    unk1 = get_le16(&s->pb);
140
    unk2 = get_le16(&s->pb);
141
    url_fskip(&s->pb, 22); // ascii timestamp
142
    
143
    av_log(NULL, AV_LOG_DEBUG, "Ingenient packet: size=%d, width=%d, height=%d, unk1=%d unk2=%d\n",
144
	size, w, h, unk1, unk2);
145

  
146
    if (av_new_packet(pkt, size) < 0)
147
        return AVERROR_IO;
148

  
149
    pkt->pos = url_ftell(&s->pb);
150
    pkt->stream_index = 0;
151
    ret = get_buffer(&s->pb, pkt->data, size);
152
    if (ret <= 0) {
153
        av_free_packet(pkt);
154
        return AVERROR_IO;
155
    }
156
    pkt->size = ret;
157
    return ret;
158
}
159

  
123 160
static int raw_read_close(AVFormatContext *s)
124 161
{
125 162
    return 0;
......
309 346

  
310 347
AVInputFormat shorten_iformat = {
311 348
    "shn",
312
    "raw shn",
349
    "raw shorten",
313 350
    0,
314 351
    NULL,
315 352
    shorten_read_header,
......
516 553
    .value = CODEC_ID_MJPEG,
517 554
};
518 555

  
556
AVInputFormat ingenient_iformat = {
557
    "ingenient",
558
    "Ingenient MJPEG",
559
    0,
560
    NULL,
561
    video_read_header,
562
    ingenient_read_packet,
563
    raw_read_close,
564
    .extensions = "cgi", // FIXME
565
    .value = CODEC_ID_MJPEG,
566
};
567

  
519 568
#ifdef CONFIG_MUXERS
520 569
AVOutputFormat mjpeg_oformat = {
521 570
    "mjpeg",
......
714 763

  
715 764
    av_register_input_format(&mjpeg_iformat);
716 765
    av_register_output_format(&mjpeg_oformat);
766
    
767
    av_register_input_format(&ingenient_iformat);
717 768

  
718 769
    av_register_input_format(&pcm_s16le_iformat);
719 770
    av_register_output_format(&pcm_s16le_oformat);

Also available in: Unified diff