// Initialisation phase ///////////////////////////////////////////////////////
// Create an instance of the DIL
DIL_ContextSettings context_settings = { 0 };
char * json_settings = "{\
\"hardware_buffers\": false,\
\"use_u8_surface\": false,\
\"force_passthrough\": false\
DIL_Decoder decoder = nullptr;
if (DIL_Create(json_settings, &context_settings , &decoder) != DIL_RC_Success)
fprintf(stderr, "Unable to create DIL instance\n");
// Destruction phase //////////////////////////////////////////////////////////
// Handling input buffers /////////////////////////////////////////////////////
// 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);
// 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;
// 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;
// Decode info reports if LCEVC is available and has been applied