mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Test: Use AssumptionViolatedException for OpenGL Tone-map support.
PiperOrigin-RevId: 616827385
This commit is contained in:
parent
0731b07954
commit
4c85a04d07
4 changed files with 23 additions and 41 deletions
|
|
@ -38,26 +38,24 @@ public final class HdrCapabilitiesUtil {
|
||||||
private static final String SKIP_REASON_NO_YUV = "Device lacks YUV extension support.";
|
private static final String SKIP_REASON_NO_YUV = "Device lacks YUV extension support.";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the test should be skipped because the device is incapable of tone-mapping the
|
* Assumes that the device supports OpenGL tone-mapping for the {@code inputFormat}.
|
||||||
* {@code inputFormat} using OpenGL.
|
|
||||||
*
|
*
|
||||||
* <p>If the test should be skipped, logs the reason for skipping.
|
* @throws AssumptionViolatedException if the device does not support OpenGL tone-mapping.
|
||||||
*/
|
*/
|
||||||
public static boolean skipAndLogIfOpenGlToneMappingUnsupported(String testId, Format inputFormat)
|
public static void assumeDeviceSupportsOpenGlToneMapping(String testId, Format inputFormat)
|
||||||
throws JSONException, IOException, MediaCodecUtil.DecoderQueryException {
|
throws JSONException, IOException, MediaCodecUtil.DecoderQueryException {
|
||||||
Context context = getApplicationContext();
|
Context context = getApplicationContext();
|
||||||
if (Util.SDK_INT < 29) {
|
if (Util.SDK_INT < 29) {
|
||||||
recordTestSkipped(context, testId, SKIP_REASON_NO_OPENGL_UNDER_API_29);
|
recordTestSkipped(context, testId, SKIP_REASON_NO_OPENGL_UNDER_API_29);
|
||||||
return true;
|
throw new AssumptionViolatedException(SKIP_REASON_NO_OPENGL_UNDER_API_29);
|
||||||
}
|
}
|
||||||
if (!GlUtil.isYuvTargetExtensionSupported()) {
|
if (!GlUtil.isYuvTargetExtensionSupported()) {
|
||||||
recordTestSkipped(context, testId, SKIP_REASON_NO_YUV);
|
recordTestSkipped(context, testId, SKIP_REASON_NO_YUV);
|
||||||
return true;
|
throw new AssumptionViolatedException(SKIP_REASON_NO_YUV);
|
||||||
}
|
}
|
||||||
if (skipAndLogIfFormatsUnsupported(context, testId, inputFormat, /* outputFormat= */ null)) {
|
if (skipAndLogIfFormatsUnsupported(context, testId, inputFormat, /* outputFormat= */ null)) {
|
||||||
return true;
|
throw new AssumptionViolatedException("Input format is unsupported: " + inputFormat);
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import static androidx.media3.common.MimeTypes.VIDEO_H265;
|
||||||
import static androidx.media3.test.utils.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888;
|
import static androidx.media3.test.utils.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888;
|
||||||
import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmap;
|
import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmap;
|
||||||
import static androidx.media3.transformer.AndroidTestUtil.recordTestSkipped;
|
import static androidx.media3.transformer.AndroidTestUtil.recordTestSkipped;
|
||||||
import static androidx.media3.transformer.mh.HdrCapabilitiesUtil.skipAndLogIfOpenGlToneMappingUnsupported;
|
import static androidx.media3.transformer.mh.HdrCapabilitiesUtil.assumeDeviceSupportsOpenGlToneMapping;
|
||||||
import static androidx.media3.transformer.mh.UnoptimizedGlEffect.NO_OP_EFFECT;
|
import static androidx.media3.transformer.mh.UnoptimizedGlEffect.NO_OP_EFFECT;
|
||||||
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
|
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
@ -137,9 +137,7 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void toneMap_hlgFrame_matchesGoldenFile() throws Exception {
|
public void toneMap_hlgFrame_matchesGoldenFile() throws Exception {
|
||||||
if (skipAndLogIfOpenGlToneMappingUnsupported(testId, HLG_ASSET_FORMAT)) {
|
assumeDeviceSupportsOpenGlToneMapping(testId, HLG_ASSET_FORMAT);
|
||||||
return;
|
|
||||||
}
|
|
||||||
videoFrameProcessorTestRunner =
|
videoFrameProcessorTestRunner =
|
||||||
getDefaultFrameProcessorTestRunnerBuilder(testId)
|
getDefaultFrameProcessorTestRunnerBuilder(testId)
|
||||||
.setVideoAssetPath(HLG_ASSET_STRING)
|
.setVideoAssetPath(HLG_ASSET_STRING)
|
||||||
|
|
@ -174,9 +172,7 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void toneMapWithNoOpEffect_hlgFrame_matchesGoldenFile() throws Exception {
|
public void toneMapWithNoOpEffect_hlgFrame_matchesGoldenFile() throws Exception {
|
||||||
if (skipAndLogIfOpenGlToneMappingUnsupported(testId, HLG_ASSET_FORMAT)) {
|
assumeDeviceSupportsOpenGlToneMapping(testId, HLG_ASSET_FORMAT);
|
||||||
return;
|
|
||||||
}
|
|
||||||
videoFrameProcessorTestRunner =
|
videoFrameProcessorTestRunner =
|
||||||
getDefaultFrameProcessorTestRunnerBuilder(testId)
|
getDefaultFrameProcessorTestRunnerBuilder(testId)
|
||||||
.setVideoAssetPath(HLG_ASSET_STRING)
|
.setVideoAssetPath(HLG_ASSET_STRING)
|
||||||
|
|
@ -212,9 +208,7 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void toneMap_pqFrame_matchesGoldenFile() throws Exception {
|
public void toneMap_pqFrame_matchesGoldenFile() throws Exception {
|
||||||
if (skipAndLogIfOpenGlToneMappingUnsupported(testId, PQ_ASSET_FORMAT)) {
|
assumeDeviceSupportsOpenGlToneMapping(testId, PQ_ASSET_FORMAT);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
videoFrameProcessorTestRunner =
|
videoFrameProcessorTestRunner =
|
||||||
getDefaultFrameProcessorTestRunnerBuilder(testId)
|
getDefaultFrameProcessorTestRunnerBuilder(testId)
|
||||||
|
|
@ -250,9 +244,7 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void toneMapWithNoOpEffect_pqFrame_matchesGoldenFile() throws Exception {
|
public void toneMapWithNoOpEffect_pqFrame_matchesGoldenFile() throws Exception {
|
||||||
if (skipAndLogIfOpenGlToneMappingUnsupported(testId, PQ_ASSET_FORMAT)) {
|
assumeDeviceSupportsOpenGlToneMapping(testId, PQ_ASSET_FORMAT);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
videoFrameProcessorTestRunner =
|
videoFrameProcessorTestRunner =
|
||||||
getDefaultFrameProcessorTestRunnerBuilder(testId)
|
getDefaultFrameProcessorTestRunnerBuilder(testId)
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET_720P_4_SECON
|
||||||
import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET_720P_4_SECOND_HDR10_FORMAT;
|
import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET_720P_4_SECOND_HDR10_FORMAT;
|
||||||
import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET_DOLBY_VISION_HDR;
|
import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET_DOLBY_VISION_HDR;
|
||||||
import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET_DOLBY_VISION_HDR_FORMAT;
|
import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET_DOLBY_VISION_HDR_FORMAT;
|
||||||
import static androidx.media3.transformer.mh.HdrCapabilitiesUtil.skipAndLogIfOpenGlToneMappingUnsupported;
|
import static androidx.media3.transformer.mh.HdrCapabilitiesUtil.assumeDeviceSupportsOpenGlToneMapping;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
@ -60,30 +60,24 @@ public class ToneMapHdrToSdrUsingOpenGlTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void export_toneMap_hlg10File_toneMaps() throws Exception {
|
public void export_toneMap_hlg10File_toneMaps() throws Exception {
|
||||||
if (skipAndLogIfOpenGlToneMappingUnsupported(
|
assumeDeviceSupportsOpenGlToneMapping(
|
||||||
testId, /* inputFormat= */ MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT)) {
|
testId, /* inputFormat= */ MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
runTransformerWithOpenGlToneMapping(testId, MP4_ASSET_1080P_5_SECOND_HLG10);
|
runTransformerWithOpenGlToneMapping(testId, MP4_ASSET_1080P_5_SECOND_HLG10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void export_toneMap_hdr10File_toneMaps() throws Exception {
|
public void export_toneMap_hdr10File_toneMaps() throws Exception {
|
||||||
if (skipAndLogIfOpenGlToneMappingUnsupported(
|
assumeDeviceSupportsOpenGlToneMapping(
|
||||||
testId, /* inputFormat= */ MP4_ASSET_720P_4_SECOND_HDR10_FORMAT)) {
|
testId, /* inputFormat= */ MP4_ASSET_720P_4_SECOND_HDR10_FORMAT);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
runTransformerWithOpenGlToneMapping(testId, MP4_ASSET_720P_4_SECOND_HDR10);
|
runTransformerWithOpenGlToneMapping(testId, MP4_ASSET_720P_4_SECOND_HDR10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void export_toneMap_dolbyVisionFile_toneMaps() throws Exception {
|
public void export_toneMap_dolbyVisionFile_toneMaps() throws Exception {
|
||||||
if (skipAndLogIfOpenGlToneMappingUnsupported(
|
assumeDeviceSupportsOpenGlToneMapping(
|
||||||
testId, /* inputFormat= */ MP4_ASSET_DOLBY_VISION_HDR_FORMAT)) {
|
testId, /* inputFormat= */ MP4_ASSET_DOLBY_VISION_HDR_FORMAT);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
runTransformerWithOpenGlToneMapping(testId, MP4_ASSET_DOLBY_VISION_HDR);
|
runTransformerWithOpenGlToneMapping(testId, MP4_ASSET_DOLBY_VISION_HDR);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ import static androidx.media3.transformer.SequenceEffectTestUtil.assertBitmapsMa
|
||||||
import static androidx.media3.transformer.SequenceEffectTestUtil.clippedVideo;
|
import static androidx.media3.transformer.SequenceEffectTestUtil.clippedVideo;
|
||||||
import static androidx.media3.transformer.SequenceEffectTestUtil.createComposition;
|
import static androidx.media3.transformer.SequenceEffectTestUtil.createComposition;
|
||||||
import static androidx.media3.transformer.mh.HdrCapabilitiesUtil.assumeDeviceSupportsHdrEditing;
|
import static androidx.media3.transformer.mh.HdrCapabilitiesUtil.assumeDeviceSupportsHdrEditing;
|
||||||
import static androidx.media3.transformer.mh.HdrCapabilitiesUtil.skipAndLogIfOpenGlToneMappingUnsupported;
|
import static androidx.media3.transformer.mh.HdrCapabilitiesUtil.assumeDeviceSupportsOpenGlToneMapping;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static org.junit.Assume.assumeFalse;
|
import static org.junit.Assume.assumeFalse;
|
||||||
|
|
||||||
|
|
@ -80,9 +80,8 @@ public final class TransformerSequenceEffectTestWithHdr {
|
||||||
@Test
|
@Test
|
||||||
@RequiresNonNull("testId")
|
@RequiresNonNull("testId")
|
||||||
public void export_withSdrThenHdr() throws Exception {
|
public void export_withSdrThenHdr() throws Exception {
|
||||||
assumeFalse(
|
assumeDeviceSupportsOpenGlToneMapping(
|
||||||
skipAndLogIfOpenGlToneMappingUnsupported(
|
testId, /* inputFormat= */ MP4_ASSET_720P_4_SECOND_HDR10_FORMAT);
|
||||||
testId, /* inputFormat= */ MP4_ASSET_720P_4_SECOND_HDR10_FORMAT));
|
|
||||||
Composition composition =
|
Composition composition =
|
||||||
createComposition(
|
createComposition(
|
||||||
Presentation.createForHeight(EXPORT_HEIGHT),
|
Presentation.createForHeight(EXPORT_HEIGHT),
|
||||||
|
|
@ -157,9 +156,8 @@ public final class TransformerSequenceEffectTestWithHdr {
|
||||||
@RequiresNonNull("testId")
|
@RequiresNonNull("testId")
|
||||||
public void export_withHdrThenSdr_whenHdrEditingUnsupported() throws Exception {
|
public void export_withHdrThenSdr_whenHdrEditingUnsupported() throws Exception {
|
||||||
assumeDeviceSupportsHdrEditing(testId, MP4_ASSET_720P_4_SECOND_HDR10_FORMAT);
|
assumeDeviceSupportsHdrEditing(testId, MP4_ASSET_720P_4_SECOND_HDR10_FORMAT);
|
||||||
assumeFalse(
|
assumeDeviceSupportsOpenGlToneMapping(
|
||||||
skipAndLogIfOpenGlToneMappingUnsupported(
|
testId, /* inputFormat= */ MP4_ASSET_720P_4_SECOND_HDR10_FORMAT);
|
||||||
testId, /* inputFormat= */ MP4_ASSET_720P_4_SECOND_HDR10_FORMAT));
|
|
||||||
assumeFalse(
|
assumeFalse(
|
||||||
skipAndLogIfFormatsUnsupported(
|
skipAndLogIfFormatsUnsupported(
|
||||||
context,
|
context,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue