Move NV12ToYUV420 helper function out of header
... as it is only used locally in YUVConverter.cpp.
This is part of a chain of changes to refactor YUVConverter
to support YUV P010 buffers.
Bug: b/191084459
Test: cvd start --gpu_mode=gfxstream
Change-Id: I23ce3a26779c6cd3f7fca526450d90b058f39ca8
diff --git a/stream-servers/YUVConverter.cpp b/stream-servers/YUVConverter.cpp
index 22858e4..e8be035 100644
--- a/stream-servers/YUVConverter.cpp
+++ b/stream-servers/YUVConverter.cpp
@@ -42,6 +42,28 @@
YUVInterleaveDirectionUV = 1,
};
+// NV12 and YUV420 are all packed
+static void NV12ToYUV420PlanarInPlaceConvert(int nWidth,
+ int nHeight,
+ uint8_t* pFrame,
+ uint8_t* pQuad) {
+ std::vector<uint8_t> tmp;
+ if (pQuad == nullptr) {
+ tmp.resize(nWidth * nHeight / 4);
+ pQuad = tmp.data();
+ }
+ int nPitch = nWidth;
+ uint8_t *puv = pFrame + nPitch * nHeight, *pu = puv,
+ *pv = puv + nPitch * nHeight / 4;
+ for (int y = 0; y < nHeight / 2; y++) {
+ for (int x = 0; x < nWidth / 2; x++) {
+ pu[y * nPitch / 2 + x] = puv[y * nPitch + x * 2];
+ pQuad[y * nWidth / 2 + x] = puv[y * nPitch + x * 2 + 1];
+ }
+ }
+ memcpy(pv, pQuad, nWidth * nHeight / 4);
+}
+
// getYUVOffsets(), given a YUV-formatted buffer that is arranged
// according to the spec
// https://developer.android.com/reference/android/graphics/ImageFormat.html#YUV
diff --git a/stream-servers/YUVConverter.h b/stream-servers/YUVConverter.h
index e323b54..7c8830c 100644
--- a/stream-servers/YUVConverter.h
+++ b/stream-servers/YUVConverter.h
@@ -63,28 +63,6 @@
void swapTextures(uint32_t type, uint32_t* textures);
- // NV12 and YUV420 are all packed
- static void NV12ToYUV420PlanarInPlaceConvert(int nWidth,
- int nHeight,
- uint8_t* pFrame,
- uint8_t* pQuad) {
- std::vector<uint8_t> tmp;
- if (pQuad == nullptr) {
- tmp.resize(nWidth * nHeight / 4);
- pQuad = tmp.data();
- }
- int nPitch = nWidth;
- uint8_t *puv = pFrame + nPitch * nHeight, *pu = puv,
- *pv = puv + nPitch * nHeight / 4;
- for (int y = 0; y < nHeight / 2; y++) {
- for (int x = 0; x < nWidth / 2; x++) {
- pu[y * nPitch / 2 + x] = puv[y * nPitch + x * 2];
- pQuad[y * nWidth / 2 + x] = puv[y * nPitch + x * 2 + 1];
- }
- }
- memcpy(pv, pQuad, nWidth * nHeight / 4);
- }
-
// public so other classes can call
static void createYUVGLTex(GLenum texture_unit,
GLsizei width,