android_external_ffmpeg/libavcodec/v4l2_request_internal.h
Jonas Karlman 90124e1139 avcodec/v4l2request: Probe for a capable media and video device
Probe all media devices and its linked video devices to locate a video
device that support stateless decoding of the specific codec using the
V4L2 Request API.

When AVV4L2RequestDeviceContext.media_fd is a valid file descriptor only
video devices for the opened media device is probed.
E.g. using a -init_hw_device v4l2request:/dev/media1 parameter.

A video device is deemed capable when all tests pass, e.g. kernel driver
support the codec, FFmpeg v4l2-request code know about the buffer format
and kernel driver report that the frame size is supported.

A codec specific hook, post_probe, is supported to e.g. test for codec
specific limitations, PROFILE and LEVEL controls.

Basic flow for initialization follow the kernel Memory-to-memory
Stateless Video Decoder Interface > Initialization [1].

[1] https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/dev-stateless-decoder.html#initialization

Co-developed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Co-developed-by: Alex Bee <knaerzche@gmail.com>
Signed-off-by: Alex Bee <knaerzche@gmail.com>
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
2025-07-09 20:38:47 +00:00

51 lines
1.8 KiB
C

/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVCODEC_V4L2_REQUEST_INTERNAL_H
#define AVCODEC_V4L2_REQUEST_INTERNAL_H
#include <linux/media.h>
#include "internal.h"
#include "v4l2_request.h"
typedef struct V4L2RequestFrameDescriptor {
AVDRMFrameDescriptor base;
V4L2RequestBuffer capture;
} V4L2RequestFrameDescriptor;
static inline V4L2RequestContext *v4l2_request_context(AVCodecContext *avctx)
{
return (V4L2RequestContext *)avctx->internal->hwaccel_priv_data;
}
static inline V4L2RequestFrameDescriptor *v4l2_request_framedesc(AVFrame *frame)
{
return (V4L2RequestFrameDescriptor *)frame->data[0];
}
enum AVPixelFormat ff_v4l2_request_get_sw_format(struct v4l2_format *format);
int ff_v4l2_request_set_drm_descriptor(V4L2RequestFrameDescriptor *framedesc,
struct v4l2_format *format);
int ff_v4l2_request_probe(AVCodecContext *avctx, uint32_t pixelformat,
uint32_t buffersize, struct v4l2_ext_control *control,
int count);
#endif /* AVCODEC_V4L2_REQUEST_INTERNAL_H */