iff.c 17.2 KB
Newer Older
Jai Menon's avatar
Jai Menon committed
1 2
/*
 * Copyright (c) 2008 Jaikrishnan Menon <realityman@gmx.net>
3
 * Copyright (c) 2010 Peter Ross <pross@xvid.org>
4
 * Copyright (c) 2010 Sebastian Vater <cdgs.basty@googlemail.com>
Jai Menon's avatar
Jai Menon committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * FFmpeg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

/**
24
 * @file
Diego Biurrun's avatar
Diego Biurrun committed
25
 * IFF file demuxer
Jai Menon's avatar
Jai Menon committed
26 27 28 29 30
 * by Jaikrishnan Menon
 * for more information on the .iff file format, visit:
 * http://wiki.multimedia.cx/index.php?title=IFF
 */

31
#include "libavutil/avassert.h"
Justin Ruggles's avatar
Justin Ruggles committed
32
#include "libavutil/channel_layout.h"
33
#include "libavutil/intreadwrite.h"
34
#include "libavutil/dict.h"
35
#include "libavcodec/bytestream.h"
Jai Menon's avatar
Jai Menon committed
36
#include "avformat.h"
37
#include "internal.h"
Jai Menon's avatar
Jai Menon committed
38 39

#define ID_8SVX       MKTAG('8','S','V','X')
Paul B Mahol's avatar
Paul B Mahol committed
40
#define ID_16SV       MKTAG('1','6','S','V')
Paul B Mahol's avatar
Paul B Mahol committed
41 42 43
#define ID_MAUD       MKTAG('M','A','U','D')
#define ID_MHDR       MKTAG('M','H','D','R')
#define ID_MDAT       MKTAG('M','D','A','T')
Jai Menon's avatar
Jai Menon committed
44 45 46 47
#define ID_VHDR       MKTAG('V','H','D','R')
#define ID_ATAK       MKTAG('A','T','A','K')
#define ID_RLSE       MKTAG('R','L','S','E')
#define ID_CHAN       MKTAG('C','H','A','N')
48 49 50
#define ID_PBM        MKTAG('P','B','M',' ')
#define ID_ILBM       MKTAG('I','L','B','M')
#define ID_BMHD       MKTAG('B','M','H','D')
51
#define ID_DGBL       MKTAG('D','G','B','L')
52
#define ID_CAMG       MKTAG('C','A','M','G')
53
#define ID_CMAP       MKTAG('C','M','A','P')
54
#define ID_ACBM       MKTAG('A','C','B','M')
55
#define ID_DEEP       MKTAG('D','E','E','P')
56 57
#define ID_RGB8       MKTAG('R','G','B','8')
#define ID_RGBN       MKTAG('R','G','B','N')
Jai Menon's avatar
Jai Menon committed
58 59 60 61 62 63 64 65 66 67

#define ID_FORM       MKTAG('F','O','R','M')
#define ID_ANNO       MKTAG('A','N','N','O')
#define ID_AUTH       MKTAG('A','U','T','H')
#define ID_CHRS       MKTAG('C','H','R','S')
#define ID_COPYRIGHT  MKTAG('(','c',')',' ')
#define ID_CSET       MKTAG('C','S','E','T')
#define ID_FVER       MKTAG('F','V','E','R')
#define ID_NAME       MKTAG('N','A','M','E')
#define ID_TEXT       MKTAG('T','E','X','T')
68
#define ID_ABIT       MKTAG('A','B','I','T')
Jai Menon's avatar
Jai Menon committed
69
#define ID_BODY       MKTAG('B','O','D','Y')
70 71
#define ID_DBOD       MKTAG('D','B','O','D')
#define ID_DPEL       MKTAG('D','P','E','L')
72
#define ID_DLOC       MKTAG('D','L','O','C')
73
#define ID_TVDC       MKTAG('T','V','D','C')
Jai Menon's avatar
Jai Menon committed
74 75 76 77 78

#define LEFT    2
#define RIGHT   4
#define STEREO  6

79 80 81 82 83 84 85 86
/**
 * This number of bytes if added at the beginning of each AVPacket
 * which contain additional information about video properties
 * which has to be shared between demuxer and decoder.
 * This number may change between frames, e.g. the demuxer might
 * set it to smallest possible size of 2 to indicate that there's
 * no extradata changing in this frame.
 */
87
#define IFF_EXTRA_VIDEO_SIZE 41
88

89 90 91 92 93 94
typedef enum {
    COMP_NONE,
    COMP_FIB,
    COMP_EXP
} svx8_compression_type;

Jai Menon's avatar
Jai Menon committed
95
typedef struct {
96 97
    int64_t  body_pos;
    int64_t  body_end;
Jai Menon's avatar
Jai Menon committed
98
    uint32_t  body_size;
99
    svx8_compression_type   svx8_compression;
Paul B Mahol's avatar
Paul B Mahol committed
100 101
    unsigned  maud_bits;
    unsigned  maud_compression;
102
    unsigned  bitmap_compression;  ///< delta compression method used
103 104 105 106 107
    unsigned  bpp;          ///< bits per plane to decode (differs from bits_per_coded_sample if HAM)
    unsigned  ham;          ///< 0 if non-HAM or number of hold bits (6 for bpp > 6, 4 otherwise)
    unsigned  flags;        ///< 1 for EHB, 0 is no extra half darkening
    unsigned  transparency; ///< transparency color index in palette
    unsigned  masking;      ///< masking method used
108
    uint8_t   tvdc[32];     ///< TVDC lookup table
Jai Menon's avatar
Jai Menon committed
109 110
} IffDemuxContext;

Sebastian Vater's avatar
Sebastian Vater committed
111 112 113 114 115 116 117 118 119 120
/* Metadata string read */
static int get_metadata(AVFormatContext *s,
                        const char *const tag,
                        const unsigned data_size)
{
    uint8_t *buf = ((data_size + 1) == 0) ? NULL : av_malloc(data_size + 1);

    if (!buf)
        return AVERROR(ENOMEM);

121
    if (avio_read(s->pb, buf, data_size) < 0) {
Sebastian Vater's avatar
Sebastian Vater committed
122 123 124 125
        av_free(buf);
        return AVERROR(EIO);
    }
    buf[data_size] = 0;
126
    av_dict_set(&s->metadata, tag, buf, AV_DICT_DONT_STRDUP_VAL);
Sebastian Vater's avatar
Sebastian Vater committed
127 128 129
    return 0;
}

Jai Menon's avatar
Jai Menon committed
130 131 132 133
static int iff_probe(AVProbeData *p)
{
    const uint8_t *d = p->buf;

134 135
    if (  AV_RL32(d)   == ID_FORM &&
         (AV_RL32(d+8) == ID_8SVX ||
Paul B Mahol's avatar
Paul B Mahol committed
136
          AV_RL32(d+8) == ID_16SV ||
Paul B Mahol's avatar
Paul B Mahol committed
137
          AV_RL32(d+8) == ID_MAUD ||
138 139 140
          AV_RL32(d+8) == ID_PBM  ||
          AV_RL32(d+8) == ID_ACBM ||
          AV_RL32(d+8) == ID_DEEP ||
141 142 143
          AV_RL32(d+8) == ID_ILBM ||
          AV_RL32(d+8) == ID_RGB8 ||
          AV_RL32(d+8) == ID_RGBN) )
Jai Menon's avatar
Jai Menon committed
144 145 146 147
        return AVPROBE_SCORE_MAX;
    return 0;
}

148 149
static const uint8_t deep_rgb24[] = {0, 0, 0, 3, 0, 1, 0, 8, 0, 2, 0, 8, 0, 3, 0, 8};
static const uint8_t deep_rgba[]  = {0, 0, 0, 4, 0, 1, 0, 8, 0, 2, 0, 8, 0, 3, 0, 8};
150 151 152
static const uint8_t deep_bgra[]  = {0, 0, 0, 4, 0, 3, 0, 8, 0, 2, 0, 8, 0, 1, 0, 8};
static const uint8_t deep_argb[]  = {0, 0, 0, 4, 0,17, 0, 8, 0, 1, 0, 8, 0, 2, 0, 8};
static const uint8_t deep_abgr[]  = {0, 0, 0, 4, 0,17, 0, 8, 0, 3, 0, 8, 0, 2, 0, 8};
153

154
static int iff_read_header(AVFormatContext *s)
Jai Menon's avatar
Jai Menon committed
155 156
{
    IffDemuxContext *iff = s->priv_data;
157
    AVIOContext *pb = s->pb;
Jai Menon's avatar
Jai Menon committed
158
    AVStream *st;
159
    uint8_t *buf;
Jai Menon's avatar
Jai Menon committed
160
    uint32_t chunk_id, data_size;
Paul B Mahol's avatar
Paul B Mahol committed
161
    uint32_t screenmode = 0, num, den;
162 163
    unsigned transparency = 0;
    unsigned masking = 0; // no mask
164 165
    uint8_t fmt[16];
    int fmt_size;
Jai Menon's avatar
Jai Menon committed
166

167
    st = avformat_new_stream(s, NULL);
Jai Menon's avatar
Jai Menon committed
168
    if (!st)
169
        return AVERROR(ENOMEM);
Jai Menon's avatar
Jai Menon committed
170 171

    st->codec->channels = 1;
Justin Ruggles's avatar
Justin Ruggles committed
172
    st->codec->channel_layout = AV_CH_LAYOUT_MONO;
173
    avio_skip(pb, 8);
174
    // codec_tag used by ByteRun1 decoder to distinguish progressive (PBM) and interlaced (ILBM) content
175
    st->codec->codec_tag = avio_rl32(pb);
176 177 178 179
    iff->bitmap_compression = -1;
    iff->svx8_compression = -1;
    iff->maud_bits = -1;
    iff->maud_compression = -1;
Jai Menon's avatar
Jai Menon committed
180

181 182
    while(!url_feof(pb)) {
        uint64_t orig_pos;
Sebastian Vater's avatar
Sebastian Vater committed
183 184
        int res;
        const char *metadata_tag = NULL;
185 186
        chunk_id = avio_rl32(pb);
        data_size = avio_rb32(pb);
187
        orig_pos = avio_tell(pb);
Jai Menon's avatar
Jai Menon committed
188 189 190

        switch(chunk_id) {
        case ID_VHDR:
191
            st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
192 193 194

            if (data_size < 14)
                return AVERROR_INVALIDDATA;
195
            avio_skip(pb, 12);
196
            st->codec->sample_rate = avio_rb16(pb);
197
            if (data_size >= 16) {
198
                avio_skip(pb, 1);
199
                iff->svx8_compression = avio_r8(pb);
200
            }
Jai Menon's avatar
Jai Menon committed
201 202
            break;

Paul B Mahol's avatar
Paul B Mahol committed
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
        case ID_MHDR:
            st->codec->codec_type = AVMEDIA_TYPE_AUDIO;

            if (data_size < 32)
                return AVERROR_INVALIDDATA;
            avio_skip(pb, 4);
            iff->maud_bits = avio_rb16(pb);
            avio_skip(pb, 2);
            num = avio_rb32(pb);
            den = avio_rb16(pb);
            if (!den)
                return AVERROR_INVALIDDATA;
            avio_skip(pb, 2);
            st->codec->sample_rate = num / den;
            st->codec->channels = avio_rb16(pb);
            iff->maud_compression = avio_rb16(pb);
            if (st->codec->channels == 1)
                st->codec->channel_layout = AV_CH_LAYOUT_MONO;
            else if (st->codec->channels == 2)
                st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
            break;

225
        case ID_ABIT:
Jai Menon's avatar
Jai Menon committed
226
        case ID_BODY:
227
        case ID_DBOD:
Paul B Mahol's avatar
Paul B Mahol committed
228
        case ID_MDAT:
229
            iff->body_pos = avio_tell(pb);
230
            iff->body_end = iff->body_pos + data_size;
Jai Menon's avatar
Jai Menon committed
231 232 233 234
            iff->body_size = data_size;
            break;

        case ID_CHAN:
235 236
            if (data_size < 4)
                return AVERROR_INVALIDDATA;
Justin Ruggles's avatar
Justin Ruggles committed
237 238 239 240 241 242 243
            if (avio_rb32(pb) < 6) {
                st->codec->channels       = 1;
                st->codec->channel_layout = AV_CH_LAYOUT_MONO;
            } else {
                st->codec->channels       = 2;
                st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
            }
Jai Menon's avatar
Jai Menon committed
244 245
            break;

246 247 248 249 250 251
        case ID_CAMG:
            if (data_size < 4)
                return AVERROR_INVALIDDATA;
            screenmode                = avio_rb32(pb);
            break;

252
        case ID_CMAP:
253 254
            st->codec->extradata_size = data_size + IFF_EXTRA_VIDEO_SIZE;
            st->codec->extradata      = av_malloc(data_size + IFF_EXTRA_VIDEO_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
255 256
            if (!st->codec->extradata)
                return AVERROR(ENOMEM);
257
            if (avio_read(pb, st->codec->extradata + IFF_EXTRA_VIDEO_SIZE, data_size) < 0)
258 259 260 261
                return AVERROR(EIO);
            break;

        case ID_BMHD:
262
            st->codec->codec_type            = AVMEDIA_TYPE_VIDEO;
263 264
            if (data_size <= 8)
                return AVERROR_INVALIDDATA;
265 266
            st->codec->width                 = avio_rb16(pb);
            st->codec->height                = avio_rb16(pb);
267
            avio_skip(pb, 4); // x, y offset
268
            st->codec->bits_per_coded_sample = avio_r8(pb);
269 270 271
            if (data_size >= 10)
                masking                      = avio_r8(pb);
            if (data_size >= 11)
272
                iff->bitmap_compression      = avio_r8(pb);
273 274 275
            if (data_size >= 14) {
                avio_skip(pb, 1); // padding
                transparency                 = avio_rb16(pb);
276 277
            }
            if (data_size >= 16) {
278 279
                st->sample_aspect_ratio.num  = avio_r8(pb);
                st->sample_aspect_ratio.den  = avio_r8(pb);
280
            }
281 282
            break;

283 284 285 286 287 288
        case ID_DPEL:
            if (data_size < 4 || (data_size & 3))
                return AVERROR_INVALIDDATA;
            if ((fmt_size = avio_read(pb, fmt, sizeof(fmt))) < 0)
                return fmt_size;
            if (fmt_size == sizeof(deep_rgb24) && !memcmp(fmt, deep_rgb24, sizeof(deep_rgb24)))
289
                st->codec->pix_fmt = AV_PIX_FMT_RGB24;
290
            else if (fmt_size == sizeof(deep_rgba) && !memcmp(fmt, deep_rgba, sizeof(deep_rgba)))
291
                st->codec->pix_fmt = AV_PIX_FMT_RGBA;
292 293 294 295 296 297
            else if (fmt_size == sizeof(deep_bgra) && !memcmp(fmt, deep_bgra, sizeof(deep_bgra)))
                st->codec->pix_fmt = AV_PIX_FMT_BGRA;
            else if (fmt_size == sizeof(deep_argb) && !memcmp(fmt, deep_argb, sizeof(deep_argb)))
                st->codec->pix_fmt = AV_PIX_FMT_ARGB;
            else if (fmt_size == sizeof(deep_abgr) && !memcmp(fmt, deep_abgr, sizeof(deep_abgr)))
                st->codec->pix_fmt = AV_PIX_FMT_ABGR;
298
            else {
299
                av_log_ask_for_sample(s, "unsupported color format\n");
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
                return AVERROR_PATCHWELCOME;
            }
            break;

        case ID_DGBL:
            st->codec->codec_type            = AVMEDIA_TYPE_VIDEO;
            if (data_size < 8)
                return AVERROR_INVALIDDATA;
            st->codec->width                 = avio_rb16(pb);
            st->codec->height                = avio_rb16(pb);
            iff->bitmap_compression          = avio_rb16(pb);
            st->sample_aspect_ratio.num      = avio_r8(pb);
            st->sample_aspect_ratio.den      = avio_r8(pb);
            st->codec->bits_per_coded_sample = 24;
            break;

316 317 318 319 320 321 322
        case ID_DLOC:
            if (data_size < 4)
                return AVERROR_INVALIDDATA;
            st->codec->width  = avio_rb16(pb);
            st->codec->height = avio_rb16(pb);
            break;

323 324 325 326 327 328 329 330
        case ID_TVDC:
            if (data_size < sizeof(iff->tvdc))
                return AVERROR_INVALIDDATA;
            res = avio_read(pb, iff->tvdc, sizeof(iff->tvdc));
            if (res < 0)
                return res;
            break;

331
        case ID_ANNO:
332 333 334 335
        case ID_TEXT:      metadata_tag = "comment";   break;
        case ID_AUTH:      metadata_tag = "artist";    break;
        case ID_COPYRIGHT: metadata_tag = "copyright"; break;
        case ID_NAME:      metadata_tag = "title";     break;
Jai Menon's avatar
Jai Menon committed
336
        }
337

Sebastian Vater's avatar
Sebastian Vater committed
338 339
        if (metadata_tag) {
            if ((res = get_metadata(s, metadata_tag, data_size)) < 0) {
340
                av_log(s, AV_LOG_ERROR, "cannot allocate metadata tag %s!\n", metadata_tag);
Sebastian Vater's avatar
Sebastian Vater committed
341 342 343
                return res;
            }
        }
344
        avio_skip(pb, data_size - (avio_tell(pb) - orig_pos) + (data_size & 1));
Jai Menon's avatar
Jai Menon committed
345 346
    }

347
    avio_seek(pb, iff->body_pos, SEEK_SET);
348

349
    switch(st->codec->codec_type) {
350
    case AVMEDIA_TYPE_AUDIO:
351
        avpriv_set_pts_info(st, 32, 1, st->codec->sample_rate);
Jai Menon's avatar
Jai Menon committed
352

Paul B Mahol's avatar
Paul B Mahol committed
353 354
        if (st->codec->codec_tag == ID_16SV)
            st->codec->codec_id = AV_CODEC_ID_PCM_S16BE_PLANAR;
Paul B Mahol's avatar
Paul B Mahol committed
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
        else if (st->codec->codec_tag == ID_MAUD) {
            if (iff->maud_bits == 8 && !iff->maud_compression) {
                st->codec->codec_id = AV_CODEC_ID_PCM_U8;
            } else if (iff->maud_bits == 16 && !iff->maud_compression) {
                st->codec->codec_id = AV_CODEC_ID_PCM_S16BE;
            } else if (iff->maud_bits ==  8 && iff->maud_compression == 2) {
                st->codec->codec_id = AV_CODEC_ID_PCM_ALAW;
            } else if (iff->maud_bits ==  8 && iff->maud_compression == 3) {
                st->codec->codec_id = AV_CODEC_ID_PCM_MULAW;
            } else {
                av_log_ask_for_sample(s, "unsupported compression %d and bit depth %d\n", iff->maud_compression, iff->maud_bits);
                return AVERROR_PATCHWELCOME;
            }

            st->codec->bits_per_coded_sample =
                av_get_bits_per_sample(st->codec->codec_id);

            st->codec->block_align =
                st->codec->bits_per_coded_sample * st->codec->channels / 8;
        } else {
375
        switch (iff->svx8_compression) {
376
        case COMP_NONE:
377
            st->codec->codec_id = AV_CODEC_ID_PCM_S8_PLANAR;
378 379
            break;
        case COMP_FIB:
380
            st->codec->codec_id = AV_CODEC_ID_8SVX_FIB;
381 382
            break;
        case COMP_EXP:
383
            st->codec->codec_id = AV_CODEC_ID_8SVX_EXP;
384 385
            break;
        default:
386 387
            av_log(s, AV_LOG_ERROR,
                   "Unknown SVX8 compression method '%d'\n", iff->svx8_compression);
388 389
            return -1;
        }
Paul B Mahol's avatar
Paul B Mahol committed
390
        }
Jai Menon's avatar
Jai Menon committed
391

Paul B Mahol's avatar
Paul B Mahol committed
392
        st->codec->bits_per_coded_sample = av_get_bits_per_sample(st->codec->codec_id);
393 394 395
        st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * st->codec->bits_per_coded_sample;
        st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample;
        break;
396

397
    case AVMEDIA_TYPE_VIDEO:
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
        iff->bpp          = st->codec->bits_per_coded_sample;
        if ((screenmode & 0x800 /* Hold And Modify */) && iff->bpp <= 8) {
            iff->ham      = iff->bpp > 6 ? 6 : 4;
            st->codec->bits_per_coded_sample = 24;
        }
        iff->flags        = (screenmode & 0x80 /* Extra HalfBrite */) && iff->bpp <= 8;
        iff->masking      = masking;
        iff->transparency = transparency;

        if (!st->codec->extradata) {
            st->codec->extradata_size = IFF_EXTRA_VIDEO_SIZE;
            st->codec->extradata      = av_malloc(IFF_EXTRA_VIDEO_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
            if (!st->codec->extradata)
                return AVERROR(ENOMEM);
        }
        buf = st->codec->extradata;
        bytestream_put_be16(&buf, IFF_EXTRA_VIDEO_SIZE);
415
        bytestream_put_byte(&buf, iff->bitmap_compression);
416 417 418 419 420
        bytestream_put_byte(&buf, iff->bpp);
        bytestream_put_byte(&buf, iff->ham);
        bytestream_put_byte(&buf, iff->flags);
        bytestream_put_be16(&buf, iff->transparency);
        bytestream_put_byte(&buf, iff->masking);
421
        bytestream_put_buffer(&buf, iff->tvdc, sizeof(iff->tvdc));
422
        st->codec->codec_id = AV_CODEC_ID_IFF_ILBM;
423 424 425 426
        break;
    default:
        return -1;
    }
Jai Menon's avatar
Jai Menon committed
427 428 429 430 431 432 433 434

    return 0;
}

static int iff_read_packet(AVFormatContext *s,
                           AVPacket *pkt)
{
    IffDemuxContext *iff = s->priv_data;
435
    AVIOContext *pb = s->pb;
436
    AVStream *st = s->streams[0];
Jai Menon's avatar
Jai Menon committed
437
    int ret;
438
    int64_t pos = avio_tell(pb);
Jai Menon's avatar
Jai Menon committed
439

440
    if (pos >= iff->body_end)
441
        return AVERROR_EOF;
Jai Menon's avatar
Jai Menon committed
442

443
    if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
Paul B Mahol's avatar
Paul B Mahol committed
444
        if (st->codec->codec_tag == ID_MAUD) {
445
            ret = av_get_packet(pb, pkt, FFMIN(iff->body_end - pos, 1024 * st->codec->block_align));
Paul B Mahol's avatar
Paul B Mahol committed
446 447 448
        } else {
            ret = av_get_packet(pb, pkt, iff->body_size);
        }
449
    } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
450 451 452 453 454 455 456 457 458
        uint8_t *buf;

        if (av_new_packet(pkt, iff->body_size + 2) < 0) {
            return AVERROR(ENOMEM);
        }

        buf = pkt->data;
        bytestream_put_be16(&buf, 2);
        ret = avio_read(pb, buf, iff->body_size);
459
    } else {
460
        av_assert0(0);
Jai Menon's avatar
Jai Menon committed
461
    }
Jai Menon's avatar
Jai Menon committed
462

463
    if (pos == iff->body_pos)
464
        pkt->flags |= AV_PKT_FLAG_KEY;
Paul B Mahol's avatar
Paul B Mahol committed
465 466
    if (ret < 0)
        return ret;
Jai Menon's avatar
Jai Menon committed
467 468 469 470
    pkt->stream_index = 0;
    return ret;
}

471
AVInputFormat ff_iff_demuxer = {
472
    .name           = "iff",
473
    .long_name      = NULL_IF_CONFIG_SMALL("IFF (Interchange File Format)"),
474 475 476 477
    .priv_data_size = sizeof(IffDemuxContext),
    .read_probe     = iff_probe,
    .read_header    = iff_read_header,
    .read_packet    = iff_read_packet,
478
    .flags          = AVFMT_GENERIC_INDEX,
Jai Menon's avatar
Jai Menon committed
479
};