2
2
* Interplay MVE File Demuxer
3
3
* Copyright (c) 2003 The ffmpeg Project
5
* This library is free software; you can redistribute it and/or
5
* This file is part of FFmpeg.
7
* FFmpeg is free software; you can redistribute it and/or
6
8
* modify it under the terms of the GNU Lesser General Public
7
9
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
10
* version 2.1 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
12
* FFmpeg is distributed in the hope that it will be useful,
11
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
15
* Lesser General Public License for more details.
15
17
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
* License along with FFmpeg; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
330
325
chunk_type = CHUNK_BAD;
333
s->fps = 1000000 / (LE_32(&scratch[0]) * LE_16(&scratch[4]));
334
s->fps++; /* above calculation usually yields 14.9; we need 15 */
328
s->fps = 1000000.0 / (AV_RL32(&scratch[0]) * AV_RL16(&scratch[4]));
335
329
s->frame_pts_inc = 90000 / s->fps;
336
debug_ipmovie("%d frames/second (timer div = %d, subdiv = %d)\n",
337
s->fps, LE_32(&scratch[0]), LE_16(&scratch[4]));
330
debug_ipmovie(" %.2f frames/second (timer div = %d, subdiv = %d)\n",
331
s->fps, AV_RL32(&scratch[0]), AV_RL16(&scratch[4]));
340
334
case OPCODE_INIT_AUDIO_BUFFERS:
540
537
if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_VIDEO)
541
538
return AVERROR_INVALIDDATA;
543
/* process the next chunk which should be CHUNK_INIT_AUDIO */
544
if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_AUDIO)
540
/* peek ahead to the next chunk-- if it is an init audio chunk, process
541
* it; if it is the first video chunk, this is a silent file */
542
if (get_buffer(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
545
chunk_type = AV_RL16(&chunk_preamble[2]);
546
url_fseek(pb, -CHUNK_PREAMBLE_SIZE, SEEK_CUR);
548
if (chunk_type == CHUNK_VIDEO)
549
ipmovie->audio_type = 0; /* no audio */
550
else if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_AUDIO)
545
551
return AVERROR_INVALIDDATA;
547
/* set the pts reference (1 pts = 1/90000) */
551
553
/* initialize the stream decoders */
552
554
st = av_new_stream(s, 0);
554
556
return AVERROR_NOMEM;
557
av_set_pts_info(st, 33, 1, 90000);
555
558
ipmovie->video_stream_index = st->index;
556
st->codec.codec_type = CODEC_TYPE_VIDEO;
557
st->codec.codec_id = CODEC_ID_INTERPLAY_VIDEO;
558
st->codec.codec_tag = 0; /* no fourcc */
559
st->codec.width = ipmovie->video_width;
560
st->codec.height = ipmovie->video_height;
559
st->codec->codec_type = CODEC_TYPE_VIDEO;
560
st->codec->codec_id = CODEC_ID_INTERPLAY_VIDEO;
561
st->codec->codec_tag = 0; /* no fourcc */
562
st->codec->width = ipmovie->video_width;
563
st->codec->height = ipmovie->video_height;
562
565
/* palette considerations */
563
st->codec.extradata_size = sizeof(AVPaletteControl);
564
st->codec.extradata = &ipmovie->palette_control;
566
st->codec->palctrl = &ipmovie->palette_control;
566
st = av_new_stream(s, 0);
568
return AVERROR_NOMEM;
569
ipmovie->audio_stream_index = st->index;
570
st->codec.codec_type = CODEC_TYPE_AUDIO;
571
st->codec.codec_id = ipmovie->audio_type;
572
st->codec.codec_tag = 0; /* no tag */
573
st->codec.channels = ipmovie->audio_channels;
574
st->codec.sample_rate = ipmovie->audio_sample_rate;
575
st->codec.bits_per_sample = ipmovie->audio_bits;
576
st->codec.bit_rate = st->codec.channels * st->codec.sample_rate *
577
st->codec.bits_per_sample;
578
if (st->codec.codec_id == CODEC_ID_INTERPLAY_DPCM)
579
st->codec.bit_rate /= 2;
580
st->codec.block_align = st->codec.channels * st->codec.bits_per_sample;
568
if (ipmovie->audio_type) {
569
st = av_new_stream(s, 0);
571
return AVERROR_NOMEM;
572
av_set_pts_info(st, 33, 1, 90000);
573
ipmovie->audio_stream_index = st->index;
574
st->codec->codec_type = CODEC_TYPE_AUDIO;
575
st->codec->codec_id = ipmovie->audio_type;
576
st->codec->codec_tag = 0; /* no tag */
577
st->codec->channels = ipmovie->audio_channels;
578
st->codec->sample_rate = ipmovie->audio_sample_rate;
579
st->codec->bits_per_sample = ipmovie->audio_bits;
580
st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
581
st->codec->bits_per_sample;
582
if (st->codec->codec_id == CODEC_ID_INTERPLAY_DPCM)
583
st->codec->bit_rate /= 2;
584
st->codec->block_align = st->codec->channels * st->codec->bits_per_sample;