Example Integration Code

In basic terms, a sample integration code using the DIL can be briefly described, among the various phases, as follows:

// Include DIL header
#include <lcevc_dil.h>
// Initialisation phase ///////////////////////////////////////////////////////
// Create an instance of the DIL
DIL_ContextSettings context_settings = { 0 };
char * json_settings = "{\
 \"gl_decode\": true,\
 \"gl_es\": true,\
 \"gl_major\": 3,\
 \"gl_minor\": 1,\
 \"swap_interval\": 0,\
 \"fullscreen\": false,\
 \"hardware_buffers\": false,\
 \"use_u8_surface\": false,\
 \"force_passthrough\": false\
}";
// Create a DIL instance
DIL_Decoder decoder = nullptr;
if (DIL_Create(json_settings, &context_settings , &decoder) != DIL_RC_Success)
{
    fprintf(stderr, "Unable to create DIL instance\n");
    exit(-1);
}
// Destruction phase //////////////////////////////////////////////////////////
DIL_Destroy(decoder);
decoder = nullptr;
// Handling input buffers /////////////////////////////////////////////////////
//...
DIL_NALFormat nalFormat;
// Set NAL format, from metadata, properties or parsing the input buffers
// ...
if (DIL_AddNALData(decoder, inputCc, presentationTimeStamp, buffer, length, nalFormat) != DIL_RC_Success)
{
    fprintf(stderr, "Unable to pass input buffer for inputCc=%u pts=%PRId64\n", inputCc, presentationTimeStamp);
    exit(-2);
}
// Handling decoded frame from base decoder ///////////////////////////////////
// ...
// Get size of ouput picture if needed
DIL_DecodeInformation decodeInfo;
if (DIL_GetDecodeInformation(decoder, inputCc, presentationTimeStamp, baseWidth, baseHeight, &decodeInfo) != DIL_RC_Success)
{
    fprintf(stderr, "DIL get decode info failed for inputCc=%u pts=%PRId64\n", inputCc, baseImage.pts;
    exit(-3);
}
// Using decode info
// ...
DIL_Image baseImage;
// Fill the base "Image" struct with the data properties of the base frame
// ...
DIL_RenderInformation renderInfo;
// Fill rotation and pixel aspect ratio
// ...
if (DIL_DecodeAndRender(decoder, inputCc, presentationTimeStamp, baseImage, &renderInfo, &decodeInfo) != DIL_RC_Success)
{
    fprintf(stderr, "DIL decode failed for pts=%PRId64\n", baseImage.pts;
    exit(-4);
}
// Decode info reports if LCEVC is available and has been applied
// ...

Last updated

Was this helpful?