v4l2_codec2: Remove duplicated HalPixelFormat and InputCodec types.

This CL removes the duplicate HalPixelFormat and InputCodec types in
common.h that are also present in VideoTypes.h.

VideoTypes.h is moved to the common/ folder so it can also be used by
other classes.

note: Submit together with ag/12467730

Bug: 143333813
Test: tast run $HOST arc.VideoEncodeAccel.h264_vm on hatch-arc-r
Change-Id: I93bca14a3b2f0c4c49104149d5683193554ba3eb
diff --git a/common/Android.bp b/common/Android.bp
index e9d407b..45334d0 100644
--- a/common/Android.bp
+++ b/common/Android.bp
@@ -10,6 +10,7 @@
         "EncodeHelpers.cpp",
         "FormatConverter.cpp",
         "V4L2ComponentCommon.cpp",
+        "VideoTypes.cpp",
     ],
 
     export_include_dirs: [
diff --git a/common/FormatConverter.cpp b/common/FormatConverter.cpp
index 657676e..9ab9161 100644
--- a/common/FormatConverter.cpp
+++ b/common/FormatConverter.cpp
@@ -20,7 +20,7 @@
 #include <ui/GraphicBuffer.h>
 #include <utils/Log.h>
 
-#include <v4l2_codec2/common/Common.h>  // for HalPixelFormat
+#include <v4l2_codec2/common/VideoTypes.h>  // for HalPixelFormat
 
 using android::hardware::graphics::common::V1_0::BufferUsage;
 
@@ -131,7 +131,7 @@
         // conversion to perform I420.
         halFormat = HalPixelFormat::YV12;
     } else {
-        halFormat = HalPixelFormat::YCbCr_420_888;  // will allocate NV12 by minigbm.
+        halFormat = HalPixelFormat::YCBCR_420_888;  // will allocate NV12 by minigbm.
     }
 
     uint32_t bufferCount = std::max(inputCount, kMinInputBufferCount);
diff --git a/components/VideoTypes.cpp b/common/VideoTypes.cpp
similarity index 88%
rename from components/VideoTypes.cpp
rename to common/VideoTypes.cpp
index 9b71db8..1ecceca 100644
--- a/components/VideoTypes.cpp
+++ b/common/VideoTypes.cpp
@@ -5,7 +5,7 @@
 //#define LOG_NDEBUG 0
 #define LOG_TAG "VideoTypes"
 
-#include <v4l2_codec2/components/VideoTypes.h>
+#include <v4l2_codec2/common/VideoTypes.h>
 
 #include <log/log.h>
 
@@ -24,6 +24,8 @@
 
 const char* HalPixelFormatToString(HalPixelFormat format) {
     switch (format) {
+    case HalPixelFormat::UNKNOWN:
+        return "Unknown";
     case HalPixelFormat::YCBCR_420_888:
         return "YCBCR_420_888";
     case HalPixelFormat::YV12:
diff --git a/common/include/v4l2_codec2/common/Common.h b/common/include/v4l2_codec2/common/Common.h
index 1b816ef..650b7a7 100644
--- a/common/include/v4l2_codec2/common/Common.h
+++ b/common/include/v4l2_codec2/common/Common.h
@@ -15,20 +15,6 @@
     uint32_t mStride;
 };
 
-enum class HalPixelFormat : uint32_t {
-    UNKNOWN = 0x0,
-    // The pixel formats defined in Android but are used among C2VDAComponent.
-    YCbCr_420_888 = 0x23,
-    YV12 = 0x32315659,
-    NV12 = 0x3231564e,
-};
-
-enum class InputCodec {
-    H264,
-    VP8,
-    VP9,
-};
-
-} // namespace android
+}  // namespace android
 
 #endif  // ANDROID_V4L2_CODEC2_COMMON_COMMON_H
diff --git a/components/include/v4l2_codec2/components/VideoTypes.h b/common/include/v4l2_codec2/common/VideoTypes.h
similarity index 80%
rename from components/include/v4l2_codec2/components/VideoTypes.h
rename to common/include/v4l2_codec2/common/VideoTypes.h
index bcc9bc0..a5130d2 100644
--- a/components/include/v4l2_codec2/components/VideoTypes.h
+++ b/common/include/v4l2_codec2/common/VideoTypes.h
@@ -22,10 +22,11 @@
 
 // Enumeration of supported pixel format. The value should be the same as
 // ::android::hardware::graphics::common::V1_0::PixelFormat.
-using ::android::hardware::graphics::common::V1_0::PixelFormat;
+using HPixelFormat = ::android::hardware::graphics::common::V1_0::PixelFormat;
 enum class HalPixelFormat : int32_t {
-    YCBCR_420_888 = static_cast<int32_t>(PixelFormat::YCBCR_420_888),
-    YV12 = static_cast<int32_t>(PixelFormat::YV12),
+    UNKNOWN = 0x0,
+    YCBCR_420_888 = static_cast<int32_t>(HPixelFormat::YCBCR_420_888),
+    YV12 = static_cast<int32_t>(HPixelFormat::YV12),
     // NV12 is not defined at PixelFormat, follow the convention to use fourcc value.
     NV12 = 0x3231564e,
 };
diff --git a/components/Android.bp b/components/Android.bp
index 7f2b9dc..8273412 100644
--- a/components/Android.bp
+++ b/components/Android.bp
@@ -16,7 +16,6 @@
         "V4L2EncodeComponent.cpp",
         "V4L2EncodeInterface.cpp",
         "VideoDecoder.cpp",
-        "VideoTypes.cpp",
     ],
     export_include_dirs: [
         "include",
diff --git a/components/V4L2DecodeComponent.cpp b/components/V4L2DecodeComponent.cpp
index 1c8a0e8..1ea9a7b 100644
--- a/components/V4L2DecodeComponent.cpp
+++ b/components/V4L2DecodeComponent.cpp
@@ -24,10 +24,10 @@
 #include <media/stagefright/foundation/ColorUtils.h>
 
 #include <h264_parser.h>
+#include <v4l2_codec2/common/VideoTypes.h>
 #include <v4l2_codec2/components/BitstreamBuffer.h>
 #include <v4l2_codec2/components/V4L2Decoder.h>
 #include <v4l2_codec2/components/VideoFramePool.h>
-#include <v4l2_codec2/components/VideoTypes.h>
 #include <v4l2_codec2/plugin_store/C2VdaBqBlockPool.h>
 
 namespace android {
diff --git a/components/VideoFramePool.cpp b/components/VideoFramePool.cpp
index 0a0c914..0fdd260 100644
--- a/components/VideoFramePool.cpp
+++ b/components/VideoFramePool.cpp
@@ -16,7 +16,7 @@
 #include <base/time/time.h>
 #include <log/log.h>
 
-#include <v4l2_codec2/components/VideoTypes.h>
+#include <v4l2_codec2/common/VideoTypes.h>
 #include <v4l2_codec2/plugin_store/C2VdaBqBlockPool.h>
 #include <v4l2_codec2/plugin_store/C2VdaPooledBlockPool.h>
 #include <v4l2_codec2/plugin_store/V4L2AllocatorId.h>
diff --git a/components/include/v4l2_codec2/components/V4L2DecodeInterface.h b/components/include/v4l2_codec2/components/V4L2DecodeInterface.h
index 46c565e..b57f6c1 100644
--- a/components/include/v4l2_codec2/components/V4L2DecodeInterface.h
+++ b/components/include/v4l2_codec2/components/V4L2DecodeInterface.h
@@ -12,7 +12,7 @@
 #include <util/C2InterfaceHelper.h>
 
 #include <size.h>
-#include <v4l2_codec2/components/VideoTypes.h>
+#include <v4l2_codec2/common/VideoTypes.h>
 
 namespace android {
 
diff --git a/components/include/v4l2_codec2/components/V4L2Decoder.h b/components/include/v4l2_codec2/components/V4L2Decoder.h
index eb12950..5539042 100644
--- a/components/include/v4l2_codec2/components/V4L2Decoder.h
+++ b/components/include/v4l2_codec2/components/V4L2Decoder.h
@@ -15,10 +15,10 @@
 
 #include <rect.h>
 #include <size.h>
+#include <v4l2_codec2/common/VideoTypes.h>
 #include <v4l2_codec2/components/VideoDecoder.h>
 #include <v4l2_codec2/components/VideoFrame.h>
 #include <v4l2_codec2/components/VideoFramePool.h>
-#include <v4l2_codec2/components/VideoTypes.h>
 #include <v4l2_device.h>
 
 namespace android {
diff --git a/components/include/v4l2_codec2/components/VideoDecoder.h b/components/include/v4l2_codec2/components/VideoDecoder.h
index 42b57c1..c737c65 100644
--- a/components/include/v4l2_codec2/components/VideoDecoder.h
+++ b/components/include/v4l2_codec2/components/VideoDecoder.h
@@ -10,10 +10,10 @@
 
 #include <base/callback.h>
 
+#include <v4l2_codec2/common/VideoTypes.h>
 #include <v4l2_codec2/components/BitstreamBuffer.h>
 #include <v4l2_codec2/components/VideoFrame.h>
 #include <v4l2_codec2/components/VideoFramePool.h>
-#include <v4l2_codec2/components/VideoTypes.h>
 
 namespace android {
 
diff --git a/components/include/v4l2_codec2/components/VideoFramePool.h b/components/include/v4l2_codec2/components/VideoFramePool.h
index c692cb0..ca26004 100644
--- a/components/include/v4l2_codec2/components/VideoFramePool.h
+++ b/components/include/v4l2_codec2/components/VideoFramePool.h
@@ -17,8 +17,8 @@
 #include <base/threading/thread.h>
 
 #include <size.h>
+#include <v4l2_codec2/common/VideoTypes.h>
 #include <v4l2_codec2/components/VideoFrame.h>
-#include <v4l2_codec2/components/VideoTypes.h>
 
 namespace android {