V-NOVA
Search…
Encoder Integration Layer (EIL)

Introduction

This article serves as a reference to the V-Nova LCEVC Encoder Integration Layer and should be read in conjunction with the Encoder Integration Layer (EIL) header, where each function is well documented as to its behaviour, arguments and return conditions. This document outlines the design, flow of functionality, and the properties exposed through the Integration Layers configuration system.
The following figure illustrates the EIL software stack.
V-Nova LCEVC Encoding Software Stack
The EIL combines V-Nova LCEVC with the base codec, and wrappers for supported base codecs. V-Nova provides example source code below to show how to use the Integration Layer.

Functionality

The EIL provides a simple yet powerful API, and is similar in usage to working with other video encoding libraries.
The steps for encoding streams using the V-Nova LCEVC EIL are as follows:
  1. 1.
    Initialise the Integration Layer
  2. 2.
    While there are frames to encode:
    a. Obtain an input frame and pass ownership to the encoder.
    b. Wait for the encoder to complete, then fetch the decoded frame.
    c. Release ownership of the output frame back to the encoder.
  3. 3.
    Shut down the Integration Layer

EIL Integration Process Overview

The integration of the EIL can be summarised in several steps:
  1. 1.
    Creation of the EIL
  2. 2.
    Initialisation of the EIL
  3. 3.
    Passing video frames to the EIL
  4. 4.
    Fetching the encoded bitstream from the EIL
  5. 5.
    Flushing the EIL
  6. 6.
    Destruction of the EIL
The above steps, as well as the various options available to integrations, are described below.

1. Creation of the EIL

An instance of the EIL is created using EIL_Open. An EILOpenSettings object is required, which at minimum, must specify the name of a base encoder. This instance of the EIL should be passed to all other functions. The EILOpenSettings can be initialised to a sensible default state using EIL_OpenSettingsDefault.
The EIL issues internally generated logging messages via a callback. The callback is registered on the EILOpenSettings struct. You must provide a callback function pointer before calling Open to receive messages.
1
void Log(void* userdata, int32_t level, const char* msg)
2
{
3
fprintf(level == EIL_LL_Error ? stderr : stdout, msg);
4
}
5
6
EILContext OpenEIL()
7
{
8
EILOpenSettings settings;
9
EILReturnCode rc = EIL_OpenSettingsDefault(&settings);
10
11
if (rc != EIL_RC_Success)
12
{
13
fprintf(stderr, "Unable to initialise default open settings: %s\n",
14
EIL_GetErrorString(rc));
15
return NULL;
16
}
17
18
settings.base_encoder = "x264";
19
settings.log_callback = Log;
20
EILContext context = NULL;
21
22
if ((rc = EIL_Open(&settings, &context)) != EIL_RC_Success)
23
{
24
fprintf(stderr, "Unable to open the EIL: %s\n", EIL_GetErrorString(ret));
25
return NULL;
26
}
27
28
return context;
29
}
Copied!

2. Initialisation of the EIL

The EIL is initialised using EIL_Initialise. An EILInitSettings object is required, in which the encoding properties, such as resolution, framerate and bitrate, are specified. properties_json should be set to a json object string with extra optional encoder options.
Upon successful initialisation, the user can then proceed to encoding YUV input.
1
// context should have been previously created with EIL_Open
2
bool InitialiseEIL(EILContext context)
3
{
4
EILInitSettings settings;
5
EILReturnCode rc = EIL_InitSettingsDefault(&settings);
6
7
settings.width = 1920;
8
settings.height = 1080;
9
settings.fps_num = 25;
10
settings.fps_denom = 1;
11
settings.bitrate = 3000; // NB: This is in kbps
12
13
// The properties are usually generated from user input
14
settings.properties_json = "{ \"encoding_transform_type\": \"dds\" }";
15
16
if ((rc = EIL_Initialise(context, &settings)) != EIL_RC_Success)
17
{
18
fprintf(stderr, "Unable to intiailise the EIL: %s\n",
19
EIL_GetErrorString(rc));
20
return false;
21
}
22
23
return true;
24
}
Copied!

3. Passing video frames to the EIL

If the previous steps succeeded, then the EIL is now ready to receive frames.
If the EIL has been configured to not use external input, then a preallocated frame can be fetched from the EIL using EIL_GetPicture; otherwise, an EILPicture object should be created at the integration layer and passed to EIL_Encode.
To encode YUV frames, perform the following steps:
  1. 1.
    Call EIL_GetPicture to obtain an EILPicture object for the type of frame to be encoded. The caller now temporarily owns the picture object.
  2. 2.
    Load YUV data into the pre-allocated memory of the plane member of the picture object.
  3. 3.
    Call EIL_Encode using the EILPicture object to begin encoding the picture. The encoder retakes ownership of the EILPicture object, and it is no longer valid to manipulate it. This is a blocking call for the duration of the encoding of a single frame.
1
bool Encode(EILContext context, int64_t pts)
2
{
3
EILPicture* picture = NULL;
4
EILReturnCode rc = EIL_GetPicture(context, EIL_FrameType_Progressive, &picture);
5
6
if (rc != EIL_RC_Success)
7
{
8
fprintf(stderr, "Unable to obtain picture from the EIL: %s\n",
9
EIL_GetErrorString(rc));
10
return false;
11
}
12
13
// Write the frame data to picture->plane ensuring that the picture->stride
14
// for each plane is obeyed.
15
16
picture->pts = pts;
17
18
if ((rc = EIL_Encode(context, picture)) != EIL_RC_Success)
19
{
20
fprintf(stderr, "Unable to encode picture: %s\n", EIL_GetErrorString(rc));
21
return false;
22
}
23
24
return true;
25
}
26
Copied!
It is invalid behaviour to hold onto the EILOutput object across multiple frames. The caller must copy and buffer the data if that is the required behaviour.

4. Fetching the encoded bitstream from the EIL

After receiving enough frames, the EIL has available encoded data ready for the integration. The encoded data is fetched using the EIL_GetOutput function.
  • If there is any output data available when EIL_GetOutput is invoked, then EIL_GetOutput returns EIL_RC_Success.
  • If there is no data available and no errors occurred, then EIL_GetOutput returns EIL_RC_Finished.
To fetch the encoded bitstream from the EIL, perform the following steps:
  1. 1.
    The loop call EIL_GetOutput returns the following, depending upon the presence of output data: - If there is output data, then EILGetOutput returns EIL_RC_Success and populates EILOutput* with a valid pointer. The caller now owns the output data object. - If there is no more output data, then the EIL_GetOutput returns EIL_RC_Finished, unless an error is generated. This step is important, as the EIL may generate more than one output per single input, for example, when generating an interlaced encoding.
  2. 2.
    Utilise the output data, either by writing it directly out to file or copying it if it must be buffered for output in a muxing system.
  3. 3.
    Call EIL_ReleaseOutput to release the output object back to the ownership of the encoder. It is then no longer valid to read from this object.
Once the integration has finished with the output data, it should return it to the EIL using EIL_ReleaseOutput. It is perfectly fine to call this method from a separate thread other than EIL_Encode.
1
bool HandleOutput(EILContext context)
2
{
3
EILOutput* output = NULL;
4
EILReturnCode rc = EIL_GetOutput(context, &output);
5
6
if (rc != EIL_RC_Success)
7
{
8
if (rc != EIL_RC_Finished)
9
{
10
fprintf(stderr, "Unable to get output from the EIL: %s\n",
11
EIL_GetErrorString(rc));
12
return false;
13
}
14
15
return true;
16
}
17
18
// pass the bitstream to a muxer
19
mux(output->pts, output->dts, output->data, output->data_length);
20
21
if ((rc = EIL_ReleaseOutput(context, output)) != EIL_RC_Success)
22
{
23
fprintf(stderr, "Unable to release output back to the EIL: %s\n",
24
EIL_GetErrorString(rc));
25
return false;
26
}
27
28
return true;
29
}
Copied!

5. Flushing the EIL

To signal to the EIL that no more input data is available, simply pass NULL to EIL_Encode. The EIL then finishes processing any queued video frames. This should only ever be performed at the end of the stream.
To complete encoding, perform the following steps:
  1. 1.
    Call EIL_Encode once using a null pointer for the picture object argument, to flush the entire pipeline. This is a blocking call whilst the remaining pictures are encoded. Subsequent calls will have no effect.
  2. 2.
    Repeat step 4 from the encoding process IL_RC_Finished is returned.

6. Destruction of the EIL and Shutdown

Once encoding has finished, then the EIL can be destroyed. Call EIL_Close to safely shut down and release the encoding context.
1
void CloseEIL(EILContext* context)
2
{
3
EIL_Close(*context);
4
*context = NULL;
5
}
Copied!

Features

External Input

The EIL can be configured to accept externally allocated input frames. To do this, the integration should set external_input in EILInitSettings to true. When configured in this mode, the EIL will not allocate any pictures itself, and so EIL_GetPicture will always fail.
In external input mode, the integration must create the EILPicture object itself. The object can be default initialised using EIL_InitPictureDefault. The integration then must set the plane pointers to memory it has allocated and stride to the number of bytes per line. The other fields are then used in the same manner as when external input is disabled.
The planes must be valid from the point that the picture is passed to EIL_Encode, until the associated output is produced.
The EIL can also accept Android hardware buffers in this mode when the EIL is configured for GPU mode. To do this the picture's memory_type is set to EIL_MT_AHardwareBuffer and the plane pointers are set to AHardwareBuffer.
1
bool InitialiseExteranlInput(EILContext context)
2
{
3
EILInitSettings settings;
4
EILReturnCode rc = EIL_InitSettingsDefault(&settings);
5
6
settings.width = 1920;
7
settings.height = 1080;
8
settings.fps_num = 25;
9
settings.fps_denom = 1;
10
settings.bitrate = 3000; // NB: This is in kbps
11
settings.external_input = 1;
12
13
// The properties are usually generated from user input
14
settings.properties_json = "{ \"encoding_transform_type\": \"dds\" }";
15
16
if ((rc = EIL_Initialise(context, &settings)) != EIL_RC_Success)
17
{
18
fprintf(stderr, "Unable to intiailise the EIL: %s\n",
19
EIL_GetErrorString(rc));
20
return false;
21
}
22
23
return true;
24
}
25
26
bool EncodeExternalInput(EILContext context, int64_t pts)
27
{
28
EILPicture* picture = (EILPicture*)malloc(sizeof(EILPicture));
29
30
if (EIL_InitPictureDefault(picture) != EIL_RC_Success)
31
{
32
fprintf(stderr, "Unable to initialise picture object\n");
33
return false;
34
}
35
36
// For the example the planes are allocated inline. These could just as
37
// easily be set to pointers that already contain the frame data to
38
// avoid copying the data.
39
// Assuming 1080p YUV420p
40
picture->pts = pts;
41
picture->num_planes = 3;
42
picture->plane[0] = malloc(1920 * 1080);
43
picture->stride[0] = 1080;
44
picture->plane[1] = malloc(960 * 540);
45
picture->stride[1] = 540;
46
picture->plane[2] = malloc(960 * 540);
47
picture->stride[2] = 540;
48
picture->user_data = picture;
49
50
// populate the allocated planes with frame data
51
52
EILReturnCode rc = EIL_Encode(context, picture);
53
54
if (rc != EIL_RC_Success)
55
{
56
for (int i = 0; i < picture->num_planes; ++i)
57
free(picture->plane[i]);
58
59
fprintf(stderr, "Unable to encode frame: %s\n", EIL_GetErrorString(rc));
60
return false;
61
}
62
63
return true;
64
}
65
66
bool HandleOutput(EILContext context)
67
{
68
EILOutput* output = NULL;
69
EILReturnCode rc = EIL_GetOutput(context, &output);
70
71
if (rc != EIL_RC_Success)
72
{
73
if (rc != EIL_RC_Finished)
74
{
75
fprintf(stderr, "Unable to get output from the EIL: %s\n",
76
EIL_GetErrorString(rc));
77
return false;
78
}
79
80
return true;
81
}
82
83
// pass the bitstream to a muxer
84
mux(output->pts, output->dts, output->data, output->data_length);
85
86
EILPicture* picture = (EILPicture*)output->user_data;
87
88
for (int i = 0; i < picture->num_planes; ++i)
89
free(picture->plane[i]);
90
91
if ((rc = EIL_ReleaseOutput(context, output)) != EIL_RC_Success)
92
{
93
fprintf(stderr, "Unable to release output back to the EIL: %s\n",
94
EIL_GetErrorString(rc));
95
return false;
96
}
97
98
return true;
99
}
Copied!

Dynamic Reconfiguration

The EIL is able to reconfigure the target bitrate and framerate, if the base encoder also supports dynamic reconfiguration. This is done by passing EILReconfigureSettings, with the new values, to the EIL_Reconfigure function.
1
bool Reconfigure(EILContext context)
2
{
3
EILReconfigureSettings settings;
4
5
if (EIL_ReconfigureSettingsDefault(&settings) != EIL_RC_Success)
6
{
7
fprintf(stderr, "Unable to default initialise reconfigure settings");
8
return false;
9
}
10
11
settings.flags = EIL_RF_Bitrate | EIL_RF_Framerate;
12
settings.bitrate = 5000;
13
settings.fps_num = 30;
14
settings.fps_denom = 1;
15
16
EILReturnCode rc = EIL_Reconfigure(context, &settings);
17
18
if (rc != EIL_RC_Success)
19
{
20
fprintf(stderr, "Unable to reconfigure EIL: %s\n",
21
EIL_GetErrorString(rc));
22
return false;
23
}
24
25
return true;
26
}
Copied!

Error Handling

Almost all of the APIs available from the EIL return EILReturnCode. The documentation for each function Error Handling outlines the potential return conditions. Every effort has been made to ensure that invalid usage of the IL is caught and presented with a meaningful return code. Additionally, a log error or warning will typically be issued via the logging mechanism.

Base Encoder Plugin

Base layer encoding is implemented via a plugin system. Base encoder plugins, along with their corresponding wrappers, are dynamically loaded at runtime, based upon the name of the Base encoder specified in the EILOpenSettings structure.
The name of the base encoder that the EIL uses for base encoding should not contain the preceding lcevc_eilp_ (liblcevc_eilp_ on Linux) or the platform's dynamic library extension. For example, if a plugin is called liblcevc_eilp_x264.so or lcevc_eilp_x264.dll, then the base_encoder string should be x264.
The EIL utilises several search paths to locate plugins. This is to assist with different program usage behaviours and EIL integration techniques. The order of search is as follows:
  1. 1.
    The location of the application process.
  2. 2.
    The current working directory.
  3. 3.
    System-defined PATH environment variable.
An API is provided for the EIL to interact with plugins. This allows a user to optionally implement their own base encoder through the plugin system without the need to be embedded within the EIL, and provides the benefits of modularity. Note: This requires the base plugin API and further documentation on how to develop your own base encoder plugin.

Encoding Configuration Properties

The EIL provides a very powerful configuration system. All configuration properties, except for the basic frame information, are set via a JSON configuration string in the EILInitSettings structure.
The configuration system is supported by a comprehensive built-in system of optimised parameter defaults. The EIL employs ideal settings for both the LCEVC encoder and base encoder, based upon key parameters passed to it by the application, e.g., resolution, bitrate, tune.
Properties can be anonymously queried by the EIL_QueryPropertyGroups API, and, if the user knows the name of properties, by the EIL_QueryProperty API.
Properties specified within the JSON string override any setting provided by the database. Therefore, it is important that an application takes care to specify only properties within the JSON string that the user has explicitly set. For example, in a command-line program, only the options specified by the user in the command line should be included in the JSON string, or, from a GUI, only the options that the user has manually specified a choice for should be included in the JSON string.
The JSON string is processed utilising strong typing correlating to the target property type. If the types are not adhered to, then the EIL will fail to initialise. The user must take care to generate a JSON string that utilises the correct JSON type for each property type. The following table outlines the types and their JSON equivalents:
EILPropertyType
JSON type
EIL_PT_Int32
Number
EIL_PT_Int64
Number
EIL_PT_Uint32
Number
EIL_PT_Uint64
Number
EIL_PT_Float
Number
EIL_PT_Double
Number
EIL_PT_String
String
EIL_PT_Boolean
Boolean, string (‘0’ = false), or number (0 = false)
EIL_PT_Blob
Not used for properties
The JSON string is formatted with a top-level object, and a member per property, as shown in the following example:
1
{
2
"encoding_downsample_luma" : "cubic",
3
"temporal_enabled" : true,
4
5
}
Copied!
For additional convenience, properties have been assigned to logical groupings, and can optionally contain a description about what the property does. This is so a user may dynamically generate a command-line parser, or a UI, for the publicly available properties.

Querying Configuration Properties

All publicly available encoding configuration properties for the base encoder and LCEVC enhancement can be queried through the API using EIL_QueryPropertyGroups. This will return an array of all property groups which each contain an array of all properties in that group. Alternatively, if the name of the parameter is known then it can be directly queried through EIL_QueryProperty.
Each property contains a name, description, the expected type of that property and its current value. Below is an example that queries the API for all properties and prints them.
1
void PrintProperties(EILContext context)
2
{
3
EILPropertyGroups groups;
4
EILReturnCode rc = EIL_QueryPropertyGroups(context, &groups);
5
6
if (rc != EIL_RC_Success)
7
{
8
fprintf(stderr, "Unable to query property groups: %s\n", EIL_GetErrorString(rc));
9
return;
10
}
11
12
for (uint32_t g = 0; g < groups.group_count; ++g)
13
{
14
EILPropertyGroup* group = &groups.group[g];
15
16
printf("%s:\n", group->name);
17
18
for (uint32_t p = 0; p < group->property_count; ++p)
19
{
20
EILProperty* property = &group->properties[p];
21
22
printf("\t%s (", property->name);
23
24
switch (property->type)
25
{
26
case EIL_PT_Int16: printf("int16"); break;
27
case EIL_PT_Int32: printf("int32"); break;
28
case EIL_PT_Int64: printf("int64"); break;
29
case EIL_PT_Uint16: printf("uint16"); break;
30
case EIL_PT_Uint32: printf("uint32"); break;
31
case EIL_PT_Uint64: printf("uint64"); break;
32
case EIL_PT_Float: printf("float"); break;
33
case EIL_PT_Double: printf("double"); break;
34
case EIL_PT_String: printf("string"); break;
35
case EIL_PT_Boolean: printf("boolean"); break;
36
case EIL_PT_Blob: printf("blob"); break;
37
}
38
39
printf("): %s\n", property->description);
40
}
41
}
42
}
Copied!

Metadata

Metadata works much in the same way as properties, except that they are queried only from the system, and they cannot be set externally. They can be treated as read-only properties.
Metadata can only be queried by name using the EIL_QueryMetadata API.
Metadata additionally implements an extension to properties allowing access to a contiguous block of memory (EIL_PT_Blob). This system is incorporated with the Base encoder plugin, such that a Base encoder can output some data to the integrator of the IL, with the IL being ignorant to its usage.
This system is used to allow the EIL to report to the user some internal values, or data that are either not interpreted as properties, or that cannot be expressed as properties.
For example, the ffmpeg sample integration utilises this feature to obtain the h.264 global headers from the libx264 Base encoder plugin to be used for HLS.

Metadata Values

Metadata Values Overview

This section describes the metadata values available from the EIL. It is broken down into sections for each discrete component of the EIL. The following tables indicate the name of the metadata, its associated property type, and a description of what it is and how it is used.

Integration Layer

Metadata
Type
Description
base_type
EIL_PT_String
Describes the underlying technology of the base encoder plugin utilised. For example, the libx264 plugin will output h264 in this metadata.
base_width
EIL_PT_Uint32
Width of the base encoded video.
base_height
EIL_PT_Uint32
Height of the base encoded video.

x264 Integration Layer Plugin

Metadata
Type
Description
h264_header_data
EIL_PT_Blob
This is available when the ‘global-header’ x264 property is set to 1. This is a contiguous block of memory containing the H.264 headers (PPS, SPS, etc.), and can be used when the output container is segmented, so that the headers can be injected at the start of each segment.

API (version 3.2.2)

EIL_GetErrorString

1
VN_EIL_PublicAPI const char* EIL_GetErrorString(EILReturnCode error);
Copied!
Utility method for getting a string representation of an EIL return code in English.

EIL_OpenSettingsDefault and EIL_Open

EIL_OpenSettingsDefault

1
VN_EIL_PublicAPI EILReturnCode EIL_OpenSettingsDefault(EILOpenSettings* settings);
Copied!
Initialises the members of an EILOpenSettings object to sensible default state. Some fields of the settings must still be populated by the integration before the settings can be used by the EIL.

EIL_Open

1
#define VN_EIL_OpenFnName VN_EIL_PP_Concat(EIL_Open_, VN_EIL_API_Version)
2
3
VN_EIL_PublicAPI EILReturnCode VN_EIL_OpenFnName(EILOpenSettings* settings, EILContext* output);
4
5
#define EIL_Open VN_EIL_OpenFnName
Copied!
This is the entry point for creating an instance of the EIL. The open function will have the version of the API appended at the end of the function name to ensure that a newer or older version of the EIL that contains breaking changes cannot be mistakenly used. As such, the EIL_Open define is provided to aid in calling the correct open function.
If the EIL fails to open, then it is typically due to not being able to find and open the requested base encoder. A detailed message as to why the encoder failed to open should be sent to the log callback, if it is provided.

EILContext

1
typedef struct EILContextImpl* EILContext;
Copied!
The EILContext is an opaque handle to the EIL's encoder instance. An EILContext is created when the EIL is opened using EIL_Open, and the same instance should be passed to all other functions. It is destroyed when EIL_Close is called.

EILOpenSettings

EILOpenSettings Overview
1
typedef struct EILOpenSettings
2
{
3
const char* base_encoder;
4
void* base_encoder_userdata;
5
void (*log_callback)(void* userdata, int32_t level, const char* msg);
6
void* log_userdata;
7
const char* log_filepath;
8
void* reserved;
9
void* reserved2;
10
} EILOpenSettings;
Copied!
EILOpenSettings contains the information required to open the EIL. It can be default initialised using EIL_OpenSettingsDefault.
base_encoder
1
const char* base_encoder;
Copied!
[ Required ]
The name of the base encoder that the EIL uses for base encoding should not contain the preceding lcevc_eilp_ (liblcevc_eilp_ on Linux) or the platform's dynamic library extension. For example, if a plugin is called liblcevc_eilp_x264.so or lcevc_eilp_x264.dll, then the base_encoder string should be x264.
There are two special strings for base_encoder: none and inject:
  • none is a pass-through plugin that sets the output recon to the input.
  • inject allows for reserved2 to reference an EILPAPI object that contains function pointers for all of a plugin's methods.
base_encoder_userdata
1
void* base_encoder_userdata;
Copied!
[ Dependent on the plugin | Default: NULL ]
The base_encoder_userdata is a handle that allows some arbitrary data to be passed through to a base plugin.
log_callback
1
void (*log_callback)(void* userdata, int32_t level, const char* msg);
2
void* log_userdata;
Copied!
[ Optional | Default: NULL ]
log_callback can be set to a method that receives all log messages.
userdata is the value set in log_userdata, and level is one of the levels in the enumeration EILLogLevel. If left unset, then all logging is disabled.
All log messages are in the format level | group | message\n, and are limited to 4096 bytes.
log_filepath
1
const char* log_filepath;
Copied!
[ Optional | Default: NULL ]
log_filepath is an optional file path, that when specified , contains all log messages.
reserved, reserved2
1
void* reserved;
2
void* reserved2;
Copied!
Reserved fields that should not be modified, unless specified elsewhere.

EIL_InitSettingsDefault and EIL_Initialise

EIL_InitSettingsDefault

1
VN_EIL_PublicAPI EILReturnCode EIL_InitSettingsDefault(EILInitSettings* settings);
Copied!
Initialises the members of an EILInitSettings object to sensible defaults. Some fields of the structure must still be populated by the integration before the settings can be used by the EIL.

EIL_Initialise

1
VN_EIL_PublicAPI EILReturnCode EIL_Initialise(EILContext context, EILInitSettings* settings);
Copied!
Initialises the EIL so that it is ready to receive pictures for encoding. The context must have previously been created using EIL_Open.

EILInitSettings

EILInitSettingsOverview

1
typedef struct EILInitSettings
2
{
3
EILColourFormat color_format;
4
uint32_t width;
5
uint32_t height;
6
uint32_t fps_num;
7
uint32_t fps_denom;
8
uint32_t bitrate;
9
int32_t gop_length;
10
const char* properties_json;
11
uint8_t external_input;
12
} EILInitSettings;
Copied!
EILInitSettings contains the information required to initialise the EIL. It can be default initialised using EIL_InitSettingsDefault.

color_format

1
EILColourFormat color_format;
Copied!
[ Optional | Default: EIL_YUV_420P ]
The colour format of the input image. If it is not one of the YUV formats, then there will be an extra conversion step that converts the input into the YUV format. The matrix used for the colour conversion can be controlled using the picture_colorspace config option.

width, height

1
uint32_t width;
2
uint32_t height;
Copied!
[ Required ]
The resolution of the input image. Once the EIL is initialised. then these are modified by the EIL to become the resolution of the base video. These modified values should be used by any operation or process that consumes the bitstream. Consult the LCEVC standard for supported resolutions.

fps_num

1
uint32_t fps_num;
2
uint32_t fps_denom;
Copied!
[ Required ]
The framerate's numerator and denominator, e.g., 25/1 for 25fps or 30000/1001 for 29.97fps

bitrate

1
uint32_t bitrate;
Copied!
[ Required ]
The target bitrate, in kilobits/s, at which to encode.

gop_length

1
int32_t gop_length;
Copied!
[ Optional | Default: EIL_GOPLengthAuto ]
The GOP length in frames. There are three values to which gop_length can be set, subject to the base encoder's abilities:
  • EIL_GOPLengthAuto: The EIL determines which GOP length to use.
  • EIL_GOPLengthInfinite: Only the first frame is an I-frame.
  • EIL_GOPLengthIntraOnly: Every frame is an I-frame.

properties_json

1
const char* properties_json;
Copied!
[ Required ]
A string containing json properties for the EIL's user-specified options.

external_input

1
uint8_t external_input;
Copied!
[ Optional | Default: 0 ]
Whether or not the input image's planes should be allocated by the integration or the EIL.
  • When set to 0, the EIL allocates and manages the lifetimes of an image's planes.
  • When set to 1, the planes are expected to be allocated and managed external to the EIL.

EIL_GetPicture

EIL_GetPicture Overview

1
VN_EIL_PublicAPI EILReturnCode EIL_GetPicture(EILContext context, EILFrameType frameType, EILPicture** picture);
Copied!
When the EIL is configured to operate in internal input mode (see external_input under EIL_InitSettings), this method is used to obtain a picture object with preallocated planes. The planes can then be populated with frame data and passed to EIL_Encode. A picture obtained using this method is owned by the integration until that picture is passed back through EIL_Encode.
The EIL internally creates a pool of pictures from which this method extracts. The most common reason for the failure of this method, is that the pool of pictures is empty. This can occur if this function is called too frequently without returning the pictures through EIL_Encode. The size of the pool depends on the base encoder's frame delay plus the EIL's frame delay, where frame delay is the number of frames that must be provided to the encoder before any output is produced.

EILPicture

EILPicture Overview
1
typedef struct EILPicture
2
{
3
EILMemoryType memory_type;
4
uint32_t num_planes;
5
void* plane[EIL_MaxPlanes];
6
uint32_t stride[EIL_MaxPlanes];
7
EILBaseType base_type;
8
EILFrameType frame_type;
9
EILFieldType field_type;
10
int64_t pts;
11
void* user_data;
12
const void* reserved;
13
} EILPicture;
Copied!
An EILPicture is in the input to the encoder, containing all information needed to encode a single frame of video. If the EIL is configured to operate in external input mode, then it is up to the integration to set the fields of this struct, in which case it can be default initialised using EIL_InitPictureDefault. Otherwise, the EIL will populate the fields of the struct, and the integration should populate the preallocated planes.
memory_type
1
EILMemoryType memory_type;
Copied!
[ Optional if externally allocated | Default EIL_MT_Host ]
memory_type specifies the type of memory stored in the picture's planes. This can currently only be either:
  • EIL_MT_Host is memory that is accessible from the device's CPU, i.e., allocated using malloc or some device memory that has been mapped. If the memory is externally allocated, then the memory must be aligned for 8- or 16-bit access, depending upon the bitdepth.
  • EIL_MT_AHardwareBuffer indicates that the planes are Android hardware buffers
    (AHardwareBuffer). The encoder must be configured to use the GPU for this to be accepted, when used in conjunction with external input.
Other memory types:
  • EIL_MT_TextureGL is currently unsupported as input to the EIL. The EIL may pass this type of
    memory to the base encoder, depending upon the configuration.
  • EIL_MT_Unknown is used only to indicate that the memory type is not yet defined. memory_type should not be set to EIL_MT_Unknown by the point of ingest.
num_planes, plane[EIL_MaxPlanes]
1
uint32_t num_planes;
2
void* plane[EIL_MaxPlanes];
Copied!
[ Required if externally allocated ]
Pointers to the appropriate structures holding the plane data, as defined by the memory_type. These planes can be interleaved in the cases of the RGB formats. As such, num_planes indicates the number of plane pointers rather than the number of channels. In the case of contiguous memory, each pointer should be set to the starting address of each plane, and the number of planes should be set as if the memory is not contiguous.
stride[EIL_MaxPlanes]
1
uint32_t stride[EIL_MaxPlanes];
Copied!
[ Required if externally allocated ]
The stride, in bytes, for each plane defined in plane.
base_type
1
EILBaseType base_type;
Copied!
[ Optional | Default: EIL_BT_Uknown ]
If set to a value other than the default, then when this picture is encoded, the EIL will attempt to force the requested type of picture from the base encoder. Whether or not the requested type of frame is produced, is subject to a base encoder's capabilities.
frame_type, field_type
1
EILFrameType frame_type;
2
EILFieldType field_type;
Copied!
[ Optional if externally allocated | Default: EIL_FrameType_Progressive ]
Whether this frame is progressive, a single field, or interlaced, and if it is a single field, then whether the frame is the top or bottom field.
pts
1
int64_t pts;
Copied!
[ Optional | Defaut: -1 ]
The presentation timestamp of the picture. If left as the default, then it is determined by the EIL.
user_data
1
void* user_data;
Copied!
[ Optional | Default: NULL ]
A handle to some arbitrary data that is set on the EILOutput produced by the picture.
reserved
1
const void* reserved;
Copied!
Internally used field. Do not modify.

EIL_Encode

1
VN_EIL_PublicAPI EILReturnCode EIL_Encode(EILContext context, EILPicture* picture);
Copied!
Passes a picture that is ready for encode to the EIL. A picture can be obtained from the EI, either:
  • Using EIL_GetPicture, if external input is disabled; or,
  • Created and populated by the integration, if external input is enabled.

EIL_GetOutput and EIL_ReleaseOutput

Get_Output

1
VN_EIL_PublicAPI EILReturnCode EIL_GetOutput(EILContext context, EILOutput** output);
Copied!
Gets the next output available from the EIL. The integration has ownership of the EILOutput until it has been passed back through EIL_ReleaseOutput. This can return one of two return codes upon success:
  • EIL_RC_Success: Successfully got the next frame of output.
  • EIL_RC_Finished: No errors occurred but there there is currently no output available.

Release_Output

1
VN_EIL_PublicAPI EILReturnCode EIL_ReleaseOutput(EILContext context, EILOutput* output);
Copied!
Returns an output obtained using EIL_GetOutput back to the encoder.
EILOutput
  • EILOutput Overview
1
typedef struct EILOutput
2
{
3
EILFrameType frame_type;
4
EILFieldType field_type;
5
EILBaseType base_type;
6
int8_t keyframe;
7
int32_t qp;
8
int64_t pts;
9
int64_t dts;
10
int8_t config;
11
const uint8_t* data;
12
uint32_t data_length;
13
const uint8_t* lcevc;
14
uint32_t lcevc_length;
15
void* user_data;
16
const void* reserved;
17
} EILOutput;
Copied!
The EILOutput struct contains all information for an encoded frame of video. These should never have to be created manually, and should be treated as read-only.
  • frame_type, field_type
1
EILFrameType frame_type;
2
EILFieldType field_type;
Copied!
Whether the frame that produced this output is progressive, interlaced or a field. field_type is applicable, only if the type is EIL_FT_Field.
  • base_type, keyframe
1
EILBaseType base_type;
2
int8_t keyframe;
Copied!
The type of frame that the base encoder produced, and whether or not it is flagged as a keyframe. Refer to the appropriate base encoder's standard for their meanings.
  • qp
1
int32_t qp;
Copied!
The Quantisation Parameter (QP) of the frame, as reported by the base encoder.
  • pts
1
int64_t pts;
Copied!
The presentation timestamp of the encoded frame. This is the input frame's pts, if it was specified; otherwise, it is the pts that the base encoder produced.
  • dts
1
int64_t dts;
Copied!
The decode timestamp of the encoded frame, as produced by the base encoder.
  • config
1
int8_t config;
Copied!
Whether the data in this output is the encoder's config. For example, if the base encoder is an H264 encoder and config is 1, then the output contains only the SPS and PPS NAL units. The config output is always presented before any frame data.
  • data, data_length, lcevc, lcevc_length
1
const uint8_t* data;
2
uint32_t data_length;
3
const uint8_t* lcevc;
4
uint32_t lcevc_length;
Copied!
The encoded bitstream for the frame and its length. If the separate_output config option is set, then the LCEVC data is on the lcevc field; otherwise, it is contained in the data field, along with the base bitstream.
  • user_data
1
void* user_data;
Copied!
The user data that was set on the picture that produced this frame.
  • reserved
1
const void* reserved;
Copied!
Internally used field. Do not modify.

EIL_QueryPropertyGroups, EIL_QueryProperty

EIL_QueryPropertyGroups, EIL_QueryProperty Overview

1
VN_EIL_PublicAPI EILReturnCode EIL_QueryPropertyGroups(EILContext context, EILPropertyGroups* output);
2
VN_EIL_PublicAPI EILReturnCode EIL_QueryProperty(EILContext context, const char* name, EILProperty* output);
Copied!
This group of methods is used to query the options available through the EIL. These are usually controlled by the user.
  • EIL_QueryPropertyGroups returns a collection of all properties in their logical groupings.
  • EIL_QueryProperty obtains an individual property by its name.
The properties and their values are passed to the EIL in JSON format on the EILInitSettings structure through the properties_json field.

EILPropertyGroups

1
typedef struct EILPropertyGroups
2
{
3
EILPropertyGroup* group;
4
uint32_t group_count;
5
} EILPropertyGroups;
Copied!
This structure contains an array of all property groups.
1
typedef struct EILPropertyGroup
2
{
3
const char* name;
4
const char* description;
5
EILProperty* properties;
6
uint32_t property_count;
7
} EILPropertyGroup;
Copied!
The property group contains a logical grouping of all properties available through the EIL and base encoders.

EILProperty

EILProperty Overview
1
typedef struct EILProperty
2
{
3
const char* name;
4
const char* description;
5
EILPropertyType type;
6
7
union
8
{
9
int32_t i32;
10
int64_t i64;
11
uint32_t u32;
12
uint64_t u64;
13
float f;
14
double d;
15
const char* str;
16
} value;
17
18
const uint8_t* blob;
19
uint32_t blob_size;
20
} EILProperty;
Copied!
This structure is used to describe config properties or metadata of the EIL and the base encoder.
name, description
1
const char* name;
2
const char* description;
Copied!
A short name and description of the property that was queried.
type
1
EILPropertyType type;
Copied!
The type of value contained in this property. This value should be used to determine which field of the value union is set:
  • EIL_PT_Int32: value.i32
  • EIL_PT_Int64: value.i64
  • EIL_PT_Uint32: value.u32
  • EIL_PT_Uint64: value.u64
  • EIL_PT_Float: value.f
  • EIL_PT_Double: value.d
  • EIL_PT_String: value.str
  • EIL_PT_Boolean: value.i32
blob, blob_size
1
const uint8_t* blob;
2
uint32_t blob_size;
Copied!
blob and blob_size are used when the property type is EIL_PT_Blob. This is only ever the case when querying metadata.
Last modified 6mo ago