codec2: remove ANDROID_VERSION_NYC specific code

Note: if you really need to grab external/v4l2_codec2 repo under arc-nyc-mr1,
please use the one in master-arc-dev branch.

Bug: 32691050
Test: build pi-arc-dev image
Change-Id: I1e407efe5c86c071b385f82267e5518759609cb1
diff --git a/Android.mk b/Android.mk
index f752953..c645e7d 100644
--- a/Android.mk
+++ b/Android.mk
@@ -40,18 +40,6 @@
 
 LOCAL_LDFLAGS := -Wl,-Bsymbolic
 
-# define ANDROID_VERSION from PLATFORM_VERSION major number (ex. 7.0.1 -> 7)
-ANDROID_VERSION := $(word 1, $(subst ., , $(PLATFORM_VERSION)))
-
-ifeq ($(ANDROID_VERSION),7)  # NYC
-LOCAL_C_INCLUDES += $(TOP)/external/v4l2_codec2/vndk/include \
-
-LOCAL_SHARED_LIBRARIES += libv4l2_codec2_vndk \
-
-LOCAL_CFLAGS += -DANDROID_VERSION_NYC
-
-endif
-
 # Build C2VDAAdaptorProxy only for ARC++ case.
 ifneq (,$(findstring cheets_,$(TARGET_PRODUCT)))
 
diff --git a/C2VDAComponent.cpp b/C2VDAComponent.cpp
index 4e8023e..f702396 100644
--- a/C2VDAComponent.cpp
+++ b/C2VDAComponent.cpp
@@ -14,17 +14,10 @@
 #define __C2_GENERATE_GLOBAL_VARS__
 #include <C2VDAComponent.h>
 
-#ifdef ANDROID_VERSION_NYC
-// Get allocators from NYC-specific implementation
-#include <C2VDASupport.h>
-#else
-// Get allocators from framework
-#include <C2PlatformSupport.h>
-#endif
-
 #include <videodev2.h>
 
 #include <C2ComponentFactory.h>
+#include <C2PlatformSupport.h>
 
 #include <base/bind.h>
 #include <base/bind_helpers.h>
diff --git a/cmds/Android.mk b/cmds/Android.mk
index 642c9e1..3f015d9 100644
--- a/cmds/Android.mk
+++ b/cmds/Android.mk
@@ -23,6 +23,7 @@
                           libgui \
                           liblog \
                           libmedia \
+                          libmediaextractor \
                           libstagefright \
                           libstagefright_codec2 \
                           libstagefright_foundation \
@@ -37,17 +38,4 @@
 LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter
 LOCAL_CLANG := true
 
-# define ANDROID_VERSION from PLATFORM_VERSION major number (ex. 7.0.1 -> 7)
-ANDROID_VERSION := $(word 1, $(subst ., , $(PLATFORM_VERSION)))
-
-ifeq ($(ANDROID_VERSION),7)  # NYC
-LOCAL_C_INCLUDES += $(TOP)/external/v4l2_codec2/vndk/include \
-
-LOCAL_SHARED_LIBRARIES += libv4l2_codec2_vndk \
-
-LOCAL_CFLAGS += -DANDROID_VERSION_NYC
-else
-LOCAL_SHARED_LIBRARIES += libmediaextractor
-endif
-
 include $(BUILD_EXECUTABLE)
diff --git a/cmds/codec2.cpp b/cmds/codec2.cpp
index fe3fbff..10be9d0 100644
--- a/cmds/codec2.cpp
+++ b/cmds/codec2.cpp
@@ -7,17 +7,10 @@
 
 #include <C2VDAComponent.h>
 
-#ifdef ANDROID_VERSION_NYC
-// Get allocators from NYC-specific implementation
-#include <C2VDASupport.h>
-#else
-// Get allocators from framework
-#include <C2PlatformSupport.h>
-#endif
-
 #include <C2Buffer.h>
 #include <C2BufferPriv.h>
 #include <C2Component.h>
+#include <C2PlatformSupport.h>
 #include <C2Work.h>
 
 #include <binder/IServiceManager.h>
@@ -36,17 +29,11 @@
 #include <media/stagefright/foundation/ALooper.h>
 #include <media/stagefright/foundation/AMessage.h>
 #include <media/stagefright/foundation/AUtils.h>
-#ifdef ANDROID_VERSION_NYC
-#include <media/stagefright/DataSource.h>
-#include <media/stagefright/MediaExtractor.h>
-#include <media/stagefright/MediaSource.h>
-#else
 #include <media/DataSource.h>
 #include <media/MediaExtractor.h>
 #include <media/MediaSource.h>
 #include <media/stagefright/DataSourceFactory.h>
 #include <media/stagefright/MediaExtractorFactory.h>
-#endif
 
 #include <fcntl.h>
 #include <inttypes.h>
@@ -152,11 +139,7 @@
         mComposerClient(new SurfaceComposerClient) {
     CHECK_EQ(mComposerClient->initCheck(), OK);
 
-#ifdef ANDROID_VERSION_NYC
-    std::shared_ptr<C2AllocatorStore> store = GetCodec2VDAAllocatorStore();
-#else
     std::shared_ptr<C2AllocatorStore> store = GetCodec2PlatformAllocatorStore();
-#endif
     CHECK_EQ(store->fetchAllocator(C2AllocatorStore::DEFAULT_LINEAR, &mLinearAlloc), C2_OK);
 
     mLinearBlockPool = std::make_shared<C2BasicLinearBlockPool>(mLinearAlloc);
@@ -167,14 +150,7 @@
     CHECK(mControl != nullptr);
     CHECK(mControl->isValid());
 
-#ifdef ANDROID_VERSION_NYC
-    SurfaceComposerClient::openGlobalTransaction();
-    CHECK_EQ(mControl->setLayer(INT_MAX), OK);
-    CHECK_EQ(mControl->show(), OK);
-    SurfaceComposerClient::closeGlobalTransaction();
-#else
     SurfaceComposerClient::Transaction{}.setLayer(mControl, INT_MAX).show(mControl).apply();
-#endif
 
     mSurface = mControl->getSurface();
     CHECK(mSurface != nullptr);
@@ -208,28 +184,6 @@
     // TODO
 }
 
-#ifdef ANDROID_VERSION_NYC
-// TODO(johnylin): remove this when we move the development env to P
-// from master: system/core/libcutils/native_handle.c
-native_handle_t* native_handle_clone(const native_handle_t* handle) {
-    native_handle_t* clone = native_handle_create(handle->numFds, handle->numInts);
-    if (clone == nullptr) return nullptr;
-    for (int i = 0; i < handle->numFds; i++) {
-        clone->data[i] = dup(handle->data[i]);
-        ALOGV("clone handle fd: %d", clone->data[i]);
-        if (clone->data[i] == -1) {
-            clone->numFds = i;
-            native_handle_close(clone);
-            native_handle_delete(clone);
-            return nullptr;
-        }
-    }
-    memcpy(&clone->data[handle->numFds], &handle->data[handle->numFds],
-           sizeof(int) * handle->numInts);
-    return clone;
-}
-#endif
-
 status_t SimplePlayer::play(const sp<IMediaSource>& source) {
     std::deque<sp<ABuffer>> csds;
     if (kComponentName == kH264DecoderName) {
@@ -289,19 +243,10 @@
                 std::shared_ptr<C2Buffer> output = work->worklets.front()->output.buffers[0];
                 C2ConstGraphicBlock graphic_block = output->data().graphicBlocks().front();
 
-#ifdef ANDROID_VERSION_NYC
-                // Create GraphicBuffer from cloning native_handle
-                native_handle_t* cloneHandle = native_handle_clone(graphic_block.handle());
-                sp<GraphicBuffer> buffer = new GraphicBuffer(
-                        graphic_block.width(), graphic_block.height(),
-                        HAL_PIXEL_FORMAT_YCbCr_420_888, GRALLOC_USAGE_SW_READ_OFTEN,
-                        graphic_block.width(), cloneHandle, false);
-#else
                 sp<GraphicBuffer> buffer(new GraphicBuffer(
                         graphic_block.handle(), GraphicBuffer::CLONE_HANDLE, graphic_block.width(),
                         graphic_block.height(), HAL_PIXEL_FORMAT_YCbCr_420_888, 1 /* layerCount */,
                         GRALLOC_USAGE_SW_READ_OFTEN, graphic_block.width()));
-#endif
 
                 CHECK_EQ(igbp->attachBuffer(&slot, buffer), OK);
                 ALOGV("attachBuffer slot=%d ts=%lld", slot,
@@ -318,11 +263,6 @@
                 // displayed (consumed), so we could returned the graphic buffer.
                 pendingDisplayBuffers[slot].swap(output);
 
-#ifdef ANDROID_VERSION_NYC
-                // Remember to close the cloned handle.
-                native_handle_close(cloneHandle);
-                native_handle_delete(cloneHandle);
-#endif
             }
 
             bool eos = work->worklets.front()->output.flags & C2FrameData::FLAG_END_OF_STREAM;
@@ -348,11 +288,7 @@
         size_t size = 0u;
         void* data = nullptr;
         int64_t timestamp = 0u;
-#ifdef ANDROID_VERSION_NYC
-        MediaBuffer* buffer = nullptr;
-#else
         MediaBufferBase* buffer = nullptr;
-#endif
         sp<ABuffer> csd;
         if (!csds.empty()) {
             csd = std::move(csds.front());
@@ -370,13 +306,8 @@
 
                 break;
             }
-#ifdef ANDROID_VERSION_NYC
-            sp<MetaData> meta = buffer->meta_data();
-            CHECK(meta->findInt64(kKeyTime, &timestamp));
-#else
             MetaDataBase &meta = buffer->meta_data();
             CHECK(meta.findInt64(kKeyTime, &timestamp));
-#endif
 
             size = buffer->size();
             data = buffer->data();
@@ -440,23 +371,15 @@
 static bool getMediaSourceFromFile(const char* filename, sp<IMediaSource>* source) {
     source->clear();
 
-#ifdef ANDROID_VERSION_NYC
-    sp<DataSource> dataSource = DataSource::CreateFromURI(nullptr /* httpService */, filename);
-#else
     sp<DataSource> dataSource =
             DataSourceFactory::CreateFromURI(nullptr /* httpService */, filename);
-#endif
 
     if (dataSource == nullptr) {
         fprintf(stderr, "Unable to create data source.\n");
         return false;
     }
 
-#ifdef ANDROID_VERSION_NYC
-    sp<IMediaExtractor> extractor = MediaExtractor::Create(dataSource);
-#else
     sp<IMediaExtractor> extractor = MediaExtractorFactory::Create(dataSource);
-#endif
     if (extractor == nullptr) {
         fprintf(stderr, "could not create extractor.\n");
         return false;
diff --git a/tests/Android.mk b/tests/Android.mk
index ba22580..a6ea6fe 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -46,6 +46,7 @@
   libcutils \
   liblog \
   libmedia \
+  libmediaextractor \
   libstagefright \
   libstagefright_codec2 \
   libstagefright_codec2_vndk \
@@ -69,17 +70,4 @@
 
 LOCAL_LDFLAGS := -Wl,-Bsymbolic
 
-# define ANDROID_VERSION from PLATFORM_VERSION major number (ex. 7.0.1 -> 7)
-ANDROID_VERSION := $(word 1, $(subst ., , $(PLATFORM_VERSION)))
-
-ifeq ($(ANDROID_VERSION),7)  # NYC
-LOCAL_C_INCLUDES += $(TOP)/external/v4l2_codec2/vndk/include \
-
-LOCAL_SHARED_LIBRARIES += libv4l2_codec2_vndk \
-
-LOCAL_CFLAGS += -DANDROID_VERSION_NYC
-else
-LOCAL_SHARED_LIBRARIES += libmediaextractor
-endif
-
 include $(BUILD_NATIVE_TEST)
diff --git a/tests/C2VDAComponent_test.cpp b/tests/C2VDAComponent_test.cpp
index e8ef7ce..75a9e6e 100644
--- a/tests/C2VDAComponent_test.cpp
+++ b/tests/C2VDAComponent_test.cpp
@@ -7,17 +7,10 @@
 
 #include <C2VDAComponent.h>
 
-#ifdef ANDROID_VERSION_NYC
-// Get allocators from NYC-specific implementation
-#include <C2VDASupport.h>
-#else
-// Get allocators from framework
-#include <C2PlatformSupport.h>
-#endif
-
 #include <C2Buffer.h>
 #include <C2BufferPriv.h>
 #include <C2Component.h>
+#include <C2PlatformSupport.h>
 #include <C2Work.h>
 
 #include <base/files/file.h>
@@ -37,17 +30,11 @@
 #include <media/stagefright/foundation/AMessage.h>
 #include <media/stagefright/foundation/AUtils.h>
 #include <utils/Log.h>
-#ifdef ANDROID_VERSION_NYC
-#include <media/stagefright/DataSource.h>
-#include <media/stagefright/MediaExtractor.h>
-#include <media/stagefright/MediaSource.h>
-#else
 #include <media/DataSource.h>
 #include <media/MediaExtractor.h>
 #include <media/MediaSource.h>
 #include <media/stagefright/DataSourceFactory.h>
 #include <media/stagefright/MediaExtractorFactory.h>
-#endif
 
 #include <fcntl.h>
 #include <inttypes.h>
@@ -234,11 +221,7 @@
 };
 
 C2VDAComponentTest::C2VDAComponentTest() : mListener(new Listener(this)) {
-#ifdef ANDROID_VERSION_NYC
-    std::shared_ptr<C2AllocatorStore> store = GetCodec2VDAAllocatorStore();
-#else
     std::shared_ptr<C2AllocatorStore> store = GetCodec2PlatformAllocatorStore();
-#endif
     CHECK_EQ(store->fetchAllocator(C2AllocatorStore::DEFAULT_LINEAR, &mLinearAlloc), C2_OK);
 
     mLinearBlockPool = std::make_shared<C2BasicLinearBlockPool>(mLinearAlloc);
@@ -282,24 +265,15 @@
                                    const TestVideoFile::CodecType codec, sp<IMediaSource>* source) {
     source->clear();
 
-#ifdef ANDROID_VERSION_NYC
-    sp<DataSource> dataSource =
-            DataSource::CreateFromURI(nullptr /* httpService */, filename.c_str());
-#else
     sp<DataSource> dataSource =
             DataSourceFactory::CreateFromURI(nullptr /* httpService */, filename.c_str());
-#endif
 
     if (dataSource == nullptr) {
         fprintf(stderr, "Unable to create data source.\n");
         return false;
     }
 
-#ifdef ANDROID_VERSION_NYC
-    sp<IMediaExtractor> extractor = MediaExtractor::Create(dataSource);
-#else
     sp<IMediaExtractor> extractor = MediaExtractorFactory::Create(dataSource);
-#endif
     if (extractor == nullptr) {
         fprintf(stderr, "could not create extractor.\n");
         return false;
@@ -602,11 +576,7 @@
             size_t size = 0u;
             void* data = nullptr;
             int64_t timestamp = 0u;
-#ifdef ANDROID_VERSION_NYC
-            MediaBuffer* buffer = nullptr;
-#else
             MediaBufferBase* buffer = nullptr;
-#endif
             sp<ABuffer> csd;
             bool queueDummyEOSWork = false;
             if (!csds.empty()) {
@@ -629,13 +599,8 @@
                     // TODO(johnylin): add test with drain with DRAIN_COMPONENT_NO_EOS when we know
                     //                 the actual use case of it.
                 } else {
-#ifdef ANDROID_VERSION_NYC
-                    sp<MetaData> meta = buffer->meta_data();
-                    ASSERT_TRUE(meta->findInt64(kKeyTime, &timestamp));
-#else
                     MetaDataBase &meta = buffer->meta_data();
                     ASSERT_TRUE(meta.findInt64(kKeyTime, &timestamp));
-#endif
                     size = buffer->size();
                     data = buffer->data();
                 }
diff --git a/vndk/Android.mk b/vndk/Android.mk
deleted file mode 100644
index 77a06b5..0000000
--- a/vndk/Android.mk
+++ /dev/null
@@ -1,50 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# Note: libv4l2_codec2_vndk should be only compiled on ARC-NYC env.
-#       For ARC-PIC this makefile should be just skipped.
-
-# define ANDROID_VERSION from PLATFORM_VERSION major number (ex. 7.0.1 -> 7)
-ANDROID_VERSION := $(word 1, $(subst ., , $(PLATFORM_VERSION)))
-
-ifeq ($(ANDROID_VERSION),7)  # NYC
-
-LOCAL_SRC_FILES:= \
-        C2AllocatorCrosGrallocNyc.cpp \
-        C2AllocatorMemDealer.cpp \
-        C2VDAStore.cpp \
-
-LOCAL_C_INCLUDES += \
-        $(TOP)/external/v4l2_codec2/vndk/include \
-        $(TOP)/frameworks/av/media/libstagefright/include \
-        $(TOP)/frameworks/native/include \
-        $(TOP)/hardware/google/av/codec2/include \
-        $(TOP)/hardware/google/av/codec2/vndk/include \
-
-LOCAL_MODULE:= libv4l2_codec2_vndk
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SHARED_LIBRARIES := libbinder \
-                          libcutils \
-                          libgui \
-                          liblog \
-                          libmedia \
-                          libstagefright \
-                          libstagefright_codec2 \
-                          libstagefright_codec2_vndk \
-                          libstagefright_foundation \
-                          libui \
-                          libutils \
-                          android.hardware.media.bufferpool@1.0 \
-
-LOCAL_CFLAGS += -Werror -Wall -std=c++14
-LOCAL_CLANG := true
-LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow
-
-LOCAL_LDFLAGS := -Wl,-Bsymbolic
-
-LOCAL_CFLAGS += -DANDROID_VERSION_NYC
-
-include $(BUILD_SHARED_LIBRARY)
-
-endif  # ifeq ($(ANDROID_VERSION),7)
diff --git a/vndk/C2AllocatorCrosGrallocNyc.cpp b/vndk/C2AllocatorCrosGrallocNyc.cpp
deleted file mode 100644
index 479b935..0000000
--- a/vndk/C2AllocatorCrosGrallocNyc.cpp
+++ /dev/null
@@ -1,272 +0,0 @@
-// Copyright 2017 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.
-
-//#define LOG_NDEBUG 0
-#define LOG_TAG "C2AllocatorCrosGralloc"
-
-#include <C2AllocatorCrosGrallocNyc.h>
-
-#include <C2Buffer.h>
-
-#include <media/stagefright/MediaDefs.h>
-#include <ui/GraphicBuffer.h>
-#include <utils/Log.h>
-#include <utils/misc.h>
-
-#include <limits>
-#include <sys/mman.h>
-#include <limits>
-
-namespace android {
-
-/* ================================== CROS GRALLOC ALLOCATION ================================== */
-
-class C2AllocationCrosGralloc : public C2GraphicAllocation {
-public:
-    virtual ~C2AllocationCrosGralloc();
-
-    virtual c2_status_t map(C2Rect rect, C2MemoryUsage usage, C2Fence* fence,
-                            C2PlanarLayout* layout /* nonnull */,
-                            uint8_t** addr /* nonnull */) override;
-    virtual c2_status_t unmap(uint8_t** addr, C2Rect rect, C2Fence* fence /* nullable */) override;
-    virtual C2Allocator::id_t getAllocatorId() const override;
-    virtual const C2Handle* handle() const override;
-    virtual bool equals(const std::shared_ptr<const C2GraphicAllocation>& other) const override;
-
-    // internal methods
-    C2AllocationCrosGralloc(sp<IGraphicBufferAlloc> allocator, uint32_t width, uint32_t height,
-                            uint32_t format, uint32_t usage, C2Allocator::id_t allocatorId);
-    c2_status_t status() const;
-
-protected:
-    class Impl;
-    Impl* mImpl;
-};
-
-class C2AllocationCrosGralloc::Impl {
-public:
-    Impl(sp<IGraphicBufferAlloc> allocator, uint32_t width, uint32_t height, uint32_t format,
-         uint32_t usage, C2Allocator::id_t allocatorId)
-          : mInit(C2_OK), mLocked(false), mAllocatorId(allocatorId) {
-        if (format != HAL_PIXEL_FORMAT_YCbCr_420_888) {
-            ALOGE("only support format HAL_PIXEL_FORMAT_YCbCr_420_888");
-            mInit = C2_BAD_VALUE;
-            return;
-        }
-        status_t error = OK;
-        mGraphicBuffer = allocator->createGraphicBuffer(width, height, format, usage, &error);
-        if (mGraphicBuffer == nullptr) {
-            ALOGE("failed to allocate buffer: %d", error);
-            mInit = C2_CORRUPTED;
-        }
-    }
-
-    ~Impl() {}
-
-    c2_status_t map(C2Rect rect, C2MemoryUsage usage, C2Fence* fence,
-                    C2PlanarLayout* layout /* nonnull */, uint8_t** addr /* nonnull */) {
-        // TODO
-        (void)fence;
-        if (mLocked) {
-            return C2_DUPLICATE;
-        }
-        if (!layout || !addr) {
-            return C2_BAD_VALUE;
-        }
-        if (usage.expected != C2MemoryUsage::CPU_READ) {
-            return C2_BAD_VALUE;  // always use GRALLOC_USAGE_SW_READ_OFTEN
-        }
-
-        // For simplicity, only support mapping with the same size as allocation.
-        if (rect != C2Rect(mGraphicBuffer->getWidth(), mGraphicBuffer->getHeight())) {
-            ALOGE("Only support the same size mapping.");
-            return C2_BAD_VALUE;
-        }
-
-        // Resolve the format
-        struct android_ycbcr ycbcr;
-        memset(&ycbcr, 0, sizeof(ycbcr));
-        LOG_ALWAYS_FATAL_IF(mGraphicBuffer->lockYCbCr(GRALLOC_USAGE_SW_READ_OFTEN, &ycbcr));
-        addr[C2PlanarLayout::PLANE_Y] = (uint8_t*)ycbcr.y;
-        addr[C2PlanarLayout::PLANE_U] = (uint8_t*)ycbcr.cb;
-        addr[C2PlanarLayout::PLANE_V] = (uint8_t*)ycbcr.cr;
-        ALOGV("Mapped as addr y=%p cb=%p cr=%p, chrome_step=%zu, stride y=%zu c=%zu",
-              addr[C2PlanarLayout::PLANE_Y], addr[C2PlanarLayout::PLANE_U],
-              addr[C2PlanarLayout::PLANE_V], ycbcr.chroma_step, ycbcr.ystride, ycbcr.cstride);
-
-        LOG_ALWAYS_FATAL_IF(ycbcr.chroma_step != 1 && ycbcr.chroma_step != 2);
-        layout->type = C2PlanarLayout::TYPE_YUV;
-        layout->numPlanes = 3;
-        layout->rootPlanes = 3;
-        layout->planes[C2PlanarLayout::PLANE_Y] = {
-                C2PlaneInfo::CHANNEL_Y,   // channel
-                1,                        // colInc
-                (int32_t)ycbcr.ystride,   // rowInc
-                1,                        // colSampling
-                1,                        // rowSampling
-                8,                        // allocatedDepth
-                8,                        // bitDepth
-                0,                        // valueShift
-                C2PlaneInfo::NATIVE,      // endianness
-                C2PlanarLayout::PLANE_Y,  // rootIx
-                0,                        // offset
-        };
-        layout->planes[C2PlanarLayout::PLANE_U] = {
-                C2PlaneInfo::CHANNEL_CB,     // channel
-                (int32_t)ycbcr.chroma_step,  // colInc
-                (int32_t)ycbcr.cstride,      // rowInc
-                2,                           // colSampling
-                2,                           // rowSampling
-                8,                           // allocatedDepth
-                8,                           // bitDepth
-                0,                           // valueShift
-                C2PlaneInfo::NATIVE,         // endianness
-                C2PlanarLayout::PLANE_U,     // rootIx
-                0,                           // offset
-        };
-        layout->planes[C2PlanarLayout::PLANE_V] = {
-                C2PlaneInfo::CHANNEL_CR,     // channel
-                (int32_t)ycbcr.chroma_step,  // colInc
-                (int32_t)ycbcr.cstride,      // rowInc
-                2,                           // colSampling
-                2,                           // rowSampling
-                8,                           // allocatedDepth
-                8,                           // bitDepth
-                0,                           // valueShift
-                C2PlaneInfo::NATIVE,         // endianness
-                C2PlanarLayout::PLANE_V,     // rootIx
-                0,                           // offset
-        };
-        // handle interleaved formats
-        intptr_t uvOffset = addr[C2PlanarLayout::PLANE_V] - addr[C2PlanarLayout::PLANE_U];
-        if (uvOffset > 0 && uvOffset < (intptr_t)ycbcr.chroma_step) {
-            layout->rootPlanes = 2;
-            layout->planes[C2PlanarLayout::PLANE_V].rootIx = C2PlanarLayout::PLANE_U;
-            layout->planes[C2PlanarLayout::PLANE_V].offset = uvOffset;
-        } else if (uvOffset < 0 && uvOffset > -(intptr_t)ycbcr.chroma_step) {
-            layout->rootPlanes = 2;
-            layout->planes[C2PlanarLayout::PLANE_U].rootIx = C2PlanarLayout::PLANE_V;
-            layout->planes[C2PlanarLayout::PLANE_U].offset = -uvOffset;
-        }
-
-        LOG_ALWAYS_FATAL_IF(layout->numPlanes > C2PlanarLayout::MAX_NUM_PLANES);
-        mLocked = true;
-        return C2_OK;
-    }
-
-    c2_status_t unmap(uint8_t** addr, C2Rect rect, C2Fence* fence /* nullable */) {
-        (void)addr;   // TODO
-        (void)rect;   // TODO
-        (void)fence;  // TODO
-        mGraphicBuffer->unlock();
-        mLocked = false;
-        return C2_OK;
-    }
-
-    c2_status_t status() const { return mInit; }
-
-    const C2Handle* handle() const { return mGraphicBuffer->handle; }
-
-    C2Allocator::id_t getAllocatorId() const { return mAllocatorId; }
-
-private:
-    c2_status_t mInit;
-    sp<GraphicBuffer> mGraphicBuffer;
-    bool mLocked;
-    C2Allocator::id_t mAllocatorId;
-};
-
-C2AllocationCrosGralloc::C2AllocationCrosGralloc(sp<IGraphicBufferAlloc> allocator, uint32_t width,
-                                                 uint32_t height, uint32_t format, uint32_t usage,
-                                                 C2Allocator::id_t allocatorId)
-      : C2GraphicAllocation(width, height),
-        mImpl(new Impl(allocator, width, height, format, usage, allocatorId)) {}
-
-C2AllocationCrosGralloc::~C2AllocationCrosGralloc() {
-    delete mImpl;
-}
-
-c2_status_t C2AllocationCrosGralloc::map(C2Rect rect, C2MemoryUsage usage, C2Fence* fence,
-                                         C2PlanarLayout* layout /* nonnull */,
-                                         uint8_t** addr /* nonnull */) {
-    return mImpl->map(rect, usage, fence, layout, addr);
-}
-
-c2_status_t C2AllocationCrosGralloc::unmap(uint8_t** addr, C2Rect rect,
-                                           C2Fence* fence /* nullable */) {
-    return mImpl->unmap(addr, rect, fence);
-}
-
-C2Allocator::id_t C2AllocationCrosGralloc::getAllocatorId() const {
-    return mImpl->getAllocatorId();
-}
-
-const C2Handle* C2AllocationCrosGralloc::handle() const {
-    return mImpl->handle();
-}
-
-bool C2AllocationCrosGralloc::equals(
-        const std::shared_ptr<const C2GraphicAllocation>& other) const {
-    (void)other;
-    return false;  // TODO(johnylin)
-}
-
-c2_status_t C2AllocationCrosGralloc::status() const {
-    return mImpl->status();
-}
-
-/* =================================== CROS GRALLOC ALLOCATOR ================================== */
-
-C2AllocatorCrosGralloc::C2AllocatorCrosGralloc(id_t id) {
-    mComposer = ComposerService::getComposerService();
-    if (mComposer.get() == nullptr) {
-        ALOGE("failed to connect to SurfaceComposer");
-        return;
-    }
-
-    mAllocator = mComposer->createGraphicBufferAlloc();
-    if (mAllocator.get() == nullptr) {
-        ALOGE("failed to create GraphicBuffer allocator");
-    }
-
-    C2MemoryUsage minUsage = {0, 0};
-    C2MemoryUsage maxUsage = {std::numeric_limits<uint64_t>::max(),
-                              std::numeric_limits<uint64_t>::max()};
-    Traits traits = {"vda.allocator.crosgralloc", id, C2Allocator::GRAPHIC, minUsage, maxUsage};
-    mTraits = std::make_shared<C2Allocator::Traits>(traits);
-}
-
-C2AllocatorCrosGralloc::~C2AllocatorCrosGralloc() {}
-
-C2Allocator::id_t C2AllocatorCrosGralloc::getId() const {
-    return mTraits->id;
-}
-
-C2String C2AllocatorCrosGralloc::getName() const {
-    return mTraits->name;
-}
-
-std::shared_ptr<const C2Allocator::Traits> C2AllocatorCrosGralloc::getTraits() const {
-    return mTraits;
-}
-
-c2_status_t C2AllocatorCrosGralloc::newGraphicAllocation(
-        uint32_t width, uint32_t height, uint32_t format, C2MemoryUsage usage,
-        std::shared_ptr<C2GraphicAllocation>* allocation) {
-    *allocation = nullptr;
-    if (usage.expected != C2MemoryUsage::CPU_READ) {
-        return C2_BAD_VALUE;  // always use GRALLOC_USAGE_SW_READ_OFTEN
-    }
-
-    auto alloc = std::make_shared<C2AllocationCrosGralloc>(
-            mAllocator, width, height, format, GRALLOC_USAGE_SW_READ_OFTEN, getId());
-
-    c2_status_t ret = alloc->status();
-    if (ret == C2_OK) {
-        *allocation = alloc;
-    }
-    return ret;
-}
-
-}  // namespace android
diff --git a/vndk/C2AllocatorMemDealer.cpp b/vndk/C2AllocatorMemDealer.cpp
deleted file mode 100644
index 1e47353..0000000
--- a/vndk/C2AllocatorMemDealer.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
-// Copyright 2017 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.
-
-//#define LOG_NDEBUG 0
-#define LOG_TAG "C2AllocatorMemDealer"
-
-#include <C2AllocatorMemDealer.h>
-
-#include <C2Buffer.h>
-
-#include <binder/IMemory.h>
-#include <binder/MemoryDealer.h>
-#include <media/stagefright/MediaDefs.h>
-#include <utils/Log.h>
-#include <utils/misc.h>
-
-#include <limits>
-#include <sys/mman.h>
-#include <limits>
-
-namespace android {
-
-/* ================================= MEMORY DEALER ALLOCATION ================================== */
-
-class C2AllocationMemDealer : public C2LinearAllocation {
-public:
-    virtual ~C2AllocationMemDealer();
-
-    virtual c2_status_t map(size_t offset, size_t size, C2MemoryUsage usage, C2Fence* fence,
-                            void** addr /* nonnull */) override;
-    virtual c2_status_t unmap(void* addr, size_t size, C2Fence* fence) override;
-    virtual C2Allocator::id_t getAllocatorId() const override;
-    virtual const C2Handle* handle() const override;
-    virtual bool equals(const std::shared_ptr<C2LinearAllocation>& other) const override;
-
-    // internal methods
-    C2AllocationMemDealer(uint32_t capacity, C2Allocator::id_t id);
-    c2_status_t status() const;
-
-protected:
-    class Impl;
-    Impl* mImpl;
-};
-
-class C2AllocationMemDealer::Impl {
-public:
-    // NOTE: using constructor here instead of a factory method as we will need the
-    // error value and this simplifies the error handling by the wrapper.
-    Impl(uint32_t capacity, C2Allocator::id_t id)
-          : mInit(C2_OK), mHandle(nullptr), mMapSize(0u), mAllocatorId(id) {
-        sp<MemoryDealer> dealer = new MemoryDealer(capacity, "C2AllocationMemDealer");
-        mMemory = dealer->allocate(capacity);
-        if (mMemory == nullptr || mMemory->pointer() == nullptr) {
-            ALOGE("fail to allocate memory: %u", capacity);
-            mInit = C2_NO_MEMORY;
-            return;
-        }
-
-        // Create a handle for IMemory.
-        sp<IMemoryHeap> heap = mMemory->getMemory();
-        mHandle = native_handle_create(1 /* numFds */, 0 /* numInts */);
-        if (mHandle == nullptr) {
-            ALOGE("fail to create native handle.");
-            mInit = C2_NO_MEMORY;
-            return;
-        }
-        mHandle->data[0] = heap->getHeapID();
-    }
-
-    c2_status_t map(size_t offset, size_t size, C2MemoryUsage usage, C2Fence* fence, void** addr) {
-        (void)fence;  // TODO: wait for fence
-        (void)usage;
-        *addr = nullptr;
-        // For simplicity, only support offset = 0 mapping for now.
-        if (offset != 0) {
-            ALOGE("Only support offset=0 mapping now.");
-            return C2_OMITTED;
-        }
-        if (size > mMemory->size()) {
-            ALOGE("Mapping size(%zu) exceeds allocation size(%zu).", size, mMemory->size());
-            return C2_NO_MEMORY;
-        }
-
-        *addr = mMemory->pointer();
-        mMapSize = size;
-        return C2_OK;
-    }
-
-    c2_status_t unmap(void* addr, size_t size, C2Fence* fence) {
-        if (addr != mMemory->pointer() || size != mMapSize) {
-            return C2_BAD_VALUE;
-        }
-        mMapSize = 0u;
-        if (fence) {
-            *fence = C2Fence();
-        }
-        return C2_OK;
-    }
-
-    ~Impl() { native_handle_delete(mHandle); }
-
-    c2_status_t status() const { return mInit; }
-
-    const C2Handle* handle() const { return mHandle; }
-
-    C2Allocator::id_t getAllocatorId() const { return mAllocatorId; }
-
-private:
-    c2_status_t mInit;
-    C2Handle* mHandle;
-    sp<IMemory> mMemory;
-    size_t mMapSize;
-    C2Allocator::id_t mAllocatorId;
-};
-
-c2_status_t C2AllocationMemDealer::map(size_t offset, size_t size, C2MemoryUsage usage,
-                                       C2Fence* fence, void** addr) {
-    return mImpl->map(offset, size, usage, fence, addr);
-}
-
-c2_status_t C2AllocationMemDealer::unmap(void* addr, size_t size, C2Fence* fence) {
-    return mImpl->unmap(addr, size, fence);
-}
-
-C2Allocator::id_t C2AllocationMemDealer::getAllocatorId() const {
-    return mImpl->getAllocatorId();
-}
-
-c2_status_t C2AllocationMemDealer::status() const {
-    return mImpl->status();
-}
-
-bool C2AllocationMemDealer::equals(const std::shared_ptr<C2LinearAllocation>& other) const {
-    (void)other;
-    return false;  // TODO(johnylin)
-}
-
-const C2Handle* C2AllocationMemDealer::handle() const {
-    return mImpl->handle();
-}
-
-C2AllocationMemDealer::~C2AllocationMemDealer() {
-    delete mImpl;
-}
-
-C2AllocationMemDealer::C2AllocationMemDealer(uint32_t capacity, C2Allocator::id_t id)
-      : C2LinearAllocation(capacity), mImpl(new Impl(capacity, id)) {}
-
-/* ================================ MEMORY DEALER ALLOCATOR ==================================== */
-
-C2AllocatorMemDealer::C2AllocatorMemDealer(id_t id) {
-    C2MemoryUsage minUsage = {0, 0};
-    C2MemoryUsage maxUsage = {std::numeric_limits<uint64_t>::max(),
-                              std::numeric_limits<uint64_t>::max()};
-    Traits traits = {"vda.allocator.memdealer", id, C2Allocator::LINEAR, minUsage, maxUsage};
-    mTraits = std::make_shared<C2Allocator::Traits>(traits);
-}
-
-C2AllocatorMemDealer::~C2AllocatorMemDealer() {}
-
-C2Allocator::id_t C2AllocatorMemDealer::getId() const {
-    return mTraits->id;
-}
-
-C2String C2AllocatorMemDealer::getName() const {
-    return mTraits->name;
-}
-
-std::shared_ptr<const C2Allocator::Traits> C2AllocatorMemDealer::getTraits() const {
-    return mTraits;
-}
-
-c2_status_t C2AllocatorMemDealer::newLinearAllocation(
-        uint32_t capacity, C2MemoryUsage usage, std::shared_ptr<C2LinearAllocation>* allocation) {
-    (void)usage;  // is usage needed?
-    *allocation = nullptr;
-
-    auto alloc = std::make_shared<C2AllocationMemDealer>(capacity, getId());
-
-    c2_status_t ret = alloc->status();
-    if (ret == C2_OK) {
-        *allocation = alloc;
-    }
-    return ret;
-}
-
-}  // namespace android
diff --git a/vndk/C2VDAStore.cpp b/vndk/C2VDAStore.cpp
deleted file mode 100644
index 2b0dcf9..0000000
--- a/vndk/C2VDAStore.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright 2017 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.
-
-#include <C2AllocatorCrosGrallocNyc.h>
-#include <C2AllocatorMemDealer.h>
-
-#include <C2BufferPriv.h>
-#include <C2Component.h>
-#include <C2VDASupport.h>
-
-#include <map>
-#include <memory>
-#include <mutex>
-
-namespace android {
-
-class C2VDAAllocatorStore : public C2AllocatorStore {
-public:
-    enum : id_t {
-        MEM_DEALER = VENDOR_START,
-        CROS_GRALLOC,
-    };
-
-    C2VDAAllocatorStore() = default;
-
-    c2_status_t fetchAllocator(id_t id, std::shared_ptr<C2Allocator>* const allocator) override;
-
-    std::vector<std::shared_ptr<const C2Allocator::Traits>> listAllocators_nb() const override {
-        return std::vector<std::shared_ptr<const C2Allocator::Traits>>();  /// TODO
-    }
-
-    C2String getName() const override { return "vda.allocator-store"; }
-
-private:
-    // returns a shared-singleton memory dealer allocator
-    std::shared_ptr<C2Allocator> fetchMemDealerAllocator();
-
-    // returns a shared-singleton CrOS gralloc allocator
-    std::shared_ptr<C2Allocator> fetchCrosGrallocAllocator();
-
-    static std::weak_ptr<C2Allocator> mMemDealerAllocator;
-    static std::weak_ptr<C2Allocator> mCrosGrallocAllocator;
-};
-
-// Instantiate
-std::weak_ptr<C2Allocator> C2VDAAllocatorStore::mMemDealerAllocator;
-std::weak_ptr<C2Allocator> C2VDAAllocatorStore::mCrosGrallocAllocator;
-
-c2_status_t C2VDAAllocatorStore::fetchAllocator(id_t id,
-                                                std::shared_ptr<C2Allocator>* const allocator) {
-    allocator->reset();
-    switch (id) {
-    case C2VDAAllocatorStore::MEM_DEALER:
-        *allocator = fetchMemDealerAllocator();
-        break;
-
-    case C2VDAAllocatorStore::CROS_GRALLOC:
-        *allocator = fetchCrosGrallocAllocator();
-        break;
-
-    default:
-        return C2_NOT_FOUND;
-    }
-    if (*allocator == nullptr) {
-        return C2_NO_MEMORY;
-    }
-    return C2_OK;
-}
-
-std::shared_ptr<C2Allocator> C2VDAAllocatorStore::fetchMemDealerAllocator() {
-    static std::mutex mutex;
-    std::lock_guard<std::mutex> lock(mutex);
-    auto allocator = mMemDealerAllocator.lock();
-    if (!allocator) {
-        allocator = std::make_shared<C2AllocatorMemDealer>(MEM_DEALER);
-        mMemDealerAllocator = allocator;
-    }
-    return allocator;
-}
-
-std::shared_ptr<C2Allocator> C2VDAAllocatorStore::fetchCrosGrallocAllocator() {
-    static std::mutex mutex;
-    std::lock_guard<std::mutex> lock(mutex);
-    auto allocator = mCrosGrallocAllocator.lock();
-    if (!allocator) {
-        allocator = std::make_shared<C2AllocatorCrosGralloc>(CROS_GRALLOC);
-        mCrosGrallocAllocator = allocator;
-    }
-    return allocator;
-}
-
-std::shared_ptr<C2AllocatorStore> GetCodec2VDAAllocatorStore() {
-    return std::make_shared<C2VDAAllocatorStore>();
-}
-
-c2_status_t GetCodec2BlockPool(C2BlockPool::local_id_t id,
-                               std::shared_ptr<const C2Component> component,
-                               std::shared_ptr<C2BlockPool>* pool) {
-    pool->reset();
-    if (!component) {
-        return C2_BAD_VALUE;
-    }
-    std::shared_ptr<C2AllocatorStore> allocatorStore = GetCodec2VDAAllocatorStore();
-    std::shared_ptr<C2Allocator> allocator;
-    c2_status_t res = C2_NOT_FOUND;
-
-    switch (id) {
-    case C2BlockPool::BASIC_LINEAR:
-        res = allocatorStore->fetchAllocator(C2AllocatorStore::DEFAULT_LINEAR, &allocator);
-        if (res == C2_OK) {
-            *pool = std::make_shared<C2BasicLinearBlockPool>(allocator);
-        }
-        break;
-    case C2BlockPool::BASIC_GRAPHIC:
-        res = allocatorStore->fetchAllocator(C2AllocatorStore::DEFAULT_GRAPHIC, &allocator);
-        if (res == C2_OK) {
-            *pool = std::make_shared<C2BasicGraphicBlockPool>(allocator);
-        }
-        break;
-    default:
-        break;
-    }
-    return res;
-}
-
-}  // namespace android
diff --git a/vndk/include/C2AllocatorCrosGrallocNyc.h b/vndk/include/C2AllocatorCrosGrallocNyc.h
deleted file mode 100644
index 16bd67f..0000000
--- a/vndk/include/C2AllocatorCrosGrallocNyc.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2017 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_C2_ALLOCATOR_CROS_GRALLOC_NYC_H
-#define ANDROID_C2_ALLOCATOR_CROS_GRALLOC_NYC_H
-
-#include <C2Buffer.h>
-
-#include <gui/ISurfaceComposer.h>
-#include <gui/Surface.h>
-#include <private/gui/ComposerService.h>
-
-namespace android {
-
-class C2AllocatorCrosGralloc : public C2Allocator {
-public:
-    virtual id_t getId() const override;
-
-    virtual C2String getName() const override;
-
-    virtual std::shared_ptr<const Traits> getTraits() const override;
-
-    virtual c2_status_t newGraphicAllocation(
-            uint32_t width, uint32_t height, uint32_t format, C2MemoryUsage usage,
-            std::shared_ptr<C2GraphicAllocation>* allocation) override;
-
-    C2AllocatorCrosGralloc(id_t id);
-    virtual ~C2AllocatorCrosGralloc();
-
-private:
-    sp<ISurfaceComposer> mComposer;
-    sp<IGraphicBufferAlloc> mAllocator;
-    std::shared_ptr<const Traits> mTraits;
-};
-
-}  // namespace android
-
-#endif  // ANDROID_C2_ALLOCATOR_CROS_GRALLOC_NYC_H
diff --git a/vndk/include/C2AllocatorMemDealer.h b/vndk/include/C2AllocatorMemDealer.h
deleted file mode 100644
index db5d863..0000000
--- a/vndk/include/C2AllocatorMemDealer.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2017 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_C2_ALLOCATOR_MEM_DEALER_H
-#define ANDROID_C2_ALLOCATOR_MEM_DEALER_H
-
-#include <C2Buffer.h>
-
-namespace android {
-
-class C2AllocatorMemDealer : public C2Allocator {
-public:
-    virtual id_t getId() const override;
-
-    virtual C2String getName() const override;
-
-    virtual std::shared_ptr<const Traits> getTraits() const override;
-
-    virtual c2_status_t newLinearAllocation(
-            uint32_t capacity, C2MemoryUsage usage,
-            std::shared_ptr<C2LinearAllocation>* allocation) override;
-
-    C2AllocatorMemDealer(id_t id);
-    virtual ~C2AllocatorMemDealer();
-
-private:
-    std::shared_ptr<const Traits> mTraits;
-};
-
-}  // namespace android
-
-#endif  // ANDROID_C2_ALLOCATOR_MEM_DEALER_H
diff --git a/vndk/include/C2VDASupport.h b/vndk/include/C2VDASupport.h
deleted file mode 100644
index 648f9ef..0000000
--- a/vndk/include/C2VDASupport.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2017 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_C2_VDA_SUPPORT_H
-#define ANDROID_C2_VDA_SUPPORT_H
-
-#include <C2Component.h>
-
-namespace android {
-
-/**
- * Returns the VDA allocator store.
- * \retval nullptr if the VDA allocator store could not be obtained
- */
-std::shared_ptr<C2AllocatorStore> GetCodec2VDAAllocatorStore();
-
-/**
- * Retrieves a block pool for a component.
- *
- * \param id        the local ID of the block pool
- * \param component the component using the block pool (must be non-null)
- * \param pool      pointer to where the obtained block pool shall be stored on success. nullptr
- *                  will be stored here on failure
- *
- * \retval C2_OK        the operation was successful
- * \retval C2_BAD_VALUE the component is null
- * \retval C2_NOT_FOUND if the block pool does not exist
- * \retval C2_NO_MEMORY not enough memory to fetch the block pool (this return value is only
- *                      possible for basic pools)
- * \retval C2_TIMED_OUT the operation timed out (this return value is only possible for basic pools)
- * \retval C2_REFUSED   no permission to complete any required allocation (this return value is only
- *                      possible for basic pools)
- * \retval C2_CORRUPTED some unknown, unrecoverable error occured during operation (unexpected,
- *                      this return value is only possible for basic pools)
- */
-c2_status_t GetCodec2BlockPool(C2BlockPool::local_id_t id,
-                               std::shared_ptr<const C2Component> component,
-                               std::shared_ptr<C2BlockPool>* pool);
-
-}  // namespace android
-
-#endif  // ANDROID_C2_VDA_SUPPORT_H