[mmapi] Please merge two libtegrav4l2.so that modify different issues

Hello everyone:

I use R28.2 release on TX1.

I need to merge the following posts into one libtegrav4l2.so, because these two bugs need to be fixed in my project.

  1. Memory leaks due to encoding re-initialization

https://devtalk.nvidia.com/default/topic/1035330/jetson-tx2/-mmapi-r28-2-r28-1-deinitplane-of-nvvideoencoder-memory-leak-/1

  1. Conv errors caused by re-initialization

https://devtalk.nvidia.com/default/topic/1038225/-r28-2-mmapi-crop-rects-right-out-of-boundary/#5275045

Thank You!

1,Compare R28.2 demo ‘01_video_encode’ to rewrite my program

use lib from https://devtalk.nvidia.com/default/topic/1038225/-r28-2-mmapi-crop-rects-right-out-of-boundary/#5275045

Strangely, my program has no memory leaks, I made the following modifications, the enc’s Output_plane DQ and Q operations are completed sequentially in one thread, and the start and exit mechanisms use the new event mechanism (setEncoderCommand func)

enc.output_plane–DMA_BUF
enc.capture_plane–MMAP

2,But the revised ‘01_video_encode’ still has a memory leak, is it because the demo mmap out the dma_buf ?

The code is in the attachment

./video_encode Night_1280x720_60.yuv 1280 720 H265 out.h265 -br 2000000 -ifi 25 -fps 25 1 -hpt 1
video_encode_main.cpp (34.9 KB)

Hi Li,
Please try the attachment.
r28_2_1_libtegrav4l2.zip (60.9 KB)