Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

Using C6Accel on DM6467 with DVSDK 3.x

From Texas Instruments Wiki
Jump to: navigation, search

END OF LIFE

C6Accel is still available for download, but is no longer being actively developed or maintained. Please consider other alternatives such as .

Introduction

The purpose of this article is to explain and provide an article on how to take the C6Accel package and integrate it into an older DVSDK 3.10 in order to support DM6467 platforms. It will also explain how to use C6Accel on its own and as part of an existing codec server with multimedia codecs.

The example code is can be downloaded from File:C6accel dm6467.tar.gz. It does not include the C6Accel or Codec Server packages which must be downloaded separately. This means that the changes described in the following sections of the article C6Accel directory and Codec Server codec.cfg file need to be done before they can be built and run.

Create a new project in DVSDK build system

Create the file structure

Create a new directory to build the C6accel package such as /dvsdk_3_10_00_19_c6accel_example. This directory will contain all the files that are added or changed. This means that the main dvsdk_3_10_00_19 directory and all its components can be left as is.

- Copy from the main dvsdk_3_10_00_19 directory the sub directory /examples.

- Copy from the main dvsdk_3_10_00_19" directory the contents of /dvsdk_demos_3_10_00_16/data.

- Extract the codec package to subdirectory /cs2dm6467_1_00_00_10 and the C6Accel package to subdirectory c6accel_1_01_00_00.

- Extract the downloaded package c6accel_dm6467.tar.gz to the new DVSDK project directory. This package will create the two new demo apps supplied in /dvsdk_demos_3_10_00_16/dm6467/sobel and /dvsdk_demos_3_10_00_16/dm6467/encodedecodesobel. These are both derived from the original DVSDK demo encodedecode.


The only file that needs to be manually patched as described in this section is dvsdk_3_10_00_19_c6accel_example/cs2dm6467_1_00_00_10/packages/ti/sdo/server/cs/codec.cfg.

Downloads

Edit the build system

The package also installed the build system files Rules.mak and Makefile for the project. Rules.mak must be modified to point the Path Variables to the correct directories to pick up the standard components from the main DVSDK and the modified components from the new directory.

Rules.mak must be modified to point to the install directories for DVSDK and the new project. The two following variables must be set to match the .

DVSDK_INSTALL_DIR=/my path to main dvsdk 3.10.00.19
DVSDK_NEW_DEMO_INSTALL_DIR=/my path to new c6accel project

For reference the changes to a standard Rules.mak are to add the variable to point to new project directory.

# The installation directory for C6accel and new examples
DVSDK_NEW_DEMO_INSTALL_DIR=/home/dvsdk_3_10_00_19_c6accel_example

and modify the component path variables that are in the new directory

ifeq ($(PLATFORM),dm6467)
# Where the cs2dm6467 codec server package is installed. In this case it is in new directory as we will add c6accel codec to std codec server
CODEC_INSTALL_DIR=$(DVSDK_NEW_DEMO_INSTALL_DIR)/cs2dm6467_1_00_00_10
endif
 
# Where the DVSDK demos are installed
DEMO_INSTALL_DIR=$(DVSDK_NEW_DEMO_INSTALL_DIR)/dvsdk_demos_3_10_00_16

Add C6Accel for DM6467 to this project

As downloaded C6Accel is designed to be built by a make command in the main c6accel directory dvsdk_3_10_00_19_c6accel_example/c6accel_1_01_00_00. In order to integrate it into the main dvsdk build system the following changes and additions must be made (all paths are relative to dvsdk_3_10_00_19_c6accel_example). All the changes have been rolled up into a patch that can be installed as follows:

To run the patch (after installing the c6accel 1.01.00.00 package in the new project directory) execute the following command from new project directory

 ~/dvsdk_3_10_00_19_c6accel_example$ patch -p1 < c6accel_patch/c6accel_dm6467.patch


Now that the demos are installed and c6accel patched the code is ready to build. Build the the c6accel library and app for dm6467 and install to the EXEC_DIR.

~/dvsdk_3_10_00_19_c6accel_example$ make c6accel_clean
~/dvsdk_3_10_00_19_c6accel_example$ make c6accel
~/dvsdk_3_10_00_19_c6accel_example$ make c6accel_install


Changes introduced by the patch to the c6accel package

The aim of this section is to explain all the changes that have been made by the patch and in the top level build files in order to build C6Accel for DM6467. It is only for reference and understanding.


  • /Rules.mak

Add Platform based build definitions for variables to start of file. This is migrating information from c6accel_1_01_00_00/Rules.mak and adding DM6467 support.

# Define target platform.
PLATFORM=dm6467
 
ifeq ($(PLATFORM),omapl138)
 PLATFORM_XDC=ti.platforms.evmOMAPL138
 DSP_ISA=674
 ARM_ISA=armv5t
endif
ifeq ($(PLATFORM),omap3530)
 PLATFORM_XDC=ti.platforms.evmOMAP3530
 DSP_ISA=64P
 ARM_ISA=armv7-a
endif
ifeq ($(PLATFORM),dm6467)
 PLATFORM_XDC=ti.platforms.evmDM6467T
 DSP_ISA=64P
 ARM_ISA=armv5t
endif


Add path variable for C6Accel

C6ACCEL_INSTALL_DIR=$(DVSDK_NEW_DEMO_INSTALL_DIR)/c6accel_1_01_00_00


  • /Makefile

Add c6accel and c6accel_clean to default rules

#==============================================================================
# The default build target.
#==============================================================================
all:	check cmem dmammapk edmak irqk dmai c6accel demos
 
#==============================================================================
# Clean up the targets built by 'make all'.
#==============================================================================
clean:	cmem_clean dmammapk_clean edmak_clean irqk_clean dmai_clean c6accel_clean demos_clean

Add C6Accel path variable to the demos rules with C6ACCEL_INSTALL_DIR=$(C6ACCEL_INSTALL_DIR)

#==============================================================================
# Build the dvsdk demos for the configured platform. Also, an explicit cleanup
# target is defined.
#==============================================================================
demos:
	$(MAKE) -C $(DEMO_INSTALL_DIR) $(PLATFORM) C6ACCEL_INSTALL_DIR=$(C6ACCEL_INSTALL_DIR) DEMO_INSTALL_DIR=$(DEMO_INSTALL_DIR)                              \
                DVSDK_INSTALL_DIR=$(DVSDK_INSTALL_DIR) XDC_INSTALL_DIR=$(XDC_INSTALL_DIR) CE_INSTALL_DIR=$(CE_INSTALL_DIR) FC_INSTALL_DIR=$(FC_INSTALL_DIR)     \
                CMEM_INSTALL_DIR=$(CMEM_INSTALL_DIR) CODEC_INSTALL_DIR=$(CODEC_INSTALL_DIR) XDAIS_INSTALL_DIR=$(XDAIS_INSTALL_DIR)                              \
                LINK_INSTALL_DIR=$(LINK_INSTALL_DIR) DMAI_INSTALL_DIR=$(DMAI_INSTALL_DIR) MVTOOL_DIR=$(MVTOOL_DIR) CC=$(CSTOOL_PREFIX)gcc AR=$(CSTOOL_PREFIX)ar \
                CROSS_COMPILE=$(MVTOOL_PREFIX) LINUXLIBS_INSTALL_DIR=$(LINUXLIBS_INSTALL_DIR) PLATFORM=$(PLATFORM)
 
 
demos_clean:
	$(MAKE) -C $(DEMO_INSTALL_DIR) clean DVSDK_INSTALL_DIR=$(DVSDK_INSTALL_DIR) C6ACCEL_INSTALL_DIR=$(C6ACCEL_INSTALL_DIR) XDC_INSTALL_DIR=$(XDC_INSTALL_DIR) \
                CE_INSTALL_DIR=$(CE_INSTALL_DIR) FC_INSTALL_DIR=$(FC_INSTALL_DIR) CMEM_INSTALL_DIR=$(CMEM_INSTALL_DIR) CODEC_INSTALL_DIR=$(CODEC_INSTALL_DIR)     \
                XDAIS_INSTALL_DIR=$(XDAIS_INSTALL_DIR) LINK_INSTALL_DIR=$(LINK_INSTALL_DIR) DMAI_INSTALL_DIR=$(DMAI_INSTALL_DIR) MVTOOL_DIR=$(MVTOOL_DIR)         \
                CC=$(CSTOOL_PREFIX)gcc CROSS_COMPILE=$(MVTOOL_PREFIX) LINUXLIBS_INSTALL_DIR=$(LINUXLIBS_INSTALL_DIR) PLATFORM=$(PLATFORM)

Add the C6Accel path to the codecs rule so that in the case that C6Accel is being added to the existing server the codec server build can pick up the C6Accel codec package for integration from the C6Accel directory rather than the more conventional /codec directory.

codecs:
ifeq ($(HAS_SERVER),true)
	$(MAKE) -C $(CODEC_INSTALL_DIR) C6ACCEL_INSTALL_DIR=$(C6ACCEL_INSTALL_DIR) DVSDK_INSTALL_DIR=$(DVSDK_INSTALL_DIR) BIOS_INSTALL_DIR=$(BIOS_INSTALL_DIR)   \
                XDC_INSTALL_DIR=$(XDC_INSTALL_DIR) CE_INSTALL_DIR=$(CE_INSTALL_DIR) FC_INSTALL_DIR=$(FC_INSTALL_DIR) CMEM_INSTALL_DIR=$(LINUXUTILS_INSTALL_DIR)  \
                CODEC_INSTALL_DIR=$(CODEC_INSTALL_DIR) BIOSUTILS_INSTALL_DIR=$(BIOSUTILS_INSTALL_DIR) XDAIS_INSTALL_DIR=$(XDAIS_INSTALL_DIR)                     \
                EDMA3_LLD_INSTALL_DIR=$(EDMA3_LLD_INSTALL_DIR) CODEGEN_INSTALL_DIR=$(CODEGEN_INSTALL_DIR) LINK_INSTALL_DIR=$(LINK_INSTALL_DIR) XDCARGS=\"prod\"
endif
 
codecs_clean:
ifeq ($(HAS_SERVER),true)
	$(MAKE) -C $(CODEC_INSTALL_DIR)  C6ACCEL_INSTALL_DIR=$(C6ACCEL_INSTALL_DIR) DVSDK_INSTALL_DIR=$(DVSDK_INSTALL_DIR) BIOS_INSTALL_DIR=$(BIOS_INSTALL_DIR)  \
                XDC_INSTALL_DIR=$(XDC_INSTALL_DIR) CE_INSTALL_DIR=$(CE_INSTALL_DIR) FC_INSTALL_DIR=$(FC_INSTALL_DIR) CMEM_INSTALL_DIR=$(LINUXUTILS_INSTALL_DIR)  \
                CODEC_INSTALL_DIR=$(CODEC_INSTALL_DIR) BIOSUTILS_INSTALL_DIR=$(BIOSUTILS_INSTALL_DIR) XDAIS_INSTALL_DIR=$(XDAIS_INSTALL_DIR)                     \
                LINK_INSTALL_DIR=$(LINK_INSTALL_DIR) XDCARGS=\"prod\" clean
endif

Add the new rules to build C6Accel

#==============================================================================
# Build codec package for the configured platform. Also, an explicit cleanup
# target is defined.
#==============================================================================
c6accel:
	$(MAKE) -C $(C6ACCEL_INSTALL_DIR) \
	CE_INSTALL_DIR=$(CE_INSTALL_DIR) \
	FC_INSTALL_DIR=$(FC_INSTALL_DIR) \
	LINK_INSTALL_DIR=$(LINK_INSTALL_DIR) \
	CMEM_INSTALL_DIR=$(CMEM_INSTALL_DIR) \
	XDAIS_INSTALL_DIR=$(XDAIS_INSTALL_DIR) \
	XDC_INSTALL_DIR=$(XDC_INSTALL_DIR) \
	LPM_INSTALL_DIR=$(LPM_INSTALL_DIR) \
	BIOS_INSTALL_DIR=$(BIOS_INSTALL_DIR) \
	CODEGEN_INSTALL_DIR=$(CODEGEN_INSTALL_DIR) \
	BIOSUTILS_INSTALL_DIR=$(BIOSUTILS_INSTALL_DIR) \
	C6ACCEL_INSTALL_DIR=$(C6ACCEL_INSTALL_DIR) \
        PLATFORM_XDC=$(PLATFORM_XDC) \
        DSP_ISA=$(DSP_ISA) \
        ARM_ISA=$(ARM_ISA) \
	XDCARGS="eval" \
	all
 
c6accel_clean:
	$(MAKE) -C $(C6ACCEL_INSTALL_DIR) \
	CE_INSTALL_DIR=$(CE_INSTALL_DIR) \
	FC_INSTALL_DIR=$(FC_INSTALL_DIR) \
	LINK_INSTALL_DIR=$(LINK_INSTALL_DIR) \
	CMEM_INSTALL_DIR=$(CMEM_INSTALL_DIR) \
	XDAIS_INSTALL_DIR=$(XDAIS_INSTALL_DIR) \
	XDC_INSTALL_DIR=$(XDC_INSTALL_DIR) \
	LPM_INSTALL_DIR=$(LPM_INSTALL_DIR) \
	BIOS_INSTALL_DIR=$(BIOS_INSTALL_DIR) \
	CODEGEN_INSTALL_DIR=$(CODEGEN_INSTALL_DIR) \
	BIOSUTILS_INSTALL_DIR=$(BIOSUTILS_INSTALL_DIR) \
	C6ACCEL_INSTALL_DIR=$(C6ACCEL_INSTALL_DIR) \
        PLATFORM_XDC=$(PLATFORM_XDC) \
        DSP_ISA=$(DSP_ISA) \
        ARM_ISA=$(ARM_ISA) \
	XDCARGS="eval" \
	clean
 
c6accel_install:
	$(MAKE) -C $(C6ACCEL_INSTALL_DIR) install

Add C6ACCEL_INSTALL_DIR to the install rule

#==============================================================================
# Install the built binaries to the target file system.
#==============================================================================
install:
	@echo
	@echo Creating $(EXEC_DIR)
	@mkdir -p $(EXEC_DIR)
 
	@echo Copying kernel modules to target file system: $(EXEC_DIR)/
	@install -m 666 $(DVSDK_INSTALL_DIR)/kernel_binaries/$(PLATFORM)/* $(EXEC_DIR)/
 
	@echo Installing DVSDK demos..
	$(MAKE) -C $(DEMO_INSTALL_DIR)/$(PLATFORM) install EXEC_DIR=$(EXEC_DIR) C6ACCEL_INSTALL_DIR=$(C6ACCEL_INSTALL_DIR)


  • c6accel_1_01_00_00/Rules.mak

Change the Rules.mak include to point to file in directory above and remove PLATFORM_XDC, DSP_ISA and ARM_ISA definitions as they are now done in main directory as they are required for main Makefile to build c6accel.

#=========================================================
# If C6Accel package is found under DVSDK Root Directory
# Set only the DVSDK INSTALL Directory below
#=========================================================
-include ../Rules.make
 
EXEC_DIR_C6ACCEL = $(EXEC_DIR)/c6accel_app
 
 
#==============================================================================
# Set the below paths as needed if not previously defined above
# according to the location where components have been installed/placed
#==============================================================================
  • c6accel_1_01_00_00/Makefile

Add install rule for c6accel if PLATFORM is DM6467

ifeq ($(PLATFORM),dm6467)
	@echo Copying kernel modules to target file system: $(EXEC_DIR_C6ACCEL)/
	@echo Copying cmemk.ko
	@install -m 755 $(CMEM_INSTALL_DIR)/packages/ti/sdo/linuxutils/cmem/src/module/cmemk.ko $(EXEC_DIR_C6ACCEL)/
	@echo Copying dsplinkk.ko
	@install -m 755 $(LINK_INSTALL_DIR)/dsplink/gpp/export/BIN/Linux/DAVINCIHD/RELEASE/dsplinkk.ko $(EXEC_DIR_C6ACCEL)/
	@echo Copying c6accel codec servers from $(C6ACCEL_INSTALL_DIR)/soc
	@install -m 755 $(C6ACCEL_INSTALL_DIR)/soc/packages/ti/c6accel_unitservers/dm6467/c6accel_dm6467.x64P $(EXEC_DIR_C6ACCEL)/
	@echo Copying c6accel test app from $(C6ACCEL_INSTALL_DIR)/soc/app
	@install -m 755 $(C6ACCEL_INSTALL_DIR)/soc/app/c6accel_app $(EXEC_DIR_C6ACCEL)/
	@echo Copying testfile from $(C6ACCEL_INSTALL_DIR)/soc/app
	@install -m 755 $(C6ACCEL_INSTALL_DIR)/soc/app/test_files/* $(EXEC_DIR_C6ACCEL)/test_files
	@chmod -x $(EXEC_DIR_C6ACCEL)/*.x64P $(EXEC_DIR_C6ACCEL)/*.ko
	@chmod +x $(EXEC_DIR_C6ACCEL)/c6accel_app
	@install -m 755 $(C6ACCEL_INSTALL_DIR)/soc/app/dm6467/loadmodules_dm6467_c6accel.sh $(EXEC_DIR_C6ACCEL)
	@chmod +x $(EXEC_DIR_C6ACCEL)/loadmodules_dm6467_c6accel.sh
endif
  • c6accel_1_01_00_00/soc/Makefile

Change Rules.mak include to point to directory above

include ../../Rules.make

and remove server_install rule entries for PLATFORM equals omap3530 or omapl138 as it is handled in previous file change.

server_install:
	@install -d $(EXEC_DIR_C6ACCEL)
 
clean_packages:
	$(XDC) clean -PR packages
  • c6accel_1_01_00_00/soc/c6accelw/Makefile

Change ROOTDIR to make Rules.mak include point to new project directory.

ROOTDIR = ../../..
  • c6accel_1_01_00_00/soc/app/Makefile

Change ROOTDIR to make Rules.mak include point to new project directory.

ROOTDIR = ../../..

and add support for DM6467 in C_FLAGS definition.

ifeq ($(PLATFORM),dm6467)
    C_FLAGS	+= -DPLATFORM=6467
endif
  • c6accel_1_01_00_00/soc/app/appMain.c

Add support for PLATFORM==6467 in definition of ENGINENAME

#if (PLATFORM == 3530)
 #define ENGINENAME "omap3530"
 #warning ENGINENAME "omap3530"
#elif (PLATFORM == 138)
 #define ENGINENAME "omapl138"
 #warning ENGINENAME "omapl138"
 #define DEVICE_FLOAT
#elif (PLATFORM ==6467)
 #define ENGINENAME "dm6467"
 #warning ENGINENAME "dm6467"
#endif

The next couple of files are required to support the creation of the DSP server for C6Accel. Copy the files for the DM6467 server files from the codec server directory /cs2dm6467_1_00_00_10\packages\ti\sdo\server\cs to a new directory c6accel_1_01_00_00/soc/packages/ti/c6accel_unitservers_dm6467.

  • c6accel_1_01_00_00/soc/packages/ti/c6accel_unitservers_dm6467/codec.cfg

This is the file that describes all the codecs that will be built into the DSP codec server. So remove contents of this file and replace with

// Define the new codec
    var C6ACCEL = xdc.useModule('ti.c6accel.ce.C6ACCEL');
 
        C6ACCEL.serverFxns = undefined;
        C6ACCEL.stubFxns = undefined;
        C6ACCEL.serverFxns = "UNIVERSAL_SKEL";
        C6ACCEL.stubFxns = "UNIVERSAL_STUBS";
        C6ACCEL.alg.FLOAT = false;
        C6ACCEL.alg.watermark = false;
        C6ACCEL.alg.codeSection = "DDR2";
        C6ACCEL.alg.udataSection = "DDR2";
        C6ACCEL.alg.dataSection = "DDR2";
 
/*
 * The array of algorithms this server can serve up.  This array also
 * configures details about the threads which will be created to run the
 * algorithms (e.g. stack sizes, priorities, etc.).
 */
Server.algs = [
    {name: "c6accel", mod: C6ACCEL , threadAttrs: {
        stackMemId: 0, priority: Server.MINPRI + 1},
        groupId : 0,
    },
 
];
  • c6accel_1_01_00_00/soc/packages/ti/c6accel_unitservers_dm6467/package.bld

This file controls the building of the server. Change two following two lines to add the correct server name and target type

    var serverName = "c6accel_" + fullName.substring(fullName.lastIndexOf('.')+ 1);
    Pkg.addExecutable( serverName, targ, "ti.platforms.evmDM6467T",
  • c6accel_1_01_00_00/soc/packages/ti/c6accel_unitservers_dm6467/package.xdc

This file defines the package name for the new server. Change the file contents to

package ti.c6accel_unitservers.dm6467 [1,0,0] {
  • c6accel_1_01_00_00/soc/packages/ti/c6accel_unitservers_dm6467/package.xs

Change the function validate() to only validate the new C6Accel codec

         validate_one_codec( "ti.c6accel", "C6ACCEL" );

How to integrate C6Accel into applications

This section will explain how to use C6Accel in two modes.

In the first the only thing being done on the DSP is C6Accel and so internally to C6accel Codec Engine will load a DSP server that only contains C6Accel. The sobel demo reworks the standard DVSDK encodedecode software and implements a 720p component video loopback and applies the Sobel edge detector to the captured video and outputs the edge map to the display.

In the second mode C6Accel functionality is being added to an existing multimedia system which already has a DSP codec server to implement. In this case C6Accel must be added to the existing codec server. The encodedecodesobel demo reworks the standard DVSDK encodedecode software and captures a 720p component video, applies the Sobel edge detector to the captured video, encodes it in H264 then decodes it and finally outputs the edge map to the display. This case illustrates one of the key benefits of C6Accel as it can integrate DSP functionality alongside Multimedia.


Before building the demos the following changes must be made to the codec server build. These are not included in the patch file and so must be done manually. The patch file only modified the c6accel package.

  • /dvsdk_3_10_00_19_c6accel_example/cs2dm6467_1_00_00_10/Makefile

Add path $(C6ACCEL_INSTALL_DIR)/soc/packages; to C6Accel codec to XDCPATH

XDCPATH = $(CURDIR);$(C6ACCEL_INSTALL_DIR)/soc/packages;$(CODEC_INSTALL_DIR)/packages;$(XDAIS_INSTALL_DIR)/packages;$(FC_INSTALL_DIR)/packages;$(FC_INSTALL_DIR)/fctools/packages;$(BIOS_INSTALL_DIR)/packages;$(BIOSUTILS_INSTALL_DIR)/packages;$(CMEM_INSTALL_DIR)/packages;$(LINK_INSTALL_DIR)/packages;$(LINK_INSTALL_DIR);$(CE_INSTALL_DIR)/packages;$(CE_INSTALL_DIR)/cetools/packages;$(EDMA3_LLD_INSTALL_DIR)/packages
</syntaxhighlight.
 
*/dvsdk_3_10_00_19_c6accel_example/cs2dm6467_1_00_00_10/packages/ti/sdo/server/cs/codec.cfg
Add the definition for the C6Accel codec
 
<syntaxhighlight lang='javascript'>
    // Define the new codec
    var C6ACCEL = xdc.useModule('ti.c6accel.ce.C6ACCEL');
 
        C6ACCEL.serverFxns = undefined;
        C6ACCEL.stubFxns = undefined;
        C6ACCEL.serverFxns = "UNIVERSAL_SKEL";
        C6ACCEL.stubFxns = "UNIVERSAL_STUBS";
        C6ACCEL.alg.FLOAT = false;
        C6ACCEL.alg.watermark = false;
        C6ACCEL.alg.codeSection = "DDR2";
        C6ACCEL.alg.udataSection = "DDR2";
        C6ACCEL.alg.dataSection = "DDR2";


and then add it to the Server.algs structure. Set the groupId to 0 and priority to MINPRI+1 so that C6Accel is in same group as the codecs and so will be run in a round-robin mode to avoid cache thrashing due to unnecessary DSP context switches. When the server is built from the top level with command make codecs this will pull in the C6Accel codec and add it to existing server.

     // Add the codec to server
    {name: "c6accel", mod: C6ACCEL , threadAttrs: {
        stackMemId: 0, priority: Server.MINPRI + 1},
        groupId : 0,
    },




The new demos can be built as follows. The first time they are built the codecs and dmai need to be built before the demos.

~/dvsdk_3_10_00_19_c6accel_example$ make codecs
~/dvsdk_3_10_00_19_c6accel_example$ make dmai
~/dvsdk_3_10_00_19_c6accel_example$ make demos
~/dvsdk_3_10_00_19_c6accel_example$ make install


Sobel Demo - C6Accel only

This section summarises the changes that were made to the encodedecode application to integrate C6Accel .

Initially the directory dvsdk_demos_3_10_00_16/dm6467/encodedecode was copied to dvsdk_demos_3_10_00_16/dm6467/sobel and the following changes were made to the files in this directory.

  • Rename /encodedecode.cfg to /sobel.cfg

Change the server used by Codec Engine to the C6accel one for DM6467

var demoEngine = Engine.createFromServer(
    "dm6467",
    "./c6accel_dm6467.x64P",
    "ti.c6accel_unitservers.dm6467"
    );
  • /Makefile

Add the paths to XDC_PATH to allow the tools to find C6accel's /soc/packages directory and /examples in Demo directory

XDC_PATH =  $(USER_XDC_PATH); ../../packages;$(C6ACCEL_INSTALL_DIR)/soc/packages;$(DEMO_INSTALL_DIR)/packages;      \
            $(DMAI_INSTALL_DIR)/packages;$(CE_INSTALL_DIR)/packages;$(LINK_INSTALL_DIR);$(FC_INSTALL_DIR)/packages; \
            $(LINK_INSTALL_DIR)/packages;$(XDAIS_INSTALL_DIR)/packages;$(CMEM_INSTALL_DIR)/packages;$(CODEC_INSTALL_DIR)/packages

Add variables to point to the C6Accel wrapper library that the ARM code links with and the location of the DSP codec server binary so it can be copied by make install.

C6ACCEL_LIB = $(C6ACCEL_INSTALL_DIR)/soc/c6accelw/lib/c6accelw_dm6467.a470MV
C6ACCEL_BINARY = $(C6ACCEL_INSTALL_DIR)/soc/packages/ti/c6accel_unitservers/dm6467/c6accel_dm6467.x64P

Add C6ACCEL_BINARY to the install rule

install_$(TARGET):
	@install -d $(EXEC_DIR)
	@install $(TARGET) $(EXEC_DIR)
	@install $(TARGET).txt $(EXEC_DIR)
	@install $(C6ACCEL_BINARY) $(EXEC_DIR)
	@echo
	@echo Installed $(TARGET) binaries to $(EXEC_DIR)..

and the C6Accel wrapper library C6ACCEL_LIB to the linker arguments

$(TARGET):	$(OBJFILES) $(C6ACCEL_LIB) $(XDC_LFILE)
	@echo
	@echo Linking $@ from $^..
	$(LINK.c) -o $@ $^
  • /video.h

Add the following defines that will be used to access underlying Codec Engine

// Defines for c6accel usage in sobel only demo which uses server called dm6467
#define ENGINENAME "dm6467"
#define ALGNAME "c6accel"
#define APPNAME "app"
  • /video.c

This file contains major changes to remove the codec functionality. Essentially the new function takes the passThrough mode from the original and adds C6accel sobel operation. Best way to see this is to do a diff between /encodedecode and /sobel

The changes that are relevant to creating a new application that uses C6Accel are to

Add includes and defintions for C6Accel

#include "../c6accelw/c6accelw.h"
 
/*Define a C6Accel Handle to call the abstracted wrapper APIs*/
C6accel_Handle hC6 = NULL;

Add code to open C6Accel. As C6Accel is the only user of the DSP in this example the first parameter to C6accel_create() is the ENGINENAME and second parameter is NULL as their is no existing Engine open.

    /* Create call generates a C6ACCEL handle */
    hC6 = C6accel_create(ENGINENAME, NULL,ALGNAME, NULL);
 
    /*Check for failure*/
    if ( hC6 == NULL)
      {ERR("%s: C6accel_create() failed \n",APPNAME);
       cleanup(THREAD_FAILURE);
      }
    /* Set C6Accel instance for synchronous call*/
    C6Accel_setSync(hC6);


Add code to implement the C6accel_IMG_sobel_3x3_8() operation as well as changes to buffer management to return the input hVidBuf to the capture driver.

        // Main process function here
        // Get display buffer
        fifoRet = Fifo_get(envp->hDisplayOutFifo, &hDispBuf);
        // Use C6accel to do sobel filtering on captured frame luma and then zero chroma
        C6accel_IMG_sobel_3x3_8(hC6,
                               (const unsigned char *)Buffer_getUserPtr(hVidBuf),   /* Input image data   */
                               (unsigned char*)Buffer_getUserPtr(hDispBuf),         /* Output image data  */
                               envp->imageWidth, envp->imageHeight                  /* Image dimensions   */
                              );
 
        // Set all the Chroma pixels in 420SP buffer to neutral (black) 0x80 as sobel only fills Luma plane
        memset((unsigned char*)(Buffer_getUserPtr(hDispBuf)+(envp->imageWidth* envp->imageHeight)),0x80,envp->imageWidth* envp->imageHeight/2);
 
         /* Send the buffer through to the display thread */
         if (Fifo_put(envp->hDisplayInFifo, hDispBuf) < 0) {
            ERR("Failed to send buffer to display thread\n");
            cleanup(THREAD_FAILURE);
             }
        // Main process function here
        // Get display buffer
        fifoRet = Fifo_get(envp->hDisplayOutFifo, &hDispBuf);
        // Use C6accel to do sobel filtering on captured frame luma and then zero chroma
        C6accel_IMG_sobel_3x3_8(hC6,
                               (const unsigned char *)Buffer_getUserPtr(hVidBuf),   /* Input image data   */
                               (unsigned char*)Buffer_getUserPtr(hDispBuf),         /* Output image data  */
                               envp->imageWidth, envp->imageHeight                  /* Image dimensions   */
                              );
 
        // Set all the Chroma pixels in 420SP buffer to neutral (black) 0x80 as sobel only fills Luma plane
        memset((unsigned char*)(Buffer_getUserPtr(hDispBuf)+(envp->imageWidth* envp->imageHeight)),0x80,envp->imageWidth* envp->imageHeight/2);
 
        /* Send the buffer through to the display thread */
        if (Fifo_put(envp->hDisplayInFifo, hDispBuf) < 0) {
            ERR("Failed to send buffer to display thread\n");
            cleanup(THREAD_FAILURE);
             }
        /* and return input video frame to capture thread */
        if (Fifo_put(envp->hCaptureInFifo, hVidBuf) < 0) {
            ERR("Failed to send buffer to capture thread\n");
            cleanup(THREAD_FAILURE);
             }

and finally add code to delete C6Accel

    if (hC6) {
        C6accel_delete(hC6);
    }

Encode Decode Sobel Demo - C6Accel + Multimedia Codec server

This demo is also a rework of the standard encodedecode application but in this case the encode and decode functionality is maintained and the input video is passed through the Sobel function before encoding. The key difference in terms of the use of C6Accel is that the C6accel codec is added to the existing codec server.

The example implementation has chosen to place a new copy of the DM6467 codec server in the new project directory so that the standard codec server in main DVSDK is untouched. This is only to isolate the changes made in the new application.



  • /encodedecodesobel.cfg

This file simply points to the existing Codec Server and so is only renamed to match the application name encodedecodesobel.

  • /Makefile

These changes are very similar to those required for Sobel, change XDC_PATH to add $(C6ACCEL_INSTALL_DIR)/soc/packages;$DEMO_INSTALL_DIR)/packages and then define C6ACCEL_LIB and add to $(TARGET) rule.

  • /video.h

Only need to add definitions for ALGNAME and APPNAME as the Codec Engine we open is the standard one.

  • /video.c

The core of this function is the same as the encodedecode demo. The main difference in flow is that function encodedecode() now does a C6accel_sobel_3x3_8() operation before the encode call. In order to do this its API is extended to include hC6 handle and a temporary buffer handle hTempBuf.

The key difference concerning C6Accel relative to sobel example is that because C6Accel is included in an existing Codec Engine handle (already opened) the usage of C6accel_create() is changed so that parameter 1 is now NULL and parameter 2 is the pre-existing handle to Codec Engine.

        /* Create call generates a C6ACCEL handle */
        /* As we are co-existing with a server that has been rebuilt to add c6accel we pass in the name of existing server  */
        hC6 = C6accel_create(NULL, hEngine,ALGNAME, NULL);

Build the Demos

Use the following sequence to build and install the demos. Note that make all in the main DVSDK directory and the make codecs_clean and make codecs are to ensure that all components required are build. Subsequent builds will only require make demos and make install in the new project directory.

~/dvsdk_3_10_00_19$ make all
~/dvsdk_3_10_00_19$ cd ../dvsdk_3_10_00_19_c6accel_example
~/dvsdk_3_10_00_19_c6accel_example$ make codecs_clean
~/dvsdk_3_10_00_19_c6accel_example$ make codecs
~/dvsdk_3_10_00_19_c6accel_example$ make demos
~/dvsdk_3_10_00_19_c6accel_example$ make install

Benchmark results

The examples have been built and installed on a DM6467 EVM (ARM9 at 363MHz/DSP at 729MHZ) running the arago filesystem from DVSDK 3.10.00.19.

sobel

The demo is installed to the EXEC_DIR which in this case is /home/root directory in the file system. Firstly the modules are loaded and then app is run.

root@dm6467t-evm:~# ./loadmodules_sobel.sh
 
root@dm6467t-evm:~# ./sobel
C6ACCEL sobel demo started.
C6ACCEL Sobel demo ARM Load: 23% DSP Load: 100% Display Type: 720P 60Hz Video Co
dec: H.264 BP Video fps: 28 fps Video bit rate: 0 kbps Video resolution: 1280x72
0 Time: 00:00:01
C6ACCEL Sobel demo ARM Load: 23% DSP Load: 100% Display Type: 720P 60Hz Video Co
dec: H.264 BP Video fps: 30 fps Video bit rate: 0 kbps Video resolution: 1280x72
0 Time: 00:00:02

The terminal window gives a frame rate of 30fps. Initially the DSP load is 100% but immediately declines to the real number. This is a side-effect of the hsitory window used to calculate the DSP load which defaults to 100% at start.

Logging of the operation shows that the 1280x720p sobel operation is taking 15ms. This logging was done using the CE_DEBUG=2 option on the command line, writing the output to file for speed and running for 2 seconds. From this log it is possible to extract the time taken for the Sobel operation as seen by the ARM. The command line to write the log to a file is:

root@dm6467t-evm:~# CE_DEBUG=2 ./sobel -t2 > log_sobel.txt

encodedecodesobel

The demo is installed to the EXEC_DIR which in this case is /home/root directory in the file system. Firstly the modules are loaded and then app is run.

root@dm6467t-evm:~# ./loadmodules_sobel.sh
 
root@dm6467t-evm:~# ./encodedecodesobel
Encodedecode + C6accel sobel demo started.
Encode Decode + C6accel sobel demo ARM Load: 12% DSP Load: 100% Display Type: 72
0P 60Hz Video Codec: H.264 BP Video fps: 9 fps Video bit rate: 10705 kbps Video
resolution: 1280x720 Time: 00:00:01
 
Encode Decode + C6accel sobel demo ARM Load: 12% DSP Load: 100% Display Type: 72
0P 60Hz Video Codec: H.264 BP Video fps: 17 fps Video bit rate: 4536 kbps Video
resolution: 1280x720 Time: 00:00:02
 
Encode Decode + C6accel sobel demo ARM Load: 17% DSP Load: 100% Display Type: 72
0P 60Hz Video Codec: H.264 BP Video fps: 17 fps Video bit rate: 7267 kbps Video
resolution: 1280x720 Time: 00:00:03
 
Encode Decode + C6accel sobel demo ARM Load: 12% DSP Load: 100% Display Type: 72
0P 60Hz Video Codec: H.264 BP Video fps: 16 fps Video bit rate: 10482 kbps Video
 resolution: 1280x720 Time: 00:00:04

The terminal window gives a frame rate of 16/17fps. Logging of the operation shows that the 1280x720p sobel operation is taking 15ms, the H264 encode 28ms and H264 decode 22ms. This give a total processing time of 65ms which corresponds to around 15fps.

Return to C6Accel Main page

Click Here, Codec Engine IUNIVERSAL support, OpenCL or RCM