libsf-wave511: package WAVE511 decoder library

Make upstream library build with horribly patched symlink and Makefile
fork combination. Need to be refactored to a decent build system.
This commit is contained in:
Andreas Cord-Landwehr 2023-01-25 21:33:40 +01:00 committed by Khem Raj
parent 33a768b7fe
commit e0036cf0a9
3 changed files with 244 additions and 0 deletions

View file

@ -0,0 +1,75 @@
SUMMARY = "WAVE511 decoding library for VisionFive2"
DESCRIPTION = "Library provides API to vdec Kernel module for using the WAVE511 chip for HEVC/H.265 and AVC/H.264 decoding."
LICENSE = "ChipsMedia_VisionFive2"
LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=16bead7cc56b053f5da0061ce0637ad2"
COMPATIBLE_MACHINE = "visionfive2"
require recipes-bsp/common/visionfive2-firmware.inc
inherit autotools
SOLIBS = ".so"
FILES_SOLIBSDEV = ""
SRC_URI += " \
file://WaveDecode_yocto.mak;subdir=git/wave511/code \
file://20_vdec.rules \
"
S = "${WORKDIR}/git/wave511/code"
do_configure:prepend() {
# workaround wrong build system/include path assumptions
ln -sf ${S} ${S}/wave511
}
do_compile() {
oe_runmake -C ${S} -f WaveDecode_yocto.mak
}
do_install() {
install -D -m 0644 ${S}/sample_v2/component_list_all.h ${D}/usr/include/wave511/sample_v2/component_list_all.h
install -D -m 0644 ${S}/sample_v2/helper/misc/bw_monitor.h ${D}/usr/include/wave511/sample_v2/helper/misc/bw_monitor.h
install -D -m 0644 ${S}/sample_v2/helper/misc/pbu.h ${D}/usr/include/wave511/sample_v2/helper/misc/pbu.h
install -D -m 0644 ${S}/sample_v2/helper/misc/json_output.h ${D}/usr/include/wave511/sample_v2/helper/misc/json_output.h
install -D -m 0644 ${S}/sample_v2/helper/misc/header_struct.h ${D}/usr/include/wave511/sample_v2/helper/misc/header_struct.h
install -D -m 0644 ${S}/sample_v2/helper/misc/debug.h ${D}/usr/include/wave511/sample_v2/helper/misc/debug.h
install -D -m 0644 ${S}/sample_v2/helper/main_helper.h ${D}/usr/include/wave511/sample_v2/helper/main_helper.h
install -D -m 0644 ${S}/sample_v2/component_decoder/decoder_listener.h ${D}/usr/include/wave511/sample_v2/component_decoder/decoder_listener.h
install -D -m 0644 ${S}/sample_v2/component_encoder/encoder_listener.h ${D}/usr/include/wave511/sample_v2/component_encoder/encoder_listener.h
install -D -m 0644 ${S}/sample_v2/component/component.h ${D}/usr/include/wave511/sample_v2/component/component.h
install -D -m 0644 ${S}/sample_v2/component/component_list.h ${D}/usr/include/wave511/sample_v2/component/component_list.h
install -D -m 0644 ${S}/sample_v2/component/cnm_app_internal.h ${D}/usr/include/wave511/sample_v2/component/cnm_app_internal.h
install -D -m 0644 ${S}/sample_v2/component/cnm_app.h ${D}/usr/include/wave511/sample_v2/component/cnm_app.h
install -D -m 0644 ${S}/sample_v2/component_list_decoder.h ${D}/usr/include/wave511/sample_v2/component_list_decoder.h
install -D -m 0644 ${S}/sample_v2/component_list_encoder.h ${D}/usr/include/wave511/sample_v2/component_list_encoder.h
install -D -m 0644 ${S}/config.h ${D}/usr/include/wave511/config.h
install -D -m 0644 ${S}/vpuapi/wave/wave5_regdefine.h ${D}/usr/include/wave511/vpuapi/wave/wave5_regdefine.h
install -D -m 0644 ${S}/vpuapi/wave/wave5.h ${D}/usr/include/wave511/vpuapi/wave/wave5.h
install -D -m 0644 ${S}/vpuapi/vpuerror.h ${D}/usr/include/wave511/vpuapi/vpuerror.h
install -D -m 0644 ${S}/vpuapi/vputypes.h ${D}/usr/include/wave511/vpuapi/vputypes.h
install -D -m 0644 ${S}/vpuapi/vpuconfig.h ${D}/usr/include/wave511/vpuapi/vpuconfig.h
install -D -m 0644 ${S}/vpuapi/coda9/coda9.h ${D}/usr/include/wave511/vpuapi/coda9/coda9.h
install -D -m 0644 ${S}/vpuapi/coda9/coda9_vpuconfig.h ${D}/usr/include/wave511/vpuapi/coda9/coda9_vpuconfig.h
install -D -m 0644 ${S}/vpuapi/coda9/coda9_regdefine.h ${D}/usr/include/wave511/vpuapi/coda9/coda9_regdefine.h
install -D -m 0644 ${S}/vpuapi/vpuapifunc.h ${D}/usr/include/wave511/vpuapi/vpuapifunc.h
install -D -m 0644 ${S}/vpuapi/vpuapi.h ${D}/usr/include/wave511/vpuapi/vpuapi.h
install -D -m 0644 ${S}/vpuapi/product.h ${D}/usr/include/wave511/vpuapi/product.h
install -D -m 0644 ${S}/vdi/mm.h ${D}/usr/include/wave511/vdi/mm.h
install -D -m 0644 ${S}/vdi/linux/driver/vdec-starfive.h ${D}/usr/include/wave511/vdi/linux/driver/vdec-starfive.h
install -D -m 0644 ${S}/vdi/linux/driver/vpu.h ${D}/usr/include/wave511/vdi/linux/driver/vpu.h
install -D -m 0644 ${S}/vdi/linux/driver/vmm.h ${D}/usr/include/wave511/vdi/linux/driver/vmm.h
install -D -m 0644 ${S}/vdi/vdi.h ${D}/usr/include/wave511/vdi/vdi.h
install -D -m 0644 ${S}/vdi/vdi_osal.h ${D}/usr/include/wave511/vdi/vdi_osal.h
install -d ${D}/usr/lib
install -m 0644 ${S}/libsfdec.so ${D}/usr/lib/
install -d ${D}/${base_libdir}/udev/rules.d/
install -m 0644 ${WORKDIR}/20_vdec.rules ${D}/${base_libdir}/udev/rules.d/
}
FILES:${PN} += " \
${base_libdir}/* \
${libdir}/* \
"

View file

@ -0,0 +1 @@
SUBSYSTEM=="vdec", MODE="0666"

View file

@ -0,0 +1,168 @@
# ----------------------------------------------------------------------
#
# Project: C&M Video decoder sample
#
# ----------------------------------------------------------------------
.PHONY: CREATE_DIR
BUILD_CONFIGURATION := EmbeddedRiscvLinux
PRODUCT := WAVE511
#PRODUCT := WAVE521C
$(shell cp sample_v2/component_list_decoder.h sample_v2/component/component_list.h)
USE_PTHREAD = yes
USE_RTL_SIM = no
LINT_HOME = etc/lint
UNAME = $(shell uname -a)
ifneq (,$(findstring i386, $(UNAME)))
USE_32BIT = yes
endif
ifeq ($(RTL_SIM), 1)
USE_RTL_SIM = yes
endif
REFC := 0
ifeq ($(USE_32BIT), yes)
PLATFORM = nativelinux
else
PLATFORM = nativelinux_64bit
endif
CROSS_CC_PREFIX =
VDI_C = vdi/linux/vdi.c
VDI_OSAL_C = vdi/linux/vdi_osal.c
MM_C =
PLATFORM_FLAGS =
VDI_VPATH = vdi/linux
ifeq ("$(BUILD_CONFIGURATION)", "NonOS")
CROSS_CC_PREFIX = arm-none-eabi-
VDI_C = vdi/nonos/vdi.c
VDI_OSAL_C = vdi/nonos/vdi_osal.c
MM_C = vdi/mm.c
USE_PTHREAD = no
PLATFORM = none
DEFINES = -DLIB_C_STUB
PLATFORM_FLAGS =
VDI_VPATH = vdi/nonos
NONOS_RULE = options_nonos.lnt
endif
ifeq ("$(BUILD_CONFIGURATION)", "EmbeddedLinux")
CROSS_CC_PREFIX = arm-none-linux-gnueabi-
PLATFORM = armlinux
endif
ifeq ("$(BUILD_CONFIGURATION)", "EmbeddedRiscvLinux")
# CROSS_CC_PREFIX = riscv64-buildroot-linux-gnu-
# PLATFORM = riscvlinux
endif
#CC = $(CROSS_CC_PREFIX)gcc
#CXX = $(CROSS_CC_PREFIX)g++
LINKER=$(CC)
AR = $(CROSS_CC_PREFIX)ar
INCLUDES = -I./vpuapi -I./ffmpeg/include -I./sample_v2/helper -I./sample_v2/helper/misc -I./sample_v2/component -I./vdi -I../
INCLUDES += -I./sample_v2/component_decoder
ifeq ($(USE_RTL_SIM), yes)
DEFINES += -DCNM_SIM_PLATFORM -DCNM_SIM_DPI_INTERFACE -DSUPPORT_DECODER
DEFINES += -D$(PRODUCT) -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
else
DEFINES += -D$(PRODUCT) -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
endif # USE_SIM_PLATFORM
DEFINES += -DUSE_FEEDING_METHOD_BUFFER
CFLAGS += -g -I. -Wl,--fatal-warning $(INCLUDES) $(DEFINES) $(PLATFORM_FLAGS)
ifeq ($(USE_RTL_SIM), yes)
ifeq ($(IUS), 1)
CFLAGS += -fPIC # ncverilog is 64bit version
endif
endif
ARFLAGS += cru
#LDFLAGS = $(PLATFORM_FLAGS)
ifeq ($(USE_PTHREAD), yes)
LDLIBS += -lpthread
endif
LDLIBS += -lm -lrt
BUILDLIST=DECTEST
MAKEFILE=WaveDecode.mak
DECTEST=libsfdec.so
OBJDIR=obj
ALLOBJS=*.o
ALLDEPS=*.dep
ALLLIBS=*.a
RM=rm -f
MKDIR=mkdir -p
SOURCES_COMMON =main_helper.c vpuhelper.c bitstreamfeeder.c \
bitstreamreader.c bsfeeder_fixedsize_impl.c bsfeeder_framesize_impl.c \
bsfeeder_size_plus_es_impl.c bin_comparator_impl.c comparator.c \
md5_comparator_impl.c yuv_comparator_impl.c bsfeeder_buffer_impl.c \
cfgParser.c decoder_listener.c \
cnm_video_helper.c container.c \
datastructure.c debug.c \
bw_monitor.c pf_monitor.c \
cnm_app.c cnm_task.c component.c \
component_dec_decoder.c component_dec_feeder.c component_dec_renderer.c \
product.c vpuapifunc.c vpuapi.c \
coda9.c wave5.c \
$(VDI_C) $(VDI_OSAL_C) $(MM_C)
VPATH = sample_v2:
VPATH += sample_v2/component_encoder:
VPATH += sample_v2/component_decoder:
VPATH += sample_v2/helper:
VPATH += sample_v2/helper/bitstream:
VPATH += sample_v2/helper/comparator:
VPATH += sample_v2/helper/display:sample_v2/helper/misc:sample_v2/helper/yuv:sample_v2/component:
VPATH += vdi:
VPATH += $(VDI_VPATH):vpuapi:vpuapi/coda9:vpuapi/wave
VPATH2=$(patsubst %,-I%,$(subst :, ,$(VPATH)))
OBJECTNAMES_COMMON=$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCES_COMMON)))
OBJECTPATHS_COMMON=$(addprefix $(OBJDIR)/,$(notdir $(OBJECTNAMES_COMMON)))
SOURCES_DECTEST = sample_v2/main_dec_test.c
ifeq ($(USE_RTL_SIM), yes)
SOURCES_DECTEST += sample/main_sim.c
endif
OBJECTNAMES_DECTEST=$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCES_DECTEST)))
OBJECTPATHS_DECTEST=$(addprefix $(OBJDIR)/,$(notdir $(OBJECTNAMES_DECTEST))) $(OBJECTPATHS_COMMON)
all: $(BUILDLIST)
ifeq ($(USE_RTL_SIM), yes)
DECTEST: CREATE_DIR $(OBJECTPATHS_COMMON)
else
DECTEST: CREATE_DIR $(OBJECTPATHS_COMMON)
$(LINKER) -fPIC -shared -o $(DECTEST) $(LDFLAGS) -Wl,-gc-section -Wl,--start-group $(OBJECTPATHS_COMMON) $(LDLIBS) -Wl,--end-group
endif
-include $(OBJECTPATHS:.o=.dep)
clean:
$(RM) $(DECTEST)
$(RM) $(OBJDIR)/$(ALLOBJS)
$(RM) $(OBJDIR)/$(ALLDEPS)
CREATE_DIR:
-mkdir -p $(OBJDIR)
obj/%.o: %.c $(MAKEFILE)
$(CC) -fPIC -shared $(CFLAGS) -Wall -c $< -o $@ -MD -MF $(@:.o=.dep)
lint:
"$(LINT_HOME)/flint" -i"$(LINT_HOME)" $(DEFINES) $(INCLUDES) $(VPATH2) linux_std.lnt $(HAPS_RULE) $(NONOS_RULE) $(SOURCES_COMMON)