Skip to content

Commit 542b5ce

Browse files
Updated to version 1.1.1
1 parent a70ebc1 commit 542b5ce

File tree

7 files changed

+188
-21
lines changed

7 files changed

+188
-21
lines changed

LICENSE.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright [2023] [ConstantRobotics Sp. z o.o]
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

README.md

Lines changed: 162 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66

77
# **VCodec interface C++ library**
88

9-
**v1.1.0**
9+
**v1.1.1**
1010

1111
------
1212

13+
14+
1315
# Table of contents
1416

1517
- [Overview](#Overview)
@@ -23,19 +25,27 @@
2325
- [Data structures](#Data-structures)
2426
- [VCodecCommand enum](#VCodecCommand-enum)
2527
- [VCodecParam enum](#VCodecParam-enum)
28+
- [Build and connect to your project](#Build-and-connect-to-your-project)
29+
30+
2631

2732
# Overview
2833

29-
**VCodec** C++ library provides standard interface as well defines data structures and rules for different video codec classes (video encoding and decoding). **VCodec** interface class doesn't do anything, just provides interface. Different video codec classes inherit interface form **VCodec** C++ class. **VCodec.h** file contains VCodecCommand** enum, **VCodecParam** enum and **VCodec** class declaration. **VCodecCommands** enum contains IDs of commands supported by **VCodec** class. **VCodecParam** enum contains IDs of params supported by **VCodec** class. All video codec should include params and commands listed in **VCodec.h** file. **VCodec** class depends on **Frame** class which determines video frame structure. Video codec interface supports only 8 bit depth input pixels.
34+
**VCodec** C++ library provides standard interface as well defines data structures and rules for different video codec classes (video encoding and decoding). **VCodec** interface class doesn't do anything, just provides interface. Different video codec classes inherit interface form **VCodec** C++ class. **VCodec.h** file contains **VCodecCommand** enum, **VCodecParam** enum and **VCodec** class declaration. **VCodecCommands** enum contains IDs of commands supported by **VCodec** class. **VCodecParam** enum contains IDs of params supported by **VCodec** class. All video codec should include params and commands listed in **VCodec.h** file. **VCodec** class depends on **Frame** class which determines video frame structure. Video codec interface supports only 8 bit depth input pixels.
35+
36+
3037

3138
# Versions
3239

3340
**Table 1** - Library versions.
3441

35-
| Version | Release date | What's new |
36-
| ------- | ------------ | ---------------------- |
37-
| 1.0.0 | 14.06.2023 | First version. |
38-
| 1.1.0 | 20.06.2023 | - Added new parameter. |
42+
| Version | Release date | What's new |
43+
| ------- | ------------ | ------------------------------------------------------------ |
44+
| 1.0.0 | 14.06.2023 | First version. |
45+
| 1.1.0 | 20.06.2023 | - Added new parameter. |
46+
| 1.1.1 | 28.06.2023 | - Frame submodule updated.<br />- Documentation updated.<br />- License added.<br />- Repository made public.<br />- Added new parameters. |
47+
48+
3949

4050
# Video codec interface class description
4151

@@ -59,30 +69,26 @@ public:
5969
* @return String of current library version.
6070
*/
6171
static std::string getVersion();
62-
6372
/**
64-
* @brief Get new video frame.
73+
* @brief Encode/decode.
6574
* @param src Source frame (RAW or compressed).
6675
* @param dst Result frame (RAW or compressed).
6776
* @return TRUE if frame was processed or FLASE if not.
6877
*/
6978
virtual bool transcode(Frame& src, Frame& dst) = 0;
70-
7179
/**
7280
* @brief Set video codec param.
7381
* @param id Parameter ID.
7482
* @param value Parameter value to set.
7583
* @return TRUE if parameter was set of FALSE.
7684
*/
7785
virtual bool setParam(VCodecParam id, float value) = 0;
78-
7986
/**
8087
* @brief Get video codec parameter value.
8188
* @param id Parameter ID according to camera specification.
8289
* @return Parameter value or -1.
8390
*/
8491
virtual float getParam(VCodecParam id) = 0;
85-
8692
/**
8793
* @brief Execute command.
8894
* @param id Command ID .
@@ -94,9 +100,11 @@ public:
94100
}
95101
```
96102

103+
104+
97105
## getVersion method
98106

99-
**getVersion()** method return string of current version of **VCodec** class. Particular video codec class can have it's own **getVersion()** method. Method declaration:
107+
**getVersion()** method returns string of current version of **VCodec** class. Particular video codec class can have it's own **getVersion()** method. Method declaration:
100108

101109
```cpp
102110
static std::string getVersion();
@@ -108,6 +116,14 @@ Method can be used without **VCodec** class instance:
108116
std::cout << "VCodec class version: " << VCodec::getVersion() << std::endl;
109117
```
110118

119+
Console output:
120+
121+
```bash
122+
VCodec class version: 1.1.1
123+
```
124+
125+
126+
111127
## transcode method
112128

113129
**transcode(...)** method intended to encode and decode video frame (**Frame** class). Video codec encode/decode video frames frame-by-frame. Method declaration:
@@ -119,10 +135,12 @@ virtual bool transcode(Frame& src, Frame& dst) = 0;
119135
| Parameter | Value |
120136
| --------- | ------------------------------------------------------------ |
121137
| src | Source video frame (see **Frame** class description). To encode video data **src** frame must have RAW pixel data (field **fourcc** of **Frame** class): **RGB24**, **BGR24**, **YUYV**, **UYVY**, **GRAY**, **YUV24**, **NV12**, **NV21**, **YU12** or **YV12**. To decode video data **src** frame must have compressed pixel format (field **fourcc** of **Frame** class): **JPEG**, **H264** or **HEVC**. Particular video codec can support limited RAW input pixel format or only one. When it possible video codec should accept all supported RAW pixel formats and should do pixel format conversion inside if it necessary. Also, particular video codec can support all, few or just one compressed pixel format. When it possible video code should support all compressed pixel format to encode/decode. |
122-
| dst | Result video frame (see **Frame** class description). To decode video data **src** frame must have compressed pixel format (field **fourcc** of **Frame** class): **JPEG**, **H264** or **HEVC**. In case decoding particular video codec can set output pixel format automatically. To encode video frame user must set **fourcc** field of dst frame to necessary output compressed format: **JPEG**, **H264** or **HEVC**. |
138+
| dst | Result video frame (see **Frame** class description). To decode video data **src** frame must have compressed pixel format (field **fourcc** of **Frame** class): **JPEG**, **H264** or **HEVC**. In case decoding particular video codec can set output pixel format automatically. To encode video frame user must set **fourcc** field of dst frame to necessary output compressed format: **JPEG**, **H264** or **HEVC**. The method will write decoded frame data (RAW pixel format) to **data** filed of **src** frame in case decoding or will write compressed data in case encoding. |
123139
124140
**Returns:** TRUE if frame was encoded/decoded or FALSE if not.
125141
142+
143+
126144
## setParam method
127145
128146
**setParam(...)** method designed to set new video codec parameters value. Method declaration:
@@ -138,6 +156,8 @@ virtual bool setParam(VCodecParam id, float value) = 0;
138156

139157
**Returns:** TRUE is the parameter was set or FALSE if not.
140158

159+
160+
141161
## getParam method
142162

143163
**getParam(...)** method designed to obtain video codec parameter value. Method declaration:
@@ -152,6 +172,8 @@ virtual float getParam(VCodecParam id) = 0;
152172
153173
**Returns:** parameter value or -1 of the parameters doesn't exist in particular video codec class.
154174
175+
176+
155177
## executeCommand method
156178
157179
**executeCommand(...)** method designed to execute video codec command. Method declaration:
@@ -166,10 +188,14 @@ virtual bool executeCommand(VCodecCommand id) = 0;
166188

167189
**Returns:** TRUE is the command was executed or FALSE if not.
168190

191+
192+
169193
# Data structures
170194

171195
**VCodec.h** file defines IDs for parameters (**VCodecParam** enum) and IDs for commands (**VCodecCommand** enum).
172196

197+
198+
173199
## VCodecCommand enum
174200

175201
Enum declaration:
@@ -191,6 +217,8 @@ enum class VCodecCommand
191217
| RESET | Reset video codec. |
192218
| MAKE_KEY_FRAME | Command to generate key frame for H264 or H265(HEVC) encoding. |
193219

220+
221+
194222
## VCodecParam enum
195223

196224
Enum declaration:
@@ -212,7 +240,13 @@ enum class VCodecParam
212240
/// [read/write] H264 profile: 0 - Baseline, 1 - Main, 2 - High.
213241
H264_PROFILE,
214242
/// [read/write] Codec type. Depends on implementation.
215-
TYPE
243+
TYPE,
244+
/// Custom 1. Depends on implementation.
245+
CUSTOM_1,
246+
/// Custom 2. Depends on implementation.
247+
CUSTOM_2,
248+
/// Custom 3. Depends on implementation.
249+
CUSTOM_3
216250
};
217251
```
218252

@@ -227,3 +261,117 @@ enum class VCodecParam
227261
| GOP | read / write | GOP size (Period of key frames) for H264 or H265(HEVC) encoding. Value: 1 - each output frame is key frame, 20 - each 20th frame is key frame etc. |
228262
| H264_PROFILE | read / write | H264 profile for H264 encoding: 0 - Baseline, 1 - Main, 2 - High. |
229263
| TYPE | read / write | Codec type. Depends on implementation. It can be type of backend. Some codecs may not support this parameter. |
264+
| CUSTOM_1 | read / write | Custom parameter. Depends on particular implementation. |
265+
| CUSTOM_2 | read / write | Custom parameter. Depends on particular implementation. |
266+
| CUSTOM_3 | read / write | Custom parameter. Depends on particular implementation. |
267+
268+
269+
270+
# Build and connect to your project
271+
272+
Typical commands to build **VCodec** library:
273+
274+
```bash
275+
git clone https://github.com/ConstantRobotics-Ltd/VCodec.git
276+
cd VCodec
277+
git submodule update --init --recursive
278+
mkdir build
279+
cd build
280+
cmake ..
281+
make
282+
```
283+
284+
If you want connect **VCodec** library to your CMake project as source code you can make follow. For example, if your repository has structure:
285+
286+
```bash
287+
CMakeLists.txt
288+
src
289+
CMakeList.txt
290+
yourLib.h
291+
yourLib.cpp
292+
```
293+
294+
You can add repository **VCodec** as submodule by commands:
295+
296+
```bash
297+
cd <your respository folder>
298+
git submodule add https://github.com/ConstantRobotics-Ltd/VCodec.git 3rdparty/VCodec
299+
git submodule update --init --recursive
300+
```
301+
302+
In you repository folder will be created folder **3rdparty/VCodec** which contains files of **VCodec** repository with subrepositories **Frame**. New structure of your repository:
303+
304+
```bash
305+
CMakeLists.txt
306+
src
307+
CMakeList.txt
308+
yourLib.h
309+
yourLib.cpp
310+
3rdparty
311+
VCodec
312+
```
313+
314+
Create CMakeLists.txt file in **3rdparty** folder. CMakeLists.txt should contain:
315+
316+
```cmake
317+
cmake_minimum_required(VERSION 3.13)
318+
319+
################################################################################
320+
## 3RD-PARTY
321+
## dependencies for the project
322+
################################################################################
323+
project(3rdparty LANGUAGES CXX)
324+
325+
################################################################################
326+
## SETTINGS
327+
## basic 3rd-party settings before use
328+
################################################################################
329+
# To inherit the top-level architecture when the project is used as a submodule.
330+
SET(PARENT ${PARENT}_YOUR_PROJECT_3RDPARTY)
331+
# Disable self-overwriting of parameters inside included subdirectories.
332+
SET(${PARENT}_SUBMODULE_CACHE_OVERWRITE OFF CACHE BOOL "" FORCE)
333+
334+
################################################################################
335+
## CONFIGURATION
336+
## 3rd-party submodules configuration
337+
################################################################################
338+
SET(${PARENT}_SUBMODULE_VCODEC ON CACHE BOOL "" FORCE)
339+
if (${PARENT}_SUBMODULE_VCODEC)
340+
SET(${PARENT}_VCODEC ON CACHE BOOL "" FORCE)
341+
endif()
342+
343+
################################################################################
344+
## INCLUDING SUBDIRECTORIES
345+
## Adding subdirectories according to the 3rd-party configuration
346+
################################################################################
347+
if (${PARENT}_SUBMODULE_VCODEC)
348+
add_subdirectory(VCodec)
349+
endif()
350+
```
351+
352+
File **3rdparty/CMakeLists.txt** adds folder **VCodec** to your project. Your repository new structure will be:
353+
354+
```bash
355+
CMakeLists.txt
356+
src
357+
CMakeList.txt
358+
yourLib.h
359+
yourLib.cpp
360+
3rdparty
361+
CMakeLists.txt
362+
VCodec
363+
```
364+
365+
Next you need include folder 3rdparty in main **CMakeLists.txt** file of your repository. Add string at the end of your main **CMakeLists.txt**:
366+
367+
```cmake
368+
add_subdirectory(3rdparty)
369+
```
370+
371+
Next you have to include VCodec library in your **src/CMakeLists.txt** file:
372+
373+
```cmake
374+
target_link_libraries(${PROJECT_NAME} VCodec)
375+
```
376+
377+
Done!

README.pdf

10.2 KB
Binary file not shown.

_static/vcodec_logo.png

-1.16 KB
Loading

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.13)
66
## LIBRARY-PROJECT
77
## name and version
88
###############################################################################
9-
project(VCodec VERSION 1.0.0 LANGUAGES CXX)
9+
project(VCodec VERSION 1.1.1 LANGUAGES CXX)
1010

1111

1212

src/VCodec.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ enum class VCodecParam
2727
/// [read/write] H264 profile: 0 - Baseline, 1 - Main, 2 - High.
2828
H264_PROFILE,
2929
/// [read/write] Codec type. Depends on implementation.
30-
TYPE
30+
TYPE,
31+
/// Custom 1. Depends on implementation.
32+
CUSTOM_1,
33+
/// Custom 2. Depends on implementation.
34+
CUSTOM_2,
35+
/// Custom 3. Depends on implementation.
36+
CUSTOM_3
3137
};
3238

3339

@@ -59,7 +65,7 @@ class VCodec
5965
static std::string getVersion();
6066

6167
/**
62-
* @brief Get new video frame.
68+
* @brief Encode/decode.
6369
* @param src Source frame (RAW or compressed).
6470
* @param dst Result frame (RAW or compressed).
6571
* @return TRUE if frame was processed or FLASE if not.
@@ -75,7 +81,7 @@ class VCodec
7581
virtual bool setParam(VCodecParam id, float value) = 0;
7682

7783
/**
78-
* @brief Get video codec parameter value.
84+
* @brief Get video codec param value.
7985
* @param id Parameter ID according to camera specification.
8086
* @return Parameter value or -1.
8187
*/

src/VCodecVersion.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
#define VCODEC_MAJOR_VERSION 1
4-
#define VCODEC_MINOR_VERSION 0
5-
#define VCODEC_PATCH_VERSION 0
4+
#define VCODEC_MINOR_VERSION 1
5+
#define VCODEC_PATCH_VERSION 1
66

7-
#define VCODEC_VERSION "1.0.0"
7+
#define VCODEC_VERSION "1.1.1"

0 commit comments

Comments
 (0)