Bug 1524890 - P6. Remove mFrames member from MediaData. r=bryce

The number of frames is only meaningful with audio as a VideoData always contain a single frame.
So we only have this member in AudioData, which will simplify the logic in a future commit where the number of frames present depends on the trimming filter applied.

Differential Revision: https://phabricator.services.mozilla.com/D20164

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jean-Yves Avenard 2019-02-22 09:18:33 +00:00
Родитель 964cc95e13
Коммит dd3c534de5
10 изменённых файлов: 40 добавлений и 47 удалений

Просмотреть файл

@ -127,7 +127,7 @@ VideoData::VideoData(int64_t aOffset, const TimeUnit& aTime,
const TimeUnit& aDuration, bool aKeyframe,
const TimeUnit& aTimecode, IntSize aDisplay,
layers::ImageContainer::FrameID aFrameID)
: MediaData(Type::VIDEO_DATA, aOffset, aTime, aDuration, 1),
: MediaData(Type::VIDEO_DATA, aOffset, aTime, aDuration),
mDisplay(aDisplay),
mFrameID(aFrameID),
mSentToCompositor(false),
@ -354,16 +354,16 @@ already_AddRefed<VideoData> VideoData::CreateFromImage(
}
MediaRawData::MediaRawData()
: MediaData(Type::RAW_DATA, 0), mCrypto(mCryptoInternal) {}
: MediaData(Type::RAW_DATA), mCrypto(mCryptoInternal) {}
MediaRawData::MediaRawData(const uint8_t* aData, size_t aSize)
: MediaData(Type::RAW_DATA, 0),
: MediaData(Type::RAW_DATA),
mCrypto(mCryptoInternal),
mBuffer(aData, aSize) {}
MediaRawData::MediaRawData(const uint8_t* aData, size_t aSize,
const uint8_t* aAlphaData, size_t aAlphaSize)
: MediaData(Type::RAW_DATA, 0),
: MediaData(Type::RAW_DATA),
mCrypto(mCryptoInternal),
mBuffer(aData, aSize),
mAlphaBuffer(aAlphaData, aAlphaSize) {}

Просмотреть файл

@ -268,13 +268,12 @@ class MediaData {
}
MediaData(Type aType, int64_t aOffset, const media::TimeUnit& aTimestamp,
const media::TimeUnit& aDuration, uint32_t aFrames)
const media::TimeUnit& aDuration)
: mType(aType),
mOffset(aOffset),
mTime(aTimestamp),
mTimecode(aTimestamp),
mDuration(aDuration),
mFrames(aFrames),
mKeyframe(false) {}
// Type of contained data.
@ -293,9 +292,6 @@ class MediaData {
// Duration of sample, in microseconds.
media::TimeUnit mDuration;
// Amount of frames for contained data.
const uint32_t mFrames;
bool mKeyframe;
media::TimeUnit GetEndTime() const { return mTime + mDuration; }
@ -318,8 +314,7 @@ class MediaData {
}
protected:
MediaData(Type aType, uint32_t aFrames)
: mType(aType), mOffset(0), mFrames(aFrames), mKeyframe(false) {}
explicit MediaData(Type aType) : mType(aType), mOffset(0), mKeyframe(false) {}
virtual ~MediaData() {}
};
@ -330,7 +325,7 @@ class NullData : public MediaData {
public:
NullData(int64_t aOffset, const media::TimeUnit& aTime,
const media::TimeUnit& aDuration)
: MediaData(Type::NULL_DATA, aOffset, aTime, aDuration, 0) {}
: MediaData(Type::NULL_DATA, aOffset, aTime, aDuration) {}
static const Type sType = Type::NULL_DATA;
};
@ -342,10 +337,11 @@ class AudioData : public MediaData {
const media::TimeUnit& aDuration, uint32_t aFrames,
AlignedAudioBuffer&& aData, uint32_t aChannels, uint32_t aRate,
uint32_t aChannelMap = AudioConfig::ChannelLayout::UNKNOWN_MAP)
: MediaData(sType, aOffset, aTime, aDuration, aFrames),
: MediaData(sType, aOffset, aTime, aDuration),
mChannels(aChannels),
mChannelMap(aChannelMap),
mRate(aRate),
mFrames(aFrames),
mAudioData(std::move(aData)) {}
static const Type sType = Type::AUDIO_DATA;
@ -376,9 +372,12 @@ class AudioData : public MediaData {
// channel map.
const AudioConfig::ChannelLayout::ChannelMap mChannelMap;
const uint32_t mRate;
// Amount of frames for contained data.
const uint32_t mFrames;
// At least one of mAudioBuffer/mAudioData must be non-null.
// mChannels channels, each with mFrames frames
RefPtr<SharedBuffer> mAudioBuffer;
protected:
~AudioData() {}

Просмотреть файл

@ -1684,12 +1684,12 @@ void MediaFormatReader::NotifyNewOutput(
"{\"type\":\"AudioData\", \"offset\":%" PRIi64
", \"time_us\":%" PRIi64 ", \"timecode_us\":%" PRIi64
", \"duration_us\":%" PRIi64 ", \"frames\":%" PRIu32
", \"kf\":%s, \"channels\":%" PRIu32 ", \"rate\":%" PRIu32
", \"channels\":%" PRIu32 ", \"rate\":%" PRIu32
", \"bytes\":%zu}",
sample->mOffset, sample->mTime.ToMicroseconds(),
sample->mTimecode.ToMicroseconds(),
sample->mDuration.ToMicroseconds(), sample->mFrames,
sample->mKeyframe ? "true" : "false",
sample->mDuration.ToMicroseconds(),
static_cast<AudioData*>(sample.get())->mFrames,
sample->As<AudioData>()->mChannels,
sample->As<AudioData>()->mRate,
sample->As<AudioData>()->Data().Length());
@ -1700,11 +1700,11 @@ void MediaFormatReader::NotifyNewOutput(
: "decoded_got_video!?",
"{\"type\":\"VideoData\", \"offset\":%" PRIi64
", \"time_us\":%" PRIi64 ", \"timecode_us\":%" PRIi64
", \"duration_us\":%" PRIi64 ", \"frames\":%" PRIu32
", \"duration_us\":%" PRIi64
", \"kf\":%s, \"size\":[%" PRIi32 ",%" PRIi32 "]}",
sample->mOffset, sample->mTime.ToMicroseconds(),
sample->mTimecode.ToMicroseconds(),
sample->mDuration.ToMicroseconds(), sample->mFrames,
sample->mDuration.ToMicroseconds(),
sample->mKeyframe ? "true" : "false",
sample->As<VideoData>()->mDisplay.width,
sample->As<VideoData>()->mDisplay.height);
@ -1717,11 +1717,10 @@ void MediaFormatReader::NotifyNewOutput(
: "decoded_?",
"{\"type\":\"RawData\", \"offset\":%" PRIi64
" \"time_us\":%" PRIi64 ", \"timecode_us\":%" PRIi64
", \"duration_us\":%" PRIi64 ", \"frames\":%" PRIu32
", \"kf\":%s}",
", \"duration_us\":%" PRIi64 ", \"kf\":%s}",
sample->mOffset, sample->mTime.ToMicroseconds(),
sample->mTimecode.ToMicroseconds(),
sample->mDuration.ToMicroseconds(), sample->mFrames,
sample->mDuration.ToMicroseconds(),
sample->mKeyframe ? "true" : "false");
break;
case MediaData::Type::NULL_DATA:
@ -1732,11 +1731,10 @@ void MediaFormatReader::NotifyNewOutput(
: "decoded_?",
"{\"type\":\"NullData\", \"offset\":%" PRIi64
" \"time_us\":%" PRIi64 ", \"timecode_us\":%" PRIi64
", \"duration_us\":%" PRIi64 ", \"frames\":%" PRIu32
", \"kf\":%s}",
", \"duration_us\":%" PRIi64 ", \"kf\":%s}",
sample->mOffset, sample->mTime.ToMicroseconds(),
sample->mTimecode.ToMicroseconds(),
sample->mDuration.ToMicroseconds(), sample->mFrames,
sample->mDuration.ToMicroseconds(),
sample->mKeyframe ? "true" : "false");
break;
}
@ -1957,11 +1955,11 @@ void MediaFormatReader::DecodeDemuxedSamples(TrackType aTrack,
: aTrack == TrackInfo::kVideoTrack ? "decode_video" : "decode_?",
"{\"type\":\"MediaRawData\", \"offset\":%" PRIi64
", \"bytes\":%zu, \"time_us\":%" PRIi64 ", \"timecode_us\":%" PRIi64
", \"duration_us\":%" PRIi64 ", \"frames\":%" PRIu32 "%s%s}",
", \"duration_us\":%" PRIi64 ",%s%s}",
aSample->mOffset, aSample->Size(), aSample->mTime.ToMicroseconds(),
aSample->mTimecode.ToMicroseconds(),
aSample->mDuration.ToMicroseconds(), aSample->mFrames,
aSample->mKeyframe ? " kf" : "", aSample->mEOS ? " eos" : "");
aSample->mDuration.ToMicroseconds(), aSample->mKeyframe ? " kf" : "",
aSample->mEOS ? " eos" : "");
decoder.mDecoder->Decode(aSample)
->Then(
mTaskQueue, __func__,

Просмотреть файл

@ -10,7 +10,6 @@ struct MediaDataIPDL
int64_t time;
int64_t timecode;
int64_t duration;
uint32_t frames;
bool keyframe;
};

Просмотреть файл

@ -27,6 +27,7 @@ struct RemoteAudioDataIPDL
MediaDataIPDL base;
uint32_t channels;
uint32_t rate;
uint32_t frames;
uint32_t channelMap;
Shmem buffer;
};

Просмотреть файл

@ -30,7 +30,7 @@ mozilla::ipc::IPCResult RemoteAudioDecoderChild::RecvOutput(
new AudioData(aData.base().offset(),
media::TimeUnit::FromMicroseconds(aData.base().time()),
media::TimeUnit::FromMicroseconds(aData.base().duration()),
aData.base().frames(), std::move(alignedAudioBuffer),
aData.frames(), std::move(alignedAudioBuffer),
aData.channels(), aData.rate(), aData.channelMap());
mDecodedData.AppendElement(std::move(audio));
@ -117,9 +117,9 @@ void RemoteAudioDecoderParent::ProcessDecodedData(
RemoteAudioDataIPDL output(
MediaDataIPDL(data->mOffset, data->mTime.ToMicroseconds(),
data->mTimecode.ToMicroseconds(),
data->mDuration.ToMicroseconds(), data->mFrames,
data->mKeyframe),
audio->mChannels, audio->mRate, audio->mChannelMap, buffer);
data->mDuration.ToMicroseconds(), data->mKeyframe),
audio->mChannels, audio->mRate, audio->mFrames, audio->mChannelMap,
buffer);
Unused << SendOutput(output);
}

Просмотреть файл

@ -114,8 +114,7 @@ RefPtr<MediaDataDecoder::DecodePromise> RemoteDecoderChild::Decode(
MediaRawDataIPDL sample(
MediaDataIPDL(aSample->mOffset, aSample->mTime.ToMicroseconds(),
aSample->mTimecode.ToMicroseconds(),
aSample->mDuration.ToMicroseconds(), aSample->mFrames,
aSample->mKeyframe),
aSample->mDuration.ToMicroseconds(), aSample->mKeyframe),
buffer);
SendInput(sample);

Просмотреть файл

@ -193,8 +193,7 @@ void RemoteVideoDecoderParent::ProcessDecodedData(
RemoteVideoDataIPDL output(
MediaDataIPDL(data->mOffset, data->mTime.ToMicroseconds(),
data->mTimecode.ToMicroseconds(),
data->mDuration.ToMicroseconds(), data->mFrames,
data->mKeyframe),
data->mDuration.ToMicroseconds(), data->mKeyframe),
video->mDisplay, image->GetSize(), sdBuffer, video->mFrameID);
Unused << SendOutput(output);
}

Просмотреть файл

@ -4,13 +4,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "VideoDecoderChild.h"
#include "VideoDecoderManagerChild.h"
#include "mozilla/layers/TextureClient.h"
#include "mozilla/Telemetry.h"
#include "base/thread.h"
#include "MediaInfo.h"
#include "ImageContainer.h"
#include "GPUVideoImage.h"
#include "ImageContainer.h"
#include "MediaInfo.h"
#include "VideoDecoderManagerChild.h"
#include "base/thread.h"
#include "mozilla/Telemetry.h"
#include "mozilla/layers/TextureClient.h"
namespace mozilla {
@ -245,8 +245,7 @@ RefPtr<MediaDataDecoder::DecodePromise> VideoDecoderChild::Decode(
MediaRawDataIPDL sample(
MediaDataIPDL(aSample->mOffset, aSample->mTime.ToMicroseconds(),
aSample->mTimecode.ToMicroseconds(),
aSample->mDuration.ToMicroseconds(), aSample->mFrames,
aSample->mKeyframe),
aSample->mDuration.ToMicroseconds(), aSample->mKeyframe),
buffer);
SendInput(sample);
return mDecodePromise.Ensure(__func__);

Просмотреть файл

@ -196,8 +196,7 @@ void VideoDecoderParent::ProcessDecodedData(
VideoDataIPDL output(
MediaDataIPDL(data->mOffset, data->mTime.ToMicroseconds(),
data->mTimecode.ToMicroseconds(),
data->mDuration.ToMicroseconds(), data->mFrames,
data->mKeyframe),
data->mDuration.ToMicroseconds(), data->mKeyframe),
video->mDisplay, texture ? texture->GetSize() : IntSize(),
texture ? mParent->StoreImage(video->mImage, texture)
: SurfaceDescriptorGPUVideo(0, null_t()),