зеркало из 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
|
||||
// decoding after a padding discard is invalid.
|
||||
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) {
|
||||
|
@ -187,7 +189,9 @@ OpusDataDecoder::DoDecode(MediaRawData* aSample)
|
|||
if (frames_number <= 0) {
|
||||
OPUS_DEBUG("Invalid packet header: r=%ld length=%ld",
|
||||
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(),
|
||||
|
@ -198,7 +202,8 @@ OpusDataDecoder::DoDecode(MediaRawData* aSample)
|
|||
int32_t frames = frames_number*samples;
|
||||
if (frames < 120 || frames > 5760) {
|
||||
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);
|
||||
|
@ -217,7 +222,8 @@ OpusDataDecoder::DoDecode(MediaRawData* aSample)
|
|||
buffer.get(), frames, false);
|
||||
#endif
|
||||
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");
|
||||
CheckedInt64 startTime = aSample->mTime;
|
||||
|
@ -238,7 +244,8 @@ OpusDataDecoder::DoDecode(MediaRawData* aSample)
|
|||
if (aDiscardPadding < 0) {
|
||||
// Negative discard padding is invalid.
|
||||
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) {
|
||||
OPUS_DEBUG("OpusDecoder discardpadding %" PRId64 "", aDiscardPadding);
|
||||
|
@ -246,13 +253,15 @@ OpusDataDecoder::DoDecode(MediaRawData* aSample)
|
|||
TimeUnitToFrames(media::TimeUnit::FromNanoseconds(aDiscardPadding),
|
||||
mOpusParser->mRate);
|
||||
if (!discardFrames.isValid()) {
|
||||
NS_WARNING("Int overflow in DiscardPadding");
|
||||
return NS_ERROR_DOM_MEDIA_OVERFLOW_ERR;
|
||||
return MediaResult(NS_ERROR_DOM_MEDIA_OVERFLOW_ERR,
|
||||
RESULT_DETAIL("Overflow in DiscardPadding"));
|
||||
}
|
||||
if (discardFrames.value() > frames) {
|
||||
// Discarding more than the entire packet is invalid.
|
||||
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",
|
||||
int32_t(discardFrames.value()), frames);
|
||||
|
@ -286,15 +295,17 @@ OpusDataDecoder::DoDecode(MediaRawData* aSample)
|
|||
|
||||
CheckedInt64 duration = FramesToUsecs(frames, mOpusParser->mRate);
|
||||
if (!duration.isValid()) {
|
||||
NS_WARNING("OpusDataDecoder: Int overflow converting WebM audio duration");
|
||||
return NS_ERROR_DOM_MEDIA_OVERFLOW_ERR;
|
||||
return MediaResult(
|
||||
NS_ERROR_DOM_MEDIA_OVERFLOW_ERR,
|
||||
RESULT_DETAIL("Overflow converting WebM audio duration"));
|
||||
}
|
||||
CheckedInt64 time =
|
||||
startTime - FramesToUsecs(mOpusParser->mPreSkip, mOpusParser->mRate) +
|
||||
FramesToUsecs(mFrames, mOpusParser->mRate);
|
||||
if (!time.isValid()) {
|
||||
NS_WARNING("OpusDataDecoder: Int overflow shifting tstamp by codec delay");
|
||||
return NS_ERROR_DOM_MEDIA_OVERFLOW_ERR;
|
||||
return MediaResult(
|
||||
NS_ERROR_DOM_MEDIA_OVERFLOW_ERR,
|
||||
RESULT_DETAIL("Overflow shifting tstamp by codec delay"));
|
||||
};
|
||||
|
||||
mCallback->Output(new AudioData(aSample->mOffset,
|
||||
|
|
|
@ -187,7 +187,8 @@ TheoraDecoder::DoDecode(MediaRawData* aSample)
|
|||
return NS_OK;
|
||||
} else {
|
||||
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)) {
|
||||
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;
|
||||
|
@ -157,7 +159,8 @@ VPXDecoder::DoDecode(MediaRawData* aSample)
|
|||
b.mPlanes[2].mWidth = img->d_w;
|
||||
} else {
|
||||
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 =
|
||||
|
|
|
@ -168,13 +168,16 @@ VorbisDataDecoder::DoDecode(MediaRawData* aSample)
|
|||
ogg_packet pkt = InitVorbisPacket(aData, aLength, false, aSample->mEOS,
|
||||
aSample->mTimecode, mPacketCount++);
|
||||
|
||||
if (vorbis_synthesis(&mVorbisBlock, &pkt) != 0) {
|
||||
return NS_ERROR_DOM_MEDIA_DECODE_ERR;
|
||||
int err = vorbis_synthesis(&mVorbisBlock, &pkt);
|
||||
if (err) {
|
||||
return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
|
||||
RESULT_DETAIL("vorbis_synthesis:%d", err));
|
||||
}
|
||||
|
||||
if (vorbis_synthesis_blockin(&mVorbisDsp,
|
||||
&mVorbisBlock) != 0) {
|
||||
return NS_ERROR_DOM_MEDIA_DECODE_ERR;
|
||||
err = vorbis_synthesis_blockin(&mVorbisDsp, &mVorbisBlock);
|
||||
if (err) {
|
||||
return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
|
||||
RESULT_DETAIL("vorbis_synthesis_blockin:%d", err));
|
||||
}
|
||||
|
||||
VorbisPCMValue** pcm = 0;
|
||||
|
@ -198,19 +201,21 @@ VorbisDataDecoder::DoDecode(MediaRawData* aSample)
|
|||
|
||||
CheckedInt64 duration = FramesToUsecs(frames, rate);
|
||||
if (!duration.isValid()) {
|
||||
NS_WARNING("Int overflow converting WebM audio duration");
|
||||
return NS_ERROR_DOM_MEDIA_OVERFLOW_ERR;
|
||||
return MediaResult(NS_ERROR_DOM_MEDIA_OVERFLOW_ERR,
|
||||
RESULT_DETAIL("Overflow converting audio duration"));
|
||||
}
|
||||
CheckedInt64 total_duration = FramesToUsecs(mFrames, rate);
|
||||
if (!total_duration.isValid()) {
|
||||
NS_WARNING("Int overflow converting WebM audio total_duration");
|
||||
return NS_ERROR_DOM_MEDIA_OVERFLOW_ERR;
|
||||
return MediaResult(
|
||||
NS_ERROR_DOM_MEDIA_OVERFLOW_ERR,
|
||||
RESULT_DETAIL("Overflow converting audio total_duration"));
|
||||
}
|
||||
|
||||
CheckedInt64 time = total_duration + aTstampUsecs;
|
||||
if (!time.isValid()) {
|
||||
NS_WARNING("Int overflow adding total_duration and aTstampUsecs");
|
||||
return NS_ERROR_DOM_MEDIA_OVERFLOW_ERR;
|
||||
return MediaResult(
|
||||
NS_ERROR_DOM_MEDIA_OVERFLOW_ERR,
|
||||
RESULT_DETAIL("Overflow adding total_duration and aTstampUsecs"));
|
||||
};
|
||||
|
||||
if (!mAudioConverter) {
|
||||
|
@ -218,7 +223,9 @@ VorbisDataDecoder::DoDecode(MediaRawData* aSample)
|
|||
rate);
|
||||
AudioConfig out(channels, rate);
|
||||
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);
|
||||
}
|
||||
|
@ -235,8 +242,10 @@ VorbisDataDecoder::DoDecode(MediaRawData* aSample)
|
|||
channels,
|
||||
rate));
|
||||
mFrames += frames;
|
||||
if (vorbis_synthesis_read(&mVorbisDsp, frames) != 0) {
|
||||
return NS_ERROR_DOM_MEDIA_DECODE_ERR;
|
||||
err = vorbis_synthesis_read(&mVorbisDsp, frames);
|
||||
if (err) {
|
||||
return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
|
||||
RESULT_DETAIL("vorbis_synthesis_read:%d", err));
|
||||
}
|
||||
|
||||
frames = vorbis_synthesis_pcmout(&mVorbisDsp, &pcm);
|
||||
|
|
Загрузка…
Ссылка в новой задаче