Closed Bug 1020679 Opened 10 years ago Closed 10 years ago

MP4Sample::duration should not always be 0

Categories

(Core :: Audio/Video, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla33

People

(Reporter: cpearce, Assigned: ajones)

References

Details

Attachments

(3 files, 3 obsolete files)

MP4Sample::duration is always 0, it should not be. This causes the BlankDecoderModule to not play audio, as it relies on the duration being correct. It should play an a4 tone.
Summary: MP4Sample::duration not not always be 0 → MP4Sample::duration should not always be 0
Assignee: nobody → ajones
Status: NEW → ASSIGNED
Does it break anything other than the blank decoder?
Comment on attachment 8435521 [details] [diff] [review]
Fix MP4 demuxer duration

Review of attachment 8435521 [details] [diff] [review]:
-----------------------------------------------------------------

::: media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
@@ +2773,5 @@
> +    mTrackFragmentHeaderInfo.mSampleDescriptionIndex = 0;
> +    mTrackFragmentHeaderInfo.mDefaultSampleDuration = 0;
> +    mTrackFragmentHeaderInfo.mDefaultSampleSize = 0;
> +    mTrackFragmentHeaderInfo.mDefaultSampleFlags = 0;
> +    mTrackFragmentHeaderInfo.mDataOffset = 0;

This just fixes an unrelated issue with uninitialised data.
Attachment #8435521 - Flags: review?(cpearce)
Attachment #8435521 - Flags: review?(cpearce) → review+
Comment on attachment 8435521 [details] [diff] [review]
Fix MP4 demuxer duration

Review of attachment 8435521 [details] [diff] [review]:
-----------------------------------------------------------------

::: media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
@@ +3173,5 @@
>              mBuffer->meta_data()->setInt64(kKey64BitFileOffset, offset);
>              mBuffer->meta_data()->setInt64(
>                      kKeyTime, ((int64_t)cts * 1000000) / mTimescale);
> +            mBuffer->meta_data()->setInt64(
> +                    kKeyDuration, ((int64_t)duration * 1000000) / mTimescale);

Can mTimescale ever be 0? Please figure out whether it can be 0, and if so prevent it being 0 (in another bug/patch).
Comment on attachment 8438915 [details] [diff] [review]
Guard against MP4 /0 for timescale

Review of attachment 8438915 [details] [diff] [review]:
-----------------------------------------------------------------

Please also check for or otherwise prevent divisions by Track->timescale and MPEG4Extractor::mHeaderTimescale in MPEG4Extractor.cpp.
Attachment #8438915 - Flags: review?(cpearce) → review-
Attachment #8438915 - Attachment is obsolete: true
Attached patch Crash test for timescale /0 (obsolete) — Splinter Review
Attachment #8438961 - Flags: review?(cpearce)
Comment on attachment 8438952 [details] [diff] [review]
Guard against MP4 /0 for timescale

Review of attachment 8438952 [details] [diff] [review]:
-----------------------------------------------------------------

r+ with the fix mentioned.

::: media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
@@ +448,5 @@
>                  if (track->sampleTable->findThumbnailSample(&sampleIndex) == OK
>                          && track->sampleTable->getMetaDataForSample(
>                              sampleIndex, NULL /* offset */, NULL /* size */,
>                              &sampleTime) == OK) {
> +                    if (!track->timescale) {

The callsite of this also needs(MP4Demuxer::Init()) to null check the return value of this function before dereferencing it.
Attachment #8438952 - Flags: review?(cpearce) → review+
Attachment #8438961 - Flags: review?(cpearce) → review+
(In reply to Chris Pearce (:cpearce) from comment #11)
> The callsite of this also needs(MP4Demuxer::Init()) to null check the return
> value of this function before dereferencing it.

Are you talking about:

    if (!metaData.get() || !metaData->findCString(kKeyMIMEType, &mimeType)) {
      continue;
    }

metaData.get() calls the sp::get() function. The Mozilla conventional `!metaData` doesn't compile so perhaps it be better written as:

    if (metaData == nullptr || !metaData->findCString(kKeyMIMEType, &mimeType)) {
      continue;
    }

This compiles and is a little clearer.
That's fine.
Attachment #8438952 - Attachment is obsolete: true
Removed b2g from crashtest based on try results; carrying r+
Attachment #8438961 - Attachment is obsolete: true
Depends on: 1048628
See Also: → 1140995
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: