v4l2_codec2: Move common code to common helpers folder.

This CL moves the C2VEAFormatConverter.cpp/h and C2VDACommon.h files to
the common helpers package, so they can be reused by the upcoming
V4L2EncodeComponent. Additionaly some fo the code in
VideoEncodeAcceleratorAdaptor.h has been moved to the common.h file.

Some files have been renamed in the process:
C2VEAFormatConverter.cpp/h -> FormatConverter.cpp/h
C2VDACommon.h -> Common.h

Note: The original C2VDACommon.h file has not been removed yet as it's
referenced by vendor/google_arc/. It will be deleted after all
references have been removed.

Bug: 143333813
Test: m -j32
Change-Id: I97044e0916518bee8882604dd68872c3f49cfafb
diff --git a/Android.mk b/Android.mk
index 8564183..6066c14 100644
--- a/Android.mk
+++ b/Android.mk
@@ -9,13 +9,13 @@
         C2EncoderInterface.cpp \
         C2VDAComponent.cpp \
         C2VEAComponent.cpp \
-        C2VEAFormatConverter.cpp \
         C2VDAAdaptor.cpp   \
 
 LOCAL_C_INCLUDES += \
         $(TOP)/external/libchrome \
         $(TOP)/external/gtest/include \
         $(TOP)/external/v4l2_codec2/accel \
+        $(TOP)/external/v4l2_codec2/common \
         $(TOP)/external/v4l2_codec2/include \
         $(TOP)/frameworks/av/media/codec2/components/base/include \
         $(TOP)/frameworks/av/media/codec2/core/include \
@@ -46,7 +46,6 @@
                           libvda_c2_pixelformat \
 
 LOCAL_STATIC_LIBRARIES := libv4l2_codec2_common \
-                          libyuv_static \
 
 # -Wno-unused-parameter is needed for libchrome/base codes
 LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter
diff --git a/C2VEAComponent.cpp b/C2VEAComponent.cpp
index ba084b4..5de5ae9 100644
--- a/C2VEAComponent.cpp
+++ b/C2VEAComponent.cpp
@@ -14,13 +14,13 @@
 #include <C2Config.h>
 #include <C2PlatformSupport.h>
 #include <C2VEAComponent.h>
-#include <C2VEAFormatConverter.h>
 #include <SimpleC2Interface.h>
 #include <base/bind.h>
 #include <base/files/scoped_file.h>
 #include <inttypes.h>
 #include <utils/Log.h>
 #include <v4l2_codec2/common/EncodeHelpers.h>
+#include <v4l2_codec2/common/FormatConverter.h>
 
 #include <algorithm>
 
@@ -839,8 +839,8 @@
 #ifdef USE_VEA_FORMAT_CONVERTER
     // Note: OnRequireBitstreamBuffers() must not be called twice.
     CHECK(!mFormatConverter);
-    mFormatConverter = C2VEAFormatConverter::Create(kInputPixelFormat, visibleSize, inputCount,
-                                                    inputCodedSize);
+    mFormatConverter =
+            FormatConverter::Create(kInputPixelFormat, visibleSize, inputCount, inputCodedSize);
     if (!mFormatConverter) {
         if (mStartDoneEvent) {
             mVEAInitResult = VideoEncodeAcceleratorAdaptor::Result::PLATFORM_FAILURE;
diff --git a/common/Android.bp b/common/Android.bp
index cfaa5a1..e9d407b 100644
--- a/common/Android.bp
+++ b/common/Android.bp
@@ -8,6 +8,7 @@
 
     srcs: [
         "EncodeHelpers.cpp",
+        "FormatConverter.cpp",
         "V4L2ComponentCommon.cpp",
     ],
 
@@ -16,6 +17,7 @@
     ],
 
     shared_libs: [
+        "libchrome",
         "libcutils",
         "liblog",
         "libui",
@@ -23,6 +25,10 @@
         "libv4l2_codec2_accel"
     ],
 
+    static_libs: [
+        "libyuv_static"
+    ],
+
     cflags: [
       "-Werror",
       "-Wall",
diff --git a/C2VEAFormatConverter.cpp b/common/FormatConverter.cpp
similarity index 83%
rename from C2VEAFormatConverter.cpp
rename to common/FormatConverter.cpp
index 7c81d94..657676e 100644
--- a/C2VEAFormatConverter.cpp
+++ b/common/FormatConverter.cpp
@@ -3,23 +3,25 @@
 // found in the LICENSE file.
 
 //#define LOG_NDEBUG 0
-#define LOG_TAG "C2VEAFormatConverter"
+#define LOG_TAG "FormatConverter"
 
-#include <C2VDACommon.h>  // for HalPixelFormat
-#include <C2VEAFormatConverter.h>
-
-#include <C2AllocatorGralloc.h>
-#include <C2PlatformSupport.h>
-
-#include <android/hardware/graphics/common/1.0/types.h>
-#include <utils/Log.h>
+#include <v4l2_codec2/common/FormatConverter.h>
 
 #include <inttypes.h>
-#include <libyuv.h>
 
 #include <memory>
 #include <string>
 
+#include <C2AllocatorGralloc.h>
+#include <C2PlatformSupport.h>
+#include <android/hardware/graphics/common/1.0/types.h>
+#include <inttypes.h>
+#include <libyuv.h>
+#include <ui/GraphicBuffer.h>
+#include <utils/Log.h>
+
+#include <v4l2_codec2/common/Common.h>  // for HalPixelFormat
+
 using android::hardware::graphics::common::V1_0::BufferUsage;
 
 namespace android {
@@ -28,8 +30,9 @@
 // The constant expression of mapping the pixel format conversion pair (src, dst) to a unique
 // integer.
 constexpr int convertMap(media::VideoPixelFormat src, media::VideoPixelFormat dst) {
-    return static_cast<int>(src) * (static_cast<int>(
-            media::VideoPixelFormat::PIXEL_FORMAT_MAX) + 1) + static_cast<int>(dst);
+    return static_cast<int>(src) *
+                   (static_cast<int>(media::VideoPixelFormat::PIXEL_FORMAT_MAX) + 1) +
+           static_cast<int>(dst);
 }
 
 // The helper function to copy a plane pixel by pixel. It assumes bytesPerPixel is 1.
@@ -51,8 +54,7 @@
 }  // namespace
 
 ImplDefinedToRGBXMap::ImplDefinedToRGBXMap(sp<GraphicBuffer> buf, uint8_t* addr, int rowInc)
-      : mBuffer(std::move(buf)), mAddr(addr), mRowInc(rowInc) {
-}
+      : mBuffer(std::move(buf)), mAddr(addr), mRowInc(rowInc) {}
 
 ImplDefinedToRGBXMap::~ImplDefinedToRGBXMap() {
     mBuffer->unlock();
@@ -63,9 +65,8 @@
         const C2ConstGraphicBlock& block) {
     uint32_t width, height, format, stride, igbpSlot, generation;
     uint64_t usage, igbpId;
-    android::_UnwrapNativeCodec2GrallocMetadata(block.handle(), &width, &height,
-                                                &format, &usage, &stride, &generation, &igbpId,
-                                                &igbpSlot);
+    android::_UnwrapNativeCodec2GrallocMetadata(block.handle(), &width, &height, &format, &usage,
+                                                &stride, &generation, &igbpId, &igbpSlot);
 
     if (format != HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) {
         ALOGE("The original format (=%u) is not IMPLEMENTATION_DEFINED", format);
@@ -92,26 +93,27 @@
 }
 
 // static
-std::unique_ptr<C2VEAFormatConverter> C2VEAFormatConverter::Create(
-        media::VideoPixelFormat outFormat, const media::Size& visibleSize, uint32_t inputCount,
-        const media::Size& codedSize) {
+std::unique_ptr<FormatConverter> FormatConverter::Create(media::VideoPixelFormat outFormat,
+                                                         const media::Size& visibleSize,
+                                                         uint32_t inputCount,
+                                                         const media::Size& codedSize) {
     if (outFormat != media::VideoPixelFormat::PIXEL_FORMAT_I420 &&
         outFormat != media::VideoPixelFormat::PIXEL_FORMAT_NV12) {
         ALOGE("Unsupported output format: %d", static_cast<int32_t>(outFormat));
         return nullptr;
     }
 
-    std::unique_ptr<C2VEAFormatConverter> converter(new C2VEAFormatConverter);
+    std::unique_ptr<FormatConverter> converter(new FormatConverter);
     if (converter->initialize(outFormat, visibleSize, inputCount, codedSize) != C2_OK) {
-        ALOGE("Failed to initialize C2VEAFormatConverter");
+        ALOGE("Failed to initialize FormatConverter");
         return nullptr;
     }
     return converter;
 }
 
-c2_status_t C2VEAFormatConverter::initialize(media::VideoPixelFormat outFormat,
-                                             const media::Size& visibleSize, uint32_t inputCount,
-                                             const media::Size& codedSize) {
+c2_status_t FormatConverter::initialize(media::VideoPixelFormat outFormat,
+                                        const media::Size& visibleSize, uint32_t inputCount,
+                                        const media::Size& codedSize) {
     ALOGV("initialize(out_format=%s, visible_size=%dx%d, input_count=%u, coded_size=%dx%d)",
           media::VideoPixelFormatToString(outFormat).c_str(), visibleSize.width(),
           visibleSize.height(), inputCount, codedSize.width(), codedSize.height());
@@ -135,10 +137,11 @@
     uint32_t bufferCount = std::max(inputCount, kMinInputBufferCount);
     for (uint32_t i = 0; i < bufferCount; i++) {
         std::shared_ptr<C2GraphicBlock> block;
-        status = pool->fetchGraphicBlock(
-                codedSize.width(), codedSize.height(), static_cast<uint32_t>(halFormat),
-                {(C2MemoryUsage::CPU_READ|C2MemoryUsage::CPU_WRITE),
-                 static_cast<uint64_t>(BufferUsage::VIDEO_ENCODER)}, &block);
+        status = pool->fetchGraphicBlock(codedSize.width(), codedSize.height(),
+                                         static_cast<uint32_t>(halFormat),
+                                         {(C2MemoryUsage::CPU_READ | C2MemoryUsage::CPU_WRITE),
+                                          static_cast<uint64_t>(BufferUsage::VIDEO_ENCODER)},
+                                         &block);
         if (status != C2_OK) {
             ALOGE("Failed to fetch graphic block (err=%d)", status);
             return status;
@@ -158,9 +161,9 @@
     return C2_OK;
 }
 
-C2ConstGraphicBlock C2VEAFormatConverter::convertBlock(uint64_t frameIndex,
-                                                       const C2ConstGraphicBlock& inputBlock,
-                                                       c2_status_t* status) {
+C2ConstGraphicBlock FormatConverter::convertBlock(uint64_t frameIndex,
+                                                  const C2ConstGraphicBlock& inputBlock,
+                                                  c2_status_t* status) {
     if (!isReady()) {
         ALOGV("There is no available block for conversion");
         *status = C2_NO_MEMORY;
@@ -249,8 +252,8 @@
                         media::VideoPixelFormat::PIXEL_FORMAT_NV12):
             libyuv::CopyPlane(srcY, srcStrideY, dstY, dstStrideY, mVisibleSize.width(),
                               mVisibleSize.height());
-            copyPlaneByPixel(srcU, srcStrideU, 2, dstUV, dstStrideUV, 2,
-                             mVisibleSize.width() / 2, mVisibleSize.height() / 2);
+            copyPlaneByPixel(srcU, srcStrideU, 2, dstUV, dstStrideUV, 2, mVisibleSize.width() / 2,
+                             mVisibleSize.height() / 2);
             copyPlaneByPixel(srcV, srcStrideV, 2, dstUV + 1, dstStrideUV, 2,
                              mVisibleSize.width() / 2, mVisibleSize.height() / 2);
             break;
@@ -266,10 +269,9 @@
         // BGRA_8888 is not used now?
         inputFormat = media::VideoPixelFormat::PIXEL_FORMAT_ABGR;
 
-        const uint8_t* srcRGB = (idMap) ? idMap->addr()
-                                        : inputView.data()[C2PlanarLayout::PLANE_R];
-        const int srcStrideRGB = (idMap) ? idMap->rowInc()
-                                         : inputLayout.planes[C2PlanarLayout::PLANE_R].rowInc;
+        const uint8_t* srcRGB = (idMap) ? idMap->addr() : inputView.data()[C2PlanarLayout::PLANE_R];
+        const int srcStrideRGB =
+                (idMap) ? idMap->rowInc() : inputLayout.planes[C2PlanarLayout::PLANE_R].rowInc;
 
         switch (convertMap(inputFormat, mOutFormat)) {
         case convertMap(media::VideoPixelFormat::PIXEL_FORMAT_ABGR,
@@ -278,8 +280,7 @@
                                dstStrideV, mVisibleSize.width(), mVisibleSize.height());
             break;
         case convertMap(media::VideoPixelFormat::PIXEL_FORMAT_ABGR,
-                        media::VideoPixelFormat::PIXEL_FORMAT_NV12):
-        {
+                        media::VideoPixelFormat::PIXEL_FORMAT_NV12): {
             // There is no libyuv function to convert ABGR to NV12. Therefore, we first convert to
             // I420 on dst-Y plane and temporary U/V plane. Then we copy U and V pixels from
             // temporary planes to dst-UV interleavedly.
@@ -312,13 +313,13 @@
     return outputBlock->share(C2Rect(mVisibleSize.width(), mVisibleSize.height()), C2Fence());
 }
 
-c2_status_t C2VEAFormatConverter::returnBlock(uint64_t frameIndex) {
+c2_status_t FormatConverter::returnBlock(uint64_t frameIndex) {
     ALOGV("returnBlock(frame_index=%" PRIu64 ")", frameIndex);
 
-    auto iter = std::find_if(
-            mGraphicBlocks.begin(), mGraphicBlocks.end(),
-            [frameIndex](const std::unique_ptr<BlockEntry>& be) {
-                    return be->mAssociatedFrameIndex == frameIndex; });
+    auto iter = std::find_if(mGraphicBlocks.begin(), mGraphicBlocks.end(),
+                             [frameIndex](const std::unique_ptr<BlockEntry>& be) {
+                                 return be->mAssociatedFrameIndex == frameIndex;
+                             });
     if (iter == mGraphicBlocks.end()) {
         ALOGE("Failed to find graphic block by converted/zero-copied frame index: %" PRIu64 "",
               frameIndex);
diff --git a/common/include/v4l2_codec2/common/Common.h b/common/include/v4l2_codec2/common/Common.h
new file mode 100644
index 0000000..1b816ef
--- /dev/null
+++ b/common/include/v4l2_codec2/common/Common.h
@@ -0,0 +1,34 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ANDROID_V4L2_CODEC2_COMMON_COMMON_H
+#define ANDROID_V4L2_CODEC2_COMMON_COMMON_H
+
+#include <inttypes.h>
+
+namespace android {
+
+// The offset and stride of a video frame plane.
+struct VideoFramePlane {
+    uint32_t mOffset;
+    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
+
+#endif  // ANDROID_V4L2_CODEC2_COMMON_COMMON_H
diff --git a/common/include/v4l2_codec2/common/EncodeHelpers.h b/common/include/v4l2_codec2/common/EncodeHelpers.h
index da93606..ff6e00b 100644
--- a/common/include/v4l2_codec2/common/EncodeHelpers.h
+++ b/common/include/v4l2_codec2/common/EncodeHelpers.h
@@ -8,10 +8,44 @@
 #include <C2Config.h>
 #include <C2ParamDef.h>
 #include <system/graphics.h>
+
+#include <size.h>
 #include <video_codecs.h>
+#include <video_pixel_format.h>
 
 namespace android {
 
+// Specification of an encoding profile supported by an encoder.
+struct VideoEncodeProfile {
+    media::VideoCodecProfile mProfile;
+    media::Size mMaxResolution;
+    uint32_t mMaxFramerateNumerator;
+    uint32_t mMaxFramerateDenominator;
+};
+
+// The encoder parameter set.
+//  |mInputFormat| is the pixel format of the input frames.
+//  |mInputVisibleSize| is the resolution of the input frames.
+//  |mOutputProfile| is the codec profile of the encoded output stream.
+//  |mInitialBitrate| is the initial bitrate of the encoded output stream, in bits per second.
+//  |mInitialFramerate| is the initial requested framerate.
+//  |mH264OutputLevel| is H264 level of encoded output stream.
+//  |mStorageType| is the storage type of video frame provided on encode().
+struct VideoEncoderAcceleratorConfig {
+    enum VideoFrameStorageType {
+        SHMEM = 0,
+        DMABUF = 1,
+    };
+
+    media::VideoPixelFormat mInputFormat;
+    media::Size mInputVisibleSize;
+    media::VideoCodecProfile mOutputProfile;
+    uint32_t mInitialBitrate;
+    uint32_t mInitialFramerate;
+    uint8_t mH264OutputLevel;
+    VideoFrameStorageType mStorageType;
+};
+
 // Convert the specified C2Config profile to a media::VideoCodecProfile.
 media::VideoCodecProfile c2ProfileToVideoCodecProfile(C2Config::profile_t profile);
 
diff --git a/include/C2VEAFormatConverter.h b/common/include/v4l2_codec2/common/FormatConverter.h
similarity index 87%
rename from include/C2VEAFormatConverter.h
rename to common/include/v4l2_codec2/common/FormatConverter.h
index cc49af7..f00f115 100644
--- a/include/C2VEAFormatConverter.h
+++ b/common/include/v4l2_codec2/common/FormatConverter.h
@@ -2,24 +2,22 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef ANDROID_C2_VEA_FORMAT_CONVERTER_H
-#define ANDROID_C2_VEA_FORMAT_CONVERTER_H
-
-#include <size.h>
-#include <video_pixel_format.h>
-
-#include <C2Buffer.h>
-
-#include <base/macros.h>
-
-#include <ui/GraphicBuffer.h>
+#ifndef ANDROID_V4L2_CODEC2_COMMON_FORMAT_CONVERTER_H
+#define ANDROID_V4L2_CODEC2_COMMON_FORMAT_CONVERTER_H
 
 #include <limits>
 #include <queue>
 #include <vector>
 
+#include <C2Buffer.h>
+#include <size.h>
+#include <utils/StrongPointer.h>
+#include <video_pixel_format.h>
+
 namespace android {
 
+class GraphicBuffer;
+
 // ImplDefinedToRGBXMap can provide the layout for RGB-backed IMPLEMENTATION_DEFINED format case,
 // which will be failed to map by C2AllocationGralloc::map(). When the instance is created, it will
 // own the GraphicBuffer wrapped from input block and lock it, to provide the address, offset, and
@@ -43,13 +41,16 @@
     const int mRowInc;
 };
 
-class C2VEAFormatConverter {
+class FormatConverter {
 public:
-    ~C2VEAFormatConverter() = default;
+    ~FormatConverter() = default;
 
-    // Create C2VEAFormatConverter instance and initialize it, nullptr will be returned on
+    FormatConverter(const FormatConverter&) = delete;
+    FormatConverter& operator=(const FormatConverter&) = delete;
+
+    // Create FormatConverter instance and initialize it, nullptr will be returned on
     // initialization error.
-    static std::unique_ptr<C2VEAFormatConverter> Create(media::VideoPixelFormat outFormat,
+    static std::unique_ptr<FormatConverter> Create(media::VideoPixelFormat outFormat,
                                                         const media::Size& visibleSize,
                                                         uint32_t inputCount,
                                                         const media::Size& codedSize);
@@ -74,7 +75,7 @@
     // 1. If |mBlock| is an allocated graphic block (not nullptr). This BlockEntry is for
     //    conversion, and |mAssociatedFrameIndex| records the frame index of the input frame which
     //    is currently converted from. This is created on initialize() and released while
-    //    C2VEAFormatConverter is destroyed.
+    //    FormatConverter is destroyed.
     // 2. If |mBlock| is nullptr. This BlockEntry is only used to record zero-copied frame index to
     //    |mAssociatedFrameIndex|. This is created on zero-copy is applied during convertBlock(),
     //    and released on returnBlock() in associated with returned frame index.
@@ -88,7 +89,7 @@
         uint64_t mAssociatedFrameIndex = kNoFrameAssociated;
     };
 
-    C2VEAFormatConverter() = default;
+    FormatConverter() = default;
 
     // Initialize foramt converter. It will pre-allocate a set of graphic blocks as |codedSize| and
     // |outFormat|. This function should be called prior to other functions.
@@ -107,10 +108,8 @@
 
     media::VideoPixelFormat mOutFormat = media::VideoPixelFormat::PIXEL_FORMAT_UNKNOWN;
     media::Size mVisibleSize;
-
-    DISALLOW_COPY_AND_ASSIGN(C2VEAFormatConverter);
 };
 
 }  // namespace android
 
-#endif  // ANDROID_C2_VEA_FORMAT_CONVERTER_H
+#endif  // ANDROID_V4L2_CODEC2_COMMON_FORMAT_CONVERTER_H
diff --git a/include/C2EncoderInterface.h b/include/C2EncoderInterface.h
index c5d8960..b4f42a9 100644
--- a/include/C2EncoderInterface.h
+++ b/include/C2EncoderInterface.h
@@ -5,16 +5,17 @@
 #ifndef ANDROID_C2_ENCODER_INTERFACE_H
 #define ANDROID_C2_ENCODER_INTERFACE_H
 
+#include <vector>
+
+#include <base/optional.h>
 #include <C2.h>
 #include <C2Buffer.h>
 #include <C2Config.h>
-#include <VideoEncodeAcceleratorAdaptor.h>
-#include <accel/size.h>
-#include <accel/video_codecs.h>
-#include <base/optional.h>
 #include <util/C2InterfaceHelper.h>
 
-#include <vector>
+#include <size.h>
+#include <video_codecs.h>
+#include <v4l2_codec2/common/EncodeHelpers.h>
 
 namespace android {
 
diff --git a/include/C2VDAComponent.h b/include/C2VDAComponent.h
index be636d6..7d87ee0 100644
--- a/include/C2VDAComponent.h
+++ b/include/C2VDAComponent.h
@@ -5,13 +5,12 @@
 #ifndef ANDROID_C2_VDA_COMPONENT_H
 #define ANDROID_C2_VDA_COMPONENT_H
 
-#include <C2VDACommon.h>
-#include <VideoDecodeAcceleratorAdaptor.h>
-
-#include <rect.h>
-#include <size.h>
-#include <video_codecs.h>
-#include <video_decode_accelerator.h>
+#include <atomic>
+#include <deque>
+#include <map>
+#include <mutex>
+#include <queue>
+#include <unordered_map>
 
 #include <C2Component.h>
 #include <C2Config.h>
@@ -27,12 +26,12 @@
 #include <base/synchronization/waitable_event.h>
 #include <base/threading/thread.h>
 
-#include <atomic>
-#include <deque>
-#include <map>
-#include <mutex>
-#include <queue>
-#include <unordered_map>
+#include <VideoDecodeAcceleratorAdaptor.h>
+#include <rect.h>
+#include <size.h>
+#include <video_codecs.h>
+#include <video_decode_accelerator.h>
+#include <v4l2_codec2/common/Common.h>
 
 namespace android {
 
diff --git a/include/C2VEAComponent.h b/include/C2VEAComponent.h
index 5e97520..ca60865 100644
--- a/include/C2VEAComponent.h
+++ b/include/C2VEAComponent.h
@@ -5,25 +5,26 @@
 #ifndef ANDROID_C2_VEA_COMPONENT_H
 #define ANDROID_C2_VEA_COMPONENT_H
 
+#include <atomic>
+#include <map>
+#include <memory>
+
 #include <C2Component.h>
-#include <C2EncoderInterface.h>
-#include <VideoEncodeAcceleratorAdaptor.h>
-#include <accel/size.h>
 #include <base/memory/weak_ptr.h>
 #include <base/optional.h>
 #include <base/single_thread_task_runner.h>
 #include <base/synchronization/waitable_event.h>
 #include <base/threading/thread.h>
 
-#include <atomic>
-#include <map>
-#include <memory>
+#include <size.h>
+#include <C2EncoderInterface.h>
+#include <VideoEncodeAcceleratorAdaptor.h>
 
 class C2ReflectorHelper;
 
 namespace android {
 
-class C2VEAFormatConverter;
+class FormatConverter;
 
 class C2VEAComponent : public C2Component,
                        public VideoEncodeAcceleratorAdaptor::Client,
@@ -224,7 +225,7 @@
     std::deque<std::unique_ptr<C2Work>> mPendingWorks;
     // If using format converter for input frames, this will be initialized for converting input
     // frames to the default pixel format (onto the additional buffers) to send to VEA.
-    std::unique_ptr<C2VEAFormatConverter> mFormatConverter;
+    std::unique_ptr<FormatConverter> mFormatConverter;
 
     // The following members should be utilized on parent thread.
 
diff --git a/include/VideoDecodeAcceleratorAdaptor.h b/include/VideoDecodeAcceleratorAdaptor.h
index f4fd37d..f5792a0 100644
--- a/include/VideoDecodeAcceleratorAdaptor.h
+++ b/include/VideoDecodeAcceleratorAdaptor.h
@@ -5,25 +5,18 @@
 #ifndef ANDROID_VIDEO_DECODE_ACCELERATOR_ADAPTOR_H
 #define ANDROID_VIDEO_DECODE_ACCELERATOR_ADAPTOR_H
 
-#include <C2VDACommon.h>
+#include <vector>
+
+#include <base/files/scoped_file.h>
 
 #include <rect.h>
 #include <size.h>
 #include <video_codecs.h>
 #include <video_pixel_format.h>
-
-#include <base/files/scoped_file.h>
-
-#include <vector>
+#include <v4l2_codec2/common/Common.h>
 
 namespace android {
 
-// The offset and stride of a video frame plane.
-struct VideoFramePlane {
-    uint32_t mOffset;
-    uint32_t mStride;
-};
-
 // Video decoder accelerator adaptor interface.
 // The adaptor plays the role of providing unified adaptor API functions and client callback to
 // codec component side.
diff --git a/include/VideoEncodeAcceleratorAdaptor.h b/include/VideoEncodeAcceleratorAdaptor.h
index 9c073e4..7222f59 100644
--- a/include/VideoEncodeAcceleratorAdaptor.h
+++ b/include/VideoEncodeAcceleratorAdaptor.h
@@ -5,53 +5,19 @@
 #ifndef ANDROID_VIDEO_ENCODE_ACCELERATOR_ADAPTOR_H
 #define ANDROID_VIDEO_ENCODE_ACCELERATOR_ADAPTOR_H
 
+#include <vector>
+
+#include <base/files/scoped_file.h>
+#include <base/optional.h>
+
+#include <h264_parser.h>
 #include <size.h>
 #include <video_codecs.h>
 #include <video_pixel_format.h>
-
-#include <base/files/scoped_file.h>
-
-#include <vector>
+#include <v4l2_codec2/common/Common.h>
 
 namespace android {
 
-// The offset and stride of a video frame plane.
-struct VideoFramePlane {
-    uint32_t mOffset;
-    uint32_t mStride;
-};
-
-// Specification of an encoding profile supported by an encoder.
-struct VideoEncodeProfile {
-    media::VideoCodecProfile mProfile;
-    media::Size mMaxResolution;
-    uint32_t mMaxFramerateNumerator;
-    uint32_t mMaxFramerateDenominator;
-};
-
-// The encoder parameter set.
-//  |mInputFormat| is the pixel format of the input frames.
-//  |mInputVisibleSize| is the resolution of the input frames.
-//  |mOutputProfile| is the codec profile of the encoded output stream.
-//  |mInitialBitrate| is the initial bitrate of the encoded output stream, in bits per second.
-//  |mInitialFramerate| is the initial requested framerate.
-//  |mH264OutputLevel| is H264 level of encoded output stream.
-//  |mStorageType| is the storage type of video frame provided on encode().
-struct VideoEncoderAcceleratorConfig {
-    enum VideoFrameStorageType {
-        SHMEM = 0,
-        DMABUF = 1,
-    };
-
-    media::VideoPixelFormat mInputFormat;
-    media::Size mInputVisibleSize;
-    media::VideoCodecProfile mOutputProfile;
-    uint32_t mInitialBitrate;
-    uint32_t mInitialFramerate;
-    uint8_t mH264OutputLevel;
-    VideoFrameStorageType mStorageType;
-};
-
 // Video encoder accelerator adaptor interface.
 // The adaptor plays the role of providing unified adaptor API functions and client callback to
 // codec component side.
diff --git a/tests/c2_comp_intf/Android.mk b/tests/c2_comp_intf/Android.mk
index 188b2f9..b91a598 100644
--- a/tests/c2_comp_intf/Android.mk
+++ b/tests/c2_comp_intf/Android.mk
@@ -23,6 +23,7 @@
 
 LOCAL_C_INCLUDES += \
   $(TOP)/external/v4l2_codec2/accel \
+  $(TOP)/external/v4l2_codec2/common/include \
   $(TOP)/external/v4l2_codec2/include \
   $(TOP)/frameworks/av/media/codec2/components/base/include \
   $(TOP)/frameworks/av/media/codec2/core/include \
@@ -60,8 +61,8 @@
   libv4l2_codec2_accel \
 
 LOCAL_C_INCLUDES += \
-  $(TOP)/external/v4l2_codec2 \
   $(TOP)/external/v4l2_codec2/accel \
+  $(TOP)/external/v4l2_codec2/common/include \
   $(TOP)/external/v4l2_codec2/include \
   $(TOP)/frameworks/av/media/codec2/components/base/include \
   $(TOP)/frameworks/av/media/codec2/core/include \
@@ -101,8 +102,8 @@
   libv4l2_codec2_accel \
 
 LOCAL_C_INCLUDES += \
-  $(TOP)/external/libchrome \
   $(TOP)/external/v4l2_codec2/accel \
+  $(TOP)/external/v4l2_codec2/common/include \
   $(TOP)/external/v4l2_codec2/include \
   $(TOP)/frameworks/av/media/codec2/components/base/include \
   $(TOP)/frameworks/av/media/codec2/core/include \