Skip to content

lib: introduction of the VC8000NanoE video encoder library #295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ if(CONFIG_HAS_STM32LIB)
add_subdirectory_ifdef(CONFIG_BT_STM32_IPM stm32wb)
add_subdirectory_ifdef(CONFIG_BT_STM32WBA stm32wba)
add_subdirectory_ifdef(CONFIG_BT_STM32WB0 stm32wb0)
add_subdirectory_ifdef(CONFIG_VIDEO_STM32_VENC vc8000nanoe)
endif()
32 changes: 32 additions & 0 deletions lib/vc8000nanoe/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (c) 2025 STMicroelectronics
#
# SPDX-License-Identifier: Apache-2.0

zephyr_library_compile_definitions(H1_HAVE_ENCDEBUG_H)
#zephyr_library_compile_definitions(CONFIG_VENC_DEBUG)
zephyr_include_directories(inc)
zephyr_include_directories(source/common)
zephyr_include_directories(source/h264)

zephyr_library_sources(source/common/encasiccontroller.c)
zephyr_library_sources(source/common/encasiccontroller_v2.c)
zephyr_library_sources(source/common/encpreprocess.c)
zephyr_library_sources(source/common/encswhwregisters.c)

zephyr_library_sources(source/h264/H264Cabac.c)
zephyr_library_sources(source/h264/H264CodeFrame.c)
zephyr_library_sources(source/h264/H264Denoise.c)
zephyr_library_sources(source/h264/H264EncApi.c)
zephyr_library_sources(source/h264/H264Init.c)
zephyr_library_sources(source/h264/H264Mad.c)
zephyr_library_sources(source/h264/H264NalUnit.c)
zephyr_library_sources(source/h264/H264PictureBuffer.c)
zephyr_library_sources(source/h264/H264PictureParameterSet.c)
zephyr_library_sources(source/h264/H264PutBits.c)
zephyr_library_sources(source/h264/H264RateControl.c)
zephyr_library_sources(source/h264/H264Sei.c)
zephyr_library_sources(source/h264/H264SequenceParameterSet.c)
zephyr_library_sources(source/h264/H264Slice.c)
zephyr_library_sources(source/h264/h264encapi_ext.c)


3 changes: 3 additions & 0 deletions lib/vc8000nanoe/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (c) 2023 STMicroelectronics

This software component is licensed by STMicroelectronics under the **BSD-3-Clause** license. You may not use this software except in compliance with this license. You may obtain a copy of the license [here](https://opensource.org/licenses/BSD-3-Clause).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop this file - it's large and unneeded. (Also, I'm a bit worried about licensing...)

Binary file not shown.
129 changes: 129 additions & 0 deletions lib/vc8000nanoe/inc/basetype.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*
* Copyright (c) 2015-2022, Verisilicon Inc. - All Rights Reserved
* Copyright (c) 2011-2014, Google Inc. - All Rights Reserved
*
*
********************************************************************************
*
* This software is distributed under the terms of
* BSD-3-Clause. The following provisions apply :
*
********************************************************************************
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
********************************************************************************
*
* Description : Basic type definitions.
*
********************************************************************************
*/

#ifndef BASETYPE_H_INCLUDED
#define BASETYPE_H_INCLUDED

#include <stdint.h>

#define VOLATILE volatile

#ifdef __linux__ /* typedefs for Linux */

#include <stddef.h> /* for size_t, NULL, etc. */

typedef unsigned char u8;
typedef signed char i8;
typedef unsigned short u16;
typedef signed short i16;
typedef unsigned int u32;
typedef signed int i32;
typedef unsigned long long u64;
typedef int64_t i64;

typedef size_t ptr_t;

#ifdef ADDRESS_WIDTH_64
#define PRT_PTR "lx"
#else
#define PRT_PTR "x"
#endif

#ifndef __cplusplus
typedef enum {
false = 0,
true = 1
} bool;
#endif

#else /* __symbian__ or __win__ or whatever, customize it to suit well */

#include <stdbool.h>

#ifndef _SIZE_T_DEFINED
typedef uint32_t size_t;

#define _SIZE_T_DEFINED
#endif

#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else /* */
#define NULL ((void *)0)
#endif /* */
#endif

typedef uint32_t ptr_t;

typedef uint8_t u8;
typedef int8_t i8;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint64_t u64;
typedef int64_t i64;


#ifndef __cplusplus
#ifndef __bool_true_false_are_defined
typedef enum {
false = 0,
true = 1
} bool;
#endif
#endif

#endif

#if defined(VC1SWDEC_16BIT) || defined(MP4ENC_ARM11)
typedef uint16_t u16x;
typedef int16_t i16x;
#else
typedef uint16_t u16x;
typedef int16_t i16x;
#endif

#endif /* BASETYPE_H_INCLUDED */
129 changes: 129 additions & 0 deletions lib/vc8000nanoe/inc/encInputLineBuffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*
* Copyright (c) 2015-2022, Verisilicon Inc. - All Rights Reserved
* Copyright (c) 2011-2014, Google Inc. - All Rights Reserved
*
*
********************************************************************************
*
* This software is distributed under the terms of
* BSD-3-Clause. The following provisions apply :
*
********************************************************************************
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
********************************************************************************
*
* Abstract : For test/fpga_verification/example purpose. operations on Input
* line buffer.
*
********************************************************************************
*/

#ifndef ENC_INPUTLINEBUFREGISTER_H
#define ENC_INPUTLINEBUFREGISTER_H

#include "basetype.h"

typedef u32 (*getHEncRdMbLines)(const void *inst);
typedef i32 (*setHEncWrMbLines)(const void *inst, u32 lines);

typedef struct
{
u8 *buf;
ptr_t busAddress;
} lineBufMem;

/* struct for input mb line buffer */
typedef struct
{
/* src picture related pointers */
u8 *src; /* source buffer */
u8 *lumSrc;
u8 *cbSrc;
u8 *crSrc;

/* line buffer related pointers */
u8 *buf; /* line buffer virtual address */
u32 *reg; /* virtual address of registers in line buffer, only for fpga verification purpose */
ptr_t busAddress; /* line buffer bus address */
lineBufMem lumBuf; /*luma address in line buffer */
lineBufMem cbBuf; /*cb address in line buffer */
lineBufMem crBuf; /*cr address in line buffer */

/* encoding parameters */
u32 inputFormat; /* format of input video */
u32 pixOnRow; /* pixels in one line */
u32 encWidth;
u32 encHeight;
u32 srcHeight;
u32 srcVerOffset;

/* parameters of line buffer mode */
i32 wrCnt;
u32 depth; /* number of MB_row lines in the input line buffer */
u32 loopBackEn;
u32 hwHandShake;

/*functions */
getHEncRdMbLines getMbLines; /* get read mb lines from encoder register */
setHEncWrMbLines setMbLines; /* set written mb lines to encoder register */

/* encoder instance */
void *inst;
}inputLineBufferCfg;

#ifdef PCIE_FPGA_VERI_LINEBUF
#include "encswhwregisters.h"
/* HW Register field names */
typedef enum {
InputlineBufWrCntr,
InputlineBufDepth,
InputlineBufHwHandshake,
InputlineBufPicHeight,
InputlineBufRdCntr,
} lineBufRegName;

#define LINE_BUF_SWREG_AMOUNT 4 /*4x 32-bit*/

static const regField_s lineBufRegisterDesc[] = {
/* HW ID register, read-only */
{InputlineBufWrCntr , 0x000, 0x000001ff, 0, 0, RW, "slice_wr_cntr. +slice_depth when one slice is filled into slice_fifo"},
{InputlineBufDepth , 0x000, 0x0003fe00, 9, 0, RW, "slice_depth. unit is MB line"},
{InputlineBufHwHandshake , 0x000, 0x00040000, 18, 0, RW, "slice_hw_mode_en. active high. enable bit of slice_fifo hardware mode. should be disabled before the start of next frame."},
{InputlineBufPicHeight , 0x000, 0x0ff80000, 19, 0, RW, "pic_height. same value of swreg14[18:10] in H1."},
{InputlineBufRdCntr , 0x008, 0x000001ff, 0, 0, RO, "slice_rd_cntr. read only"},
};
#endif

void HEncInitInputLineBufSrcPtr (inputLineBufferCfg *lineBufCfg);
void HEncInitInputLineBufPtr (inputLineBufferCfg *lineBufCfg);
i32 HEncInitInputLineBuffer(inputLineBufferCfg *lineBufCfg, const void *ewl);
void HEncStartInputLineBuffer(inputLineBufferCfg * lineBufCfg);
void HEncInputMBLineBufDone (void *pAppData);

#endif

Loading