Skip to content
Snippets Groups Projects
Commit 58d8f58f authored by Jean-Yves Avenard's avatar Jean-Yves Avenard
Browse files

Bug 1406503 - P2. Use common draining mechanism for both audio and video decoder. r=jwwang

MozReview-Commit-ID: AtDHOuDfpi5

--HG--
extra : rebase_source : bdc16d68a69d8987559663ea1cd2a47405fcaa26
parent e147a460
No related branches found
No related tags found
No related merge requests found
......@@ -215,13 +215,6 @@ FFmpegAudioDecoder<LIBAV_VER>::DoDecode(MediaRawData* aSample,
return NS_OK;
}
RefPtr<MediaDataDecoder::DecodePromise>
FFmpegAudioDecoder<LIBAV_VER>::ProcessDrain()
{
ProcessFlush();
return DecodePromise::CreateAndResolve(DecodedData(), __func__);
}
AVCodecID
FFmpegAudioDecoder<LIBAV_VER>::GetCodecId(const nsACString& aMimeType)
{
......
......@@ -33,7 +33,6 @@ public:
}
private:
RefPtr<DecodePromise> ProcessDrain() override;
MediaResult DoDecode(MediaRawData* aSample,
uint8_t* aData,
int aSize,
......
......@@ -29,6 +29,7 @@ FFmpegDataDecoder<LIBAV_VER>::FFmpegDataDecoder(FFmpegLibWrapper* aLib,
, mExtraData(nullptr)
, mCodecID(aCodecID)
, mTaskQueue(aTaskQueue)
, mLastInputDts(media::TimeUnit::FromMicroseconds(INT64_MIN))
{
MOZ_ASSERT(aLib);
MOZ_COUNT_CTOR(FFmpegDataDecoder);
......@@ -137,6 +138,8 @@ FFmpegDataDecoder<LIBAV_VER>::DoDecode(MediaRawData* aSample, bool* aGotFrame,
uint8_t* inputData = const_cast<uint8_t*>(aSample->Data());
size_t inputSize = aSample->Size();
mLastInputDts = aSample->mTimecode;
if (inputSize && mCodecParser) {
while (inputSize) {
uint8_t* data = inputData;
......@@ -180,6 +183,19 @@ FFmpegDataDecoder<LIBAV_VER>::Drain()
&FFmpegDataDecoder<LIBAV_VER>::ProcessDrain);
}
RefPtr<MediaDataDecoder::DecodePromise>
FFmpegDataDecoder<LIBAV_VER>::ProcessDrain()
{
RefPtr<MediaRawData> empty(new MediaRawData());
empty->mTimecode = mLastInputDts;
bool gotFrame = false;
DecodedData results;
while (NS_SUCCEEDED(DoDecode(empty, &gotFrame, results)) &&
gotFrame) {
}
return DecodePromise::CreateAndResolve(Move(results), __func__);
}
RefPtr<MediaDataDecoder::FlushPromise>
FFmpegDataDecoder<LIBAV_VER>::ProcessFlush()
{
......
......@@ -58,7 +58,7 @@ protected:
private:
RefPtr<DecodePromise> ProcessDecode(MediaRawData* aSample);
virtual RefPtr<DecodePromise> ProcessDrain() = 0;
RefPtr<DecodePromise> ProcessDrain();
virtual MediaResult DoDecode(MediaRawData* aSample,
uint8_t* aData,
int aSize,
......@@ -70,6 +70,7 @@ private:
static StaticMutex sMonitor;
const RefPtr<TaskQueue> mTaskQueue;
MozPromiseHolder<DecodePromise> mPromise;
media::TimeUnit mLastInputDts;
};
} // namespace mozilla
......
......@@ -128,7 +128,6 @@ FFmpegVideoDecoder<LIBAV_VER>::FFmpegVideoDecoder(
, mImageAllocator(aAllocator)
, mImageContainer(aImageContainer)
, mInfo(aConfig)
, mLastInputDts(INT64_MIN)
, mLowLatency(aLowLatency)
{
// Use a new MediaByteBuffer as the object will be modified during
......@@ -195,7 +194,7 @@ FFmpegVideoDecoder<LIBAV_VER>::DoDecode(MediaRawData* aSample,
packet.data = aData;
packet.size = aSize;
packet.dts = mLastInputDts = aSample->mTimecode.ToMicroseconds();
packet.dts = aSample->mTimecode.ToMicroseconds();
packet.pts = aSample->mTime.ToMicroseconds();
packet.flags = aSample->mKeyframe ? AV_PKT_FLAG_KEY : 0;
packet.pos = aSample->mOffset;
......@@ -358,19 +357,6 @@ FFmpegVideoDecoder<LIBAV_VER>::DoDecode(MediaRawData* aSample,
return NS_OK;
}
RefPtr<MediaDataDecoder::DecodePromise>
FFmpegVideoDecoder<LIBAV_VER>::ProcessDrain()
{
RefPtr<MediaRawData> empty(new MediaRawData());
empty->mTimecode = TimeUnit::FromMicroseconds(mLastInputDts);
bool gotFrame = false;
DecodedData results;
while (NS_SUCCEEDED(DoDecode(empty, nullptr, 0, &gotFrame, results)) &&
gotFrame) {
}
return DecodePromise::CreateAndResolve(Move(results), __func__);
}
RefPtr<MediaDataDecoder::FlushPromise>
FFmpegVideoDecoder<LIBAV_VER>::ProcessFlush()
{
......
......@@ -52,7 +52,6 @@ public:
static AVCodecID GetCodecId(const nsACString& aMimeType);
private:
RefPtr<DecodePromise> ProcessDrain() override;
RefPtr<FlushPromise> ProcessFlush() override;
MediaResult DoDecode(MediaRawData* aSample,
uint8_t* aData,
......@@ -98,7 +97,6 @@ private:
};
PtsCorrectionContext mPtsContext;
int64_t mLastInputDts;
DurationMap mDurationMap;
const bool mLowLatency;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment