Skip to content

Commit 1459cdf

Browse files
committed
lib: add vc8000nanoe h264 video encoding stack
Add VC8000NanoE H264 video encoding stack needed by STM32 VENC peripheral to generate H264 compressed bitstream. Signed-off-by: Hugues Fruchet <[email protected]>
1 parent 6e4716f commit 1459cdf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+30033
-0
lines changed

lib/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ if(CONFIG_HAS_STM32LIB)
99
add_subdirectory_ifdef(CONFIG_BT_STM32_IPM stm32wb)
1010
add_subdirectory_ifdef(CONFIG_BT_STM32WBA stm32wba)
1111
add_subdirectory_ifdef(CONFIG_BT_STM32WB0 stm32wb0)
12+
add_subdirectory_ifdef(CONFIG_VIDEO_STM32_VENC vc8000nanoe)
1213
endif()

lib/vc8000nanoe/CMakeLists.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright (c) 2025 STMicroelectronics
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
zephyr_include_directories(inc)
6+
zephyr_include_directories(source/common)
7+
zephyr_include_directories(source/h264)
8+
9+
zephyr_library_sources(source/common/encasiccontroller.c)
10+
zephyr_library_sources(source/common/encasiccontroller_v2.c)
11+
zephyr_library_sources(source/common/encpreprocess.c)
12+
zephyr_library_sources(source/common/encswhwregisters.c)
13+
14+
zephyr_library_sources(source/h264/H264Cabac.c)
15+
zephyr_library_sources(source/h264/H264CodeFrame.c)
16+
zephyr_library_sources(source/h264/H264Denoise.c)
17+
zephyr_library_sources(source/h264/H264EncApi.c)
18+
zephyr_library_sources(source/h264/H264Init.c)
19+
zephyr_library_sources(source/h264/H264Mad.c)
20+
zephyr_library_sources(source/h264/H264NalUnit.c)
21+
zephyr_library_sources(source/h264/H264PictureBuffer.c)
22+
zephyr_library_sources(source/h264/H264PictureParameterSet.c)
23+
zephyr_library_sources(source/h264/H264PutBits.c)
24+
zephyr_library_sources(source/h264/H264RateControl.c)
25+
zephyr_library_sources(source/h264/H264Sei.c)
26+
zephyr_library_sources(source/h264/H264SequenceParameterSet.c)
27+
zephyr_library_sources(source/h264/H264Slice.c)
28+
zephyr_library_sources(source/h264/h264encapi_ext.c)
29+
30+

lib/vc8000nanoe/LICENSE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Copyright (c) 2023 STMicroelectronics
2+
3+
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).
5.36 MB
Binary file not shown.

lib/vc8000nanoe/inc/basetype.h

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/*
2+
* Copyright (c) 2015-2022, Verisilicon Inc. - All Rights Reserved
3+
* Copyright (c) 2011-2014, Google Inc. - All Rights Reserved
4+
*
5+
*
6+
********************************************************************************
7+
*
8+
* This software is distributed under the terms of
9+
* BSD-3-Clause. The following provisions apply :
10+
*
11+
********************************************************************************
12+
*
13+
* Redistribution and use in source and binary forms, with or without
14+
* modification, are permitted provided that the following conditions are met:
15+
*
16+
* 1. Redistributions of source code must retain the above copyright notice, this
17+
* list of conditions and the following disclaimer.
18+
*
19+
* 2. Redistributions in binary form must reproduce the above copyright notice,
20+
* this list of conditions and the following disclaimer in the documentation
21+
* and/or other materials provided with the distribution.
22+
*
23+
* 3. Neither the name of the copyright holder nor the names of its contributors
24+
* may be used to endorse or promote products derived from this software without
25+
* specific prior written permission.
26+
*
27+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
31+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37+
*
38+
********************************************************************************
39+
*
40+
* Description : Basic type definitions.
41+
*
42+
********************************************************************************
43+
*/
44+
45+
#ifndef BASETYPE_H_INCLUDED
46+
#define BASETYPE_H_INCLUDED
47+
48+
#include <stdint.h>
49+
50+
#define VOLATILE volatile
51+
52+
#ifdef __linux__ /* typedefs for Linux */
53+
54+
#include <stddef.h> /* for size_t, NULL, etc. */
55+
56+
typedef unsigned char u8;
57+
typedef signed char i8;
58+
typedef unsigned short u16;
59+
typedef signed short i16;
60+
typedef unsigned int u32;
61+
typedef signed int i32;
62+
typedef unsigned long long u64;
63+
typedef int64_t i64;
64+
65+
typedef size_t ptr_t;
66+
67+
#ifdef ADDRESS_WIDTH_64
68+
#define PRT_PTR "lx"
69+
#else
70+
#define PRT_PTR "x"
71+
#endif
72+
73+
#ifndef __cplusplus
74+
typedef enum {
75+
false = 0,
76+
true = 1
77+
} bool;
78+
#endif
79+
80+
#else /* __symbian__ or __win__ or whatever, customize it to suit well */
81+
82+
#ifndef _SIZE_T_DEFINED
83+
typedef uint32_t size_t;
84+
85+
#define _SIZE_T_DEFINED
86+
#endif
87+
88+
#ifndef NULL
89+
#ifdef __cplusplus
90+
#define NULL 0
91+
#else /* */
92+
#define NULL ((void *)0)
93+
#endif /* */
94+
#endif
95+
96+
typedef uint32_t ptr_t;
97+
98+
typedef uint8_t u8;
99+
typedef int8_t i8;
100+
typedef uint16_t u16;
101+
typedef int16_t i16;
102+
typedef uint32_t u32;
103+
typedef int32_t i32;
104+
typedef uint64_t u64;
105+
typedef int64_t i64;
106+
107+
108+
#ifndef __cplusplus
109+
typedef enum {
110+
false = 0,
111+
true = 1
112+
} bool;
113+
#endif
114+
115+
#endif
116+
117+
#if defined(VC1SWDEC_16BIT) || defined(MP4ENC_ARM11)
118+
typedef uint16_t u16x;
119+
typedef int16_t i16x;
120+
#else
121+
typedef uint16_t u16x;
122+
typedef int16_t i16x;
123+
#endif
124+
125+
#endif /* BASETYPE_H_INCLUDED */
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*
2+
* Copyright (c) 2015-2022, Verisilicon Inc. - All Rights Reserved
3+
* Copyright (c) 2011-2014, Google Inc. - All Rights Reserved
4+
*
5+
*
6+
********************************************************************************
7+
*
8+
* This software is distributed under the terms of
9+
* BSD-3-Clause. The following provisions apply :
10+
*
11+
********************************************************************************
12+
*
13+
* Redistribution and use in source and binary forms, with or without
14+
* modification, are permitted provided that the following conditions are met:
15+
*
16+
* 1. Redistributions of source code must retain the above copyright notice, this
17+
* list of conditions and the following disclaimer.
18+
*
19+
* 2. Redistributions in binary form must reproduce the above copyright notice,
20+
* this list of conditions and the following disclaimer in the documentation
21+
* and/or other materials provided with the distribution.
22+
*
23+
* 3. Neither the name of the copyright holder nor the names of its contributors
24+
* may be used to endorse or promote products derived from this software without
25+
* specific prior written permission.
26+
*
27+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
31+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37+
*
38+
********************************************************************************
39+
*
40+
* Abstract : For test/fpga_verification/example purpose. operations on Input
41+
* line buffer.
42+
*
43+
********************************************************************************
44+
*/
45+
46+
#ifndef ENC_INPUTLINEBUFREGISTER_H
47+
#define ENC_INPUTLINEBUFREGISTER_H
48+
49+
#include "basetype.h"
50+
51+
typedef u32 (*getHEncRdMbLines)(const void *inst);
52+
typedef i32 (*setHEncWrMbLines)(const void *inst, u32 lines);
53+
54+
typedef struct
55+
{
56+
u8 *buf;
57+
ptr_t busAddress;
58+
} lineBufMem;
59+
60+
/* struct for input mb line buffer */
61+
typedef struct
62+
{
63+
/* src picture related pointers */
64+
u8 *src; /* source buffer */
65+
u8 *lumSrc;
66+
u8 *cbSrc;
67+
u8 *crSrc;
68+
69+
/* line buffer related pointers */
70+
u8 *buf; /* line buffer virtual address */
71+
u32 *reg; /* virtual address of registers in line buffer, only for fpga verification purpose */
72+
ptr_t busAddress; /* line buffer bus address */
73+
lineBufMem lumBuf; /*luma address in line buffer */
74+
lineBufMem cbBuf; /*cb address in line buffer */
75+
lineBufMem crBuf; /*cr address in line buffer */
76+
77+
/* encoding parameters */
78+
u32 inputFormat; /* format of input video */
79+
u32 pixOnRow; /* pixels in one line */
80+
u32 encWidth;
81+
u32 encHeight;
82+
u32 srcHeight;
83+
u32 srcVerOffset;
84+
85+
/* parameters of line buffer mode */
86+
i32 wrCnt;
87+
u32 depth; /* number of MB_row lines in the input line buffer */
88+
u32 loopBackEn;
89+
u32 hwHandShake;
90+
91+
/*functions */
92+
getHEncRdMbLines getMbLines; /* get read mb lines from encoder register */
93+
setHEncWrMbLines setMbLines; /* set written mb lines to encoder register */
94+
95+
/* encoder instance */
96+
void *inst;
97+
}inputLineBufferCfg;
98+
99+
#ifdef PCIE_FPGA_VERI_LINEBUF
100+
#include "encswhwregisters.h"
101+
/* HW Register field names */
102+
typedef enum {
103+
InputlineBufWrCntr,
104+
InputlineBufDepth,
105+
InputlineBufHwHandshake,
106+
InputlineBufPicHeight,
107+
InputlineBufRdCntr,
108+
} lineBufRegName;
109+
110+
#define LINE_BUF_SWREG_AMOUNT 4 /*4x 32-bit*/
111+
112+
static const regField_s lineBufRegisterDesc[] = {
113+
/* HW ID register, read-only */
114+
{InputlineBufWrCntr , 0x000, 0x000001ff, 0, 0, RW, "slice_wr_cntr. +slice_depth when one slice is filled into slice_fifo"},
115+
{InputlineBufDepth , 0x000, 0x0003fe00, 9, 0, RW, "slice_depth. unit is MB line"},
116+
{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."},
117+
{InputlineBufPicHeight , 0x000, 0x0ff80000, 19, 0, RW, "pic_height. same value of swreg14[18:10] in H1."},
118+
{InputlineBufRdCntr , 0x008, 0x000001ff, 0, 0, RO, "slice_rd_cntr. read only"},
119+
};
120+
#endif
121+
122+
void HEncInitInputLineBufSrcPtr (inputLineBufferCfg *lineBufCfg);
123+
void HEncInitInputLineBufPtr (inputLineBufferCfg *lineBufCfg);
124+
i32 HEncInitInputLineBuffer(inputLineBufferCfg *lineBufCfg, const void *ewl);
125+
void HEncStartInputLineBuffer(inputLineBufferCfg * lineBufCfg);
126+
void HEncInputMBLineBufDone (void *pAppData);
127+
128+
#endif
129+

0 commit comments

Comments
 (0)