TextDiff::TextDiff(const boost::filesystem::path &a, const boost::filesystem::path &b) { LinesReader aReader(a); LinesReader bReader(b); boost::optional<std::string> aLine; boost::optional<std::string> bLine; while (aLine = aReader.readLine(), bLine = bReader.readLine(), aLine || bLine) { if (aLine != bLine) { equal = false; return; } } equal = true; }
RefPtr<MediaDataDecoder::DecodePromise> WaveDataDecoder::ProcessDecode(MediaRawData* aSample) { size_t aLength = aSample->Size(); BufferReader aReader(aSample->Data(), aLength); int64_t aOffset = aSample->mOffset; int32_t frames = aLength * 8 / mInfo.mBitDepth / mInfo.mChannels; AlignedAudioBuffer buffer(frames * mInfo.mChannels); if (!buffer) { return DecodePromise::CreateAndReject( MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__), __func__); } for (int i = 0; i < frames; ++i) { for (unsigned int j = 0; j < mInfo.mChannels; ++j) { if (mInfo.mProfile == 6) { //ALAW Data auto res = aReader.ReadU8(); if (res.isErr()) { return DecodePromise::CreateAndReject( MediaResult(res.unwrapErr(), __func__), __func__); } int16_t decoded = DecodeALawSample(res.unwrap()); buffer[i * mInfo.mChannels + j] = IntegerToAudioSample<AudioDataValue>(decoded); } else if (mInfo.mProfile == 7) { //ULAW Data auto res = aReader.ReadU8(); if (res.isErr()) { return DecodePromise::CreateAndReject( MediaResult(res.unwrapErr(), __func__), __func__); } int16_t decoded = DecodeULawSample(res.unwrap()); buffer[i * mInfo.mChannels + j] = IntegerToAudioSample<AudioDataValue>(decoded); } else { //PCM Data if (mInfo.mBitDepth == 8) { auto res = aReader.ReadU8(); if (res.isErr()) { return DecodePromise::CreateAndReject( MediaResult(res.unwrapErr(), __func__), __func__); } buffer[i * mInfo.mChannels + j] = UInt8bitToAudioSample<AudioDataValue>(res.unwrap()); } else if (mInfo.mBitDepth == 16) { auto res = aReader.ReadLE16(); if (res.isErr()) { return DecodePromise::CreateAndReject( MediaResult(res.unwrapErr(), __func__), __func__); } buffer[i * mInfo.mChannels + j] = IntegerToAudioSample<AudioDataValue>(res.unwrap()); } else if (mInfo.mBitDepth == 24) { auto res = aReader.ReadLE24(); if (res.isErr()) { return DecodePromise::CreateAndReject( MediaResult(res.unwrapErr(), __func__), __func__); } buffer[i * mInfo.mChannels + j] = Int24bitToAudioSample<AudioDataValue>(res.unwrap()); } } } } auto duration = FramesToTimeUnit(frames, mInfo.mRate); return DecodePromise::CreateAndResolve( DecodedData{ new AudioData(aOffset, aSample->mTime, duration, frames, Move(buffer), mInfo.mChannels, mInfo.mRate) }, __func__); }