Commit graph

122265 commits

Author SHA1 Message Date
Venkata Atchuta Bheemeswara Sarma Darbha
5dbfbaa935 Remove libdav1d decoder from the codec_list.c
Since, this repo provides support for av1 HW decoding using v4l2_requests api. Including libdav1d in the codec list would cause the codec2 service to pick it up whenever any av1 video is played and this would leave us with software decoding and would leave out
hw decoding.

Signed-off-by: Venkata Atchuta Bheemeswara Sarma Darbha <vdarbha0473@gmail.com>
2026-04-18 20:45:21 -05:00
Venkata Atchuta Bheemeswara Sarma Darbha
135263a5bb Merge branch 'add-hevc-ext-sps' into android-16.0_r3-8.0
Signed-off-by: Venkata Atchuta Bheemeswara Sarma Darbha <vdarbha0473@gmail.com>
2026-01-06 00:03:12 -06:00
Venkata Atchuta Bheemeswara Sarma Darbha
c582efa569 android: adding more
Signed-off-by: Venkata Atchuta Bheemeswara Sarma Darbha <vdarbha0473@gmail.com>
2026-01-06 00:01:02 -06:00
Venkata Atchuta Bheemeswara Sarma Darbha
7348d2774f android: Fixing build
Some of the files need to be integrated in the Android.bp to build successfully.

Signed-off-by: Venkata Atchuta Bheemeswara Sarma Darbha <vdarbha0473@gmail.com>
2026-01-02 20:30:50 -06:00
Venkata Atchuta Bheemeswara Sarma Darbha
b27f905b2d android: Removing unnecessary -Werror parameters
Signed-off-by: Venkata Atchuta Bheemeswara Sarma Darbha <vdarbha0473@gmail.com>
2026-01-02 20:29:12 -06:00
Venkata Atchuta Bheemeswara Sarma Darbha
bda805db4d Defining V4L2_PIX_FMT_NV15 and DRM_FORMAT_NV15
Signed-off-by: Venkata Atchuta Bheemeswara Sarma Darbha <vdarbha0473@gmail.com>
2026-01-02 20:28:18 -06:00
Venkata Atchuta Bheemeswara Sarma Darbha
c3a5da97e4 android: uncommenting "used" variable from ShortTermRPS
Signed-off-by: Venkata Atchuta Bheemeswara Sarma Darbha <vdarbha0473@gmail.com>
2026-01-02 20:27:01 -06:00
Venkata Atchuta Bheemeswara Sarma Darbha
27453f4a6b android: adding v4l2_timeval_to_ns function
This function is missing from header files of aosp. hence, adding it here as it is only used by v4l2_requests.

Signed-off-by: Venkata Atchuta Bheemeswara Sarma Darbha <vdarbha0473@gmail.com>
2026-01-02 20:25:07 -06:00
dvab-sarma
fe862bef03 Merge branch 'add-hevc-ext-sps' into android-16.0_r3-8.0 2026-01-02 10:40:04 -06:00
dvab-sarma
75e2f16d7d Adding u16 delta_poc_s0(1) in ShortTermRPS
Signed-off-by: Venkata Atchuta Bheemeswara Sarma Darbha <vdarbha0473@gmail.com>
2026-01-02 10:38:46 -06:00
dvab-sarma
747873e9a6 Merge branch 'add-config' into android-16.0_r3-8.0 2026-01-02 10:26:37 -06:00
dvab-sarma
cab36b55b5 android: adding libudev in libavutil/Android.bp
Signed-off-by: dvab-sarma <vdarbha0473@gmail.com>
2026-01-02 10:25:19 -06:00
dvab-sarma
56b0f32b28 Merge branch 'add-config' into android-16.0_r3-8.0 2026-01-02 01:39:13 -06:00
dvab-sarma
a9bc34530d android: removing non-existing files
Signed-off-by: dvab-sarma <vdarbha0473@gmail.com>
2026-01-02 01:38:35 -06:00
dvab-sarma
a508de9343 Merge branch 'add-config' into android-16.0_r3-8.0 2026-01-02 01:35:46 -06:00
dvab-sarma
b71d1590be android: Correction, removing non-existing files
Signed-off-by: dvab-sarma <vdarbha0473@gmail.com>
2026-01-02 01:34:56 -06:00
dvab-sarma
5c0ec3ad33 Merge branch 'add-config' into android-16.0_r3-8.0 2026-01-02 01:26:36 -06:00
dvab-sarma
7248455519 Correction
Signed-off-by: Venkata Atchuta Bheemeswara Sarma Darbha <vdarbha0473@gmail.com>
2026-01-02 01:26:00 -06:00
dvab-sarma
3c2f7ea726 Merge branch 'add-hevc-ext-sps' into android-16.0_r3-8.0 2026-01-02 01:19:57 -06:00
dvab-sarma
0bf29f9955 Signed-off-by: Venkata Atchuta Bheemeswara Sarma Darbha <vdarbha0473@gmail.com>
android: Adding ext_sps_s(l)t_rps for v4l2_request_hevc

This adds Short & Long term ref pic set parameters which are currently used on hevc driver of vdpu381 (rk3588's Hardware Video Decoder). This needs to be removed in future, in both the kernel rkvdec driver and Userspace's FFMPEG.
2026-01-02 01:14:21 -06:00
dvab-sarma
a027a15b3e Signed-off-by: Venkata Atchuta Bheemeswara Sarma Darbha <vdarbha0473@gmail.com>
android: Converting Android.bp to follow upstream FFMPEG
2026-01-02 00:58:24 -06:00
Konsta
3507011150 android: add blueprint makefiles 2026-01-01 23:54:13 -06:00
Michael Goffioul
1a2456b0f2 android: Disable -Wbool-operation locally
The flag -Wbool-operation only triggers a build error at 1 specific
place in ffmpeg. As the flag is marked non-overridable in build/soong,
it's easier to disable the warning locally with pragma than patching the
soong repo (which would lead to possible forks in android-x86).
2026-01-01 23:50:41 -06:00
Michael Goffioul
97b8f0f68f android: Rename libavutil/time.h to libavutil/avtime.h
This avoid conflicts with libc's time.h. Using "-I bionic/libc/include"
is not working anymore, because bionic now exports the same directory
with -isystem, which supersedes the -I version (as stated in GCC doc).
This means the version of time.h in libavutil will now be found first,
via "-I external/ffmpeg/libavutil" (-I dirs are searched first, before
the -isystem ones).

Change-Id: I0d1e4276fbd0ea79d448ca96577528b296a4d462
2026-01-01 22:37:41 -06:00
dvab-sarma
992d2cd5f9 Signed-off-by: Venkata Atchuta Bheemeswara Sarma Darbha <vdarbha0473@gmail.com>
android: adding configure-android generated files
2026-01-01 22:05:15 -06:00
dvab-sarma
bc67bdd515 Signed-off-by: Venkata Atchuta Bheemeswara Sarma Darbha <vdarbha0473@gmail.com>
android: modify gitignore to add generated files
2026-01-01 22:04:29 -06:00
dvab-sarma
60866f0108 Signed-off-by: Venkata Atchuta Bheemeswara Sarma Darbha <vdarbha0473@gmail.com>
Correction
2026-01-01 21:58:21 -06:00
Konsta
d9ea3111c5 android: add rpi specific configuration 2026-01-01 20:55:10 -06:00
dvab-sarma
d4da4ba3cf Signed-off-by: Venkata Atchuta Bheemeswara Sarma Darbha <vdarbha0473@gmail.com>
FFMPEG Ver correction
2026-01-01 20:51:51 -06:00
Konsta
961e565e82 android: add configure script 2026-01-01 20:44:53 -06:00
Jonas Karlman
65d878325c FIXUP: v4l2request_select_capture_format 2025-12-22 17:24:39 +00:00
Jonas Karlman
a73da69fc8 avutil/hwcontext_v4l2request: Add support for BROADCOM_SAND128 pix fmts 2025-12-20 23:50:14 +00:00
Jernej Skrabec
f83acd4a00 avutil/hwcontext_v4l2request: Add support for AFBC_16X16_SPLIT pix fmts 2025-12-20 23:50:14 +00:00
Jonas Karlman
eea5530b31 avcodec: Add V4L2 Request API av1 hwaccel
Add a V4L2 Request API hwaccel for AV1.

Support for AV1 is enabled when Linux kernel headers declare the
control id V4L2_CID_STATELESS_AV1_FRAME, added in v6.5.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
2025-12-20 23:50:13 +00:00
Boris Brezillon
9558cb0439 avcodec: Add V4L2 Request API vp9 hwaccel
Add a V4L2 Request API hwaccel for VP9.

Support for VP9 is enabled when Linux kernel headers declare the
control id V4L2_CID_STATELESS_VP9_FRAME, added in v5.17.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Co-developed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Co-developed-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
2025-12-20 23:50:13 +00:00
Boris Brezillon
449917e1b9 avcodec: Add V4L2 Request API vp8 hwaccel
Add a V4L2 Request API hwaccel for VP8.

Support for VP8 is enabled when Linux kernel headers declare the
control id V4L2_CID_STATELESS_VP8_FRAME, added in v5.13.

Co-developed-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Co-developed-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
2025-12-20 23:50:13 +00:00
Jernej Skrabec
64dd728bd2 avcodec: Add V4L2 Request API hevc hwaccel
Add a V4L2 Request API hwaccel for HEVC, supporting both slice and
frame decoding modes.

Support for HEVC is enabled when Linux kernel headers declare the
control id V4L2_CID_STATELESS_HEVC_SPS, added in v6.0.

Co-developed-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Co-developed-by: Alex Bee <knaerzche@gmail.com>
Signed-off-by: Alex Bee <knaerzche@gmail.com>
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Co-developed-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
2025-12-20 23:50:13 +00:00
Jernej Skrabec
152b1cc6db avcodec: Add V4L2 Request API h264 hwaccel
Add a V4L2 Request API hwaccel for H.264, supporting both slice and
frame decoding modes.

Support for H.264 is enabled when Linux kernel headers declare the
control id V4L2_CID_STATELESS_H264_DECODE_MODE, added in v5.11.

Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Co-developed-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
2025-12-20 23:50:13 +00:00
Boris Brezillon
5491f1d2ac avcodec/h264dec: add ref_pic_marking and pic_order_cnt bit_size to slice context
The V4L2_CID_STATELESS_H264_DECODE_PARAMS control require following:

- dec_ref_pic_marking_bit_size
  Size in bits of the dec_ref_pic_marking() syntax element.

- pic_order_cnt_bit_size
  Combined size in bits of the picture order count related syntax
  elements: pic_order_cnt_lsb, delta_pic_order_cnt_bottom,
  delta_pic_order_cnt0, and delta_pic_order_cnt1.

Save the bit sizes while parsing for later use in hwaccel, similar to
short/long_term_ref_pic_set_size in hevcdec.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
2025-12-20 23:50:13 +00:00
Jonas Karlman
969a4e8c36 avcodec: Add V4L2 Request API mpeg2 hwaccel
Add a V4L2 Request API hwaccel for MPEG2.

Support for MPEG2 is enabled when Linux kernel headers declare the
control id V4L2_CID_STATELESS_MPEG2_SEQUENCE, added in v5.14.

This also change v4l2_request hwaccel to use autodetect in configure.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
2025-12-20 23:50:13 +00:00
Jonas Karlman
49cbf00a3a avcodec/v4l2request: Add common decode support for hwaccels
Add common support for decoding using the V4L2 Request API.

Basic flow for decoding follows the kernel Memory-to-memory Stateless
Video Decoder Interface > Decoding [1].

A codec hwaccel typically handle decoding as follow:

In start_frame next OUTPUT buffer and its related request object is
picked from a circular queue and any codec specific CONTROLs are
prepared.

In decode_slice the slice bitstream data is appended to the OUTPUT
buffer.

In end_frame a CAPTURE buffer tied to the AVFrame is queued, it will be
used as the decoding target by the driver / hw decoder. The prepared
codec specific CONTROLs are queued as part of the request object.
Finally, the request object is submitted for decoding.

In post_process the AVFrame is only returned once the CAPTURE buffer
tied to the AVFrame has been made available for dequeuing by the driver.

For slice based hw decoders only the request for the final slice of the
frame is submitted in end_frame, remaining is submitted in decode_slice.

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

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-12-20 23:50:13 +00:00
Jonas Karlman
fa79ad8b0e avcodec: Add common V4L2 Request API code
Add initial helpers for supporting V4L2 Request API hwaccels.

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

In init a hw frame ctx is created and initialized to start a new V4L2
video decoding session, initial CAPTURE buffers is pre-allocated,
OUTPUT buffers and request objects are allocated for a circular queue.

In frame_params the codec pixel format and optional codec-specific
extended controls is configured before the hw frame ctx is initialized.

In uninit any pending request is flushed before resources are released.

[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-12-20 23:50:13 +00:00
Jonas Karlman
3f72885fb2 avutil/hwcontext_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.

A video device is deemed capable when all tests pass, e.g. kernel
drivers support the coded pixel format and the frame size is supported.

Basic flow for initialization follows 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-12-20 23:50:13 +00:00
Jonas Karlman
bb10d3d5a1 avutil/hwcontext: Add hwdevice type for V4L2 Request API
Add a hwdevice type for use with V4L2 Request API stateless decoding.

AVV4L2RequestFramesContext is expected to be filled with a V4L2 coded
pixel format and optional codec-specific extended controls before an
AVHWFramesContext is initialized.

Once initialized AVV4L2RequestFramesContextInternal describe the opened
V4L2 stateless decoder session, with details about media/video file
descriptors, formats of CAPTURE/OUTPUT queues and buffer pools for
creating CAPTURE/OUTPUT buffers.

AVHWFramesContext.pool defaults to create frame descriptors around a
CAPTURE buffer, and frames are returned with AVFrame.data[0] pointing
to a AVDRMFrameDescriptor and AVFrame.data[1] the CAPTURE buffer index.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
2025-12-20 23:45:35 +00:00
Leo Izen
784aa09fa8
avcodec/exif: parse additional EXIF IFDs
Most EXIF metadata is in IFD0 and most EXIF payloads only contain
one IFD, but it is possible for there to be more IFDs after the
existing trailing one. exiftool and similar software report these IFDs
as IFD1, IFD2, etc. This commit reads those additional IFDs and attaches
them as dummy entries in the top-level IFD ranging from 0xFFFC down to
0xFFED, which are unused by the EXIF spec. The EXIF API is only able to
return and work with a single IFD, so by attaching it as a subdirectory
this metadata can be preserved.

This is done transparently through the read/write process. Upon parsing
an additional IFD1, it will be attached, but it will be written with
av_exif_write after IFD0 rather than as a subdirectory, as intended.

Existing files without more than one IFD, i.e. most files, will be unaffected
by this change, as well as API clients looking to parse specific fields, but
now more metadata is parsed and written, rather than simply being discarded
as trailing data.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-12-20 11:53:23 -05:00
Leo Izen
105b6fcd9c
avcodec/exif: avoid leaking EXIF metadata upon parse failure
Before this commit, exif_parse_ifd_list didn't free *ifd upon failure,
relying on the caller to do so instead. We only guarded some of the
calls against this function, not all of them, so sometimes it leaked.

This commit fixes this, so exif_parse_ifd_list freeds *ifd upon failure
so callers do not have to guard its invocation with a free wrapper.

Fixes: ossfuzz 440747118: Integer-overflow in av_strerror

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-12-20 11:53:21 -05:00
Niklas Haas
7505264b6a swscale/ops: update comment on SWS_COMP_EXACT
That the integer is "in-range" is implied by the min/max range tracking,
not the flag itself.
2025-12-20 13:52:45 +00:00
Niklas Haas
1d0fd7fabf swscale/ops: categorize ops by type compatibility
This is a more useful grouping than the previous, somewhat arbitrary one.
2025-12-20 13:52:45 +00:00
Niklas Haas
94777ed2eb swscale/ops_chain: fix comment 2025-12-20 13:52:45 +00:00
Niklas Haas
75ba2bf457 swscale/ops: correctly truncate on ff_sws_apply_op_q(SWS_OP_RSHIFT)
Instead of using a "precise" division, simulate the actual truncation.

Note that the division by `den` is unneeded in principle because the
denominator *should* always be 1 for an integer, but this way we don't
explode if the user should happen to pass `4/2` or something.

Fixes a lot of unnecessary clamps w.r.t. xv36, e.g.:

 xv36be -> yuv444p12be:
   [u16 XXXX -> ++++] SWS_OP_READ         : 4 elem(s) packed >> 0
   [u16 ...X -> ++++] SWS_OP_SWAP_BYTES
   [u16 ...X -> ++++] SWS_OP_SWIZZLE      : 1023
   [u16 ...X -> ++++] SWS_OP_RSHIFT       : >> 4
-  [u16 ...X -> ++++] SWS_OP_CONVERT      : u16 -> f32
-  [f32 ...X -> ++++] SWS_OP_MIN          : x <= {4095 4095 4095 _}
-  [f32 ...X -> ++++] SWS_OP_CONVERT      : f32 -> u16
   [u16 ...X -> ++++] SWS_OP_SWAP_BYTES
   [u16 ...X -> ++++] SWS_OP_WRITE        : 3 elem(s) planar >> 0
     (X = unused, + = exact, 0 = zero)
2025-12-20 13:52:45 +00:00