Since the thread NvJPEGEncoder::encodeFromBuffer trigger segmentation fault is locked. I open this new thread.
I’ve tried the following code
NvJPEGEncoder* jpegencoder = NvJPEGEncoder::createJPEGEncoder("jpegenc");
NvBuffer bufferEnc(V4L2_PIX_FMT_YUV420M, roundedWidth, roundedHeight, 0);
bufferEnc.allocateMemory();
unsigned char* p_YEnc = bufferEnc.planes[0].data;
unsigned char* p_UEnc = bufferEnc.planes[1].data;
unsigned char* p_VEnc = bufferEnc.planes[2].data;
err = cudaMemcpy2D(p_YEnc, roundedWidth, srcYPtr, 1920, roundedWidth, roundedHeight, cudaMemcpyHostToHost);
err = cudaMemcpy2D(p_UEnc, roundedWidth/2, srcUPtr, 1920/2, roundedWidth/2, roundedHeight/2, cudaMemcpyHostToHost);
err = cudaMemcpy2D(p_VEnc, roundedWidth/2, srcVPtr, 1920/2, roundedWidth/2, roundedHeight/2, cudaMemcpyHostToHost);
unsigned char* outputBuf2 = outputBuf;
unsigned long outputBufSize = sizeof(outputBuf);
int ret = jpegencoder->encodeFromFd(bufferEnc.planes[0].fd, JCS_YCbCr, &outputBuf2, outputBufSize, 75);
and I got error:
[ERROR] (NvJpegEncoder.cpp:77) <jpegenc> Not encoding because fd = -1
But there seems no example showing me how to do a similar thing. Is there another example showing how to create a fd from some data in CPU?