зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1304252: P3. Further error details for agnostic decoders. r=gerald
MozReview-Commit-ID: 1tb4f9xQKyr --HG-- extra : rebase_source : 37bd772240de01d9fcb2fac765f58b27e6f86c9c
This commit is contained in:
Родитель
5b5bc32ab4
Коммит
2010639f50
|
@ -172,7 +172,9 @@ OpusDataDecoder::DoDecode(MediaRawData* aSample)
|
||||||
// Discard padding should be used only on the final packet, so
|
// Discard padding should be used only on the final packet, so
|
||||||
// decoding after a padding discard is invalid.
|
// decoding after a padding discard is invalid.
|
||||||
OPUS_DEBUG("Opus error, discard padding on interstitial packet");
|
OPUS_DEBUG("Opus error, discard padding on interstitial packet");
|
||||||
return NS_ERROR_DOM_MEDIA_FATAL_ERR;
|
return MediaResult(
|
||||||
|
NS_ERROR_DOM_MEDIA_FATAL_ERR,
|
||||||
|
RESULT_DETAIL("Discard padding on interstitial packet"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mLastFrameTime || mLastFrameTime.ref() != aSample->mTime) {
|
if (!mLastFrameTime || mLastFrameTime.ref() != aSample->mTime) {
|
||||||
|
@ -187,7 +189,9 @@ OpusDataDecoder::DoDecode(MediaRawData* aSample)
|
||||||
if (frames_number <= 0) {
|
if (frames_number <= 0) {
|
||||||
OPUS_DEBUG("Invalid packet header: r=%ld length=%ld",
|
OPUS_DEBUG("Invalid packet header: r=%ld length=%ld",
|
||||||
frames_number, aSample->Size());
|
frames_number, aSample->Size());
|
||||||
return NS_ERROR_DOM_MEDIA_DECODE_ERR;
|
return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
|
||||||
|
RESULT_DETAIL("Invalid packet header: r=%d length=%u",
|
||||||
|
frames_number, uint32_t(aSample->Size())));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t samples = opus_packet_get_samples_per_frame(aSample->Data(),
|
int32_t samples = opus_packet_get_samples_per_frame(aSample->Data(),
|
||||||
|
@ -198,7 +202,8 @@ OpusDataDecoder::DoDecode(MediaRawData* aSample)
|
||||||
int32_t frames = frames_number*samples;
|
int32_t frames = frames_number*samples;
|
||||||
if (frames < 120 || frames > 5760) {
|
if (frames < 120 || frames > 5760) {
|
||||||
OPUS_DEBUG("Invalid packet frames: %ld", frames);
|
OPUS_DEBUG("Invalid packet frames: %ld", frames);
|
||||||
return NS_ERROR_DOM_MEDIA_DECODE_ERR;
|
return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
|
||||||
|
RESULT_DETAIL("Invalid packet frames:%d", frames));
|
||||||
}
|
}
|
||||||
|
|
||||||
AlignedAudioBuffer buffer(frames * channels);
|
AlignedAudioBuffer buffer(frames * channels);
|
||||||
|
@ -217,7 +222,8 @@ OpusDataDecoder::DoDecode(MediaRawData* aSample)
|
||||||
buffer.get(), frames, false);
|
buffer.get(), frames, false);
|
||||||
#endif
|
#endif
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return NS_ERROR_DOM_MEDIA_DECODE_ERR;
|
return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
|
||||||
|
RESULT_DETAIL("Opus decoding error:%d", ret));
|
||||||
}
|
}
|
||||||
NS_ASSERTION(ret == frames, "Opus decoded too few audio samples");
|
NS_ASSERTION(ret == frames, "Opus decoded too few audio samples");
|
||||||
CheckedInt64 startTime = aSample->mTime;
|
CheckedInt64 startTime = aSample->mTime;
|
||||||
|
@ -238,7 +244,8 @@ OpusDataDecoder::DoDecode(MediaRawData* aSample)
|
||||||
if (aDiscardPadding < 0) {
|
if (aDiscardPadding < 0) {
|
||||||
// Negative discard padding is invalid.
|
// Negative discard padding is invalid.
|
||||||
OPUS_DEBUG("Opus error, negative discard padding");
|
OPUS_DEBUG("Opus error, negative discard padding");
|
||||||
return NS_ERROR_DOM_MEDIA_FATAL_ERR;
|
return MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
|
||||||
|
RESULT_DETAIL("Negative discard padding"));
|
||||||
}
|
}
|
||||||
if (aDiscardPadding > 0) {
|
if (aDiscardPadding > 0) {
|
||||||
OPUS_DEBUG("OpusDecoder discardpadding %" PRId64 "", aDiscardPadding);
|
OPUS_DEBUG("OpusDecoder discardpadding %" PRId64 "", aDiscardPadding);
|
||||||
|
@ -246,13 +253,15 @@ OpusDataDecoder::DoDecode(MediaRawData* aSample)
|
||||||
TimeUnitToFrames(media::TimeUnit::FromNanoseconds(aDiscardPadding),
|
TimeUnitToFrames(media::TimeUnit::FromNanoseconds(aDiscardPadding),
|
||||||
mOpusParser->mRate);
|
mOpusParser->mRate);
|
||||||
if (!discardFrames.isValid()) {
|
if (!discardFrames.isValid()) {
|
||||||
NS_WARNING("Int overflow in DiscardPadding");
|
return MediaResult(NS_ERROR_DOM_MEDIA_OVERFLOW_ERR,
|
||||||
return NS_ERROR_DOM_MEDIA_OVERFLOW_ERR;
|
RESULT_DETAIL("Overflow in DiscardPadding"));
|
||||||
}
|
}
|
||||||
if (discardFrames.value() > frames) {
|
if (discardFrames.value() > frames) {
|
||||||
// Discarding more than the entire packet is invalid.
|
// Discarding more than the entire packet is invalid.
|
||||||
OPUS_DEBUG("Opus error, discard padding larger than packet");
|
OPUS_DEBUG("Opus error, discard padding larger than packet");
|
||||||
return NS_ERROR_DOM_MEDIA_FATAL_ERR;
|
return MediaResult(
|
||||||
|
NS_ERROR_DOM_MEDIA_FATAL_ERR,
|
||||||
|
RESULT_DETAIL("Discard padding larger than packet"));
|
||||||
}
|
}
|
||||||
OPUS_DEBUG("Opus decoder discarding %d of %d frames",
|
OPUS_DEBUG("Opus decoder discarding %d of %d frames",
|
||||||
int32_t(discardFrames.value()), frames);
|
int32_t(discardFrames.value()), frames);
|
||||||
|
@ -286,15 +295,17 @@ OpusDataDecoder::DoDecode(MediaRawData* aSample)
|
||||||
|
|
||||||
CheckedInt64 duration = FramesToUsecs(frames, mOpusParser->mRate);
|
CheckedInt64 duration = FramesToUsecs(frames, mOpusParser->mRate);
|
||||||
if (!duration.isValid()) {
|
if (!duration.isValid()) {
|
||||||
NS_WARNING("OpusDataDecoder: Int overflow converting WebM audio duration");
|
return MediaResult(
|
||||||
return NS_ERROR_DOM_MEDIA_OVERFLOW_ERR;
|
NS_ERROR_DOM_MEDIA_OVERFLOW_ERR,
|
||||||
|
RESULT_DETAIL("Overflow converting WebM audio duration"));
|
||||||
}
|
}
|
||||||
CheckedInt64 time =
|
CheckedInt64 time =
|
||||||
startTime - FramesToUsecs(mOpusParser->mPreSkip, mOpusParser->mRate) +
|
startTime - FramesToUsecs(mOpusParser->mPreSkip, mOpusParser->mRate) +
|
||||||
FramesToUsecs(mFrames, mOpusParser->mRate);
|
FramesToUsecs(mFrames, mOpusParser->mRate);
|
||||||
if (!time.isValid()) {
|
if (!time.isValid()) {
|
||||||
NS_WARNING("OpusDataDecoder: Int overflow shifting tstamp by codec delay");
|
return MediaResult(
|
||||||
return NS_ERROR_DOM_MEDIA_OVERFLOW_ERR;
|
NS_ERROR_DOM_MEDIA_OVERFLOW_ERR,
|
||||||
|
RESULT_DETAIL("Overflow shifting tstamp by codec delay"));
|
||||||
};
|
};
|
||||||
|
|
||||||
mCallback->Output(new AudioData(aSample->mOffset,
|
mCallback->Output(new AudioData(aSample->mOffset,
|
||||||
|
|
|
@ -187,7 +187,8 @@ TheoraDecoder::DoDecode(MediaRawData* aSample)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
} else {
|
} else {
|
||||||
LOG("Theora Decode error: %d", ret);
|
LOG("Theora Decode error: %d", ret);
|
||||||
return NS_ERROR_DOM_MEDIA_DECODE_ERR;
|
return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
|
||||||
|
RESULT_DETAIL("Theora decode error:%d", ret));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,9 @@ VPXDecoder::DoDecode(MediaRawData* aSample)
|
||||||
|
|
||||||
if (vpx_codec_err_t r = vpx_codec_decode(&mVPX, aSample->Data(), aSample->Size(), nullptr, 0)) {
|
if (vpx_codec_err_t r = vpx_codec_decode(&mVPX, aSample->Data(), aSample->Size(), nullptr, 0)) {
|
||||||
LOG("VPX Decode error: %s", vpx_codec_err_to_string(r));
|
LOG("VPX Decode error: %s", vpx_codec_err_to_string(r));
|
||||||
return NS_ERROR_DOM_MEDIA_DECODE_ERR;
|
return MediaResult(
|
||||||
|
NS_ERROR_DOM_MEDIA_DECODE_ERR,
|
||||||
|
RESULT_DETAIL("VPX error: %s", vpx_codec_err_to_string(r)));
|
||||||
}
|
}
|
||||||
|
|
||||||
vpx_codec_iter_t iter = nullptr;
|
vpx_codec_iter_t iter = nullptr;
|
||||||
|
@ -157,7 +159,8 @@ VPXDecoder::DoDecode(MediaRawData* aSample)
|
||||||
b.mPlanes[2].mWidth = img->d_w;
|
b.mPlanes[2].mWidth = img->d_w;
|
||||||
} else {
|
} else {
|
||||||
LOG("VPX Unknown image format");
|
LOG("VPX Unknown image format");
|
||||||
return NS_ERROR_DOM_MEDIA_DECODE_ERR;
|
return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
|
||||||
|
RESULT_DETAIL("VPX Unknown image format"));
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<VideoData> v =
|
RefPtr<VideoData> v =
|
||||||
|
|
|
@ -168,13 +168,16 @@ VorbisDataDecoder::DoDecode(MediaRawData* aSample)
|
||||||
ogg_packet pkt = InitVorbisPacket(aData, aLength, false, aSample->mEOS,
|
ogg_packet pkt = InitVorbisPacket(aData, aLength, false, aSample->mEOS,
|
||||||
aSample->mTimecode, mPacketCount++);
|
aSample->mTimecode, mPacketCount++);
|
||||||
|
|
||||||
if (vorbis_synthesis(&mVorbisBlock, &pkt) != 0) {
|
int err = vorbis_synthesis(&mVorbisBlock, &pkt);
|
||||||
return NS_ERROR_DOM_MEDIA_DECODE_ERR;
|
if (err) {
|
||||||
|
return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
|
||||||
|
RESULT_DETAIL("vorbis_synthesis:%d", err));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vorbis_synthesis_blockin(&mVorbisDsp,
|
err = vorbis_synthesis_blockin(&mVorbisDsp, &mVorbisBlock);
|
||||||
&mVorbisBlock) != 0) {
|
if (err) {
|
||||||
return NS_ERROR_DOM_MEDIA_DECODE_ERR;
|
return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
|
||||||
|
RESULT_DETAIL("vorbis_synthesis_blockin:%d", err));
|
||||||
}
|
}
|
||||||
|
|
||||||
VorbisPCMValue** pcm = 0;
|
VorbisPCMValue** pcm = 0;
|
||||||
|
@ -198,19 +201,21 @@ VorbisDataDecoder::DoDecode(MediaRawData* aSample)
|
||||||
|
|
||||||
CheckedInt64 duration = FramesToUsecs(frames, rate);
|
CheckedInt64 duration = FramesToUsecs(frames, rate);
|
||||||
if (!duration.isValid()) {
|
if (!duration.isValid()) {
|
||||||
NS_WARNING("Int overflow converting WebM audio duration");
|
return MediaResult(NS_ERROR_DOM_MEDIA_OVERFLOW_ERR,
|
||||||
return NS_ERROR_DOM_MEDIA_OVERFLOW_ERR;
|
RESULT_DETAIL("Overflow converting audio duration"));
|
||||||
}
|
}
|
||||||
CheckedInt64 total_duration = FramesToUsecs(mFrames, rate);
|
CheckedInt64 total_duration = FramesToUsecs(mFrames, rate);
|
||||||
if (!total_duration.isValid()) {
|
if (!total_duration.isValid()) {
|
||||||
NS_WARNING("Int overflow converting WebM audio total_duration");
|
return MediaResult(
|
||||||
return NS_ERROR_DOM_MEDIA_OVERFLOW_ERR;
|
NS_ERROR_DOM_MEDIA_OVERFLOW_ERR,
|
||||||
|
RESULT_DETAIL("Overflow converting audio total_duration"));
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckedInt64 time = total_duration + aTstampUsecs;
|
CheckedInt64 time = total_duration + aTstampUsecs;
|
||||||
if (!time.isValid()) {
|
if (!time.isValid()) {
|
||||||
NS_WARNING("Int overflow adding total_duration and aTstampUsecs");
|
return MediaResult(
|
||||||
return NS_ERROR_DOM_MEDIA_OVERFLOW_ERR;
|
NS_ERROR_DOM_MEDIA_OVERFLOW_ERR,
|
||||||
|
RESULT_DETAIL("Overflow adding total_duration and aTstampUsecs"));
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!mAudioConverter) {
|
if (!mAudioConverter) {
|
||||||
|
@ -218,7 +223,9 @@ VorbisDataDecoder::DoDecode(MediaRawData* aSample)
|
||||||
rate);
|
rate);
|
||||||
AudioConfig out(channels, rate);
|
AudioConfig out(channels, rate);
|
||||||
if (!in.IsValid() || !out.IsValid()) {
|
if (!in.IsValid() || !out.IsValid()) {
|
||||||
return NS_ERROR_DOM_MEDIA_FATAL_ERR;
|
return MediaResult(
|
||||||
|
NS_ERROR_DOM_MEDIA_FATAL_ERR,
|
||||||
|
RESULT_DETAIL("Invalid channel layout:%u", channels));
|
||||||
}
|
}
|
||||||
mAudioConverter = MakeUnique<AudioConverter>(in, out);
|
mAudioConverter = MakeUnique<AudioConverter>(in, out);
|
||||||
}
|
}
|
||||||
|
@ -235,8 +242,10 @@ VorbisDataDecoder::DoDecode(MediaRawData* aSample)
|
||||||
channels,
|
channels,
|
||||||
rate));
|
rate));
|
||||||
mFrames += frames;
|
mFrames += frames;
|
||||||
if (vorbis_synthesis_read(&mVorbisDsp, frames) != 0) {
|
err = vorbis_synthesis_read(&mVorbisDsp, frames);
|
||||||
return NS_ERROR_DOM_MEDIA_DECODE_ERR;
|
if (err) {
|
||||||
|
return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
|
||||||
|
RESULT_DETAIL("vorbis_synthesis_read:%d", err));
|
||||||
}
|
}
|
||||||
|
|
||||||
frames = vorbis_synthesis_pcmout(&mVorbisDsp, &pcm);
|
frames = vorbis_synthesis_pcmout(&mVorbisDsp, &pcm);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче