DSP

移植人脸识别 到 davince codec engine 记录

2019-07-13 09:47发布

1) 负责基于TI6000系列DSP的嵌入式视频处理系统的开发; 2) 负责图像及视频处理算法在DSP上的移植与优化;职位要求: 3)对图像及视频处理算法的DSP移植和开发有一定实际经验;
4)有一定的DSP算法优化经验,熟悉DSP上C语言优化以及汇编级优化;熟悉TI DSP DaVinci 系统架构,具有 DaVinci开发经验为优;了解Codec Engine的算法移植;
5)熟练操作CCS和Linux环境下的编译工具,精通C编程,了解算法的定点化,熟悉程序的汇编优化和逻辑优化;
6)了解图像处理和模式识别的相关知识,并具有该方面的算法移植经验;
/**************************************************************************************** *                                  Common declarations                                   *
****************************************************************************************/

/************************************alloca****************************************/


#ifndef    alloca    /* else probably defined as _builtin_alloca */

#ifdef    __STDC__

#include    

typedef void *    pointer;        /* generic pointer type (Std C) */

#else    /* !defined(__STDC__) */    /* assume pre-ANSI; no prototypes */

extern void        abort( /* void */ );
extern void        free( /* pointer */ );
extern pointer    malloc( /* size_t */ );

typedef char *    pointer;        /* generic pointer type (K&R C) */

#define    NULL    0            /* null pointer constant */

#endif    /* !defined(__STDC__) */


#define    LINEARIZE( p )    (p)



#ifndef    STACK_DIRECTION
#define    STACK_DIRECTION    0        /* initially unknown */
#endif

#if    STACK_DIRECTION != 0

#define    STK_DIR    STACK_DIRECTION    /* known at compile-time */

#else    /* STACK_DIRECTION == 0; need run-time probe */

static int    stack_dir = 0;            /* 1 or -1 once known */
#define    STK_DIR    stack_dir

static void
find_stack_direction( /* void */ )
    {
    static char *    addr = (char *)NULL;    /* address for
                                   first "dummy",
                                   once known */
    auto char        dummy;        /* to get stack address */

    if ( addr == NULL )
        {                    /* initial entry */
          addr = LINEARIZE( &dummy );

        find_stack_direction();        /* recurse once */
        }
    else                        /* second entry */
        if ( LINEARIZE( &dummy ) > addr )    /* crucial test */
            stack_dir = 1;        /* stack grew upward */
        else
            stack_dir = -1;        /* stack grew downward */
    }

#endif    /* STACK_DIRECTION == 0 */

/*
    An "alloca header" is used to:
    (a) chain together all alloca()ed blocks;
    (b) keep track of stack depth.

    It is very important that sizeof(header) agree with malloc()
    alignment chunk size.  The following default should work okay.
*/

#ifndef    ALIGN_SIZE
#define    ALIGN_SIZE    sizeof(double)
#endif

typedef union hdr
    {
    char        align[ALIGN_SIZE];    /* to force sizeof(header) */
    struct
        {
        union hdr *    next;            /* for chaining headers */
        char *    deep;            /* for stack depth measure */
        }    h;
    }    header;

/*
    alloca( size ) returns a pointer to at least "size" bytes of
    storage which will be automatically reclaimed upon exit from
    the procedure that called alloca().  Originally, this space
    was supposed to be taken from the current stack frame of the
    caller, but that method cannot be made to work for some
    implementations of C, for example under Gould's UTX/32.
*/

pointer
alloca( size_t size )
    {
    static header *    last = NULL;    /* -> last alloca header */
    auto char        probe;        /* probes stack depth: */
    register char *    depth = &probe;

#if    STACK_DIRECTION == 0
    if ( STK_DIR == 0 )            /* unknown growth direction */
        find_stack_direction();
#endif

    /* Reclaim garbage, defined as all alloca()ed storage that
       was allocated from deeper in the stack than currently. */

        {
        register header *    hp;        /* traverses linked list */

        for ( hp = last; hp != NULL; )
            if ( STK_DIR > 0 && hp->h.deep > depth
              || STK_DIR < 0 && hp->h.deep < depth
               )    {
                register header *    np = hp->h.next;

                free( (pointer)hp );    /* collect garbage */

                hp = np;        /* -> next header */
                }
            else
                break;        /* rest are not deeper */

        last = hp;                /* -> last valid storage */
        }

    if ( size == 0 )
        return (pointer)NULL;        /* no allocation required */

    /* Allocate combined header + user data storage. */

        {
        register pointer    newa = malloc( sizeof(header) + size );
                            /* address of header */

        if ( newa == NULL )
#ifdef    RETURN_NULL_ON_FAILURE
            return (pointer)NULL;
#else
            abort();            /* abort() is traditional */
#endif

        ((header *)newa)->h.next = last;
        ((header *)newa)->h.deep = depth;

        last = (header *)newa;

        /* User storage begins just after header. */

        return (pointer)((char *)newa + sizeof(header));
        }
    }

#endif /* !defined(alloca) */


/*****************************************************************************/




在用haar detect时,颜 {MOD}转换要用到 alloc,所以得加上这段 因为这里用到这个函数 
#define cvStackAlloc(size) cvAlignPtr( alloca((size) + CV_MALLOC_ALIGN), CV_MALLOC_ALIGN )