Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed blue and red were swapped on Pixel 5a. #215

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading