Camera2: Consolidate the overriding of PRIVATE format
We had overriding of PRIVATE format scattered at multiple places. Consolidate them into one place. Test: Camera preview/capture, and camcorder recording Change-Id: I098ce93bba2000760a20c0297fcf0cb9d8c6caab
This commit is contained in:
@@ -348,9 +348,7 @@ public class LegacyCameraDevice implements AutoCloseable {
|
||||
|
||||
Size[] sizes = streamConfigurations.getOutputSizes(surfaceType);
|
||||
if (sizes == null) {
|
||||
// WAR: Override default format to IMPLEMENTATION_DEFINED for b/9487482
|
||||
if ((surfaceType >= LegacyMetadataMapper.HAL_PIXEL_FORMAT_RGBA_8888 &&
|
||||
surfaceType <= LegacyMetadataMapper.HAL_PIXEL_FORMAT_BGRA_8888)) {
|
||||
if (surfaceType == ImageFormat.PRIVATE) {
|
||||
|
||||
// YUV_420_888 is always present in LEGACY for all
|
||||
// IMPLEMENTATION_DEFINED output sizes, and is publicly visible in the
|
||||
@@ -649,7 +647,16 @@ public class LegacyCameraDevice implements AutoCloseable {
|
||||
*/
|
||||
public static int detectSurfaceType(Surface surface) throws BufferQueueAbandonedException {
|
||||
checkNotNull(surface);
|
||||
return LegacyExceptionUtils.throwOnError(nativeDetectSurfaceType(surface));
|
||||
int surfaceType = nativeDetectSurfaceType(surface);
|
||||
|
||||
// TODO: remove this override since the default format should be
|
||||
// ImageFormat.PRIVATE. b/9487482
|
||||
if ((surfaceType >= LegacyMetadataMapper.HAL_PIXEL_FORMAT_RGBA_8888 &&
|
||||
surfaceType <= LegacyMetadataMapper.HAL_PIXEL_FORMAT_BGRA_8888)) {
|
||||
surfaceType = ImageFormat.PRIVATE;
|
||||
}
|
||||
|
||||
return LegacyExceptionUtils.throwOnError(surfaceType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -408,12 +408,6 @@ public final class StreamConfigurationMap {
|
||||
// See if consumer is flexible.
|
||||
boolean isFlexible = SurfaceUtils.isFlexibleConsumer(surface);
|
||||
|
||||
// Override RGB formats to IMPLEMENTATION_DEFINED, b/9487482
|
||||
if ((surfaceFormat >= LegacyMetadataMapper.HAL_PIXEL_FORMAT_RGBA_8888 &&
|
||||
surfaceFormat <= LegacyMetadataMapper.HAL_PIXEL_FORMAT_BGRA_8888)) {
|
||||
surfaceFormat = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED;
|
||||
}
|
||||
|
||||
StreamConfiguration[] configs =
|
||||
surfaceDataspace != HAL_DATASPACE_DEPTH ? mConfigurations : mDepthConfigurations;
|
||||
for (StreamConfiguration config : configs) {
|
||||
|
||||
@@ -118,15 +118,7 @@ public class SurfaceUtils {
|
||||
* @param surface The high speed output surface to be checked.
|
||||
*/
|
||||
private static void checkHighSpeedSurfaceFormat(Surface surface) {
|
||||
// TODO: remove this override since the default format should be
|
||||
// ImageFormat.PRIVATE. b/9487482
|
||||
final int HAL_FORMAT_RGB_START = 1; // HAL_PIXEL_FORMAT_RGBA_8888 from graphics.h
|
||||
final int HAL_FORMAT_RGB_END = 5; // HAL_PIXEL_FORMAT_BGRA_8888 from graphics.h
|
||||
int surfaceFormat = SurfaceUtils.getSurfaceFormat(surface);
|
||||
if (surfaceFormat >= HAL_FORMAT_RGB_START &&
|
||||
surfaceFormat <= HAL_FORMAT_RGB_END) {
|
||||
surfaceFormat = ImageFormat.PRIVATE;
|
||||
}
|
||||
|
||||
if (surfaceFormat != ImageFormat.PRIVATE) {
|
||||
throw new IllegalArgumentException("Surface format(" + surfaceFormat + ") is not"
|
||||
|
||||
Reference in New Issue
Block a user