HDR: Use better color test.

Our previous test video was difficult to use for testing our tone-mapping
algorithm, because it didn't have many different colors. Use a better
video for tone-map tests, by having one with more different colors

PiperOrigin-RevId: 606274843
This commit is contained in:
huangdarwin 2024-02-12 09:26:47 -08:00 committed by Copybara-Service
parent 2594691950
commit 69f651a40d
5 changed files with 42 additions and 12 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 695 KiB

After

Width:  |  Height:  |  Size: 8.5 MiB

View File

@ -15,10 +15,9 @@
*/ */
package androidx.media3.transformer.mh; package androidx.media3.transformer.mh;
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.MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT;
import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET_720P_4_SECOND_HDR10_FORMAT;
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.skipAndLogIfOpenGlToneMappingUnsupported;
import static androidx.media3.transformer.mh.UnoptimizedGlEffect.NO_OP_EFFECT; import static androidx.media3.transformer.mh.UnoptimizedGlEffect.NO_OP_EFFECT;
@ -29,6 +28,7 @@ import android.graphics.Bitmap;
import android.util.Log; import android.util.Log;
import androidx.media3.common.C; import androidx.media3.common.C;
import androidx.media3.common.ColorInfo; import androidx.media3.common.ColorInfo;
import androidx.media3.common.Format;
import androidx.media3.effect.DefaultVideoFrameProcessor; import androidx.media3.effect.DefaultVideoFrameProcessor;
import androidx.media3.test.utils.DecodeOneFrameUtil; import androidx.media3.test.utils.DecodeOneFrameUtil;
import androidx.media3.test.utils.VideoFrameProcessorTestRunner; import androidx.media3.test.utils.VideoFrameProcessorTestRunner;
@ -68,10 +68,40 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest {
"media/bitmap/sample_mp4_first_frame/electrical_colors/tone_map_pq_to_sdr.png"; "media/bitmap/sample_mp4_first_frame/electrical_colors/tone_map_pq_to_sdr.png";
/** Input HLG video of which we only use the first frame. */ /** Input HLG video of which we only use the first frame. */
private static final String INPUT_HLG_MP4_ASSET_STRING = "media/mp4/hlg-1080p.mp4"; private static final String HLG_ASSET_STRING = "media/mp4/hlg10-color-test.mp4";
private static final Format HLG_ASSET_FORMAT =
new Format.Builder()
.setSampleMimeType(VIDEO_H265)
.setWidth(1920)
.setHeight(1080)
.setFrameRate(30.000f)
.setColorInfo(
new ColorInfo.Builder()
.setColorSpace(C.COLOR_SPACE_BT2020)
.setColorRange(C.COLOR_RANGE_LIMITED)
.setColorTransfer(C.COLOR_TRANSFER_HLG)
.build())
.setCodecs("hvc1.2.4.L153")
.build();
/** Input PQ video of which we only use the first frame. */ /** Input PQ video of which we only use the first frame. */
private static final String INPUT_PQ_MP4_ASSET_STRING = "media/mp4/hdr10-720p.mp4"; private static final String PQ_ASSET_STRING = "media/mp4/hdr10plus-color-test.mp4";
public static final Format PQ_ASSET_FORMAT =
new Format.Builder()
.setSampleMimeType(VIDEO_H265)
.setWidth(3840)
.setHeight(2160)
.setFrameRate(29.024f)
.setColorInfo(
new ColorInfo.Builder()
.setColorSpace(C.COLOR_SPACE_BT2020)
.setColorRange(C.COLOR_RANGE_LIMITED)
.setColorTransfer(C.COLOR_TRANSFER_ST2084)
.build())
.setCodecs("hvc1.2.4.L153")
.build();
private static final ColorInfo TONE_MAP_SDR_COLOR = private static final ColorInfo TONE_MAP_SDR_COLOR =
new ColorInfo.Builder() new ColorInfo.Builder()
@ -92,12 +122,12 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest {
@Test @Test
public void toneMap_hlgFrame_matchesGoldenFile() throws Exception { public void toneMap_hlgFrame_matchesGoldenFile() throws Exception {
String testId = "toneMap_hlgFrame_matchesGoldenFile"; String testId = "toneMap_hlgFrame_matchesGoldenFile";
if (skipAndLogIfOpenGlToneMappingUnsupported(testId, MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT)) { if (skipAndLogIfOpenGlToneMappingUnsupported(testId, HLG_ASSET_FORMAT)) {
return; return;
} }
videoFrameProcessorTestRunner = videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId) getDefaultFrameProcessorTestRunnerBuilder(testId)
.setVideoAssetPath(INPUT_HLG_MP4_ASSET_STRING) .setVideoAssetPath(HLG_ASSET_STRING)
.setOutputColorInfo(TONE_MAP_SDR_COLOR) .setOutputColorInfo(TONE_MAP_SDR_COLOR)
.build(); .build();
Bitmap expectedBitmap = readBitmap(TONE_MAP_HLG_TO_SDR_PNG_ASSET_PATH); Bitmap expectedBitmap = readBitmap(TONE_MAP_HLG_TO_SDR_PNG_ASSET_PATH);
@ -130,12 +160,12 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest {
@Test @Test
public void toneMapWithNoOpEffect_hlgFrame_matchesGoldenFile() throws Exception { public void toneMapWithNoOpEffect_hlgFrame_matchesGoldenFile() throws Exception {
String testId = "toneMapWithNoOpEffect_hlgFrame_matchesGoldenFile"; String testId = "toneMapWithNoOpEffect_hlgFrame_matchesGoldenFile";
if (skipAndLogIfOpenGlToneMappingUnsupported(testId, MP4_ASSET_1080P_5_SECOND_HLG10_FORMAT)) { if (skipAndLogIfOpenGlToneMappingUnsupported(testId, HLG_ASSET_FORMAT)) {
return; return;
} }
videoFrameProcessorTestRunner = videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId) getDefaultFrameProcessorTestRunnerBuilder(testId)
.setVideoAssetPath(INPUT_HLG_MP4_ASSET_STRING) .setVideoAssetPath(HLG_ASSET_STRING)
.setOutputColorInfo(TONE_MAP_SDR_COLOR) .setOutputColorInfo(TONE_MAP_SDR_COLOR)
.setEffects(ImmutableList.of(NO_OP_EFFECT)) .setEffects(ImmutableList.of(NO_OP_EFFECT))
.build(); .build();
@ -169,13 +199,13 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest {
@Test @Test
public void toneMap_pqFrame_matchesGoldenFile() throws Exception { public void toneMap_pqFrame_matchesGoldenFile() throws Exception {
String testId = "toneMap_pqFrame_matchesGoldenFile"; String testId = "toneMap_pqFrame_matchesGoldenFile";
if (skipAndLogIfOpenGlToneMappingUnsupported(testId, MP4_ASSET_720P_4_SECOND_HDR10_FORMAT)) { if (skipAndLogIfOpenGlToneMappingUnsupported(testId, PQ_ASSET_FORMAT)) {
return; return;
} }
videoFrameProcessorTestRunner = videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId) getDefaultFrameProcessorTestRunnerBuilder(testId)
.setVideoAssetPath(INPUT_PQ_MP4_ASSET_STRING) .setVideoAssetPath(PQ_ASSET_STRING)
.setOutputColorInfo(TONE_MAP_SDR_COLOR) .setOutputColorInfo(TONE_MAP_SDR_COLOR)
.build(); .build();
Bitmap expectedBitmap = readBitmap(TONE_MAP_PQ_TO_SDR_PNG_ASSET_PATH); Bitmap expectedBitmap = readBitmap(TONE_MAP_PQ_TO_SDR_PNG_ASSET_PATH);
@ -208,13 +238,13 @@ public final class ToneMapHdrToSdrUsingOpenGlPixelTest {
@Test @Test
public void toneMapWithNoOpEffect_pqFrame_matchesGoldenFile() throws Exception { public void toneMapWithNoOpEffect_pqFrame_matchesGoldenFile() throws Exception {
String testId = "toneMapWithNoOpEffect_pqFrame_matchesGoldenFile"; String testId = "toneMapWithNoOpEffect_pqFrame_matchesGoldenFile";
if (skipAndLogIfOpenGlToneMappingUnsupported(testId, MP4_ASSET_720P_4_SECOND_HDR10_FORMAT)) { if (skipAndLogIfOpenGlToneMappingUnsupported(testId, PQ_ASSET_FORMAT)) {
return; return;
} }
videoFrameProcessorTestRunner = videoFrameProcessorTestRunner =
getDefaultFrameProcessorTestRunnerBuilder(testId) getDefaultFrameProcessorTestRunnerBuilder(testId)
.setVideoAssetPath(INPUT_PQ_MP4_ASSET_STRING) .setVideoAssetPath(PQ_ASSET_STRING)
.setOutputColorInfo(TONE_MAP_SDR_COLOR) .setOutputColorInfo(TONE_MAP_SDR_COLOR)
.setEffects(ImmutableList.of(NO_OP_EFFECT)) .setEffects(ImmutableList.of(NO_OP_EFFECT))
.build(); .build();