v4l2_codec2 encoder: Fix wrong pixel format for TYPE_RGB videos.
ag/16211950 performed cleanup in the format converter used to convert
input video frames to a different pixel format. This inadvertently
broke the functionality for RGB video frames. This CL fixes the
problem.
Bug: 207888705
Test: arc.VideoEncodeAccel.h264_192p_i420_vm
android.media.cts.DecodeEditEncodeTest#testVideoEdit720p
Change-Id: Idf93f02599d859eb290792f8c7785765fad1294c
(cherry picked from commit ba5e6aeb894d9bdb0751185653bf1a61ed4cef22)
diff --git a/common/FormatConverter.cpp b/common/FormatConverter.cpp
index 4a43217..cb1a049 100644
--- a/common/FormatConverter.cpp
+++ b/common/FormatConverter.cpp
@@ -191,6 +191,8 @@
? VideoPixelFormat::NV12
: VideoPixelFormat::NV21;
}
+ } else if (inputLayout.type == C2PlanarLayout::TYPE_RGB) {
+ inputFormat = VideoPixelFormat::ABGR;
} else if (static_cast<uint32_t>(inputLayout.type) == 0u) {
// The above layout() cannot fill layout information and sets it to 0 instead if the input
// format is IMPLEMENTATION_DEFINED and its backed format is RGB. We fill the layout by
@@ -204,6 +206,9 @@
// BGRA_8888 is not used now?
inputFormat = VideoPixelFormat::ABGR;
inputLayout.type = C2PlanarLayout::TYPE_RGB;
+ } else {
+ ALOGE("Failed to determine input pixel format: %u", inputLayout.type);
+ return C2_CORRUPTED;
}
if (inputFormat == mOutFormat) {