HDR: For HDR videos, enableHdrEditing by default.
Previously, tone-mapping was the default. PiperOrigin-RevId: 488362209
This commit is contained in:
parent
f38a5a4963
commit
6820704b08
@ -69,7 +69,6 @@ public final class ConfigurationActivity extends AppCompatActivity {
|
||||
public static final String ENABLE_DEBUG_PREVIEW = "enable_debug_preview";
|
||||
public static final String ENABLE_REQUEST_SDR_TONE_MAPPING = "enable_request_sdr_tone_mapping";
|
||||
public static final String FORCE_INTERPRET_HDR_VIDEO_AS_SDR = "force_interpret_hdr_video_as_sdr";
|
||||
public static final String ENABLE_HDR_EDITING = "enable_hdr_editing";
|
||||
public static final String DEMO_EFFECTS_SELECTIONS = "demo_effects_selections";
|
||||
public static final String PERIODIC_VIGNETTE_CENTER_X = "periodic_vignette_center_x";
|
||||
public static final String PERIODIC_VIGNETTE_CENTER_Y = "periodic_vignette_center_y";
|
||||
@ -157,7 +156,6 @@ public final class ConfigurationActivity extends AppCompatActivity {
|
||||
private @MonotonicNonNull CheckBox enableDebugPreviewCheckBox;
|
||||
private @MonotonicNonNull CheckBox enableRequestSdrToneMappingCheckBox;
|
||||
private @MonotonicNonNull CheckBox forceInterpretHdrVideoAsSdrCheckBox;
|
||||
private @MonotonicNonNull CheckBox enableHdrEditingCheckBox;
|
||||
private @MonotonicNonNull Button selectDemoEffectsButton;
|
||||
private boolean @MonotonicNonNull [] demoEffectsSelections;
|
||||
private @Nullable Uri localFileUri;
|
||||
@ -254,7 +252,6 @@ public final class ConfigurationActivity extends AppCompatActivity {
|
||||
findViewById(R.id.request_sdr_tone_mapping).setEnabled(isRequestSdrToneMappingSupported());
|
||||
forceInterpretHdrVideoAsSdrCheckBox =
|
||||
findViewById(R.id.force_interpret_hdr_video_as_sdr_checkbox);
|
||||
enableHdrEditingCheckBox = findViewById(R.id.hdr_editing_checkbox);
|
||||
|
||||
demoEffectsSelections = new boolean[DEMO_EFFECTS.length];
|
||||
selectDemoEffectsButton = findViewById(R.id.select_demo_effects_button);
|
||||
@ -313,7 +310,6 @@ public final class ConfigurationActivity extends AppCompatActivity {
|
||||
"enableDebugPreviewCheckBox",
|
||||
"enableRequestSdrToneMappingCheckBox",
|
||||
"forceInterpretHdrVideoAsSdrCheckBox",
|
||||
"enableHdrEditingCheckBox",
|
||||
"demoEffectsSelections"
|
||||
})
|
||||
private void startTransformation(View view) {
|
||||
@ -355,7 +351,6 @@ public final class ConfigurationActivity extends AppCompatActivity {
|
||||
ENABLE_REQUEST_SDR_TONE_MAPPING, enableRequestSdrToneMappingCheckBox.isChecked());
|
||||
bundle.putBoolean(
|
||||
FORCE_INTERPRET_HDR_VIDEO_AS_SDR, forceInterpretHdrVideoAsSdrCheckBox.isChecked());
|
||||
bundle.putBoolean(ENABLE_HDR_EDITING, enableHdrEditingCheckBox.isChecked());
|
||||
bundle.putBooleanArray(DEMO_EFFECTS_SELECTIONS, demoEffectsSelections);
|
||||
bundle.putInt(COLOR_FILTER_SELECTION, colorFilterSelection);
|
||||
bundle.putFloat(CONTRAST_VALUE, contrastValue);
|
||||
@ -595,7 +590,6 @@ public final class ConfigurationActivity extends AppCompatActivity {
|
||||
"enableDebugPreviewCheckBox",
|
||||
"enableRequestSdrToneMappingCheckBox",
|
||||
"forceInterpretHdrVideoAsSdrCheckBox",
|
||||
"enableHdrEditingCheckBox",
|
||||
"selectDemoEffectsButton"
|
||||
})
|
||||
private void onRemoveAudio(View view) {
|
||||
@ -617,7 +611,6 @@ public final class ConfigurationActivity extends AppCompatActivity {
|
||||
"enableDebugPreviewCheckBox",
|
||||
"enableRequestSdrToneMappingCheckBox",
|
||||
"forceInterpretHdrVideoAsSdrCheckBox",
|
||||
"enableHdrEditingCheckBox",
|
||||
"selectDemoEffectsButton"
|
||||
})
|
||||
private void onRemoveVideo(View view) {
|
||||
@ -638,7 +631,6 @@ public final class ConfigurationActivity extends AppCompatActivity {
|
||||
"enableDebugPreviewCheckBox",
|
||||
"enableRequestSdrToneMappingCheckBox",
|
||||
"forceInterpretHdrVideoAsSdrCheckBox",
|
||||
"enableHdrEditingCheckBox",
|
||||
"selectDemoEffectsButton"
|
||||
})
|
||||
private void enableTrackSpecificOptions(boolean isAudioEnabled, boolean isVideoEnabled) {
|
||||
@ -651,7 +643,6 @@ public final class ConfigurationActivity extends AppCompatActivity {
|
||||
enableRequestSdrToneMappingCheckBox.setEnabled(
|
||||
isRequestSdrToneMappingSupported() && isVideoEnabled);
|
||||
forceInterpretHdrVideoAsSdrCheckBox.setEnabled(isVideoEnabled);
|
||||
enableHdrEditingCheckBox.setEnabled(isVideoEnabled);
|
||||
selectDemoEffectsButton.setEnabled(isVideoEnabled);
|
||||
|
||||
findViewById(R.id.audio_mime_text_view).setEnabled(isAudioEnabled);
|
||||
@ -662,7 +653,6 @@ public final class ConfigurationActivity extends AppCompatActivity {
|
||||
findViewById(R.id.request_sdr_tone_mapping)
|
||||
.setEnabled(isRequestSdrToneMappingSupported() && isVideoEnabled);
|
||||
findViewById(R.id.force_interpret_hdr_video_as_sdr).setEnabled(isVideoEnabled);
|
||||
findViewById(R.id.hdr_editing).setEnabled(isVideoEnabled);
|
||||
}
|
||||
|
||||
private static boolean isRequestSdrToneMappingSupported() {
|
||||
|
@ -274,8 +274,6 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||
bundle.getBoolean(ConfigurationActivity.ENABLE_REQUEST_SDR_TONE_MAPPING));
|
||||
requestBuilder.experimental_setForceInterpretHdrVideoAsSdr(
|
||||
bundle.getBoolean(ConfigurationActivity.FORCE_INTERPRET_HDR_VIDEO_AS_SDR));
|
||||
requestBuilder.experimental_setEnableHdrEditing(
|
||||
bundle.getBoolean(ConfigurationActivity.ENABLE_HDR_EDITING));
|
||||
transformerBuilder
|
||||
.setTransformationRequest(requestBuilder.build())
|
||||
.setRemoveAudio(bundle.getBoolean(ConfigurationActivity.SHOULD_REMOVE_AUDIO))
|
||||
|
@ -207,16 +207,6 @@
|
||||
android:id="@+id/request_sdr_tone_mapping_checkbox"
|
||||
android:layout_gravity="end" />
|
||||
</TableRow>
|
||||
<TableRow
|
||||
android:layout_weight="1">
|
||||
<TextView
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@+id/hdr_editing"
|
||||
android:text="@string/hdr_editing" />
|
||||
<CheckBox
|
||||
android:id="@+id/hdr_editing_checkbox"
|
||||
android:layout_gravity="end" />
|
||||
</TableRow>
|
||||
<TableRow
|
||||
android:layout_weight="1">
|
||||
<TextView
|
||||
|
@ -32,7 +32,6 @@
|
||||
<string name="trim" translatable="false">Trim</string>
|
||||
<string name="request_sdr_tone_mapping" translatable="false">Request SDR tone-mapping (API 31+)</string>
|
||||
<string name="force_interpret_hdr_video_as_sdr" translatable="false">[Experimental] Force interpret HDR video as SDR (API 29+)</string>
|
||||
<string name="hdr_editing" translatable="false">[Experimental] HDR editing (API 31+)</string>
|
||||
<string name="select_demo_effects" translatable="false">Add demo effects</string>
|
||||
<string name="periodic_vignette_options" translatable="false">Periodic vignette options</string>
|
||||
<string name="no_media_pipe_error" translatable="false">Failed to load MediaPipe processor. Check the README for instructions.</string>
|
||||
|
@ -43,10 +43,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* {@link Transformer} instrumentation test for applying an {@linkplain
|
||||
* TransformationRequest.Builder#experimental_setEnableHdrEditing HDR frame edit}.
|
||||
*/
|
||||
/** {@link Transformer} instrumentation test for applying an HDR frame edit. */
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class SetHdrEditingTest {
|
||||
public static final String TAG = "SetHdrEditingTest";
|
||||
@ -68,11 +65,7 @@ public class SetHdrEditingTest {
|
||||
String testId = "transform_noRequestedTranscode_hdr10File_transformsOrThrows";
|
||||
Context context = ApplicationProvider.getApplicationContext();
|
||||
|
||||
Transformer transformer =
|
||||
new Transformer.Builder(context)
|
||||
.setTransformationRequest(
|
||||
new TransformationRequest.Builder().experimental_setEnableHdrEditing(true).build())
|
||||
.build();
|
||||
Transformer transformer = new Transformer.Builder(context).build();
|
||||
|
||||
try {
|
||||
TransformationTestResult transformationTestResult =
|
||||
@ -95,11 +88,7 @@ public class SetHdrEditingTest {
|
||||
String testId = "transform_noRequestedTranscode_hlg10File_transformsOrThrows";
|
||||
Context context = ApplicationProvider.getApplicationContext();
|
||||
|
||||
Transformer transformer =
|
||||
new Transformer.Builder(context)
|
||||
.setTransformationRequest(
|
||||
new TransformationRequest.Builder().experimental_setEnableHdrEditing(true).build())
|
||||
.build();
|
||||
Transformer transformer = new Transformer.Builder(context).build();
|
||||
|
||||
try {
|
||||
TransformationTestResult transformationTestResult =
|
||||
@ -130,10 +119,7 @@ public class SetHdrEditingTest {
|
||||
Transformer transformer =
|
||||
new Transformer.Builder(context)
|
||||
.setTransformationRequest(
|
||||
new TransformationRequest.Builder()
|
||||
.experimental_setEnableHdrEditing(true)
|
||||
.setRotationDegrees(180)
|
||||
.build())
|
||||
new TransformationRequest.Builder().setRotationDegrees(180).build())
|
||||
.build();
|
||||
|
||||
TransformationTestResult transformationTestResult =
|
||||
@ -156,10 +142,7 @@ public class SetHdrEditingTest {
|
||||
Transformer transformer =
|
||||
new Transformer.Builder(context)
|
||||
.setTransformationRequest(
|
||||
new TransformationRequest.Builder()
|
||||
.experimental_setEnableHdrEditing(true)
|
||||
.setRotationDegrees(180)
|
||||
.build())
|
||||
new TransformationRequest.Builder().setRotationDegrees(180).build())
|
||||
.build();
|
||||
|
||||
TransformationTestResult transformationTestResult =
|
||||
@ -184,10 +167,7 @@ public class SetHdrEditingTest {
|
||||
Transformer transformer =
|
||||
new Transformer.Builder(context)
|
||||
.setTransformationRequest(
|
||||
new TransformationRequest.Builder()
|
||||
.experimental_setEnableHdrEditing(true)
|
||||
.setRotationDegrees(180)
|
||||
.build())
|
||||
new TransformationRequest.Builder().setRotationDegrees(180).build())
|
||||
.addListener(
|
||||
new Transformer.Listener() {
|
||||
@Override
|
||||
@ -238,10 +218,7 @@ public class SetHdrEditingTest {
|
||||
Transformer transformer =
|
||||
new Transformer.Builder(context)
|
||||
.setTransformationRequest(
|
||||
new TransformationRequest.Builder()
|
||||
.experimental_setEnableHdrEditing(true)
|
||||
.setRotationDegrees(180)
|
||||
.build())
|
||||
new TransformationRequest.Builder().setRotationDegrees(180).build())
|
||||
.addListener(
|
||||
new Transformer.Listener() {
|
||||
@Override
|
||||
@ -289,11 +266,7 @@ public class SetHdrEditingTest {
|
||||
return;
|
||||
}
|
||||
|
||||
Transformer transformer =
|
||||
new Transformer.Builder(context)
|
||||
.setTransformationRequest(
|
||||
new TransformationRequest.Builder().experimental_setEnableHdrEditing(true).build())
|
||||
.build();
|
||||
Transformer transformer = new Transformer.Builder(context).build();
|
||||
new TransformerAndroidTestRunner.Builder(context, transformer)
|
||||
.build()
|
||||
.run(
|
||||
|
@ -95,10 +95,6 @@ import androidx.media3.common.util.Util;
|
||||
if (transformationRequest.outputHeight != originalTransformationRequest.outputHeight) {
|
||||
fallbackRequestBuilder.setResolution(transformationRequest.outputHeight);
|
||||
}
|
||||
if (transformationRequest.enableHdrEditing != originalTransformationRequest.enableHdrEditing) {
|
||||
fallbackRequestBuilder.experimental_setEnableHdrEditing(
|
||||
transformationRequest.enableHdrEditing);
|
||||
}
|
||||
if (transformationRequest.enableRequestSdrToneMapping
|
||||
!= originalTransformationRequest.enableRequestSdrToneMapping) {
|
||||
fallbackRequestBuilder.setEnableRequestSdrToneMapping(
|
||||
|
@ -55,6 +55,7 @@ public final class TransformationRequest {
|
||||
scaleX = 1;
|
||||
scaleY = 1;
|
||||
outputHeight = C.LENGTH_UNSET;
|
||||
enableHdrEditing = true;
|
||||
}
|
||||
|
||||
private Builder(TransformationRequest transformationRequest) {
|
||||
@ -220,13 +221,14 @@ public final class TransformationRequest {
|
||||
* supported, high dynamic range (HDR) input will be tone-mapped into an SDR opto-electrical
|
||||
* transfer function before processing.
|
||||
*
|
||||
* <p>The default value is {@code true}, which corresponds to tone-mapping output if possible.
|
||||
* <p>The default value is {@code false}, which corresponds to editing and outputting HDR video
|
||||
* if possible, and falling back to tone-mapping if not.
|
||||
*
|
||||
* <p>The setting has no effect if the input is already in SDR, or if tone-mapping is not
|
||||
* supported. Currently tone-mapping is only guaranteed to be supported from Android T onwards.
|
||||
*
|
||||
* <p>Setting this as {@code true} will set {@linkplain #experimental_setEnableHdrEditing} and
|
||||
* {@linkplain #forceInterpretHdrVideoAsSdr} to {@code false}.
|
||||
* <p>Setting this as {@code true} will set {@linkplain #enableHdrEditing} and {@linkplain
|
||||
* #forceInterpretHdrVideoAsSdr} to {@code false}.
|
||||
*
|
||||
* @param enableRequestSdrToneMapping Whether to request tone-mapping down to SDR.
|
||||
* @return This builder.
|
||||
@ -235,8 +237,8 @@ public final class TransformationRequest {
|
||||
public Builder setEnableRequestSdrToneMapping(boolean enableRequestSdrToneMapping) {
|
||||
this.enableRequestSdrToneMapping = enableRequestSdrToneMapping;
|
||||
if (enableRequestSdrToneMapping) {
|
||||
forceInterpretHdrVideoAsSdr = false;
|
||||
enableHdrEditing = false;
|
||||
forceInterpretHdrVideoAsSdr = false;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@ -244,8 +246,8 @@ public final class TransformationRequest {
|
||||
/**
|
||||
* Sets whether to interpret HDR video as SDR, resulting in washed out video.
|
||||
*
|
||||
* <p>The default value is {@code false}, with {@link #setEnableRequestSdrToneMapping} being
|
||||
* applied.
|
||||
* <p>The default value is {@code false}, which corresponds to editing and outputting HDR video
|
||||
* if possible, and falling back to tone-mapping if not.
|
||||
*
|
||||
* <p>Use of this flag may result in {@code
|
||||
* TransformationException.ERROR_CODE_HDR_DECODING_UNSUPPORTED} or {@code
|
||||
@ -259,8 +261,8 @@ public final class TransformationRequest {
|
||||
*
|
||||
* <p>The setting has no effect if the input is already in SDR.
|
||||
*
|
||||
* <p>Setting this as {@code true} will set {@linkplain #experimental_setEnableHdrEditing} and
|
||||
* {@linkplain #forceInterpretHdrVideoAsSdr} to {@code false}.
|
||||
* <p>Setting this as {@code true} will set {@linkplain #enableHdrEditing} and {@linkplain
|
||||
* #forceInterpretHdrVideoAsSdr} to {@code false}.
|
||||
*
|
||||
* @param forceInterpretHdrVideoAsSdr Whether to interpret HDR contents as SDR.
|
||||
* @return This builder.
|
||||
@ -278,32 +280,12 @@ public final class TransformationRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether to allow processing high dynamic range (HDR) input video streams as HDR.
|
||||
*
|
||||
* <p>The default value is {@code false}, with {@link #setEnableRequestSdrToneMapping} being
|
||||
* applied.
|
||||
*
|
||||
* <p>This method is experimental, and will be renamed or removed in a future release. The HDR
|
||||
* editing feature is under development and is intended for developing/testing HDR support.
|
||||
*
|
||||
* <p>Setting this as {@code true} will set {@linkplain #experimental_setEnableHdrEditing} and
|
||||
* {@linkplain #forceInterpretHdrVideoAsSdr} to {@code false}.
|
||||
*
|
||||
* <p>With this flag enabled, HDR streams will correctly edit in HDR, convert via tone-mapping
|
||||
* to SDR, or throw an error, based on the device's HDR support. SDR streams will be interpreted
|
||||
* the same way regardless of this flag's state.
|
||||
*
|
||||
* @param enableHdrEditing Whether to attempt to process any input video stream as a high
|
||||
* dynamic range (HDR) signal.
|
||||
* @return This builder.
|
||||
* @deprecated This method is now a no-op. (@code experimental_setEnableHdrEditing(true)} is now
|
||||
* the default behavior.
|
||||
*/
|
||||
@Deprecated
|
||||
@CanIgnoreReturnValue
|
||||
public Builder experimental_setEnableHdrEditing(boolean enableHdrEditing) {
|
||||
this.enableHdrEditing = enableHdrEditing;
|
||||
if (enableHdrEditing) {
|
||||
enableRequestSdrToneMapping = false;
|
||||
forceInterpretHdrVideoAsSdr = false;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -375,11 +357,7 @@ public final class TransformationRequest {
|
||||
/** Whether to force interpreting HDR video as SDR. */
|
||||
public final boolean forceInterpretHdrVideoAsSdr;
|
||||
|
||||
/**
|
||||
* Whether to attempt to process any input video stream as a high dynamic range (HDR) signal.
|
||||
*
|
||||
* @see Builder#experimental_setEnableHdrEditing(boolean)
|
||||
*/
|
||||
/** Whether to attempt to process any input video stream as a high dynamic range (HDR) signal. */
|
||||
public final boolean enableHdrEditing;
|
||||
|
||||
private TransformationRequest(
|
||||
|
@ -303,9 +303,7 @@ import org.checkerframework.dataflow.qual.Pure;
|
||||
TransformationRequest.Builder transformationRequestBuilder = transformationRequest.buildUpon();
|
||||
if (transformationRequest.enableRequestSdrToneMapping != isToneMappedToSdr) {
|
||||
checkState(isToneMappedToSdr);
|
||||
transformationRequestBuilder
|
||||
.setEnableRequestSdrToneMapping(true)
|
||||
.experimental_setEnableHdrEditing(false);
|
||||
transformationRequestBuilder.setEnableRequestSdrToneMapping(true);
|
||||
}
|
||||
return transformationRequestBuilder
|
||||
.setVideoMimeType(supportedFormat.sampleMimeType)
|
||||
|
Loading…
x
Reference in New Issue
Block a user