void ASFStream::parseStreamHeader() { ASFGUID guid = ASFGUID(*_stream); if (guid != s_asfAudioStream) throw Common::Exception("ASFStream::parseStreamHeader(): Found non-audio stream"); _stream->skip(16); // skip a guid _stream->readUint64LE(); // total size uint32 typeSpecificSize = _stream->readUint32LE(); _stream->readUint32LE(); _streamID = _stream->readUint16LE(); _stream->readUint32LE(); // Parse the wave header _compression = _stream->readUint16LE(); _channels = _stream->readUint16LE(); _sampleRate = _stream->readUint32LE(); _bitRate = _stream->readUint32LE() * 8; _blockAlign = _stream->readUint16LE(); _bitsPerCodedSample = (typeSpecificSize == 14) ? 8 : _stream->readUint16LE(); if (typeSpecificSize >= 18) { uint32 cbSize = _stream->readUint16LE(); cbSize = MIN<int>(cbSize, typeSpecificSize - 18); _extraData = _stream->readStream(cbSize); } _codec = createCodec(); }
AVIDecoder::AVIVideoTrack::AVIVideoTrack(int frameCount, const AVIStreamHeader &streamHeader, const BitmapInfoHeader &bitmapInfoHeader, byte *initialPalette) : _frameCount(frameCount), _vidsHeader(streamHeader), _bmInfo(bitmapInfoHeader), _initialPalette(initialPalette) { _videoCodec = createCodec(); _lastFrame = 0; _curFrame = -1; useInitialPalette(); }
AVIDecoder::AVIVideoTrack::AVIVideoTrack(int frameCount, const AVIStreamHeader &streamHeader, const BitmapInfoHeader &bitmapInfoHeader) : _frameCount(frameCount), _vidsHeader(streamHeader), _bmInfo(bitmapInfoHeader) { memset(_palette, 0, sizeof(_palette)); _videoCodec = createCodec(); _dirtyPalette = false; _lastFrame = 0; _curFrame = -1; }
bool AVIDecoder::AVIVideoTrack::rewind() { _curFrame = -1; useInitialPalette(); delete _videoCodec; _videoCodec = createCodec(); _lastFrame = 0; return true; }
bool AviDecoder::loadStream(Common::SeekableReadStream *stream) { close(); _fileStream = stream; _decodedHeader = false; // Read chunks until we have decoded the header while (!_decodedHeader) runHandle(_fileStream->readUint32BE()); uint32 nextTag = _fileStream->readUint32BE(); // Throw out any JUNK section if (nextTag == ID_JUNK) { runHandle(ID_JUNK); nextTag = _fileStream->readUint32BE(); } // Ignore the 'movi' LIST if (nextTag == ID_LIST) { _fileStream->readUint32BE(); // Skip size if (_fileStream->readUint32BE() != ID_MOVI) error ("Expected 'movi' LIST"); } else error ("Expected 'movi' LIST"); // Now, create the codec _videoCodec = createCodec(); // Initialize the video stuff too _audStream = createAudioStream(); if (_audStream) _mixer->playStream(_soundType, _audHandle, _audStream); debug (0, "Frames = %d, Dimensions = %d x %d", _header.totalFrames, _header.width, _header.height); debug (0, "Frame Rate = %d", _vidsHeader.rate / _vidsHeader.scale); if (_wvInfo.samplesPerSec != 0) debug (0, "Sound Rate = %d", _wvInfo.samplesPerSec); debug (0, "Video Codec = \'%s\'", tag2str(_vidsHeader.streamHandler)); if (!_videoCodec) return false; return true; }
void QuickTimeDecoder::init() { // Remove non-Video/Audio streams for (uint32 i = 0; i < _numStreams;) { if (_streams[i]->codec_type == CODEC_TYPE_MOV_OTHER) { delete _streams[i]; for (uint32 j = i + 1; j < _numStreams; j++) _streams[j - 1] = _streams[j]; _numStreams--; } else i++; } // Adjust time/duration for (uint32 i = 0; i < _numStreams; i++) { MOVStreamContext *sc = _streams[i]; if (!sc->time_rate) sc->time_rate = 1; if (!sc->time_scale) sc->time_scale = _timeScale; sc->duration /= sc->time_rate; if (sc->codec_type == CODEC_TYPE_VIDEO && _videoStreamIndex < 0) _videoStreamIndex = i; else if (sc->codec_type == CODEC_TYPE_AUDIO && _audioStreamIndex < 0) _audioStreamIndex = i; } // Initialize audio, if present if (_audioStreamIndex >= 0) { STSDEntry *entry = &_streams[_audioStreamIndex]->stsdEntries[0]; if (checkAudioCodecSupport(entry->codecTag)) { _audStream = Audio::makeQueuingAudioStream(entry->sampleRate, entry->channels == 2); _curAudioChunk = 0; // Make sure the bits per sample transfers to the sample size if (entry->codecTag == MKID_BE('raw ') || entry->codecTag == MKID_BE('twos')) _streams[_audioStreamIndex]->sample_size = (entry->bitsPerSample / 8) * entry->channels; startAudio(); } _audioStartOffset = Audio::Timestamp(0); } // Initialize video, if present if (_videoStreamIndex >= 0) { for (uint32 i = 0; i < _streams[_videoStreamIndex]->stsdEntryCount; i++) { STSDEntry *entry = &_streams[_videoStreamIndex]->stsdEntries[i]; entry->videoCodec = createCodec(entry->codecTag, entry->bitsPerSample & 0x1F); } if (getScaleFactorX() != 1 || getScaleFactorY() != 1) { // We have to initialize the scaled surface _scaledSurface = new Graphics::Surface(); _scaledSurface->create(getWidth(), getHeight(), getPixelFormat().bytesPerPixel); } } }