Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2c12b0c authored by Wonsik Kim's avatar Wonsik Kim Committed by Automerger Merge Worker
Browse files

Merge "C2SoftCodecTests: Add unit tests for c2 soft codecs" am: 99e9d191

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/1619569

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ia925e34d605f52589d95d7e0eddf35fca04c5287
parents b6e3cf89 99e9d191
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
// mappings for frameworks/av/media/codec2/components/mpeg4_h263
{
  "presubmit": [
    { "name": "C2SoftMpeg4DecTest" }
  ]
}
+68 −0
Original line number Diff line number Diff line
package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "frameworks_av_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["frameworks_av_license"],
}

cc_defaults {
    name: "C2SoftCodecTest-defaults",
    gtest: true,
    host_supported: false,
    srcs: [
        "C2SoftCodecTest.cpp",
    ],

    static_libs: [
        "liblog",
        "libion",
        "libfmq",
        "libbase",
        "libutils",
        "libcutils",
        "libcodec2",
        "libhidlbase",
        "libdmabufheap",
        "libcodec2_vndk",
        "libnativewindow",
        "libcodec2_soft_common",
        "libsfplugin_ccodec_utils",
        "libstagefright_foundation",
        "libstagefright_bufferpool@2.0.1",
        "android.hardware.graphics.mapper@2.0",
        "android.hardware.graphics.mapper@3.0",
        "android.hardware.media.bufferpool@2.0",
        "android.hardware.graphics.allocator@2.0",
        "android.hardware.graphics.allocator@3.0",
        "android.hardware.graphics.bufferqueue@2.0",
    ],

    shared_libs: [
        "libui",
        "libdl",
        "libhardware",
        "libvndksupport",
        "libprocessgroup",
    ],

    cflags: [
        "-Wall",
        "-Werror",
    ],
}

cc_test {
    name: "C2SoftMpeg4DecTest",
    defaults: ["C2SoftCodecTest-defaults"],

    static_libs: [
        "libstagefright_m4vh263dec",
        "libcodec2_soft_mpeg4dec",
    ],

    test_suites: [
        "general-tests",
    ],
}
+105 −0
Original line number Diff line number Diff line
/******************************************************************************
 *
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *****************************************************************************
 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
 */
#include <C2Config.h>
#include <C2ComponentFactory.h>
#include <gtest/gtest.h>
#include <log/log.h>

using namespace android;
extern "C" ::C2ComponentFactory* CreateCodec2Factory();
extern "C" void DestroyCodec2Factory(::C2ComponentFactory* factory);

class C2SoftCodecTest : public ::testing::Test {
public:
  void SetUp() override {
    mFactory = CreateCodec2Factory();
  }

  void TearDown() override {
    if (mFactory) {
      DestroyCodec2Factory(mFactory);
    }
  }

  c2_status_t createComponent(
        std::shared_ptr<C2Component>* const comp) {
    if (!mFactory) {
      return C2_NO_INIT;
    }
    return mFactory->createComponent(
        kPlaceholderId, comp, std::default_delete<C2Component>());
  }

  c2_status_t createInterface(
      std::shared_ptr<C2ComponentInterface>* const intf) {
    if (!mFactory) {
      return C2_NO_INIT;
    }
    return mFactory->createInterface(
        kPlaceholderId, intf, std::default_delete<C2ComponentInterface>());
  }

  ::C2ComponentFactory *getFactory() { return mFactory; }

private:
  static constexpr ::c2_node_id_t kPlaceholderId = 0;

  ::C2ComponentFactory *mFactory;
};

TEST_F(C2SoftCodecTest, PictureSizeInfoTest) {
  std::shared_ptr<C2ComponentInterface> interface;
  c2_status_t status = createInterface(&interface);
  ASSERT_EQ(status, C2_OK) << "Error in createInterface";
  ASSERT_NE(interface, nullptr) << "interface is null";

  std::unique_ptr<C2StreamPictureSizeInfo::output> param =
      std::make_unique<C2StreamPictureSizeInfo::output>();
  std::vector<C2FieldSupportedValuesQuery> validValueInfos = {
      C2FieldSupportedValuesQuery::Current(
          C2ParamField(param.get(), &C2StreamPictureSizeInfo::width)),
      C2FieldSupportedValuesQuery::Current(
          C2ParamField(param.get(), &C2StreamPictureSizeInfo::height))};
  status = interface->querySupportedValues_vb(validValueInfos, C2_MAY_BLOCK);
  ASSERT_EQ(status, C2_OK) << "Error in querySupportedValues_vb";
  ASSERT_EQ(validValueInfos.size(), 2) << "querySupportedValues_vb didn't return 2 values";

  ASSERT_EQ(validValueInfos[0].values.range.max.ref<uint32_t>(), 1920)
      << "Incorrect maximum value for width";
  ASSERT_EQ(validValueInfos[1].values.range.max.ref<uint32_t>(), 1920)
      << "Incorrect maximum value for height";
  ASSERT_EQ(validValueInfos[0].values.range.min.ref<uint32_t>(), 2)
      << "Incorrect minimum value for width";
  ASSERT_EQ(validValueInfos[1].values.range.min.ref<uint32_t>(), 2)
      << "Incorrect minimum value for height";
  ASSERT_EQ(validValueInfos[0].values.range.step.ref<uint32_t>(), 2)
      << "Incorrect alignment value for width";
  ASSERT_EQ(validValueInfos[1].values.range.step.ref<uint32_t>(), 2)
      << "Incorrect alignment value for height";

  return;
}

int main(int argc, char** argv) {
  ::testing::InitGoogleTest(&argc, argv);
  int status = RUN_ALL_TESTS();
  ALOGV("Test result = %d\n", status);
  return status;
}