Skip to content

Commit

Permalink
fixed blue and red were swapped on Pixel 5a.
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo4405 committed Jan 4, 2024
1 parent 68d2632 commit 0c11305
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ class Camera2Source(
}

companion object {
private const val IMAGE_FORMAT = ImageFormat.YUV_420_888

private const val IMAGE_FORMAT = 0x00000022 // AIMAGE_FORMAT_PRIVATE
private const val DEFAULT_CAMERA_ID = "0"
private val TAG = Camera2Source::class.java.simpleName
}
Expand Down
14 changes: 10 additions & 4 deletions vulkan/src/main/cpp/Graphics/ImageReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@ void ImageReader::SetUp(int32_t width, int32_t height, int32_t format) {
buffers.resize(maxImages);
images.resize(maxImages);

AImageReader_newWithUsage(
auto result = AImageReader_newWithUsage(
width,
height,
format,
AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE |
AHARDWAREBUFFER_USAGE_CPU_READ_RARELY,
AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE,
maxImages + 2,
&reader);

AImageReader_getWindow(reader, &window);
if (result == AMEDIA_OK) {
AImageReader_getWindow(reader, &window);
} else {
LOGE("Failed to AImageReader_newWithUsage error: %d", result);
}
}

void ImageReader::TearDown() {
Expand All @@ -38,6 +41,9 @@ ANativeWindow *ImageReader::GetWindow() {
}

AHardwareBuffer *ImageReader::GetLatestBuffer() {
if (reader == nullptr) {
return nullptr;
}
if (cursor == buffers.size()) {
cursor = 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class VkPixelTransform : PixelTransform {
format: Int,
lambda: (surface: Surface) -> Unit
) {
lambda(nativeCreateInputSurface(width, height, format))
nativeCreateInputSurface(width, height, format)?.let { lambda(it) }
}

override fun dispose() {
Expand All @@ -163,7 +163,7 @@ class VkPixelTransform : PixelTransform {
private external fun nativeSetVideoGravity(videoGravity: Int)
private external fun nativeSetImageExtent(width: Int, height: Int)
private external fun nativeSetAssetManager(assetManager: AssetManager?)
private external fun nativeCreateInputSurface(width: Int, height: Int, format: Int): Surface
private external fun nativeCreateInputSurface(width: Int, height: Int, format: Int): Surface?
private external fun nativeSetRotatesWithContent(expectedOrientationSynchronize: Boolean)
private external fun nativeSetFrameRate(frameRate: Int)
private external fun nativeSetVideoEffect(videoEffect: VideoEffect)
Expand Down

0 comments on commit 0c11305

Please sign in to comment.