hi li lin,
Except setting mmap in converter, you can use below APIs on r28.1 to get mapped buffers:
int NvBufferMemMap (int dmabuf_fd, unsigned int plane, NvBufferMemFlags memflag, void **pVirtAddr);
int NvBufferMemSyncForCpu (int dmabuf_fd, unsigned int plane, void **pVirtAddr);
int NvBufferMemUnMap (int dmabuf_fd, unsigned int plane, void **pVirtAddr);
Thank you for your reply, sorry for such a long time to update.
I am using L4T 28.1
Then I changed the mmapi ‘backend’ sample, you can reproduce the problem.
./video_decode …/…/data/Video/sample_outdoor_car_1080p_10fps.h264 H264 --input-nalu
Set governor to performance before enabling profiler
Failed to query video capabilities: Inappropriate ioctl for device
NvMMLiteOpen : Block : BlockType = 261
TVMR: NvMMLiteTVMRDecBlockOpen: 7907: NvMMLiteBlockOpen
NvMMLiteBlockCreate : Block : BlockType = 261
Failed to query video capabilities: Inappropriate ioctl for device
+++ after create conv0
Failed to query video capabilities: Inappropriate ioctl for device
DEBUG @ render_thread_for_test, 775, we created it
DEBUG @ render_thread_for_test, 779
DEBUG @ render_thread_for_test, 781, we destroy it
Failed to query video capabilities: Inappropriate ioctl for device libv4l2_nvvidconv: set mapping failed
DEBUG @ render_thread_for_test, 775, we created it
DEBUG @ render_thread_for_test, 779
*** Error in `./video_decode’: free(): invalid pointer: 0x0000007f780013c0 ***
Aborted
Thank you for your reply. But this error does not matter with mmap, I do not need the dma_buf mmap operation.
The error occurs when creating a converter
I suspect that the converter module is not thread-safe
Please check the code in #5, compared with the original code of the sample, the change is very small, I just created and destroyed one more converter in the sample.
like:
In the second time to create vic0, there will be set mapping failed error
int
main(int argc, char *argv[])
{
NvVideoConverter *vic0;
NvVideoConverter *vic1;
log_level = LOG_LEVEL_DEBUG;
vic1 = NvVideoConverter::createVideoConverter("vic1");
//If it is open, no error occurs
//delete vic1;
while(1)
{
vic0 = NvVideoConverter::createVideoConverter("vic0");
delete vic0;
}
}
For example, a mmapi pipeline for multi-channel encoding or decoding.
Among them, one channel of encoding or decoding resolution changes, we need to delete and create the converter.
This should be a very common operation.
This question should be very similar to the one we had previously solved in
The same is the problems occurred in the conv delete/create.
I do not know if you are care about the process of module destruction in the software.
Please help me solve, useing vic is very important part in my project(for encode/decode/stitch), thank you!
I found a way to avoid this problem.
Do not destroy the converter, only destroy the two planes of the converter, and then re-configure them (similar to the decoding sample).
I’ll share the way to reconfigure one of the converters when creating multiple converters:
Reconfigure plane:
1, conv-> setOutputPlaneFormat
conv-> setCapturePlaneFormat
2, conv-> output_plane.setupPlane
conv-> capture_plane.setupPlane
3, prepared buffers for the two planes, such as get the NvBuffer from the output_plane, or put v4l2_buffer into capture_plane
4, conv-> output_plane.setStreamStatus (true)
conv-> capture_plane.setStreamStatus (true)
5, conv-> output_plane.startDQThread
conv-> capture_plane.startDQThread