OpenMAX encoder and HW buffers

Hi,

I’m implementing 10bit H265 encoding using OpenMAX API (since V4L doesn’t yet support 10bit YUV format) on L4T 32.1 and having trouble using HW buffers as input. I have successfully encoded ordinary CPU buffers, but with NvBuffer input it seems impossible. I have tried 2 options after setting NVX_PARAM_USENVBUFFER parameter:

  1. requesting buffers from encoder using OMX_AllocateBuffer
  2. allocating buffers myself using NvBufferCreateEx and OMX_UseBuffer

With first option I’m unable to fill the buffers with data - I need to create an EGL image from returned NvBuffer (in order to use it from CUDA), which requires fd, but ExtractFdFromNvBuffer function returns zero. With second option I get the following error when trying to encode the first frame:

NvMMLiteVideoEncDoWork: Surface resolution (0 x 0) smaller than encode resolution (2064 x 1544)
VENC: NvMMLiteVideoEncDoWork: 4207: BlockSide error 0x4
Event_BlockError from 0BlockHevcEnc : Error code - 4
Sending error event from 0BlockHevcEnc

Is there a way to resolve either of these problems?

Also somewhat related question - why OpenMAX encoder requires at least 6 allocated input and output buffers, when V4L works fine with 4? In result OpenMAX requires more memory, which creates some problems.

Hi,
On r32.2, we support

$ gst-launch-1.0 videotestsrc num-buffers=300 ! video/x-raw,format=P010_10LE ! nvvidconv ! 'video/x-raw(memory:NVMM)' ! nvv4l2h265enc ! h265parse ! matroskamux ! filesink location=a.mkv

Please upgrade to r32.2 and give it a try. The format is P010_10LE

Hi DaneLLL,

release came just in time:)) Indeed 10bit encoding works fine via V4L2, including HW buffers.

Could you confirm for me that the following memory consumption numbers is normal for TX2 H265 encoder?

  • Picture size: 3960x3002 P010
  • Bitrate: CBR 10Mbit/s
  • HW preset: SLOW
  • Input buffers: 4x 34MiB = 136 MiB
  • Output buffers: 3x 17MiB = 51 MiB
  • Memory consumption: 738 MiB

So around 551 MiB is used by encoder for some internal purposes. Is it right? Is this number affected by anything other than input picture size? I’m interested in lowering memory consumption if it is at all possible.

Hi,
You may check

# cat sys/kernel/debug/nvmap/iovmm/clients

It shows working buffers/memory used by processes.