162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 262306a36Sopenharmony_ci 362306a36Sopenharmony_ci.. _mem2mem: 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci******************************** 662306a36Sopenharmony_ciVideo Memory-To-Memory Interface 762306a36Sopenharmony_ci******************************** 862306a36Sopenharmony_ci 962306a36Sopenharmony_ciA V4L2 memory-to-memory device can compress, decompress, transform, or 1062306a36Sopenharmony_ciotherwise convert video data from one format into another format, in memory. 1162306a36Sopenharmony_ciSuch memory-to-memory devices set the ``V4L2_CAP_VIDEO_M2M`` or 1262306a36Sopenharmony_ci``V4L2_CAP_VIDEO_M2M_MPLANE`` capability. Examples of memory-to-memory 1362306a36Sopenharmony_cidevices are codecs, scalers, deinterlacers or format converters (i.e. 1462306a36Sopenharmony_ciconverting from YUV to RGB). 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ciA memory-to-memory video node acts just like a normal video node, but it 1762306a36Sopenharmony_cisupports both output (sending frames from memory to the hardware) 1862306a36Sopenharmony_ciand capture (receiving the processed frames from the hardware into 1962306a36Sopenharmony_cimemory) stream I/O. An application will have to setup the stream I/O for 2062306a36Sopenharmony_ciboth sides and finally call :ref:`VIDIOC_STREAMON <VIDIOC_STREAMON>` 2162306a36Sopenharmony_cifor both capture and output to start the hardware. 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ciMemory-to-memory devices function as a shared resource: you can 2462306a36Sopenharmony_ciopen the video node multiple times, each application setting up their 2562306a36Sopenharmony_ciown properties that are local to the file handle, and each can use 2662306a36Sopenharmony_ciit independently from the others. The driver will arbitrate access to 2762306a36Sopenharmony_cithe hardware and reprogram it whenever another file handler gets access. 2862306a36Sopenharmony_ciThis is different from the usual video node behavior where the video 2962306a36Sopenharmony_ciproperties are global to the device (i.e. changing something through one 3062306a36Sopenharmony_cifile handle is visible through another file handle). 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ciOne of the most common memory-to-memory device is the codec. Codecs 3362306a36Sopenharmony_ciare more complicated than most and require additional setup for 3462306a36Sopenharmony_citheir codec parameters. This is done through codec controls. 3562306a36Sopenharmony_ciSee :ref:`codec-controls`. More details on how to use codec memory-to-memory 3662306a36Sopenharmony_cidevices are given in the following sections. 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci.. toctree:: 3962306a36Sopenharmony_ci :maxdepth: 1 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci dev-decoder 4262306a36Sopenharmony_ci dev-encoder 4362306a36Sopenharmony_ci dev-stateless-decoder 44