Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ifneq ($(filter $(BOARD_HAVE_MEDIASDK_CODEC2),true),)
MFX_C2_HOME := $(call my-dir)

# Recursively call sub-folder Android.mk
include $(call all-subdir-makefiles)
endif
75 changes: 75 additions & 0 deletions c2_utils/include/mfx_c2_params.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright (c) 2017-2021 Intel Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#pragma once

#include <C2Config.h>

enum C2ParamIndexKindVendor : C2Param::type_index_t {

kParamIndexRateControl = C2Param::TYPE_INDEX_VENDOR_START,
kParamIndexProfile,
kParamIndexLevel,
kParamIndexFrameQP,
kParamIndexMemoryType,
};

// not existing tuning, Google defines bitrate as Info,
// so define bitrate tuning here for test purpose,
// otherwise cannot push_back it into C2Worklet::tunings
typedef C2StreamParam<C2Tuning, C2Uint32Value, kParamIndexBitrate> C2BitrateTuning;
constexpr char MFX_C2_PARAMKEY_BITRATE_TUNING[] = "coded.bitrate.tuning";

C2ENUM(C2RateControlMethod, int32_t,
C2RateControlCQP,
C2RateControlCBR,
C2RateControlVBR,
);

typedef C2PortParam<C2Setting, C2SimpleValueStruct<C2RateControlMethod>, kParamIndexRateControl>::output
C2RateControlSetting;

struct C2FrameQPStruct {
uint32_t qp_i;
uint32_t qp_p;
uint32_t qp_b;

DEFINE_AND_DESCRIBE_C2STRUCT(FrameQP)
C2FIELD(qp_i, "QPI")
C2FIELD(qp_p, "QPP")
C2FIELD(qp_b, "QPB")
};

typedef C2PortParam<C2Tuning, C2FrameQPStruct, kParamIndexFrameQP>::output C2FrameQPSetting;

typedef C2PortParam<C2Tuning, C2Int32Value, kParamIndexIntraRefresh>::output C2IntraRefreshTuning;

typedef C2PortParam<C2Setting, C2Uint32Value, kParamIndexProfile>::output C2ProfileSetting;

typedef C2PortParam<C2Setting, C2Uint32Value, kParamIndexLevel>::output C2LevelSetting;

typedef C2PortParam<C2Info, C2SimpleArrayStruct<C2ProfileLevelStruct>, kParamIndexProfileLevel> C2ProfileLevelInfo;

C2ENUM(C2MemoryType, int32_t,
C2MemoryTypeSystem,
C2MemoryTypeGraphics,
);

typedef C2GlobalParam<C2Setting, C2SimpleValueStruct<C2MemoryType>, kParamIndexMemoryType> C2MemoryTypeSetting;
107 changes: 107 additions & 0 deletions mfx_c2_defs.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Purpose:
# Defines include paths, compilation flags, etc. to build Media SDK targets.
#
# Defined variables:
# MFX_C2_CFLAGS - common flags for all targets
# MFX_C2_CFLAGS_LIBVA - LibVA support flags (to build apps with or without LibVA support)
# MFX_C2_INCLUDES - common include paths for all targets
# MFX_C2_INCLUDES_LIBVA - include paths to LibVA headers
# MFX_C2_HEADER_LIBRARIES - common imported headers for all targets
# MFX_C2_LDFLAGS - common link flags for all targets

include $(MFX_C2_HOME)/mfx_c2_env.mk

# =============================================================================
# Common definitions

MFX_C2_CFLAGS := -DANDROID

# Use oneVPL API
USE_ONEVPL := true
ifeq ($(USE_ONEVPL), true)
MFX_C2_CFLAGS += -DMFX_VERSION=2008
endif

# Android version preference:
# We start codec2.0 development starting from Android R
ifneq ($(filter 13 13.% T% ,$(PLATFORM_VERSION)),)
MFX_ANDROID_VERSION:= MFX_T
endif
ifneq ($(filter 12 12.% S ,$(PLATFORM_VERSION)),)
MFX_ANDROID_VERSION:= MFX_S
endif
ifneq ($(filter 11 11.% R ,$(PLATFORM_VERSION)),)
MFX_ANDROID_VERSION:= MFX_R
endif

ifeq ($(MFX_ANDROID_PLATFORM),)
MFX_ANDROID_PLATFORM:=$(TARGET_BOARD_PLATFORM)
endif

# Passing Android-dependency information to the code
MFX_C2_CFLAGS += \
-DMFX_ANDROID_VERSION=$(MFX_ANDROID_VERSION) \
-DMFX_ANDROID_PLATFORM=$(MFX_ANDROID_PLATFORM)

ifeq ($(BOARD_USES_GRALLOC1),true)
# plugins should use PRIME buffer descriptor since Android P
MFX_C2_CFLAGS += -DMFX_C2_USE_PRIME
else
$(error "Required GRALLOC1 support")
endif

# MFX_BUFFER_QUEUE := true
ifeq ($(MFX_BUFFER_QUEUE),true)
MFX_C2_CFLAGS += -DMFX_BUFFER_QUEUE
endif

# Security
MFX_C2_CFLAGS += \
-fstack-protector-strong \
-fPIE -fPIC \
-O2 -D_FORTIFY_SOURCE=2 \
-Wno-error \
-Wno-deprecated-declarations \
-fexceptions -std=c++17

# LibVA support.
MFX_C2_CFLAGS_LIBVA := -DLIBVA_SUPPORT -DLIBVA_ANDROID_SUPPORT

# Setting usual paths to include files
MFX_C2_INCLUDES := \
$(LOCAL_PATH)/include

MFX_C2_SHARED_LIBS := libcodec2_vndk

ifeq ($(BOARD_USES_GRALLOC1),true)
MFX_C2_INCLUDES += $(INTEL_MINIGBM)/cros_gralloc
endif

MFX_C2_INCLUDES_LIBVA := $(TARGET_OUT_HEADERS)/libva

ifeq ($(USE_ONEVPL), true)
# Setting oneVPL imported headers
MFX_C2_HEADER_LIBRARIES := libvpl_headers libmfx_android_headers libcodec2_headers
MFX_C2_SHARED_LIBS += libvpl
else
# Setting MediaSDK imported headers
MFX_C2_HEADER_LIBRARIES := libmfx_headers libcodec2_headers
endif

# Setting usual imported headers
MFX_C2_HEADER_LIBRARIES += \
libutils_headers \
libhardware_headers # It's here due to <hardware/gralloc.h> include. Need to remove when the header will be removed

# Setting usual link flags
MFX_C2_LDFLAGS := \
-z noexecstack \
-z relro -z now

MFX_C2_EXE_LDFLAGS := $(MFX_C2_LDFLAGS) -pie

# Setting vendor
LOCAL_MODULE_OWNER := intel

# Moving executables to proprietary location
LOCAL_PROPRIETARY_MODULE := true
24 changes: 24 additions & 0 deletions mfx_c2_env.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Defines Media SDK targets to build. Should be included
# in all Android.mk files which define build targets prior
# to any other directives.

# Build HW C2 plugins
ifeq ($(MFX_C2_IMPL_HW),)
MFX_C2_IMPL_HW:=true
endif

# BOARD_HAVE_MEDIASDK_SRC is not set
# BOARD_HAVE_MEDIASDK_OPEN_SOURCE is set
ifeq ($(BOARD_HAVE_MEDIASDK_SRC),true)

# Build SW C2 plugins
ifeq ($(MFX_C2_IMPL_SW),)
MFX_C2_IMPL_SW:=true
endif

# Build PURE C2 plugins
ifeq ($(MFX_C2_IMPL_PURE),)
MFX_C2_IMPL_PURE:=true
endif

endif
Loading