Add YuvImage as a GpuBuffer storage backend.
PiperOrigin-RevId: 505128789
This commit is contained in:
		
							parent
							
								
									e059d55d29
								
							
						
					
					
						commit
						1df4511e9d
					
				|  | @ -441,6 +441,21 @@ cc_library( | ||||||
|     ], |     ], | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | cc_library( | ||||||
|  |     name = "gpu_buffer_storage_yuv_image", | ||||||
|  |     srcs = ["gpu_buffer_storage_yuv_image.cc"], | ||||||
|  |     hdrs = ["gpu_buffer_storage_yuv_image.h"], | ||||||
|  |     visibility = ["//visibility:public"], | ||||||
|  |     deps = [ | ||||||
|  |         ":gpu_buffer_format", | ||||||
|  |         ":gpu_buffer_storage", | ||||||
|  |         "//mediapipe/framework/formats:yuv_image", | ||||||
|  |         "//third_party/libyuv", | ||||||
|  |         "@com_google_absl//absl/log", | ||||||
|  |         "@com_google_absl//absl/log:check", | ||||||
|  |     ], | ||||||
|  | ) | ||||||
|  | 
 | ||||||
| cc_library( | cc_library( | ||||||
|     name = "gpu_buffer_storage_ahwb", |     name = "gpu_buffer_storage_ahwb", | ||||||
|     srcs = ["gpu_buffer_storage_ahwb.cc"], |     srcs = ["gpu_buffer_storage_ahwb.cc"], | ||||||
|  | @ -1187,3 +1202,17 @@ mediapipe_cc_test( | ||||||
|         "//mediapipe/framework/port:gtest_main", |         "//mediapipe/framework/port:gtest_main", | ||||||
|     ], |     ], | ||||||
| ) | ) | ||||||
|  | 
 | ||||||
|  | mediapipe_cc_test( | ||||||
|  |     name = "gpu_buffer_storage_yuv_image_test", | ||||||
|  |     size = "small", | ||||||
|  |     srcs = ["gpu_buffer_storage_yuv_image_test.cc"], | ||||||
|  |     exclude_platforms = [ | ||||||
|  |         "ios", | ||||||
|  |     ], | ||||||
|  |     deps = [ | ||||||
|  |         ":gpu_buffer_format", | ||||||
|  |         ":gpu_buffer_storage_yuv_image", | ||||||
|  |         "//mediapipe/framework/port:gtest_main", | ||||||
|  |     ], | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | @ -212,6 +212,10 @@ ImageFormat::Format ImageFormatForGpuBufferFormat(GpuBufferFormat format) { | ||||||
|     case GpuBufferFormat::kTwoComponentHalf16: |     case GpuBufferFormat::kTwoComponentHalf16: | ||||||
|     case GpuBufferFormat::kRGBAHalf64: |     case GpuBufferFormat::kRGBAHalf64: | ||||||
|     case GpuBufferFormat::kRGBAFloat128: |     case GpuBufferFormat::kRGBAFloat128: | ||||||
|  |     case GpuBufferFormat::kNV12: | ||||||
|  |     case GpuBufferFormat::kNV21: | ||||||
|  |     case GpuBufferFormat::kI420: | ||||||
|  |     case GpuBufferFormat::kYV12: | ||||||
|     case GpuBufferFormat::kUnknown: |     case GpuBufferFormat::kUnknown: | ||||||
|       return ImageFormat::UNKNOWN; |       return ImageFormat::UNKNOWN; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | @ -52,6 +52,14 @@ enum class GpuBufferFormat : uint32_t { | ||||||
|   kRGB24 = 0x00000018,  // Note: prefer BGRA32 whenever possible.
 |   kRGB24 = 0x00000018,  // Note: prefer BGRA32 whenever possible.
 | ||||||
|   kRGBAHalf64 = MEDIAPIPE_FOURCC('R', 'G', 'h', 'A'), |   kRGBAHalf64 = MEDIAPIPE_FOURCC('R', 'G', 'h', 'A'), | ||||||
|   kRGBAFloat128 = MEDIAPIPE_FOURCC('R', 'G', 'f', 'A'), |   kRGBAFloat128 = MEDIAPIPE_FOURCC('R', 'G', 'f', 'A'), | ||||||
|  |   // 8-bit Y plane + interleaved 8-bit U/V plane with 2x2 subsampling.
 | ||||||
|  |   kNV12 = MEDIAPIPE_FOURCC('N', 'V', '1', '2'), | ||||||
|  |   // 8-bit Y plane + interleaved 8-bit V/U plane with 2x2 subsampling.
 | ||||||
|  |   kNV21 = MEDIAPIPE_FOURCC('N', 'V', '2', '1'), | ||||||
|  |   // 8-bit Y plane + non-interleaved 8-bit U/V planes with 2x2 subsampling.
 | ||||||
|  |   kI420 = MEDIAPIPE_FOURCC('I', '4', '2', '0'), | ||||||
|  |   // 8-bit Y plane + non-interleaved 8-bit V/U planes with 2x2 subsampling.
 | ||||||
|  |   kYV12 = MEDIAPIPE_FOURCC('Y', 'V', '1', '2'), | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| #if !MEDIAPIPE_DISABLE_GPU | #if !MEDIAPIPE_DISABLE_GPU | ||||||
|  | @ -111,6 +119,10 @@ inline OSType CVPixelFormatForGpuBufferFormat(GpuBufferFormat format) { | ||||||
|       return kCVPixelFormatType_64RGBAHalf; |       return kCVPixelFormatType_64RGBAHalf; | ||||||
|     case GpuBufferFormat::kRGBAFloat128: |     case GpuBufferFormat::kRGBAFloat128: | ||||||
|       return kCVPixelFormatType_128RGBAFloat; |       return kCVPixelFormatType_128RGBAFloat; | ||||||
|  |     case GpuBufferFormat::kNV12: | ||||||
|  |     case GpuBufferFormat::kNV21: | ||||||
|  |     case GpuBufferFormat::kI420: | ||||||
|  |     case GpuBufferFormat::kYV12: | ||||||
|     case GpuBufferFormat::kUnknown: |     case GpuBufferFormat::kUnknown: | ||||||
|       return -1; |       return -1; | ||||||
|   } |   } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user