mirror of
https://github.com/androidx/media.git
synced 2025-05-03 21:57:46 +08:00
Allow video format filtering without viewport constraint.
This commit is contained in:
parent
80e829d7d1
commit
e65f726458
@ -82,10 +82,10 @@ public final class VideoFormatSelectorUtil {
|
|||||||
* viewport during playback.
|
* viewport during playback.
|
||||||
* @param viewportWidth The width in pixels of the viewport within which the video will be
|
* @param viewportWidth The width in pixels of the viewport within which the video will be
|
||||||
* displayed. If the viewport size may change, this should be set to the maximum possible
|
* displayed. If the viewport size may change, this should be set to the maximum possible
|
||||||
* width.
|
* width. -1 if selection should not be constrained by a viewport.
|
||||||
* @param viewportHeight The height in pixels of the viewport within which the video will be
|
* @param viewportHeight The height in pixels of the viewport within which the video will be
|
||||||
* displayed. If the viewport size may change, this should be set to the maximum possible
|
* displayed. If the viewport size may change, this should be set to the maximum possible
|
||||||
* height.
|
* height. -1 if selection should not be constrained by a viewport.
|
||||||
* @return An array holding the indices of the selected formats.
|
* @return An array holding the indices of the selected formats.
|
||||||
* @throws DecoderQueryException
|
* @throws DecoderQueryException
|
||||||
*/
|
*/
|
||||||
@ -107,7 +107,7 @@ public final class VideoFormatSelectorUtil {
|
|||||||
// Keep track of the number of pixels of the selected format whose resolution is the
|
// Keep track of the number of pixels of the selected format whose resolution is the
|
||||||
// smallest to exceed the maximum size at which it can be displayed within the viewport.
|
// smallest to exceed the maximum size at which it can be displayed within the viewport.
|
||||||
// We'll discard formats of higher resolution in a second pass.
|
// We'll discard formats of higher resolution in a second pass.
|
||||||
if (format.width > 0 && format.height > 0) {
|
if (format.width > 0 && format.height > 0 && viewportWidth > 0 && viewportHeight > 0) {
|
||||||
Point maxVideoSizeInViewport = getMaxVideoSizeInViewport(orientationMayChange,
|
Point maxVideoSizeInViewport = getMaxVideoSizeInViewport(orientationMayChange,
|
||||||
viewportWidth, viewportHeight, format.width, format.height);
|
viewportWidth, viewportHeight, format.width, format.height);
|
||||||
int videoPixels = format.width * format.height;
|
int videoPixels = format.width * format.height;
|
||||||
@ -123,11 +123,13 @@ public final class VideoFormatSelectorUtil {
|
|||||||
// Second pass to filter out formats that exceed maxVideoPixelsToRetain. These formats are have
|
// Second pass to filter out formats that exceed maxVideoPixelsToRetain. These formats are have
|
||||||
// unnecessarily high resolution given the size at which the video will be displayed within the
|
// unnecessarily high resolution given the size at which the video will be displayed within the
|
||||||
// viewport.
|
// viewport.
|
||||||
for (int i = selectedIndexList.size() - 1; i >= 0; i--) {
|
if (maxVideoPixelsToRetain != Integer.MAX_VALUE) {
|
||||||
Format format = formatWrappers.get(selectedIndexList.get(i)).getFormat();
|
for (int i = selectedIndexList.size() - 1; i >= 0; i--) {
|
||||||
if (format.width > 0 && format.height > 0
|
Format format = formatWrappers.get(selectedIndexList.get(i)).getFormat();
|
||||||
&& format.width * format.height > maxVideoPixelsToRetain) {
|
if (format.width > 0 && format.height > 0
|
||||||
selectedIndexList.remove(i);
|
&& format.width * format.height > maxVideoPixelsToRetain) {
|
||||||
|
selectedIndexList.remove(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user