How can I efficiently pass captured data to memory allocated by VPU_EncGetMem?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How can I efficiently pass captured data to memory allocated by VPU_EncGetMem?

1,474件の閲覧回数
kuri
Contributor III

I would like to inquire about a method to efficiently pass captured data to the memory allocated by VPU_EncGetMem.

Is it possible to achieve this without using address assignment?

I am using v4l and V4L2_MEMORY_MMAP for capturing.

The memory for encoding is allocated using VPU_EncGetMem.

When I use memcpy to copy the data to the memory allocated by VPU_EncGetMem, encoding works fine. However, if I assign the memory address of the memory allocated by VPU_EncGetMem directly to input_buf, the encoded video appears green.

OK:

memcpy(pInputVirt, input_buf, input_size);

 

NG: Encoded video appears green.

pInputVirt = input_buf;

 

pInputVirt: Memory allocated by VPU_EncGetMem for encoding.
input_buf: Memory allocated by mmap for capturing.

CPU: i.MX8MPlus

 

0 件の賞賛
返信
4 返答(返信)

1,439件の閲覧回数
Dhruvit
NXP TechSupport
NXP TechSupport

Hi @kuri,

I hope you are doing well.
 
To avoid memory-related issues we would recommend using the memcpy rather than the address assignment. Because the function VPU_EncGetMem uses the constant pointers for the address.
 
Thanks & Regards,
Dhruvit Vasavada
0 件の賞賛
返信

1,373件の閲覧回数
kuri
Contributor III

@Dhruvit 

After researching, the following findings have been made:

(1) Copy from the address allocated by mmap to a global variable (414720 bytes) → Takes approximately 30ms for the copy operation.

(2) Copy within the global variable (414720 bytes) → Completes the copy in approximately 2ms.

The slow copying from the capture buffer allocated by mmap is identified as the issue.

The mmap is allocated with the following options:

addr = mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset)

<Questions> - Do you have any insights into the reasons for the slow copying from the mmap address? - Could you provide any methods to speed up the copying from the mmap address?

 

Best Regards

0 件の賞賛
返信

1,417件の閲覧回数
kuri
Contributor III

Dear @Dhruvit

Thank you for your response.
It takes about 30ms to copy Full HD YUYV data using memcpy.
I need to achieve 2-channel recording at Full HD and 30fps, but the processing speed is a problem.
Is there any good solution?

Best Regards

0 件の賞賛
返信

1,352件の閲覧回数
Dhruvit
NXP TechSupport
NXP TechSupport
Hi @kuri,

I hope you are doing well
 
To improve the speed, one can use a DMA channel for data transfer. For more information to enable the DMA, kindly refer to the file devicetree/bindings/dma/dma.txt from the kernel source.
 
Thanks & Regards,
Dhruvit Vasavada

0 件の賞賛
返信