Set image tile counts to what the manifest says

Vertical and horizontal tile counts inside Format used by ImageRenderer
used to be required to equal 1 and were set to 1 regardless of what
the manifest said.

This change removes the above requirement and sets the tile counts to
the values from the manifest.

PiperOrigin-RevId: 590608353
This commit is contained in:
lpribanic 2023-12-13 08:33:39 -08:00 committed by Copybara-Service
parent b1d65f6d00
commit d52772dff8
4 changed files with 9 additions and 46 deletions

View File

@ -998,6 +998,8 @@ public final class Format implements Bundleable {
// Use manifest value only.
@Nullable String id = manifestFormat.id;
int tileCountHorizontal = manifestFormat.tileCountHorizontal;
int tileCountVertical = manifestFormat.tileCountVertical;
// Prefer manifest values, but fill in from sample format if missing.
@Nullable String label = manifestFormat.label != null ? manifestFormat.label : this.label;
@ -1051,6 +1053,8 @@ public final class Format implements Bundleable {
.setMetadata(metadata)
.setDrmInitData(drmInitData)
.setFrameRate(frameRate)
.setTileCountHorizontal(tileCountHorizontal)
.setTileCountVertical(tileCountVertical)
.build();
}

View File

@ -94,9 +94,6 @@ public final class BitmapFactoryImageDecoder
if (!MimeTypes.isImage(format.containerMimeType)) {
return RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE);
}
if (format.tileCountHorizontal != 1 || format.tileCountVertical != 1) {
return RendererCapabilities.create(C.FORMAT_EXCEEDS_CAPABILITIES);
}
return SUPPORTED_IMAGE_TYPES.contains(format.containerMimeType)
? RendererCapabilities.create(C.FORMAT_HANDLED)
: RendererCapabilities.create(C.FORMAT_UNSUPPORTED_SUBTYPE);

View File

@ -35,48 +35,15 @@ public class BitmapFactoryImageDecoderFactoryTest {
@Test
public void supportsFormat_validFormat_returnsFormatSupported() throws Exception {
Format.Builder format =
new Format.Builder()
.setContainerMimeType(MimeTypes.IMAGE_JPEG)
.setTileCountVertical(1)
.setTileCountHorizontal(1);
Format.Builder format = new Format.Builder().setContainerMimeType(MimeTypes.IMAGE_JPEG);
assertThat(imageDecoderFactory.supportsFormat(format.build()))
.isEqualTo(RendererCapabilities.create(C.FORMAT_HANDLED));
}
@Test
public void supportsFormat_unsetTileCounts_returnsExceedsCapabilities() throws Exception {
Format.Builder format = new Format.Builder().setContainerMimeType(MimeTypes.IMAGE_JPEG);
assertThat(imageDecoderFactory.supportsFormat(format.build()))
.isEqualTo(RendererCapabilities.create(C.FORMAT_EXCEEDS_CAPABILITIES));
}
@Test
public void supportsFormat_unsetTileCountVertical_returnsExceedsCapabilities() throws Exception {
Format.Builder format = new Format.Builder().setContainerMimeType(MimeTypes.IMAGE_JPEG);
format.setTileCountVertical(1);
assertThat(imageDecoderFactory.supportsFormat(format.build()))
.isEqualTo(RendererCapabilities.create(C.FORMAT_EXCEEDS_CAPABILITIES));
}
@Test
public void supportsFormat_unsetTileCountHorizontal_returnsExceedsCapabilities()
throws Exception {
Format.Builder format = new Format.Builder().setContainerMimeType(MimeTypes.IMAGE_JPEG);
format.setTileCountHorizontal(1);
assertThat(imageDecoderFactory.supportsFormat(format.build()))
.isEqualTo(RendererCapabilities.create(C.FORMAT_EXCEEDS_CAPABILITIES));
}
@Test
public void supportsFormat_noContainerMimeType_returnsUnsupportedType() throws Exception {
Format.Builder format = new Format.Builder().setTileCountHorizontal(1).setTileCountVertical(1);
Format.Builder format = new Format.Builder();
assertThat(imageDecoderFactory.supportsFormat(format.build()))
.isEqualTo(RendererCapabilities.create(C.FORMAT_UNSUPPORTED_TYPE));
@ -84,7 +51,7 @@ public class BitmapFactoryImageDecoderFactoryTest {
@Test
public void supportsFormat_nonImageMimeType_returnsUnsupportedType() throws Exception {
Format.Builder format = new Format.Builder().setTileCountHorizontal(1).setTileCountVertical(1);
Format.Builder format = new Format.Builder();
format.setContainerMimeType(MimeTypes.VIDEO_AV1);
@ -94,7 +61,7 @@ public class BitmapFactoryImageDecoderFactoryTest {
@Test
public void supportsFormat_unsupportedImageMimeType_returnsUnsupportedSubType() throws Exception {
Format.Builder format = new Format.Builder().setTileCountHorizontal(1).setTileCountVertical(1);
Format.Builder format = new Format.Builder();
format.setContainerMimeType("image/custom");

View File

@ -139,12 +139,7 @@ public final class SingleSampleExtractor implements Extractor {
@RequiresNonNull("this.extractorOutput")
private void outputImageTrackAndSeekMap(String containerMimeType) {
trackOutput = extractorOutput.track(IMAGE_TRACK_ID, C.TRACK_TYPE_IMAGE);
trackOutput.format(
new Format.Builder()
.setContainerMimeType(containerMimeType)
.setTileCountHorizontal(1)
.setTileCountVertical(1)
.build());
trackOutput.format(new Format.Builder().setContainerMimeType(containerMimeType).build());
extractorOutput.endTracks();
extractorOutput.seekMap(new SingleSampleSeekMap(/* durationUs= */ C.TIME_UNSET));
state = STATE_READING;