mbox

[FFmpeg-devel,0/5] Add V4L2 request API H.264 hwaccel

Message ID 20201209202513.27449-1-jonas@kwiboo.se
Headers show

Message

Jonas Karlman Dec. 9, 2020, 8:25 p.m. UTC
Hello,

This is a follow up to an old RFC [1], adding a new hwaccel using the
V4L2 request API for stateless decoding of H.264.

The V4L2 ctrls needed for stateless decoding of H.264 is targeted for being
de-staged and moved to public linux uapi with linux v5.11.

De-stage of MPEG-2 and VP8 stateless codec APIs will hopefully follow in
v5.12, HEVC and VP9 will follow later.

These patches must be used with latest linux-media or linux-next tree.
De-stage H.264 stateless codec APIs pull-request [2] has been merged into
linux-media tree and is on track for inclusion in v5.11.

Patch 1 contains a new buffer pool function av_buffer_pool_flush() that will
free all available buffers in a buffer pool. This can be used to save memory
when seeking in e.g. H.264 where a new hwaccel instance may get init:ed before
the current one is uninit. The V4L2 request API hwaccel use this function
to minimize memory usage.

Patch 2 adds common code used in the hwaccel, libudev is used to enumerate
media and video devices to locate devices that support stateless decoding.

Patch 3-4 add idr_pic_id, ref_pic_marking and pic_order_cnt bit_size in
H.264 slice context for use by the V4L2 request API H.264 hwaccel.

Patch 5 adds the V4L2 request API H.264 hwaccel.

Use --enable-v4l2-request --enable-libdrm --enable-libudev to enable hwaccel.

Playback can be tested using kodi-gbm or mpv with any supported device using
cedrus, hantro or rkvdec drivers located in staging.

This hwaccel has in one form or another been used in LibreELEC community and
nightly images since Dec 20th 2018.

A copy of this series can also be found at [3].

[1] http://ffmpeg.org/pipermail/ffmpeg-devel/2019-April/242316.html
[2] https://patchwork.linuxtv.org/project/linux-media/patch/d68da172-b251-000f-653d-38a8a4c7b715@xs4all.nl/
[3] https://github.com/Kwiboo/FFmpeg/commits/v4l2-request-hwaccel-master-stable

Regards,
Jonas

Boris Brezillon (1):
  h264dec: add ref_pic_marking and pic_order_cnt bit_size to slice
    context

Ezequiel Garcia (1):
  h264dec: add idr_pic_id to slice context

Jernej Skrabec (1):
  h264dec: add V4L2 request API hwaccel

Jonas Karlman (2):
  avutil/buffer: add av_buffer_pool_flush()
  avcodec: add common V4L2 request API code

 Changelog                      |   1 +
 configure                      |  15 +
 doc/APIchanges                 |   3 +
 libavcodec/Makefile            |   2 +
 libavcodec/h264_slice.c        |  12 +-
 libavcodec/h264dec.c           |   3 +
 libavcodec/h264dec.h           |   3 +
 libavcodec/hwaccels.h          |   1 +
 libavcodec/hwconfig.h          |   2 +
 libavcodec/v4l2_request.c      | 987 +++++++++++++++++++++++++++++++++
 libavcodec/v4l2_request.h      |  77 +++
 libavcodec/v4l2_request_h264.c | 457 +++++++++++++++
 libavcodec/version.h           |   4 +-
 libavutil/buffer.c             |  13 +
 libavutil/buffer.h             |   5 +
 libavutil/version.h            |   2 +-
 16 files changed, 1582 insertions(+), 5 deletions(-)
 create mode 100644 libavcodec/v4l2_request.c
 create mode 100644 libavcodec/v4l2_request.h
 create mode 100644 libavcodec/v4l2_request_h264.c