9262 Commits

Author SHA1 Message Date
tonihei
dc805232a3 Treat NO_VALUE as zero when adding up total required bitrate
We currently use the literal -1 (=NO_VALUE) when adding up the
total. Tracks without known bitrate can be ignored in the
calculation, but we should use an explicit value of 0.

#minor-release

Issue: google/ExoPlayer#10664
PiperOrigin-RevId: 480048126
(cherry picked from commit af19e0ea890e7b274b6f75f409f00f11e11c1c81)
2022-10-10 11:11:30 +00:00
michaelkatz
e8a5ac91ef Adjust track selection with Dolby Vision if display does not support
If the sample type is Dolby Vision and the display does not support Dolby Vision, then the capabilities DecoderSupport flag is set to DECODER_SUPPORT_FALLBACK_MIMETYPE. This denotes that the renderer will use a decoder for a fallback mimetype if possible. This alters track selection as tracks with DecoderSupport DECODER_SUPPORT_PRIMARY are preferred.

UnitTests included
-DefaultTrackSelector test that checks track selection reordering with DECODER_SUPPORT_FALLBACK_MIMETYPE
-MediaCodecVideoRenderer test that checks setting of DecoderSupport flag based on Display's Dolby Vision support

Issue: google/ExoPlayer#8944
PiperOrigin-RevId: 480040876
(cherry picked from commit a366590a0425ff138520752e2fc94c70429c20ab)
2022-10-10 10:35:17 +00:00
claincly
efb7bf2fc2 Remove late frame dropping in FrameProcessor
Currently, a frame is dropped if it's requested release time is in the past.
This mode was added to support previewing. However, in normal ExoPlayer
playback, slightly late frames (<30ms late) are also rendered. On MediaCodec
side, this means calling `releaseOutputBuffer` with a release time in the
past.

PiperOrigin-RevId: 479615291
(cherry picked from commit 2188685c465aa6d641e78ab33eaa93fbb92185b8)
2022-10-07 17:29:15 +00:00
huangdarwin
15e316da3f HDR: Disable tone mapping on unsupported pixel build ID.
Also, update tests to allow AnyOf error codes, and no longer check exception messages, which caused quite a bit of churn.

PiperOrigin-RevId: 479570861
(cherry picked from commit faa796d7365330d1f1d4f5b17901d6b1a78ce868)
2022-10-07 13:57:06 +00:00
ibaker
ee9bff08da Document the allowed values of TsPayloadReader.Flags IntDef
PiperOrigin-RevId: 479569806
(cherry picked from commit 7c68b8d4500cb25779a473b52029944ec4d29543)
2022-10-07 13:50:28 +00:00
claincly
808180455a Add a FrameProcessor flag to drop the processed frame
This mode is supported by using `C.TIME_UNSET` (which is a negative value). The
new logic decouples the value of `C.TIME_UNSET` and the frame dropping
behaviour.

PiperOrigin-RevId: 479368880
(cherry picked from commit ccab9fba0369ea9709a6987024177e8b73a5c7ac)
2022-10-06 18:30:14 +00:00
tianyifeng
d2f7fb1d50 Provide access to original media timestamps in AudioSink.
* Add `setOutputStreamOffsetUs(long)` method in `AudioSink`.
* Add private methods `setOutputStreamOffsetUs(long)` method in `MediaCodecRenderer` and `DecoderAudioRenderer`.
* Add protected method `onOutputStreamOffsetUs(long)` method in `MediaCodecRenderer`, in which:
  * `MediaCodecRenderer` itself will be no-op for this method.
  * `MediaCodecAudioRenderer` will propagate this value to its `audioSink`.
* Add logics in `DecoderAudioRenderer` to calculate `outputStreamOffsetUs`.

PiperOrigin-RevId: 479265429
(cherry picked from commit 4c73241058041fd978e9748b2158168d4e6e702d)
2022-10-06 09:58:37 +00:00
tonihei
e37f16a749 Fix RequestMetadata JavaDoc link to point to the right MediaController.
The JavaDoc of RequestMetadata should point to the media3 controller,
not the platform one.

PiperOrigin-RevId: 479047924
(cherry picked from commit 088958994776a65666045b3e7b332f5f0c336bcf)
2022-10-05 15:03:16 +00:00
claincly
92ceeda5b8 Add FrameProcessor functionality to release a frame immediately
Currently `FrameProcessor.releaseOutputFrame()` method supports

Release at a specific system time
Drops the frame
This API is not that convenient to use when the caller wants to release a frame, now, regardless of the release time. A use case is to release (present) a frame when no frame is shown for a while, and it's thus better to just release the frame, now.

Currently if MCVR wants a frame to be rendered now, MCVR calls release frame with a set offset like 10us: `releaseOutputFrame(System.nanoTime() + 10_000)`. The 10us offset is to prevent the frame processor dropping the frame, due to thread hopping delays.

To make the API better usable, consider adding a mode for releasing the frame now, like (bold marks the new mode)

- Use C.TIME_UNSET to drop
- **Use -1 to release the frame immediately, or**
- Use an actual release time.

PiperOrigin-RevId: 479044215
(cherry picked from commit ff8dd0b4b9aa498a831c9721c530e77bf099a4ed)
2022-10-05 14:45:27 +00:00
huangdarwin
a06b0ba5f6 HDR: Check isToneMappingApplied in HDR editing test.
Assert that tone mapping is applied when an HDR edit cannot be HDR, but is successfully tone mapped. Meanwhile, assert that fallback, which is applied after codec configuration (which throws the "Tone-mapping requested but not supported by the decoder" error) is not applied when that error is called.

PiperOrigin-RevId: 478762951
(cherry picked from commit 36e41059ea9e98aeab105375a683f7cd7481c5a8)
2022-10-04 13:01:27 +00:00
huangdarwin
2361213d8f HDR: Add tests with HLG10 input.
PiperOrigin-RevId: 478019046
(cherry picked from commit b9a3aa5ca1b7fb01fc6500a57d9ddcbba6ff9b54)
2022-09-30 17:02:37 +00:00
huangdarwin
fdd72aed5a Effect: Update javadoc to remove "final effect" references
"Final" was likely added to reference the FinalMatrixTextureProcessorWrapper,
which is a package-private class. However, I think more clear to express that
this is the input size, which then has all effects applied, to get the output
size.

PiperOrigin-RevId: 477975358
(cherry picked from commit 7286155fc327b1ffcd72903a739368b4bdeebcf8)
2022-09-30 13:24:26 +00:00
huangdarwin
b49c2aab62 Test: Rename to avoid redundant substrings.
Rename test files to avoid substrings that can be implied by the directory name,
like "Transformation" and "Test"

No functional changes. Renaming-only.

PiperOrigin-RevId: 477724724
(cherry picked from commit 97868025275e5fb6dd62e8407a7384ff44e204f6)
2022-09-29 14:54:25 +00:00
huangdarwin
09776f3d72 HDR: Add period to end of error message.
For tone mapping error messages.

PiperOrigin-RevId: 477447799
(cherry picked from commit 05ce639ea05b8806f6c8bae7d1816ddae5d99fb7)
2022-09-28 14:30:48 +00:00
huangdarwin
619333fe3c HDR: Add tests for tone mapping.
Also, add checks for output file color.

PiperOrigin-RevId: 477439139
(cherry picked from commit 507a1be61d24baf8fd26047938360db48dffabdb)
2022-09-28 13:42:36 +00:00
samrobinson
d348157777 Fix badly formatted AudioProcessor javadoc.
PiperOrigin-RevId: 476909855
(cherry picked from commit 9b1909e56362a5b44ba41d8cad9c3d927bdb650b)
2022-09-26 16:00:10 +00:00
tonihei
289d039410 Add setPreferredAudioDevice method to ExoPlayer
This allows to access the associated functionality of AudioTrack and
fills a feature gap to MediaPlayer, which has a similar method.

Issue: androidx/media#135
PiperOrigin-RevId: 476398964
(cherry picked from commit ccb820dd2f43ff20dff06a92a4e29c13676e647d)
2022-09-23 17:05:43 +00:00
leonwind
0a1f30aba5 Store LUT bitmap as texture with processor creation.
* Before this CL, the texture was stored during the construction of the LUT processor. This failed since if one creates a list of GlEffects on the application thread, the texture will get stored in the application thread during the effect creation and not on the GL thread, which executes the FrameProcessors.
* This is an issue since the executing thread then can't index from the texture stored on a different thread.

PiperOrigin-RevId: 476388021
(cherry picked from commit f745c6ee0ea0b610cfdf6a146818b0da7d06326a)
2022-09-23 16:19:43 +00:00
Marc Baechinger
d648c1910c Merge pull request #123 from stoyicker:wrapping_media_source
PiperOrigin-RevId: 476376463
(cherry picked from commit 8623f1f01657abc6a1359f3677a59d1cbde07b37)
2022-10-19 23:42:52 +00:00
michaelkatz
9ac9322a45 Try alternative decoder for Dolby Vision if display does not support
If the sample type is dolby vision and the following conditions match
a)There is a supported alternative codec mimetype
b)Display does not support Dolby Vision
Then getDecoderInfos will return the alternative types.

Issue: google/ExoPlayer#9794
PiperOrigin-RevId: 476356223
(cherry picked from commit 94a88e93d91e86c93239639a65612eab297efa9b)
2022-09-23 13:43:21 +00:00
huangdarwin
a3a08f8355 HDR: Assert output C.ColorTransfer for tests.
To confirm that tone mapping did or did not happen.

PiperOrigin-RevId: 476354606
(cherry picked from commit df58107eae0dd7e19f9b551751d1fbb19ca05e6d)
2022-09-23 13:33:28 +00:00
leonwind
a534f60f56 Add OETF and EOTF ES2 fragment shaders for non-HDR frames.
* Transform the intermediate color space to linear SDR by applying the SMPTE 170M EOTF and OETF.
* Use linear colors for the color filter pixel tests and update all golden bitmaps.

PiperOrigin-RevId: 476124592
(cherry picked from commit afd829e5db17c48abccea30842eec20b702aa330)
2022-09-22 16:45:28 +00:00
ibaker
eb496dabcd Work around a bug in the Android 13 ClearKey implementation
The ClearKey CDM will attach an 'invalid' URL in `KeyRequest` objects,
when the documentation states this should be an empty string if a
default URL is not known.

#minor-release

PiperOrigin-RevId: 476113513
(cherry picked from commit 331d4d626fcb1b65088c7ab849c0a0a3f5f6ba0e)
2022-09-22 15:59:44 +00:00
samrobinson
61acf5871a Add file size to TransformationResult at the end of a Transformation.
Tested:
  * Manually using both path and file descriptor.
PiperOrigin-RevId: 475860978
(cherry picked from commit 08bb01b218461506352ae4c2f17efd27989553e5)
2022-09-21 17:18:42 +00:00
rohks
a6f58bdb29 Fix instrumentation tests not working via Gradle
PiperOrigin-RevId: 475560401
(cherry picked from commit 6015f052ba1b21bea4ded5bfc4924dc1c096b07a)
2022-09-20 15:25:38 +00:00
yschimke
3af297101c Fix tracing under offload.
Currently doSomeWork is never closed and so tracing is deceiving.

See https://screenshot.googleplex.com/eZDzn5APpBNnhe5

PiperOrigin-RevId: 474755816
(cherry picked from commit 005b73c82a1a3264a7167ffdf93a9387c4d22b95)
2022-09-16 08:26:54 +00:00
samrobinson
3adfa48f34 Add support for skipping windows in MssimCalculator.
By skipping every other row and column, SSIM calculation time reduces by 10-30%.

PiperOrigin-RevId: 474286702
(cherry picked from commit 6dd2a6dac655f538020a4057e3ab6d997449a9fe)
2022-09-14 14:35:12 +00:00
samrobinson
766b9cd385 Clarify the replaceOutputBuffer parameter because count is unclear.
PiperOrigin-RevId: 474279220
(cherry picked from commit 3e0ad6d8042c9e6604c281e283885b9e07eb8786)
2022-09-14 13:54:06 +00:00
samrobinson
c4f4c42e1d Add MssimCalculatorTest to verify SSIM calculations.
As part of this change, MssimCalculator is moved from androidTest/ to main/

PiperOrigin-RevId: 473771344
(cherry picked from commit 20aa22c9fad2c1e2d237dc9a8bee81781a729445)
2022-09-12 16:45:36 +00:00
samrobinson
d10dbc56d5 Rollback of eb6c1183b6
*** Original commit ***

Handle int instead of byte in SSIM.

The value of pixels are converted to integers at the point of use,
move this logic to the initialisation step.

This is a prerequisite step for testing SSIM calculation, which
will lead on to some SSIM improvements being verifiable.

Tested manually and SSIM values match for the same video
before and after this change.

***

PiperOrigin-RevId: 473259446
(cherry picked from commit 8f9c9d0f88374573f32d76cf7d3a8fde9ca83f87)
2022-09-09 15:33:08 +00:00
samrobinson
c714b51c04 Handle int instead of byte in SSIM.
The value of pixels are converted to integers at the point of use,
move this logic to the initialisation step.

This is a prerequisite step for testing SSIM calculation, which
will lead on to some SSIM improvements being verifiable.

Tested manually and SSIM values match for the same video
before and after this change.

PiperOrigin-RevId: 473231779
(cherry picked from commit eb6c1183b69d319a610d79ef57028f62e74a7614)
2022-09-09 13:07:14 +00:00
huangdarwin
e725600b0c Decoder: Reduce max pending frame count limit down to 5.
PiperOrigin-RevId: 473212543
(cherry picked from commit 41963fce9b7ad7d2cd9d0fdb428c44eb2bddf5f1)
2022-09-09 10:56:03 +00:00
huangdarwin
8eab7391c2 HDR: Add fallback MH tests.
Test that HDR editing succeeds on devices supporting HDR editing, tone maps on
devices supporting tone mapping, and throws exceptions on all other devices.

Also, only restrict HDR editing and tone mapping support to API 31+ only when
transcoding, not for all transformations.

PiperOrigin-RevId: 472958965
(cherry picked from commit 8ee2121627c2702419402b514fa93dbe8ac19b8b)
2022-09-08 12:03:40 +00:00
claincly
ce4ba2b6de Remove conditional check for no-longer flaky API version
PiperOrigin-RevId: 472949850
(cherry picked from commit caefa565f76912922011155cc580d45243e86ecc)
2022-09-08 11:02:51 +00:00
bachinger
b47c7a37ac Add withAvailableAd for server side inserted ad groups
#minor-release

PiperOrigin-RevId: 472714732
(cherry picked from commit 072f376b4839b6d4e71bcd09366695b3b9fc2c02)
2022-09-07 14:01:26 +00:00
tonihei
8df931b1fe Discard backbuffer before playback gets stuck.
If the back buffer is using too much memory, there is a risk
playback could get stuck because LoadControl refuses to load
further data. This eventually results in a stuck-buffering
playback error.

We can detect this case, clear the back buffer and then ask
the LoadControl again to avoid failing playback in such a case.

PiperOrigin-RevId: 472679797
(cherry picked from commit 125646e4c98e80b35d1a8b195300d324a9aaf2b5)
2022-09-07 10:09:29 +00:00
claincly
7acffcfe34 Remove redundant constant definition
PiperOrigin-RevId: 472522846
(cherry picked from commit 9a9baa54a5cdf701695556a91436b2778868cddd)
2022-09-06 19:06:17 +00:00
bachinger
d7d75a0157 Update presentation time of metadata when the stream offset changes
The stream offset is used to calculate the presentation time of
a metadata object when reading and later when playing, to calculate
the current presentation time to decide whether to send the metadata
to the output.

Accordingly, the presentation time of a pending metadata that has been
calculated with a given offset needs to be recalculated when the
stream offset changes.

#minor-release

PiperOrigin-RevId: 472499943
(cherry picked from commit 5a1223777c4d4ee2faa4043be2079971e44093a9)
2022-09-06 17:40:52 +00:00
Marc Baechinger
d2623dda9b Merge pull request #10549 from ferhatparmak:release-requirementswatcher
PiperOrigin-RevId: 472488921
(cherry picked from commit 92cfa7467b8f74daab22276c6db4e885b76e7c28)
2022-10-19 21:14:45 +00:00
Marc Baechinger
0a0df93334 Merge pull request #10570 from Artemych:fix/progressive_downloader_infinite_loop
PiperOrigin-RevId: 472475124
(cherry picked from commit 9c56b2c4b631062731ccfc0d8e5b5c105449074c)
2022-10-19 21:10:57 +00:00
claincly
912da2910c Include CamcorderProfile resolution in encoder capability test
PiperOrigin-RevId: 472459423
(cherry picked from commit 6e45824992c8fe72ffd2f4edb726aa0cd8f8c29e)
2022-09-06 15:05:46 +00:00
Googler
ec91dfc693 Fix 3 ErrorProneStyle findings:
* Non-standard parameter comment; prefer `/* paramName= */ arg`
  (see http://go/bugpattern/ParameterComment) (3 times)

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/error-prone-bug for category ErrorProneStyle if there's an issue with the CL content.
* File a bug under go/rosie-bug if there's an issue with how the CL was managed.
* Revert this CL and not get a CL that cleans up these paths in the future by
replying "BLOCKLIST: <provide reason>". This is not reversible! We recommend to
opt out the respective paths in your CL Robot configuration instead:
go/clrobot-opt-out.

This CL was generated by CL Robot - a tool that cleans up code findings
(go/clrobot). The affected code paths have been enabled for CL Robot in //depot/google3/java/com/google/android/libraries/media/METADATA which is reachable following include_presubmits from //depot/google3/third_party/java_src/android_libs/media/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

#codehealth

Tested:
    Local presubmit tests passed.
PiperOrigin-RevId: 472254253
(cherry picked from commit 83966478960ae6c0f882e523d73848edab95fd3a)
2022-09-05 12:08:04 +00:00
huangdarwin
fdffdfeeb6 Minor javadoc and scoping cleanup.
No functional changes.

PiperOrigin-RevId: 472245797
(cherry picked from commit 8e14611d60d40f0db41063a5e537638b76c2d46a)
2022-09-05 11:06:21 +00:00
huangdarwin
f52a3c2240 Rename shouldPassthrough to shouldTranscode
shouldPassthrough's internal checks seem to be check whether we should *not*
pass through, which seemed a bit like a confusing double-negative to me.

shouldTranscode is slightly more clear, by instead returning true when we do
want to transcode.

No functional changes intended.

PiperOrigin-RevId: 471753771
(cherry picked from commit 1a4cd549a426881474014a02b595382b375864ee)
2022-09-02 09:49:26 +00:00
Googler
61374d1698 Skip transcoding if HDR video does not need encoding.
3b0d2c1586 made `shouldPassthrough` always return false for `enableHdrVideoEditing`:

>We force using `FrameEditor` (no passthrough) to avoid the need to select another edit operation, and use the new shaders. The `EGLContext` and `EGLSurface` also need to be set up differently for this path.

However, this was introduced before the `videoNeedsEncoding` setting was introduced in 3f615040c0. That setting should apply to HDR videos as much as SDR videos.

PiperOrigin-RevId: 471569853
(cherry picked from commit 94713a8ffb6ba4e83a05bb50921b4cf2ab2eab75)
2022-09-01 17:37:30 +00:00
Googler
4d4af37637 Fix 3 ErrorProneStyle findings:
* Non-standard parameter comment; prefer `/* paramName= */ arg`
  (see http://go/bugpattern/ParameterComment) (3 times)

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/error-prone-bug for category ErrorProneStyle if there's an issue with the CL content.
* File a bug under go/rosie-bug if there's an issue with how the CL was managed.
* Revert this CL and not get a CL that cleans up these paths in the future by
replying "BLOCKLIST: <provide reason>". This is not reversible! We recommend to
opt out the respective paths in your CL Robot configuration instead:
go/clrobot-opt-out.

This CL was generated by CL Robot - a tool that cleans up code findings
(go/clrobot). The affected code paths have been enabled for CL Robot in //depot/google3/java/com/google/android/libraries/media/METADATA which is reachable following include_presubmits from //depot/google3/third_party/java_src/android_libs/media/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

#codehealth

Tested:
    Local presubmit tests passed.
PiperOrigin-RevId: 471198016
(cherry picked from commit bac7d697c3620195f8895068369099466fb7bd1c)
2022-08-31 08:29:19 +00:00
Googler
ba01d04ed5 Add @SuppressWarnings to nullness errors detected by a newer version of the Checker Framework
PiperOrigin-RevId: 471137219
(cherry picked from commit 90e684a6dcd5d92470780060feb2099c2f905bbd)
2022-08-31 01:09:09 +00:00
huangdarwin
53b1cabef8 Effect: Add some FrameProcessor javadoc.
In particular, make it a bit more clear that "rendering" and "releasing" frames are
related concepts, and how they differ from one another in conjunction with frame
dropping.

PiperOrigin-RevId: 471037733
(cherry picked from commit e6a1936ba9e210555eaa61a9b6d206bdfa753f09)
2022-08-30 18:01:11 +00:00
Googler
fc8edfcd48 Fix 19 ErrorProneStyle findings:
* Non-standard parameter comment; prefer `/* paramName= */ arg`
  (see http://go/bugpattern/ParameterComment) (19 times)

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/error-prone-bug for category ErrorProneStyle if there's an issue with the CL content.
* File a bug under go/rosie-bug if there's an issue with how the CL was managed.
* Revert this CL and not get a CL that cleans up these paths in the future by
replying "BLOCKLIST: <provide reason>". This is not reversible! We recommend to
opt out the respective paths in your CL Robot configuration instead:
go/clrobot-opt-out.

This CL was generated by CL Robot - a tool that cleans up code findings
(go/clrobot). The affected code paths have been enabled for CL Robot in //depot/google3/java/com/google/android/libraries/media/METADATA which is reachable following include_presubmits from //depot/google3/third_party/java_src/android_libs/media/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

#codehealth

Tested:
    Local presubmit tests passed.
PiperOrigin-RevId: 471022923
(cherry picked from commit 674b3d4575ae6fdb59ae9db58be52151bbcae3a6)
2022-08-30 17:07:31 +00:00
ibaker
b6fecfc18a Remove media3-only line from exoplayer2 build.gradle file
#minor-release

PiperOrigin-RevId: 470999044
(cherry picked from commit e285e7078545435e86e3d43219ad9f6fc8373755)
2022-08-30 15:27:12 +00:00