1*4882a593Smuzhiyun.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 2*4882a593Smuzhiyun 3*4882a593Smuzhiyun.. _mem2mem: 4*4882a593Smuzhiyun 5*4882a593Smuzhiyun******************************** 6*4882a593SmuzhiyunVideo Memory-To-Memory Interface 7*4882a593Smuzhiyun******************************** 8*4882a593Smuzhiyun 9*4882a593SmuzhiyunA V4L2 memory-to-memory device can compress, decompress, transform, or 10*4882a593Smuzhiyunotherwise convert video data from one format into another format, in memory. 11*4882a593SmuzhiyunSuch memory-to-memory devices set the ``V4L2_CAP_VIDEO_M2M`` or 12*4882a593Smuzhiyun``V4L2_CAP_VIDEO_M2M_MPLANE`` capability. Examples of memory-to-memory 13*4882a593Smuzhiyundevices are codecs, scalers, deinterlacers or format converters (i.e. 14*4882a593Smuzhiyunconverting from YUV to RGB). 15*4882a593Smuzhiyun 16*4882a593SmuzhiyunA memory-to-memory video node acts just like a normal video node, but it 17*4882a593Smuzhiyunsupports both output (sending frames from memory to the hardware) 18*4882a593Smuzhiyunand capture (receiving the processed frames from the hardware into 19*4882a593Smuzhiyunmemory) stream I/O. An application will have to setup the stream I/O for 20*4882a593Smuzhiyunboth sides and finally call :ref:`VIDIOC_STREAMON <VIDIOC_STREAMON>` 21*4882a593Smuzhiyunfor both capture and output to start the hardware. 22*4882a593Smuzhiyun 23*4882a593SmuzhiyunMemory-to-memory devices function as a shared resource: you can 24*4882a593Smuzhiyunopen the video node multiple times, each application setting up their 25*4882a593Smuzhiyunown properties that are local to the file handle, and each can use 26*4882a593Smuzhiyunit independently from the others. The driver will arbitrate access to 27*4882a593Smuzhiyunthe hardware and reprogram it whenever another file handler gets access. 28*4882a593SmuzhiyunThis is different from the usual video node behavior where the video 29*4882a593Smuzhiyunproperties are global to the device (i.e. changing something through one 30*4882a593Smuzhiyunfile handle is visible through another file handle). 31*4882a593Smuzhiyun 32*4882a593SmuzhiyunOne of the most common memory-to-memory device is the codec. Codecs 33*4882a593Smuzhiyunare more complicated than most and require additional setup for 34*4882a593Smuzhiyuntheir codec parameters. This is done through codec controls. 35*4882a593SmuzhiyunSee :ref:`mpeg-controls`. More details on how to use codec memory-to-memory 36*4882a593Smuzhiyundevices are given in the following sections. 37*4882a593Smuzhiyun 38*4882a593Smuzhiyun.. toctree:: 39*4882a593Smuzhiyun :maxdepth: 1 40*4882a593Smuzhiyun 41*4882a593Smuzhiyun dev-decoder 42*4882a593Smuzhiyun dev-encoder 43*4882a593Smuzhiyun dev-stateless-decoder 44