mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-12-05 11:59:30 +01:00
65 lines
2.9 KiB
Java
65 lines
2.9 KiB
Java
package androidx.camera.video.internal;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.camera.core.DynamicRange;
|
|
import androidx.camera.core.impl.EncoderProfilesProvider;
|
|
import androidx.camera.core.impl.EncoderProfilesProxy;
|
|
import androidx.camera.video.internal.utils.DynamicRangeUtil;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes.dex */
|
|
public class DynamicRangeMatchedEncoderProfilesProvider implements EncoderProfilesProvider {
|
|
private final DynamicRange mDynamicRange;
|
|
private final Map<Integer, EncoderProfilesProxy> mEncoderProfilesCache = new HashMap();
|
|
private final EncoderProfilesProvider mEncoderProfilesProvider;
|
|
|
|
public DynamicRangeMatchedEncoderProfilesProvider(@NonNull EncoderProfilesProvider encoderProfilesProvider, @NonNull DynamicRange dynamicRange) {
|
|
this.mEncoderProfilesProvider = encoderProfilesProvider;
|
|
this.mDynamicRange = dynamicRange;
|
|
}
|
|
|
|
@Nullable
|
|
private static EncoderProfilesProxy filterUnmatchedDynamicRange(@Nullable EncoderProfilesProxy encoderProfilesProxy, @NonNull DynamicRange dynamicRange) {
|
|
if (encoderProfilesProxy == null) {
|
|
return null;
|
|
}
|
|
ArrayList arrayList = new ArrayList();
|
|
for (EncoderProfilesProxy.VideoProfileProxy videoProfileProxy : encoderProfilesProxy.getVideoProfiles()) {
|
|
if (DynamicRangeUtil.isHdrSettingsMatched(videoProfileProxy, dynamicRange)) {
|
|
arrayList.add(videoProfileProxy);
|
|
}
|
|
}
|
|
if (arrayList.isEmpty()) {
|
|
return null;
|
|
}
|
|
return EncoderProfilesProxy.ImmutableEncoderProfilesProxy.create(encoderProfilesProxy.getDefaultDurationSeconds(), encoderProfilesProxy.getRecommendedFileFormat(), encoderProfilesProxy.getAudioProfiles(), arrayList);
|
|
}
|
|
|
|
@Nullable
|
|
private EncoderProfilesProxy getProfilesInternal(int i) {
|
|
if (this.mEncoderProfilesCache.containsKey(Integer.valueOf(i))) {
|
|
return this.mEncoderProfilesCache.get(Integer.valueOf(i));
|
|
}
|
|
if (!this.mEncoderProfilesProvider.hasProfile(i)) {
|
|
return null;
|
|
}
|
|
EncoderProfilesProxy filterUnmatchedDynamicRange = filterUnmatchedDynamicRange(this.mEncoderProfilesProvider.getAll(i), this.mDynamicRange);
|
|
this.mEncoderProfilesCache.put(Integer.valueOf(i), filterUnmatchedDynamicRange);
|
|
return filterUnmatchedDynamicRange;
|
|
}
|
|
|
|
@Override // androidx.camera.core.impl.EncoderProfilesProvider
|
|
@Nullable
|
|
public EncoderProfilesProxy getAll(int i) {
|
|
return getProfilesInternal(i);
|
|
}
|
|
|
|
@Override // androidx.camera.core.impl.EncoderProfilesProvider
|
|
public boolean hasProfile(int i) {
|
|
return this.mEncoderProfilesProvider.hasProfile(i) && getProfilesInternal(i) != null;
|
|
}
|
|
}
|