I want to convert output format of DecodeFrameNoDelay
function is yuvData
and bufferInfo
to OpenCV matrix that I can use imshow
function to display frame on window
Link git to DecodeFrameNoDelay detail: https://github.com/cisco/openh264/wiki/ISVCDecoder#decodeframenodelay
Below is my code use to decode frame with Openh264
ISVCDecoder *decoder;
SBufferInfo bufferInfo;
SDecodingParam decodingParam;
uint8_t** yuvData;
void init(int width, int height) {
WelsCreateDecoder(&decoder);
decodingParam = {0};
decodingParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_AVC;
decoder->Initialize(&decodingParam);
bufferInfo = {0};
bufferInfo.iBufferStatus = 1;
yuvData = new uint8_t*[3];
yuvData[0] = new uint8_t[width * height];
yuvData[1] = new uint8_t[width * height / 4];
yuvData[2] = new uint8_t[width * height / 4];
}
bool decode(const unsigned char* rawEncodedData, int rawEncodedDataLength, uint8_t** yuvData, char *name) {
int err = decoder->DecodeFrameNoDelay(rawEncodedData, rawEncodedDataLength, yuvData, &bufferInfo);
if (err != 0) {
std::cout << "H264 decoding failed. Error code: " << err << "." << std::endl;
parseErrorCode(err);
return false;
}
printf("H264 decoding success, err: %d, name: %s, status: %d\n", err, name, bufferInfo.iBufferStatus);
return true;
}
Any help is appreciated.
Thanks and best regards.